You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

122 lines
4.4 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. <insert id="insertCouponPasswds" parameterType="java.util.List">
  72. INSERT INTO wx_coupon_password (`id`,`coupon_id`,`coupon_short`,`password`,`status`,`create_date`,`update_date`)
  73. VALUES
  74. <foreach collection="list" item="item" index="index" separator=",">
  75. (
  76. #{item.id},#{item.couponId},#{item.couponShort},#{item.password},#{item.status},
  77. #{item.createDate},#{item.updateDate}
  78. )
  79. </foreach>
  80. </insert>
  81. <update id="updateStatusByCouponId" parameterType="Long">
  82. update wx_coupon_password
  83. set status=4, update_date=now()
  84. where status != 3 and tenant_id = #{tenantId} and coupon_id=#{couponId}
  85. </update>
  86. <select id="findCouponGroupList" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap">
  87. select `coupon_id`,`coupon_short`
  88. from wx_coupon_password
  89. where `tenant_id` = #{tenantId}
  90. group by `coupon_id`,`coupon_short`
  91. </select>
  92. <resultMap id="CouponCountInfoMap" type="com.iformall.domain.vo.WxCouponPasswordCountInfoVO">
  93. <result column="coupon_count" jdbcType="BIGINT" property="couponCount"/>
  94. <result column="title" jdbcType="VARCHAR" property="couponName"/>
  95. <result column="coupon_id" jdbcType="BIGINT" property="couponId"/>
  96. </resultMap>
  97. <select id="findCouponCountInfo" parameterType="com.iformall.domain.po.WxCouponPassword"
  98. resultMap="CouponCountInfoMap">
  99. select cp.coupon_id,c.title,cp.coupon_count from
  100. (select count(*) as coupon_count,coupon_id from wx_coupon_password
  101. where tenant_id#{tenantId} and status=0) cp
  102. inner join wx_coupon c on cp.coupon_id = c.id
  103. where c.tenant_id=#{tenantId} and c.status=1
  104. <if test=" null != couponId ">
  105. and cp.`coupon_id` = #{couponId}
  106. </if>
  107. group by cp.coupon_id
  108. </select>
  109. </mapper>