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

109 строки
3.6 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. </resultMap>
  21. <sql id="allColumns">
  22. cs.id,cs.tenant_id,cs.coupon_id,cs.title,cs.send_type,cs.conditions,cs.status,cs.create_date,cs.update_date,
  23. (case when
  24. (select count(*) from wx_coupon_merchant xcm where xcm.product_id = cs.coupon_id and xcm.status = 0)=1
  25. then
  26. (select m.name from wx_merchant m, wx_coupon_merchant cm where m.id = cm.merchant_id and cm.product_id=cs.coupon_id)
  27. else
  28. '[多商户通用]'
  29. end) as merchant_name,
  30. c.remain_inventory, c.use_limit_quantity, c.inventory, c.valid_start_date, c.valid_end_date
  31. </sql>
  32. <sql id="dynamicWhereConditions">
  33. where 1 = 1
  34. <if test=" null != id ">
  35. and cs.id = #{id}
  36. </if>
  37. <if test=" null != tenantId ">
  38. and cs.tenant_id = #{tenantId}
  39. </if>
  40. <if test=" null != couponId ">
  41. and cs.coupon_id = #{couponId}
  42. </if>
  43. <if test=" null != title ">
  44. and cs.title like concat('%', #{title},'%')
  45. </if>
  46. <if test=" null != sendType ">
  47. and cs.send_type = #{sendType}
  48. </if>
  49. <if test=" null != status ">
  50. and cs.status = #{status}
  51. </if>
  52. <if test=" null != createDate ">
  53. and cs.create_date = #{createDate}
  54. </if>
  55. <if test=" null != updateDate ">
  56. and cs.update_date = #{updateDate}
  57. </if>
  58. <if test=" null != ids ">
  59. and id in
  60. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  61. #{idItem}
  62. </foreach>
  63. </if>
  64. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  65. </sql>
  66. <select id="findListVo" parameterType="com.iformall.domain.vo.WxCouponSendVo" resultMap="BaseResultMap">
  67. select <include refid="allColumns" /> from wx_coupon_send cs left join wx_coupon c on c.id = cs.coupon_id
  68. <include refid="dynamicWhereConditions" />
  69. </select>
  70. <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
  71. update wx_coupon_send set status=#{status}
  72. where coupon_id=#{couponId}
  73. <if test=" null != tenantId ">
  74. and tenant_id = #{tenantId}
  75. </if>
  76. </update>
  77. <update id="offExpiriedCouponSendByCouponStatus">
  78. update wx_coupon_send cs, wx_coupon c
  79. set cs.status=1, cs.update_date = now()
  80. where c.id = cs.coupon_id and cs.status = 0 and
  81. ((c.status = 1) or (c.valid_type = 1 and c.valid_end_date &lt; now()))
  82. </update>
  83. </mapper>