CmHeheCollageProductMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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.CmHeheCollageProductDao">
  4. <sql id="cmHeheCollageProductColumns">
  5. a.id AS "id",
  6. a.productId AS "productId",
  7. a.limitedNum AS "limitedNum",
  8. a.unlimitedFlag AS "unlimitedFlag",
  9. a.memberNum AS "memberNum",
  10. a.status AS "status",
  11. a.addTime AS "addTime",
  12. s.name AS shopName,
  13. p.name AS productName,
  14. p.mainImage AS productImage
  15. </sql>
  16. <sql id="cmHeheCollageProductJoins">
  17. left join product p on a.productId = p.productID
  18. left join cm_hehe_product chp on p.productID = chp.productId
  19. left join shop s on p.shopID = s.shopID
  20. </sql>
  21. <select id="get" resultType="CmHeheCollageProduct">
  22. SELECT
  23. <include refid="cmHeheCollageProductColumns"/>
  24. FROM cm_hehe_collage_product a
  25. <include refid="cmHeheCollageProductJoins"/>
  26. WHERE a.id = #{id}
  27. </select>
  28. <select id="findList" resultType="CmHeheCollageProduct">
  29. SELECT
  30. <include refid="cmHeheCollageProductColumns"/>
  31. FROM cm_hehe_collage_product a
  32. <include refid="cmHeheCollageProductJoins"/>
  33. <where>
  34. chp.id is not null
  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 a.addTime desc
  54. </otherwise>
  55. </choose>
  56. </select>
  57. <select id="findAllList" resultType="CmHeheCollageProduct">
  58. SELECT
  59. <include refid="cmHeheCollageProductColumns"/>
  60. FROM cm_hehe_collage_product a
  61. <include refid="cmHeheCollageProductJoins"/>
  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="findReductionProductIds" resultType="java.lang.Integer">
  73. select chp.id
  74. from cm_hehe_reduction chap
  75. left join cm_hehe_product chp on chap.productId = chp.productId;
  76. </select>
  77. <select id="getProductId" resultType="java.lang.Integer">
  78. select productId
  79. from cm_hehe_product
  80. where id = #{heheProductId}
  81. </select>
  82. <select id="findCollageSku" resultType="com.caimei.modules.product.entity.CmSku">
  83. select chs.price as 'price', chcs.collagePrice , chs.skuId
  84. from cm_hehe_sku chs
  85. left join cm_hehe_collage_sku chcs on chs.skuId = chcs.skuId
  86. left join cm_hehe_product chp on chs.productId = chp.productId
  87. where chs.productId = #{productId}
  88. </select>
  89. <select id="findCollageByHeHeId" resultType="com.caimei.modules.product.entity.CmSku">
  90. select chs.price as 'price', chcs.collagePrice as 'price', chs.skuId
  91. from cm_hehe_sku chs
  92. left join cm_hehe_collage_sku chcs on chs.skuId = chcs.skuId
  93. left join cm_hehe_product chp on chs.productId = chp.productId
  94. where chp.id = #{productId}
  95. </select>
  96. <select id="getSkuCollage" resultType="com.caimei.modules.product.entity.CmSku">
  97. select skuId, productId, collagePrice
  98. from cm_hehe_collage_sku
  99. where skuId = #{skuId}
  100. </select>
  101. <select id="getCollagePrice" resultType="java.lang.Double">
  102. select collagePrice
  103. from cm_hehe_collage_sku
  104. where productId = #{productId}
  105. order by collagePrice asc
  106. limit 1
  107. </select>
  108. <insert id="insert" parameterType="CmHeheCollageProduct" keyProperty="id" useGeneratedKeys="true">
  109. INSERT INTO cm_hehe_collage_product(productId,
  110. limitedNum,
  111. unlimitedFlag,
  112. memberNum,
  113. status,
  114. addTime)
  115. VALUES ((select productId from cm_hehe_product where id = #{productId}),
  116. #{limitedNum},
  117. #{unlimitedFlag},
  118. #{memberNum},
  119. #{status},
  120. NOW())
  121. </insert>
  122. <insert id="insertSkuCollage">
  123. insert into cm_hehe_collage_sku(skuId, productid, collageprice)
  124. values (#{skuId}, (select productId from cm_sku where skuId = #{skuId}), #{collagePrice})
  125. </insert>
  126. <update id="update">
  127. UPDATE cm_hehe_collage_product
  128. SET productId = #{productId},
  129. limitedNum = #{limitedNum},
  130. unlimitedFlag = #{unlimitedFlag},
  131. memberNum = #{memberNum},
  132. status = #{status}
  133. WHERE id = #{id}
  134. </update>
  135. <update id="updateStatus">
  136. update cm_hehe_collage_product
  137. set status = #{status}
  138. where id = #{id}
  139. </update>
  140. <update id="updateProductId">
  141. update cm_hehe_collage_product
  142. set productId = #{newProductId}
  143. where productId = #{oldProductId}
  144. </update>
  145. <update id="updateSkuCollage">
  146. update cm_hehe_collage_sku
  147. set collagePrice=#{collagePrice}
  148. where skuId = #{skuId}
  149. </update>
  150. <delete id="delete">
  151. DELETE
  152. FROM cm_hehe_collage_product
  153. WHERE id = #{id}
  154. </delete>
  155. </mapper>