OrderProductMapper.xml 20 KB

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