CmCouponOrderRecordMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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.CmCouponOrderRecordDao">
  4. <sql id="cmCouponOrderRecordColumns">
  5. a.id AS "id",
  6. a.orderCode AS "orderCode",
  7. a.totalAmount AS "totalAmount",
  8. a.refundAmount AS "refundAmount",
  9. a.paymentTime AS "paymentTime",
  10. a.refundTime AS "refundTime",
  11. a.couponCode AS "couponCode",
  12. a.discountAmount AS "discountAmount",
  13. a.status AS "status",
  14. a.customerCode AS "customerCode",
  15. a.customerName AS "customerName",
  16. a.customerMobile AS "customerMobile",
  17. a.refundFlag AS "refundFlag",
  18. a.createTime AS "createTime",
  19. a.updateTime AS "updateTime",
  20. a.delFlag AS "delFlag",
  21. u.userName AS "clubName",
  22. ccrs.mobile AS "couponMobile"
  23. </sql>
  24. <sql id="cmCouponOrderRecordJoins">
  25. LEFT JOIN cm_coupon_record ccr ON ccr.couponCode = a.couponCode
  26. LEFT JOIN cm_coupon_record_scan ccrs ON ccrs.couponCode = a.couponCode
  27. LEFT JOIN user u ON u.userID = ccr.userID
  28. LEFT JOIN club c on c.userID = u.companyUserID
  29. </sql>
  30. <select id="get" resultType="CmCouponOrderRecord">
  31. SELECT
  32. <include refid="cmCouponOrderRecordColumns"/>
  33. FROM cm_coupon_order_record a
  34. <include refid="cmCouponOrderRecordJoins"/>
  35. WHERE a.id = #{id}
  36. </select>
  37. <select id="findList" resultType="CmCouponOrderRecord">
  38. SELECT
  39. <include refid="cmCouponOrderRecordColumns"/>
  40. FROM cm_coupon_order_record a
  41. <include refid="cmCouponOrderRecordJoins"/>
  42. <where>
  43. <if test="orderCode != null and orderCode != ''">
  44. AND a.orderCode = #{orderCode}
  45. </if>
  46. <if test="clubName != null and clubName != ''">
  47. AND (u.userName LIKE concat('%',#{clubName},'%') OR ccrs.mobile = #{clubName} OR c.name LIKE concat('%',#{clubName},'%'))
  48. </if>
  49. <if test="startTime != null and startTime != ''">
  50. AND a.paymentTime <![CDATA[ >= ]]> #{startTime}
  51. </if>
  52. <if test="endTime != null and endTime != ''">
  53. AND a.paymentTime <![CDATA[ <= ]]> #{endTime}
  54. </if>
  55. </where>
  56. <choose>
  57. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  58. ORDER BY ${page.orderBy}
  59. </when>
  60. <otherwise>
  61. ORDER BY a.paymentTime DESC
  62. </otherwise>
  63. </choose>
  64. </select>
  65. <select id="findListBuyAgain" resultType="CmCouponOrderRecord">
  66. SELECT
  67. a.*,
  68. u.username AS "clubName",
  69. c.name AS "companyName",
  70. ccrs.mobile AS "couponMobile"
  71. FROM cm_coupon_order_record a
  72. LEFT JOIN cm_coupon_record ccr ON ccr.couponCode = a.couponCode
  73. LEFT JOIN cm_coupon_record_scan ccrs ON ccrs.couponCode = a.couponCode
  74. LEFT JOIN user u ON u.userID = ccr.sharerUserId
  75. LEFT JOIN club c on c.userID = u.companyUserID
  76. WHERE
  77. a.customerMobile = #{customerMobile}
  78. AND ( c.name is NOT NULL OR ccrs.mobile is NOT NULL )
  79. </select>
  80. <select id="findAllList" resultType="CmCouponOrderRecord">
  81. SELECT
  82. <include refid="cmCouponOrderRecordColumns"/>
  83. FROM cm_coupon_order_record a
  84. <include refid="cmCouponOrderRecordJoins"/>
  85. <where>
  86. </where>
  87. <choose>
  88. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  89. ORDER BY ${page.orderBy}
  90. </when>
  91. <otherwise>
  92. </otherwise>
  93. </choose>
  94. </select>
  95. <insert id="insert" parameterType="CmCouponOrderRecord" keyProperty="id" useGeneratedKeys="true">
  96. INSERT INTO cm_coupon_order_record(
  97. id,
  98. orderCode,
  99. totalAmount,
  100. refundAmount,
  101. paymentTime,
  102. refundTime,
  103. couponCode,
  104. discountAmount,
  105. status,
  106. customerCode,
  107. customerName,
  108. customerMobile,
  109. refundFlag,
  110. createTime,
  111. updateTime,
  112. delFlag
  113. ) VALUES (
  114. #{id},
  115. #{orderCode},
  116. #{totalAmount},
  117. #{refundAmount},
  118. #{paymentTime},
  119. #{refundTime},
  120. #{couponCode},
  121. #{discountAmount},
  122. #{status},
  123. #{customerCode},
  124. #{customerName},
  125. #{customerMobile},
  126. #{refundFlag},
  127. #{createTime},
  128. #{updateTime},
  129. #{delFlag}
  130. )
  131. </insert>
  132. <update id="update">
  133. UPDATE cm_coupon_order_record SET
  134. orderCode = #{orderCode},
  135. totalAmount = #{totalAmount},
  136. refundAmount = #{refundAmount},
  137. paymentTime = #{paymentTime},
  138. refundTime = #{refundTime},
  139. couponCode = #{couponCode},
  140. discountAmount = #{discountAmount},
  141. status = #{status},
  142. customerCode = #{customerCode},
  143. customerName = #{customerName},
  144. customerMobile = #{customerMobile},
  145. refundFlag = #{refundFlag},
  146. createTime = #{createTime},
  147. updateTime = #{updateTime},
  148. delFlag = #{delFlag}
  149. WHERE id = #{id}
  150. </update>
  151. <delete id="delete">
  152. DELETE FROM cm_coupon_order_record
  153. WHERE id = #{id}
  154. </delete>
  155. </mapper>