CmOrganizeProductMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. # p.unit,
  24. s.name AS "shopName"
  25. </sql>
  26. <sql id="cmOrganizeProductJoins">
  27. left join product p on a.productId = p.productID
  28. left join shop s on p.shopID = s.shopID
  29. </sql>
  30. <select id="get" resultType="CmOrganizeProduct">
  31. SELECT
  32. <include refid="cmOrganizeProductColumns"/>
  33. FROM cm_organize_product a
  34. <include refid="cmOrganizeProductJoins"/>
  35. WHERE a.id = #{id}
  36. </select>
  37. <select id="findList" resultType="CmOrganizeProduct">
  38. SELECT
  39. <include refid="cmOrganizeProductColumns"/>
  40. FROM cm_organize_product a
  41. <include refid="cmOrganizeProductJoins"/>
  42. <where>
  43. a.delFlag = 0
  44. and p.productCategory = 1
  45. <if test="id != null and id != ''">
  46. AND a.id = #{id}
  47. </if>
  48. <if test="productName != null and productName != ''">
  49. and p.name like concat('%',#{productName},'%')
  50. </if>
  51. <if test="shopName != null and shopName != ''">
  52. and s.name like concat('%',#{shopName},'%')
  53. </if>
  54. <if test="includedTax != null">
  55. AND a.includedTax = #{includedTax}
  56. </if>
  57. <if test="invoiceType != null">
  58. AND a.invoiceType = #{invoiceType}
  59. </if>
  60. <if test="status != null">
  61. AND a.status = #{status}
  62. </if>
  63. <if test="organizeId != null">
  64. AND a.organizeId = #{organizeId}
  65. </if>
  66. </where>
  67. order by a.addTime desc
  68. </select>
  69. <select id="findAllList" resultType="CmOrganizeProduct">
  70. SELECT
  71. <include refid="cmOrganizeProductColumns"/>
  72. FROM cm_organize_product a
  73. <include refid="cmOrganizeProductJoins"/>
  74. <where>
  75. </where>
  76. <choose>
  77. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  78. ORDER BY ${page.orderBy}
  79. </when>
  80. <otherwise>
  81. </otherwise>
  82. </choose>
  83. </select>
  84. <select id="getOrganizeProductList" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
  85. SELECT
  86. cmop.id,
  87. cmop.productID,
  88. p.name as productName,
  89. p.mainImage as productImage,
  90. s.name as shopName,
  91. cmop.validFlag as status,
  92. p.includedTax,
  93. p.invoiceType,
  94. cmop.addTime
  95. FROM cm_mall_organize_products cmop
  96. LEFT JOIN product p ON p.productId = cmop.productId
  97. LEFT JOIN shop s ON s.shopID = p.shopID
  98. <where>
  99. cmop.delFlag = 0
  100. <if test="productId != null and productId != ''">
  101. AND cmop.productId = #{productId}
  102. </if>
  103. <if test="productName != null and productName != ''">
  104. and p.name like concat('%',#{productName},'%')
  105. </if>
  106. <if test="shopName != null and shopName != ''">
  107. and s.name like concat('%',#{shopName},'%')
  108. </if>
  109. <if test="includedTax != null">
  110. AND p.includedTax = #{includedTax}
  111. </if>
  112. <if test="status != null and status != ''">
  113. AND cmop.validFlag = #{status}
  114. </if>
  115. <if test="invoiceType != null">
  116. AND p.invoiceType = #{invoiceType}
  117. </if>
  118. <if test="organizeId != null">
  119. AND cmop.organizeID = #{organizeId}
  120. </if>
  121. </where>
  122. order by cmop.addTime desc
  123. </select>
  124. <select id="getOrganizeSku" resultType="com.caimei.modules.weisha.entity.CmOrganizeSku">
  125. SELECT
  126. cmps.id,
  127. cmps.productId,
  128. cmps.id,
  129. cmps.skuId,
  130. cmps.minBuyNumber,
  131. cmps.price,
  132. cs.unit,
  133. cs.price as clubPrice,
  134. cs.costCheckFlag as costCheckFlag,
  135. cs.costPrice as costPrice,
  136. cs.costProportional as costProportional,
  137. cs.minBuyNumber AS cmMinBuyNumber,
  138. cmps.organizePercent,
  139. cmps.shopPercent,
  140. cmps.cmPercent
  141. FROM cm_mall_product_sku cmps
  142. LEFT JOIN cm_sku cs ON cmps.skuId = cs.skuId
  143. <where>
  144. <if test="productIds.size() > 0">
  145. cmps.productId in
  146. <foreach collection="productIds" item="productId" open="(" separator="," close=")">
  147. #{productId}
  148. </foreach>
  149. </if>
  150. </where>
  151. </select>
  152. <update id="updateproduct">
  153. update cm_mall_organize_products
  154. set validFlag = #{validFlag}
  155. where id = #{id}
  156. </update>
  157. <select id="findProductList" resultType="com.caimei.modules.product.entity.Product">
  158. select p.productID, p.mainImage, p.name,
  159. s.name as shopName, IF(cmop.productId is not null, 0, 1) as validFlag
  160. from product p
  161. left join cm_mall_organize_products cmop on p.productID = cmop.productId and cmop.organizeId = #{organizeId} and cmop.delFlag = 0
  162. left join shop s on p.shopID = s.shopID
  163. <where>
  164. p.productCategory = 1
  165. <if test="productID != null">
  166. AND p.productID = #{productID}
  167. </if>
  168. <if test="name != null and name != ''">
  169. AND p.name LIKE concat('%',#{name},'%')
  170. </if>
  171. <if test="shopName != null and shopName != ''">
  172. AND s.name LIKE concat('%',#{shopName},'%')
  173. </if>
  174. </where>
  175. </select>
  176. <select id="findProductByProductId" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
  177. select productID as productId, # ladderPriceFlag, price as price,
  178. ifnull(includedTax,2) as includedTax,invoiceType,taxPoint as clubTaxPoint,supplierTaxPoint as shopTaxPoint # minBuyNumber,
  179. # costCheckFlag as costType,
  180. # costPrice,costProportional
  181. from product
  182. where productID = #{productId}
  183. </select>
  184. <select id="findLadderPrice" resultType="com.caimei.modules.weisha.entity.OrganizeProductLadderPrice">
  185. select * from organize_product_ladder_price where productId = #{productId}
  186. </select>
  187. <select id="findFormerLadderPriceList"
  188. resultType="com.caimei.modules.weisha.entity.OrganizeProductLadderPrice">
  189. select ladderNum,buyNum,buyPrice from product_ladder_price where productId = #{productId}
  190. </select>
  191. <select id="getOrganizeInfo" resultType="com.caimei.modules.weisha.entity.CmMallOrganize">
  192. select a.id AS "id",
  193. a.organizeName AS "organizeName",
  194. a.organizeLinkName AS "organizeLinkName",
  195. a.mobile AS "mobile",
  196. a.status AS "status",
  197. a.contactNumber AS "contactNumber",
  198. a.systemName AS "systemName",
  199. a.systemImage AS "systemImage",
  200. a.introduction AS "introduction",
  201. a.afterSale AS "afterSale",
  202. a.shoppingNotes AS "shoppingNotes",
  203. a.updateTime AS "updateTime",
  204. a.addTime AS "addTime",
  205. a.delFlag AS "delFlag"
  206. from cm_mall_organize a
  207. where a.id = #{id}
  208. </select>
  209. <select id="getShopInfo" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
  210. SELECT
  211. p.productId,
  212. p.name AS productName,
  213. s.name AS shopName
  214. FROM product p
  215. LEFT JOIN shop s ON p.shopId = s.shopId
  216. <where>
  217. <if test="productIds.size()>0">
  218. productId in
  219. <foreach collection="productIds" item="productId" open="(" separator="," close=")">
  220. #{productId}
  221. </foreach>
  222. </if>
  223. </where>
  224. </select>
  225. <select id="getSkuInfo" resultType="com.caimei.modules.product.entity.CmSku">
  226. SELECT
  227. skuId,
  228. productId,
  229. normalPrice,
  230. price,
  231. costPrice,
  232. ladderPriceFlag,
  233. minBuyNumber
  234. FROM cm_sku
  235. where productId = #{productId}
  236. order by normalPrice
  237. </select>
  238. <insert id="insertMallProduct" parameterType="CmOrganizeProduct" keyProperty="id" useGeneratedKeys="true">
  239. INSERT INTO cm_mall_organize_products (organizeID, productID, normalPrice, costPrice, ladderPriceFlag, retailPrice, minBuyNumber, validFlag, ADDTIME, updateTime, delFlag)
  240. VALUES(#{organizeId}, #{productId}, #{normalPrice}, #{costPrice}, #{ladderPriceFlag}, #{retailPrice}, #{minBuyNumber}, #{status},#{addTime}, #{updateTime}, #{delFlag})
  241. </insert>
  242. <insert id="insertMallSku">
  243. INSERT INTO cm_mall_product_sku(skuId, productId, mallProductId, minBuyNumber, price)
  244. VALUES (#{skuId}, #{productId}, #{mallProductId}, #{minBuyNumber}, #{price})
  245. </insert>
  246. <update id="updateMallProduct">
  247. update cm_mall_organize_products
  248. <set>
  249. <if test="retailPrice != null and retailPrice != ''">
  250. retailPrice = #{retailPrice},
  251. </if>
  252. <if test="minBuyNumber != null and minBuyNumber != ''">
  253. minBuyNumber = #{minBuyNumber}
  254. </if>
  255. </set>
  256. where id =#{id}
  257. </update>
  258. <update id="updateMallProductSku">
  259. update cm_mall_product_sku
  260. <set>
  261. <if test="price != null and price != ''">
  262. price = #{price},
  263. </if>
  264. <if test="minBuyNumber != null and minBuyNumber != ''">
  265. minBuyNumber = #{minBuyNumber},
  266. </if>
  267. <if test="organizePercent != null and organizePercent != ''">
  268. organizePercent = #{organizePercent},
  269. </if>
  270. <if test="shopPercent != null and shopPercent != ''">
  271. shopPercent = #{shopPercent},
  272. </if>
  273. <if test="cmPercent != null and cmPercent != ''">
  274. cmPercent = #{cmPercent}
  275. </if>
  276. </set>
  277. where id =#{id}
  278. </update>
  279. <select id="getProductInfo" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
  280. SELECT cmop.id,
  281. cmop.organizeID AS organizeId,
  282. p.productID AS productId,
  283. p.mainImage AS productImage,
  284. p.name AS productName,
  285. s.name AS shopName,
  286. IF(cmop.productId IS NOT NULL, 0, 1) AS validFlag,
  287. p.includedTax,
  288. p.invoiceType,
  289. p.taxPoint,
  290. p.supplierTaxPoint
  291. FROM product p
  292. LEFT JOIN cm_mall_organize_products cmop ON p.productID = cmop.productId
  293. LEFT JOIN shop s ON p.shopID = s.shopID
  294. WHERE p.productCategory = 1 AND cmop.id = #{id}
  295. </select>
  296. <update id="deleteProduct">
  297. update cm_mall_organize_products
  298. set delFlag = 1
  299. where id = #{id}
  300. </update>
  301. <insert id="insert" parameterType="CmOrganizeProduct" keyProperty="id" useGeneratedKeys="true">
  302. INSERT INTO cm_organize_product(
  303. organizeId,
  304. productId,
  305. ladderPriceFlag,
  306. price,
  307. includedTax,
  308. invoiceType,
  309. clubTaxPoint,
  310. shopTaxPoint,
  311. minBuyNumber,
  312. costType,
  313. costPrice,
  314. costProportional,
  315. addTime
  316. ) VALUES (
  317. #{organizeId},
  318. #{productId},
  319. #{ladderPriceFlag},
  320. #{price},
  321. #{includedTax},
  322. #{invoiceType},
  323. #{clubTaxPoint},
  324. #{shopTaxPoint},
  325. #{minBuyNumber},
  326. #{costType},
  327. #{costPrice},
  328. #{costProportional},
  329. #{addTime}
  330. )
  331. </insert>
  332. <insert id="insertLadderPrice">
  333. insert into organize_product_ladder_price(
  334. productId, ladderNum, buyNum, buyPrice
  335. ) values (#{productId},#{ladderNum},#{buyNum},#{buyPrice})
  336. </insert>
  337. <update id="update">
  338. UPDATE cm_organize_product SET
  339. ladderPriceFlag = #{ladderPriceFlag},
  340. price = #{price},
  341. includedTax = #{includedTax},
  342. invoiceType = #{invoiceType},
  343. clubTaxPoint = #{clubTaxPoint},
  344. shopTaxPoint = #{shopTaxPoint},
  345. minBuyNumber = #{minBuyNumber},
  346. costType = #{costType},
  347. costPrice = #{costPrice},
  348. costProportional = #{costProportional},
  349. status = #{status},
  350. addTime = #{addTime},
  351. delFlag = #{delFlag}
  352. WHERE id = #{id}
  353. </update>
  354. <update id="updateStatus">
  355. UPDATE cm_organize_product SET
  356. status = #{status}
  357. WHERE id = #{id}
  358. </update>
  359. <update id="updateLadderPrice">
  360. update organize_product_ladder_price
  361. set productId = #{productId},ladderNum = #{ladderNum},buyNum=#{buyNum},buyPrice=#{buyPrice}
  362. where id = #{id}
  363. </update>
  364. <update id="updateLadderPriceFlag">
  365. update cm_organize_product set ladderPriceFlag = #{ladderPriceFlag} where id = #{productId}
  366. </update>
  367. <delete id="delete">
  368. UPDATE cm_organize_product set delFlag = 1 where id = #{id}
  369. </delete>
  370. <delete id="deleteLadderPriceById">
  371. delete from organize_product_ladder_price where id = #{ladderId}
  372. </delete>
  373. </mapper>