CmCouponVipMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.caimei.modules.coupon.dao.CmCouponVipDao">
  4. <sql id="cmCouponColumns">
  5. a.id AS "id",
  6. a.name AS "name",
  7. a.couponAmount AS "couponAmount",
  8. a.touchPrice AS "touchPrice",
  9. a.startDate AS "startDate",
  10. a.endDate AS "endDate",
  11. a.status AS "status",
  12. a.couponType AS "couponType",
  13. a.userId AS "userId",
  14. a.shopId AS "shopId",
  15. a.productType AS "productType",
  16. a.pcBanner AS "pcBanner",
  17. a.appletsBanner AS "appletsBanner",
  18. a.categoryType AS "categoryType",
  19. a.couponsMode AS "couponsMode",
  20. a.createDate AS "createDate",
  21. a.delFlag AS "delFlag"
  22. </sql>
  23. <insert id="insertVipCouponMonth" parameterType="CmVipCoupon" keyProperty="id" useGeneratedKeys="true">
  24. INSERT INTO cm_svip_coupon_month (useTime, updateTime, status,delFlag)
  25. VALUES (#{useTime}, #{updateTime}, #{status}, #{delFlag})
  26. </insert>
  27. <update id="updateVipCouponMonth" parameterType="CmVipCoupon">
  28. UPDATE cm_svip_coupon_month SET useTime=#{useTime}, updateTime=#{updateTime}, status=#{status}, delFlag=#{delFlag}
  29. WHERE id=#{id}
  30. </update>
  31. <insert id="insertVipCouponRelation">
  32. INSERT INTO cm_svip_coupon (couponId, montId, updateTime, delFlag)
  33. VALUES (#{couponId}, #{montId}, #{updateTime}, #{delFlag})
  34. </insert>
  35. <update id="updateVipCouponRelation">
  36. UPDATE cm_svip_coupon SET couponId=#{couponId}, montId=#{montId}, updateTime=#{updateTime}, delFlag=#{delFlag}
  37. WHERE id=#{id}
  38. </update>
  39. <select id="get" resultType="CmVipCoupon">
  40. SELECT DISTINCT id, useTime, status, updateTime, delFlag
  41. FROM cm_svip_coupon_month
  42. WHERE id = #{id}
  43. LIMIT 1
  44. </select>
  45. <select id="getBindCoupons" resultType="java.lang.String">
  46. SELECT couponId from cm_svip_coupon WHERE montId = #{montId} AND delFlag=0
  47. </select>
  48. <select id="findList" resultType="CmVipCoupon">
  49. SELECT cs.id, cs.useTime, cs.status, cs.updateTime, cs.delFlag
  50. FROM cm_svip_coupon_month cs
  51. <where>
  52. AND cs.delFlag = 0
  53. <if test="startDate!=null and startDate!=''">
  54. AND cs.useTime <![CDATA[ >= ]]> #{startDate}
  55. </if>
  56. <if test="endDate!=null and endDate!=''">
  57. AND cs.useTime <![CDATA[ <= ]]> #{endDate}
  58. </if>
  59. </where>
  60. ORDER BY cs.useTime DESC
  61. </select>
  62. <select id="getCouponListByIds" resultType="com.caimei.modules.coupon.entity.CmCoupon">
  63. SELECT
  64. <include refid="cmCouponColumns"/>,
  65. u.name AS "clubName",
  66. s.name AS "shopName"
  67. FROM cm_coupon a
  68. LEFT JOIN cm_coupon_club ccc ON ccc.couponId = a.id
  69. LEFT JOIN USER u ON u.userID = a.userId
  70. LEFT JOIN shop s ON s.shopID = a.shopId
  71. <where>
  72. AND a.delFlag = 0
  73. <if test="couponType != null">
  74. AND a.couponType = #{couponType}
  75. </if>
  76. <if test='status == "0"'>
  77. AND a.startDate <![CDATA[ > ]]> NOW()
  78. </if>
  79. <if test='status == "1"'>
  80. AND a.startDate <![CDATA[ <= ]]> NOW()
  81. AND a.endDate <![CDATA[ >= ]]> NOW()
  82. AND a.status != '2'
  83. </if>
  84. <if test='status == "2"'>
  85. AND a.status = '2'
  86. </if>
  87. <if test='status == "3"'>
  88. AND a.endDate <![CDATA[ < ]]> NOW()
  89. </if>
  90. <if test="bindCoupons != null">
  91. AND a.id IN
  92. <foreach collection="bindCoupons" open="(" separator="," close=")" item="couponId">
  93. #{couponId}
  94. </foreach>
  95. </if>
  96. </where>
  97. GROUP BY a.id
  98. ORDER BY createDate DESC
  99. </select>
  100. <delete id="deleteByMonthId">
  101. UPDATE cm_svip_coupon SET delFlag=1 WHERE montId = #{montId}
  102. </delete>
  103. <select id="findShopName" resultType="com.caimei.modules.user.entity.NewCmShop">
  104. select name,sname,linkMan,contractMobile
  105. from shop
  106. where shopID = #{shopId}
  107. </select>
  108. <!-- <select id="findGroup" resultType="com.caimei.modules.coupon.entity.CmVipCouponRelation">-->
  109. <!-- select *-->
  110. <!-- from cm_svip_coupon cs-->
  111. <!-- where useTime = #{useTime}-->
  112. <!-- AND cs.delFlag=0-->
  113. <!-- <if test="status!=null and status != ''">-->
  114. <!-- AND cs.status=#{status}-->
  115. <!-- </if>-->
  116. <!-- </select>-->
  117. <!-- <select id="findUseTime" resultType="String">-->
  118. <!-- SELECT DISTINCT usetime-->
  119. <!-- FROM cm_svip_coupon-->
  120. <!-- </select>-->
  121. <!-- <select id="findBind" resultType="java.lang.String">-->
  122. <!-- SELECT DISTINCT bindCoupon-->
  123. <!-- FROM cm_svip_coupon-->
  124. <!-- </select>-->
  125. <!-- <select id="findByCoupon" resultType="com.caimei.modules.coupon.entity.CmVipCouponRelation">-->
  126. <!-- select useTime, status, couponId, bindCoupon-->
  127. <!-- from cm_svip_coupon-->
  128. <!-- where delFlag = 0-->
  129. <!-- and couponId=#{couponId}-->
  130. <!-- <if test="status != null and status != ''">-->
  131. <!-- and status=#{status}-->
  132. <!-- </if>-->
  133. <!-- </select>-->
  134. </mapper>