No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

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