OrderMapper.xml 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254
  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.orderSeen AS orderSeen,
  6. a.orderID AS orderID,
  7. a.orderNo AS orderNo,
  8. a.organizeID AS organizeID,
  9. a.userID AS userID,
  10. a.buyUserID AS buyUserID,
  11. a.shopOrderIDs AS shopOrderIDs,
  12. a.orderSubmitType AS orderSubmitType,
  13. a.orderType AS orderType,
  14. a.secondHandOrderFlag AS secondHandOrderFlag,
  15. a.status AS status,
  16. a.productTotalFee AS productTotalFee,
  17. a.orderTotalFee AS orderTotalFee,
  18. a.payTotalFee AS payTotalFee,
  19. a.payableAmount AS payableAmount,
  20. a.balancePayFee AS balancePayFee ,
  21. a.discountFee AS discountFee,
  22. a.spID AS spID,
  23. a.mainSpID AS mainSpID,
  24. a.note AS note,
  25. a.clubID AS clubID,
  26. a.clubScanTime AS clubScanTime,
  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.confirmFlag AS confirmFlag,
  33. a.clauseID AS clauseID,
  34. a.clauseContent AS clauseContent,
  35. a.clauseName AS clauseName,
  36. a.updateDate AS updateDate,
  37. a.freePostFlag AS freePostFlag,
  38. a.freight AS freight,
  39. a.userBeans AS userBeans,
  40. a.delFlag AS delFlag,
  41. a.onlinePayFlag AS onlinePayFlag,
  42. a.payTime AS payTime,
  43. a.splitFlag AS splitFlag,
  44. (select sum(cop.totalAddedValueTax) from cm_order_product cop where cop.orderID = a.orderID) AS totalAddedValueTax,
  45. a.preferential AS preferential,
  46. a.closeReason AS closeReason,
  47. a.receiptStatus as receiptStatus,
  48. a.payStatus as payStatus,
  49. a.sendOutStatus as sendOutStatus,
  50. a.refundType as refundType,
  51. a.postageOrderFlag AS postageOrderFlag,
  52. a.promotionFullReduction AS promotionFullReduction,
  53. a.promotionalGiftsCount AS promotionalGiftsCount,
  54. a.affirmPaymentFlag AS affirmPaymentFlag,
  55. a.rebateFlag AS rebateFlag,
  56. a.zeroCostFlag AS zeroCostFlag,
  57. a.organizeStoreId as organizeStoreId,
  58. a.couponAmount as couponAmount,
  59. a.svipFullReduction as svipFullReduction,
  60. if(chcm.id is not null,1,0) as collageFlag,
  61. chc.status as collageStatus
  62. </sql>
  63. <select id="get" resultType="newOrder">
  64. SELECT
  65. <include refid="columns"/>
  66. FROM cm_order a
  67. LEFT JOIN cm_hehe_collage_member chcm on a.orderID = chcm.orderId
  68. LEFT JOIN cm_hehe_collage chc on chcm.collageId = chc.id
  69. WHERE a.orderID = #{id}
  70. </select>
  71. <resultMap id="orderDisplayList" type="com.caimei.modules.order.entity.NewOrder">
  72. <id column="orderID" property="orderID"/>
  73. <result column="orderNo" property="orderNo"/>
  74. <result column="organizeID" property="organizeID"/>
  75. <result column="orderType" property="orderType"/>
  76. <result column="shopName" property="shopName"/>
  77. <result column="receiver" property="receiver"/>
  78. <result column="buyer" property="buyer"/>
  79. <result column="orderSource" property="orderSource"/>
  80. <result column="orderTotalFee" property="orderTotalFee"/>
  81. <result column="orderTime" property="orderTime"/>
  82. <result column="productCount" property="productCount"/>
  83. <result column="alreadyReceipt" property="alreadyReceipt"/>
  84. <result column="unReceipt" property="unReceipt"/>
  85. <result column="payTotalFee" property="payTotalFee"/>
  86. <result column="status" property="status"/>
  87. <collection property="newShopOrders" ofType="com.caimei.modules.order.entity.NewShopOrder"
  88. select="loadShopOrders" column="orderNo" fetchType="eager">
  89. </collection>
  90. </resultMap>
  91. <select id="findList" resultMap="orderDisplayList" parameterType="NewOrder">
  92. SELECT DISTINCT
  93. co.orderID AS orderID,
  94. co.orderNo AS orderNo,
  95. co.organizeID AS organizeID,
  96. co.userID AS userID,
  97. co.orderType AS orderType,
  98. co.secondHandOrderFlag AS secondHandOrderFlag,
  99. co.onlinePayFlag AS onlinePayFlag,
  100. bou.shouHuoRen AS receiver,
  101. u.name AS buyer,
  102. co.orderSource AS orderSource,
  103. co.orderTotalFee AS orderTotalFee,
  104. co.payableAmount AS payableAmount,
  105. co.orderTime AS orderTime,
  106. co.confirmTime AS confirmTime,
  107. co.payTotalFee AS payTotalFee,
  108. co.payStatus AS payStatus,
  109. co.refundType AS refundType,
  110. co.sendOutStatus AS sendOutStatus,
  111. co.receiptStatus AS receiptStatus,
  112. co.productCount AS productCount,
  113. (SELECT IFNULL(sum(cop.shouldPayFee),0) FROM cm_order_product cop WHERE cop.orderId=co.orderID) AS
  114. "shouldPayProduct",
  115. co.status AS status,
  116. co.splitFlag AS splitFlag,
  117. co.postageOrderFlag AS postageOrderFlag,
  118. (case when co.orderType = '0' then
  119. (select case status when 91 then '采美默认协销经理(官方账号)' else linkMan end from serviceprovider where serviceProviderID
  120. = co.spID)
  121. else
  122. ''
  123. end) AS spName,
  124. co.rebateFlag AS rebateFlag
  125. FROM cm_order co
  126. LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
  127. LEFT JOIN user u ON u.userID = co.userID
  128. LEFT JOIN club c ON u.userID = c.userID
  129. LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID and sp.status = 90
  130. LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
  131. LEFT JOIN product p ON cop.productID = p.productID
  132. <where>
  133. co.orderType != 2
  134. <if test="orderID != null and orderID != ''">
  135. AND co.orderID = #{orderID}
  136. </if>
  137. <if test="orderNo != null and orderNo != ''">
  138. AND co.orderNo = #{orderNo}
  139. </if>
  140. <if test="organizeID != null">
  141. AND co.organizeID = #{organizeID}
  142. </if>
  143. <if test="status != null and status != ''">
  144. <choose>
  145. <when test="status == '99'.toString()">
  146. AND co.status in (11,12,13,21,22,23,31,32,33)
  147. </when>
  148. <otherwise>
  149. AND co.status = #{status}
  150. </otherwise>
  151. </choose>
  152. </if>
  153. <if test="buyer != null and buyer != ''">
  154. AND u.name LIKE concat('%',#{buyer},'%')
  155. </if>
  156. <if test="orderType != null and orderType != ''">
  157. AND co.orderType = #{orderType}
  158. </if>
  159. <if test="secondHandOrderFlag != null and secondHandOrderFlag != ''">
  160. AND co.secondHandOrderFlag = #{secondHandOrderFlag}
  161. </if>
  162. <if test="orderSource != null and orderSource != ''">
  163. AND co.orderSource = #{orderSource}
  164. </if>
  165. <if test="orderTime != null and orderTime != ''">
  166. AND co.orderTime = #{orderTime}
  167. </if>
  168. <if test="sendOutStatus != null and sendOutStatus != ''">
  169. AND co.sendOutStatus = #{sendOutStatus}
  170. </if>
  171. <if test="startTime != null and startTime != ''">
  172. AND co.orderTime <![CDATA[ >= ]]> #{startTime}
  173. </if>
  174. <if test="endTime != null and endTime != ''">
  175. AND co.orderTime <![CDATA[ <= ]]> #{endTime}
  176. </if>
  177. <if test="startConfirmTime != null and startConfirmTime != ''">
  178. AND co.confirmTime <![CDATA[ >= ]]> #{startConfirmTime}
  179. </if>
  180. <if test="endConfirmTime != null and endConfirmTime != ''">
  181. AND co.confirmTime <![CDATA[ <= ]]> #{endConfirmTime}
  182. </if>
  183. <if test="receiver != null and receiver != ''">
  184. AND bou.shouHuoRen LIKE concat('%',#{receiver},'%')
  185. </if>
  186. <if test="receiptStatus != null and receiptStatus != ''">
  187. AND co.receiptStatus = #{receiptStatus}
  188. </if>
  189. <if test="payStatus != null and payStatus != ''">
  190. AND co.payStatus = #{payStatus}
  191. </if>
  192. <if test="sendOutStatus != null and sendOutStatus != ''">
  193. AND co.sendOutStatus = #{sendOutStatus}
  194. </if>
  195. <if test="returnedPurchaseStatus != null and returnedPurchaseStatus != ''">
  196. AND
  197. <if test="returnedPurchaseStatus == 1">
  198. exists
  199. </if>
  200. <if test="returnedPurchaseStatus == 0">
  201. not exists
  202. </if>
  203. (select 1 from cm_returned_purchase c3 where c3.status = '1' and c3.orderID = co.orderID and c3.delFlag
  204. = 0)
  205. </if>
  206. <if test="refundType != null and refundType != ''">
  207. AND
  208. <if test="refundType == 0">
  209. co.refundType is null
  210. </if>
  211. <if test="refundType == 1">
  212. co.refundType = '1'
  213. </if>
  214. <if test="refundType == 2">
  215. co.refundType = '2'
  216. </if>
  217. </if>
  218. <if test="orderRefundType != null and orderRefundType != ''">
  219. <if test="orderRefundType == 0">
  220. AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.delFlag =
  221. 0) = 0
  222. </if>
  223. <if test="orderRefundType == 1">
  224. AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.delFlag =
  225. 0) > 0
  226. </if>
  227. <if test="orderRefundType == 11">
  228. AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 1
  229. and crp.delFlag = 0) > 0
  230. </if>
  231. <if test="orderRefundType == 12">
  232. AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 2
  233. and crp.delFlag = 0
  234. <if test="startRefundTime != null and startRefundTime != ''">
  235. AND crp.confirmReturnTime <![CDATA[ >= ]]> #{startRefundTime}
  236. </if>
  237. <if test="endRefundTime != null and endRefundTime != ''">
  238. AND crp.confirmReturnTime <![CDATA[ <= ]]> #{endRefundTime}
  239. </if>
  240. ) > 0
  241. </if>
  242. <if test="orderRefundType == 13">
  243. AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 3
  244. and crp.delFlag = 0) > 0
  245. </if>
  246. </if>
  247. <if test="rebateOrder != null and rebateOrder != ''">
  248. AND
  249. (
  250. <if test="rebateOrder == 1">
  251. co.rebateFlag = '1'
  252. OR exists
  253. </if>
  254. <if test="rebateOrder == 0">
  255. co.rebateFlag = '0'
  256. AND not exists
  257. </if>
  258. (select 1 from cm_receipt_order_relation c1
  259. left join cm_discern_receipt cdr ON c1.receiptID = cdr.id
  260. where c1.relationType = '1'
  261. and c1.orderID in (select c2.shopOrderID from cm_shop_order c2 where c2.orderID = co.orderID)
  262. and c1.delFlag = '0'
  263. and cdr.receiptStatus = '2'))
  264. </if>
  265. <if test="serviceProviderId != null and serviceProviderId != 0">
  266. and (co.spID = #{serviceProviderId}
  267. or sp.serviceProviderID = #{serviceProviderId})
  268. </if>
  269. <if test="productName != null and productName != ''">
  270. and p.name like CONCAT('%',#{productName},'%')
  271. </if>
  272. AND co.delFlag = 0
  273. </where>
  274. <choose>
  275. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  276. ORDER BY ${page.orderBy}
  277. </when>
  278. <otherwise>
  279. ORDER BY co.orderID DESC, co.orderTime DESC
  280. </otherwise>
  281. </choose>
  282. </select>
  283. <select id="loadShopOrders" parameterType="string" resultType="NewShopOrder">
  284. SELECT cs.shopOrderID AS shopOrderID,
  285. cs.shopOrderNo AS shopOrderNo,
  286. cs.shopOrderNo AS shopOrderNo,
  287. cs.itemCount AS itemCount,
  288. cs.needPayAmount AS needPayAmount,
  289. s.name AS shopName,
  290. cs.shopID AS shopID
  291. FROM cm_shop_order cs
  292. LEFT JOIN shop s ON cs.shopID = s.shopID
  293. WHERE cs.orderNo = #{orderNo}
  294. AND cs.delFlag = 0
  295. </select>
  296. <select id="getShopOrders" parameterType="string" resultType="NewShopOrder">
  297. SELECT (SELECT IFNULL(sum(shouldPayFee), 0)
  298. FROM cm_order_product
  299. WHERE shopOrderID = cs.shopOrderID AND payStatus = 2) AS
  300. alreadyReceipt,
  301. (SELECT IFNULL(sum(shouldPayFee), 0)
  302. FROM cm_order_product
  303. WHERE shopOrderID = cs.shopOrderID AND payStatus != 2) AS unReceipt,
  304. cs.shopOrderID AS shopOrderID,
  305. co.orderID AS orderID,
  306. cs.shopOrderNo AS shopOrderNo,
  307. co.orderNo AS orderNo,
  308. cs.shopOrderNo AS shopOrderNo,
  309. cs.itemCount AS itemCount,
  310. cs.needPayAmount AS needPayAmount,
  311. co.orderType AS orderType,
  312. s.name AS shopName,
  313. bou.shouHuoRen AS receiver,
  314. u.name AS buyer,
  315. co.orderSource AS orderSource,
  316. co.orderTotalFee AS orderTotalFee,
  317. co.orderTime AS orderTime
  318. FROM cm_shop_order cs
  319. LEFT JOIN cm_order co ON cs.orderNo = co.orderNo
  320. LEFT JOIN shop s ON cs.shopID = s.shopID
  321. LEFT JOIN user u ON cs.userID = u.userID
  322. LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
  323. WHERE cs.orderNo = #{orderNo}
  324. AND cs.delFlag = 0
  325. </select>
  326. <update id="updateClauseContent">
  327. UPDATE cm_order
  328. SET clauseContent = #{clauseContent},
  329. clauseName= #{clauseName}WHERE orderID = #{orderID}
  330. </update>
  331. <insert id="insert" parameterType="NewOrder" keyProperty="orderID" useGeneratedKeys="true">
  332. INSERT INTO cm_order(orderSeen,
  333. orderNo,
  334. userID,
  335. buyUserID,
  336. shopOrderIDs,
  337. orderSubmitType,
  338. orderType,
  339. secondHandOrderFlag,
  340. status,
  341. payFlag,
  342. onlinePayFlag,
  343. productTotalFee,
  344. orderTotalFee,
  345. payTotalFee,
  346. balancePayFee,
  347. discountFee,
  348. spID,
  349. mainSpID,
  350. note,
  351. clubID,
  352. clubScanTime,
  353. orderSource,
  354. orderTime,
  355. productCount,
  356. confirmFlag,
  357. clauseID,
  358. clauseContent,
  359. clauseName,
  360. updateDate,
  361. freePostFlag,
  362. freight,
  363. delFlag,
  364. payTime,
  365. splitFlag,
  366. preferential,
  367. confirmTime,
  368. invoiceFlag,
  369. postageOrderFlag,
  370. sendOutStatus,
  371. payableAmount,
  372. promotionFullReduction,
  373. promotionalGiftsCount,
  374. affirmPaymentFlag,
  375. rebateFlag,
  376. payStatus,
  377. zeroCostFlag,
  378. couponAmount,
  379. svipFullReduction)
  380. VALUES (#{orderSeen},
  381. #{orderNo},
  382. #{userID},
  383. #{buyUserID},
  384. #{shopOrderIDs},
  385. #{orderSubmitType},
  386. #{orderType},
  387. #{secondHandOrderFlag},
  388. #{status},
  389. #{payFlag},
  390. #{onlinePayFlag},
  391. #{productTotalFee},
  392. #{orderTotalFee},
  393. #{payTotalFee},
  394. #{balancePayFee},
  395. #{discountFee},
  396. #{spID},
  397. #{mainSpID},
  398. #{note},
  399. #{clubID},
  400. #{clubScanTime},
  401. #{orderSource},
  402. #{orderTime},
  403. #{productCount},
  404. #{confirmFlag},
  405. #{clauseID},
  406. #{clauseContent},
  407. #{clauseName},
  408. #{updateDate},
  409. #{freePostFlag},
  410. #{freight},
  411. #{delFlag},
  412. #{payTime},
  413. #{splitFlag},
  414. #{preferential},
  415. #{confirmTime},
  416. #{invoiceFlag},
  417. #{postageOrderFlag},
  418. #{sendOutStatus},
  419. #{payableAmount},
  420. #{promotionFullReduction},
  421. #{promotionalGiftsCount},
  422. #{affirmPaymentFlag},
  423. #{rebateFlag},
  424. #{payStatus},
  425. #{zeroCostFlag},
  426. #{couponAmount},
  427. #{svipFullReduction})
  428. </insert>
  429. <update id="update">
  430. update cm_order
  431. <set>
  432. <if test="orderSeen != null">
  433. orderSeen = #{orderSeen},
  434. </if>
  435. <if test="orderNo != null">
  436. orderNo = #{orderNo,jdbcType=VARCHAR},
  437. </if>
  438. <if test="userID != null">
  439. userID = #{userID,jdbcType=BIGINT},
  440. </if>
  441. <if test="organizeID != null">
  442. organizeID = #{organizeID,jdbcType=INTEGER},
  443. </if>
  444. <if test="buyUserID != null">
  445. buyUserID = #{buyUserID,jdbcType=INTEGER},
  446. </if>
  447. <if test="shopOrderIDs != null">
  448. shopOrderIDs = #{shopOrderIDs,jdbcType=VARCHAR},
  449. </if>
  450. <if test="orderSubmitType != null">
  451. orderSubmitType = #{orderSubmitType,jdbcType=CHAR},
  452. </if>
  453. <if test="orderType != null">
  454. orderType = #{orderType,jdbcType=CHAR},
  455. </if>
  456. <if test="secondHandOrderFlag != null">
  457. secondHandOrderFlag = #{secondHandOrderFlag,jdbcType=CHAR},
  458. </if>
  459. <if test="status != null">
  460. status = #{status,jdbcType=CHAR},
  461. </if>
  462. <if test="productTotalFee != null">
  463. productTotalFee = #{productTotalFee,jdbcType=DECIMAL},
  464. </if>
  465. <if test="orderTotalFee != null">
  466. orderTotalFee = #{orderTotalFee,jdbcType=DECIMAL},
  467. </if>
  468. <if test="payTotalFee != null">
  469. payTotalFee = #{payTotalFee,jdbcType=DECIMAL},
  470. </if>
  471. <if test="payableAmount != null">
  472. payableAmount = #{payableAmount,jdbcType=DECIMAL},
  473. </if>
  474. <if test="balancePayFee != null">
  475. balancePayFee = #{balancePayFee,jdbcType=DECIMAL},
  476. </if>
  477. <if test="discountFee != null">
  478. discountFee = #{discountFee,jdbcType=DECIMAL},
  479. </if>
  480. <if test="spID != null">
  481. spID = #{spID,jdbcType=BIGINT},
  482. </if>
  483. <if test="mainSpID != null">
  484. mainSpID = #{mainSpID,jdbcType=BIGINT},
  485. </if>
  486. <if test="clubID != null">
  487. clubID = #{clubID,jdbcType=BIGINT},
  488. </if>
  489. <if test="clubScanTime != null">
  490. clubScanTime = #{clubScanTime,jdbcType=VARCHAR},
  491. </if>
  492. <if test="orderSource != null">
  493. orderSource = #{orderSource,jdbcType=CHAR},
  494. </if>
  495. <if test="orderTime != null">
  496. orderTime = #{orderTime,jdbcType=TIMESTAMP},
  497. </if>
  498. <if test="productCount != null">
  499. productCount = #{productCount,jdbcType=INTEGER},
  500. </if>
  501. <if test="presentCount != null">
  502. presentCount = #{presentCount,jdbcType=INTEGER},
  503. </if>
  504. <if test="confirmFlag != null">
  505. confirmFlag = #{confirmFlag,jdbcType=CHAR},
  506. </if>
  507. <if test="clauseID != null">
  508. clauseID = #{clauseID,jdbcType=BIGINT},
  509. </if>
  510. <if test="clauseName != null">
  511. clauseName = #{clauseName,jdbcType=VARCHAR},
  512. </if>
  513. <if test="freePostFlag != null">
  514. freePostFlag = #{freePostFlag,jdbcType=CHAR},
  515. </if>
  516. <if test="freight != null">
  517. freight = #{freight,jdbcType=DECIMAL},
  518. </if>
  519. <if test="delFlag != null">
  520. delFlag = #{delFlag,jdbcType=CHAR},
  521. </if>
  522. <if test="note != null">
  523. note = #{note,jdbcType=LONGVARCHAR},
  524. </if>
  525. <if test="clauseContent != null">
  526. clauseContent = #{clauseContent,jdbcType=LONGVARCHAR},
  527. </if>
  528. <if test="payTime != null">
  529. payTime = #{payTime,jdbcType=LONGVARCHAR},
  530. </if>
  531. <if test="preferential != null">
  532. preferential = #{preferential ,jdbcType=DECIMAL},
  533. </if>
  534. <if test="discountFee != null">
  535. discountFee = #{discountFee},
  536. </if>
  537. <if test="payFlag != null">
  538. payFlag = #{payFlag},
  539. </if>
  540. <if test="onlinePayFlag != null">
  541. onlinePayFlag = #{onlinePayFlag},
  542. </if>
  543. <if test="splitFlag != null">
  544. splitFlag = #{splitFlag},
  545. </if>
  546. <if test="closeReason != null">
  547. closeReason = #{closeReason},
  548. </if>
  549. <if test="confirmTime != null">
  550. confirmTime = #{confirmTime},
  551. </if>
  552. <if test="invoiceFlag != null">
  553. invoiceFlag = #{invoiceFlag},
  554. </if>
  555. <if test="postageOrderFlag != null">
  556. postageOrderFlag = #{postageOrderFlag},
  557. </if>
  558. <if test="sendOutStatus != null">
  559. sendOutStatus = #{sendOutStatus},
  560. </if>
  561. <if test="receiptStatus != null">
  562. receiptStatus = #{receiptStatus},
  563. </if>
  564. <if test="payStatus != null">
  565. payStatus = #{payStatus},
  566. </if>
  567. <if test="refundType != null">
  568. refundType = #{refundType},
  569. </if>
  570. <if test="promotionFullReduction != null">
  571. promotionFullReduction = #{promotionFullReduction},
  572. </if>
  573. <if test="promotionalGiftsCount != null">
  574. promotionalGiftsCount = #{promotionalGiftsCount},
  575. </if>
  576. <if test="affirmPaymentFlag != null">
  577. affirmPaymentFlag = #{affirmPaymentFlag},
  578. </if>
  579. <if test="rebateFlag != null">
  580. rebateFlag = #{rebateFlag},
  581. </if>
  582. <if test="zeroCostFlag != null">
  583. zeroCostFlag = #{zeroCostFlag},
  584. </if>
  585. <if test="couponAmount != null">
  586. couponAmount = #{couponAmount},
  587. </if>
  588. <if test="svipFullReduction != null">
  589. svipFullReduction = #{svipFullReduction}
  590. </if>
  591. </set>
  592. where orderID = #{orderID,jdbcType=BIGINT}
  593. </update>
  594. <select id="findByOrderID" resultType="NewOrder">
  595. select *
  596. from cm_order
  597. where orderID = #{orderID}
  598. </select>
  599. <update id="confirmOrder">
  600. </update>
  601. <update id="updateStatus" parameterType="NewOrder">
  602. UPDATE cm_order
  603. SET status = #{status}
  604. WHERE orderID = #{orderID}
  605. </update>
  606. <select id="getOrderByShopOrderID" resultType="NewOrder">
  607. select *
  608. from cm_order co
  609. left join cm_shop_order cso on cso.orderID = co.orderID
  610. where cso.shopOrderID = #{shopOrderID}
  611. </select>
  612. <update id="updatePayStatus">
  613. update cm_order
  614. set payStatus = #{payStatus}
  615. where orderID = #{orderID}
  616. </update>
  617. <select id="findOrderList" resultType="NewOrder" parameterType="NewOrder">
  618. SELECT co.*, bou.name AS buyer,s.name AS shopName,c.name AS clubName
  619. FROM cm_order co
  620. LEFT JOIN cm_shop_order cso ON co.orderID = cso.orderID
  621. LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
  622. LEFT JOIN shop s ON s.shopID = cso.shopID
  623. LEFT JOIN club c ON c.userID = co.userID
  624. <where>
  625. <if test="startTime != null and startTime != ''">
  626. AND co.orderTime <![CDATA[ >= ]]> #{startTime}
  627. </if>
  628. <if test="endTime != null and endTime != ''">
  629. AND co.orderTime <![CDATA[ <= ]]> #{endTime}
  630. </if>
  631. <if test="orderID != null and orderID != ''">
  632. AND co.orderID = #{orderID}
  633. </if>
  634. <if test="organizeID != null and organizeID != 9999">
  635. AND co.organizeID = #{organizeID}
  636. </if>
  637. <if test="organizeID == 9999">
  638. AND co.orderType = 2
  639. </if>
  640. <if test="orderNo != null and orderNo != ''">
  641. AND co.orderNo like concat('%', #{orderNo} ,'%')
  642. </if>
  643. <if test="shopName != null and shopName != ''">
  644. AND s.name like concat('%', #{shopName} ,'%')
  645. </if>
  646. <if test="buyer != null and buyer != ''">
  647. AND bou.name like concat('%', #{buyer} ,'%')
  648. </if>
  649. <if test="clubName != null and clubName != ''">
  650. AND c.name like concat('%', #{clubName} ,'%')
  651. </if>
  652. <if test="shopOrderIDs != null and shopOrderIDs != ''">
  653. AND cso.shopOrderID = #{shopOrderIDs}
  654. </if>
  655. <if test="shopOrderNo != null and shopOrderNo != ''">
  656. AND cso.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
  657. </if>
  658. <if test="ps != null and ps.length>0 ">
  659. AND co.payStatus IN
  660. <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
  661. #{item}
  662. </foreach>
  663. </if>
  664. <if test="receiptStatus != null and receiptStatus!= ''">
  665. AND receiptStatus = #{receiptStatus}
  666. </if>
  667. <if test="refundType !=null and refundType != ''">
  668. <if test="refundType == 1 or refundType == 2">
  669. AND refundType = #{refundType}
  670. </if>
  671. <if test="refundType == 0">
  672. AND refundType NOT IN (1,2)
  673. </if>
  674. </if>
  675. <if test="rebateOrder != null and rebateOrder !=''">
  676. <if test="rebateOrder == 0">
  677. AND cso.shopOrderID NOT IN (
  678. SELECT orderID FROM cm_receipt_order_relation
  679. WHERE relationType = '1' AND delFlag = '0' AND orderID IS NOT NULL)
  680. </if>
  681. <if test="rebateOrder == 1">
  682. AND cso.shopOrderID IN (
  683. SELECT orderID FROM cm_receipt_order_relation
  684. WHERE relationType = '1' AND delFlag = '0' AND orderID IS NOT NULL)
  685. </if>
  686. </if>
  687. AND co.delFlag = '0'
  688. AND cso.delFlag = '0'
  689. </where>
  690. GROUP BY co.orderID
  691. ORDER BY co.orderID DESC
  692. </select>
  693. <select id="findPaidOrderID" resultType="Double">
  694. SELECT SUM(payAmount)
  695. FROM cm_pay_shop_record cosr
  696. LEFT JOIN cm_shop_order cso ON cosr.shopOrderID = cso.shopOrderID
  697. WHERE cso.orderID = #{orderID}
  698. AND cosr.delFlag = '0'
  699. AND cosr.status = '1'
  700. AND cosr.paymentType IN (1, 2)
  701. GROUP BY cso.orderID
  702. </select>
  703. <select id="findPromotionsByIds" resultType="com.caimei.modules.product.entity.CmPromotion">
  704. select * from cm_promotions
  705. where id in
  706. <foreach collection="promotionsIds" item="promotionsId" index="index" open="(" separator="," close=")">
  707. #{promotionsId}
  708. </foreach>
  709. </select>
  710. <select id="getDbPromotionsByOrderId" resultType="com.caimei.modules.product.entity.CmPromotion">
  711. select *
  712. from cm_promotions_order
  713. where promotionsId = #{promotionsId}
  714. and orderId = #{orderId}
  715. </select>
  716. <select id="findServiceProviderList" resultType="com.caimei.modules.user.entity.NewCmSp">
  717. select s.serviceProviderID, s.linkMan
  718. from serviceprovider s
  719. join user u on s.userID = u.userID
  720. where s.status = 90
  721. and s.serviceProviderID != 1342
  722. </select>
  723. <insert id="insertPromotionsRecord" parameterType="com.caimei.modules.product.entity.CmPromotion" keyProperty="id"
  724. useGeneratedKeys="true">
  725. INSERT INTO cm_promotions_order(orderId,
  726. promotionsId,
  727. name,
  728. description,
  729. type,
  730. mode,
  731. touchPrice,
  732. reducedPrice,
  733. status,
  734. beginTime,
  735. endTime)
  736. VALUES (#{orderId},
  737. #{promotionsId},
  738. #{name},
  739. #{description},
  740. #{type},
  741. #{mode},
  742. #{touchPrice},
  743. #{reducedPrice},
  744. #{status},
  745. #{beginTime},
  746. #{endTime})
  747. </insert>
  748. <update id="updatePromotionsRecord">
  749. update cm_promotions_order
  750. <set>
  751. <if test="orderId != null and orderId !=''">
  752. orderId = #{orderId},
  753. </if>
  754. <if test="promotionsId != null and promotionsId !=''">
  755. promotionsId = #{promotionsId},
  756. </if>
  757. <if test="name != null and name !=''">
  758. name = #{name},
  759. </if>
  760. <if test="description != null and description !=''">
  761. description = #{description},
  762. </if>
  763. <if test="type != null and type !=''">
  764. type = #{type},
  765. </if>
  766. <if test="mode != null and mode !=''">
  767. mode = #{mode},
  768. </if>
  769. <if test="touchPrice != null and touchPrice !=''">
  770. touchPrice = #{touchPrice},
  771. </if>
  772. <if test="reducedPrice != null and reducedPrice !=''">
  773. reducedPrice = #{reducedPrice},
  774. </if>
  775. <if test="status != null and status !=''">
  776. status = #{status},
  777. </if>
  778. <if test="beginTime != null and beginTime !=''">
  779. beginTime = #{beginTime},
  780. </if>
  781. <if test="endTime != null and endTime !=''">
  782. endTime = #{endTime}
  783. </if>
  784. </set>
  785. where id = #{id}
  786. </update>
  787. <update id="updatePayAndReceipt">
  788. update cm_order
  789. set status = concat('3', sendOutStatus),
  790. payStatus= 3,
  791. receiptStatus= 3
  792. where orderID = #{orderId}
  793. </update>
  794. <update id="updateOrderStatus">
  795. update cm_order
  796. set payStatus = #{payStatus},
  797. zeroCostFlag = #{zeroCostFlag}
  798. where orderID = #{orderID}
  799. </update>
  800. <delete id="deleterPomotionsOrder">
  801. DELETE
  802. FROM cm_promotions_order
  803. WHERE orderId = #{orderId}
  804. </delete>
  805. <update id="updateByRebateFlag">
  806. UPDATE cm_order
  807. SET rebateFlag = 1
  808. WHERE orderID = #{orderId}
  809. </update>
  810. <select id="findQualificationFile" resultType="com.caimei.modules.order.entity.CmFile">
  811. SELECT fileName,
  812. ossName
  813. FROM cm_qualification_file
  814. WHERE recordId = #{recordId}
  815. </select>
  816. <select id="findQualificationImage" resultType="string">
  817. SELECT image
  818. FROM cm_qualification_image
  819. WHERE recordId = #{recordId}
  820. ORDER BY id
  821. </select>
  822. <delete id="deleteQualificationImage">
  823. DELETE
  824. FROM cm_qualification_image
  825. WHERE recordId = #{recordId}
  826. </delete>
  827. <insert id="insertQualificationImage">
  828. INSERT INTO `cm_qualification_image` (`recordId`, `image`)
  829. VALUES (#{recordId}, #{image});
  830. </insert>
  831. <delete id="deleteQualificationFile">
  832. DELETE
  833. FROM cm_qualification_file
  834. WHERE recordId = #{recordId}
  835. </delete>
  836. <insert id="insertQualificationFile">
  837. INSERT INTO `cm_qualification_file` (`recordId`, `fileName`, `ossName`)
  838. VALUES (#{recordId}, #{fileName}, #{ossName})
  839. </insert>
  840. <select id="findBYShortLink" resultType="integer">
  841. SELECT id
  842. FROM cm_short_link
  843. WHERE shortLink = #{shortLink}
  844. </select>
  845. <select id="getDepositOrderProductId" resultType="java.lang.Integer">
  846. SELECT productID
  847. FROM cm_order_product
  848. WHERE orderID = #{orderID}
  849. LIMIT 1
  850. </select>
  851. <insert id="insertShortLink">
  852. INSERT INTO cm_short_link (`markId`, `shortLink`, `jumpLink`,
  853. `createTime`)
  854. VALUES (#{markId}, #{shortLink}, #{url},
  855. NOW())
  856. </insert>
  857. <update id="updateSendNum">
  858. UPDATE cm_sms_statistics
  859. SET sendNum = (sendNum + #{num})
  860. WHERE markId = #{markId}
  861. </update>
  862. <update id="updateUserMoneyByUserId">
  863. UPDATE USER
  864. SET userMoney=(userMoney - #{payTotalFee}),
  865. ableUserMoney = (ableUserMoney - #{payTotalFee})
  866. WHERE userID = #{userID}
  867. </update>
  868. <select id="findOrderCouponRecord" resultType="com.caimei.modules.coupon.entity.CmCouponOrderRecord">
  869. SELECT `id`,
  870. `orderId`,
  871. `clubCouponId`,
  872. `couponType`,
  873. `couponAmount`,
  874. `touchPrice`,
  875. `createDate`
  876. FROM cm_coupon_order_record
  877. WHERE orderId = #{orderID}
  878. </select>
  879. <select id="findClubCouponById" resultType="com.caimei.modules.coupon.entity.CmCoupon">
  880. SELECT cc.`id`,
  881. cc.`couponAmount`,
  882. cc.`touchPrice`,
  883. cc.`couponType`,
  884. cc.`userId`,
  885. cc.`shopId`,
  886. cc.`productType`,
  887. cc.`categoryType`,
  888. cc.`couponsMode`
  889. FROM cm_coupon_club a
  890. LEFT JOIN cm_coupon cc ON a.couponId = cc.id
  891. WHERE a.id = #{clubCouponId}
  892. AND a.status = 1
  893. </select>
  894. <insert id="insertCouponOrderRecord">
  895. INSERT INTO `cm_coupon_order_record` (`orderId`,
  896. `clubCouponId`,
  897. `couponType`,
  898. `couponAmount`,
  899. `touchPrice`,
  900. `createDate`)
  901. VALUES (#{orderId},
  902. #{clubCouponId},
  903. #{couponType},
  904. #{couponAmount},
  905. #{touchPrice},
  906. #{createDate})
  907. </insert>
  908. <update id="updateCouponOrderRecord">
  909. UPDATE
  910. `cm_coupon_order_record`
  911. SET `clubCouponId` = #{clubCouponId},
  912. `couponType` = #{couponType},
  913. `couponAmount` = #{couponAmount},
  914. `touchPrice` = #{touchPrice}
  915. WHERE orderId = #{orderId}
  916. </update>
  917. <update id="updatePayStatusSon">
  918. UPDATE cm_shop_order
  919. SET payStatus=3
  920. WHERE orderID = #{orderId}
  921. </update>
  922. <delete id="deleteCouponOrderRecord">
  923. DELETE
  924. FROM cm_coupon_order_record
  925. WHERE id = #{id}
  926. </delete>
  927. <select id="getUndividedPaidReceipt" resultType="com.caimei.modules.order.entity.OrderReceiptRelationPo">
  928. SELECT cror.id,
  929. cror.relationType,
  930. cror.receiptId,
  931. cror.associateAmount,
  932. cror.orderId,
  933. cror.delFlag,
  934. cror.mbOrderId,
  935. cror.orderRequestNo,
  936. cror.splitStatus,
  937. cror.shopOrderId,
  938. cdr.payType
  939. FROM cm_receipt_order_relation cror
  940. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  941. LEFT JOIN cm_order co ON cror.orderID = co.orderID
  942. WHERE cror.relationType = 2
  943. AND cror.delFlag = 0
  944. AND cror.mbOrderId IS NOT NULL
  945. AND cror.splitStatus = 0
  946. AND cdr.payWay = 1
  947. AND cdr.receiptDate <![CDATA[ <= ]]> #{currentTime}
  948. AND co.organizeID = 0
  949. AND co.orderType != 2
  950. AND co.refundType != 2
  951. </select>
  952. <select id="getOnlineBalance" resultType="com.caimei.modules.order.entity.OrderReceiptRelationPo">
  953. SELECT DISTINCT cror.id,
  954. cror.relationType,
  955. cror.receiptId,
  956. cror.associateAmount,
  957. cror.orderId,
  958. cror.delFlag,
  959. cror.mbOrderId,
  960. cror.orderRequestNo,
  961. cror.splitStatus,
  962. cdr.payType
  963. FROM cm_receipt_order_relation cror
  964. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  965. LEFT JOIN cm_order co ON cror.orderID = co.orderID
  966. LEFT JOIN cm_user_balance_record cubr ON cubr.orderId = cror.orderID
  967. WHERE cror.relationType = 2
  968. AND cror.delFlag = 0
  969. AND cror.splitStatus = 0
  970. AND cdr.delFlag = 0
  971. AND cdr.payWay = 3
  972. AND cdr.receiptDate <![CDATA[ <= ]]> #{currentTime}
  973. AND co.organizeID = 0
  974. AND co.orderType != 2
  975. AND co.refundType != 2
  976. AND cubr.balanceType = 10
  977. AND cror.associateAmount > 0.01
  978. </select>
  979. <select id="getOrderProductByOrderId" resultType="com.caimei.modules.order.entity.OrderProductVo">
  980. SELECT cop.orderProductID AS orderProductId,
  981. cop.orderID AS orderId,
  982. cop.orderNo,
  983. cop.shopOrderID AS shopOrderId,
  984. cop.shopOrderNo,
  985. cop.orderPromotionsId,
  986. cop.productId,
  987. cop.shopId,
  988. cop.name,
  989. cop.productImage AS image,
  990. cop.price,
  991. cop.shopName,
  992. IF(cop.shopid = 998 AND co.freight > 0, co.freight, cop.costPrice) AS costPrice,
  993. cop.normalPrice,
  994. cop.ladderPriceFlag,
  995. cop.discountPrice,
  996. cop.discount,
  997. cop.totalAmount,
  998. cop.totalFee,
  999. cop.shouldPayFee,
  1000. cop.productUnit,
  1001. cop.num,
  1002. cop.presentNum,
  1003. cop.discountFee,
  1004. cop.includedTax,
  1005. cop.invoiceType,
  1006. cop.taxRate,
  1007. cop.addedValueTax,
  1008. cop.totalAddedValueTax,
  1009. cop.singleShouldPayTotalTax,
  1010. cop.shouldPayTotalTax,
  1011. cop.shopProductAmount,
  1012. cop.singleShopFee,
  1013. cop.shopFee,
  1014. cop.singleOtherFee,
  1015. cop.otherFee,
  1016. cop.singleCmFee,
  1017. cop.cmFee,
  1018. cop.payStatus,
  1019. cop.buyAgainFlag,
  1020. cop.notOutStore,
  1021. cop.isActProduct AS actProduct,
  1022. cop.productType,
  1023. p.productCategory as productCategory,
  1024. p.splitCode
  1025. FROM cm_order_product cop
  1026. LEFT JOIN product p ON cop.productID = p.productID
  1027. LEFT JOIN cm_order co ON cop.orderId = co.orderId
  1028. WHERE co.orderID = #{orderId}
  1029. AND IF(co.userBeans = 0, 1 = 1, cop.shopid != 998)
  1030. ORDER BY cop.discountPrice DESC
  1031. </select>
  1032. <select id="getOrderProductPaidAmount" resultType="java.lang.Double">
  1033. SELECT SUM(splitAccount)
  1034. FROM cm_split_account
  1035. WHERE orderProductId = #{orderProductId}
  1036. AND payStatus = 1
  1037. AND productType = 1
  1038. </select>
  1039. <select id="getShopOrderListByOrderId" resultType="com.caimei.modules.order.entity.ShopOrderVo">
  1040. SELECT shopOrderID AS shopOrderId,
  1041. shopOrderNo,
  1042. orderID AS orderId,
  1043. orderNo,
  1044. shopID AS shopId,
  1045. note,
  1046. userID AS userId,
  1047. clubID AS clubId,
  1048. spID AS spId,
  1049. orderPromotionsId,
  1050. promotionFullReduction,
  1051. brokerage,
  1052. canRefundAmount,
  1053. itemCount,
  1054. totalAmount,
  1055. productAmount,
  1056. needPayAmount,
  1057. shopProductAmount,
  1058. shopPostFee,
  1059. shopTaxFee,
  1060. shouldPayShopAmount,
  1061. orderTime,
  1062. orderSubmitType,
  1063. payStatus,
  1064. sendOutStatus,
  1065. splitFlag,
  1066. splitCode
  1067. FROM cm_shop_order
  1068. WHERE delFlag = 0
  1069. AND shopOrderID = #{shopOrderId}
  1070. </select>
  1071. <select id="getPaidShipping" resultType="java.lang.Double">
  1072. SELECT SUM(splitAccount)
  1073. FROM cm_split_account
  1074. WHERE orderId = #{orderId}
  1075. AND shopId = #{shopId}
  1076. AND productType = 2
  1077. AND payStatus = 1
  1078. </select>
  1079. <select id="getShopCommercialCode" resultType="java.lang.String">
  1080. SELECT commercialCode
  1081. FROM cm_shop_splitcode
  1082. WHERE shopID = #{shopId}
  1083. limit 1
  1084. </select>
  1085. <select id="getOrderByOrderId" resultType="com.caimei.modules.order.entity.OrderVo">
  1086. SELECT orderID AS orderId,
  1087. shopOrderIds,
  1088. orderSource,
  1089. orderNo,
  1090. organizeID AS organizeId,
  1091. userID AS userId,
  1092. clubID AS clubId,
  1093. buyUserID AS buyUserId,
  1094. orderTime AS orderTime,
  1095. updateDate AS updateDate,
  1096. delFlag,
  1097. userBeans,
  1098. orderType,
  1099. orderSubmitType,
  1100. confirmFlag,
  1101. onlinePayFlag,
  1102. splitFlag,
  1103. payFlag,
  1104. receiptStatus,
  1105. payStatus,
  1106. zeroCostFlag,
  1107. sendOutStatus,
  1108. refundType,
  1109. affirmPaymentFlag,
  1110. productCount,
  1111. presentCount,
  1112. promotionalGiftsCount,
  1113. hasActProduct,
  1114. promotionFullReduction,
  1115. secondHandOrderFlag,
  1116. invoiceFlag,
  1117. freePostFlag AS postageFlag,
  1118. freight AS postage,
  1119. productTotalFee,
  1120. orderTotalFee,
  1121. payTotalFee,
  1122. payableAmount,
  1123. balancePayFee,
  1124. discountFee,
  1125. status,
  1126. paySuccessCounter,
  1127. confirmTime,
  1128. payTime,
  1129. rebateFlag,
  1130. clauseID AS clauseId,
  1131. clauseName
  1132. FROM cm_order
  1133. WHERE orderID = #{orderId}
  1134. </select>
  1135. <select id="findSplitTime" resultType="java.util.Date">
  1136. SELECT splitTime
  1137. FROM cm_split_account
  1138. WHERE splitTime IS NOT NULL
  1139. AND splitTime > DATE_ADD(NOW(), INTERVAL -2 MINUTE)
  1140. LIMIT 1
  1141. </select>
  1142. <select id="findSupport" resultType="java.lang.Integer">
  1143. SELECT s.chargeSupport FROM shop s
  1144. LEFT JOIN cm_shop_order cso ON cso.shopId= s.shopId
  1145. WHERE cso.shopOrderId=25059
  1146. </select>
  1147. <select id="getOrderProductByShopOrderId" resultType="com.caimei.modules.order.entity.OrderProductVo">
  1148. SELECT cop.orderProductID AS orderProductId,
  1149. cop.orderID AS orderId,
  1150. cop.orderNo,
  1151. cop.shopOrderID AS shopOrderId,
  1152. cop.shopOrderNo,
  1153. cop.orderPromotionsId,
  1154. cop.productId,
  1155. cop.shopId,
  1156. cop.name,
  1157. cop.productImage AS image,
  1158. cop.price,
  1159. cop.shopName,
  1160. IF(cop.shopid = 998 AND co.freight > 0, co.freight, cop.costPrice) AS costPrice,
  1161. cop.normalPrice,
  1162. cop.ladderPriceFlag,
  1163. cop.discountPrice,
  1164. cop.discount,
  1165. cop.totalAmount,
  1166. cop.totalFee,
  1167. cop.shouldPayFee,
  1168. cop.productUnit,
  1169. cop.num,
  1170. cop.presentNum,
  1171. cop.discountFee,
  1172. cop.includedTax,
  1173. cop.invoiceType,
  1174. cop.taxRate,
  1175. cop.addedValueTax,
  1176. cop.totalAddedValueTax,
  1177. cop.singleShouldPayTotalTax,
  1178. cop.shouldPayTotalTax,
  1179. cop.shopProductAmount,
  1180. cop.singleShopFee,
  1181. cop.shopFee,
  1182. cop.singleOtherFee,
  1183. cop.otherFee,
  1184. cop.singleCmFee,
  1185. cop.cmFee,
  1186. cop.payStatus,
  1187. cop.buyAgainFlag,
  1188. cop.notOutStore,
  1189. cop.isActProduct AS actProduct,
  1190. cop.productType,
  1191. p.productCategory as productCategory,
  1192. p.splitCode
  1193. FROM cm_order_product cop
  1194. LEFT JOIN product p ON cop.productID = p.productID
  1195. left join cm_order co on co.orderID = cop.orderID
  1196. WHERE cop.shopOrderID = #{shopOrderId}
  1197. AND IF(co.userBeans = 0, 1 = 1, cop.shopid != 998)
  1198. ORDER BY cop.discountPrice DESC
  1199. </select>
  1200. <insert id="insertSplitAccount">
  1201. INSERT INTO cm_split_account (orderId, productId, orderProductId, shopId, couponRecordId, vipRecordId,
  1202. authVipRecordId, type, subUserNo, splitAccount,
  1203. mbOrderId, orderRequestNo, payStatus, productType, splitTime)
  1204. VALUES (#{orderId}, #{productId}, #{orderProductId}, #{shopId}, #{couponRecordId}, #{vipRecordId},
  1205. #{authVipRecordId}, #{type}, #{subUserNo}, #{splitAccount},
  1206. #{mbOrderId}, #{orderRequestNo}, #{payStatus}, #{productType}, NOW());
  1207. </insert>
  1208. </mapper>