OrderProductMapper.xml 25 KB

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