CmOrganizeProductMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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.weisha.dao.CmOrganizeProductDao">
  4. <sql id="cmOrganizeProductColumns">
  5. a.id AS "id",
  6. a.organizeId AS "organizeId",
  7. a.productId AS "productId",
  8. a.ladderPriceFlag AS "ladderPriceFlag",
  9. a.price AS "price",
  10. a.includedTax AS "includedTax",
  11. a.invoiceType AS "invoiceType",
  12. a.clubTaxPoint,
  13. a.shopTaxPoint,
  14. a.minBuyNumber AS "minBuyNumber",
  15. a.costType AS "costType",
  16. a.costPrice AS "costPrice",
  17. a.costProportional AS "costProportional",
  18. a.status AS "status",
  19. a.addTime AS "addTime",
  20. a.delFlag AS "delFlag",
  21. p.name AS "productName",
  22. p.mainImage AS "productImage",
  23. s.name AS "shopName"
  24. </sql>
  25. <sql id="cmOrganizeProductJoins">
  26. left join product p on a.productId = p.productID
  27. left join shop s on p.shopID = s.shopID
  28. </sql>
  29. <select id="getOrganizeProductList" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
  30. SELECT
  31. cmop.id,
  32. cmop.productID,
  33. p.name as productName,
  34. p.mainImage as productImage,
  35. s.name as shopName,
  36. cmop.validFlag as status,
  37. p.includedTax,
  38. p.invoiceType,
  39. cmop.addTime,
  40. cmps.minBuyNumber
  41. FROM cm_mall_organize_products cmop
  42. LEFT JOIN product p ON p.productId = cmop.productId
  43. LEFT JOIN shop s ON s.shopID = p.shopID
  44. LEFT JOIN cm_mall_product_sku cmps ON cmop.productID=cmps.productId
  45. <where>
  46. cmop.delFlag = 0
  47. <if test="productId != null and productId != ''">
  48. AND cmop.productId = #{productId}
  49. </if>
  50. <if test="productName != null and productName != ''">
  51. and p.name like concat('%',#{productName},'%')
  52. </if>
  53. <if test="shopName != null and shopName != ''">
  54. and s.name like concat('%',#{shopName},'%')
  55. </if>
  56. <if test="includedTax != null">
  57. AND p.includedTax = #{includedTax}
  58. </if>
  59. <if test="status != null and status != ''">
  60. AND cmop.validFlag = #{status}
  61. </if>
  62. <if test="invoiceType != null">
  63. AND p.invoiceType = #{invoiceType}
  64. </if>
  65. <if test="organizeId != null">
  66. AND cmop.organizeID = #{organizeId}
  67. </if>
  68. </where>
  69. GROUP BY cmop.id
  70. order by cmop.addTime desc
  71. </select>
  72. <select id="getOrganizeSku" resultType="com.caimei.modules.weisha.entity.CmOrganizeSku">
  73. SELECT
  74. cmps.id,
  75. cmps.productId,
  76. cmps.minBuyNumber,
  77. cmps.price,
  78. cmps.stock
  79. cmps.unit,
  80. cmps.organizePercent,
  81. cmps.shopPercent,
  82. cmps.cmPercent
  83. FROM cm_mall_product_sku cmps
  84. <where>
  85. <if test="productIds.size() > 0">
  86. cmps.productId in
  87. <foreach collection="productIds" item="productId" open="(" separator="," close=")">
  88. #{productId}
  89. </foreach>
  90. </if>
  91. </where>
  92. </select>
  93. <update id="updateproduct">
  94. update cm_mall_organize_products
  95. set validFlag = #{validFlag}
  96. where id = #{id}
  97. </update>
  98. <select id="findProductList" resultType="com.caimei.modules.product.entity.Product">
  99. select p.productID, p.mainImage, p.name,
  100. s.name as shopName, IF(cmop.productId is not null, 0, 1) as validFlag,k.price
  101. from product p
  102. left join cm_mall_organize_products cmop on p.productID = cmop.productId and cmop.organizeId = #{organizeId} and cmop.delFlag = 0
  103. left join shop s on p.shopID = s.shopID
  104. left join cm_sku k on p.productID = k.productId
  105. <where>
  106. p.productCategory = 1 AND p.validFlag not in ( 0,1,8 ) and s.shopType != 2 and cmop.productId is null
  107. AND p.shopID not in (SELECT s.`value` FROM `sys_dict` s WHERE s.type='heheShopID')
  108. AND p.productID NOT IN (6060, 6061, 6062, 6063, 6064,6065, 6066, 6067, 6068, 6069)
  109. <if test="productID != null">
  110. AND p.productID = #{productID}
  111. </if>
  112. <if test="name != null and name != ''">
  113. AND p.name LIKE concat('%',#{name},'%')
  114. </if>
  115. <if test="shopName != null and shopName != ''">
  116. AND s.name LIKE concat('%',#{shopName},'%')
  117. </if>
  118. </where>
  119. GROUP BY p.productID
  120. order by price asc
  121. </select>
  122. <select id="findProductByProductId" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
  123. select productID as productId,
  124. ifnull(includedTax, 2) as includedTax,
  125. invoiceType,
  126. taxPoint as clubTaxPoint,
  127. supplierTaxPoint as shopTaxPoint
  128. from product
  129. where productID = #{productId}
  130. </select>
  131. <select id="findFormerLadderPriceList"
  132. resultType="com.caimei.modules.weisha.entity.OrganizeProductLadderPrice">
  133. select ladderNum, buyNum, buyPrice
  134. from product_ladder_price
  135. where productId = #{productId}
  136. </select>
  137. <select id="getOrganizeInfo" resultType="com.caimei.modules.weisha.entity.CmMallOrganize">
  138. select a.id AS "id",
  139. a.organizeName AS "organizeName",
  140. a.organizeLinkName AS "organizeLinkName",
  141. a.mobile AS "mobile",
  142. a.status AS "status",
  143. a.contactNumber AS "contactNumber",
  144. a.systemName AS "systemName",
  145. a.systemImage AS "systemImage",
  146. a.introduction AS "introduction",
  147. a.afterSale AS "afterSale",
  148. a.shoppingNotes AS "shoppingNotes",
  149. a.updateTime AS "updateTime",
  150. a.addTime AS "addTime",
  151. a.delFlag AS "delFlag"
  152. from cm_mall_organize a
  153. where a.id = #{id}
  154. </select>
  155. <select id="getShopInfo" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
  156. SELECT
  157. p.productId,
  158. p.name AS productName,
  159. s.name AS shopName
  160. FROM product p
  161. LEFT JOIN shop s ON p.shopId = s.shopId
  162. <where>
  163. <if test="productIds.size()>0">
  164. productId in
  165. <foreach collection="productIds" item="productId" open="(" separator="," close=")">
  166. #{productId}
  167. </foreach>
  168. </if>
  169. </where>
  170. </select>
  171. <select id="getSkuInfo" resultType="com.caimei.modules.product.entity.CmSku">
  172. SELECT skuId,
  173. productId,
  174. normalPrice,
  175. price,
  176. costPrice,
  177. ladderPriceFlag,
  178. minBuyNumber
  179. FROM cm_sku
  180. where productId = #{productId}
  181. order by normalPrice
  182. </select>
  183. <insert id="insertMallProduct" parameterType="CmOrganizeProduct" keyProperty="id" useGeneratedKeys="true">
  184. INSERT INTO cm_mall_organize_products (organizeID, productID, normalPrice, costPrice, ladderPriceFlag,
  185. retailPrice, minBuyNumber, validFlag, ADDTIME, updateTime, delFlag)
  186. VALUES (#{organizeId}, #{productId}, #{normalPrice}, #{costPrice}, #{ladderPriceFlag}, #{retailPrice},
  187. #{minBuyNumber}, #{status}, #{addTime}, #{updateTime}, #{delFlag})
  188. </insert>
  189. <insert id="insertMallSku">
  190. INSERT INTO cm_mall_product_sku(productId, mallProductId, minBuyNumber, price)
  191. VALUES (#{productId}, #{mallProductId}, #{minBuyNumber}, #{price})
  192. </insert>
  193. <update id="updateMallProduct">
  194. update cm_mall_organize_products
  195. <set>
  196. <if test="retailPrice != null and retailPrice != ''">
  197. retailPrice = #{retailPrice},
  198. </if>
  199. <if test="minBuyNumber != null and minBuyNumber != ''">
  200. minBuyNumber = #{minBuyNumber}
  201. </if>
  202. </set>
  203. where id =#{id}
  204. </update>
  205. <update id="updateMallProductSku">
  206. update cm_mall_product_sku
  207. <set>
  208. <if test="price != null and price != ''">
  209. price = #{price},
  210. </if>
  211. <if test="minBuyNumber != null and minBuyNumber != ''">
  212. minBuyNumber = #{minBuyNumber},
  213. </if>
  214. <if test="organizePercent != null and organizePercent != ''">
  215. organizePercent = #{organizePercent},
  216. </if>
  217. <if test="shopPercent != null and shopPercent != ''">
  218. shopPercent = #{shopPercent},
  219. </if>
  220. <if test="cmPercent != null and cmPercent != ''">
  221. cmPercent = #{cmPercent}
  222. </if>
  223. </set>
  224. where id =#{id}
  225. </update>
  226. <select id="getProductInfo" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
  227. SELECT cmop.id,
  228. cmop.organizeID AS organizeId,
  229. p.productID AS productId,
  230. p.mainImage AS productImage,
  231. p.name AS productName,
  232. s.name AS shopName,
  233. IF(cmop.productId IS NOT NULL, 0, 1) AS validFlag,
  234. p.includedTax,
  235. p.invoiceType,
  236. p.taxPoint,
  237. p.supplierTaxPoint
  238. FROM product p
  239. LEFT JOIN cm_mall_organize_products cmop ON p.productID = cmop.productId
  240. LEFT JOIN shop s ON p.shopID = s.shopID
  241. WHERE p.productCategory = 1
  242. AND cmop.id = #{id}
  243. </select>
  244. <update id="deleteProduct">
  245. update cm_mall_organize_products
  246. set delFlag = 1
  247. where id = #{id}
  248. </update>
  249. <delete id="deleteMallProductSku">
  250. delete
  251. from cm_mall_product_sku
  252. where mallProductId = #{id}
  253. </delete>
  254. </mapper>