|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?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.iformall.mapper.WxCouponSendMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponSend">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <result column="send_type" jdbcType="INTEGER" property="sendType" />
- <result column="conditions" jdbcType="VARCHAR" property="conditions" />
- <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="send_sms" jdbcType="INTEGER" property="sendSms" />
- <result column="operator_id" jdbcType="INTEGER" property="operatorId" />
- </resultMap>
- <sql id="columns">
- `id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`title`,`send_type`,`conditions`,`status`,`create_date`,`update_date`,`send_sms`,`operator_id`,
- cs.conditions -> '$.merchantSend' as merchantSend,
- cs.conditions -> '$.merchantLnventory' as merchantLnventory,
- cs.conditions -> '$.merchantRemain' as merchantRemain
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and cs.id = #{id}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and cs.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cs.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != couponId ">
- and cs.coupon_id = #{couponId}
- </if>
-
- <if test=" null != title ">
- and cs.title like concat('%', #{title},'%')
- </if>
-
- <if test=" null != sendType ">
- and cs.send_type = #{sendType}
- </if>
-
- <if test=" null != status ">
- and cs.status = #{status}
- </if>
-
- <if test=" null != createDate ">
- and cs.create_date = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and cs.update_date = #{updateDate}
- </if>
- <if test=" null != merchantName and ''!=merchantName">
- and cs.conditions -> '$.title' like concat('%',#{merchantName},'%')
- </if>
- <if test=" null != merchantId and ''!=merchantId ">
- and cs.conditions->'$.id' = concat(#{merchantId},'')
- </if>
- <if test=" null != merchantRemain">
- and cs.conditions -> '$.merchantRemain'> #{merchantRemain}
- </if>
- <if test=" null != couponIds ">
- and cs.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
- #{couponIdItem}
- </foreach>
- </if>
- <if test=" null != ids ">
- and cs.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sendSms ">
- and cs.send_sms = #{sendSms}
- </if>
- <if test=" null != sortColumns">
- order by ${sortColumns}
- </if>
- <if test=" null != sortCol">
- order by ${sortCol}
- </if>
- </sql>
-
- <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select <include refid="columns" /> from wx_coupon_send cs where cs.id = #{id} and cs.tenant_id = #{tenantId}
- </select>
-
- <delete id="deleteById" parameterType="java.util.HashMap">
- delete from wx_coupon_send cs where cs.id = #{id} and cs.tenant_id = #{tenantId}
- </delete>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCouponSend" resultMap="BaseResultMap">
- select <include refid="columns" />
- from wx_coupon_send cs
- <include refid="dynamicWhereConditions" />
- </select>
-
- <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
- update wx_coupon_send set status=#{status}
- where coupon_id=#{couponId}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </update>
-
- <update id="updateBirthdayConfig" parameterType="com.iformall.domain.po.WxCouponSend">
- update wx_coupon_send
- set conditions=#{conditions},update_date = #{updateDate}
- where send_type = #{sendType}
- and tenant_id = #{tenantId}
- </update>
-
- <update id="offExpiriedCouponSendByCouponStatus" parameterType="String">
- update wx_coupon_send cs, wx_coupon c
- set cs.status=1, cs.update_date = now()
- where c.id = cs.coupon_id and cs.status = 0 and cs.tenant_id = #{tenantId} and
- ((c.status = 1) or (c.valid_type = 1 and c.valid_end_date < now()))
- </update>
- <update id="reduceMerchantSend" parameterType="java.util.HashMap">
- update wx_coupon_send
- SET conditions = JSON_SET(conditions, '$.merchantRemain', #{merchantRemain} - #{number} , '$.merchantSend',
- #{merchantSend} + #{number})
- where id = #{id}
- and conditions -> '$.merchantRemain' = #{merchantRemain}
- </update>
- <update id="backMerchantSend">
- update wx_coupon_send
- SET conditions = JSON_SET(conditions, '$.merchantRemain', #{merchantRemain} + #{number} , '$.merchantSend',
- #{merchantSend} - #{number})
- where id = #{id}
- and conditions -> '$.merchantRemain' = #{merchantRemain}
- </update>
- </mapper>
|