OrderProductMapper.xml 26 KB

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