Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 

311 Zeilen
10 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.iformall.mapper.WxCouponChannelMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponChannel">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  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="INTEGER" property="business" />
  13. <result column="sub_business" jdbcType="INTEGER" property="subBusiness" />
  14. <result column="show_begin_time" jdbcType="TIMESTAMP" property="showBeginTime" />
  15. <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" />
  16. <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
  17. <result column="status" jdbcType="INTEGER" property="status" />
  18. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  19. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  20. <result column="sub_target_id" jdbcType="BIGINT" property="subTargetId" />
  21. <result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
  22. <result column="tt_qr_code" jdbcType="VARCHAR" property="ttQrCode"/>
  23. <result column="tt_spu_id" jdbcType="VARCHAR" property="ttSpuId"/>
  24. </resultMap>
  25. <sql id="allColumns">
  26. distinct cc.`id`,cc.`tenant_id`,cc.`parent_tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`show_begin_time`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code,cc.tt_qr_code,cc.tt_spu_id
  27. </sql>
  28. <sql id="dynamicWhereConditions">
  29. where 1=1
  30. <if test="null != couponStatus">
  31. and c.status = #{couponStatus}
  32. </if>
  33. <if test="null != status ">
  34. and cc.status = #{status}
  35. </if>
  36. <if test="null == status ">
  37. and cc.status = 0
  38. </if>
  39. <if test=" null != id ">
  40. and cc.`id` = #{id}
  41. </if>
  42. <if test=" null != tenantId and '' != tenantId">
  43. and cc.`tenant_id` = #{tenantId}
  44. </if>
  45. <if test=" null != parentTenantId and '' != parentTenantId">
  46. and cc.`parent_tenant_id` = #{parentTenantId}
  47. </if>
  48. <if test=" null != couponId ">
  49. and cc.`coupon_id` = #{couponId}
  50. </if>
  51. <if test=" null != type ">
  52. and cc.`type` = #{type}
  53. </if>
  54. <if test=" null != title and ''!= title">
  55. and cc.`title` like concat('%', #{title},'%')
  56. </if>
  57. <if test=" null != targetAd ">
  58. and cc.`target_ad` = #{targetAd}
  59. </if>
  60. <if test=" null != business ">
  61. and cc.`business` = #{business}
  62. </if>
  63. <if test=" null != subBusiness ">
  64. and cc.`sub_business` = #{subBusiness}
  65. </if>
  66. <if test=" null != showBeginTime ">
  67. and cc.`show_begin_time` &lt;= #{showBeginTime}
  68. </if>
  69. <if test=" null != startdate and null!=enddate">
  70. and cc.`create_date` between #{startdate} and #{enddate}
  71. </if>
  72. <if test=" null != status ">
  73. and cc.`status` = #{status}
  74. </if>
  75. <if test=" null != createDate ">
  76. and cc.`create_date` = #{createDate}
  77. </if>
  78. <if test=" null != updateDate ">
  79. and cc.`update_date` = #{updateDate}
  80. </if>
  81. <if test=" null != subTargetId ">
  82. and cc.`sub_target_id` = #{subTargetId}
  83. </if>
  84. <if test=" null != ttSpuId and ''!= ttSpuId">
  85. and cc.`tt_spu_id` = #{ttSpuId}
  86. </if>
  87. <if test=" null != supportTransfer ">
  88. and c.`support_transfer` = #{supportTransfer}
  89. </if>
  90. <if test=" null != userCredit ">
  91. and c.`credit_price` &lt;= #{userCredit}
  92. </if>
  93. <if test=" null != sourceType ">
  94. and c.`source_type` = #{sourceType}
  95. </if>
  96. <if test=" null != merchantId ">
  97. and cm.`merchant_id` = #{merchantId}
  98. </if>
  99. <if test=" null != ids ">
  100. and cc.id in
  101. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  102. #{idItem}
  103. </foreach>
  104. </if>
  105. <if test=" null != couponIds ">
  106. and cc.coupon_id in
  107. <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")">
  108. #{couponIdsItem}
  109. </foreach>
  110. </if>
  111. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  112. </sql>
  113. <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  114. select <include refid="allColumns" /> from wx_coupon_channel cc where id = #{id} and tenant_id = #{tenantId}
  115. </select>
  116. <select id="findList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="BaseResultMap">
  117. select <include refid="allColumns" /> from wx_coupon_channel cc
  118. <include refid="dynamicWhereConditions" />
  119. </select>
  120. <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
  121. update wx_coupon_channel
  122. set status=#{status}, update_date=#{updateDate}
  123. where coupon_id=#{couponId}
  124. <if test=" null != tenantId and '' != tenantId">
  125. and `tenant_id` = #{tenantId}
  126. </if>
  127. <if test=" null != parentTenantId and '' != parentTenantId">
  128. and `parent_tenant_id` = #{parentTenantId}
  129. </if>
  130. </update>
  131. <update id="updateEndTimeByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
  132. update wx_coupon_channel
  133. set end_time = #{endTime}
  134. where coupon_id=#{couponId}
  135. <if test=" null != tenantId and '' != tenantId">
  136. and `tenant_id` = #{tenantId}
  137. </if>
  138. <if test=" null != parentTenantId and '' != parentTenantId">
  139. and `parent_tenant_id` = #{parentTenantId}
  140. </if>
  141. </update>
  142. <select id="findVoDetail" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  143. select
  144. cc.id,cc.coupon_id,cc.target_ad,cc.begin_time,cc.end_time,cc.tenant_id,cc.parent_tenant_id,cc.qr_code,cc.tt_qr_code
  145. from wx_coupon_channel cc where cc.id = #{id} and cc.tenant_id = #{tenantId}
  146. </select>
  147. <select id="findVoStatusDetail" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  148. select cc.id,cc.coupon_id
  149. from wx_coupon_channel cc
  150. where cc.id = #{id} and cc.tenant_id = #{tenantId}
  151. </select>
  152. <select id="countCoupon" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="java.lang.Integer">
  153. select count(distinct coupon_id) from wx_coupon_channel cc
  154. <include refid="dynamicWhereConditions" />
  155. </select>
  156. <select id="countCouponChannel" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="java.lang.Integer">
  157. select count(1) from wx_coupon_channel cc
  158. <include refid="dynamicWhereConditions" />
  159. </select>
  160. <update id="offExpiriedCouponChannelByEndTime" parameterType="String">
  161. update wx_coupon_channel SET status = 1, update_date = now()
  162. where status = 0 and tenant_id = #{tenantId} and end_time &lt; now()
  163. </update>
  164. <update id="offExpiriedCouponChannelByValidDate">
  165. update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
  166. where cc.status = 0 and cc.tenant_id = #{tenantId} and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date &lt; now()
  167. </update>
  168. <update id="offExpiriedCouponChannelByCouponStatus">
  169. update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
  170. where cc.status = 0 and cc.tenant_id = #{tenantId} and cc.coupon_id = c.id and c.status = 1
  171. </update>
  172. <update id="offExpiriedCouponChannel2ByEndTime">
  173. update wx_coupon_channel SET status = 1, update_date = now()
  174. where status = 0 and tenant_id = #{tenantId} and target_ad = 2 and end_time &lt; now()
  175. </update>
  176. <delete id="delByTopic" parameterType="com.iformall.domain.po.WxTopic">
  177. update wx_coupon_channel set status = 1 where sub_target_id = #{id}
  178. </delete>
  179. <select id="findQrcodeEmptyList" resultType="com.iformall.domain.po.WxCouponChannel">
  180. select * from wx_coupon_channel where (qr_code is null or tt_qr_code is null)
  181. </select>
  182. <update id="cardDefer">
  183. update wx_coupon_channel set end_time = #{endTime} where coupon_id = #{couponId} and tenant_id = #{tenantId} and target_ad = 5 and type = 100
  184. </update>
  185. <select id="newfindCList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="BaseResultMap">
  186. select cc.`id`,cc.`tenant_id`,cc.`parent_tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,
  187. cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`show_begin_time`,cc.`begin_time`,cc.`end_time`,cc.`status`,
  188. cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code
  189. from wx_coupon_channel cc
  190. where cc.status = 0
  191. <if test=" null != id ">
  192. and cc.`id` = #{id}
  193. </if>
  194. <if test=" null != tenantId and '' != tenantId">
  195. and cc.`tenant_id` = #{tenantId}
  196. </if>
  197. <if test=" null != parentTenantId and '' != parentTenantId">
  198. and cc.`parent_tenant_id` = #{parentTenantId}
  199. </if>
  200. <if test=" null != couponId ">
  201. and cc.`coupon_id` = #{couponId}
  202. </if>
  203. <if test=" null != type ">
  204. and cc.`type` = #{type}
  205. </if>
  206. <if test=" null != title and ''!= title">
  207. and cc.`title` like concat('%', #{title},'%')
  208. </if>
  209. <if test=" null != targetAd ">
  210. and cc.`target_ad` = #{targetAd}
  211. </if>
  212. <if test=" null != business ">
  213. and cc.`business` = #{business}
  214. </if>
  215. <if test=" null != subBusiness ">
  216. and cc.`sub_business` = #{subBusiness}
  217. </if>
  218. <if test=" null != showBeginTime ">
  219. and cc.`show_begin_time` &lt;= #{showBeginTime}
  220. </if>
  221. <if test=" null != startdate and null!=enddate">
  222. and cc.`create_date` between #{startdate} and #{enddate}
  223. </if>
  224. <if test=" null != status ">
  225. and cc.`status` = #{status}
  226. </if>
  227. <if test=" null != createDate ">
  228. and cc.`create_date` = #{createDate}
  229. </if>
  230. <if test=" null != updateDate ">
  231. and cc.`update_date` = #{updateDate}
  232. </if>
  233. <if test=" null != subTargetId ">
  234. and cc.`sub_target_id` = #{subTargetId}
  235. </if>
  236. <if test=" null != ids ">
  237. and cc.id in
  238. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  239. #{idItem}
  240. </foreach>
  241. </if>
  242. <if test=" null != couponIds ">
  243. and cc.coupon_id in
  244. <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")">
  245. #{couponIdsItem}
  246. </foreach>
  247. </if>
  248. <if test=" null != targetAds ">
  249. and cc.target_ad in
  250. <foreach collection="targetAds" index="index" item="targetAdsItem" open="(" separator="," close=")">
  251. #{targetAdsItem}
  252. </foreach>
  253. </if>
  254. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  255. </select>
  256. </mapper>