|
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.simple.mapper.WxCouponChannelMapper">
- <resultMap id="BaseResultMap" type="com.simple.domain.po.WxCouponChannel">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
- <result column="business" jdbcType="VARCHAR" property="business" />
- <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" />
- <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="sub_target_id" jdbcType="BIGINT" property="subTargetId" />
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`merchant_id`,`coupon_id`,`coupon_status`,`type`,`title`,`target_ad`,`business`,`begin_time`,`end_time`,`status`,`create_date`,`update_date`,`sub_target_id`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != tenantId ">
- and `tenant_id` like concat('%', #{tenantId},'%')
- </if>
-
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
-
- <if test=" null != couponId ">
- and `coupon_id` = #{couponId}
- </if>
-
-
- <if test=" null != type ">
- and `type` = #{type}
- </if>
-
- <if test=" null != title ">
- and `title` like concat('%', #{title},'%')
- </if>
-
- <if test=" null != targetAd ">
- and `target_ad` = #{targetAd}
- </if>
-
- <if test=" null != business and '0' == business">
- and JSON_CONTAINS(`business`->'$',JSON_ARRAY('0'))
- </if>
- <if test=" null != business and '0' != business">
- and (JSON_CONTAINS(`business`->'$',JSON_ARRAY('0')) or (JSON_CONTAINS(`business`->'$',JSON_ARRAY(#{business}))))
- </if>
-
- <if test=" null != beginTime ">
- and `begin_time` = #{beginTime}
- </if>
-
- <if test=" null != endTime ">
- and `end_time` = #{endTime}
- </if>
-
- <if test=" null != status ">
- and `status` = #{status}
- </if>
-
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
- <if test=" null != subTargetId ">
- and `sub_target_id` = #{subTargetId}
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != couponIds ">
- and coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")">
- #{couponIdsItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </sql>
-
- <select id="findList" parameterType="com.simple.domain.po.WxCouponChannel" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_channel
- <include refid="dynamicWhereConditions" />
- </select>
- <select id="findListByCouponIds" parameterType="com.simple.domain.po.WxCouponChannel" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_channel
- <include refid="dynamicWhereConditions" />
- </select>
-
-
-
-
- <select id="findVoList" parameterType="com.simple.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap">
- select <include refid="allColumns" /> from wx_coupon_channel
- <include refid="dynamicWhereConditions" />
- </select>
-
- <update id="updateStatusByCouponId" parameterType="com.simple.domain.po.WxCouponChannel">
- update wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId}
- </update>
-
-
- <resultMap id="CouponChannelVoMap" type="com.simple.domain.vo.WxCouponChannelVo">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
- <result column="business" jdbcType="VARCHAR" property="business" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="sub_target_id" jdbcType="BIGINT" property="subTargetId" />
- </resultMap>
-
-
-
- <update id="offExpiriedCouponChannelByEndTime">
- update wx_coupon_channel SET status = 1, update_date = now()
- where status = 0 and end_time < now()
-
- </update>
-
- <update id="offExpiriedCouponChannelByValidDate">
- update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
- where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and valid_end_date < now()
- </update>
-
- <update id="offExpiriedCouponChannelByCouponStatus">
- update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
- where cc.status = 0 and cc.coupon_id = c.id and c.status = 1
- </update>
-
- </mapper>
|