Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

156 строки
5.5 KiB

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.simple.mapper.WxCouponChannelMapper">
  4. <resultMap id="BaseResultMap" type="com.simple.domain.po.WxCouponChannel">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  8. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  9. <result column="type" jdbcType="INTEGER" property="type" />
  10. <result column="title" jdbcType="VARCHAR" property="title" />
  11. <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
  12. <result column="business" jdbcType="VARCHAR" property="business" />
  13. <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" />
  14. <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
  15. <result column="status" jdbcType="INTEGER" property="status" />
  16. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  17. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  18. <result column="sub_target_id" jdbcType="BIGINT" property="subTargetId" />
  19. </resultMap>
  20. <sql id="allColumns">
  21. `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`
  22. </sql>
  23. <sql id="dynamicWhereConditions">
  24. where 1 = 1
  25. <if test=" null != id ">
  26. and `id` = #{id}
  27. </if>
  28. <if test=" null != tenantId ">
  29. and `tenant_id` like concat('%', #{tenantId},'%')
  30. </if>
  31. <if test=" null != merchantId ">
  32. and `merchant_id` = #{merchantId}
  33. </if>
  34. <if test=" null != couponId ">
  35. and `coupon_id` = #{couponId}
  36. </if>
  37. <if test=" null != type ">
  38. and `type` = #{type}
  39. </if>
  40. <if test=" null != title ">
  41. and `title` like concat('%', #{title},'%')
  42. </if>
  43. <if test=" null != targetAd ">
  44. and `target_ad` = #{targetAd}
  45. </if>
  46. <if test=" null != business and '0' == business">
  47. and JSON_CONTAINS(`business`->'$',JSON_ARRAY('0'))
  48. </if>
  49. <if test=" null != business and '0' != business">
  50. and (JSON_CONTAINS(`business`->'$',JSON_ARRAY('0')) or (JSON_CONTAINS(`business`->'$',JSON_ARRAY(#{business}))))
  51. </if>
  52. <if test=" null != beginTime ">
  53. and `begin_time` = #{beginTime}
  54. </if>
  55. <if test=" null != endTime ">
  56. and `end_time` = #{endTime}
  57. </if>
  58. <if test=" null != status ">
  59. and `status` = #{status}
  60. </if>
  61. <if test=" null != createDate ">
  62. and `create_date` = #{createDate}
  63. </if>
  64. <if test=" null != updateDate ">
  65. and `update_date` = #{updateDate}
  66. </if>
  67. <if test=" null != subTargetId ">
  68. and `sub_target_id` = #{subTargetId}
  69. </if>
  70. <if test=" null != ids ">
  71. and id in
  72. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  73. #{idItem}
  74. </foreach>
  75. </if>
  76. <if test=" null != couponIds ">
  77. and coupon_id in
  78. <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")">
  79. #{couponIdsItem}
  80. </foreach>
  81. </if>
  82. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  83. </sql>
  84. <select id="findList" parameterType="com.simple.domain.po.WxCouponChannel" resultMap="BaseResultMap">
  85. select <include refid="allColumns" /> from wx_coupon_channel
  86. <include refid="dynamicWhereConditions" />
  87. </select>
  88. <select id="findListByCouponIds" parameterType="com.simple.domain.po.WxCouponChannel" resultMap="BaseResultMap">
  89. select <include refid="allColumns" /> from wx_coupon_channel
  90. <include refid="dynamicWhereConditions" />
  91. </select>
  92. <select id="findVoList" parameterType="com.simple.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap">
  93. select <include refid="allColumns" /> from wx_coupon_channel
  94. <include refid="dynamicWhereConditions" />
  95. </select>
  96. <update id="updateStatusByCouponId" parameterType="com.simple.domain.po.WxCouponChannel">
  97. update wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId}
  98. </update>
  99. <resultMap id="CouponChannelVoMap" type="com.simple.domain.vo.WxCouponChannelVo">
  100. <id column="id" jdbcType="BIGINT" property="id" />
  101. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  102. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  103. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  104. <result column="type" jdbcType="INTEGER" property="type" />
  105. <result column="title" jdbcType="VARCHAR" property="title" />
  106. <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
  107. <result column="business" jdbcType="VARCHAR" property="business" />
  108. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  109. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  110. <result column="sub_target_id" jdbcType="BIGINT" property="subTargetId" />
  111. </resultMap>
  112. <update id="offExpiriedCouponChannelByEndTime">
  113. update wx_coupon_channel SET status = 1, update_date = now()
  114. where status = 0 and end_time &lt; now()
  115. </update>
  116. <update id="offExpiriedCouponChannelByValidDate">
  117. update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
  118. where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and valid_end_date &lt; now()
  119. </update>
  120. <update id="offExpiriedCouponChannelByCouponStatus">
  121. update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
  122. where cc.status = 0 and cc.coupon_id = c.id and c.status = 1
  123. </update>
  124. </mapper>