CouponMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.platform.yijia.dao.CouponMapper">
  4. <!--优惠券-->
  5. <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.Coupon">
  6. <id column="id" jdbcType="INTEGER" property="couponId" />
  7. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  8. <result column="coupon_name" jdbcType="VARCHAR" property="couponName" />
  9. <result column="coupon_type" jdbcType="VARCHAR" property="couponType" />
  10. <result column="coupon_threshold_amt" jdbcType="DECIMAL" property="couponThresholdAmt" />
  11. <result column="oil_type" jdbcType="VARCHAR" property="oilType" />
  12. <result column="coupon_amt" jdbcType="VARCHAR" property="couponAmt" />
  13. <result column="coupon_num" jdbcType="INTEGER" property="couponNum" />
  14. <result column="effective_time_type" jdbcType="VARCHAR" property="effectiveTimeType" />
  15. <result column="effective_time_start" jdbcType="TIMESTAMP" property="effectiveTimeStart" />
  16. <result column="effective_time_end" jdbcType="TIMESTAMP" property="effectiveTimeEnd" />
  17. <result column="effective_day_num" jdbcType="INTEGER" property="effectiveDayNum" />
  18. <result column="coupon_receive_num" jdbcType="INTEGER" property="couponReceiveNum" />
  19. <result column="open_platform" jdbcType="VARCHAR" property="openPlatform" />
  20. <result column="grant_status" jdbcType="VARCHAR" property="grantStatus" />
  21. <result column="status" jdbcType="VARCHAR" property="status" />
  22. </resultMap>
  23. <!--用户优惠券-->
  24. <resultMap id="UserCouponsBaseResultMap" type="com.platform.yijia.pojo.UserCoupon">
  25. <result column="coupon_id" jdbcType="INTEGER" property="couponId" />
  26. <result column="union_id" jdbcType="VARCHAR" property="unionId" />
  27. <result column="get_coupon_origin" jdbcType="VARCHAR" property="getCouponOrigin" />
  28. <result column="coupon_is_used" jdbcType="VARCHAR" property="couponIsUsed" />
  29. <result column="coupon_no" jdbcType="VARCHAR" property="couponNo" />
  30. <result column="coupon_is_effective" jdbcType="VARCHAR" property="couponIsEffective" />
  31. <result column="grant_coupon_shop" jdbcType="INTEGER" property="grantCouponShop" />
  32. <result column="get_coupon_time" jdbcType="TIMESTAMP" property="getCouponTime" />
  33. <result column="grant_coupon_person" jdbcType="INTEGER" property="grantCouponPerson" />
  34. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  35. <result column="coupon_name" jdbcType="VARCHAR" property="couponName" />
  36. <result column="coupon_type" jdbcType="VARCHAR" property="couponType" />
  37. <result column="coupon_threshold_amt" jdbcType="DECIMAL" property="couponThresholdAmt" />
  38. <result column="oil_type" jdbcType="VARCHAR" property="oilType" />
  39. <result column="coupon_amt" jdbcType="VARCHAR" property="couponAmt" />
  40. <result column="coupon_num" jdbcType="INTEGER" property="couponNum" />
  41. <result column="effective_time_type" jdbcType="VARCHAR" property="effectiveTimeType" />
  42. <result column="effective_time_start" jdbcType="TIMESTAMP" property="effectiveTimeStart" />
  43. <result column="effective_time_end" jdbcType="TIMESTAMP" property="effectiveTimeEnd" />
  44. <result column="effective_day_num" jdbcType="INTEGER" property="effectiveDayNum" />
  45. <result column="coupon_receive_num" jdbcType="INTEGER" property="couponReceiveNum" />
  46. <result column="open_platform" jdbcType="VARCHAR" property="openPlatform" />
  47. <result column="grant_status" jdbcType="VARCHAR" property="grantStatus" />
  48. <result column="status" jdbcType="VARCHAR" property="status" />
  49. <result column="dept_name" jdbcType="VARCHAR" property="stationName" />
  50. </resultMap>
  51. <sql id="Base_Column_List">
  52. id, station_id, coupon_name, coupon_type, coupon_threshold_amt, oil_type, coupon_amt, coupon_num, effective_time_type,
  53. effective_time_start, effective_time_end, effective_day_num, coupon_receive_num, open_platform, grant_status, status
  54. </sql>
  55. <!--获取加油券信息-->
  56. <select id="selectCouponInfo" parameterType="com.platform.yijia.pojo.Coupon" resultMap="BaseResultMap">
  57. SELECT
  58. <include refid="Base_Column_List"/>
  59. FROM
  60. coupon_info
  61. <where>
  62. <if test="id !=null">
  63. id = #{id}
  64. </if>
  65. </where>
  66. </select>
  67. <!--获取用户所拥有的加油券-->
  68. <select id="selectUserCoupons" parameterType="com.platform.yijia.pojo.UserCoupon" resultMap="UserCouponsBaseResultMap">
  69. SELECT
  70. T1.union_id,
  71. T1.coupon_id,
  72. T1.coupon_is_effective,
  73. T1.coupon_is_used,
  74. T1.grant_coupon_shop,
  75. T1.grant_coupon_person,
  76. T1.get_coupon_origin,
  77. T1.get_coupon_time,
  78. T3.dept_name,
  79. T2.station_id,
  80. T2.oil_type,
  81. T2.coupon_name,
  82. T2.coupon_threshold_amt,
  83. T2.coupon_amt,
  84. T2.effective_time_type,
  85. T2.effective_time_start,
  86. T2.effective_time_end,
  87. T2.effective_day_num,
  88. T2.status
  89. FROM coupon_user AS T1
  90. LEFT JOIN coupon_info AS T2 ON T1.coupon_id = T2.id
  91. LEFT JOIN sys_dept AS T3 ON T2.station_id = T3.dept_id
  92. <where>
  93. <if test="stationId !=null and stationId !=''">
  94. T1.station_id = #{stationId}
  95. </if>
  96. <if test="unionId !=null and unionId !=''">
  97. AND T1.union_id = #{unionId}
  98. </if>
  99. </where>
  100. </select>
  101. <!--用户获取优惠券-->
  102. <insert id="addUserCoupon" parameterType="com.platform.yijia.pojo.UserCoupon">
  103. INSERT INTO coupon_user
  104. <trim prefix="(" suffix=")" suffixOverrides=",">
  105. <if test="unionId !=null">
  106. union_id,
  107. </if>
  108. <if test="couponId !=null">
  109. coupon_id,
  110. </if>
  111. <if test="couponNo !=null">
  112. coupon_no,
  113. </if>
  114. <if test="getCouponOrigin !=null">
  115. get_coupon_origin,
  116. </if>
  117. <if test="couponIsUsed !=null">
  118. coupon_is_used,
  119. </if>
  120. <if test="couponIsEffective !=null">
  121. coupon_is_effective,
  122. </if>
  123. <if test="grantCouponShop !=null">
  124. grant_coupon_shop,
  125. </if>
  126. <if test="getCouponTime !=null">
  127. get_coupon_time,
  128. </if>
  129. <if test="grantCouponPerson !=null">
  130. grant_coupon_person,
  131. </if>
  132. <if test="stationId !=null">
  133. station_id,
  134. </if>
  135. </trim>
  136. <trim prefix="values (" suffix=")" suffixOverrides=",">
  137. <if test="unionId !=null">
  138. #{unionId},
  139. </if>
  140. <if test="couponId !=null">
  141. #{couponId},
  142. </if>
  143. <if test="couponNo !=null">
  144. #{couponNo},
  145. </if>
  146. <if test="getCouponOrigin !=null">
  147. #{getCouponOrigin},
  148. </if>
  149. <if test="couponIsUsed !=null">
  150. #{couponIsUsed},
  151. </if>
  152. <if test="couponIsEffective !=null">
  153. #{couponIsEffective},
  154. </if>
  155. <if test="grantCouponShop !=null">
  156. #{grantCouponShop},
  157. </if>
  158. <if test="getCouponTime !=null">
  159. #{getCouponTime},
  160. </if>
  161. <if test="grantCouponPerson !=null">
  162. #{grantCouponPerson},
  163. </if>
  164. <if test="stationId !=null">
  165. #{stationId},
  166. </if>
  167. </trim>
  168. </insert>
  169. </mapper>