ShopOrderMapper.xml 45 KB

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