ShopOrderMapper.xml 29 KB

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