Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

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