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.
 
 
 
 
 

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