CmHeheProductMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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.CmHeheProductDao">
  4. <sql id="cmHeheProductColumns">
  5. a.id AS "id",
  6. a.productId AS "productId",
  7. a.validFlag AS "validFlag",
  8. a.price AS "price",
  9. a.includedTax AS "includedTax",
  10. a.invoiceType AS "invoiceType",
  11. a.clubTaxPoint AS "clubTaxPoint",
  12. a.shopTaxPoint AS "shopTaxPoint",
  13. p.costCheckFlag AS "costType",
  14. p.costPrice AS "costPrice",
  15. p.costProportional AS "costProportional",
  16. a.addTime AS "addTime",
  17. p.name AS "name",
  18. p.mainImage AS "mainImage",
  19. s.name AS "shopName",
  20. chap.activityId,
  21. group_concat(chfp.floorId) as floorIds
  22. </sql>
  23. <sql id="cmHeheProductJoins">
  24. LEFT JOIN product p ON a.productId = p.productID
  25. LEFT JOIN shop s ON s.shopID = p.shopID
  26. left join cm_hehe_activity_product chap on a.productId = chap.productId
  27. left join cm_hehe_floor_product chfp on a.productId = chfp.productId
  28. </sql>
  29. <select id="get" resultType="CmHeheProduct">
  30. SELECT
  31. <include refid="cmHeheProductColumns"/>
  32. FROM cm_hehe_product a
  33. <include refid="cmHeheProductJoins"/>
  34. WHERE a.id = #{id}
  35. group by a.id
  36. </select>
  37. <select id="findList" resultType="CmHeheProduct">
  38. SELECT
  39. <include refid="cmHeheProductColumns"/>
  40. FROM cm_hehe_product a
  41. <include refid="cmHeheProductJoins"/>
  42. <where>
  43. <if test="productId != null and productId != ''">
  44. AND a.productId = #{productId}
  45. </if>
  46. <if test="validFlag != null and validFlag != ''">
  47. AND a.validFlag = #{validFlag}
  48. </if>
  49. <if test="includedTax != null and includedTax != ''">
  50. AND a.includedTax = #{includedTax}
  51. </if>
  52. <if test="invoiceType != null and invoiceType != ''">
  53. AND a.invoiceType = #{invoiceType}
  54. </if>
  55. <if test="id != null and id != ''">
  56. AND a.id = #{id}
  57. </if>
  58. <if test="name != null and name != ''">
  59. AND p.name LIKE CONCAT('%',#{name},'%')
  60. </if>
  61. <if test="shopName != null and shopName != ''">
  62. AND s.name LIKE CONCAT('%',#{shopName},'%')
  63. </if>
  64. </where>
  65. group by a.id
  66. <choose>
  67. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  68. ORDER BY ${page.orderBy}
  69. </when>
  70. <otherwise>
  71. ORDER BY addTime DESC
  72. </otherwise>
  73. </choose>
  74. </select>
  75. <select id="findAllList" resultType="CmHeheProduct">
  76. SELECT
  77. <include refid="cmHeheProductColumns"/>
  78. FROM cm_hehe_product a
  79. <include refid="cmHeheProductJoins"/>
  80. <where>
  81. </where>
  82. <choose>
  83. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  84. ORDER BY ${page.orderBy}
  85. </when>
  86. <otherwise>
  87. </otherwise>
  88. </choose>
  89. </select>
  90. <insert id="insert" parameterType="CmHeheProduct" keyProperty="id" useGeneratedKeys="true">
  91. INSERT INTO cm_hehe_product(
  92. productId,
  93. validFlag,
  94. price,
  95. includedTax,
  96. invoiceType,
  97. clubTaxPoint,
  98. shopTaxPoint,
  99. addTime
  100. ) VALUES (
  101. #{productId},
  102. #{validFlag},
  103. #{price},
  104. #{includedTax},
  105. #{invoiceType},
  106. #{clubTaxPoint},
  107. #{shopTaxPoint},
  108. NOW()
  109. )
  110. </insert>
  111. <insert id="addActivityProduct">
  112. insert into cm_hehe_activity_product (activityId, productId, addTime, delFlag)
  113. values (#{activityId}, #{productId}, NOW(), 0)
  114. </insert>
  115. <insert id="addFloorProduct">
  116. insert into cm_hehe_floor_product(floorId, productId, validFlag, recommend, sort, addTime)
  117. VALUES (#{floorId}, #{productId}, 1, 0, 1, NOW())
  118. </insert>
  119. <update id="update">
  120. UPDATE cm_hehe_product SET
  121. productId = #{productId},
  122. validFlag = #{validFlag},
  123. price = #{price},
  124. includedTax = #{includedTax},
  125. invoiceType = #{invoiceType},
  126. clubTaxPoint = #{clubTaxPoint},
  127. shopTaxPoint = #{shopTaxPoint}
  128. WHERE id = #{id}
  129. </update>
  130. <delete id="delete">
  131. DELETE FROM cm_hehe_product
  132. WHERE id = #{id}
  133. </delete>
  134. <select id="findHeHeProductId" resultType="integer">
  135. SELECT productId FROM cm_hehe_product
  136. </select>
  137. <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
  138. SELECT
  139. a.*,s.name AS "shopName"
  140. FROM product a
  141. LEFT JOIN shop s on s.shopID = a.shopID
  142. <where>
  143. a.splitCode is not null and a.splitCode != ''
  144. <if test="productID != null" >
  145. AND a.productID = #{productID}
  146. </if>
  147. <if test="name != null and name != ''">
  148. AND a.name LIKE concat('%',#{name},'%')
  149. </if>
  150. <if test="shopName != null and shopName != ''">
  151. AND s.name LIKE concat('%',#{shopName},'%')
  152. </if>
  153. <if test="ids != null and ids.size() > 0 ">
  154. AND a.productID NOT IN
  155. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  156. #{id}
  157. </foreach>
  158. </if>
  159. </where>
  160. <choose>
  161. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  162. ORDER BY ${page.orderBy}
  163. </when>
  164. <otherwise>
  165. order by a.productID
  166. </otherwise>
  167. </choose>
  168. </select>
  169. <select id="findCouponProduct" resultType="com.caimei.modules.product.entity.Product">
  170. SELECT
  171. a.*,s.name AS "shopName"
  172. FROM cm_hehe_product
  173. product a
  174. LEFT JOIN shop s on s.shopID = a.shopID
  175. <where>
  176. <if test="productID != null" >
  177. AND a.productID = #{productID}
  178. </if>
  179. <if test="name != null and name != ''">
  180. AND a.name LIKE concat('%',#{name},'%')
  181. </if>
  182. <if test="shopName != null and shopName != ''">
  183. AND s.name LIKE concat('%',#{shopName},'%')
  184. </if>
  185. <if test="ids != null and ids.size() > 0 ">
  186. AND a.productID NOT IN
  187. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  188. #{id}
  189. </foreach>
  190. </if>
  191. </where>
  192. <choose>
  193. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  194. ORDER BY ${page.orderBy}
  195. </when>
  196. <otherwise>
  197. order by a.productID
  198. </otherwise>
  199. </choose>
  200. </select>
  201. <select id="findProductActivity" resultType="java.lang.Integer">
  202. select activityId from cm_hehe_activity_product where productId = #{productId}
  203. </select>
  204. <update id="deleteActivityProduct">
  205. UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE productId = #{productId}
  206. </update>
  207. <update id="updateProductId">
  208. update cm_hehe_product set productId = #{newProductId} where id = #{heheProductId}
  209. </update>
  210. </mapper>