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.
 
 
 
 
 

301 lines
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. </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. <update id="updateEndTimeByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
  94. update wx_coupon_channel
  95. set end_time = #{endTime}
  96. where coupon_id=#{couponId}
  97. <if test=" null != tenantId ">
  98. and tenant_id = #{tenantId}
  99. </if>
  100. </update>
  101. <sql id="CouponChannelVoColumns">
  102. <include refid="allColumns" />,
  103. c.remain_inventory,c.inventory,c.cover_img,c.title,c.sub_title,c.sale_price,
  104. c.use_price,c.price,c.unit,c.use_limit_quantity,c.send_type,c.support_transfer,c.press_limit_num,c.auto_refund,
  105. c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.credit_price
  106. </sql>
  107. <resultMap id="CouponChannelVoMap" type="com.iformall.domain.vo.WxCouponChannelVo">
  108. <id column="id" jdbcType="BIGINT" property="id" />
  109. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  110. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  111. <result column="type" jdbcType="INTEGER" property="type" />
  112. <result column="title" jdbcType="VARCHAR" property="title" />
  113. <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
  114. <result column="business" jdbcType="VARCHAR" property="business" />
  115. <result column="sub_business" jdbcType="INTEGER" property="subBusiness" />
  116. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  117. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  118. <result column="sub_target_id" jdbcType="BIGINT" property="subTargetId" />
  119. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  120. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  121. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  122. <result column="title" jdbcType="VARCHAR" property="title"/>
  123. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  124. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  125. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  126. <result column="price" jdbcType="INTEGER" property="price"/>
  127. <result column="unit" jdbcType="INTEGER" property="unit"/>
  128. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  129. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  130. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  131. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  132. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
  133. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  134. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  135. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  136. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  137. <result column="qr_code" property="qrCode"/>
  138. <collection column="{productId=coupon_id}" property="merchantVoList"
  139. ofType="com.iformall.domain.vo.WxMerchantVo"
  140. javaType="java.util.List"
  141. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" >
  142. </collection>
  143. </resultMap>
  144. <select id="findVoList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap">
  145. select <include refid="CouponChannelVoColumns" />
  146. from wx_coupon_channel cc
  147. left join wx_coupon c on cc.coupon_id = c.id
  148. <include refid="dynamicWhereConditions" />
  149. </select>
  150. <select id="findVoListByMerchant" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap">
  151. select <include refid="CouponChannelVoColumns" />
  152. ,mer.qr_code
  153. from wx_coupon_channel cc
  154. join wx_coupon_merchant cm
  155. on cm.product_id = cc.coupon_id
  156. and cm.status = 0
  157. <if test="merchantId != null">
  158. and cm.merchant_id=#{merchantId}
  159. </if>
  160. left join wx_coupon c on cc.coupon_id = c.id
  161. left join wx_merchant mer on cm.merchant_id = mer.id
  162. where cc.`target_ad` in (1,2,5,6,7)
  163. <if test="status != null">
  164. and cc.status=#{status}
  165. </if>
  166. <if test=" null != tenantId ">
  167. and cc.tenant_id = #{tenantId}
  168. </if>
  169. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  170. </select>
  171. <sql id="WxCouponCVoColumn">
  172. cc.id,cc.coupon_id,cc.target_ad,cc.begin_time,cc.end_time,
  173. 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,
  174. c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,
  175. c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,
  176. c.create_date,c.update_date,c.business,c.sub_business,c.support_transfer,c.press_limit_num, c.auto_refund,c.credit_price
  177. </sql>
  178. <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
  179. <id column="id" jdbcType="BIGINT" property="id"/>
  180. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  181. <result column="type" jdbcType="INTEGER" property="type" />
  182. <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
  183. <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime"/>
  184. <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
  185. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  186. <result column="type" jdbcType="INTEGER" property="type"/>
  187. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  188. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  189. <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
  190. <result column="title" jdbcType="VARCHAR" property="title"/>
  191. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  192. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  193. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  194. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  195. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  196. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  197. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  198. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  199. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  200. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  201. <result column="price" jdbcType="INTEGER" property="price"/>
  202. <result column="unit" jdbcType="INTEGER" property="unit"/>
  203. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  204. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  205. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  206. <result column="status" jdbcType="INTEGER" property="status"/>
  207. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  208. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  209. <result column="business" jdbcType="INTEGER" property="business"/>
  210. <result column="subBusiness" jdbcType="INTEGER" property="subBusiness"/>
  211. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  212. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  213. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
  214. <collection column="{productId=coupon_id}" property="merchantVoList"
  215. ofType="com.iformall.domain.vo.WxMerchantVo"
  216. javaType="java.util.List"
  217. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  218. </collection>
  219. </resultMap>
  220. <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">
  221. select
  222. <include refid="WxCouponCVoColumn"/>
  223. from wx_coupon_channel cc
  224. left join wx_coupon c on cc.coupon_id = c.id
  225. where cc.id = #{id}
  226. </select>
  227. <select id="countCoupon" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="java.lang.Integer">
  228. select count(distinct coupon_id) from wx_coupon_channel cc
  229. <include refid="dynamicWhereConditions" />
  230. </select>
  231. <select id="countCouponChannel" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="java.lang.Integer">
  232. select count(*) from wx_coupon_channel cc
  233. <include refid="dynamicWhereConditions" />
  234. </select>
  235. <update id="offExpiriedCouponChannelByEndTime">
  236. update wx_coupon_channel SET status = 1, update_date = now()
  237. where status = 0 and end_time &lt; now()
  238. </update>
  239. <update id="offExpiriedCouponChannelByValidDate">
  240. update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
  241. where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date &lt; now()
  242. </update>
  243. <update id="offExpiriedCouponChannelByCouponStatus">
  244. update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
  245. where cc.status = 0 and cc.coupon_id = c.id and c.status = 1
  246. </update>
  247. <update id="offExpiriedCouponChannel2ByEndTime">
  248. update wx_coupon_channel SET status = 1, update_date = now()
  249. where status = 0 and target_ad = 2 and end_time &lt; now()
  250. </update>
  251. <delete id="delByTopic" parameterType="com.iformall.domain.po.WxTopic">
  252. delete from wx_coupon_channel where sub_target_id = #{id}
  253. </delete>
  254. <select id="findQrcodeEmptyList" resultType="com.iformall.domain.po.WxCouponChannel">
  255. select * from wx_coupon_channel where qr_code is null
  256. </select>
  257. </mapper>