CouponDao.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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.admin.dao.CouponDao">
  4. <resultMap type="com.kmall.admin.entity.CouponEntity" id="couponMap">
  5. <result property="id" column="id"/>
  6. <result property="name" column="name"/>
  7. <result property="storeId" column="store_id"/>
  8. <result property="merchSn" column="merch_sn"/>
  9. <result property="typeMoney" column="type_money"/>
  10. <result property="sendType" column="send_type"/>
  11. <result property="minAmount" column="min_amount"/>
  12. <result property="maxAmount" column="max_amount"/>
  13. <result property="sendStartDate" column="send_start_date"/>
  14. <result property="sendEndDate" column="send_end_date"/>
  15. <result property="useStartDate" column="use_start_date"/>
  16. <result property="useEndDate" column="use_end_date"/>
  17. <result property="minGoodsAmount" column="min_goods_amount"/>
  18. <result property="isAll" column="is_all"/>
  19. </resultMap>
  20. <sql id="conditions">
  21. <where>
  22. <if test="sendType != null">and a.`send_type` = #{sendType}</if>
  23. <if test="name != null and name.trim() != ''">
  24. AND a.name LIKE concat('%',#{name},'%')
  25. </if>
  26. <if test="storeId != null and storeId != ''">
  27. AND (a.store_id = #{storeId} OR a.is_all = 1)
  28. </if>
  29. <if test="merchSn != null and merchSn.trim() != ''">
  30. AND (a.merch_sn = #{merchSn} OR a.is_all = 1)
  31. </if>
  32. </where>
  33. </sql>
  34. <select id="queryObject" resultType="com.kmall.admin.entity.CouponEntity">
  35. select
  36. `id`,
  37. `name`,
  38. `store_id`,
  39. `merch_sn`,
  40. `type_money`,
  41. `send_type`,
  42. `min_amount`,
  43. `max_amount`,
  44. `send_start_date`,
  45. `send_end_date`,
  46. `use_start_date`,
  47. `use_end_date`,
  48. `min_goods_amount`,
  49. `is_all`
  50. from mall_coupon
  51. where id = #{id}
  52. </select>
  53. <select id="queryList" resultType="com.kmall.admin.entity.CouponEntity">
  54. select
  55. `id`,
  56. `name`,
  57. `store_id`,
  58. `merch_sn`,
  59. `type_money`,
  60. `send_type`,
  61. `min_amount`,
  62. `max_amount`,
  63. `send_start_date`,
  64. `send_end_date`,
  65. `use_start_date`,
  66. `use_end_date`,
  67. `min_goods_amount`,
  68. `is_all`
  69. from mall_coupon a
  70. <include refid="conditions"/>
  71. <choose>
  72. <when test="sidx != null and sidx.trim() != ''">
  73. order by ${sidx} ${order}
  74. </when>
  75. <otherwise>
  76. order by a.id desc
  77. </otherwise>
  78. </choose>
  79. <if test="offset != null and limit != null">
  80. limit #{offset}, #{limit}
  81. </if>
  82. </select>
  83. <select id="queryTotal" resultType="int">
  84. select count(*) from mall_coupon a
  85. <include refid="conditions"/>
  86. </select>
  87. <insert id="save" parameterType="com.kmall.admin.entity.CouponEntity" useGeneratedKeys="true" keyProperty="id">
  88. insert into mall_coupon(
  89. `name`,
  90. `store_id`,
  91. `merch_sn`,
  92. `type_money`,
  93. `send_type`,
  94. `min_amount`,
  95. `max_amount`,
  96. `send_start_date`,
  97. `send_end_date`,
  98. `use_start_date`,
  99. `use_end_date`,
  100. `min_goods_amount`,
  101. `is_all`)
  102. values(
  103. #{name},
  104. #{storeId},
  105. #{merchSn},
  106. #{typeMoney},
  107. #{sendType},
  108. #{minAmount},
  109. #{maxAmount},
  110. #{sendStartDate},
  111. #{sendEndDate},
  112. #{useStartDate},
  113. #{useEndDate},
  114. #{minGoodsAmount},
  115. #{isAll})
  116. </insert>
  117. <update id="update" parameterType="com.kmall.admin.entity.CouponEntity">
  118. update mall_coupon
  119. <set>
  120. <if test="name != null">`name` = #{name},</if>
  121. <if test="storeId != null">`store_id` = #{storeId}, </if>
  122. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  123. <if test="typeMoney != null">`type_money` = #{typeMoney},</if>
  124. <if test="sendType != null">`send_type` = #{sendType},</if>
  125. <if test="minAmount != null">`min_amount` = #{minAmount},</if>
  126. <if test="maxAmount != null">`max_amount` = #{maxAmount},</if>
  127. <if test="sendStartDate != null">`send_start_date` = #{sendStartDate},</if>
  128. <if test="sendEndDate != null">`send_end_date` = #{sendEndDate},</if>
  129. <if test="useStartDate != null">`use_start_date` = #{useStartDate},</if>
  130. <if test="useEndDate != null">`use_end_date` = #{useEndDate},</if>
  131. <if test="minGoodsAmount != null">`min_goods_amount` = #{minGoodsAmount},</if>
  132. <if test="isAll != null">`is_all` = #{isAll},</if>
  133. </set>
  134. where id = #{id}
  135. </update>
  136. <delete id="delete">
  137. delete from mall_coupon where id = #{value}
  138. </delete>
  139. <delete id="deleteBatch">
  140. delete from mall_coupon where id in
  141. <foreach item="id" collection="array" open="(" separator="," close=")">
  142. #{id}
  143. </foreach>
  144. </delete>
  145. </mapper>