OrderMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  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.NewOrderDao">
  4. <sql id="columns">
  5. a.orderID AS orderID,
  6. a.orderNo AS orderNo,
  7. a.organizeID AS organizeID,
  8. a.userID AS userID,
  9. a.buyUserID AS buyUserID,
  10. a.shopOrderIDs AS shopOrderIDs,
  11. a.orderSubmitType AS orderSubmitType,
  12. a.orderType AS orderType,
  13. a.secondHandOrderFlag AS secondHandOrderFlag,
  14. a.status AS status,
  15. a.productTotalFee AS productTotalFee,
  16. a.orderTotalFee AS orderTotalFee,
  17. a.payTotalFee AS payTotalFee,
  18. a.payableAmount AS payableAmount,
  19. a.balancePayFee AS balancePayFee ,
  20. a.discountFee AS discountFee,
  21. a.spID AS spID,
  22. a.mainSpID AS mainSpID,
  23. a.note AS note,
  24. a.clubID AS clubID,
  25. a.clubScanTime AS clubScanTime,
  26. a.payWay AS payWay,
  27. a.orderSource AS orderSource,
  28. a.orderTime AS orderTime,
  29. a.confirmTime AS confirmTime,
  30. a.productCount AS productCount,
  31. a.presentCount AS presentCount,
  32. a.cooFreeFlag AS cooFreeFlag,
  33. a.cooFreeRate AS cooFreeRate,
  34. a.cooFreeAmount AS cooFreeAmount,
  35. a.confirmFlag AS confirmFlag,
  36. a.clauseID AS clauseID,
  37. a.clauseContent AS clauseContent,
  38. a.clauseName AS clauseName,
  39. a.updateDate AS updateDate,
  40. a.freePostFlag AS freePostFlag,
  41. a.freight AS freight,
  42. a.delFlag AS delFlag,
  43. a.onlinePayFlag AS onlinePayFlag,
  44. a.payTime AS payTime,
  45. a.splitFlag AS splitFlag,
  46. (select sum(cop.totalAddedValueTax) from cm_order_product cop where cop.orderID = a.orderID) AS totalAddedValueTax,
  47. a.preferential AS preferential,
  48. a.closeReason AS closeReason,
  49. a.receiptStatus as receiptStatus,
  50. a.payStatus as payStatus,
  51. a.sendOutStatus as sendOutStatus,
  52. a.refundType as refundType,
  53. a.postageOrderFlag AS postageOrderFlag,
  54. a.promotionFullReduction AS promotionFullReduction,
  55. a.promotionalGiftsCount AS promotionalGiftsCount,
  56. a.affirmPaymentFlag AS affirmPaymentFlag,
  57. a.rebateFlag AS rebateFlag,
  58. a.zeroCostFlag AS zeroCostFlag
  59. </sql>
  60. <select id="get" resultType="newOrder">
  61. SELECT <include refid="columns"/>
  62. FROM cm_order a
  63. WHERE a.orderID = #{id}
  64. </select>
  65. <resultMap id="orderDisplayList" type="com.caimei.modules.order.entity.NewOrder">
  66. <id column="orderID" property="orderID"/>
  67. <result column="orderNo" property="orderNo"/>
  68. <result column="organizeID" property="organizeID"/>
  69. <result column="orderType" property="orderType"/>
  70. <result column="shopName" property="shopName"/>
  71. <result column="receiver" property="receiver"/>
  72. <result column="buyer" property="buyer"/>
  73. <result column="orderSource" property="orderSource"/>
  74. <result column="orderTotalFee" property="orderTotalFee"/>
  75. <result column="orderTime" property="orderTime"/>
  76. <result column="productCount" property="productCount"/>
  77. <result column="alreadyReceipt" property="alreadyReceipt"/>
  78. <result column="unReceipt" property="unReceipt"/>
  79. <result column="payTotalFee" property="payTotalFee"/>
  80. <result column="payWay" property="payWay"/>
  81. <result column="status" property="status"/>
  82. <collection property="newShopOrders" ofType="com.caimei.modules.order.entity.NewShopOrder"
  83. select="loadShopOrders" column="orderNo" fetchType="eager">
  84. </collection>
  85. </resultMap>
  86. <select id="findList" resultMap="orderDisplayList" parameterType="NewOrder">
  87. SELECT DISTINCT
  88. co.orderID AS orderID,
  89. co.orderNo AS orderNo,
  90. co.organizeID AS organizeID,
  91. co.userID AS userID,
  92. co.orderType AS orderType,
  93. co.secondHandOrderFlag AS secondHandOrderFlag,
  94. co.onlinePayFlag AS onlinePayFlag,
  95. bou.shouHuoRen AS receiver,
  96. u.name AS buyer,
  97. co.orderSource AS orderSource,
  98. co.orderTotalFee AS orderTotalFee,
  99. co.payableAmount AS payableAmount,
  100. co.orderTime AS orderTime,
  101. co.confirmTime AS confirmTime,
  102. co.payTotalFee AS payTotalFee,
  103. co.payWay AS payWay,
  104. co.payStatus AS payStatus,
  105. co.refundType AS refundType,
  106. co.sendOutStatus AS sendOutStatus,
  107. co.receiptStatus AS receiptStatus,
  108. co.productCount AS productCount,
  109. (SELECT IFNULL(sum(cop.shouldPayFee),0) FROM cm_order_product cop WHERE cop.orderId=co.orderID) AS "shouldPayProduct",
  110. co.status AS status,
  111. co.splitFlag AS splitFlag,
  112. co.postageOrderFlag AS postageOrderFlag,
  113. (case when co.orderType = '0' then
  114. (select case status when 91 then '采美默认协销经理(官方账号)' else linkMan1 end from serviceprovider where serviceProviderID = co.spID)
  115. else
  116. ''
  117. end) AS spName,
  118. co.rebateFlag AS rebateFlag
  119. FROM cm_order co
  120. LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
  121. LEFT JOIN user u ON u.userID = co.userID
  122. LEFT JOIN club c ON u.userID = c.userID
  123. LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID and sp.status = 90
  124. LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
  125. LEFT JOIN product p ON cop.productID = p.productID
  126. <where>
  127. co.orderType != 2
  128. <if test="orderID != null and orderID != ''">
  129. AND co.orderID = #{orderID}
  130. </if>
  131. <if test="orderNo != null and orderNo != ''">
  132. AND co.orderNo = #{orderNo}
  133. </if>
  134. <if test="organizeID != null">
  135. AND co.organizeID = #{organizeID}
  136. </if>
  137. <if test="status != null and status != ''">
  138. <choose>
  139. <when test="status == '99'.toString()">
  140. AND co.status in (11,12,13,21,22,23,31,32,33)
  141. </when>
  142. <otherwise>
  143. AND co.status = #{status}
  144. </otherwise>
  145. </choose>
  146. </if>
  147. <if test="buyer != null and buyer != ''">
  148. AND u.name LIKE concat('%',#{buyer},'%')
  149. </if>
  150. <if test="orderType != null and orderType != ''">
  151. AND co.orderType = #{orderType}
  152. </if>
  153. <if test="secondHandOrderFlag != null and secondHandOrderFlag != ''">
  154. AND co.secondHandOrderFlag = #{secondHandOrderFlag}
  155. </if>
  156. <if test="orderSource != null and orderSource != ''">
  157. AND co.orderSource = #{orderSource}
  158. </if>
  159. <if test="orderTime != null and orderTime != ''">
  160. AND co.orderTime = #{orderTime}
  161. </if>
  162. <if test="sendOutStatus != null and sendOutStatus != ''">
  163. AND co.sendOutStatus = #{sendOutStatus}
  164. </if>
  165. <if test="startTime != null and startTime != ''">
  166. AND co.orderTime <![CDATA[ >= ]]> #{startTime}
  167. </if>
  168. <if test="endTime != null and endTime != ''">
  169. AND co.orderTime <![CDATA[ <= ]]> #{endTime}
  170. </if>
  171. <if test="startConfirmTime != null and startConfirmTime != ''">
  172. AND co.confirmTime <![CDATA[ >= ]]> #{startConfirmTime}
  173. </if>
  174. <if test="endConfirmTime != null and endConfirmTime != ''">
  175. AND co.confirmTime <![CDATA[ <= ]]> #{endConfirmTime}
  176. </if>
  177. <if test="receiver != null and receiver != ''">
  178. AND bou.shouHuoRen LIKE concat('%',#{receiver},'%')
  179. </if>
  180. <if test="receiptStatus != null and receiptStatus != ''">
  181. AND co.receiptStatus = #{receiptStatus}
  182. </if>
  183. <if test="payStatus != null and payStatus != ''">
  184. AND co.payStatus = #{payStatus}
  185. </if>
  186. <if test="sendOutStatus != null and sendOutStatus != ''">
  187. AND co.sendOutStatus = #{sendOutStatus}
  188. </if>
  189. <if test="returnedPurchaseStatus != null and returnedPurchaseStatus != ''">
  190. AND
  191. <if test="returnedPurchaseStatus == 1">
  192. exists
  193. </if>
  194. <if test="returnedPurchaseStatus == 0">
  195. not exists
  196. </if>
  197. (select 1 from cm_returned_purchase c3 where c3.status = '1' and c3.orderID = co.orderID and c3.delFlag = 0)
  198. </if>
  199. <if test="refundType != null and refundType != ''">
  200. AND
  201. <if test="refundType == 0">
  202. co.refundType is null
  203. </if>
  204. <if test="refundType == 1">
  205. co.refundType = '1'
  206. </if>
  207. <if test="refundType == 2">
  208. co.refundType = '2'
  209. </if>
  210. </if>
  211. <if test="orderRefundType != null and orderRefundType != ''">
  212. <if test="orderRefundType == 0">
  213. AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.delFlag = 0) = 0
  214. </if>
  215. <if test="orderRefundType == 1">
  216. AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.delFlag = 0) > 0
  217. </if>
  218. <if test="orderRefundType == 11">
  219. AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 1 and crp.delFlag = 0) > 0
  220. </if>
  221. <if test="orderRefundType == 12">
  222. AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 2 and crp.delFlag = 0
  223. <if test="startRefundTime != null and startRefundTime != ''">
  224. AND crp.confirmReturnTime <![CDATA[ >= ]]> #{startRefundTime}
  225. </if>
  226. <if test="endRefundTime != null and endRefundTime != ''">
  227. AND crp.confirmReturnTime <![CDATA[ <= ]]> #{endRefundTime}
  228. </if>
  229. ) > 0
  230. </if>
  231. <if test="orderRefundType == 13">
  232. AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 3 and crp.delFlag = 0) > 0
  233. </if>
  234. </if>
  235. <if test="rebateOrder != null and rebateOrder != ''">
  236. AND
  237. (<if test="rebateOrder == 1">
  238. co.rebateFlag = '1'
  239. OR exists
  240. </if>
  241. <if test="rebateOrder == 0">
  242. co.rebateFlag = '0'
  243. AND not exists
  244. </if>
  245. (select 1 from cm_receipt_order_relation c1
  246. left join cm_discern_receipt cdr ON c1.receiptID = cdr.id
  247. where c1.relationType = '1'
  248. and c1.orderID in (select c2.shopOrderID from cm_shop_order c2 where c2.orderID = co.orderID)
  249. and c1.delFlag = '0'
  250. and cdr.receiptStatus = '2'))
  251. </if>
  252. <if test="serviceProviderId != null and serviceProviderId != 0">
  253. and (co.spID = #{serviceProviderId}
  254. or sp.serviceProviderID = #{serviceProviderId})
  255. </if>
  256. <if test="productName != null and productName != ''">
  257. and p.name like CONCAT('%',#{productName},'%')
  258. </if>
  259. AND co.delFlag = 0
  260. </where>
  261. <choose>
  262. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  263. ORDER BY ${page.orderBy}
  264. </when>
  265. <otherwise>
  266. ORDER BY co.orderID DESC, co.orderTime DESC
  267. </otherwise>
  268. </choose>
  269. </select>
  270. <select id="loadShopOrders" parameterType="string" resultType="NewShopOrder">
  271. SELECT
  272. cs.shopOrderID AS shopOrderID,
  273. cs.shopOrderNo AS shopOrderNo,
  274. cs.shopOrderNo AS shopOrderNo,
  275. cs.itemCount AS itemCount,
  276. cs.needPayAmount AS needPayAmount,
  277. s.name AS shopName,
  278. cs.status AS status,
  279. cs.shopID AS shopID
  280. FROM cm_shop_order cs
  281. LEFT JOIN shop s ON cs.shopID = s.shopID
  282. WHERE cs.orderNo = #{orderNo} AND cs.delFlag = 0
  283. </select>
  284. <select id="getShopOrders" parameterType="string" resultType="NewShopOrder">
  285. SELECT
  286. (SELECT IFNULL(sum(shouldPayFee),0) FROM cm_order_product WHERE shopOrderID = cs.shopOrderID AND payStatus = 2) AS
  287. alreadyReceipt,
  288. (SELECT IFNULL(sum(shouldPayFee),0) FROM cm_order_product WHERE shopOrderID = cs.shopOrderID AND payStatus !=2) AS unReceipt,
  289. cs.shopOrderID AS shopOrderID,
  290. co.orderID AS orderID,
  291. cs.shopOrderNo AS shopOrderNo,
  292. co.orderNo AS orderNo,
  293. cs.shopOrderNo AS shopOrderNo,
  294. cs.itemCount AS itemCount,
  295. cs.needPayAmount AS needPayAmount,
  296. co.orderType AS orderType,
  297. s.name AS shopName,
  298. bou.shouHuoRen AS receiver,
  299. u.name AS buyer,
  300. co.orderSource AS orderSource,
  301. co.orderTotalFee AS orderTotalFee,
  302. co.orderTime AS orderTime,
  303. cs.status AS status
  304. FROM cm_shop_order cs
  305. LEFT JOIN cm_order co ON cs.orderNo = co.orderNo
  306. LEFT JOIN shop s ON cs.shopID = s.shopID
  307. LEFT JOIN user u ON cs.userID = u.userID
  308. LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
  309. WHERE cs.orderNo = #{orderNo} AND cs.delFlag = 0
  310. </select>
  311. <update id="updateClauseContent">
  312. UPDATE cm_order SET clauseContent = #{clauseContent},clauseName= #{clauseName}WHERE orderID = #{orderID}
  313. </update>
  314. <insert id="insert" parameterType="NewOrder" keyProperty="orderID" useGeneratedKeys="true">
  315. INSERT INTO cm_order(
  316. orderNo,
  317. userID,
  318. buyUserID,
  319. shopOrderIDs,
  320. orderSubmitType,
  321. orderType,
  322. secondHandOrderFlag,
  323. status,
  324. payFlag,
  325. onlinePayFlag,
  326. productTotalFee,
  327. orderTotalFee,
  328. payTotalFee,
  329. balancePayFee,
  330. discountFee,
  331. spID,
  332. mainSpID,
  333. note,
  334. clubID,
  335. clubScanTime,
  336. payWay,
  337. orderSource,
  338. orderTime,
  339. productCount,
  340. cooFreeFlag,
  341. cooFreeRate,
  342. cooFreeAmount,
  343. confirmFlag,
  344. clauseID,
  345. clauseContent,
  346. clauseName,
  347. updateDate,
  348. freePostFlag,
  349. freight,
  350. delFlag,
  351. payTime,
  352. splitFlag,
  353. preferential,
  354. confirmTime,
  355. invoiceFlag,
  356. postageOrderFlag,
  357. sendOutStatus,
  358. payableAmount,
  359. promotionFullReduction,
  360. promotionalGiftsCount,
  361. affirmPaymentFlag,
  362. rebateFlag,
  363. payStatus,
  364. zeroCostFlag
  365. ) VALUES (
  366. #{orderNo},
  367. #{userID},
  368. #{buyUserID},
  369. #{shopOrderIDs},
  370. #{orderSubmitType},
  371. #{orderType},
  372. #{secondHandOrderFlag},
  373. #{status},
  374. #{payFlag},
  375. #{onlinePayFlag},
  376. #{productTotalFee},
  377. #{orderTotalFee},
  378. #{payTotalFee},
  379. #{balancePayFee},
  380. #{discountFee},
  381. #{spID},
  382. #{mainSpID},
  383. #{note},
  384. #{clubID},
  385. #{clubScanTime},
  386. #{payWay},
  387. #{orderSource},
  388. #{orderTime},
  389. #{productCount},
  390. #{cooFreeFlag},
  391. #{cooFreeRate},
  392. #{cooFreeAmount},
  393. #{confirmFlag},
  394. #{clauseID},
  395. #{clauseContent},
  396. #{clauseName},
  397. #{updateDate},
  398. #{freePostFlag},
  399. #{freight},
  400. #{delFlag},
  401. #{payTime},
  402. #{splitFlag},
  403. #{preferential},
  404. #{confirmTime},
  405. #{invoiceFlag},
  406. #{postageOrderFlag},
  407. #{sendOutStatus},
  408. #{payableAmount},
  409. #{promotionFullReduction},
  410. #{promotionalGiftsCount},
  411. #{affirmPaymentFlag},
  412. #{rebateFlag},
  413. #{payStatus},
  414. #{zeroCostFlag}
  415. )
  416. </insert>
  417. <update id="update">
  418. update cm_order
  419. <set >
  420. <if test="orderNo != null" >
  421. orderNo = #{orderNo,jdbcType=VARCHAR},
  422. </if>
  423. <if test="userID != null" >
  424. userID = #{userID,jdbcType=BIGINT},
  425. </if>
  426. <if test="organizeID != null" >
  427. organizeID = #{organizeID,jdbcType=INTEGER},
  428. </if>
  429. <if test="buyUserID != null" >
  430. buyUserID = #{buyUserID,jdbcType=INTEGER},
  431. </if>
  432. <if test="shopOrderIDs != null" >
  433. shopOrderIDs = #{shopOrderIDs,jdbcType=VARCHAR},
  434. </if>
  435. <if test="orderSubmitType != null" >
  436. orderSubmitType = #{orderSubmitType,jdbcType=CHAR},
  437. </if>
  438. <if test="orderType != null" >
  439. orderType = #{orderType,jdbcType=CHAR},
  440. </if>
  441. <if test="secondHandOrderFlag != null" >
  442. secondHandOrderFlag = #{secondHandOrderFlag,jdbcType=CHAR},
  443. </if>
  444. <if test="status != null" >
  445. status = #{status,jdbcType=CHAR},
  446. </if>
  447. <if test="productTotalFee != null" >
  448. productTotalFee = #{productTotalFee,jdbcType=DECIMAL},
  449. </if>
  450. <if test="orderTotalFee != null" >
  451. orderTotalFee = #{orderTotalFee,jdbcType=DECIMAL},
  452. </if>
  453. <if test="payTotalFee != null" >
  454. payTotalFee = #{payTotalFee,jdbcType=DECIMAL},
  455. </if>
  456. <if test="payableAmount != null" >
  457. payableAmount = #{payableAmount,jdbcType=DECIMAL},
  458. </if>
  459. <if test="balancePayFee != null" >
  460. balancePayFee = #{balancePayFee,jdbcType=DECIMAL},
  461. </if>
  462. <if test="discountFee != null" >
  463. discountFee = #{discountFee,jdbcType=DECIMAL},
  464. </if>
  465. <if test="spID != null" >
  466. spID = #{spID,jdbcType=BIGINT},
  467. </if>
  468. <if test="mainSpID != null" >
  469. mainSpID = #{mainSpID,jdbcType=BIGINT},
  470. </if>
  471. <if test="clubID != null" >
  472. clubID = #{clubID,jdbcType=BIGINT},
  473. </if>
  474. <if test="clubScanTime != null" >
  475. clubScanTime = #{clubScanTime,jdbcType=VARCHAR},
  476. </if>
  477. <if test="payWay != null" >
  478. payWay = #{payWay,jdbcType=INTEGER},
  479. </if>
  480. <if test="orderSource != null" >
  481. orderSource = #{orderSource,jdbcType=CHAR},
  482. </if>
  483. <if test="orderTime != null" >
  484. orderTime = #{orderTime,jdbcType=TIMESTAMP},
  485. </if>
  486. <if test="productCount != null" >
  487. productCount = #{productCount,jdbcType=INTEGER},
  488. </if>
  489. <if test="presentCount != null" >
  490. presentCount = #{presentCount,jdbcType=INTEGER},
  491. </if>
  492. <if test="cooFreeFlag != null" >
  493. cooFreeFlag = #{cooFreeFlag,jdbcType=CHAR},
  494. </if>
  495. <if test="cooFreeRate != null" >
  496. cooFreeRate = #{cooFreeRate,jdbcType=INTEGER},
  497. </if>
  498. <if test="cooFreeAmount != null" >
  499. cooFreeAmount = #{cooFreeAmount,jdbcType=DECIMAL},
  500. </if>
  501. <if test="confirmFlag != null" >
  502. confirmFlag = #{confirmFlag,jdbcType=CHAR},
  503. </if>
  504. <if test="clauseID != null" >
  505. clauseID = #{clauseID,jdbcType=BIGINT},
  506. </if>
  507. <if test="clauseName != null" >
  508. clauseName = #{clauseName,jdbcType=VARCHAR},
  509. </if>
  510. <if test="freePostFlag != null" >
  511. freePostFlag = #{freePostFlag,jdbcType=CHAR},
  512. </if>
  513. <if test="freight != null" >
  514. freight = #{freight,jdbcType=DECIMAL},
  515. </if>
  516. <if test="delFlag != null" >
  517. delFlag = #{delFlag,jdbcType=CHAR},
  518. </if>
  519. <if test="note != null" >
  520. note = #{note,jdbcType=LONGVARCHAR},
  521. </if>
  522. <if test="clauseContent != null" >
  523. clauseContent = #{clauseContent,jdbcType=LONGVARCHAR},
  524. </if>
  525. <if test="payTime != null" >
  526. payTime = #{payTime,jdbcType=LONGVARCHAR},
  527. </if>
  528. <if test="preferential != null">
  529. preferential = #{preferential ,jdbcType=DECIMAL},
  530. </if>
  531. <if test="discountFee != null" >
  532. discountFee = #{discountFee},
  533. </if>
  534. <if test="payFlag != null" >
  535. payFlag = #{payFlag},
  536. </if>
  537. <if test="onlinePayFlag != null" >
  538. onlinePayFlag = #{onlinePayFlag},
  539. </if>
  540. <if test="splitFlag != null" >
  541. splitFlag = #{splitFlag},
  542. </if>
  543. <if test="closeReason != null" >
  544. closeReason = #{closeReason},
  545. </if>
  546. <if test="confirmTime != null" >
  547. confirmTime = #{confirmTime},
  548. </if>
  549. <if test="invoiceFlag != null" >
  550. invoiceFlag = #{invoiceFlag},
  551. </if>
  552. <if test="postageOrderFlag != null" >
  553. postageOrderFlag = #{postageOrderFlag},
  554. </if>
  555. <if test="sendOutStatus != null" >
  556. sendOutStatus = #{sendOutStatus},
  557. </if>
  558. <if test="receiptStatus != null" >
  559. receiptStatus = #{receiptStatus},
  560. </if>
  561. <if test="payStatus != null" >
  562. payStatus = #{payStatus},
  563. </if>
  564. <if test="refundType != null" >
  565. refundType = #{refundType},
  566. </if>
  567. <if test="promotionFullReduction != null" >
  568. promotionFullReduction = #{promotionFullReduction},
  569. </if>
  570. <if test="promotionalGiftsCount != null" >
  571. promotionalGiftsCount = #{promotionalGiftsCount},
  572. </if>
  573. <if test="affirmPaymentFlag != null">
  574. affirmPaymentFlag = #{affirmPaymentFlag},
  575. </if>
  576. <if test="rebateFlag != null">
  577. rebateFlag = #{rebateFlag},
  578. </if>
  579. <if test="zeroCostFlag != null">
  580. zeroCostFlag = #{zeroCostFlag}
  581. </if>
  582. </set>
  583. where orderID = #{orderID,jdbcType=BIGINT}
  584. </update>
  585. <select id="findByOrderID" resultType="NewOrder">
  586. select * from cm_order where orderID = #{orderID}
  587. </select>
  588. <update id="confirmOrder">
  589. UPDATE cm_order_product SET
  590. confirmFlag = 1
  591. WHERE orderID = #{orderID}
  592. </update>
  593. <update id="updateStatus" parameterType="NewOrder">
  594. UPDATE cm_order SET
  595. status = #{status}
  596. WHERE orderID = #{orderID}
  597. </update>
  598. <select id="getOrderByShopOrderID" resultType="NewOrder">
  599. select * from cm_order co
  600. left join cm_shop_order cso on cso.orderID = co.orderID
  601. where cso.shopOrderID = #{shopOrderID}
  602. </select>
  603. <update id="updatePayStatus">
  604. update cm_order set payStatus = #{payStatus} where orderID = #{orderID}
  605. </update>
  606. <select id="findOrderList" resultType="NewOrder" parameterType="NewOrder">
  607. SELECT co.*, bou.name AS buyer,s.name AS shopName,c.name AS clubName
  608. FROM cm_order co
  609. LEFT JOIN cm_shop_order cso ON co.orderID = cso.orderID
  610. LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
  611. LEFT JOIN shop s ON s.shopID = cso.shopID
  612. LEFT JOIN club c ON c.userID = co.userID
  613. <where>
  614. <if test="startTime != null and startTime != ''">
  615. AND co.orderTime <![CDATA[ >= ]]> #{startTime}
  616. </if>
  617. <if test="endTime != null and endTime != ''">
  618. AND co.orderTime <![CDATA[ <= ]]> #{endTime}
  619. </if>
  620. <if test="orderID != null and orderID != ''">
  621. AND co.orderID = #{orderID}
  622. </if>
  623. <if test="organizeID != null and organizeID != 9999">
  624. AND co.organizeID = #{organizeID}
  625. </if>
  626. <if test="organizeID == 9999">
  627. AND co.orderType = 2
  628. </if>
  629. <if test="orderNo != null and orderNo != ''">
  630. AND co.orderNo like concat('%', #{orderNo} ,'%')
  631. </if>
  632. <if test="shopName != null and shopName != ''">
  633. AND s.name like concat('%', #{shopName} ,'%')
  634. </if>
  635. <if test="buyer != null and buyer != ''">
  636. AND bou.name like concat('%', #{buyer} ,'%')
  637. </if>
  638. <if test="clubName != null and clubName != ''">
  639. AND c.name like concat('%', #{clubName} ,'%')
  640. </if>
  641. <if test="shopOrderIDs != null and shopOrderIDs != ''">
  642. AND cso.shopOrderID = #{shopOrderIDs}
  643. </if>
  644. <if test="shopOrderNo != null and shopOrderNo != ''">
  645. AND cso.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
  646. </if>
  647. <if test="ps != null and ps.length>0 " >
  648. AND co.payStatus IN
  649. <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
  650. #{item}
  651. </foreach>
  652. </if>
  653. <if test="receiptStatus != null and receiptStatus!= ''">
  654. AND receiptStatus = #{receiptStatus}
  655. </if>
  656. <if test="refundType !=null and refundType != ''">
  657. <if test="refundType == 1 or refundType == 2">
  658. AND refundType = #{refundType}
  659. </if>
  660. <if test="refundType == 0">
  661. AND refundType NOT IN (1,2)
  662. </if>
  663. </if>
  664. <if test="rebateOrder != null and rebateOrder !=''">
  665. <if test="rebateOrder == 0">
  666. AND cso.shopOrderID NOT IN (
  667. SELECT orderID FROM cm_receipt_order_relation
  668. WHERE relationType = '1' AND delFlag = '0' AND orderID IS NOT NULL)
  669. </if>
  670. <if test="rebateOrder == 1">
  671. AND cso.shopOrderID IN (
  672. SELECT orderID FROM cm_receipt_order_relation
  673. WHERE relationType = '1' AND delFlag = '0' AND orderID IS NOT NULL)
  674. </if>
  675. </if>
  676. AND co.delFlag = '0'
  677. AND cso.delFlag = '0'
  678. </where>
  679. GROUP BY co.orderID
  680. ORDER BY co.orderID DESC
  681. </select>
  682. <select id="findPaidOrderID" resultType="Double">
  683. SELECT SUM(payAmount)
  684. FROM cm_pay_shop_record cosr
  685. LEFT JOIN cm_shop_order cso ON cosr.shopOrderID = cso.shopOrderID
  686. WHERE cso.orderID = #{orderID}
  687. AND cosr.delFlag = '0'
  688. AND cosr.status = '1'
  689. GROUP BY cso.orderID
  690. </select>
  691. <select id="findPromotionsByIds" resultType="com.caimei.modules.product.entity.CmPromotion">
  692. select * from cm_promotions
  693. where id in
  694. <foreach collection="promotionsIds" item="promotionsId" index="index" open="(" separator="," close=")">
  695. #{promotionsId}
  696. </foreach>
  697. </select>
  698. <select id="getDbPromotionsByOrderId" resultType="com.caimei.modules.product.entity.CmPromotion">
  699. select * from cm_promotions_order
  700. where promotionsId=#{promotionsId} and orderId=#{orderId}
  701. </select>
  702. <select id="findServiceProviderList" resultType="com.caimei.modules.user.entity.NewCmSp">
  703. select s.serviceProviderID,s.linkMan1 from serviceprovider s join user u on s.userID = u.userID where s.status = 90 and s.serviceProviderID != 1342
  704. </select>
  705. <insert id="insertPromotionsRecord" parameterType="com.caimei.modules.product.entity.CmPromotion" keyProperty="id" useGeneratedKeys="true">
  706. INSERT INTO cm_promotions_order(
  707. orderId,
  708. promotionsId,
  709. name,
  710. description,
  711. type,
  712. mode,
  713. touchPrice,
  714. reducedPrice,
  715. status,
  716. beginTime,
  717. endTime
  718. ) VALUES (
  719. #{orderId},
  720. #{promotionsId},
  721. #{name},
  722. #{description},
  723. #{type},
  724. #{mode},
  725. #{touchPrice},
  726. #{reducedPrice},
  727. #{status},
  728. #{beginTime},
  729. #{endTime}
  730. )
  731. </insert>
  732. <update id="updatePromotionsRecord">
  733. update cm_promotions_order
  734. <set >
  735. <if test="orderId != null and orderId !=''" >
  736. orderId = #{orderId},
  737. </if>
  738. <if test="promotionsId != null and promotionsId !=''" >
  739. promotionsId = #{promotionsId},
  740. </if>
  741. <if test="name != null and name !=''" >
  742. name = #{name},
  743. </if>
  744. <if test="description != null and description !=''" >
  745. description = #{description},
  746. </if>
  747. <if test="type != null and type !=''" >
  748. type = #{type},
  749. </if>
  750. <if test="mode != null and mode !=''" >
  751. mode = #{mode},
  752. </if>
  753. <if test="touchPrice != null and touchPrice !=''" >
  754. touchPrice = #{touchPrice},
  755. </if>
  756. <if test="reducedPrice != null and reducedPrice !=''" >
  757. reducedPrice = #{reducedPrice},
  758. </if>
  759. <if test="status != null and status !=''" >
  760. status = #{status},
  761. </if>
  762. <if test="beginTime != null and beginTime !=''" >
  763. beginTime = #{beginTime},
  764. </if>
  765. <if test="endTime != null and endTime !=''" >
  766. endTime = #{endTime}
  767. </if>
  768. </set>
  769. where id = #{id}
  770. </update>
  771. <update id="updateOrderStatus">
  772. update cm_order set payStatus = #{payStatus} ,zeroCostFlag = #{zeroCostFlag} where orderID = #{orderID}
  773. </update>
  774. <delete id="deleterPomotionsOrder">
  775. DELETE FROM cm_promotions_order WHERE orderId = #{orderId}
  776. </delete>
  777. <update id="updateByRebateFlag">
  778. UPDATE cm_order SET rebateFlag = 1 WHERE orderID = #{orderId}
  779. </update>
  780. <select id="findQualificationFile" resultType="com.caimei.modules.order.entity.CmFile">
  781. SELECT
  782. fileName,
  783. ossName
  784. FROM
  785. cm_qualification_file
  786. WHERE
  787. recordId = #{recordId}
  788. </select>
  789. <select id="findQualificationImage" resultType="string">
  790. SELECT image FROM cm_qualification_image WHERE recordId = #{recordId} ORDER BY id
  791. </select>
  792. <delete id="deleteQualificationImage">
  793. DELETE FROM cm_qualification_image WHERE recordId = #{recordId}
  794. </delete>
  795. <insert id="insertQualificationImage">
  796. INSERT INTO `cm_qualification_image` (
  797. `recordId`, `image`)
  798. VALUES
  799. (#{recordId}, #{image});
  800. </insert>
  801. <delete id="deleteQualificationFile">
  802. DELETE FROM cm_qualification_file WHERE recordId = #{recordId}
  803. </delete>
  804. <insert id="insertQualificationFile">
  805. INSERT INTO `cm_qualification_file` (
  806. `recordId`, `fileName`, `ossName`
  807. )
  808. VALUES
  809. (
  810. #{recordId}, #{fileName}, #{ossName}
  811. )
  812. </insert>
  813. </mapper>