OrderMapper.xml 27 KB

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