OrderProductMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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.order.dao.NewOrderProductDao">
  4. <resultMap id="ResultorderProduct" type="NewOrderProduct">
  5. <result property="productID" column="productId"/>
  6. <result column="id" property="contractProductId"/>
  7. <result column="shopName" property="shopName"/>
  8. <result column="shopId" property="shopId"/>
  9. <result column="price" property="price"/>
  10. <result column="discount" property="discount"/>
  11. <result column="discountPrice" property="discountPrice"/>
  12. <result column="taxRate" property="taxRate"/>
  13. <result column="addedValueTax" property="addedValueTax"/>
  14. <result column="totalAddedValueTax" property="totalAddedValueTax"/>
  15. <result column="stipulateFlag" property="stipulateFlag"/>
  16. <result column="name" property="name"/>
  17. <result column="image" property="image"/>
  18. <result column="contractId" property="contractId"/>
  19. <result column="shopFee" property="shopFee"/>
  20. <result column="otherFee" property="otherFee"/>
  21. <result column="cmFee" property="cmFee"/>
  22. <result column="ladderPriceFlag" property="ladderPriceFlag"/>
  23. </resultMap>
  24. <sql id="orderProductColumns">
  25. a.skuID AS skuId,
  26. a.`orderProductID` AS `orderProductID`,
  27. a.`orderNo` AS `orderNo`,
  28. a.`orderID` AS `orderID`,
  29. a.`shopOrderID` AS `shopOrderID`,
  30. a.`shopOrderNo` AS `shopOrderNo`,
  31. a.`shopID` AS `shopID`,
  32. a.`productID` AS `productID`,
  33. a.`num` AS `num`,
  34. a.`presentNum` AS `presentNum`,
  35. a.`outStoreType` AS `outStoreType`,
  36. a.`productNo` AS `productNo`,
  37. a.`price` AS `price`,
  38. a.`normalPrice` AS `normalPrice`,
  39. a.`totalAmount` AS `totalAmount`,
  40. a.`totalFee` AS `totalFee`,
  41. a.`shouldPayFee` AS `shouldPayFee`,
  42. a.`discount` AS `discount`,
  43. a.`discountPrice` AS `discountPrice`,
  44. a.`ladderPriceFlag` AS `ladderPriceFlag`,
  45. a.`taxRate` AS `taxRate`,
  46. a.`addedValueTax` AS `addedValueTax`,
  47. a.`totalAddedValueTax` AS `totalAddedValueTax`,
  48. IFNULL(a.`includedTax`, 2) AS `includedTax`,
  49. IFNULL(a.`invoiceType`, 3) AS `invoiceType`,
  50. IFNULL(a.`supplierTaxRate`, 0) AS `supplierTaxRate`,
  51. IFNULL(a.`singleShouldPayTotalTax`, 0) AS `singleShouldPayTotalTax`,
  52. IFNULL(a.`shouldPayTotalTax` ,0) AS `shouldPayTotalTax`,
  53. a.`shopFee` AS `shopFee`,
  54. a.`otherFee` AS `otherFee`,
  55. a.`cmFee` AS `cmFee`,
  56. a.`singleShopFee` AS `singleShopFee`,
  57. a.`singleOtherFee` AS `singleOtherFee`,
  58. a.`singleCmFee` AS `singleCmFee`,
  59. a.`status` AS `status`,
  60. a.`totalBeans` AS `totalBeans`,
  61. a.`useBalanceAmount` AS `useBalanceAmount`,
  62. a.`useBeanAmount` AS `useBeanAmount`,
  63. a.`notOutStore` AS `notOutStore`,
  64. a.`cmbeanPrice` AS `cmbeanPrice`,
  65. a.`isActProduct` AS `isActProduct`,
  66. a.`isGiftProduct` AS `isGiftProduct`,
  67. a.`productActInfo` AS `productActInfo`,
  68. a.`buyAgainFlag` AS `buyAgainFlag`,
  69. a.`confirmProductFlag` AS `confirmProductFlag`,
  70. a.`payStatus` AS `payStatus`,
  71. a.`name` AS `name`,
  72. a.`actType` AS `actType`,
  73. a.productType AS productType,
  74. a.orderPromotionsId AS orderPromotionsId,
  75. a.`actPreferential` AS `actPreferential`,
  76. a.`preferential` AS `preferential`,
  77. (select mainImage from product p where p.productID = a.productID group by p.productID) AS image,
  78. a.`discountFee` AS `discountFee`,
  79. a.`productUnit` AS `productUnit`,
  80. a.`productImage` AS `productImage`,
  81. a.`shopName` AS `shopName`,
  82. cs.stock AS stock,
  83. (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
  84. cs.costPrice AS costPrice,
  85. cs.organizeId AS organizeId,
  86. cs.unit AS unit,
  87. a.costPrice as newCostPrice,
  88. p.aliasName AS aliasName,
  89. a.singleShouldPayTotalTax AS singleShouldPayTotalTax,
  90. a.heUserId AS heUserId,
  91. p.productCategory as "productCategory",
  92. a.svipPriceFlag,
  93. a.svipPriceType,
  94. a.svipDiscount,
  95. a.svipReduction,
  96. p.returnGoodsStutas,
  97. p.machineType
  98. </sql>
  99. <sql id="orderProductJoins">
  100. left join cm_sku cs on cs.skuId = a.skuId and cs.organizeId=a.organizeID
  101. LEFT JOIN product p ON p.productID = a.productID
  102. </sql>
  103. <select id="get" resultType="NewOrderProduct">
  104. SELECT
  105. <include refid="orderProductColumns"/>
  106. FROM cm_order_product a
  107. <include refid="orderProductJoins"/>
  108. WHERE a.orderProductID = #{orderProductID}
  109. -- group by p.productID
  110. </select>
  111. <select id="findListByShopOrderID" resultType="NewOrderProduct">
  112. SELECT
  113. <include refid="orderProductColumns"/>
  114. ,csdh.secondHandType AS "secondHandType"
  115. FROM cm_order_product a
  116. <include refid="orderProductJoins"/>
  117. LEFT JOIN cm_second_hand_detail csdh ON csdh.productID = a.productID
  118. WHERE a.shopOrderID = #{shopOrderID}
  119. -- group by p.productID
  120. </select>
  121. <select id="findListProductOrderID" resultType="com.caimei.modules.order.entity.NewOrderProduct">
  122. SELECT
  123. <include refid="orderProductColumns"/>
  124. ,csdh.secondHandType AS "secondHandType"
  125. FROM cm_order_product a
  126. <include refid="orderProductJoins"/>
  127. LEFT JOIN cm_second_hand_detail csdh ON csdh.productID = a.productID
  128. WHERE a.orderID = #{orderID}
  129. -- group by p.productID
  130. </select>
  131. <select id="getListByShopOrderID" resultType="NewOrderProduct">
  132. select cop.*, cpo.touchPrice as touchPrice
  133. From cm_order_product cop
  134. LEFT JOIN product p on p.productID = cop.productID
  135. LEFT JOIN cm_promotions_order cpo on (cop.orderPromotionsId = cpo.id and cpo.mode = 1)
  136. where cop.shopOrderID = #{shopOrderID}
  137. </select>
  138. <select id="findListByOrderID" resultType="NewOrderProduct">
  139. SELECT
  140. <include refid="orderProductColumns"/>
  141. FROM cm_order_product a
  142. <include refid="orderProductJoins"/>
  143. WHERE a.orderID = #{orderID}
  144. -- group by p.productID
  145. </select>
  146. <select id="findAllList" resultType="NewOrderProduct">
  147. SELECT
  148. <include refid="orderProductColumns"/>
  149. FROM cm_order_product a
  150. <include refid="orderProductJoins"/>
  151. <where>
  152. <if test="orderID != null and orderID != ''">
  153. AND a.orderID = #{orderID}
  154. </if>
  155. <if test="shopID != null and shopID != ''">
  156. AND a.shopID = #{shopID}
  157. </if>
  158. <if test="shopOrderID != null and shopOrderID != ''">
  159. AND a.shopOrderID = #{shopOrderID}
  160. </if>
  161. <if test="payStatus != null and payStatus != ''">
  162. AND a.payStatus = #{payStatus}
  163. </if>
  164. </where>
  165. -- group by p.productID
  166. <choose>
  167. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  168. ORDER BY ${page.orderBy}
  169. </when>
  170. <otherwise>
  171. </otherwise>
  172. </choose>
  173. </select>
  174. <insert id="insert" parameterType="NewOrderProduct" keyProperty="orderProductID" useGeneratedKeys="true">
  175. INSERT INTO cm_order_product(productType,
  176. orderID,
  177. orderNo,
  178. shopOrderID,
  179. shopOrderNo,
  180. shopID,
  181. productID,
  182. num,
  183. presentNum,
  184. outStoreType,
  185. skuID,
  186. productNo,
  187. price,
  188. totalAmount,
  189. discount,
  190. discountPrice,
  191. costPrice,
  192. includedTax,
  193. invoiceType,
  194. taxRate,
  195. supplierTaxRate,
  196. addedValueTax,
  197. totalAddedValueTax,
  198. shouldPayTotalTax,
  199. shopProductAmount,
  200. shopFee,
  201. otherFee,
  202. cmFee,
  203. singleShopFee,
  204. singleOtherFee,
  205. singleCmFee,
  206. shouldPayFee,
  207. normalPrice,
  208. totalFee,
  209. totalBeans,
  210. useBalanceAmount,
  211. useBeanAmount,
  212. notOutStore,
  213. cmbeanPrice,
  214. isGiftProduct,
  215. productActInfo,
  216. buyAgainFlag,
  217. confirmProductFlag,
  218. shopName,
  219. name,
  220. preferential,
  221. productUnit,
  222. productImage,
  223. discountFee,
  224. payStatus,
  225. status,
  226. singleShouldPayTotalTax,
  227. orderPromotionsId,
  228. ladderPriceFlag,
  229. svipPriceFlag,
  230. svipPriceType,
  231. svipDiscount,
  232. svipReduction)
  233. VALUES (#{productType},
  234. #{orderID},
  235. #{orderNo},
  236. #{shopOrderID},
  237. #{shopOrderNo},
  238. #{shopID},
  239. #{productID},
  240. #{num},
  241. #{presentNum},
  242. #{outStoreType},
  243. #{skuId},
  244. #{productNo},
  245. #{price},
  246. #{totalAmount},
  247. #{discount},
  248. #{discountPrice},
  249. #{costPrice},
  250. #{includedTax},
  251. #{invoiceType},
  252. #{taxRate},
  253. #{supplierTaxRate},
  254. #{addedValueTax},
  255. #{totalAddedValueTax},
  256. #{shouldPayTotalTax},
  257. #{shopProductAmount},
  258. #{shopFee},
  259. #{otherFee},
  260. #{cmFee},
  261. #{singleShopFee},
  262. #{singleOtherFee},
  263. #{singleCmFee},
  264. #{shouldPayFee},
  265. #{normalPrice},
  266. #{totalFee},
  267. #{totalBeans},
  268. #{useBalanceAmount},
  269. #{useBeanAmount},
  270. #{notOutStore},
  271. #{cmbeanPrice},
  272. #{isGiftProduct},
  273. #{productActInfo},
  274. #{buyAgainFlag},
  275. #{confirmProductFlag},
  276. #{shopName},
  277. #{name},
  278. #{preferential},
  279. #{productUnit},
  280. #{productImage},
  281. #{discountFee},
  282. #{payStatus},
  283. #{status},
  284. #{singleShouldPayTotalTax},
  285. #{orderPromotionsId},
  286. #{ladderPriceFlag},
  287. #{svipPriceFlag},
  288. #{svipPriceType},
  289. #{svipDiscount},
  290. #{svipReduction})
  291. </insert>
  292. <insert id="insertOrderProductLadderPrice">
  293. insert into order_product_ladder_price (orderProductId, ladderNum, buyNum, buyPrice, createDate)
  294. values (#{orderProductId}, #{ladderNum}, #{buyNum}, #{buyPrice}, #{createDate})
  295. </insert>
  296. <update id="updateStatus">
  297. update cm_order_product
  298. set payStatus = #{payStatus}
  299. where orderID = #{orderID}
  300. </update>
  301. <update id="update">
  302. update cm_order_product
  303. set orderNo = #{orderNo,jdbcType=VARCHAR},
  304. orderID = #{orderID,jdbcType=BIGINT},
  305. shopOrderID = #{shopOrderID,jdbcType=INTEGER},
  306. shopOrderNo = #{shopOrderNo,jdbcType=VARCHAR},
  307. shopID = #{shopID,jdbcType=BIGINT},
  308. productID = #{productID,jdbcType=INTEGER},
  309. num = #{num,jdbcType=INTEGER},
  310. presentNum = #{presentNum,jdbcType=INTEGER},
  311. outStoreType = #{outStoreType,jdbcType=CHAR},
  312. skuID = #{skuId,jdbcType=INTEGER},
  313. productNo = #{productNo,jdbcType=VARCHAR},
  314. price = #{price,jdbcType=REAL},
  315. normalPrice = #{normalPrice,jdbcType=REAL},
  316. totalAmount = #{totalAmount,jdbcType=REAL},
  317. discount = #{discount,jdbcType=DECIMAL},
  318. discountPrice = #{discountPrice,jdbcType=DECIMAL},
  319. taxRate = #{taxRate,jdbcType=DECIMAL},
  320. addedValueTax = #{addedValueTax,jdbcType=DECIMAL},
  321. totalAddedValueTax = #{totalAddedValueTax,jdbcType=DECIMAL},
  322. shouldPayTotalTax = #{shouldPayTotalTax,jdbcType=DECIMAL},
  323. shopFee = #{shopFee},
  324. otherFee = #{otherFee},
  325. cmFee = #{cmFee},
  326. singleShopFee = #{singleShopFee,jdbcType=DECIMAL},
  327. singleOtherFee = #{singleOtherFee,jdbcType=DECIMAL},
  328. singleCmFee = #{singleCmFee,jdbcType=DECIMAL},
  329. shouldPayFee = #{shouldPayFee,jdbcType=DECIMAL},
  330. totalFee = #{totalFee,jdbcType=REAL},
  331. totalBeans = #{totalBeans,jdbcType=DECIMAL},
  332. useBalanceAmount = #{useBalanceAmount,jdbcType=VARCHAR},
  333. useBeanAmount = #{useBeanAmount,jdbcType=INTEGER},
  334. notOutStore = #{notOutStore,jdbcType=INTEGER},
  335. cmbeanPrice = #{cmbeanPrice,jdbcType=INTEGER},
  336. isGiftProduct = #{isGiftProduct,jdbcType=VARCHAR},
  337. productActInfo = #{productActInfo,jdbcType=VARCHAR},
  338. buyAgainFlag = #{buyAgainFlag,jdbcType=CHAR},
  339. confirmProductFlag = #{confirmProductFlag,jdbcType=CHAR},
  340. payStatus = #{payStatus,jdbcType=CHAR},
  341. status = #{status},
  342. discountFee = #{discountFee},
  343. shopName = #{shopName,jdbcType=VARCHAR},
  344. name = #{name,jdbcType=VARCHAR},
  345. preferential = #{preferential,jdbcType=INTEGER},
  346. productUnit = #{productUnit,jdbcType=VARCHAR},
  347. productImage = #{productImage,jdbcType=VARCHAR},
  348. singleShouldPayTotalTax = #{singleShouldPayTotalTax,jdbcType=DECIMAL},
  349. productType = #{productType},
  350. orderPromotionsId = #{orderPromotionsId},
  351. costPrice = #{costPrice},
  352. includedTax = #{includedTax},
  353. invoiceType = #{invoiceType},
  354. supplierTaxRate = #{supplierTaxRate},
  355. ladderPriceFlag = #{ladderPriceFlag},
  356. isActProduct = #{isActProduct}
  357. where orderProductID = #{orderProductID,jdbcType=INTEGER}
  358. </update>
  359. <update id="updateForDelivery">
  360. update cm_order_product
  361. <set>
  362. <if test="notOutStore != null">
  363. notOutStore = #{notOutStore},
  364. </if>
  365. <if test="status != null and status != 0">
  366. status = #{status},
  367. </if>
  368. </set>
  369. where orderProductID = #{orderProductID,jdbcType=INTEGER}
  370. </update>
  371. <delete id="delete">
  372. DELETE
  373. FROM cm_order_product
  374. WHERE orderProductID = #{orderProductID}
  375. </delete>
  376. <delete id="deleteLadderPrice">
  377. DELETE
  378. FROM order_product_ladder_price
  379. WHERE orderProductId = #{orderProductID}
  380. </delete>
  381. <update id="deleteByOrderID">
  382. DELETE
  383. FROM cm_order_product
  384. WHERE orderID = #{orderID}
  385. </update>
  386. <update id="updatePayStatus">
  387. UPDATE cm_order_product
  388. SET payStatus = #{payStatus},
  389. status = #{status}
  390. WHERE orderProductID = #{orderProductID}
  391. </update>
  392. <select id="findWithOrderID" resultType="com.caimei.modules.order.entity.NewOrderProduct">
  393. select
  394. <include refid="orderProductColumns"/>,
  395. s.ledgerNo AS "ledgerNo",
  396. s.`name` AS `shopName`
  397. FROM cm_order_product a
  398. LEFT JOIN product p on p.productID = a.productID
  399. LEFT JOIN shop s on s.shopID = a.shopID
  400. where a.orderID = #{orderID}
  401. -- AND a.productID != 999
  402. -- group by p.productID
  403. </select>
  404. <!--通过订单ID获取订单商品并以供应商分组-->
  405. <select id="getWithorderIdGroupByShopId" resultType="com.caimei.modules.order.entity.NewOrderProduct">
  406. SELECT a.*
  407. from cm_order_product a
  408. where a.orderId = #{orderId}
  409. GROUP BY a.shopID
  410. </select>
  411. <select id="getTotalPay" resultType="java.lang.Double">
  412. SELECT sum(ROUND(shopFee, 2))
  413. from cm_order_product
  414. where orderId = #{orderId}
  415. AND shopID = #{shopId}
  416. </select>
  417. <!--通过订单ID统计订单商品表中对应第三方的应付总额-->
  418. <select id="totalOtherFee" resultType="java.lang.Double">
  419. SELECT sum(ROUND(otherFee, 2))
  420. from cm_order_product
  421. where orderId = #{orderId}
  422. </select>
  423. <select id="getCmTotalPay" resultType="java.lang.Double">
  424. SELECT sum(cmFee)
  425. from cm_order_product
  426. where orderId = #{orderId}
  427. </select>
  428. <select id="getCmTotalTaxFee" resultType="java.lang.Double">
  429. SELECT sum(shouldPayTotalTax)
  430. from cm_order_product
  431. where orderId = #{orderId}
  432. </select>
  433. <select id="getProductNameByOrderproductId" resultType="NewOrderProduct">
  434. SELECT `name`
  435. from cm_order_product
  436. where orderProductID = #{ProductId}
  437. </select>
  438. <select id="findByOrderIdGroupByShopId" resultType="NewOrderProduct">
  439. SELECT
  440. <include refid="orderProductColumns"/>
  441. FROM cm_order_product a
  442. <include refid="orderProductJoins"/>
  443. WHERE a.orderID=#{orderId} GROUP BY a.shopID;
  444. </select>
  445. <update id="updateShopConfigFlag">
  446. UPDATE cm_order_product
  447. SET confirmProductFlag = 0
  448. WHERE orderID = #{orderID}
  449. </update>
  450. <update id="updateProductFee">
  451. UPDATE cm_order_product
  452. SET costPrice = #{costPrice},
  453. organizeCostPrice = #{organizeCostPrice},
  454. cmCostPrice = #{cmCostPrice},
  455. shopPercent = #{shopPercent},
  456. organizePercent = #{organizePercent},
  457. cmPercent = #{cmPercent},
  458. supplierTaxRate = #{supplierTaxRate},
  459. shouldPayTotalTax = #{shouldPayTotalTax},
  460. singleShouldPayTotalTax = #{singleShouldPayTotalTax}
  461. WHERE orderProductID = #{orderProductID}
  462. </update>
  463. <select id="findByOrderProductID" resultType="NewOrderProduct" useCache="false" flushCache="true">
  464. SELECT
  465. <include refid="orderProductColumns"/>
  466. FROM cm_order_product a
  467. <include refid="orderProductJoins"/>
  468. WHERE a.orderProductID = #{orderProductID}
  469. -- group by p.productID
  470. </select>
  471. <select id="getGroupOrderProductIdS" resultType="String">
  472. SELECT group_concat(a.orderproductID)
  473. FROM cm_order_product a
  474. WHERE a.orderID = #{orderId}
  475. </select>
  476. <select id="findFreightOrderProductList" resultType="NewOrderProduct">
  477. SELECT a.shopOrderID AS shopOrderID,
  478. a.orderID AS orderID,
  479. a.orderProductID AS orderProductID
  480. FROM cm_order_product AS a
  481. WHERE a.orderID = #{orderID}
  482. AND a.productID = #{freightProductID}
  483. </select>
  484. <select id="getReturningNum" resultType="Integer">
  485. SELECT IFNULL(sum(a.actualReturnedNum + a.actualCancelNum), 0)
  486. FROM cm_returned_purchase_product a
  487. right join cm_returned_purchase b on a.returnedID = b.id
  488. WHERE a.orderProductID = #{orderProductID}
  489. and b.status = 1
  490. and b.delFlag = 0
  491. </select>
  492. <select id="getReturnedNum" resultType="Integer">
  493. SELECT IFNULL(sum(a.actualReturnedNum + a.actualCancelNum), 0)
  494. FROM cm_returned_purchase_product a
  495. right join cm_returned_purchase b on a.returnedID = b.id
  496. WHERE a.orderProductID = #{orderProductID}
  497. and b.status = 2
  498. and b.delFlag = 0
  499. </select>
  500. <select id="getReceivedNum" resultType="Integer">
  501. SELECT IFNULL(sum(a.num), 0)
  502. FROM cm_logistics_record a
  503. right join cm_logistics_batch b on a.logisticsBatchID = b.id
  504. WHERE a.orderProductID = #{orderProductID}
  505. and b.status = 1
  506. </select>
  507. <select id="findByShopOrderID" resultType="NewOrderProduct">
  508. select cop.name AS name,
  509. cop.orderProductID AS orderProductID,
  510. cop.productID AS productID,
  511. cop.productUnit AS unit,
  512. cop.num AS num,
  513. cop.presentNum AS presentNum,
  514. cop.discountPrice AS discountPrice,
  515. cop.totalFee AS totalFee,
  516. cop.shouldPayTotalTax AS shouldPayTotalTax,
  517. cop.shopProductAmount AS shopProductAmount,
  518. cop.singleShouldPayTotalTax AS singleShouldPayTotalTax,
  519. cop.taxRate AS taxRate,
  520. cop.supplierTaxRate AS supplierTaxRate,
  521. cop.includedTax AS includedTax,
  522. cop.invoiceType AS invoiceType,
  523. cop.addedValueTax AS addedValueTax,
  524. cop.productType AS productType,
  525. cop.totalAddedValueTax AS totalAddedValueTax,
  526. cs.organizeId AS organizeId,
  527. cs.unit as productUnit,
  528. cop.costPrice AS costPrice,
  529. ifnull(cop.organizeCostPrice, 0) AS organizeCostPrice,
  530. ifnull(cop.cmCostPrice, 0) AS cmCostPrice,
  531. cop.shopPercent,
  532. cop.organizePercent,
  533. cop.cmPercent,
  534. cpo.touchPrice AS touchPrice
  535. from cm_order_product cop
  536. left join cm_sku cs on cop.skuId = cs.skuId and cs.organizeId=cop.organizeId
  537. left join cm_promotions_order cpo on (cop.orderPromotionsId = cpo.id and cpo.mode = 1)
  538. left join product p on p.productID = cop.productID
  539. left join cm_order co on co.orderID = cop.orderID
  540. left join user u on u.userID = co.userID
  541. where cop.shopOrderID = #{shopOrderID}
  542. -- and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
  543. -- group by p.productID
  544. </select>
  545. <select id="CountReturnedPurchaseProduct" resultType="java.lang.Integer">
  546. select SUM(crpp.actualReturnedNum) + SUM(crpp.actualCancelNum)
  547. from cm_returned_purchase_product crpp
  548. left join cm_returned_purchase rp on rp.id = crpp.returnedID
  549. where crpp.shopOrderID = #{shopOrderID}
  550. and crpp.orderProductID = #{orderProductID}
  551. and rp.status = '2'
  552. and rp.delFlag = '0'
  553. </select>
  554. <select id="getActualCancelNum" resultType="java.lang.Integer">
  555. select SUM(crpp.actualCancelNum)
  556. from cm_returned_purchase_product crpp
  557. left join cm_returned_purchase rp on rp.id = crpp.returnedID
  558. where crpp.orderProductID = #{orderProductID}
  559. and rp.status = '2'
  560. and rp.delFlag = '0'
  561. </select>
  562. <select id="findladderPriceList" resultType="com.caimei.modules.product.entity.OrderProductLadderPrice">
  563. select *
  564. from order_product_ladder_price
  565. where orderProductId = #{orderProductID}
  566. </select>
  567. <select id="countReturnedFreightProduct" resultType="java.lang.Integer">
  568. select SUM(crpp.actualReturnedNum) + SUM(crpp.actualCancelNum)
  569. from cm_returned_purchase_product crpp
  570. left join cm_returned_purchase rp on rp.id = crpp.returnedID
  571. left join cm_shop_order cso on crpp.shopOrderID = cso.shopOrderID
  572. where crpp.shopOrderID = cso.shopOrderID
  573. and cso.orderID = #{orderID}
  574. and cso.shopID = 998
  575. and rp.status = '2'
  576. and rp.delFlag = '0'
  577. </select>
  578. <select id="findPriceBySku" resultType="java.lang.Double">
  579. select price
  580. from cm_sku
  581. where skuId = #{skuId} and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
  582. </select>
  583. <select id="findSkuIdByProductId" resultType="java.lang.String">
  584. select skuId
  585. from cm_sku
  586. where productId = #{productID} and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
  587. </select>
  588. </mapper>