You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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