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.
 
 
 
 
 

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