后台服务
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

WxCouponPasswordMapper.xml 7.2 KiB

2年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.WxCouponPasswordMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponPassword">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  8. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  9. <result column="coupon_short" jdbcType="VARCHAR" property="couponShort" />
  10. <result column="password" jdbcType="VARCHAR" property="password" />
  11. <result column="status" jdbcType="INTEGER" property="status" />
  12. <result column="sended_phone" jdbcType="VARCHAR" property="sendedPhone" />
  13. <result column="card_id" jdbcType="BIGINT" property="cardId" />
  14. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  15. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  16. <result column="expire_date" jdbcType="TIMESTAMP" property="expireDate" />
  17. <result column="present_id" jdbcType="TIMESTAMP" property="presentId"/>
  18. </resultMap>
  19. <sql id="allColumns">
  20. `id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_short`,`password`,`status`,`sended_phone`,`card_id`,`create_date`,`update_date`,`expire_date`,`present_id`
  21. </sql>
  22. <sql id="dynamicWhereConditions">
  23. where 1 = 1
  24. <if test=" null != id ">
  25. and `id` = #{id}
  26. </if>
  27. <if test=" null != tenantId and '' != tenantId">
  28. and `tenant_id` = #{tenantId}
  29. </if>
  30. <if test=" null != parentTenantId and '' != parentTenantId">
  31. and `parent_tenant_id` = #{parentTenantId}
  32. </if>
  33. <if test=" null != couponId ">
  34. and `coupon_id` = #{couponId}
  35. </if>
  36. <if test=" null != couponShort ">
  37. and `coupon_short` = #{couponShort}
  38. </if>
  39. <if test=" null != password ">
  40. and `password` = #{password}
  41. </if>
  42. <if test=" null != status ">
  43. and `status` = #{status}
  44. </if>
  45. <if test=" null != sendedPhone ">
  46. and `sended_phone` = #{sendedPhone}
  47. </if>
  48. <if test=" null != cardId ">
  49. and `card_id` = #{cardId}
  50. </if>
  51. <if test=" null != createDate ">
  52. and `create_date` = #{createDate}
  53. </if>
  54. <if test=" null != updateDate ">
  55. and `update_date` = #{updateDate}
  56. </if>
  57. <if test=" null != expireDate ">
  58. and `expire_date` > #{expireDate}
  59. </if>
  60. <if test=" null != presentId ">
  61. and `present_id` = #{presentId}
  62. </if>
  63. <if test=" null != ids ">
  64. and id in
  65. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  66. #{idItem}
  67. </foreach>
  68. </if>
  69. <if test=" null != statusStr and ''!=statusStr">
  70. and status in (${statusStr})
  71. </if>
  72. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  73. </sql>
  74. <select id="findList" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap">
  75. select <include refid="allColumns" />
  76. from wx_coupon_password
  77. <include refid="dynamicWhereConditions" />
  78. </select>
  79. <select id="findAvaPasswordListByCouponId" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap">
  80. select <include refid="allColumns" />
  81. from wx_coupon_password
  82. <where>
  83. <if test=" null != tenantId and '' != tenantId">
  84. and `tenant_id` = #{tenantId}
  85. </if>
  86. <if test=" null != parentTenantId and '' != parentTenantId">
  87. and `parent_tenant_id` = #{parentTenantId}
  88. </if>
  89. <if test=" null != couponId ">
  90. and `coupon_id` = #{couponId}
  91. </if>
  92. <if test=" null != expireDate ">
  93. and `expire_date` > #{expireDate}
  94. </if>
  95. </where>
  96. </select>
  97. <insert id="insertCouponPasswds" parameterType="java.util.List">
  98. INSERT INTO wx_coupon_password (`id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_short`,`password`,`status`,`create_date`,`update_date`)
  99. VALUES
  100. <foreach collection="list" item="item" index="index" separator=",">
  101. (
  102. #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.couponId},#{item.couponShort},#{item.password},#{item.status},
  103. #{item.createDate},#{item.updateDate}
  104. )
  105. </foreach>
  106. </insert>
  107. <update id="disableByCouponId" parameterType="Long">
  108. update wx_coupon_password
  109. set status=4, update_date=now()
  110. where status != 3 and coupon_id=#{couponId}
  111. </update>
  112. <update id="downloadByCouponId" parameterType="Long">
  113. update wx_coupon_password
  114. set status=1, update_date=now(), expire_date=date_add(now(),interval 365 DAY)
  115. where status=0 and coupon_id=#{couponId}
  116. </update>
  117. <select id="findCouponGroupList" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap">
  118. select `coupon_id`,`coupon_short`
  119. from wx_coupon_password
  120. where 1=1
  121. <if test=" null != tenantId and '' != tenantId">
  122. and `tenant_id` = #{tenantId}
  123. </if>
  124. <if test=" null != parentTenantId and '' != parentTenantId">
  125. and `parent_tenant_id` = #{parentTenantId}
  126. </if>
  127. group by `coupon_id`,`coupon_short`
  128. </select>
  129. <resultMap id="CouponCountInfoMap" type="com.iformall.domain.vo.WxCouponPasswordCountInfoVO">
  130. <result column="coupon_count" jdbcType="BIGINT" property="couponCount"/>
  131. <result column="title" jdbcType="VARCHAR" property="couponName"/>
  132. <result column="coupon_id" jdbcType="BIGINT" property="couponId"/>
  133. <result column="price" jdbcType="VARCHAR" property="price"/>
  134. </resultMap>
  135. <select id="findCouponCountInfo" parameterType="com.iformall.domain.po.WxCouponPassword"
  136. resultMap="CouponCountInfoMap">
  137. select cp.coupon_id,c.title,c.price,cp.coupon_count from
  138. (select count(*) as coupon_count,coupon_id from wx_coupon_password
  139. where status=0
  140. <if test=" null != tenantId and '' != tenantId">
  141. and `tenant_id` = #{tenantId}
  142. </if>
  143. <if test=" null != parentTenantId and '' != parentTenantId">
  144. and `parent_tenant_id` = #{parentTenantId}
  145. </if>
  146. group by coupon_id) cp
  147. inner join wx_coupon c on cp.coupon_id = c.id
  148. where c.status=0 and c.put_apply_status in(0,2)
  149. <if test=" null != tenantId and '' != tenantId">
  150. and c.`tenant_id` = #{tenantId}
  151. </if>
  152. <if test=" null != parentTenantId and '' != parentTenantId">
  153. and c.`parent_tenant_id` = #{parentTenantId}
  154. </if>
  155. <if test=" null != couponId ">
  156. and cp.`coupon_id` = #{couponId}
  157. </if>
  158. group by cp.coupon_id
  159. order by c.create_date desc
  160. </select>
  161. <update id="updateStatus" parameterType="java.util.List">
  162. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  163. update wx_coupon_password set
  164. status=1,sended_phone=#{item.sendedPhone},update_date=now(),expire_date=date_add(now(),interval 30 DAY),
  165. present_id=#{item.presentId}
  166. where id = #{item.id}
  167. </foreach>
  168. </update>
  169. <update id="updatePostpone">
  170. update wx_coupon_password
  171. set expire_date=#{expireDate}
  172. where coupon_id=#{couponId} and status=1
  173. <if test=" null != tenantId and '' != tenantId">
  174. and `tenant_id` = #{tenantId}
  175. </if>
  176. <if test=" null != parentTenantId and '' != parentTenantId">
  177. and `parent_tenant_id` = #{parentTenantId}
  178. </if>
  179. </update>
  180. <update id="updateExpiredTime" parameterType="map">
  181. update wx_coupon_password set expire_date = #{expiredTime} , update_date = now() where coupon_id = #{couponId}
  182. </update>
  183. </mapper>