CouponMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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.ygj.yuemum.dao.coupon.CouponDao" >
  4. <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.coupon.Coupon" >
  5. <id column="id" property="id" jdbcType="INTEGER" />
  6. <result column="cp_code" property="cp_code" jdbcType="VARCHAR" />
  7. <result column="cb_code" property="cb_code" jdbcType="VARCHAR" />
  8. <result column="cc_code" property="cc_code" jdbcType="INTEGER" />
  9. <result column="cp_startdate" property="cp_startdate" jdbcType="DATE" />
  10. <result column="cp_enddate" property="cp_enddate" jdbcType="DATE" />
  11. <result column="cp_amount" property="cp_amount" jdbcType="INTEGER" />
  12. <result column="cp_status" property="cp_status" jdbcType="INTEGER" />
  13. </resultMap>
  14. <sql id="Base_Column_List" >
  15. id, cp_code,cc_code,cb_code,cp_startdate,cp_enddate,cp_amount,cp_status
  16. </sql>
  17. <!--获取所有数据-->
  18. <select id="getCount" resultType="java.lang.Integer" >
  19. select
  20. count(1)
  21. from coupon
  22. </select>
  23. <select id="getAll" resultMap="BaseResultMap" >
  24. select
  25. <include refid="Base_Column_List" />
  26. from coupon
  27. order by id desc
  28. </select>
  29. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  30. select
  31. <include refid="Base_Column_List" />
  32. from coupon
  33. where id = #{id,jdbcType=INTEGER}
  34. </select>
  35. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  36. delete from coupon
  37. where id = #{id,jdbcType=INTEGER}
  38. </delete>
  39. <update id="disableCoupon" parameterType="java.lang.Integer" >
  40. update coupon
  41. set cp_status = 4
  42. where cc_code = #{id,jdbcType=INTEGER}
  43. </update>
  44. <update id="enableCoupon" parameterType="java.lang.Integer" >
  45. update coupon
  46. set cp_status = 1
  47. where cc_code = #{id,jdbcType=INTEGER}
  48. </update>
  49. <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.coupon.Coupon" >
  50. insert into coupon
  51. <trim prefix="(" suffix=")" suffixOverrides="," >
  52. <if test="cp_code != null" >
  53. cp_code,
  54. </if>
  55. <if test="cb_code != null" >
  56. cb_code,
  57. </if>
  58. <if test="cc_code != null" >
  59. cc_code,
  60. </if>
  61. <if test="cp_startdate != null" >
  62. cp_startdate,
  63. </if>
  64. <if test="cp_enddate != null" >
  65. cp_enddate,
  66. </if>
  67. <if test="cp_amount != null" >
  68. cp_amount,
  69. </if>
  70. <if test="cp_status != null" >
  71. cp_status
  72. </if>
  73. </trim>
  74. <trim prefix="values (" suffix=")" suffixOverrides="," >
  75. <if test="cp_code != null" >
  76. #{cp_code,jdbcType=VARCHAR},
  77. </if>
  78. <if test="cb_code != null" >
  79. #{cb_code,jdbcType=VARCHAR},
  80. </if>
  81. <if test="cc_code != null" >
  82. #{cc_code,jdbcType=VARCHAR},
  83. </if>
  84. <if test="cp_startdate != null" >
  85. #{cp_startdate,jdbcType=DATE},
  86. </if>
  87. <if test="cp_enddate != null" >
  88. #{cp_enddate,jdbcType=DATE},
  89. </if>
  90. <if test="cp_amount != null" >
  91. #{cp_amount,jdbcType=INTEGER},
  92. </if>
  93. <if test="cp_status != null" >
  94. #{cp_status,jdbcType=INTEGER}
  95. </if>
  96. </trim>
  97. </insert>
  98. <!--Modoo API-->
  99. <select id="getCoupon" resultType="java.lang.String" parameterType="java.lang.String" >
  100. select
  101. cp_code
  102. from coupon
  103. where cb_code = #{cb_code,jdbcType=INTEGER}
  104. and cp_status = 1
  105. and cp_enddate &gt; now()
  106. order by id asc limit 1
  107. </select>
  108. <select id="getCouponAmount" resultType="java.lang.String" parameterType="com.ygj.yuemum.domain.coupon.Coupon" >
  109. select
  110. cp_code
  111. from coupon
  112. where
  113. 1=1
  114. <if test="cb_code != null and cb_code != ''">
  115. and cb_code = #{cb_code,jdbcType=VARCHAR}
  116. </if>
  117. <if test="cp_amount != null and cp_amount != ''">
  118. and cp_amount = #{cp_amount,jdbcType=INTEGER}
  119. </if>
  120. and cp_status = 1
  121. and cp_enddate &gt; now()
  122. order by id asc limit 1
  123. </select>
  124. <update id="updateGetCoupon" parameterType="java.lang.String" >
  125. update coupon
  126. set cp_status = 2
  127. where cp_code = #{cp_code,jdbcType=INTEGER}
  128. </update>
  129. <update id="updateUseCoupon" parameterType="com.ygj.yuemum.domain.customer.CustomerCoupon" >
  130. update coupon
  131. <set >
  132. <if test="cp_status != null" >
  133. cp_status = #{cp_status,jdbcType=VARCHAR},
  134. </if>
  135. </set>
  136. where cp_code = #{cp_code,jdbcType=INTEGER}
  137. </update>
  138. </mapper>