Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

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