ShopOrderMapper.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  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.NewShopOrderDao">
  4. <sql id="shopOrderColumns">
  5. co.couponAmount as couponAmount,
  6. co.userBeans as userBeans,
  7. a.shopOrderID AS shopOrderID,
  8. a.orderID AS orderID,
  9. a.organizeID AS organizeID,
  10. a.shopOrderNo AS shopOrderNo,
  11. a.orderNo AS orderNo,
  12. a.userID AS userID,
  13. a.shopID AS shopID,
  14. a.itemCount AS itemCount,
  15. a.townID AS townID,
  16. a.productAmount AS productAmount,
  17. a.discountAmount AS discountAmount,
  18. a.accountAmount AS accountAmount,
  19. a.totalAmount AS totalAmount,
  20. a.payFlag AS payFlag,
  21. a.payTime AS payTime,
  22. a.finishTime AS finishTime,
  23. a.refundStatus AS refundStatus,
  24. a.needPayAmount AS needPayAmount,
  25. a.canRefundAmount AS canRefundAmount,
  26. a.refundAmount AS refundAmount,
  27. a.clubID AS clubID,
  28. a.spID AS spID,
  29. a.mainSpID AS mainSpID,
  30. a.orderBeanAmount AS orderBeanAmount,
  31. a.useBeanAmount AS useBeanAmount,
  32. a.useBeanFlag AS useBeanFlag,
  33. a.canRefundFlag AS canRefundFlag,
  34. a.useBalanceFlag AS useBalanceFlag,
  35. a.canRefundBeans AS canRefundBeans,
  36. a.freePostageFee AS freePostageFee,
  37. a.freePostageTicketID AS freePostageTicketID,
  38. a.brokerage AS brokerage,
  39. a.delFlag AS delFlag,
  40. a.refundsAmount AS refundsAmount,
  41. a.orderStatusFlag AS orderStatusFlag,
  42. a.buyStatus AS buyStatus,
  43. a.orderSubmitType AS orderSubmitType,
  44. a.orderType AS orderType,
  45. a.orderTime AS orderTime,
  46. a.deliveryTimeMills AS deliveryTimeMills,
  47. a.presentNum AS presentNum,
  48. a.preferential AS preferential,
  49. a.outStoreNum AS outStoreNum,
  50. IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
  51. a.splitFlag AS splitFlag,
  52. a.autoReceiveTimeMills AS autoReceiveTimeMills,
  53. a.autoOverTimeMills AS autoOverTimeMills,
  54. a.receiveGoodsTime AS receiveGoodsTime,
  55. a.totalAddedValueTax AS totalAddedValueTax,
  56. a.note AS note,
  57. a.payStatus AS payStatus,
  58. a.sendOutStatus AS sendOutStatus,
  59. a.shopProductAmount AS shopProductAmount,
  60. a.shopPostFee AS shopPostFee,
  61. a.shopTaxFee AS shopTaxFee,
  62. a.shouldPayShopAmount AS shouldPayShopAmount,
  63. a.payedShopAmount AS payedShopAmount,
  64. a.shopOtherFee AS shopOtherFee,
  65. a.paying AS paying,
  66. a.costType AS costType,
  67. a.modifyShouldPayNote AS modifyShouldPayNote,
  68. a.orderPromotionsId AS orderPromotionsId,
  69. a.differenceType AS differenceType,
  70. a.differencePrice AS differencePrice,
  71. a.proportional AS proportional,
  72. a.promotionFullReduction As promotionFullReduction,
  73. a.zeroCostFlag AS zeroCostFlag
  74. </sql>
  75. <select id="get" resultType="NewShopOrder" useCache="false" flushCache="true">
  76. select
  77. <include refid="shopOrderColumns"/>
  78. from cm_shop_order a
  79. left join cm_order co on co.orderID = a.orderID
  80. where a.shopOrderID = #{shopOrderID}
  81. </select>
  82. <delete id="deleteByOrderID">
  83. DELETE
  84. FROM cm_shop_order
  85. WHERE orderID = #{orderID}
  86. </delete>
  87. <insert id="insert" parameterType="NewShopOrder" keyProperty="shopOrderID" useGeneratedKeys="true">
  88. INSERT INTO cm_shop_order(orderID,
  89. shopOrderNo,
  90. orderNo,
  91. userID,
  92. shopID,
  93. itemCount,
  94. townID,
  95. productAmount,
  96. discountAmount,
  97. accountAmount,
  98. totalAmount,
  99. payFlag,
  100. payTime,
  101. finishTime,
  102. refundStatus,
  103. needPayAmount,
  104. canRefundAmount,
  105. refundAmount,
  106. clubID,
  107. spID,
  108. mainSpID,
  109. orderBeanAmount,
  110. useBeanAmount,
  111. useBeanFlag,
  112. canRefundFlag,
  113. useBalanceFlag,
  114. canRefundBeans,
  115. freePostageFee,
  116. freePostageTicketID,
  117. brokerage,
  118. delFlag,
  119. refundsAmount,
  120. orderStatusFlag,
  121. buyStatus,
  122. orderSubmitType,
  123. orderType,
  124. orderTime,
  125. deliveryTimeMills,
  126. presentNum,
  127. preferential,
  128. splitFlag,
  129. autoReceiveTimeMills,
  130. autoOverTimeMills,
  131. totalAddedValueTax,
  132. receiveGoodsTime,
  133. sendOutStatus,
  134. payStatus,
  135. costType,
  136. orderPromotionsId,
  137. promotionFullReduction,
  138. zeroCostFlag,
  139. svipShopReduction)
  140. VALUES (#{orderID},
  141. #{shopOrderNo},
  142. #{orderNo},
  143. #{userID},
  144. #{shopID},
  145. #{itemCount},
  146. #{townID},
  147. #{productAmount},
  148. #{discountAmount},
  149. #{accountAmount},
  150. #{totalAmount},
  151. #{payFlag},
  152. #{payTime},
  153. #{finishTime},
  154. #{refundStatus},
  155. #{needPayAmount},
  156. #{canRefundAmount},
  157. #{refundAmount},
  158. #{clubID},
  159. #{spID},
  160. #{mainSpID},
  161. #{orderBeanAmount},
  162. #{useBeanAmount},
  163. #{useBeanFlag},
  164. #{canRefundFlag},
  165. #{useBalanceFlag},
  166. #{canRefundBeans},
  167. #{freePostageFee},
  168. #{freePostageTicketID},
  169. #{brokerage},
  170. #{delFlag},
  171. #{refundsAmount},
  172. #{orderStatusFlag},
  173. #{buyStatus},
  174. #{orderSubmitType},
  175. #{orderType},
  176. #{orderTime},
  177. #{deliveryTimeMills},
  178. #{presentNum},
  179. #{preferential},
  180. #{splitFlag},
  181. #{autoReceiveTimeMills},
  182. #{autoOverTimeMills},
  183. #{totalAddedValueTax},
  184. #{receiveGoodsTime},
  185. #{sendOutStatus},
  186. #{payStatus},
  187. #{costType},
  188. #{orderPromotionsId},
  189. #{promotionFullReduction},
  190. #{zeroCostFlag},
  191. #{svipShopReduction})
  192. </insert>
  193. <select id="findByShopOrderID" resultType="newShopOrder">
  194. select
  195. <include refid="shopOrderColumns"/>
  196. from cm_shop_order a
  197. left join cm_order co on co.orderID = a.orderID
  198. where a.shopOrderID = #{shopOrderID}
  199. </select>
  200. <select id="findList" resultType="newShopOrder">
  201. SELECT
  202. <include refid="shopOrderColumns"/>
  203. FROM cm_shop_order a
  204. left join cm_order co on co.orderID = a.orderID
  205. <where>
  206. <if test="shopOrderNo != null and itemCount != ''">
  207. AND a.shopOrderNo = #{shopOrderNo}
  208. </if>
  209. <if test="orderNo != null and itemCount != ''">
  210. AND a.orderNo = #{orderNo}
  211. </if>
  212. <if test="orderID != null and itemCount != ''">
  213. AND a.orderID = #{orderID}
  214. </if>
  215. <if test="userID != null and itemCount != ''">
  216. AND a.userID = #{userID}
  217. </if>
  218. <if test="shopID != null and itemCount != ''">
  219. AND a.shopID = #{shopID}
  220. </if>
  221. <if test="payFlag != null and itemCount != ''">
  222. AND a.payFlag = #{payFlag}
  223. </if>
  224. </where>
  225. <choose>
  226. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  227. ORDER BY ${page.orderBy}
  228. </when>
  229. <otherwise>
  230. </otherwise>
  231. </choose>
  232. </select>
  233. <select id="findListByOrderID" resultType="newShopOrder">
  234. SELECT<include refid="shopOrderColumns"/>,
  235. b.name as shopName,
  236. oa.id as orderArchiveId
  237. FROM cm_shop_order a left join shop b on a.shopID = b.shopID left join cm_order_archive oa on a.shopOrderID =
  238. oa.shopOrderId
  239. left join cm_order co on co.orderID = a.orderID
  240. WHERE a.orderID = #{orderID} ORDER BY a.shopOrderNo DESC
  241. </select>
  242. <update id="update" parameterType="newShopOrder">
  243. update cm_shop_order
  244. <set>
  245. <if test="shopOrderNo != null and shopOrderNo != ''">
  246. shopOrderNo = #{shopOrderNo},
  247. </if>
  248. <if test="shopOrderNo != null and shopOrderNo != ''">
  249. orderID = #{orderID},
  250. </if>
  251. <if test="orderNo != null and orderNo != ''">
  252. orderNo = #{orderNo},
  253. </if>
  254. <if test="userID != null and userID != ''">
  255. userID = #{userID},
  256. </if>
  257. <if test="shopID != null and shopID != ''">
  258. shopID = #{shopID},
  259. </if>
  260. <if test="itemCount != null and itemCount != ''">
  261. itemCount = #{itemCount},
  262. </if>
  263. <if test="townID != null and itemCount != ''">
  264. townID = #{townID,jdbcType=INTEGER},
  265. </if>
  266. <if test="productAmount != null and productAmount != ''">
  267. productAmount = #{productAmount},
  268. </if>
  269. <if test="discountAmount != null and discountAmount != ''">
  270. discountAmount = #{discountAmount},
  271. </if>
  272. <if test="accountAmount != null and accountAmount != ''">
  273. accountAmount = #{accountAmount},
  274. </if>
  275. <if test="totalAmount != null and totalAmount != ''">
  276. totalAmount = #{totalAmount},
  277. </if>
  278. <if test="payFlag != null and payFlag != ''">
  279. payFlag = #{payFlag},
  280. </if>
  281. <if test="payTime != null and payTime != ''">
  282. payTime = #{payTime},
  283. </if>
  284. <if test="finishTime != null and finishTime != ''">
  285. finishTime = #{finishTime},
  286. </if>
  287. <if test="refundStatus != null and refundStatus != ''">
  288. refundStatus = #{refundStatus},
  289. </if>
  290. <if test="needPayAmount != null and needPayAmount != ''">
  291. needPayAmount = #{needPayAmount},
  292. </if>
  293. <if test="canRefundAmount != null and canRefundAmount != ''">
  294. canRefundAmount = #{canRefundAmount},
  295. </if>
  296. <if test="refundAmount != null and refundAmount != ''">
  297. refundAmount = #{refundAmount},
  298. </if>
  299. <if test="clubID != null and clubID != ''">
  300. clubID = #{clubID},
  301. </if>
  302. <if test="spID != null and itemCount != ''">
  303. spID = #{spID,jdbcType=INTEGER},
  304. </if>
  305. <if test="mainSpID != null and mainSpID != ''">
  306. mainSpID = #{mainSpID},
  307. </if>
  308. <if test="orderBeanAmount != null and orderBeanAmount != ''">
  309. orderBeanAmount = #{orderBeanAmount},
  310. </if>
  311. <if test="useBeanAmount != null and useBeanAmount != ''">
  312. useBeanAmount = #{useBeanAmount},
  313. </if>
  314. <if test="useBeanFlag != null and useBeanFlag != ''">
  315. useBeanFlag = #{useBeanFlag},
  316. </if>
  317. <if test="canRefundFlag != null and canRefundFlag != ''">
  318. canRefundFlag = #{canRefundFlag},
  319. </if>
  320. <if test="useBalanceFlag != null and useBalanceFlag != ''">
  321. useBalanceFlag = #{useBalanceFlag},
  322. </if>
  323. <if test="canRefundBeans != null and canRefundBeans != ''">
  324. canRefundBeans = #{canRefundBeans},
  325. </if>
  326. <if test="freePostageFee != null and freePostageFee != ''">
  327. freePostageFee = #{freePostageFee},
  328. </if>
  329. <if test="freePostageTicketID != null and freePostageTicketID != ''">
  330. freePostageTicketID = #{freePostageTicketID},
  331. </if>
  332. <if test="brokerage != null and brokerage != ''">
  333. brokerage = #{brokerage},
  334. </if>
  335. <if test="delFlag != null and delFlag != ''">
  336. delFlag = #{delFlag},
  337. </if>
  338. <if test="refundsAmount != null and refundsAmount != ''">
  339. refundsAmount = #{refundsAmount},
  340. </if>
  341. <if test="orderStatusFlag != null and orderStatusFlag != ''">
  342. orderStatusFlag = #{orderStatusFlag},
  343. </if>
  344. <if test="buyStatus != null and buyStatus != ''">
  345. buyStatus = #{buyStatus},
  346. </if>
  347. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">
  348. deliveryTimeMills = #{deliveryTimeMills},
  349. </if>
  350. <if test="orderSubmitType != null and orderSubmitType != ''">
  351. orderSubmitType = #{orderSubmitType},
  352. </if>
  353. <if test="orderType != null and orderType != ''">
  354. orderType = #{orderType},
  355. </if>
  356. <if test="orderTime != null and orderTime != ''">
  357. orderTime = #{orderTime},
  358. </if>
  359. <if test="presentNum != null and presentNum != ''">
  360. presentNum = #{presentNum},
  361. </if>
  362. <if test="preferential != null and preferential != ''">
  363. preferential = #{preferential},
  364. </if>
  365. <if test="outStoreNum != null and outStoreNum != ''">
  366. outStoreNum = #{outStoreNum},
  367. </if>
  368. <if test="outStoreTimes != null and outStoreTimes != ''">
  369. outStoreTimes = #{outStoreTimes},
  370. </if>
  371. <if test="splitFlag != null and splitFlag != ''">
  372. splitFlag = #{splitFlag},
  373. </if>
  374. <if test="autoReceiveTimeMills != null and autoReceiveTimeMills != ''">
  375. autoReceiveTimeMills = #{autoReceiveTimeMills},
  376. </if>
  377. <if test="autoOverTimeMills != null and autoOverTimeMills != ''">
  378. autoOverTimeMills = #{autoOverTimeMills},
  379. </if>
  380. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">
  381. receiveGoodsTime = #{receiveGoodsTime},
  382. </if>
  383. <if test="totalAddedValueTax != null and totalAddedValueTax != ''">
  384. totalAddedValueTax = #{totalAddedValueTax},
  385. </if>
  386. <if test="note != null and note != ''">
  387. note = #{note},
  388. </if>
  389. <if test="sendOutStatus != null and sendOutStatus != ''">
  390. sendOutStatus = #{sendOutStatus},
  391. </if>
  392. <if test="paying != null and paying != ''">
  393. paying = #{paying},
  394. </if>
  395. <if test="shopProductAmount != null">
  396. shopProductAmount = #{shopProductAmount},
  397. </if>
  398. <if test="shopPostFee != null">
  399. shopPostFee = #{shopPostFee},
  400. </if>
  401. <if test="shopTaxFee != null">
  402. shopTaxFee = #{shopTaxFee},
  403. </if>
  404. <if test="shouldPayShopAmount != null">
  405. shouldPayShopAmount = #{shouldPayShopAmount},
  406. </if>
  407. <if test="payedShopAmount != null">
  408. payedShopAmount = #{payedShopAmount},
  409. </if>
  410. <if test="shopOtherFee != null">
  411. shopOtherFee = #{shopOtherFee},
  412. </if>
  413. <if test="payStatus != null">
  414. payStatus = #{payStatus},
  415. </if>
  416. <if test="costType != null">
  417. costType = #{costType},
  418. </if>
  419. <if test="proportional != null">
  420. proportional = #{proportional},
  421. </if>
  422. <if test="modifyShouldPayNote != null">
  423. modifyShouldPayNote = #{modifyShouldPayNote},
  424. </if>
  425. <if test="modifyShouldPayUserID != null">
  426. modifyShouldPayUserID = #{modifyShouldPayUserID},
  427. </if>
  428. <if test="modifyShouldPayDate != null">
  429. modifyShouldPayDate = #{modifyShouldPayDate},
  430. </if>
  431. <if test="orderPromotionsId != null">
  432. orderPromotionsId = #{orderPromotionsId},
  433. </if>
  434. <if test="promotionFullReduction != null">
  435. promotionFullReduction = #{promotionFullReduction},
  436. </if>
  437. <if test="zeroCostFlag != null">
  438. zeroCostFlag = #{zeroCostFlag},
  439. </if>
  440. <if test="svipShopReduction != null">
  441. svipShopReduction = #{svipShopReduction}
  442. </if>
  443. </set>
  444. <where>
  445. <if test="shopOrderID != null and shopOrderID != ''">
  446. AND shopOrderID = #{shopOrderID}
  447. </if>
  448. <if test="orderID != null and orderID != ''">
  449. AND orderID = #{orderID}
  450. </if>
  451. </where>
  452. </update>
  453. <delete id="delete">
  454. DELETE
  455. FROM cm_shop_order
  456. WHERE shopOrderID = #{shopOrderID}
  457. </delete>
  458. <insert id="shopOrderBak" parameterType="NewShopOrder" keyProperty="shopOrderBakID" useGeneratedKeys="true">
  459. INSERT INTO cm_shop_order_bak(orderID,
  460. shopOrderNo,
  461. orderNo,
  462. userID,
  463. shopID,
  464. itemCount,
  465. townID,
  466. productAmount,
  467. discountAmount,
  468. accountAmount,
  469. totalAmount,
  470. payFlag,
  471. payTime,
  472. finishTime,
  473. refundStatus,
  474. needPayAmount,
  475. canRefundAmount,
  476. refundAmount,
  477. clubID,
  478. spID,
  479. mainSpID,
  480. orderBeanAmount,
  481. useBeanAmount,
  482. useBeanFlag,
  483. canRefundFlag,
  484. useBalanceFlag,
  485. canRefundBeans,
  486. freePostageFee,
  487. freePostageTicketID,
  488. brokerage,
  489. delFlag,
  490. refundsAmount,
  491. orderStatusFlag,
  492. buyStatus,
  493. orderSubmitType,
  494. orderType,
  495. orderTime,
  496. deliveryTimeMills,
  497. presentNum,
  498. preferential)
  499. VALUES (#{orderID},
  500. #{shopOrderNo},
  501. #{orderNo},
  502. #{userID},
  503. #{shopID},
  504. #{itemCount},
  505. #{townID},
  506. #{productAmount},
  507. #{discountAmount},
  508. #{accountAmount},
  509. #{totalAmount},
  510. #{payFlag},
  511. #{payTime},
  512. #{finishTime},
  513. #{refundStatus},
  514. #{needPayAmount},
  515. #{canRefundAmount},
  516. #{refundAmount},
  517. #{clubID},
  518. #{spID},
  519. #{mainSpID},
  520. #{orderBeanAmount},
  521. #{useBeanAmount},
  522. #{useBeanFlag},
  523. #{canRefundFlag},
  524. #{useBalanceFlag},
  525. #{canRefundBeans},
  526. #{freePostageFee},
  527. #{freePostageTicketID},
  528. #{brokerage},
  529. #{delFlag},
  530. #{refundsAmount},
  531. #{orderStatusFlag},
  532. #{buyStatus},
  533. #{orderSubmitType},
  534. #{orderType},
  535. #{orderTime},
  536. #{deliveryTimeMills},
  537. #{presentNum},
  538. #{preferential})
  539. </insert>
  540. <update id="updateOrderStatus">
  541. UPDATE bp_order
  542. SET status = #{orderStatus}
  543. WHERE id = #{orderId}
  544. </update>
  545. <select id="findIDsByOrderID" resultType="int">
  546. select shopOrderID
  547. from cm_shop_order
  548. where orderID = #{orderID}
  549. </select>
  550. <update id="updateNote">
  551. UPDATE cm_shop_order
  552. SET note = #{note}
  553. WHERE shopOrderID = #{shopOrderID}
  554. </update>
  555. <select id="findShopOrderNum" resultType="int">
  556. select count(1)
  557. from cm_shop_order
  558. where orderID = #{orderID}
  559. </select>
  560. <update id="updateByShopOrderID" parameterType="newShopOrder">
  561. update cm_shop_order
  562. <set>
  563. <if test="shopOrderNo != null and shopOrderNo != ''">
  564. shopOrderNo = #{shopOrderNo},
  565. </if>
  566. <if test="orderID != null and orderID != ''">
  567. orderID = #{orderID},
  568. </if>
  569. <if test="orderNo != null and orderNo != ''">
  570. orderNo = #{orderNo},
  571. </if>
  572. <if test="userID != null and userID != ''">
  573. userID = #{userID},
  574. </if>
  575. <if test="shopID != null and shopID != ''">
  576. shopID = #{shopID},
  577. </if>
  578. <if test="itemCount != null and itemCount != ''">
  579. itemCount = #{itemCount},
  580. </if>
  581. <if test="townID != null and itemCount != ''">
  582. townID = #{townID,jdbcType=INTEGER},
  583. </if>
  584. <if test="productAmount != null and productAmount != ''">
  585. productAmount = #{productAmount},
  586. </if>
  587. <if test="discountAmount != null and discountAmount != ''">
  588. discountAmount = #{discountAmount},
  589. </if>
  590. <if test="accountAmount != null and accountAmount != ''">
  591. accountAmount = #{accountAmount},
  592. </if>
  593. <if test="totalAmount != null and totalAmount != ''">
  594. totalAmount = #{totalAmount},
  595. </if>
  596. <if test="payFlag != null and payFlag != ''">
  597. payFlag = #{payFlag},
  598. </if>
  599. <if test="payTime != null and payTime != ''">
  600. payTime = #{payTime},
  601. </if>
  602. <if test="finishTime != null and finishTime != ''">
  603. finishTime = #{finishTime},
  604. </if>
  605. <if test="refundStatus != null and refundStatus != ''">
  606. refundStatus = #{refundStatus},
  607. </if>
  608. <if test="needPayAmount != null and needPayAmount != ''">
  609. needPayAmount = #{needPayAmount},
  610. </if>
  611. <if test="canRefundAmount != null and canRefundAmount != ''">
  612. canRefundAmount = #{canRefundAmount},
  613. </if>
  614. <if test="refundAmount != null and refundAmount != ''">
  615. refundAmount = #{refundAmount},
  616. </if>
  617. <if test="clubID != null and clubID != ''">
  618. clubID = #{clubID},
  619. </if>
  620. <if test="spID != null and itemCount != ''">
  621. spID = #{spID,jdbcType=INTEGER},
  622. </if>
  623. <if test="mainSpID != null and mainSpID != ''">
  624. mainSpID = #{mainSpID},
  625. </if>
  626. <if test="orderBeanAmount != null and orderBeanAmount != ''">
  627. orderBeanAmount = #{orderBeanAmount},
  628. </if>
  629. <if test="useBeanAmount != null and useBeanAmount != ''">
  630. useBeanAmount = #{useBeanAmount},
  631. </if>
  632. <if test="useBeanFlag != null and useBeanFlag != ''">
  633. useBeanFlag = #{useBeanFlag},
  634. </if>
  635. <if test="canRefundFlag != null and canRefundFlag != ''">
  636. canRefundFlag = #{canRefundFlag},
  637. </if>
  638. <if test="useBalanceFlag != null and useBalanceFlag != ''">
  639. useBalanceFlag = #{useBalanceFlag},
  640. </if>
  641. <if test="canRefundBeans != null and canRefundBeans != ''">
  642. canRefundBeans = #{canRefundBeans},
  643. </if>
  644. <if test="freePostageFee != null and freePostageFee != ''">
  645. freePostageFee = #{freePostageFee},
  646. </if>
  647. <if test="freePostageTicketID != null and freePostageTicketID != ''">
  648. freePostageTicketID = #{freePostageTicketID},
  649. </if>
  650. <if test="brokerage != null and brokerage != ''">
  651. brokerage = #{brokerage},
  652. </if>
  653. <if test="delFlag != null and delFlag != ''">
  654. delFlag = #{delFlag},
  655. </if>
  656. <if test="refundsAmount != null and refundsAmount != ''">
  657. refundsAmount = #{refundsAmount},
  658. </if>
  659. <if test="orderStatusFlag != null and orderStatusFlag != ''">
  660. orderStatusFlag = #{orderStatusFlag},
  661. </if>
  662. <if test="buyStatus != null and buyStatus != ''">
  663. buyStatus = #{buyStatus},
  664. </if>
  665. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">
  666. deliveryTimeMills = #{deliveryTimeMills},
  667. </if>
  668. <if test="orderSubmitType != null and orderSubmitType != ''">
  669. orderSubmitType = #{orderSubmitType},
  670. </if>
  671. <if test="orderType != null and orderType != ''">
  672. orderType = #{orderType},
  673. </if>
  674. <if test="orderTime != null and orderTime != ''">
  675. orderTime = #{orderTime},
  676. </if>
  677. <if test="presentNum != null and presentNum != ''">
  678. presentNum = #{presentNum},
  679. </if>
  680. <if test="preferential != null and preferential != ''">
  681. preferential = #{preferential},
  682. </if>
  683. <if test="outStoreNum != null and outStoreNum != ''">
  684. outStoreNum = #{outStoreNum},
  685. </if>
  686. <if test="outStoreTimes != null and outStoreTimes != ''">
  687. outStoreTimes = #{outStoreTimes},
  688. </if>
  689. <if test="splitFlag != null and splitFlag != ''">
  690. splitFlag = #{splitFlag},
  691. </if>
  692. <if test="autoReceiveTimeMills != null and autoReceiveTimeMills != ''">
  693. autoReceiveTimeMills = #{autoReceiveTimeMills},
  694. </if>
  695. <if test="autoOverTimeMills != null and autoOverTimeMills != ''">
  696. autoOverTimeMills = #{autoOverTimeMills},
  697. </if>
  698. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">
  699. receiveGoodsTime = #{receiveGoodsTime},
  700. </if>
  701. <if test="totalAddedValueTax != null and totalAddedValueTax != ''">
  702. totalAddedValueTax = #{totalAddedValueTax},
  703. </if>
  704. <if test="note != null and note != ''">
  705. note = #{note},
  706. </if>
  707. <if test="sendOutStatus != null and sendOutStatus != ''">
  708. sendOutStatus = #{sendOutStatus}
  709. </if>
  710. </set>
  711. where shopOrderID = #{shopOrderID}
  712. </update>
  713. <select id="findPayOrderList" resultType="newShopOrder">
  714. select<include refid="shopOrderColumns"/>,
  715. co.payTotalFee AS payTotalFee,
  716. co.status AS status,
  717. bou.name AS buyer,
  718. s.name AS shopName,
  719. c.name AS clubName
  720. from cm_shop_order a
  721. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  722. left join bp_order_userinfo bou on bou.orderId = a.orderID
  723. left join cm_order co on co.orderID = a.orderID
  724. left join shop s on s.shopID = a.shopID
  725. LEFT JOIN club c ON c.userID = a.userID
  726. <where>
  727. <if test="startTime != null and startTime != ''">
  728. AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
  729. </if>
  730. <if test="endTime != null and endTime != ''">
  731. AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
  732. </if>
  733. <if test="orderID != null and orderID != ''">
  734. AND a.orderID = #{orderID}
  735. </if>
  736. <if test="organizeID != null and organizeID != 9999">
  737. AND co.organizeID = #{organizeID}
  738. </if>
  739. <if test="organizeID == 9999 ">
  740. AND co.orderType = 2
  741. </if>
  742. <if test="orderNo != null and orderNo != ''">
  743. AND a.orderNo like concat('%', #{orderNo} ,'%')
  744. </if>
  745. <if test="ps != null and ps.length>0 ">
  746. AND a.payStatus in
  747. <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
  748. #{item}
  749. </foreach>
  750. </if>
  751. <if test="shopName != null and shopName != ''">
  752. AND s.name like concat('%', #{shopName} ,'%')
  753. </if>
  754. <if test="buyer != null and buyer != ''">
  755. AND bou.name like concat('%', #{buyer} ,'%')
  756. </if>
  757. <if test="clubName != null and clubName != ''">
  758. AND c.name like concat('%', #{clubName} ,'%')
  759. </if>
  760. <if test="shopOrderID != null and shopOrderID != ''">
  761. AND a.shopOrderID = #{shopOrderID}
  762. </if>
  763. <if test="shopOrderNo != null and shopOrderNo != ''">
  764. AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
  765. </if>
  766. and (co.confirmFlag = '1' or co.confirmFlag = '2')
  767. <if test="operatingMode != null and operatingMode == '1'.toString()">
  768. and a.payStatus != 3 and co.status NOT IN (6,7)
  769. </if>
  770. <if test="operatingMode != null and operatingMode == '2'.toString()">
  771. and a.payStatus != 1 and co.status != 6
  772. </if>
  773. <if test="operatingMode != null and operatingMode == '3'.toString()">
  774. and a.payStatus = 3 and co.status NOT IN (6,7)
  775. </if>
  776. and co.delFlag = 0
  777. and a.delFlag = 0
  778. and a.shopID != 998
  779. and co.orderID not in (
  780. SELECT orderID FROM cm_order_product WHERE productID IN
  781. (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
  782. )
  783. </where>
  784. group by a.shopOrderID
  785. ORDER BY a.shopOrderID DESC
  786. </select>
  787. <select id="findPayOrderListByIDs" resultType="newShopOrder">
  788. select distinct<include refid="shopOrderColumns"/>,
  789. co.payTotalFee AS payTotalFee,
  790. bou.name AS buyer,
  791. s.name AS shopName
  792. from cm_shop_order a
  793. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  794. left join bp_order_userinfo bou on bou.orderId = a.orderID
  795. left join cm_order co on co.orderID = a.orderID
  796. left join shop s on s.shopID = a.shopID
  797. <where>
  798. <if test="ids != null and ids != ''">
  799. and a.shopOrderID in
  800. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  801. #{id}
  802. </foreach>
  803. </if>
  804. </where>
  805. ORDER BY a.shopOrderID DESC
  806. </select>
  807. <select id="findByRefundID" resultType="newShopOrder">
  808. select distinct<include refid="shopOrderColumns"/>,
  809. co.payTotalFee AS payTotalFee,
  810. bou.name AS buyer,
  811. s.name AS shopName
  812. from cm_shop_order a
  813. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  814. left join bp_order_userinfo bou on bou.orderId = a.orderID
  815. left join cm_order co on co.orderID = a.orderID
  816. left join shop s on s.shopID = a.shopID
  817. where a.shopOrderID in
  818. (select crsr.shopOrderID
  819. from cm_refund_shop_record crsr
  820. left join cm_refund_shop crs on crsr.refundShopID = crs.id
  821. where crs.id = #{refundShopID} and crsr.shopOrderID is not null)
  822. ORDER BY a.shopOrderID DESC
  823. </select>
  824. <select id="updatePayShopAmount">
  825. UPDATE cm_shop_order
  826. <set>
  827. <if test="shopProductAmount != null">
  828. shopProductAmount = #{shopProductAmount},
  829. </if>
  830. <if test="shopPostFee != null">
  831. shopPostFee = #{shopPostFee},
  832. </if>
  833. <if test="shopTaxFee != null">
  834. shopTaxFee = #{shopTaxFee},
  835. </if>
  836. <if test="shouldPayShopAmount != null">
  837. shouldPayShopAmount = #{shouldPayShopAmount},
  838. </if>
  839. <if test="shopOtherFee != null">
  840. shopOtherFee = #{shopOtherFee},
  841. </if>
  842. <if test="payStatus != null">
  843. payStatus = #{payStatus},
  844. </if>
  845. <if test="payedShopAmount != null">
  846. payedShopAmount = #{payedShopAmount}
  847. </if>
  848. </set>
  849. WHERE shopOrderID = #{shopOrderID}
  850. </select>
  851. <select id="findByShopOrderIDs" resultType="newShopOrder">
  852. select distinct<include refid="shopOrderColumns"/>,
  853. co.payTotalFee AS payTotalFee,
  854. bou.name AS buyer,
  855. s.name AS shopName,
  856. c.name AS clubName
  857. from cm_shop_order a
  858. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  859. left join bp_order_userinfo bou on bou.orderId = a.orderID
  860. left join cm_order co on co.orderID = a.orderID
  861. left join shop s on s.shopID = a.shopID
  862. left join club c on c.userID = a.userID
  863. <if test="shopOrderIDs != null and shopOrderIDs.size() > 0">
  864. where a.shopOrderID in
  865. <foreach collection="shopOrderIDs" separator="," item="shopOrderID" open="(" close=")">
  866. #{shopOrderID}
  867. </foreach>
  868. </if>
  869. </select>
  870. <update id="updatePaying">
  871. update cm_shop_order
  872. set paying = #{paying}
  873. where shopOrderID = #{shopOrderID}
  874. </update>
  875. <update id="outPaying">
  876. update cm_shop_order
  877. set paying = '0'
  878. where shopOrderID in
  879. (select cpsr.shopOrderID
  880. from cm_pay_shop_record cpsr
  881. left join cm_pay_shop cps on cps.id = cpsr.payShopID
  882. where cps.id = #{payShopID}
  883. and cps.delFlag = '0'
  884. and cpsr.delFlag = '0'
  885. and cpsr.shopOrderID is not null)
  886. </update>
  887. <update id="inPaying">
  888. update cm_shop_order
  889. set paying = '1'
  890. where shopOrderID in
  891. (select cpsr.shopOrderID
  892. from cm_pay_shop_record cpsr
  893. left join cm_pay_shop cps on cps.id = cpsr.payShopID
  894. where cps.id = #{payShopID}
  895. and cps.delFlag = '0'
  896. and cpsr.delFlag = '0'
  897. and cpsr.shopOrderID is not null)
  898. </update>
  899. <update id="updatePayStatus">
  900. update cm_shop_order
  901. set payStatus = #{payStatus}
  902. where shopOrderID = #{shopOrderID}
  903. </update>
  904. <select id="findPayStatusByOrderID" resultType="string">
  905. select payStatus
  906. from cm_shop_order
  907. where orderID = #{orderID}
  908. </select>
  909. <select id="getPayingStatus" resultType="string">
  910. select ifnull(paying, '0')
  911. from cm_shop_order
  912. where shopOrderID in
  913. (select cpsr.shopOrderID
  914. from cm_pay_shop_record cpsr
  915. left join cm_pay_shop cps on cps.id = cpsr.payShopID
  916. where cps.id = #{payShopID}
  917. and cps.delFlag = '0'
  918. and cpsr.delFlag = '0'
  919. and cpsr.shopOrderID is not null)
  920. </select>
  921. <select id="findSiblingPostFeeOrder" resultType="newShopOrder">
  922. select
  923. <include refid="shopOrderColumns"/>
  924. from cm_shop_order a
  925. left join cm_order co on co.orderID = a.orderID
  926. where a.orderID = #{orderID} and a.shopID = 998
  927. </select>
  928. <select id="findShopOrderNos" resultType="java.lang.String">
  929. SELECT CONCAT(shopOrderNo, '(', shopOrderID, ')') AS result
  930. FROM cm_shop_order
  931. WHERE orderID = #{orderID}
  932. and shopId != 998
  933. </select>
  934. <select id="findIncome" resultType="java.lang.Double">
  935. SELECT ROUND(IFNULL((
  936. co.payTotalFee - (IFNULL((
  937. SELECT ROUND(SUM((IFNULL(op.costPrice, 0) *
  938. (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0))) +
  939. IFNULL(op.shouldPayTotalTax, 0)),
  940. 2)
  941. FROM cm_order_product op
  942. LEFT JOIN cm_shop_order cso ON cso.shopOrderID = op.shopOrderID
  943. WHERE cso.orderID = co.orderID
  944. AND op.productID != 999
  945. GROUP BY cso.orderID
  946. ), 0))
  947. - (SELECT IFNULL(SUM(cso.shopOtherFee), 0)
  948. FROM cm_shop_order cso
  949. WHERE cso.orderID = co.orderID)
  950. - IFNULL((SELECT SUM(shopPostFee + IF(differenceType = 1, differencePrice, 0) -
  951. IF(differenceType = 2, differencePrice, 0))
  952. FROM cm_shop_order
  953. WHERE orderID = co.orderID), 0)
  954. + IFNULL((SELECT SUM(cpsr.wipePayment)
  955. FROM cm_pay_shop_record cpsr
  956. WHERE cpsr.shopOrderID IN (SELECT cso.shopOrderID
  957. FROM cm_shop_order cso
  958. WHERE cso.orderID = co.orderID)
  959. AND cpsr.delFlag = 0
  960. AND (cpsr.`status` = 1 OR cpsr.`status` = 0)), 0)
  961. ), 0), 2) AS "采美总佣金"
  962. FROM cm_order co
  963. WHERE co.orderID = #{orderID}
  964. </select>
  965. <update id="updateByShopOtherFee">
  966. UPDATE cm_shop_order
  967. SET shopOtherFee = #{shopOtherFee}
  968. WHERE shopOrderID = #{shopOrderId}
  969. </update>
  970. <update id="updateByDifferencePrice">
  971. UPDATE cm_shop_order
  972. SET differenceType = #{type},
  973. differencePrice = #{differencePrice}
  974. WHERE shopOrderID = #{shopOrderId}
  975. </update>
  976. <select id="findSplitList" resultType="newShopOrder">
  977. SELECT
  978. co.couponAmount AS couponAmount,
  979. co.userBeans AS userBeans,
  980. a.shopOrderID AS shopOrderID,
  981. a.orderID AS orderID,
  982. a.organizeID AS organizeID,
  983. a.shopOrderNo AS shopOrderNo,
  984. a.orderNo AS orderNo,
  985. a.userID AS userID,
  986. a.shopID AS shopID,
  987. a.itemCount AS itemCount,
  988. a.townID AS townID,
  989. a.productAmount AS productAmount,
  990. a.discountAmount AS discountAmount,
  991. a.accountAmount AS accountAmount,
  992. a.totalAmount AS totalAmount,
  993. a.payFlag AS payFlag,
  994. a.payTime AS payTime,
  995. a.finishTime AS finishTime,
  996. a.refundStatus AS refundStatus,
  997. a.needPayAmount AS needPayAmount,
  998. a.canRefundAmount AS canRefundAmount,
  999. a.refundAmount AS refundAmount,
  1000. a.clubID AS clubID,
  1001. a.spID AS spID,
  1002. a.mainSpID AS mainSpID,
  1003. a.orderBeanAmount AS orderBeanAmount,
  1004. a.useBeanAmount AS useBeanAmount,
  1005. a.useBeanFlag AS useBeanFlag,
  1006. a.canRefundFlag AS canRefundFlag,
  1007. a.useBalanceFlag AS useBalanceFlag,
  1008. a.canRefundBeans AS canRefundBeans,
  1009. a.freePostageFee AS freePostageFee,
  1010. a.freePostageTicketID AS freePostageTicketID,
  1011. a.brokerage AS brokerage,
  1012. a.delFlag AS delFlag,
  1013. a.refundsAmount AS refundsAmount,
  1014. a.orderStatusFlag AS orderStatusFlag,
  1015. a.buyStatus AS buyStatus,
  1016. a.orderSubmitType AS orderSubmitType,
  1017. a.orderType AS orderType,
  1018. a.orderTime AS orderTime,
  1019. a.deliveryTimeMills AS deliveryTimeMills,
  1020. a.presentNum AS presentNum,
  1021. a.preferential AS preferential,
  1022. a.outStoreNum AS outStoreNum,
  1023. IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
  1024. a.splitFlag AS splitFlag,
  1025. a.autoReceiveTimeMills AS autoReceiveTimeMills,
  1026. a.autoOverTimeMills AS autoOverTimeMills,
  1027. a.receiveGoodsTime AS receiveGoodsTime,
  1028. a.totalAddedValueTax AS totalAddedValueTax,
  1029. a.note AS note,
  1030. a.payStatus AS payStatus,
  1031. a.sendOutStatus AS sendOutStatus,
  1032. a.shopProductAmount AS shopProductAmount,
  1033. a.shopPostFee AS shopPostFee,
  1034. a.shopTaxFee AS shopTaxFee,
  1035. a.shouldPayShopAmount AS shouldPayShopAmount,
  1036. a.payedShopAmount AS payedShopAmount,
  1037. a.shopOtherFee AS shopOtherFee,
  1038. a.paying AS paying,
  1039. a.costType AS costType,
  1040. a.modifyShouldPayNote AS modifyShouldPayNote,
  1041. a.orderPromotionsId AS orderPromotionsId,
  1042. a.differenceType AS differenceType,
  1043. a.differencePrice AS differencePrice,
  1044. a.proportional AS proportional,
  1045. a.promotionFullReduction AS promotionFullReduction,
  1046. a.zeroCostFlag AS zeroCostFlag,
  1047. co.payTotalFee AS payTotalFee,
  1048. co.status AS STATUS,
  1049. bou.name AS buyer,
  1050. s.name AS shopName,
  1051. c.name AS clubName
  1052. FROM cm_shop_order a
  1053. LEFT JOIN cm_pay_shop_record cpsr ON a.shopOrderID = cpsr.shopOrderID
  1054. LEFT JOIN bp_order_userinfo bou ON bou.orderId = a.orderID
  1055. LEFT JOIN cm_order co ON co.orderID = a.orderID
  1056. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
  1057. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  1058. LEFT JOIN shop s ON s.shopID = a.shopID
  1059. LEFT JOIN club c ON c.userID = a.userID
  1060. WHERE
  1061. co.organizeID = 0
  1062. AND co.orderType != 2
  1063. AND co.refundType != 2
  1064. AND co.delFlag = 0
  1065. AND a.delFlag = 0
  1066. AND a.shopID != 998
  1067. AND cdr.payWay = 1
  1068. AND cdr.receiptDate <![CDATA[ <= ]]> NOW()
  1069. AND cror.relationType = 2
  1070. AND cror.delFlag = 0
  1071. AND cror.mbOrderId IS NOT NULL
  1072. AND cror.splitStatus = 0
  1073. AND co.orderID NOT IN (
  1074. SELECT orderID FROM cm_order_product WHERE productID IN
  1075. (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
  1076. )
  1077. GROUP BY a.shopOrderID
  1078. ORDER BY a.shopOrderID DESC
  1079. </select>
  1080. <select id="getOpenidListByPermission" resultType="java.lang.String">
  1081. SELECT DISTINCT cm.crmopenid FROM `cm_mall_operation_user` cm
  1082. LEFT JOIN `user` u ON u.userID = cm.userID
  1083. WHERE u.userID=#{userid} AND cm.unionId= #{unionid}
  1084. </select>
  1085. <select id="getOpenidunionId" resultType="java.lang.String">
  1086. SELECT DISTINCT cm.unionId FROM `cm_mall_operation_user` cm
  1087. LEFT JOIN `user` u ON u.userID = cm.userID
  1088. WHERE u.userID=#{userid} AND cm.id=1068
  1089. </select>
  1090. <select id="getProductOrder" resultType="java.lang.String">
  1091. SELECT productID FROM `cm_order_product` WHERE orderId=#{orderid}
  1092. </select>
  1093. </mapper>