ShopOrderMapper.xml 57 KB

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