后台服务
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

147 рядки
5.3 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.WxCouponSendMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponSend">
  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="coupon_id" jdbcType="BIGINT" property="couponId" />
  9. <result column="title" jdbcType="VARCHAR" property="title" />
  10. <result column="send_type" jdbcType="INTEGER" property="sendType" />
  11. <result column="conditions" jdbcType="VARCHAR" property="conditions" />
  12. <result column="status" jdbcType="INTEGER" property="status" />
  13. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  14. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  15. <result column="send_sms" jdbcType="INTEGER" property="sendSms" />
  16. <result column="operator_id" jdbcType="INTEGER" property="operatorId" />
  17. </resultMap>
  18. <sql id="columns">
  19. `id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`title`,`send_type`,`conditions`,`status`,`create_date`,`update_date`,`send_sms`,`operator_id`,
  20. cs.conditions -> '$.merchantSend' as merchantSend,
  21. cs.conditions -> '$.merchantLnventory' as merchantLnventory,
  22. cs.conditions -> '$.merchantRemain' as merchantRemain
  23. </sql>
  24. <sql id="dynamicWhereConditions">
  25. where 1 = 1
  26. <if test=" null != id ">
  27. and cs.id = #{id}
  28. </if>
  29. <if test=" null != tenantId and '' != tenantId">
  30. and cs.`tenant_id` = #{tenantId}
  31. </if>
  32. <if test=" null != parentTenantId and '' != parentTenantId">
  33. and cs.`parent_tenant_id` = #{parentTenantId}
  34. </if>
  35. <if test=" null != couponId ">
  36. and cs.coupon_id = #{couponId}
  37. </if>
  38. <if test=" null != title ">
  39. and cs.title like concat('%', #{title},'%')
  40. </if>
  41. <if test=" null != sendType ">
  42. and cs.send_type = #{sendType}
  43. </if>
  44. <if test=" null != status ">
  45. and cs.status = #{status}
  46. </if>
  47. <if test=" null != createDate ">
  48. and cs.create_date = #{createDate}
  49. </if>
  50. <if test=" null != updateDate ">
  51. and cs.update_date = #{updateDate}
  52. </if>
  53. <if test=" null != merchantName and ''!=merchantName">
  54. and cs.conditions -> '$.title' like concat('%',#{merchantName},'%')
  55. </if>
  56. <if test=" null != merchantId and ''!=merchantId ">
  57. and cs.conditions->'$.id' = concat(#{merchantId},'')
  58. </if>
  59. <if test=" null != merchantRemain">
  60. and cs.conditions -> '$.merchantRemain'> #{merchantRemain}
  61. </if>
  62. <if test=" null != couponIds ">
  63. and cs.coupon_id in
  64. <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
  65. #{couponIdItem}
  66. </foreach>
  67. </if>
  68. <if test=" null != ids ">
  69. and cs.id in
  70. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  71. #{idItem}
  72. </foreach>
  73. </if>
  74. <if test=" null != sendSms ">
  75. and cs.send_sms = #{sendSms}
  76. </if>
  77. <if test=" null != sortColumns">
  78. order by ${sortColumns}
  79. </if>
  80. <if test=" null != sortCol">
  81. order by ${sortCol}
  82. </if>
  83. </sql>
  84. <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  85. select <include refid="columns" /> from wx_coupon_send cs where cs.id = #{id} and cs.tenant_id = #{tenantId}
  86. </select>
  87. <delete id="deleteById" parameterType="java.util.HashMap">
  88. delete from wx_coupon_send cs where cs.id = #{id} and cs.tenant_id = #{tenantId}
  89. </delete>
  90. <select id="findList" parameterType="com.iformall.domain.po.WxCouponSend" resultMap="BaseResultMap">
  91. select <include refid="columns" />
  92. from wx_coupon_send cs
  93. <include refid="dynamicWhereConditions" />
  94. </select>
  95. <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
  96. update wx_coupon_send set status=#{status}
  97. where coupon_id=#{couponId}
  98. <if test=" null != tenantId and '' != tenantId">
  99. and `tenant_id` = #{tenantId}
  100. </if>
  101. <if test=" null != parentTenantId and '' != parentTenantId">
  102. and `parent_tenant_id` = #{parentTenantId}
  103. </if>
  104. </update>
  105. <update id="updateBirthdayConfig" parameterType="com.iformall.domain.po.WxCouponSend">
  106. update wx_coupon_send
  107. set conditions=#{conditions},update_date = #{updateDate}
  108. where send_type = #{sendType}
  109. and tenant_id = #{tenantId}
  110. </update>
  111. <update id="offExpiriedCouponSendByCouponStatus" parameterType="String">
  112. update wx_coupon_send cs, wx_coupon c
  113. set cs.status=1, cs.update_date = now()
  114. where c.id = cs.coupon_id and cs.status = 0 and cs.tenant_id = #{tenantId} and
  115. ((c.status = 1) or (c.valid_type = 1 and c.valid_end_date &lt; now()))
  116. </update>
  117. <update id="reduceMerchantSend" parameterType="java.util.HashMap">
  118. update wx_coupon_send
  119. SET conditions = JSON_SET(conditions, '$.merchantRemain', #{merchantRemain} - #{number} , '$.merchantSend',
  120. #{merchantSend} + #{number})
  121. where id = #{id}
  122. and conditions -> '$.merchantRemain' = #{merchantRemain}
  123. </update>
  124. <update id="backMerchantSend">
  125. update wx_coupon_send
  126. SET conditions = JSON_SET(conditions, '$.merchantRemain', #{merchantRemain} + #{number} , '$.merchantSend',
  127. #{merchantSend} - #{number})
  128. where id = #{id}
  129. and conditions -> '$.merchantRemain' = #{merchantRemain}
  130. </update>
  131. </mapper>