Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

116 строки
3.8 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.vo.WxCouponSendVo">
  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="title" jdbcType="VARCHAR" property="title" />
  9. <result column="send_type" jdbcType="INTEGER" property="sendType" />
  10. <result column="conditions" jdbcType="VARCHAR" property="conditions" />
  11. <result column="status" jdbcType="INTEGER" property="status" />
  12. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  13. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  14. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  15. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  16. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  17. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  18. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  19. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  20. <result column="send_sms" jdbcType="INTEGER" property="sendSms"/>
  21. </resultMap>
  22. <sql id="allColumns">
  23. cs.id,cs.tenant_id,cs.coupon_id,cs.title,cs.send_type,cs.conditions,cs.status,cs.create_date,cs.update_date,
  24. (case when
  25. (select count(*) from wx_coupon_merchant xcm where xcm.product_id = cs.coupon_id and xcm.status = 0)=1
  26. then
  27. (select m.name from wx_merchant m, wx_coupon_merchant cm where m.id = cm.merchant_id and cm.product_id=cs.coupon_id and cm.status = 0)
  28. else
  29. '[多商户通用]'
  30. end) as merchant_name,
  31. c.remain_inventory, c.use_limit_quantity, c.inventory, c.valid_start_date, c.valid_end_date,cs.send_sms
  32. </sql>
  33. <sql id="dynamicWhereConditions">
  34. where 1 = 1
  35. <if test=" null != id ">
  36. and cs.id = #{id}
  37. </if>
  38. <if test=" null != tenantId ">
  39. and cs.tenant_id = #{tenantId}
  40. </if>
  41. <if test=" null != couponId ">
  42. and cs.coupon_id = #{couponId}
  43. </if>
  44. <if test=" null != title ">
  45. and cs.title like concat('%', #{title},'%')
  46. </if>
  47. <if test=" null != sendType ">
  48. and cs.send_type = #{sendType}
  49. </if>
  50. <if test=" null != status ">
  51. and cs.status = #{status}
  52. </if>
  53. <if test=" null != createDate ">
  54. and cs.create_date = #{createDate}
  55. </if>
  56. <if test=" null != updateDate ">
  57. and cs.update_date = #{updateDate}
  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 != sendSms ">
  66. and cs.send_sms = #{sendSms}
  67. </if>
  68. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  69. </sql>
  70. <select id="findListVo" parameterType="com.iformall.domain.vo.WxCouponSendVo" resultMap="BaseResultMap">
  71. select <include refid="allColumns" /> from wx_coupon_send cs left join wx_coupon c on c.id = cs.coupon_id
  72. <include refid="dynamicWhereConditions" />
  73. </select>
  74. <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
  75. update wx_coupon_send set status=#{status}
  76. where coupon_id=#{couponId}
  77. <if test=" null != tenantId ">
  78. and tenant_id = #{tenantId}
  79. </if>
  80. </update>
  81. <update id="offExpiriedCouponSendByCouponStatus">
  82. update wx_coupon_send cs, wx_coupon c
  83. set cs.status=1, cs.update_date = now()
  84. where c.id = cs.coupon_id and cs.status = 0 and
  85. ((c.status = 1) or (c.valid_type = 1 and c.valid_end_date &lt; now()))
  86. </update>
  87. </mapper>