1
0

ApiCouponMapper.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.kmall.api.dao.ApiCouponMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.CouponVo" id="couponMap">
  6. <result property="id" column="id"/>
  7. <result property="name" column="name"/>
  8. <result property="type_money" column="type_money"/>
  9. <result property="send_type" column="send_type"/>
  10. <result property="min_amount" column="min_amount"/>
  11. <result property="max_amount" column="max_amount"/>
  12. <result property="send_start_date" column="send_start_date"/>
  13. <result property="send_end_date" column="send_end_date"/>
  14. <result property="use_start_date" column="use_start_date"/>
  15. <result property="use_end_date" column="use_end_date"/>
  16. <result property="coupon_txt" column="coupon_txt"/>
  17. <result property="user_id" column="user_id"/>
  18. <result property="coupon_number" column="coupon_number"/>
  19. <result property="show_state" column="show_state"/>
  20. <result property="pic_url" column="pic_url"/>
  21. <result property="isAll" column="is_all"/>
  22. <result property="couponUrl" column="coupon_url"/>
  23. </resultMap>
  24. <select id="queryObject" resultMap="couponMap">
  25. select * from mall_coupon where id = #{value}
  26. </select>
  27. <select id="queryList" resultMap="couponMap">
  28. select * from mall_coupon a
  29. where 1 = 1
  30. <if test="store_id != null">
  31. and a.`store_id` = #{store_id}
  32. </if>
  33. <if test="send_types != null">
  34. and send_type in
  35. <foreach item="item" collection="send_types" open="(" separator="," close=")">
  36. #{item}
  37. </foreach>
  38. </if>
  39. <if test="enabled != null and enabled == true">
  40. and a.use_end_date >= now()
  41. and now() >= a.use_start_date
  42. </if>
  43. <choose>
  44. <when test="sidx != null and sidx.trim() != ''">
  45. order by ${sidx} ${order}
  46. </when>
  47. <otherwise>
  48. order by a.id desc
  49. </otherwise>
  50. </choose>
  51. <if test="offset != null and limit != null">
  52. limit #{offset}, #{limit}
  53. </if>
  54. </select>
  55. <select id="queryTotal" resultType="int">
  56. select count(*) from mall_coupon a
  57. where 1 = 1
  58. <if test="send_types != null">
  59. and send_type in
  60. <foreach item="item" collection="send_types" open="(" separator="," close=")">
  61. #{item}
  62. </foreach>
  63. </if>
  64. <if test="store_id != null">
  65. and a.`store_id` = #{store_id}
  66. </if>
  67. <if test="enabled != null and enabled == true">
  68. and a.use_end_date >= now()
  69. and now() >= a.use_start_date
  70. </if>
  71. </select>
  72. <select id="queryMaxUserEnableCoupon" resultMap="couponMap">
  73. select a.*
  74. from mall_coupon a
  75. where 1 = 1
  76. and a.use_end_date >= now()
  77. and now() >= a.use_start_date
  78. <if test="send_type != null">
  79. and a.send_type = #{send_type}
  80. </if>
  81. <if test="send_types != null">
  82. and a.send_type in
  83. <foreach item="item" collection="send_types" open="(" separator="," close=")">
  84. #{item}
  85. </foreach>
  86. </if>
  87. <if test="filterCouponIds != null">
  88. and a.`id` not in
  89. <foreach item="item" collection="filterCouponIds" open="(" separator="," close=")">
  90. #{item}
  91. </foreach>
  92. </if>
  93. order by type_money desc
  94. limit 1
  95. </select>
  96. </mapper>