CmHeheCollageMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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.hehe.dao.CmHeheCollageDao">
  4. <sql id="cmHeheCollageColumns">
  5. a.id AS "id",
  6. a.productId AS "productId",
  7. a.price AS "price",
  8. a.memberNum AS "memberNum",
  9. a.status AS "status",
  10. a.startTime AS "startTime",
  11. a.completeTime AS "completeTime",
  12. a.endTime AS "endTime",
  13. p.name as productName,
  14. s.name as shopName
  15. </sql>
  16. <sql id="cmHeheCollageJoins">
  17. left join product p on a.productId = p.productID
  18. left join cm_hehe_product hp on p.productID = hp.productId
  19. left join shop s on p.shopID = s.shopID
  20. </sql>
  21. <select id="get" resultType="CmHeheCollage">
  22. SELECT
  23. <include refid="cmHeheCollageColumns"/>
  24. FROM cm_hehe_collage a
  25. <include refid="cmHeheCollageJoins"/>
  26. WHERE a.id = #{id}
  27. </select>
  28. <select id="findList" resultType="CmHeheCollage">
  29. SELECT
  30. <include refid="cmHeheCollageColumns"/>
  31. FROM cm_hehe_collage a
  32. <include refid="cmHeheCollageJoins"/>
  33. <where>
  34. a.status != 0
  35. <if test="id != null and id != ''">
  36. AND a.id = #{id}
  37. </if>
  38. <if test="status != null">
  39. AND a.status = #{status}
  40. </if>
  41. <if test="productName != null and productName != ''">
  42. and p.name like concat('%',#{productName},'%')
  43. </if>
  44. <if test="shopName != null and shopName != ''">
  45. and s.name like concat('%',#{shopName},'%')
  46. </if>
  47. </where>
  48. <choose>
  49. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  50. ORDER BY ${page.orderBy}
  51. </when>
  52. <otherwise>
  53. order by startTime desc
  54. </otherwise>
  55. </choose>
  56. </select>
  57. <select id="findAllList" resultType="CmHeheCollage">
  58. SELECT
  59. <include refid="cmHeheCollageColumns"/>
  60. FROM cm_hehe_collage a
  61. <include refid="cmHeheCollageJoins"/>
  62. <where>
  63. </where>
  64. <choose>
  65. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  66. ORDER BY ${page.orderBy}
  67. </when>
  68. <otherwise>
  69. </otherwise>
  70. </choose>
  71. </select>
  72. <select id="getCollageOrderIds" resultType="java.lang.Integer">
  73. select chcm.orderId from cm_hehe_collage_member chcm left join cm_order co on chcm.orderId = co.orderID
  74. where collageId = #{collageId} and co.receiptStatus = 3
  75. </select>
  76. <select id="findMemberList" resultType="com.caimei.modules.hehe.entity.CmHeheCollageMember">
  77. select chu.nickName,cm.launchFlag,chu.mobile,chu.userIdentity,co.orderTime,co.orderNo,co.orderID as orderId
  78. from cm_hehe_collage_member cm
  79. left join user u on cm.userId = u.userID
  80. left join cm_hehe_user chu on u.userID = chu.userId
  81. left join cm_order co on cm.orderId = co.orderID
  82. where collageId = #{collageId} and co.receiptStatus = 3
  83. <if test="nickName != null and nickName != ''">
  84. and chu.nickName like concat('%',#{nickName},'%')
  85. </if>
  86. <if test="mobile != null and mobile != ''">
  87. and chu.mobile like concat('%',#{mobile},'%')
  88. </if>
  89. <if test="orderNo != null and orderNo != ''">
  90. and (co.orderID = #{orderNo} or co.orderNo = #{orderNo})
  91. </if>
  92. order by cm.id
  93. </select>
  94. <select id="findNoPayCollageOrderIds" resultType="java.lang.Integer">
  95. select co.orderID from cm_hehe_collage_member chcm left join cm_order co on chcm.orderId = co.orderID
  96. where co.receiptStatus = 1 and chcm.collageId = #{collageId}
  97. </select>
  98. <insert id="insert" parameterType="CmHeheCollage" keyProperty="id" useGeneratedKeys="true">
  99. INSERT INTO cm_hehe_collage(
  100. productId,
  101. price
  102. ) VALUES (
  103. #{productId},
  104. #{price}
  105. )
  106. </insert>
  107. <update id="update">
  108. UPDATE cm_hehe_collage SET
  109. productId = #{productId},
  110. price = #{price}
  111. WHERE id = #{id}
  112. </update>
  113. <update id="completeCollage">
  114. update cm_hehe_collage
  115. set status = 2,
  116. completeTime = NOW(),
  117. remarks = '系统自动完成拼团'
  118. where id = #{collageId}
  119. </update>
  120. <delete id="delete">
  121. DELETE FROM cm_hehe_collage
  122. WHERE id = #{id}
  123. </delete>
  124. <delete id="cancelOrder">
  125. UPDATE
  126. cm_order
  127. SET
  128. STATUS = 6,
  129. updateDate = NOW(),
  130. closeReason = #{reason},
  131. closeTime = NOW()
  132. WHERE
  133. orderID = #{orderId}
  134. </delete>
  135. </mapper>