Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

308 lignes
13 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="coupon_id" jdbcType="BIGINT" property="couponId" />
  8. <result column="type" jdbcType="INTEGER" property="type" />
  9. <result column="title" jdbcType="VARCHAR" property="title" />
  10. <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
  11. <result column="business" jdbcType="INTEGER" property="business" />
  12. <result column="sub_business" jdbcType="INTEGER" property="subBusiness" />
  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. <result column="qr_code" property="qrCode"/>
  20. </resultMap>
  21. <sql id="allColumns">
  22. cc.`id`,cc.`tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code
  23. </sql>
  24. <sql id="dynamicWhereConditions">
  25. where cc.status = 0
  26. <if test=" null != id ">
  27. and cc.`id` = #{id}
  28. </if>
  29. <if test=" null != tenantId ">
  30. and cc.`tenant_id` = #{tenantId}
  31. </if>
  32. <if test=" null != couponId ">
  33. and cc.`coupon_id` = #{couponId}
  34. </if>
  35. <if test=" null != type ">
  36. and cc.`type` = #{type}
  37. </if>
  38. <if test=" null != title and ''!= title">
  39. and cc.`title` like concat('%', #{title},'%')
  40. </if>
  41. <if test=" null != targetAd ">
  42. and cc.`target_ad` = #{targetAd}
  43. </if>
  44. <if test=" null != business ">
  45. and cc.`business` = #{business}
  46. </if>
  47. <if test=" null != subBusiness ">
  48. and cc.`sub_business` = #{subBusiness}
  49. </if>
  50. <if test=" null != startdate and null!=enddate">
  51. and cc.`create_date` between #{startdate} and #{enddate}
  52. </if>
  53. <if test=" null != status ">
  54. and cc.`status` = #{status}
  55. </if>
  56. <if test=" null != createDate ">
  57. and cc.`create_date` = #{createDate}
  58. </if>
  59. <if test=" null != updateDate ">
  60. and cc.`update_date` = #{updateDate}
  61. </if>
  62. <if test=" null != subTargetId ">
  63. and cc.`sub_target_id` = #{subTargetId}
  64. </if>
  65. <if test=" null != supportTransfer ">
  66. and c.`support_transfer` = #{supportTransfer}
  67. </if>
  68. <if test=" null != ids ">
  69. and cc.id in
  70. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  71. #{idItem}
  72. </foreach>
  73. </if>
  74. <if test=" null != couponIds ">
  75. and cc.coupon_id in
  76. <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")">
  77. #{couponIdsItem}
  78. </foreach>
  79. </if>
  80. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  81. </sql>
  82. <select id="findList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="BaseResultMap">
  83. select <include refid="allColumns" /> from wx_coupon_channel cc
  84. <include refid="dynamicWhereConditions" />
  85. </select>
  86. <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
  87. update wx_coupon_channel
  88. set status=#{status}, update_date=#{updateDate}
  89. where coupon_id=#{couponId}
  90. <if test=" null != tenantId ">
  91. and tenant_id = #{tenantId}
  92. </if>
  93. </update>
  94. <update id="updateEndTimeByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
  95. update wx_coupon_channel
  96. set end_time = #{endTime}
  97. where coupon_id=#{couponId}
  98. <if test=" null != tenantId ">
  99. and tenant_id = #{tenantId}
  100. </if>
  101. </update>
  102. <sql id="CouponChannelVoColumns">
  103. <include refid="allColumns" />,
  104. c.remain_inventory,c.inventory,c.cover_img,c.title,c.sub_title,c.sale_price,
  105. c.use_price,c.price,c.unit,c.use_limit_quantity,c.send_type,c.support_transfer,c.press_limit_num,c.auto_refund,c.conditions,
  106. c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.credit_price
  107. </sql>
  108. <resultMap id="CouponChannelVoMap" type="com.iformall.domain.vo.WxCouponChannelVo">
  109. <id column="id" jdbcType="BIGINT" property="id" />
  110. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  111. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  112. <result column="type" jdbcType="INTEGER" property="type" />
  113. <result column="title" jdbcType="VARCHAR" property="title" />
  114. <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
  115. <result column="business" jdbcType="VARCHAR" property="business" />
  116. <result column="sub_business" jdbcType="INTEGER" property="subBusiness" />
  117. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  118. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  119. <result column="sub_target_id" jdbcType="BIGINT" property="subTargetId" />
  120. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  121. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  122. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  123. <result column="title" jdbcType="VARCHAR" property="title"/>
  124. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  125. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  126. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  127. <result column="price" jdbcType="INTEGER" property="price"/>
  128. <result column="unit" jdbcType="INTEGER" property="unit"/>
  129. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  130. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  131. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  132. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  133. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
  134. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  135. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  136. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  137. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  138. <result column="qr_code" property="qrCode"/>
  139. <result column="conditions" jdbcType="VARCHAR" property="conditions" />
  140. <collection column="{productId=coupon_id}" property="merchantVoList"
  141. ofType="com.iformall.domain.vo.WxMerchantVo"
  142. javaType="java.util.List"
  143. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" >
  144. </collection>
  145. </resultMap>
  146. <select id="findVoList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap">
  147. select <include refid="CouponChannelVoColumns" />
  148. from wx_coupon_channel cc
  149. left join wx_coupon c on cc.coupon_id = c.id
  150. <include refid="dynamicWhereConditions" />
  151. </select>
  152. <select id="findVoListByMerchant" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap">
  153. select <include refid="CouponChannelVoColumns" />
  154. ,mer.qr_code
  155. from wx_coupon_channel cc
  156. join wx_coupon_merchant cm
  157. on cm.product_id = cc.coupon_id
  158. and cm.status = 0
  159. <if test="merchantId != null">
  160. and cm.merchant_id=#{merchantId}
  161. </if>
  162. left join wx_coupon c on cc.coupon_id = c.id
  163. left join wx_merchant mer on cm.merchant_id = mer.id
  164. where cc.`target_ad` in (1,2,5,6,7)
  165. <if test="status != null">
  166. and cc.status=#{status}
  167. </if>
  168. <if test=" null != tenantId ">
  169. and cc.tenant_id = #{tenantId}
  170. </if>
  171. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  172. </select>
  173. <sql id="WxCouponCVoColumn">
  174. cc.id,cc.coupon_id,cc.target_ad,cc.begin_time,cc.end_time,
  175. c.tenant_id,c.type,c.cover_img,c.cover_picture,c.detail_picture,c.title,c.sub_title,c.sale_price,c.use_price,
  176. c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,
  177. c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,
  178. c.create_date,c.update_date,c.business,c.sub_business,c.support_transfer,c.press_limit_num, c.auto_refund,c.credit_price,c.conditions,
  179. cc.qr_code
  180. </sql>
  181. <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
  182. <id column="id" jdbcType="BIGINT" property="id"/>
  183. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  184. <result column="type" jdbcType="INTEGER" property="type" />
  185. <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
  186. <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime"/>
  187. <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
  188. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  189. <result column="type" jdbcType="INTEGER" property="type"/>
  190. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  191. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  192. <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
  193. <result column="title" jdbcType="VARCHAR" property="title"/>
  194. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  195. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  196. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  197. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  198. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  199. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  200. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  201. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  202. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  203. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  204. <result column="price" jdbcType="INTEGER" property="price"/>
  205. <result column="unit" jdbcType="INTEGER" property="unit"/>
  206. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  207. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  208. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  209. <result column="status" jdbcType="INTEGER" property="status"/>
  210. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  211. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  212. <result column="business" jdbcType="INTEGER" property="business"/>
  213. <result column="subBusiness" jdbcType="INTEGER" property="subBusiness"/>
  214. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  215. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  216. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
  217. <result column="qr_code" property="qrCode"/>
  218. <result column="conditions" jdbcType="VARCHAR" property="conditions" />
  219. <collection column="{productId=coupon_id}" property="merchantVoList"
  220. ofType="com.iformall.domain.vo.WxMerchantVo"
  221. javaType="java.util.List"
  222. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  223. </collection>
  224. </resultMap>
  225. <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">
  226. select
  227. <include refid="WxCouponCVoColumn"/>
  228. from wx_coupon_channel cc
  229. left join wx_coupon c on cc.coupon_id = c.id
  230. where cc.id = #{id}
  231. </select>
  232. <select id="countCoupon" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="java.lang.Integer">
  233. select count(distinct coupon_id) from wx_coupon_channel cc
  234. <include refid="dynamicWhereConditions" />
  235. </select>
  236. <select id="countCouponChannel" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="java.lang.Integer">
  237. select count(*) from wx_coupon_channel cc
  238. <include refid="dynamicWhereConditions" />
  239. </select>
  240. <update id="offExpiriedCouponChannelByEndTime">
  241. update wx_coupon_channel SET status = 1, update_date = now()
  242. where status = 0 and end_time &lt; now()
  243. </update>
  244. <update id="offExpiriedCouponChannelByValidDate">
  245. update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
  246. where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date &lt; now()
  247. </update>
  248. <update id="offExpiriedCouponChannelByCouponStatus">
  249. update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
  250. where cc.status = 0 and cc.coupon_id = c.id and c.status = 1
  251. </update>
  252. <update id="offExpiriedCouponChannel2ByEndTime">
  253. update wx_coupon_channel SET status = 1, update_date = now()
  254. where status = 0 and target_ad = 2 and end_time &lt; now()
  255. </update>
  256. <delete id="delByTopic" parameterType="com.iformall.domain.po.WxTopic">
  257. update wx_coupon_channel set status = 1 where sub_target_id = #{id}
  258. </delete>
  259. <select id="findQrcodeEmptyList" resultType="com.iformall.domain.po.WxCouponChannel">
  260. select * from wx_coupon_channel where qr_code is null
  261. </select>
  262. </mapper>