Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

219 rader
9.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.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 != beginTime and null != endTime and null != targetAd and 2 == targetAd">
  46. and cc.`begin_time` &lt; now()
  47. and cc.`end_time` &gt; now()
  48. </if>
  49. <if test=" null != status ">
  50. and cc.`status` = #{status}
  51. </if>
  52. <if test=" null != createDate ">
  53. and cc.`create_date` = #{createDate}
  54. </if>
  55. <if test=" null != updateDate ">
  56. and cc.`update_date` = #{updateDate}
  57. </if>
  58. <if test=" null != subTargetId ">
  59. and cc.`sub_target_id` = #{subTargetId}
  60. </if>
  61. <if test=" null != ids ">
  62. and cc.id in
  63. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  64. #{idItem}
  65. </foreach>
  66. </if>
  67. <if test=" null != couponIds ">
  68. and cc.coupon_id in
  69. <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")">
  70. #{couponIdsItem}
  71. </foreach>
  72. </if>
  73. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  74. </sql>
  75. <select id="findList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="BaseResultMap">
  76. select <include refid="allColumns" /> from wx_coupon_channel cc
  77. <include refid="dynamicWhereConditions" />
  78. </select>
  79. <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
  80. update wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId}
  81. </update>
  82. <sql id="CouponChannelVoColumns">
  83. <include refid="allColumns" />,
  84. c.remain_inventory,c.inventory,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.use_limit_quantity,c.send_type
  85. </sql>
  86. <resultMap id="CouponChannelVoMap" type="com.iformall.domain.vo.WxCouponChannelVo">
  87. <id column="id" jdbcType="BIGINT" property="id" />
  88. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  89. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  90. <result column="type" jdbcType="INTEGER" property="type" />
  91. <result column="title" jdbcType="VARCHAR" property="title" />
  92. <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
  93. <result column="business" jdbcType="VARCHAR" property="business" />
  94. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  95. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  96. <result column="sub_target_id" jdbcType="BIGINT" property="subTargetId" />
  97. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  98. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  99. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  100. <result column="title" jdbcType="VARCHAR" property="title"/>
  101. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  102. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  103. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  104. <result column="price" jdbcType="INTEGER" property="price"/>
  105. <result column="unit" jdbcType="INTEGER" property="unit"/>
  106. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  107. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  108. <collection column="{productId=coupon_id}" property="merchantVoList"
  109. ofType="com.iformall.domain.vo.WxMerchantVo"
  110. javaType="java.util.List"
  111. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" >
  112. </collection>
  113. </resultMap>
  114. <select id="findVoList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap">
  115. select <include refid="CouponChannelVoColumns" />
  116. from wx_coupon_channel cc
  117. left join wx_coupon c on cc.coupon_id = c.id
  118. <include refid="dynamicWhereConditions" />
  119. </select>
  120. <sql id="WxCouponCVoColumn">
  121. cc.id,cc.coupon_id,cc.target_ad,cc.begin_time,cc.end_time,
  122. c.tenant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business
  123. </sql>
  124. <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
  125. <id column="id" jdbcType="BIGINT" property="id"/>
  126. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  127. <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
  128. <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime"/>
  129. <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
  130. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  131. <result column="type" jdbcType="INTEGER" property="type"/>
  132. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  133. <result column="title" jdbcType="VARCHAR" property="title"/>
  134. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  135. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  136. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  137. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  138. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  139. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  140. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  141. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  142. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  143. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  144. <result column="price" jdbcType="INTEGER" property="price"/>
  145. <result column="unit" jdbcType="INTEGER" property="unit"/>
  146. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  147. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  148. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  149. <result column="status" jdbcType="INTEGER" property="status"/>
  150. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  151. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  152. <result column="business" jdbcType="INTEGER" property="business"/>
  153. <collection column="{productId=coupon_id}" property="merchantVoList"
  154. ofType="com.iformall.domain.vo.WxMerchantVo"
  155. javaType="java.util.List"
  156. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  157. </collection>
  158. </resultMap>
  159. <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">
  160. select
  161. <include refid="WxCouponCVoColumn"/>
  162. from wx_coupon_channel cc
  163. left join wx_coupon c on cc.coupon_id = c.id
  164. where cc.id = #{id}
  165. </select>
  166. <select id="countCoupon" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="java.lang.Integer">
  167. select count(distinct coupon_id) from wx_coupon_channel cc
  168. <include refid="dynamicWhereConditions" />
  169. </select>
  170. <update id="offExpiriedCouponChannelByEndTime">
  171. update wx_coupon_channel SET status = 1, update_date = now()
  172. where status = 0 and end_time &lt; now()
  173. </update>
  174. <update id="offExpiriedCouponChannelByValidDate">
  175. update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
  176. where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date &lt; now()
  177. </update>
  178. <update id="offExpiriedCouponChannelByCouponStatus">
  179. update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
  180. where cc.status = 0 and cc.coupon_id = c.id and c.status = 1
  181. </update>
  182. <update id="offExpiriedCouponChannel2ByEndTime">
  183. update wx_coupon_channel SET status = 1, update_date = now()
  184. where status = 0 and target_ad = 2 and end_time &lt; now()
  185. </update>
  186. </mapper>