1
0

CouponDao.xml 5.3 KB

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