Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

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