ShopOrderMapper.xml 154 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.caimei.modules.order.dao.NewShopOrderDao">
  4. <sql id="shopOrderColumns">
  5. co.rebateFee as rebateFee,
  6. co.userBeans as userBeans,
  7. a.shopOrderID AS shopOrderID,
  8. a.shopStatus AS status,
  9. a.shopPostFlag AS shopPostFlag,
  10. a.orderID AS orderID,
  11. a.organizeID AS organizeID,
  12. a.shopOrderNo AS shopOrderNo,
  13. a.orderNo AS orderNo,
  14. a.userID AS userID,
  15. a.shopID AS shopID,
  16. a.isColdChina AS isColdChina,
  17. a.itemCount AS itemCount,
  18. a.townID AS townID,
  19. a.productAmount AS productAmount,
  20. a.discountAmount AS discountAmount,
  21. a.accountAmount AS accountAmount,
  22. a.totalAmount AS totalAmount,
  23. a.payFlag AS payFlag,
  24. a.payTime AS payTime,
  25. a.finishTime AS finishTime,
  26. a.refundStatus AS refundStatus,
  27. a.needPayAmount AS needPayAmount,
  28. a.splitCode,
  29. ifnull(a.realPay, a.needPayAmount) AS realPay,
  30. a.eachDiscount AS eachDiscount,
  31. IFNULL((SELECT SUM(cror.associateAmount)
  32. FROM cm_receipt_order_relation cror
  33. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  34. WHERE cror.shopOrderId = a.shopOrderId
  35. AND cror.relationType = '2'
  36. AND cdr.receiptType = 1
  37. AND cdr.delFlag = 0
  38. AND cror.delFlag = 0
  39. AND cdr.receiptStatus IN (2, 3)
  40. AND cdr.payWay != 3)
  41. , 0) AS receiptAmount,
  42. (ifnull(a.realPay,a.needPayAmount) - ifnull(a.receiptAmount,0)) as restAmount,
  43. a.receiptStatus as shopReceiptStatus,
  44. a.receiptStatus as ReceiptStatus,
  45. a.canRefundAmount AS canRefundAmount,
  46. a.refundAmount AS refundAmount,
  47. a.clubID AS clubID,
  48. a.spID AS spID,
  49. a.mainSpID AS mainSpID,
  50. a.orderBeanAmount AS orderBeanAmount,
  51. a.useBeanAmount AS useBeanAmount,
  52. a.useBeanFlag AS useBeanFlag,
  53. a.canRefundFlag AS canRefundFlag,
  54. a.useBalanceFlag AS useBalanceFlag,
  55. a.canRefundBeans AS canRefundBeans,
  56. a.freePostageFee AS freePostageFee,
  57. a.freePostageTicketID AS freePostageTicketID,
  58. a.brokerage AS brokerage,
  59. a.delFlag AS delFlag,
  60. a.refundsAmount AS refundsAmount,
  61. a.orderStatusFlag AS orderStatusFlag,
  62. a.buyStatus AS buyStatus,
  63. a.orderSubmitType AS orderSubmitType,
  64. a.orderType AS orderType,
  65. a.orderTime AS orderTime,
  66. a.deliveryTimeMills AS deliveryTimeMills,
  67. a.presentNum AS presentNum,
  68. a.preferential AS preferential,
  69. a.outStoreNum AS outStoreNum,
  70. IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
  71. a.splitFlag AS splitFlag,
  72. a.autoReceiveTimeMills AS autoReceiveTimeMills,
  73. a.autoOverTimeMills AS autoOverTimeMills,
  74. a.receiveGoodsTime AS receiveGoodsTime,
  75. a.totalAddedValueTax AS totalAddedValueTax,
  76. a.note AS note,
  77. a.payStatus AS payStatus,
  78. a.sendOutStatus AS sendOutStatus,
  79. a.shopProductAmount AS shopProductAmount,
  80. ifnull(a.shopPostFee, 0) AS shopPostFee,
  81. ifnull(a.shopTaxFee,0) AS shopTaxFee,
  82. a.shouldPayShopAmount AS shouldPayShopAmount,
  83. a.payedShopAmount AS payedShopAmount,
  84. ifnull(a.shopOtherFee, 0) AS shopOtherFee,
  85. a.paying AS paying,
  86. a.costType AS costType,
  87. a.settleStatus AS settleStatus,
  88. a.modifyShouldPayNote AS modifyShouldPayNote,
  89. a.orderPromotionsId AS orderPromotionsId,
  90. a.differenceType AS differenceType,
  91. a.differencePrice AS differencePrice,
  92. a.proportional AS proportional,
  93. ifnull(a.promotionFullReduction, 0) As promotionFullReduction,
  94. ifnull(a.couponAmount, 0) As couponAmount,
  95. a.zeroCostFlag AS zeroCostFlag
  96. </sql>
  97. <select id="get" resultType="NewShopOrder" useCache="false" flushCache="true">
  98. select
  99. <include refid="shopOrderColumns"/>
  100. from cm_shop_order a
  101. left join cm_order co on co.orderID = a.orderID
  102. where a.shopOrderID = #{shopOrderID}
  103. </select>
  104. <delete id="deleteByOrderID">
  105. DELETE
  106. FROM cm_shop_order
  107. WHERE orderID = #{orderID}
  108. </delete>
  109. <insert id="insert" parameterType="NewShopOrder" keyProperty="shopOrderID" useGeneratedKeys="true">
  110. INSERT INTO cm_shop_order(orderID,
  111. shopOrderNo,
  112. orderNo,
  113. userID,
  114. shopID,
  115. itemCount,
  116. townID,
  117. productAmount,
  118. discountAmount,
  119. accountAmount,
  120. totalAmount,
  121. payFlag,
  122. payTime,
  123. finishTime,
  124. refundStatus,
  125. needPayAmount,
  126. canRefundAmount,
  127. refundAmount,
  128. clubID,
  129. spID,
  130. mainSpID,
  131. orderBeanAmount,
  132. useBeanAmount,
  133. useBeanFlag,
  134. canRefundFlag,
  135. useBalanceFlag,
  136. canRefundBeans,
  137. freePostageFee,
  138. freePostageTicketID,
  139. brokerage,
  140. delFlag,
  141. refundsAmount,
  142. orderStatusFlag,
  143. buyStatus,
  144. orderSubmitType,
  145. orderType,
  146. orderTime,
  147. deliveryTimeMills,
  148. presentNum,
  149. preferential,
  150. splitFlag,
  151. autoReceiveTimeMills,
  152. autoOverTimeMills,
  153. totalAddedValueTax,
  154. receiveGoodsTime,
  155. sendOutStatus,
  156. payStatus,
  157. costType,
  158. orderPromotionsId,
  159. promotionFullReduction,
  160. zeroCostFlag,
  161. svipShopReduction,
  162. realPay,
  163. eachDiscount,
  164. receiptStatus,
  165. receiptAmount,
  166. splitCode)
  167. VALUES (#{orderID},
  168. #{shopOrderNo},
  169. #{orderNo},
  170. #{userID},
  171. #{shopID},
  172. #{itemCount},
  173. #{townID},
  174. #{productAmount},
  175. #{discountAmount},
  176. #{accountAmount},
  177. #{totalAmount},
  178. #{payFlag},
  179. #{payTime},
  180. #{finishTime},
  181. #{refundStatus},
  182. #{needPayAmount},
  183. #{canRefundAmount},
  184. #{refundAmount},
  185. #{clubID},
  186. #{spID},
  187. #{mainSpID},
  188. #{orderBeanAmount},
  189. #{useBeanAmount},
  190. #{useBeanFlag},
  191. #{canRefundFlag},
  192. #{useBalanceFlag},
  193. #{canRefundBeans},
  194. #{freePostageFee},
  195. #{freePostageTicketID},
  196. #{brokerage},
  197. #{delFlag},
  198. #{refundsAmount},
  199. #{orderStatusFlag},
  200. #{buyStatus},
  201. #{orderSubmitType},
  202. #{orderType},
  203. #{orderTime},
  204. #{deliveryTimeMills},
  205. #{presentNum},
  206. #{preferential},
  207. #{splitFlag},
  208. #{autoReceiveTimeMills},
  209. #{autoOverTimeMills},
  210. #{totalAddedValueTax},
  211. #{receiveGoodsTime},
  212. #{sendOutStatus},
  213. #{payStatus},
  214. #{costType},
  215. #{orderPromotionsId},
  216. #{promotionFullReduction},
  217. #{zeroCostFlag},
  218. #{svipShopReduction},
  219. #{realPay},
  220. #{eachDiscount},
  221. #{shopReceiptStatus},
  222. #{receiptAmount},
  223. #{splitCode})
  224. </insert>
  225. <select id="findByShopOrderID" resultType="newShopOrder">
  226. select
  227. <include refid="shopOrderColumns"/>
  228. ,bou.shouHuoRen as receiver,
  229. bou.mobile,
  230. bou.name as buyer,
  231. ifnull(co.orderSeen,1) as orderSeen,
  232. co.orderSource,
  233. co.rebateFlag as rebateOrder,
  234. co.clauseID,
  235. co.clauseName,
  236. s.name as shopName
  237. from cm_shop_order a
  238. left join cm_order co on co.orderID = a.orderID
  239. left join bp_order_userinfo bou on bou.orderId = a.orderID
  240. left join shop s on a.shopId = s.shopId
  241. where a.shopOrderID = #{shopOrderID}
  242. </select>
  243. <select id="findByPayShopID" resultType="java.lang.Double">
  244. SELECT SUM(cpsr.payAmount)
  245. FROM cm_pay_shop cps
  246. LEFT JOIN cm_pay_shop_record cpsr ON cpsr.payShopID = cps.id
  247. WHERE cpsr.delFlag = 0
  248. AND cps.delFlag = 0
  249. AND cpsr.shopOrderId = #{shopOrderID}
  250. </select>
  251. <select id="findList" resultType="newShopOrder">
  252. SELECT
  253. <include refid="shopOrderColumns"/>
  254. FROM cm_shop_order a
  255. left join cm_order co on co.orderID = a.orderID
  256. <where>
  257. <if test="shopOrderNo != null and itemCount != ''">
  258. AND a.shopOrderNo = #{shopOrderNo}
  259. </if>
  260. <if test="orderNo != null and itemCount != ''">
  261. AND a.orderNo = #{orderNo}
  262. </if>
  263. <if test="orderID != null and itemCount != ''">
  264. AND a.orderID = #{orderID}
  265. </if>
  266. <if test="userID != null and itemCount != ''">
  267. AND a.userID = #{userID}
  268. </if>
  269. <if test="shopID != null and itemCount != ''">
  270. AND a.shopID = #{shopID}
  271. </if>
  272. <if test="payFlag != null and itemCount != ''">
  273. AND a.payFlag = #{payFlag}
  274. </if>
  275. </where>
  276. <choose>
  277. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  278. ORDER BY ${page.orderBy}
  279. </when>
  280. <otherwise>
  281. </otherwise>
  282. </choose>
  283. </select>
  284. <select id="findListByOrderID" resultType="newShopOrder">
  285. SELECT<include refid="shopOrderColumns"/>,
  286. b.name as shopName,
  287. oa.id as orderArchiveId,
  288. co.receiptStatus,
  289. (SELECT SUM(num) FROM cm_order_product WHERE shoporderid=29760 AND productType = 2) as presentNum
  290. FROM cm_shop_order a
  291. left join shop b on a.shopID = b.shopID
  292. left join cm_order_archive oa on a.shopOrderID = oa.shopOrderId
  293. left join cm_order co on co.orderID = a.orderID
  294. WHERE a.orderID = #{orderID} ORDER BY a.shopOrderNo DESC
  295. </select>
  296. <select id="getFreightAmount" resultType="java.lang.Double">
  297. SELECT ifnull(SUM(cfr.freightAmount), 0)
  298. FROM cm_freight_rule cfr
  299. LEFT JOIN cm_freight_template cft ON cft.id = cfr.freightId
  300. LEFT JOIN product p ON p.freightTemplateId = cft.id
  301. WHERE productId = #{productId}
  302. and cft.delFlag = 0
  303. </select>
  304. <select id="getShopOrderId" resultType="com.caimei.modules.product.entity.Shop">
  305. select shopId, AccountOwnership, bankAccount
  306. from shop
  307. where shopId = #{shopId}
  308. </select>
  309. <select id="findCommercialCode" resultType="String">
  310. select commercialCode
  311. FROM cm_shop_order a
  312. left join cm_shop_splitcode css on a.shopID = css.shopId
  313. WHERE a.orderID = #{orderID}
  314. </select>
  315. <update id="update" parameterType="newShopOrder">
  316. update cm_shop_order
  317. <set>
  318. <if test="shopOrderNo != null and shopOrderNo != ''">
  319. shopOrderNo = #{shopOrderNo},
  320. </if>
  321. <if test="status != null and status != ''">
  322. shopStatus = #{status},
  323. </if>
  324. <if test="confirmTime != null and confirmTime != ''">
  325. confirmTime = #{confirmTime},
  326. </if>
  327. <if test="shopOrderNo != null and shopOrderNo != ''">
  328. orderID = #{orderID},
  329. </if>
  330. <if test="orderNo != null and orderNo != ''">
  331. orderNo = #{orderNo},
  332. </if>
  333. <if test="userID != null and userID != ''">
  334. userID = #{userID},
  335. </if>
  336. <if test="shopID != null and shopID != ''">
  337. shopID = #{shopID},
  338. </if>
  339. <if test="itemCount != null and itemCount != ''">
  340. itemCount = #{itemCount},
  341. </if>
  342. <if test="townID != null and itemCount != ''">
  343. townID = #{townID,jdbcType=INTEGER},
  344. </if>
  345. <if test="productAmount != null and productAmount != ''">
  346. productAmount = #{productAmount},
  347. </if>
  348. <if test="discountAmount != null and discountAmount != ''">
  349. discountAmount = #{discountAmount},
  350. </if>
  351. <if test="accountAmount != null and accountAmount != ''">
  352. accountAmount = #{accountAmount},
  353. </if>
  354. <if test="totalAmount != null and totalAmount != ''">
  355. totalAmount = #{totalAmount},
  356. </if>
  357. <if test="payFlag != null and payFlag != ''">
  358. payFlag = #{payFlag},
  359. </if>
  360. <if test="payTime != null and payTime != ''">
  361. payTime = #{payTime},
  362. </if>
  363. <if test="finishTime != null and finishTime != ''">
  364. finishTime = #{finishTime},
  365. </if>
  366. <if test="refundStatus != null and refundStatus != ''">
  367. refundStatus = #{refundStatus},
  368. </if>
  369. <if test="needPayAmount != null and needPayAmount != ''">
  370. needPayAmount = #{needPayAmount},
  371. </if>
  372. <if test="canRefundAmount != null and canRefundAmount != ''">
  373. canRefundAmount = #{canRefundAmount},
  374. </if>
  375. <if test="refundAmount != null and refundAmount != ''">
  376. refundAmount = #{refundAmount},
  377. </if>
  378. <if test="clubID != null and clubID != ''">
  379. clubID = #{clubID},
  380. </if>
  381. <if test="spID != null and itemCount != ''">
  382. spID = #{spID,jdbcType=INTEGER},
  383. </if>
  384. <if test="mainSpID != null and mainSpID != ''">
  385. mainSpID = #{mainSpID},
  386. </if>
  387. <if test="orderBeanAmount != null and orderBeanAmount != ''">
  388. orderBeanAmount = #{orderBeanAmount},
  389. </if>
  390. <if test="useBeanAmount != null and useBeanAmount != ''">
  391. useBeanAmount = #{useBeanAmount},
  392. </if>
  393. <if test="useBeanFlag != null and useBeanFlag != ''">
  394. useBeanFlag = #{useBeanFlag},
  395. </if>
  396. <if test="canRefundFlag != null and canRefundFlag != ''">
  397. canRefundFlag = #{canRefundFlag},
  398. </if>
  399. <if test="useBalanceFlag != null and useBalanceFlag != ''">
  400. useBalanceFlag = #{useBalanceFlag},
  401. </if>
  402. <if test="canRefundBeans != null and canRefundBeans != ''">
  403. canRefundBeans = #{canRefundBeans},
  404. </if>
  405. <if test="freePostageFee != null and freePostageFee != ''">
  406. freePostageFee = #{freePostageFee},
  407. </if>
  408. <if test="freePostageTicketID != null and freePostageTicketID != ''">
  409. freePostageTicketID = #{freePostageTicketID},
  410. </if>
  411. <if test="brokerage != null and brokerage != ''">
  412. brokerage = #{brokerage},
  413. </if>
  414. <if test="delFlag != null and delFlag != ''">
  415. delFlag = #{delFlag},
  416. </if>
  417. <if test="refundsAmount != null and refundsAmount != ''">
  418. refundsAmount = #{refundsAmount},
  419. </if>
  420. <if test="orderStatusFlag != null and orderStatusFlag != ''">
  421. orderStatusFlag = #{orderStatusFlag},
  422. </if>
  423. <if test="buyStatus != null and buyStatus != ''">
  424. buyStatus = #{buyStatus},
  425. </if>
  426. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">
  427. deliveryTimeMills = #{deliveryTimeMills},
  428. </if>
  429. <if test="orderSubmitType != null and orderSubmitType != ''">
  430. orderSubmitType = #{orderSubmitType},
  431. </if>
  432. <if test="orderType != null and orderType != ''">
  433. orderType = #{orderType},
  434. </if>
  435. <if test="orderTime != null and orderTime != ''">
  436. orderTime = #{orderTime},
  437. </if>
  438. <if test="presentNum != null and presentNum != ''">
  439. presentNum = #{presentNum},
  440. </if>
  441. <if test="preferential != null and preferential != ''">
  442. preferential = #{preferential},
  443. </if>
  444. <if test="outStoreNum != null and outStoreNum != ''">
  445. outStoreNum = #{outStoreNum},
  446. </if>
  447. <if test="outStoreTimes != null and outStoreTimes != ''">
  448. outStoreTimes = #{outStoreTimes},
  449. </if>
  450. <if test="splitFlag != null and splitFlag != ''">
  451. splitFlag = #{splitFlag},
  452. </if>
  453. <if test="autoReceiveTimeMills != null and autoReceiveTimeMills != ''">
  454. autoReceiveTimeMills = #{autoReceiveTimeMills},
  455. </if>
  456. <if test="autoOverTimeMills != null and autoOverTimeMills != ''">
  457. autoOverTimeMills = #{autoOverTimeMills},
  458. </if>
  459. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">
  460. receiveGoodsTime = #{receiveGoodsTime},
  461. </if>
  462. <if test="totalAddedValueTax != null and totalAddedValueTax != ''">
  463. totalAddedValueTax = #{totalAddedValueTax},
  464. </if>
  465. <if test="note != null and note != ''">
  466. note = #{note},
  467. </if>
  468. <if test="sendOutStatus != null and sendOutStatus != ''">
  469. sendOutStatus = #{sendOutStatus},
  470. </if>
  471. <if test="paying != null and paying != ''">
  472. paying = #{paying},
  473. </if>
  474. <if test="shopProductAmount != null">
  475. shopProductAmount = #{shopProductAmount},
  476. </if>
  477. <if test="shopPostFee != null">
  478. shopPostFee = #{shopPostFee},
  479. </if>
  480. <if test="shopTaxFee != null">
  481. shopTaxFee = #{shopTaxFee},
  482. </if>
  483. <if test="shouldPayShopAmount != null">
  484. shouldPayShopAmount = #{shouldPayShopAmount},
  485. </if>
  486. <if test="payedShopAmount != null">
  487. payedShopAmount = #{payedShopAmount},
  488. </if>
  489. <if test="shopOtherFee != null">
  490. shopOtherFee = #{shopOtherFee},
  491. </if>
  492. <if test="payStatus != null">
  493. payStatus = #{payStatus},
  494. </if>
  495. <if test="costType != null">
  496. costType = #{costType},
  497. </if>
  498. <if test="proportional != null">
  499. proportional = #{proportional},
  500. </if>
  501. <if test="modifyShouldPayNote != null">
  502. modifyShouldPayNote = #{modifyShouldPayNote},
  503. </if>
  504. <if test="modifyShouldPayUserID != null">
  505. modifyShouldPayUserID = #{modifyShouldPayUserID},
  506. </if>
  507. <if test="modifyShouldPayDate != null">
  508. modifyShouldPayDate = #{modifyShouldPayDate},
  509. </if>
  510. <if test="orderPromotionsId != null">
  511. orderPromotionsId = #{orderPromotionsId},
  512. </if>
  513. <if test="promotionFullReduction != null">
  514. promotionFullReduction = #{promotionFullReduction},
  515. </if>
  516. <if test="zeroCostFlag != null">
  517. zeroCostFlag = #{zeroCostFlag},
  518. </if>
  519. <if test="svipShopReduction != null">
  520. svipShopReduction = #{svipShopReduction},
  521. </if>
  522. <if test="realPay != null">
  523. realPay = #{realPay},
  524. </if>
  525. <if test="eachDiscount != null">
  526. eachDiscount = #{eachDiscount},
  527. </if>
  528. <if test="receiptStatus != null">
  529. receiptStatus = #{receiptStatus},
  530. </if>
  531. <if test="receiptAmount != null">
  532. receiptAmount = #{receiptAmount},
  533. </if>
  534. <if test="splitCode != null">
  535. splitCode = #{splitCode},
  536. </if>
  537. <if test="supplierFreight != null">
  538. supplierFreight = #{supplierFreight},
  539. </if>
  540. <if test="rebateOrder != null">
  541. rebateOrder = #{rebateOrder},
  542. </if>
  543. </set>
  544. <where>
  545. <if test="shopOrderID != null and shopOrderID != ''">
  546. AND shopOrderID = #{shopOrderID}
  547. </if>
  548. <if test="orderID != null and orderID != ''">
  549. AND orderID = #{orderID}
  550. </if>
  551. </where>
  552. </update>
  553. <delete id="delete">
  554. DELETE
  555. FROM cm_shop_order
  556. WHERE shopOrderID = #{shopOrderID}
  557. </delete>
  558. <select id="findIDsByOrderID" resultType="int">
  559. select shopOrderID
  560. from cm_shop_order
  561. where orderID = #{orderID}
  562. </select>
  563. <update id="updateNote">
  564. UPDATE cm_shop_order
  565. SET note = #{note}
  566. WHERE shopOrderID = #{shopOrderID}
  567. </update>
  568. <select id="findShopOrderNum" resultType="int">
  569. select count(1)
  570. from cm_shop_order
  571. where orderID = #{orderID}
  572. </select>
  573. <update id="updateByShopOrderID" parameterType="newShopOrder">
  574. update cm_shop_order
  575. <set>
  576. <if test="status != null and status != ''">
  577. shopStatus = #{status},
  578. </if>
  579. <if test="shopOrderNo != null and shopOrderNo != ''">
  580. shopOrderNo = #{shopOrderNo},
  581. </if>
  582. <if test="orderID != null and orderID != ''">
  583. orderID = #{orderID},
  584. </if>
  585. <if test="orderNo != null and orderNo != ''">
  586. orderNo = #{orderNo},
  587. </if>
  588. <if test="userID != null and userID != ''">
  589. userID = #{userID},
  590. </if>
  591. <if test="shopID != null and shopID != ''">
  592. shopID = #{shopID},
  593. </if>
  594. <if test="itemCount != null and itemCount != ''">
  595. itemCount = #{itemCount},
  596. </if>
  597. <if test="townID != null and itemCount != ''">
  598. townID = #{townID,jdbcType=INTEGER},
  599. </if>
  600. <if test="productAmount != null and productAmount != ''">
  601. productAmount = #{productAmount},
  602. </if>
  603. <if test="discountAmount != null and discountAmount != ''">
  604. discountAmount = #{discountAmount},
  605. </if>
  606. <if test="accountAmount != null and accountAmount != ''">
  607. accountAmount = #{accountAmount},
  608. </if>
  609. <if test="totalAmount != null and totalAmount != ''">
  610. totalAmount = #{totalAmount},
  611. </if>
  612. <if test="payFlag != null and payFlag != ''">
  613. payFlag = #{payFlag},
  614. </if>
  615. <if test="payTime != null and payTime != ''">
  616. payTime = #{payTime},
  617. </if>
  618. <if test="finishTime != null and finishTime != ''">
  619. finishTime = #{finishTime},
  620. </if>
  621. <if test="refundStatus != null and refundStatus != ''">
  622. refundStatus = #{refundStatus},
  623. </if>
  624. <if test="needPayAmount != null and needPayAmount != ''">
  625. needPayAmount = #{needPayAmount},
  626. </if>
  627. <if test="canRefundAmount != null and canRefundAmount != ''">
  628. canRefundAmount = #{canRefundAmount},
  629. </if>
  630. <if test="refundAmount != null and refundAmount != ''">
  631. refundAmount = #{refundAmount},
  632. </if>
  633. <if test="clubID != null and clubID != ''">
  634. clubID = #{clubID},
  635. </if>
  636. <if test="spID != null and itemCount != ''">
  637. spID = #{spID,jdbcType=INTEGER},
  638. </if>
  639. <if test="mainSpID != null and mainSpID != ''">
  640. mainSpID = #{mainSpID},
  641. </if>
  642. <if test="orderBeanAmount != null and orderBeanAmount != ''">
  643. orderBeanAmount = #{orderBeanAmount},
  644. </if>
  645. <if test="useBeanAmount != null and useBeanAmount != ''">
  646. useBeanAmount = #{useBeanAmount},
  647. </if>
  648. <if test="useBeanFlag != null and useBeanFlag != ''">
  649. useBeanFlag = #{useBeanFlag},
  650. </if>
  651. <if test="canRefundFlag != null and canRefundFlag != ''">
  652. canRefundFlag = #{canRefundFlag},
  653. </if>
  654. <if test="useBalanceFlag != null and useBalanceFlag != ''">
  655. useBalanceFlag = #{useBalanceFlag},
  656. </if>
  657. <if test="canRefundBeans != null and canRefundBeans != ''">
  658. canRefundBeans = #{canRefundBeans},
  659. </if>
  660. <if test="freePostageFee != null and freePostageFee != ''">
  661. freePostageFee = #{freePostageFee},
  662. </if>
  663. <if test="freePostageTicketID != null and freePostageTicketID != ''">
  664. freePostageTicketID = #{freePostageTicketID},
  665. </if>
  666. <if test="brokerage != null and brokerage != ''">
  667. brokerage = #{brokerage},
  668. </if>
  669. <if test="delFlag != null and delFlag != ''">
  670. delFlag = #{delFlag},
  671. </if>
  672. <if test="refundsAmount != null and refundsAmount != ''">
  673. refundsAmount = #{refundsAmount},
  674. </if>
  675. <if test="orderStatusFlag != null and orderStatusFlag != ''">
  676. orderStatusFlag = #{orderStatusFlag},
  677. </if>
  678. <if test="buyStatus != null and buyStatus != ''">
  679. buyStatus = #{buyStatus},
  680. </if>
  681. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">
  682. deliveryTimeMills = #{deliveryTimeMills},
  683. </if>
  684. <if test="orderSubmitType != null and orderSubmitType != ''">
  685. orderSubmitType = #{orderSubmitType},
  686. </if>
  687. <if test="orderType != null and orderType != ''">
  688. orderType = #{orderType},
  689. </if>
  690. <if test="orderTime != null and orderTime != ''">
  691. orderTime = #{orderTime},
  692. </if>
  693. <if test="presentNum != null and presentNum != ''">
  694. presentNum = #{presentNum},
  695. </if>
  696. <if test="preferential != null and preferential != ''">
  697. preferential = #{preferential},
  698. </if>
  699. <if test="outStoreNum != null and outStoreNum != ''">
  700. outStoreNum = #{outStoreNum},
  701. </if>
  702. <if test="outStoreTimes != null and outStoreTimes != ''">
  703. outStoreTimes = #{outStoreTimes},
  704. </if>
  705. <if test="splitFlag != null and splitFlag != ''">
  706. splitFlag = #{splitFlag},
  707. </if>
  708. <if test="autoReceiveTimeMills != null and autoReceiveTimeMills != ''">
  709. autoReceiveTimeMills = #{autoReceiveTimeMills},
  710. </if>
  711. <if test="autoOverTimeMills != null and autoOverTimeMills != ''">
  712. autoOverTimeMills = #{autoOverTimeMills},
  713. </if>
  714. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">
  715. receiveGoodsTime = #{receiveGoodsTime},
  716. </if>
  717. <if test="totalAddedValueTax != null and totalAddedValueTax != ''">
  718. totalAddedValueTax = #{totalAddedValueTax},
  719. </if>
  720. <if test="note != null and note != ''">
  721. note = #{note},
  722. </if>
  723. <if test="sendOutStatus != null and sendOutStatus != ''">
  724. sendOutStatus = #{sendOutStatus}
  725. </if>
  726. </set>
  727. where shopOrderID = #{shopOrderID}
  728. </update>
  729. <select id="findPayOrderList" resultType="newShopOrder">
  730. select<include refid="shopOrderColumns"/>,
  731. co.payTotalFee AS payTotalFee,
  732. a.supplierFreight as supplierFreight,
  733. a.rebateOrder as rebateOrder,
  734. bou.name AS buyer,
  735. s.name AS shopName,
  736. c.name AS clubName,
  737. a.onlinePayWays,
  738. ifnull(a.cmAccountType,0) as cmAccountType,
  739. cdr.payWay AS payWay
  740. from cm_shop_order a
  741. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  742. left join bp_order_userinfo bou on bou.orderId = a.orderID
  743. left join cm_order co on co.orderID = a.orderID
  744. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
  745. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  746. left join shop s on s.shopID = a.shopID
  747. LEFT JOIN club c ON c.userID = a.userID
  748. <where>
  749. (s.shopId = 1161 OR s.AccountOwnership = 0 OR a.splitCode = 'E1807059160' or a.ordertype = 2)
  750. and a.shopStatus not in (4, 5)
  751. <if test="startTime != null and startTime != ''">
  752. AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
  753. </if>
  754. <if test="endTime != null and endTime != ''">
  755. AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
  756. </if>
  757. <if test="orderID != null and orderID != ''">
  758. AND a.orderID = #{orderID}
  759. </if>
  760. <if test="organizeID != null and organizeID != 9999">
  761. AND co.organizeID = #{organizeID}
  762. </if>
  763. <if test="organizeID == 9999 ">
  764. AND co.orderType = 2
  765. </if>
  766. <if test="orderNo != null and orderNo != ''">
  767. AND a.orderNo like concat('%', #{orderNo} ,'%')
  768. </if>
  769. <if test="ps != null and ps.length>0 ">
  770. AND a.payStatus in
  771. <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
  772. #{item}
  773. </foreach>
  774. </if>
  775. <if test="shopName != null and shopName != ''">
  776. AND s.name like concat('%', #{shopName} ,'%')
  777. </if>
  778. <if test="buyer != null and buyer != ''">
  779. AND bou.name like concat('%', #{buyer} ,'%')
  780. </if>
  781. <if test="clubName != null and clubName != ''">
  782. AND c.name like concat('%', #{clubName} ,'%')
  783. </if>
  784. <if test="shopOrderID != null and shopOrderID != ''">
  785. AND a.shopOrderID = #{shopOrderID}
  786. </if>
  787. <if test="shopOrderNo != null and shopOrderNo != ''">
  788. AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
  789. </if>
  790. <if test="operatingMode != null and operatingMode == '1'.toString()">
  791. and a.payStatus != 3 and co.status NOT IN (6,7)
  792. </if>
  793. <if test="operatingMode != null and operatingMode == '2'.toString()">
  794. and a.payStatus != 1 and co.status != 6
  795. </if>
  796. <if test="operatingMode != null and operatingMode == '3'.toString()">
  797. and a.payStatus = 3 and co.status NOT IN (6,7)
  798. </if>
  799. and a.shopStatus != 0
  800. and co.delFlag = 0
  801. -- and not (co.secondHandOrderFlag=1 AND co.rebateFlag=1)
  802. and a.delFlag = 0
  803. and (a.organizeID!=4 or a.organizeID is null)
  804. and a.shopID != 998
  805. and co.orderID not in (
  806. SELECT orderID FROM cm_order_product WHERE productID IN
  807. (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
  808. )
  809. </where>
  810. group by a.shopOrderID
  811. ORDER BY a.shopOrderID DESC
  812. </select>
  813. <select id="payThirdParties" resultType="newShopOrder">
  814. select<include refid="shopOrderColumns"/>,
  815. co.payTotalFee AS payTotalFee,
  816. bou.name AS buyer,
  817. s.name AS shopName,
  818. c.name AS clubName,
  819. cdr.payWay AS payWay
  820. from cm_shop_order a
  821. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  822. left join bp_order_userinfo bou on bou.orderId = a.orderID
  823. left join cm_order co on co.orderID = a.orderID
  824. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
  825. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  826. left join shop s on s.shopID = a.shopID
  827. LEFT JOIN club c ON c.userID = a.userID
  828. <where>
  829. s.name NOT LIKE '%综合供应商%'
  830. AND s.AccountOwnership = 1
  831. AND cdr.payWay = 2
  832. AND a.receiptStatus != 1
  833. <if test="startTime != null and startTime != ''">
  834. AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
  835. </if>
  836. <if test="endTime != null and endTime != ''">
  837. AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
  838. </if>
  839. <if test="orderID != null and orderID != ''">
  840. AND a.orderID = #{orderID}
  841. </if>
  842. <if test="organizeID != null and organizeID != 9999">
  843. AND co.organizeID = #{organizeID}
  844. </if>
  845. <if test="organizeID == 9999 ">
  846. AND co.orderType = 2
  847. </if>
  848. <if test="orderNo != null and orderNo != ''">
  849. AND a.orderNo like concat('%', #{orderNo} ,'%')
  850. </if>
  851. <if test="ps != null and ps.length>0 ">
  852. AND a.payStatus in
  853. <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
  854. #{item}
  855. </foreach>
  856. </if>
  857. <if test="shopName != null and shopName != ''">
  858. AND s.name like concat('%', #{shopName} ,'%')
  859. </if>
  860. <if test="buyer != null and buyer != ''">
  861. AND bou.name like concat('%', #{buyer} ,'%')
  862. </if>
  863. <if test="clubName != null and clubName != ''">
  864. AND c.name like concat('%', #{clubName} ,'%')
  865. </if>
  866. <if test="shopOrderID != null and shopOrderID != ''">
  867. AND a.shopOrderID = #{shopOrderID}
  868. </if>
  869. <if test="shopOrderNo != null and shopOrderNo != ''">
  870. AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
  871. </if>
  872. -- and (co.confirmFlag = '1' or co.confirmFlag = '2')
  873. and a.shopStatus = '1'
  874. <if test="operatingMode != null and operatingMode == '1'.toString()">
  875. and a.payStatus != 3 and co.status NOT IN (6,7)
  876. </if>
  877. <if test="operatingMode != null and operatingMode == '2'.toString()">
  878. and a.payStatus != 1 and co.status != 6
  879. </if>
  880. <if test="operatingMode != null and operatingMode == '3'.toString()">
  881. and a.payStatus = 3 and co.status NOT IN (6,7)
  882. </if>
  883. and co.delFlag = 0
  884. -- and not (co.secondHandOrderFlag=1 AND co.rebateFlag=1)
  885. and a.delFlag = 0
  886. and (a.organizeID!=4 or a.organizeID is null)
  887. and a.shopID != 998
  888. and co.orderID not in (
  889. SELECT orderID FROM cm_order_product WHERE productID IN
  890. (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
  891. )
  892. </where>
  893. group by a.shopOrderID
  894. ORDER BY a.shopOrderID DESC
  895. </select>
  896. <select id="findShopOrderList" resultType="newShopOrder">
  897. select<include refid="shopOrderColumns"/>,
  898. co.payTotalFee AS payTotalFee,
  899. bou.name AS buyer,
  900. s.name AS shopName,
  901. c.name AS clubName,
  902. cdr.payWay AS payWay,
  903. a.onlinePayWays,
  904. ifnull(cmAccountType,0) as cmAccountType,
  905. ifnull(cmShopOtherFee,0) as cmShopOtherFee,
  906. (select sum((num+presentNum)*cmCostPrice) from cm_order_product where shopOrderId = a.shopOrderId) as
  907. allServeAmount
  908. from cm_shop_order a
  909. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  910. left join bp_order_userinfo bou on bou.orderId = a.orderID
  911. left join cm_order co on co.orderID = a.orderID
  912. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
  913. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  914. left join shop s on s.shopID = a.shopID
  915. LEFT JOIN club c ON c.userID = a.userID
  916. <where>
  917. (s.shopId = 1161 OR s.AccountOwnership = 0 OR a.splitCode = 'E1807059160' or a.ordertype = 2)
  918. <if test="startTime != null and startTime != ''">
  919. AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
  920. </if>
  921. <if test="endTime != null and endTime != ''">
  922. AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
  923. </if>
  924. <if test="orderID != null and orderID != ''">
  925. AND a.orderID = #{orderID}
  926. </if>
  927. <if test="organizeID != null and organizeID != 9999">
  928. AND co.organizeID = #{organizeID}
  929. </if>
  930. <if test="organizeID == 9999 ">
  931. AND co.orderType = 2
  932. </if>
  933. <if test="orderNo != null and orderNo != ''">
  934. AND a.orderNo like concat('%', #{orderNo} ,'%')
  935. </if>
  936. <if test="ps != null and ps.length>0 ">
  937. AND a.payStatus in
  938. <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
  939. #{item}
  940. </foreach>
  941. </if>
  942. <if test="receiptStatus != null and receiptStatus!= ''">
  943. AND a.receiptStatus = #{receiptStatus}
  944. </if>
  945. <if test="refundStatus !=null and refundStatus != ''">
  946. AND a.refundStatus = #{refundStatus}
  947. </if>
  948. <if test="settleStatus != null and settleStatus!= ''">
  949. AND a.settleStatus = #{settleStatus}
  950. </if>
  951. <if test="shopName != null and shopName != ''">
  952. AND s.name like concat('%', #{shopName} ,'%')
  953. </if>
  954. <if test="buyer != null and buyer != ''">
  955. AND bou.name like concat('%', #{buyer} ,'%')
  956. </if>
  957. <if test="clubName != null and clubName != ''">
  958. AND c.name like concat('%', #{clubName} ,'%')
  959. </if>
  960. <if test="shopOrderID != null and shopOrderID != ''">
  961. AND a.shopOrderID = #{shopOrderID}
  962. </if>
  963. <if test="shopOrderNo != null and shopOrderNo != ''">
  964. AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
  965. </if>
  966. and co.delFlag = 0
  967. -- and not (co.secondHandOrderFlag=1 AND co.rebateFlag=1)
  968. and a.delFlag = 0
  969. and (a.organizeID!=4 or a.organizeID is null)
  970. and a.shopID != 998
  971. and co.orderID not in (
  972. SELECT orderID FROM cm_order_product WHERE productID IN
  973. (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
  974. )
  975. </where>
  976. group by a.shopOrderID
  977. ORDER BY a.shopOrderID DESC
  978. </select>
  979. <select id="payAmountByShopOrderId" resultType="java.lang.Double">
  980. SELECT IFNULL(SUM(cpsr.payAmount), 0)
  981. FROM cm_pay_shop cps
  982. LEFT JOIN cm_pay_shop_record cpsr ON cps.id = cpsr.payShopID
  983. WHERE cps.delFlag = 0
  984. AND cpsr.delFlag = 0
  985. AND cpsr.shopOrderID = #{shopOrderId}
  986. </select>
  987. <select id="settleAmountByShopOrderId" resultType="java.lang.Double">
  988. SELECT IFNULL(SUM(settleAmount), 0)
  989. FROM cm_settle_record
  990. WHERE shopOrderId = #{shopOrderId}
  991. </select>
  992. <select id="payShopAmountShopOrderId" resultType="java.lang.Double">
  993. SELECT IFNULL(SUM(cpsr.payCmAmount), 0)
  994. FROM cm_pay_shop cps
  995. LEFT JOIN cm_pay_shop_record cpsr ON cps.id = cpsr.payShopID
  996. WHERE cpsr.delFlag = 0
  997. AND cpsr.shopOrderID = 29478
  998. </select>
  999. <select id="returnedPurchaseFeeByShopOrderId" resultType="java.lang.Double">
  1000. SELECT IFNULL(SUM(crp.returnedPurchaseFee), 0)
  1001. FROM cm_returned_purchase crp
  1002. LEFT JOIN cm_returned_purchase_product crpp ON crp.id = crpp.returnedID
  1003. WHERE crp.delFlag = 0
  1004. AND crp.status = 2
  1005. AND crp.shopOrderId = #{shopOrderId}
  1006. </select>
  1007. <select id="findSplitCount" resultType="java.lang.Integer">
  1008. SELECT COUNT(*)
  1009. FROM cm_split_account
  1010. WHERE shopOrderId = #{shopOrderId}
  1011. </select>
  1012. <select id="findPayOrderListByIDs" resultType="newShopOrder">
  1013. select distinct<include refid="shopOrderColumns"/>,
  1014. co.payTotalFee AS payTotalFee,
  1015. co.promotionFullReduction,
  1016. bou.name AS buyer,
  1017. s.name AS shopName,
  1018. (select sum((num+presentNum)*cmCostPrice) from cm_order_product where shopOrderId = a.shopOrderId) as
  1019. allServeAmount
  1020. from cm_shop_order a
  1021. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  1022. left join bp_order_userinfo bou on bou.orderId = a.orderID
  1023. left join cm_order co on co.orderID = a.orderID
  1024. left join shop s on s.shopID = a.shopID
  1025. <where>
  1026. <if test="ids != null and ids != ''">
  1027. and a.shopOrderID in
  1028. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  1029. #{id}
  1030. </foreach>
  1031. </if>
  1032. </where>
  1033. ORDER BY a.shopOrderID DESC
  1034. </select>
  1035. <select id="findByRefundID" resultType="newShopOrder">
  1036. select distinct<include refid="shopOrderColumns"/>,
  1037. co.payTotalFee AS payTotalFee,
  1038. bou.name AS buyer,
  1039. s.name AS shopName
  1040. from cm_shop_order a
  1041. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  1042. left join bp_order_userinfo bou on bou.orderId = a.orderID
  1043. left join cm_order co on co.orderID = a.orderID
  1044. left join shop s on s.shopID = a.shopID
  1045. where a.shopOrderID in
  1046. (select crsr.shopOrderID
  1047. from cm_refund_shop_record crsr
  1048. left join cm_refund_shop crs on crsr.refundShopID = crs.id
  1049. where crs.id = #{refundShopID} and crsr.shopOrderID is not null)
  1050. ORDER BY a.shopOrderID DESC
  1051. </select>
  1052. <select id="updatePayShopAmount">
  1053. UPDATE cm_shop_order
  1054. <set>
  1055. <if test="shopProductAmount != null">
  1056. shopProductAmount = #{shopProductAmount},
  1057. </if>
  1058. <if test="shopPostFee != null">
  1059. shopPostFee = #{shopPostFee},
  1060. </if>
  1061. <if test="shopTaxFee != null">
  1062. shopTaxFee = #{shopTaxFee},
  1063. </if>
  1064. <if test="shouldPayShopAmount != null">
  1065. shouldPayShopAmount = #{shouldPayShopAmount},
  1066. </if>
  1067. <if test="shopOtherFee != null">
  1068. shopOtherFee = #{shopOtherFee},
  1069. </if>
  1070. <if test="payStatus != null">
  1071. payStatus = #{payStatus},
  1072. </if>
  1073. <if test="payedShopAmount != null">
  1074. payedShopAmount = #{payedShopAmount}
  1075. </if>
  1076. <if test="status != null and status != ''">
  1077. shopStatus = #{status},
  1078. </if>
  1079. </set>
  1080. WHERE shopOrderID = #{shopOrderID}
  1081. </select>
  1082. <select id="findByShopOrderIDs" resultType="newShopOrder">
  1083. select distinct<include refid="shopOrderColumns"/>,
  1084. co.payTotalFee AS payTotalFee,
  1085. co.promotionFullReduction AS promotionFullReduction,
  1086. a.onlinePayWays,
  1087. ifnull(a.cmAccountType,0) as cmAccountType,
  1088. ifnull(a.cmShopOtherFee,0) as cmShopOtherFee,
  1089. bou.name AS buyer,
  1090. s.name AS shopName,
  1091. c.name AS clubName
  1092. from cm_shop_order a
  1093. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  1094. left join bp_order_userinfo bou on bou.orderId = a.orderID
  1095. left join cm_order co on co.orderID = a.orderID
  1096. left join shop s on s.shopID = a.shopID
  1097. left join club c on c.userID = a.userID
  1098. <if test="shopOrderIDs != null and shopOrderIDs.size() > 0">
  1099. where a.shopOrderID in
  1100. <foreach collection="shopOrderIDs" separator="," item="shopOrderID" open="(" close=")">
  1101. #{shopOrderID}
  1102. </foreach>
  1103. </if>
  1104. </select>
  1105. <update id="updatePaying">
  1106. update cm_shop_order
  1107. set paying = #{paying}
  1108. where shopOrderID = #{shopOrderID}
  1109. </update>
  1110. <update id="outPaying">
  1111. update cm_shop_order
  1112. set paying = '0'
  1113. where shopOrderID in
  1114. (select cpsr.shopOrderID
  1115. from cm_pay_shop_record cpsr
  1116. left join cm_pay_shop cps on cps.id = cpsr.payShopID
  1117. where cps.id = #{payShopID}
  1118. and cps.delFlag = '0'
  1119. and cpsr.delFlag = '0'
  1120. and cpsr.shopOrderID is not null)
  1121. </update>
  1122. <update id="inPaying">
  1123. update cm_shop_order
  1124. set paying = '1'
  1125. where shopOrderID in
  1126. (select cpsr.shopOrderID
  1127. from cm_pay_shop_record cpsr
  1128. left join cm_pay_shop cps on cps.id = cpsr.payShopID
  1129. where cps.id = #{payShopID}
  1130. and cps.delFlag = '0'
  1131. and cpsr.delFlag = '0'
  1132. and cpsr.shopOrderID is not null)
  1133. </update>
  1134. <update id="updatePayStatus">
  1135. update cm_shop_order
  1136. set payStatus = #{payStatus}
  1137. where shopOrderID = #{shopOrderID}
  1138. </update>
  1139. <select id="findPayStatusByOrderID" resultType="string">
  1140. select payStatus
  1141. from cm_shop_order
  1142. where orderID = #{orderID}
  1143. AND shopID != 998
  1144. </select>
  1145. <select id="getPayingStatus" resultType="string">
  1146. select ifnull(paying, '0')
  1147. from cm_shop_order
  1148. where shopOrderID in
  1149. (select cpsr.shopOrderID
  1150. from cm_pay_shop_record cpsr
  1151. left join cm_pay_shop cps on cps.id = cpsr.payShopID
  1152. where cps.id = #{payShopID}
  1153. and cps.delFlag = '0'
  1154. and cpsr.delFlag = '0'
  1155. and cpsr.shopOrderID is not null)
  1156. </select>
  1157. <select id="findSiblingPostFeeOrder" resultType="newShopOrder">
  1158. select
  1159. <include refid="shopOrderColumns"/>
  1160. from cm_shop_order a
  1161. left join cm_order co on co.orderID = a.orderID
  1162. where a.orderID = #{orderID} and a.shopID = 998
  1163. </select>
  1164. <select id="findShopOrderNos" resultType="java.lang.String">
  1165. SELECT CONCAT(shopOrderNo, '(', shopOrderID, ')') AS result
  1166. FROM cm_shop_order
  1167. WHERE orderID = #{orderID}
  1168. and shopId != 998
  1169. </select>
  1170. <select id="findIncome" resultType="java.lang.Double">
  1171. SELECT ROUND(IFNULL((
  1172. co.payTotalFee - (IFNULL((SELECT ROUND(SUM((IFNULL(op.costPrice, 0) *
  1173. (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0))) +
  1174. IFNULL(op.shouldPayTotalTax, 0)),
  1175. 2)
  1176. FROM cm_order_product op
  1177. LEFT JOIN cm_shop_order cso ON cso.shopOrderID = op.shopOrderID
  1178. WHERE cso.orderID = co.orderID
  1179. AND op.productID != 999
  1180. GROUP BY cso.orderID), 0))
  1181. - (SELECT IFNULL(SUM(cso.shopOtherFee), 0)
  1182. FROM cm_shop_order cso
  1183. WHERE cso.orderID = co.orderID)
  1184. - IFNULL((SELECT SUM(shopPostFee + IF(differenceType = 1, differencePrice, 0) -
  1185. IF(differenceType = 2, differencePrice, 0))
  1186. FROM cm_shop_order
  1187. WHERE orderID = co.orderID), 0)
  1188. + IFNULL((SELECT SUM(cpsr.wipePayment)
  1189. FROM cm_pay_shop_record cpsr
  1190. WHERE cpsr.shopOrderID IN (SELECT cso.shopOrderID
  1191. FROM cm_shop_order cso
  1192. WHERE cso.orderID = co.orderID)
  1193. AND cpsr.delFlag = 0
  1194. AND (cpsr.`status` = 1 OR cpsr.`status` = 0)), 0)
  1195. + IFNULL(co.rebateFee, 0)
  1196. ), 0), 2) AS "采美总佣金"
  1197. FROM cm_order co
  1198. WHERE co.orderID = #{orderID}
  1199. </select>
  1200. <update id="updateByShopOtherFee">
  1201. UPDATE cm_shop_order
  1202. SET shopOtherFee = #{shopOtherFee}
  1203. WHERE shopOrderID = #{shopOrderId}
  1204. </update>
  1205. <update id="updateByDifferencePrice">
  1206. UPDATE cm_shop_order
  1207. SET differenceType = #{type},
  1208. differencePrice = #{differencePrice}
  1209. WHERE shopOrderID = #{shopOrderId}
  1210. </update>
  1211. <select id="findSplitList" resultType="newShopOrder">
  1212. SELECT co.couponAmount AS couponAmount,
  1213. co.userBeans AS userBeans,
  1214. a.shopOrderID AS shopOrderID,
  1215. a.orderID AS orderID,
  1216. a.organizeID AS organizeID,
  1217. a.shopOrderNo AS shopOrderNo,
  1218. a.orderNo AS orderNo,
  1219. a.userID AS userID,
  1220. a.shopID AS shopID,
  1221. a.itemCount AS itemCount,
  1222. a.townID AS townID,
  1223. a.productAmount AS productAmount,
  1224. a.discountAmount AS discountAmount,
  1225. a.accountAmount AS accountAmount,
  1226. a.totalAmount AS totalAmount,
  1227. a.payFlag AS payFlag,
  1228. a.payTime AS payTime,
  1229. a.finishTime AS finishTime,
  1230. a.refundStatus AS refundStatus,
  1231. a.needPayAmount AS needPayAmount,
  1232. a.canRefundAmount AS canRefundAmount,
  1233. a.refundAmount AS refundAmount,
  1234. a.clubID AS clubID,
  1235. a.spID AS spID,
  1236. a.mainSpID AS mainSpID,
  1237. a.orderBeanAmount AS orderBeanAmount,
  1238. a.useBeanAmount AS useBeanAmount,
  1239. a.useBeanFlag AS useBeanFlag,
  1240. a.canRefundFlag AS canRefundFlag,
  1241. a.useBalanceFlag AS useBalanceFlag,
  1242. a.canRefundBeans AS canRefundBeans,
  1243. a.freePostageFee AS freePostageFee,
  1244. a.freePostageTicketID AS freePostageTicketID,
  1245. a.brokerage AS brokerage,
  1246. a.delFlag AS delFlag,
  1247. a.refundsAmount AS refundsAmount,
  1248. a.orderStatusFlag AS orderStatusFlag,
  1249. a.buyStatus AS buyStatus,
  1250. a.orderSubmitType AS orderSubmitType,
  1251. a.orderType AS orderType,
  1252. a.orderTime AS orderTime,
  1253. a.deliveryTimeMills AS deliveryTimeMills,
  1254. a.presentNum AS presentNum,
  1255. a.preferential AS preferential,
  1256. a.outStoreNum AS outStoreNum,
  1257. IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
  1258. a.splitFlag AS splitFlag,
  1259. a.autoReceiveTimeMills AS autoReceiveTimeMills,
  1260. a.autoOverTimeMills AS autoOverTimeMills,
  1261. a.receiveGoodsTime AS receiveGoodsTime,
  1262. a.totalAddedValueTax AS totalAddedValueTax,
  1263. a.note AS note,
  1264. a.payStatus AS payStatus,
  1265. a.sendOutStatus AS sendOutStatus,
  1266. a.shopProductAmount AS shopProductAmount,
  1267. a.shopPostFee AS shopPostFee,
  1268. a.shopTaxFee AS shopTaxFee,
  1269. a.shouldPayShopAmount AS shouldPayShopAmount,
  1270. a.payedShopAmount AS payedShopAmount,
  1271. a.shopOtherFee AS shopOtherFee,
  1272. a.paying AS paying,
  1273. a.costType AS costType,
  1274. a.modifyShouldPayNote AS modifyShouldPayNote,
  1275. a.orderPromotionsId AS orderPromotionsId,
  1276. a.differenceType AS differenceType,
  1277. a.differencePrice AS differencePrice,
  1278. a.proportional AS proportional,
  1279. a.promotionFullReduction AS promotionFullReduction,
  1280. a.zeroCostFlag AS zeroCostFlag,
  1281. co.payTotalFee AS payTotalFee,
  1282. co.status AS STATUS,
  1283. bou.name AS buyer,
  1284. s.name AS shopName,
  1285. c.name AS clubName,
  1286. a.onlinePayWays,
  1287. ifnull(a.cmShopOtherFee,0) as cmShopOtherFee,
  1288. ifnull(a.cmAccountType,0) as cmAccountType
  1289. FROM cm_shop_order a
  1290. LEFT JOIN cm_pay_shop_record cpsr ON a.shopOrderID = cpsr.shopOrderID
  1291. LEFT JOIN bp_order_userinfo bou ON bou.orderId = a.orderID
  1292. LEFT JOIN cm_order co ON co.orderID = a.orderID
  1293. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
  1294. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  1295. LEFT JOIN shop s ON s.shopID = a.shopID
  1296. LEFT JOIN club c ON c.userID = a.userID
  1297. WHERE co.organizeID = 0
  1298. AND a.refundStatus = 1
  1299. AND co.delFlag = 0
  1300. AND co.orderType != 2
  1301. AND a.delFlag = 0
  1302. AND a.shopID != 998
  1303. AND (a.organizeID != 4 or a.organizeID is null)
  1304. AND cdr.payWay = 1
  1305. AND cdr.receiptDate <![CDATA[ <= ]]> NOW()
  1306. AND cror.relationType = 2
  1307. AND cror.delFlag = 0
  1308. AND cror.mbOrderId IS NOT NULL
  1309. AND cror.splitStatus = 0
  1310. AND a.receiptStatus = 3
  1311. AND a.splitCode != 'E1807059160'
  1312. AND co.orderID NOT IN (SELECT orderID
  1313. FROM cm_order_product
  1314. WHERE productID IN
  1315. (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069)
  1316. GROUP BY orderID)
  1317. GROUP BY a.shopOrderID
  1318. ORDER BY a.shopOrderID DESC
  1319. </select>
  1320. <select id="getOpenidListByPermission" resultType="java.lang.String">
  1321. SELECT openid
  1322. FROM `wechat_user`
  1323. WHERE unionid = #{unionid}
  1324. </select>
  1325. <select id="FromUnionId" resultType="java.lang.String">
  1326. SELECT unionID
  1327. FROM `cm_order`
  1328. WHERE orderID = #{orderId}
  1329. </select>
  1330. <select id="UnionId" resultType="java.lang.String">
  1331. SELECT unionID
  1332. FROM `cm_order`
  1333. WHERE userID = #{userID}
  1334. ORDER BY orderID DESC
  1335. LIMIT 1
  1336. </select>
  1337. <select id="getProductOrder" resultType="java.lang.String">
  1338. SELECT productID
  1339. FROM `cm_order_product`
  1340. WHERE orderID = #{orderid}
  1341. </select>
  1342. <select id="payWay" resultType="java.lang.Integer">
  1343. SELECT cdr.payWay
  1344. FROM cm_shop_order a
  1345. LEFT JOIN cm_order co ON co.orderID = a.orderID
  1346. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
  1347. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  1348. WHERE a.shopOrderID = #{shopOrderID}
  1349. </select>
  1350. <select id="findSettlementList" resultType="com.caimei.modules.order.entity.NewShopOrder">
  1351. SELECT co.couponAmount AS couponAmount,
  1352. co.userBeans AS userBeans,
  1353. a.shopOrderID AS shopOrderID,
  1354. a.orderID AS orderID,
  1355. a.organizeID AS organizeID,
  1356. a.shopOrderNo AS shopOrderNo,
  1357. a.orderNo AS orderNo,
  1358. a.userID AS userID,
  1359. a.shopID AS shopID,
  1360. a.itemCount AS itemCount,
  1361. a.townID AS townID,
  1362. a.productAmount AS productAmount,
  1363. a.discountAmount AS discountAmount,
  1364. a.accountAmount AS accountAmount,
  1365. a.totalAmount AS totalAmount,
  1366. a.payFlag AS payFlag,
  1367. a.payTime AS payTime,
  1368. a.finishTime AS finishTime,
  1369. a.refundStatus AS refundStatus,
  1370. a.needPayAmount AS needPayAmount,
  1371. a.canRefundAmount AS canRefundAmount,
  1372. a.refundAmount AS refundAmount,
  1373. a.clubID AS clubID,
  1374. a.spID AS spID,
  1375. a.mainSpID AS mainSpID,
  1376. a.orderBeanAmount AS orderBeanAmount,
  1377. a.useBeanAmount AS useBeanAmount,
  1378. a.useBeanFlag AS useBeanFlag,
  1379. a.canRefundFlag AS canRefundFlag,
  1380. a.useBalanceFlag AS useBalanceFlag,
  1381. a.canRefundBeans AS canRefundBeans,
  1382. a.freePostageFee AS freePostageFee,
  1383. a.freePostageTicketID AS freePostageTicketID,
  1384. a.brokerage AS brokerage,
  1385. a.delFlag AS delFlag,
  1386. a.refundsAmount AS refundsAmount,
  1387. a.orderStatusFlag AS orderStatusFlag,
  1388. a.buyStatus AS buyStatus,
  1389. a.orderSubmitType AS orderSubmitType,
  1390. a.orderType AS orderType,
  1391. a.orderTime AS orderTime,
  1392. a.deliveryTimeMills AS deliveryTimeMills,
  1393. a.presentNum AS presentNum,
  1394. a.preferential AS preferential,
  1395. a.outStoreNum AS outStoreNum,
  1396. IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
  1397. a.splitFlag AS splitFlag,
  1398. a.autoReceiveTimeMills AS autoReceiveTimeMills,
  1399. a.autoOverTimeMills AS autoOverTimeMills,
  1400. a.receiveGoodsTime AS receiveGoodsTime,
  1401. a.totalAddedValueTax AS totalAddedValueTax,
  1402. a.note AS note,
  1403. a.payStatus AS payStatus,
  1404. a.sendOutStatus AS sendOutStatus,
  1405. a.shopProductAmount AS shopProductAmount,
  1406. a.shopPostFee AS shopPostFee,
  1407. a.shopTaxFee AS shopTaxFee,
  1408. a.shouldPayShopAmount AS shouldPayShopAmount,
  1409. a.payedShopAmount AS payedShopAmount,
  1410. a.shopOtherFee AS shopOtherFee,
  1411. a.paying AS paying,
  1412. a.costType AS costType,
  1413. a.modifyShouldPayNote AS modifyShouldPayNote,
  1414. a.orderPromotionsId AS orderPromotionsId,
  1415. a.differenceType AS differenceType,
  1416. a.differencePrice AS differencePrice,
  1417. a.proportional AS proportional,
  1418. a.promotionFullReduction AS promotionFullReduction,
  1419. a.zeroCostFlag AS zeroCostFlag,
  1420. a.settleStatus AS settleStatus,
  1421. co.payTotalFee AS payTotalFee,
  1422. co.status AS STATUS,
  1423. bou.name AS buyer,
  1424. s.name AS shopName,
  1425. c.name AS clubName,
  1426. a.onlinePayWays,
  1427. ifnull(a.cmAccountType,0) as cmAccountType,
  1428. ifnull(a.a.cmShopOtherFee,0) as cmShopOtherFee
  1429. FROM cm_shop_order a
  1430. LEFT JOIN cm_pay_shop_record cpsr ON a.shopOrderID = cpsr.shopOrderID
  1431. LEFT JOIN bp_order_userinfo bou ON bou.orderId = a.orderID
  1432. LEFT JOIN cm_order co ON co.orderID = a.orderID
  1433. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
  1434. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  1435. LEFT JOIN cm_split_account csa on csa.shopOrderId = a.shopOrderID
  1436. LEFT JOIN shop s ON s.shopID = a.shopID
  1437. LEFT JOIN club c ON c.userID = a.userID
  1438. WHERE co.organizeID = 0
  1439. AND co.refundType != 2
  1440. AND co.delFlag = 0
  1441. AND co.orderType != 2
  1442. AND co.receiptStatus = 3
  1443. AND a.delFlag = 0
  1444. AND a.refundStatus = 1
  1445. AND a.shopID != 998
  1446. AND (a.organizeID!=4 or a.organizeID is null)
  1447. AND cdr.payWay = 1
  1448. AND cror.relationType = 2
  1449. AND a.settleStatus in (1,2)
  1450. AND csa.settleStatus = 0
  1451. AND cror.delFlag = 0
  1452. AND cror.mbOrderId IS NOT NULL
  1453. AND cror.splitStatus = 1
  1454. AND a.splitCode != 'E1807059160'
  1455. <if test="startTime != null and startTime != ''">
  1456. AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
  1457. </if>
  1458. <if test="endTime != null and endTime != ''">
  1459. AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
  1460. </if>
  1461. <if test="orderID != null and orderID != ''">
  1462. AND a.orderID = #{orderID}
  1463. </if>
  1464. <if test="orderNo != null and orderNo != ''">
  1465. AND a.orderNo like concat('%', #{orderNo} ,'%')
  1466. </if>
  1467. <if test="ps != null and ps.length>0 ">
  1468. AND a.settleStatus in
  1469. <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
  1470. #{item}
  1471. </foreach>
  1472. </if>
  1473. <if test="shopName != null and shopName != ''">
  1474. AND s.name like concat('%', #{shopName} ,'%')
  1475. </if>
  1476. <if test="clubName != null and clubName != ''">
  1477. AND c.name like concat('%', #{clubName} ,'%')
  1478. </if>
  1479. <if test="shopOrderID != null and shopOrderID != ''">
  1480. AND a.shopOrderID = #{shopOrderID}
  1481. </if>
  1482. <if test="shopOrderNo != null and shopOrderNo != ''">
  1483. AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
  1484. </if>
  1485. GROUP BY a.shopOrderID
  1486. ORDER BY a.shopOrderID DESC
  1487. </select>
  1488. <select id="findSettleRecord" resultType="com.caimei.modules.order.entity.SettleRecord">
  1489. select settleAmount, settleType, settleTime
  1490. from cm_settle_record
  1491. where shopOrderId = #{shopOrderID}
  1492. </select>
  1493. <select id="findListByShopOrderId" resultType="com.caimei.modules.order.entity.NewShopOrder">
  1494. SELECT<include refid="shopOrderColumns"/>,
  1495. b.name as shopName,
  1496. oa.id as orderArchiveId,
  1497. co.receiptStatus
  1498. FROM cm_shop_order a
  1499. left join shop b on a.shopID = b.shopID
  1500. left join cm_order_archive oa on a.shopOrderID = oa.shopOrderId
  1501. left join cm_order co on co.orderID = a.orderID
  1502. WHERE a.shopOrderId = #{onlineShopOrderId}
  1503. ORDER BY a.shopOrderNo DESC
  1504. </select>
  1505. <resultMap type="com.caimei.modules.order.entity.NewShopOrder" id="CmShopOrderResult">
  1506. <result property="shopOrderID" column="shopOrderID"/>
  1507. <result property="shopOrderNo" column="shopOrderNo"/>
  1508. <result property="orderNo" column="orderNo"/>
  1509. <result property="orderID" column="orderID"/>
  1510. <result property="organizeID" column="organizeID"/>
  1511. <result property="isColdChina" column="isColdChina"/>
  1512. <result property="userID" column="userID"/>
  1513. <result property="shopID" column="shopID"/>
  1514. <result property="orderPromotionsId" column="orderPromotionsId"/>
  1515. <result property="orderType" column="orderType"/>
  1516. <result property="orderSubmitType" column="orderSubmitType"/>
  1517. <result property="presentNum" column="presentNum"/>
  1518. <result property="itemCount" column="itemCount"/>
  1519. <result property="outStoreNum" column="outStoreNum"/>
  1520. <result property="outStoreTimes" column="outStoreTimes"/>
  1521. <result property="townID" column="townID"/>
  1522. <result property="note" column="note"/>
  1523. <result property="eachDiscount" column="eachDiscount"/>
  1524. <result property="realPay" column="realPay"/>
  1525. <result property="receiptAmount" column="receiptAmount"/>
  1526. <result property="accountAmount" column="accountAmount"/>
  1527. <result property="productAmount" column="productAmount"/>
  1528. <result property="totalAmount" column="totalAmount"/>
  1529. <result property="needPayAmount" column="needPayAmount"/>
  1530. <result property="discountAmount" column="discountAmount"/>
  1531. <result property="preferential" column="preferential"/>
  1532. <result property="promotionFullReduction" column="promotionFullReduction"/>
  1533. <result property="payFlag" column="payFlag"/>
  1534. <result property="orderTime" column="orderTime"/>
  1535. <result property="payTime" column="payTime"/>
  1536. <result property="finishTime" column="finishTime"/>
  1537. <result property="autoOverTimeMills" column="autoOverTimeMills"/>
  1538. <result property="settleStatus" column="settleStatus"/>
  1539. <result property="payStatus" column="payStatus"/>
  1540. <result property="receiptStatus" column="receiptStatus"/>
  1541. <result property="sendOutStatus" column="sendOutStatus"/>
  1542. <result property="refundStatus" column="refundStatus"/>
  1543. <result property="returnGoodsStatus" column="returnGoodsStatus"/>
  1544. <result property="receiveGoodsTime" column="receiveGoodsTime"/>
  1545. <result property="autoReceiveTimeMills" column="autoReceiveTimeMills"/>
  1546. <result property="totalAddedValueTax" column="totalAddedValueTax"/>
  1547. <result property="canRefundAmount" column="canRefundAmount"/>
  1548. <result property="refundAmount" column="refundAmount"/>
  1549. <result property="clubID" column="clubID"/>
  1550. <result property="spID" column="spID"/>
  1551. <result property="mainSpID" column="mainSpID"/>
  1552. <result property="orderBeanAmount" column="orderBeanAmount"/>
  1553. <result property="useBeanAmount" column="useBeanAmount"/>
  1554. <result property="useBeanFlag" column="useBeanFlag"/>
  1555. <result property="canRefundFlag" column="canRefundFlag"/>
  1556. <result property="useBalanceFlag" column="useBalanceFlag"/>
  1557. <result property="canRefundBeans" column="canRefundBeans"/>
  1558. <result property="freePostageFee" column="freePostageFee"/>
  1559. <result property="freePostageTicketID" column="freePostageTicketID"/>
  1560. <result property="brokerage" column="brokerage"/>
  1561. <result property="delFlag" column="delFlag"/>
  1562. <result property="refundsAmount" column="refundsAmount"/>
  1563. <result property="orderStatusFlag" column="orderStatusFlag"/>
  1564. <result property="buyStatus" column="buyStatus"/>
  1565. <result property="deliveryTimeMills" column="deliveryTimeMills"/>
  1566. <result property="orderDeliveryID" column="orderDeliveryID"/>
  1567. <result property="splitFlag" column="splitFlag"/>
  1568. <result property="paying" column="paying"/>
  1569. <result property="shopProductAmount" column="shopProductAmount"/>
  1570. <result property="shopPostFee" column="shopPostFee"/>
  1571. <result property="shopPostFlag" column="shopPostFlag"/>
  1572. <result property="shopTaxFee" column="shopTaxFee"/>
  1573. <result property="payCmAmount" column="payCmAmount"/>
  1574. <result property="shouldPayShopAmount" column="shouldPayShopAmount"/>
  1575. <result property="payedShopAmount" column="payedShopAmount"/>
  1576. <result property="shopOtherFee" column="shopOtherFee"/>
  1577. <result property="receiptedFlag" column="receiptedFlag"/>
  1578. <result property="receiptedType" column="receiptedType"/>
  1579. <result property="costType" column="costType"/>
  1580. <result property="proportional" column="proportional"/>
  1581. <result property="modifyShouldPayNote" column="modifyShouldPayNote"/>
  1582. <result property="modifyShouldPayUserID" column="modifyShouldPayUserID"/>
  1583. <result property="modifyShouldPayDate" column="modifyShouldPayDate"/>
  1584. <result property="zeroCostFlag" column="zeroCostFlag"/>
  1585. <result property="differenceType" column="differenceType"/>
  1586. <result property="differencePrice" column="differencePrice"/>
  1587. <result property="svipShopReduction" column="svipShopReduction"/>
  1588. <result property="splitCode" column="splitCode"/>
  1589. <result property="paySuccessCounter" column="paySuccessCounter"/>
  1590. <result property="onlinePayWays" column="onlinePayWays"/>
  1591. <result property="status" column="shopStatus"/>
  1592. </resultMap>
  1593. <sql id="selectCmShopOrderVo">
  1594. select cm_shop_order.shopOrderID,
  1595. cm_shop_order.shopOrderNo,
  1596. cm_shop_order.orderNo,
  1597. cm_shop_order.orderID,
  1598. cm_shop_order.organizeID,
  1599. cm_shop_order.isColdChina,
  1600. cm_shop_order.userID,
  1601. cm_shop_order.shopID,
  1602. cm_shop_order.orderPromotionsId,
  1603. cm_shop_order.orderType,
  1604. cm_shop_order.orderSubmitType,
  1605. cm_shop_order.presentNum,
  1606. cm_shop_order.itemCount,
  1607. cm_shop_order.outStoreNum,
  1608. cm_shop_order.outStoreTimes,
  1609. cm_shop_order.townID,
  1610. cm_shop_order.note,
  1611. ifnull(cm_shop_order.accountAmount, 0) AS accountAmount,
  1612. ifnull(cm_shop_order.productAmount, 0) AS productAmount,
  1613. ifnull(cm_shop_order.totalAmount, 0) AS totalAmount,
  1614. ifnull(cm_shop_order.needPayAmount, 0) AS needPayAmount,
  1615. ifnull(cm_shop_order.discountAmount, 0) AS discountAmount,
  1616. ifnull(cm_shop_order.preferential, 0) AS preferential,
  1617. ifnull(cm_shop_order.promotionFullReduction, 0) AS promotionFullReduction,
  1618. cm_shop_order.payFlag,
  1619. cm_shop_order.orderTime,
  1620. cm_shop_order.payTime,
  1621. cm_shop_order.finishTime,
  1622. cm_shop_order.autoOverTimeMills,
  1623. cm_shop_order.settleStatus,
  1624. cm_shop_order.payStatus,
  1625. cm_shop_order.sendOutStatus,
  1626. cm_shop_order.refundStatus,
  1627. cm_shop_order.shopStatus,
  1628. cm_shop_order.returnGoodsStatus,
  1629. cm_shop_order.receiveGoodsTime,
  1630. cm_shop_order.autoReceiveTimeMills,
  1631. ifnull(cm_shop_order.totalAddedValueTax, 0) AS totalAddedValueTax,
  1632. cm_shop_order.canRefundAmount,
  1633. cm_shop_order.refundAmount,
  1634. cm_shop_order.clubID,
  1635. cm_shop_order.spID,
  1636. cm_shop_order.mainSpID,
  1637. cm_shop_order.orderBeanAmount,
  1638. cm_shop_order.useBeanAmount,
  1639. cm_shop_order.useBeanFlag,
  1640. cm_shop_order.canRefundFlag,
  1641. cm_shop_order.useBalanceFlag,
  1642. cm_shop_order.canRefundBeans,
  1643. ifnull(cm_shop_order.freePostageFee, 0) AS freePostageFee,
  1644. cm_shop_order.freePostageTicketID,
  1645. ifnull(cm_shop_order.brokerage, 0) AS brokerage,
  1646. cm_shop_order.delFlag,
  1647. ifnull(cm_shop_order.refundsAmount, 0) AS refundsAmount,
  1648. cm_shop_order.orderStatusFlag,
  1649. cm_shop_order.buyStatus,
  1650. cm_shop_order.deliveryTimeMills,
  1651. cm_shop_order.confirmTime,
  1652. cm_shop_order.updateTime,
  1653. cm_shop_order.orderDeliveryID,
  1654. cm_shop_order.splitFlag,
  1655. cm_shop_order.receiptedFlag,
  1656. cm_shop_order.receiptedType,
  1657. cm_shop_order.paying,
  1658. ifnull(cm_shop_order.shopProductAmount, 0) AS shopProductAmount,
  1659. ifnull(cm_shop_order.shopPostFee, 0) AS shopPostFee,
  1660. cm_shop_order.shopPostFlag,
  1661. ifnull(cm_shop_order.shopTaxFee, 0) AS shopTaxFee,
  1662. ifnull(cm_shop_order.payCmAmount, 0) AS payCmAmount,
  1663. ifnull(cm_shop_order.shouldPayShopAmount, 0) AS shouldPayShopAmount,
  1664. ifnull(cm_shop_order.payedShopAmount, 0) AS payedShopAmount,
  1665. ifnull(cm_shop_order.shopOtherFee, 0) AS shopOtherFee,
  1666. cm_shop_order.costType,
  1667. ifnull(cm_shop_order.proportional, 0) AS proportional,
  1668. cm_shop_order.modifyShouldPayNote,
  1669. cm_shop_order.modifyShouldPayUserID,
  1670. cm_shop_order.modifyShouldPayDate,
  1671. cm_shop_order.zeroCostFlag,
  1672. cm_shop_order.differenceType,
  1673. ifnull(cm_shop_order.differencePrice, 0) AS differencePrice,
  1674. ifnull(cm_shop_order.svipShopReduction, 0) AS svipShopReduction,
  1675. ifnull(cm_shop_order.shopRefundAmount, 0) AS shopRefundAmount,
  1676. cm_shop_order.splitCode,
  1677. cm_shop_order.paySuccessCounter,
  1678. cm_shop_order.onlinePayWays,
  1679. cm_shop_order.receiptStatus,
  1680. ifnull(cm_shop_order.receiptAmount, 0) AS receiptAmount,
  1681. ifnull(cm_shop_order.eachDiscount, 0) AS eachDiscount,
  1682. ifnull(cm_shop_order.realPay, 0) AS realPay,
  1683. cm_shop_order.discountFee,
  1684. cm_shop_order.fee
  1685. </sql>
  1686. <select id="getByCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder"
  1687. resultMap="CmShopOrderResult">
  1688. <include refid="selectCmShopOrderVo"/>
  1689. from cm_shop_order AS cm_shop_order
  1690. <where>cm_shop_order.delFlag = 0
  1691. <if test="shopOrderID != null and shopOrderID != ''">
  1692. and cm_shop_order.shopOrderID
  1693. = #{shopOrderID}
  1694. </if>
  1695. <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
  1696. <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
  1697. <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
  1698. <foreach item="shopOrderIDIn"
  1699. collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
  1700. open="(" separator="," close=")">
  1701. #{shopOrderIDIn}
  1702. </foreach>
  1703. </if>
  1704. <if test="shopOrderNo != null and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
  1705. <if test="orderNo != null and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
  1706. <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
  1707. <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
  1708. <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
  1709. <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
  1710. <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
  1711. <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
  1712. <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
  1713. <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
  1714. <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
  1715. <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
  1716. <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
  1717. <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
  1718. <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
  1719. <if test="note != null and note != ''">and cm_shop_order.note = #{note}</if>
  1720. <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
  1721. <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
  1722. <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
  1723. <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
  1724. <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
  1725. <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
  1726. <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
  1727. <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
  1728. <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
  1729. <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
  1730. #{promotionFullReduction}
  1731. </if>
  1732. <if test="payFlag != null and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
  1733. <if test="orderTime != null and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
  1734. <if test="payTime != null and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
  1735. <if test="finishTime != null and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
  1736. <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
  1737. <if test="settleStatus != null and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
  1738. </if>
  1739. <if test="payStatus != null and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
  1740. <if test="receiptStatus != null and receiptStatus != ''">and cm_shop_order.receiptStatus =
  1741. #{receiptStatus}
  1742. </if>
  1743. <if test="sendOutStatus != null and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
  1744. #{sendOutStatus}
  1745. </if>
  1746. <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
  1747. <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
  1748. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
  1749. #{receiveGoodsTime}
  1750. </if>
  1751. <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
  1752. </if>
  1753. <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
  1754. <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
  1755. <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
  1756. <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
  1757. <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
  1758. <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
  1759. <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
  1760. <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
  1761. <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
  1762. <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
  1763. <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
  1764. <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
  1765. <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
  1766. <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
  1767. <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
  1768. <if test="delFlag != null and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
  1769. <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
  1770. <if test="orderStatusFlag != null and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
  1771. #{orderStatusFlag}
  1772. </if>
  1773. <if test="buyStatus != null and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
  1774. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
  1775. #{deliveryTimeMills}
  1776. </if>
  1777. <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
  1778. <if test="splitFlag != null and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
  1779. <if test="paying != null and paying != ''">and cm_shop_order.paying = #{paying}</if>
  1780. <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
  1781. <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
  1782. <if test="shopPostFlag != null and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
  1783. </if>
  1784. <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
  1785. <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
  1786. <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
  1787. <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
  1788. <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
  1789. <if test="receiptedFlag != null and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
  1790. #{receiptedFlag}
  1791. </if>
  1792. <if test="receiptedType != null and receiptedType != ''">and cm_shop_order.receiptedType =
  1793. #{receiptedType}
  1794. </if>
  1795. <if test="costType != null and costType != ''">and cm_shop_order.costType = #{costType}</if>
  1796. <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
  1797. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
  1798. = #{modifyShouldPayNote}
  1799. </if>
  1800. <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
  1801. #{modifyShouldPayUserID}
  1802. </if>
  1803. <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
  1804. <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
  1805. <if test="differenceType != null and differenceType != ''">and cm_shop_order.differenceType =
  1806. #{differenceType}
  1807. </if>
  1808. <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
  1809. <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
  1810. <if test="splitCode != null and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
  1811. <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
  1812. <if test="onlinePayWays != null and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
  1813. #{onlinePayWays}
  1814. </if>
  1815. <if test="status != null and status != ''">and cm_shop_order.shopStatus = #{status}</if>
  1816. </where>
  1817. group by cm_shop_order.shopOrderID
  1818. order by cm_shop_order.orderTime desc
  1819. limit 0,1
  1820. </select>
  1821. <select id="getCmShopOrderList" parameterType="com.caimei.modules.order.entity.NewShopOrder"
  1822. resultMap="CmShopOrderResult">
  1823. <include refid="selectCmShopOrderVo"/>
  1824. from cm_shop_order AS cm_shop_order
  1825. <where>cm_shop_order.delFlag = 0
  1826. <if test="shopOrderID != null and shopOrderID != ''">
  1827. and cm_shop_order.shopOrderID
  1828. = #{shopOrderID}
  1829. </if>
  1830. <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
  1831. <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
  1832. <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
  1833. <foreach item="shopOrderIDIn"
  1834. collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
  1835. open="(" separator="," close=")">
  1836. #{shopOrderIDIn}
  1837. </foreach>
  1838. </if>
  1839. <if test="shopOrderNo != null and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
  1840. <if test="orderNo != null and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
  1841. <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
  1842. <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
  1843. <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
  1844. <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
  1845. <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
  1846. <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
  1847. <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
  1848. <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
  1849. <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
  1850. <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
  1851. <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
  1852. <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
  1853. <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
  1854. <if test="note != null and note != ''">and cm_shop_order.note = #{note}</if>
  1855. <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
  1856. <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
  1857. <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
  1858. <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
  1859. <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
  1860. <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
  1861. <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
  1862. <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
  1863. <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
  1864. <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
  1865. #{promotionFullReduction}
  1866. </if>
  1867. <if test="payFlag != null and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
  1868. <if test="orderTime != null and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
  1869. <if test="payTime != null and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
  1870. <if test="finishTime != null and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
  1871. <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
  1872. <if test="settleStatus != null and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
  1873. </if>
  1874. <if test="payStatus != null and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
  1875. <if test="receiptStatus != null and receiptStatus != ''">and cm_shop_order.receiptStatus =
  1876. #{receiptStatus}
  1877. </if>
  1878. <if test="sendOutStatus != null and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
  1879. #{sendOutStatus}
  1880. </if>
  1881. <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
  1882. <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
  1883. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
  1884. #{receiveGoodsTime}
  1885. </if>
  1886. <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
  1887. </if>
  1888. <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
  1889. <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
  1890. <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
  1891. <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
  1892. <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
  1893. <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
  1894. <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
  1895. <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
  1896. <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
  1897. <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
  1898. <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
  1899. <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
  1900. <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
  1901. <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
  1902. <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
  1903. <if test="delFlag != null and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
  1904. <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
  1905. <if test="orderStatusFlag != null and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
  1906. #{orderStatusFlag}
  1907. </if>
  1908. <if test="buyStatus != null and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
  1909. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
  1910. #{deliveryTimeMills}
  1911. </if>
  1912. <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
  1913. <if test="splitFlag != null and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
  1914. <if test="paying != null and paying != ''">and cm_shop_order.paying = #{paying}</if>
  1915. <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
  1916. <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
  1917. <if test="shopPostFlag != null and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
  1918. </if>
  1919. <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
  1920. <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
  1921. <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
  1922. <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
  1923. <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
  1924. <if test="receiptedFlag != null and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
  1925. #{receiptedFlag}
  1926. </if>
  1927. <if test="receiptedType != null and receiptedType != ''">and cm_shop_order.receiptedType =
  1928. #{receiptedType}
  1929. </if>
  1930. <if test="costType != null and costType != ''">and cm_shop_order.costType = #{costType}</if>
  1931. <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
  1932. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
  1933. = #{modifyShouldPayNote}
  1934. </if>
  1935. <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
  1936. #{modifyShouldPayUserID}
  1937. </if>
  1938. <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
  1939. <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
  1940. <if test="differenceType != null and differenceType != ''">and cm_shop_order.differenceType =
  1941. #{differenceType}
  1942. </if>
  1943. <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
  1944. <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
  1945. <if test="splitCode != null and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
  1946. <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
  1947. <if test="onlinePayWays != null and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
  1948. #{onlinePayWays}
  1949. </if>
  1950. <if test="status != null and status != ''">and cm_shop_order.shopStatus = #{status}</if>
  1951. </where>
  1952. group by cm_shop_order.shopOrderID
  1953. order by cm_shop_order.orderTime desc
  1954. </select>
  1955. <select id="getCmShopOrderCount" parameterType="com.caimei.modules.order.entity.NewShopOrder" resultType="String">
  1956. select count(1)
  1957. from cm_shop_order AS cm_shop_order
  1958. <where>cm_shop_order.delFlag = 0
  1959. <if test="shopOrderID != null and shopOrderID != ''">
  1960. and cm_shop_order.shopOrderID
  1961. = #{shopOrderID}
  1962. </if>
  1963. <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
  1964. <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
  1965. <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
  1966. <foreach item="shopOrderIDIn"
  1967. collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
  1968. open="(" separator="," close=")">
  1969. #{shopOrderIDIn}
  1970. </foreach>
  1971. </if>
  1972. <if test="shopOrderNo != null and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
  1973. <if test="orderNo != null and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
  1974. <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
  1975. <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
  1976. <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
  1977. <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
  1978. <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
  1979. <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
  1980. <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
  1981. <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
  1982. <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
  1983. <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
  1984. <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
  1985. <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
  1986. <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
  1987. <if test="note != null and note != ''">and cm_shop_order.note = #{note}</if>
  1988. <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
  1989. <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
  1990. <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
  1991. <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
  1992. <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
  1993. <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
  1994. <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
  1995. <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
  1996. <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
  1997. <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
  1998. #{promotionFullReduction}
  1999. </if>
  2000. <if test="payFlag != null and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
  2001. <if test="orderTime != null and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
  2002. <if test="payTime != null and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
  2003. <if test="finishTime != null and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
  2004. <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
  2005. <if test="settleStatus != null and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
  2006. </if>
  2007. <if test="payStatus != null and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
  2008. <if test="receiptStatus != null and receiptStatus != ''">and cm_shop_order.receiptStatus =
  2009. #{receiptStatus}
  2010. </if>
  2011. <if test="sendOutStatus != null and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
  2012. #{sendOutStatus}
  2013. </if>
  2014. <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
  2015. <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
  2016. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
  2017. #{receiveGoodsTime}
  2018. </if>
  2019. <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
  2020. </if>
  2021. <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
  2022. <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
  2023. <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
  2024. <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
  2025. <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
  2026. <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
  2027. <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
  2028. <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
  2029. <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
  2030. <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
  2031. <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
  2032. <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
  2033. <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
  2034. <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
  2035. <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
  2036. <if test="delFlag != null and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
  2037. <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
  2038. <if test="orderStatusFlag != null and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
  2039. #{orderStatusFlag}
  2040. </if>
  2041. <if test="buyStatus != null and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
  2042. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
  2043. #{deliveryTimeMills}
  2044. </if>
  2045. <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
  2046. <if test="splitFlag != null and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
  2047. <if test="paying != null and paying != ''">and cm_shop_order.paying = #{paying}</if>
  2048. <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
  2049. <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
  2050. <if test="shopPostFlag != null and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
  2051. </if>
  2052. <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
  2053. <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
  2054. <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
  2055. <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
  2056. <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
  2057. <if test="receiptedFlag != null and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
  2058. #{receiptedFlag}
  2059. </if>
  2060. <if test="receiptedType != null and receiptedType != ''">and cm_shop_order.receiptedType =
  2061. #{receiptedType}
  2062. </if>
  2063. <if test="costType != null and costType != ''">and cm_shop_order.costType = #{costType}</if>
  2064. <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
  2065. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
  2066. = #{modifyShouldPayNote}
  2067. </if>
  2068. <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
  2069. #{modifyShouldPayUserID}
  2070. </if>
  2071. <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
  2072. <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
  2073. <if test="differenceType != null and differenceType != ''">and cm_shop_order.differenceType =
  2074. #{differenceType}
  2075. </if>
  2076. <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
  2077. <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
  2078. <if test="splitCode != null and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
  2079. <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
  2080. <if test="onlinePayWays != null and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
  2081. #{onlinePayWays}
  2082. </if>
  2083. <if test="status != null and status != ''">and cm_shop_order.shopStatus = #{status}</if>
  2084. </where>
  2085. group by cm_shop_order.shopOrderID
  2086. </select>
  2087. <select id="getCmShopOrderByShopOrderID" parameterType="String" resultMap="CmShopOrderResult">
  2088. <include refid="selectCmShopOrderVo"/>
  2089. from cm_shop_order AS cm_shop_order
  2090. where cm_shop_order.delFlag = 0 and cm_shop_order.shopOrderID = #{shopOrderID}
  2091. </select>
  2092. <select id="getByIds" parameterType="com.caimei.modules.order.entity.NewShopOrder" resultType="String">
  2093. select shopOrderID
  2094. from cm_shop_order AS cm_shop_order
  2095. <where>cm_shop_order.delFlag = 0
  2096. <if test="shopOrderID != null and shopOrderID != ''">
  2097. and cm_shop_order.shopOrderID
  2098. = #{shopOrderID}
  2099. </if>
  2100. <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
  2101. <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
  2102. <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
  2103. <foreach item="shopOrderIDIn"
  2104. collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
  2105. open="(" separator="," close=")">
  2106. #{shopOrderIDIn}
  2107. </foreach>
  2108. </if>
  2109. <if test="shopOrderNo != null and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
  2110. <if test="orderNo != null and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
  2111. <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
  2112. <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
  2113. <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
  2114. <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
  2115. <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
  2116. <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
  2117. <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
  2118. <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
  2119. <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
  2120. <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
  2121. <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
  2122. <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
  2123. <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
  2124. <if test="note != null and note != ''">and cm_shop_order.note = #{note}</if>
  2125. <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
  2126. <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
  2127. <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
  2128. <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
  2129. <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
  2130. <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
  2131. <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
  2132. <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
  2133. <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
  2134. <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
  2135. #{promotionFullReduction}
  2136. </if>
  2137. <if test="payFlag != null and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
  2138. <if test="orderTime != null and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
  2139. <if test="payTime != null and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
  2140. <if test="finishTime != null and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
  2141. <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
  2142. <if test="settleStatus != null and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
  2143. </if>
  2144. <if test="payStatus != null and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
  2145. <if test="receiptStatus != null and receiptStatus != ''">and cm_shop_order.receiptStatus =
  2146. #{receiptStatus}
  2147. </if>
  2148. <if test="sendOutStatus != null and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
  2149. #{sendOutStatus}
  2150. </if>
  2151. <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
  2152. <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
  2153. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
  2154. #{receiveGoodsTime}
  2155. </if>
  2156. <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
  2157. </if>
  2158. <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
  2159. <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
  2160. <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
  2161. <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
  2162. <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
  2163. <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
  2164. <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
  2165. <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
  2166. <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
  2167. <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
  2168. <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
  2169. <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
  2170. <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
  2171. <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
  2172. <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
  2173. <if test="delFlag != null and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
  2174. <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
  2175. <if test="orderStatusFlag != null and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
  2176. #{orderStatusFlag}
  2177. </if>
  2178. <if test="buyStatus != null and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
  2179. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
  2180. #{deliveryTimeMills}
  2181. </if>
  2182. <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
  2183. <if test="splitFlag != null and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
  2184. <if test="paying != null and paying != ''">and cm_shop_order.paying = #{paying}</if>
  2185. <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
  2186. <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
  2187. <if test="shopPostFlag != null and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
  2188. </if>
  2189. <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
  2190. <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
  2191. <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
  2192. <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
  2193. <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
  2194. <if test="receiptedFlag != null and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
  2195. #{receiptedFlag}
  2196. </if>
  2197. <if test="receiptedType != null and receiptedType != ''">and cm_shop_order.receiptedType =
  2198. #{receiptedType}
  2199. </if>
  2200. <if test="costType != null and costType != ''">and cm_shop_order.costType = #{costType}</if>
  2201. <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
  2202. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
  2203. = #{modifyShouldPayNote}
  2204. </if>
  2205. <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
  2206. #{modifyShouldPayUserID}
  2207. </if>
  2208. <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
  2209. <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
  2210. <if test="differenceType != null and differenceType != ''">and cm_shop_order.differenceType =
  2211. #{differenceType}
  2212. </if>
  2213. <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
  2214. <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
  2215. <if test="splitCode != null and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
  2216. <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
  2217. <if test="onlinePayWays != null and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
  2218. #{onlinePayWays}
  2219. </if>
  2220. <if test="status != null and status != ''">and cm_shop_order.shopStatus = #{status}</if>
  2221. </where>
  2222. group by cm_shop_order.shopOrderID
  2223. </select>
  2224. <select id="getById" parameterType="com.caimei.modules.order.entity.NewShopOrder" resultType="String">
  2225. select shopOrderID
  2226. from cm_shop_order AS cm_shop_order
  2227. <where>cm_shop_order.delFlag = 0
  2228. <if test="shopOrderID != null and shopOrderID != ''">
  2229. and cm_shop_order.shopOrderID
  2230. = #{shopOrderID}
  2231. </if>
  2232. <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
  2233. <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
  2234. <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
  2235. <foreach item="shopOrderIDIn"
  2236. collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
  2237. open="(" separator="," close=")">
  2238. #{shopOrderIDIn}
  2239. </foreach>
  2240. </if>
  2241. <if test="shopOrderNo != null and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
  2242. <if test="orderNo != null and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
  2243. <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
  2244. <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
  2245. <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
  2246. <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
  2247. <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
  2248. <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
  2249. <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
  2250. <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
  2251. <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
  2252. <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
  2253. <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
  2254. <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
  2255. <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
  2256. <if test="note != null and note != ''">and cm_shop_order.note = #{note}</if>
  2257. <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
  2258. <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
  2259. <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
  2260. <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
  2261. <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
  2262. <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
  2263. <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
  2264. <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
  2265. <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
  2266. <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
  2267. #{promotionFullReduction}
  2268. </if>
  2269. <if test="payFlag != null and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
  2270. <if test="orderTime != null and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
  2271. <if test="payTime != null and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
  2272. <if test="finishTime != null and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
  2273. <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
  2274. <if test="settleStatus != null and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
  2275. </if>
  2276. <if test="payStatus != null and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
  2277. <if test="receiptStatus != null and receiptStatus != ''">and cm_shop_order.receiptStatus =
  2278. #{receiptStatus}
  2279. </if>
  2280. <if test="sendOutStatus != null and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
  2281. #{sendOutStatus}
  2282. </if>
  2283. <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
  2284. <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
  2285. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
  2286. #{receiveGoodsTime}
  2287. </if>
  2288. <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
  2289. </if>
  2290. <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
  2291. <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
  2292. <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
  2293. <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
  2294. <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
  2295. <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
  2296. <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
  2297. <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
  2298. <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
  2299. <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
  2300. <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
  2301. <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
  2302. <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
  2303. <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
  2304. <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
  2305. <if test="delFlag != null and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
  2306. <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
  2307. <if test="orderStatusFlag != null and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
  2308. #{orderStatusFlag}
  2309. </if>
  2310. <if test="buyStatus != null and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
  2311. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
  2312. #{deliveryTimeMills}
  2313. </if>
  2314. <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
  2315. <if test="splitFlag != null and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
  2316. <if test="paying != null and paying != ''">and cm_shop_order.paying = #{paying}</if>
  2317. <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
  2318. <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
  2319. <if test="shopPostFlag != null and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
  2320. </if>
  2321. <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
  2322. <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
  2323. <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
  2324. <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
  2325. <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
  2326. <if test="receiptedFlag != null and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
  2327. #{receiptedFlag}
  2328. </if>
  2329. <if test="receiptedType != null and receiptedType != ''">and cm_shop_order.receiptedType =
  2330. #{receiptedType}
  2331. </if>
  2332. <if test="costType != null and costType != ''">and cm_shop_order.costType = #{costType}</if>
  2333. <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
  2334. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
  2335. = #{modifyShouldPayNote}
  2336. </if>
  2337. <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
  2338. #{modifyShouldPayUserID}
  2339. </if>
  2340. <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
  2341. <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
  2342. <if test="differenceType != null and differenceType != ''">and cm_shop_order.differenceType =
  2343. #{differenceType}
  2344. </if>
  2345. <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
  2346. <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
  2347. <if test="splitCode != null and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
  2348. <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
  2349. <if test="onlinePayWays != null and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
  2350. #{onlinePayWays}
  2351. </if>
  2352. <if test="status != null and status != ''">and cm_shop_order.shopStatus = #{status}</if>
  2353. </where>
  2354. group by cm_shop_order.shopOrderID
  2355. limit 0,1
  2356. </select>
  2357. <select id="getShopOrderlist" resultType="com.caimei.modules.order.entity.NewShopOrder">
  2358. select cso.shopOrderID,
  2359. cso.shopOrderNo,
  2360. cso.orderId,
  2361. cso.orderNo,
  2362. cso.organizeID,
  2363. cso.userID,
  2364. cso.clubID,
  2365. cso.orderType,
  2366. bou.shouHuoRen AS receiver,
  2367. co.orderSource,
  2368. cso.needPayAmount,
  2369. cso.orderTime,
  2370. cso.confirmTime,
  2371. cso.payStatus,
  2372. cso.sendOutStatus,
  2373. cso.receiptStatus,
  2374. cso.refundStatus,
  2375. cso.shopStatus,
  2376. u.name AS buyer,
  2377. (case when co.orderType = '0' then
  2378. (select case status when 91 then '采美默认协销经理(官方账号)' else linkMan end from serviceprovider where serviceProviderID
  2379. = co.spID)
  2380. else
  2381. ''
  2382. end) AS spName,
  2383. co.rebateFlag,
  2384. cso.closeTime,
  2385. (SELECT COUNT(*) FROM cm_returned_purchase
  2386. WHERE shopOrderId = cso.shopOrderId AND status =1 AND delFLag = 0) AS returnedPurchaseStatus,
  2387. co.closeReason AS closeReason
  2388. from cm_shop_order cso
  2389. left join cm_order co on cso.orderId = co.orderId
  2390. left join bp_order_userinfo bou on bou.orderId = cso.orderId
  2391. <if test="productName != null and productName != ''">
  2392. LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
  2393. LEFT JOIN product p ON cop.productID = p.productID
  2394. </if>
  2395. LEFT JOIN user u ON u.userID = cso.userID
  2396. <where>
  2397. cso.delFlag = 0
  2398. and co.delflag = 0
  2399. and cso.orderType != 2
  2400. <if test="serviceProviderId != null and serviceProviderId != 0">
  2401. and cso.orderType = 0
  2402. and co.spID = #{serviceProviderId}
  2403. </if>
  2404. <if test="shopOrderNo != null and shopOrderNo != ''">
  2405. AND cso.shopOrderNo = #{shopOrderNo}
  2406. </if>
  2407. <if test="shopOrderID != null and shopOrderID != ''">
  2408. AND cso.shopOrderID = #{shopOrderID}
  2409. </if>
  2410. <if test="orderNo != null and orderNo != ''">
  2411. AND cso.orderNo = #{orderNo}
  2412. </if>
  2413. <if test="orderID != null and orderID != ''">
  2414. AND cso.orderID = #{orderID}
  2415. </if>
  2416. <if test="buyer != null and buyer != ''">
  2417. AND u.name LIKE concat('%',#{buyer},'%')
  2418. </if>
  2419. <if test="status != null">
  2420. AND cso.shopStatus = #{status}
  2421. </if>
  2422. <if test="productName != null and productName != ''">
  2423. and p.name like CONCAT('%',#{productName},'%')
  2424. </if>
  2425. <if test="receiptStatus != null and receiptStatus != ''">
  2426. AND cso.receiptStatus = #{receiptStatus}
  2427. </if>
  2428. <if test="sendOutStatus != null and sendOutStatus != ''">
  2429. AND cso.sendOutStatus = #{sendOutStatus}
  2430. </if>
  2431. <if test="payStatus != null and payStatus != ''">
  2432. AND cso.payStatus = #{payStatus}
  2433. </if>
  2434. <if test="refundStatus != null and refundStatus != ''">
  2435. AND cso.refundStatus = #{refundStatus}
  2436. </if>
  2437. <if test="orderType != null">
  2438. AND cso.orderType = #{orderType}
  2439. </if>
  2440. <if test="spID != null and spID != ''">
  2441. AND co.spId = #{spID}
  2442. </if>
  2443. <if test="rebateFlag != null and rebateFlag != ''">
  2444. AND co.rebateFlag = #{rebateFlag}
  2445. </if>
  2446. <if test="orderSource != null and orderSource != ''">
  2447. AND co.orderSource = #{orderSource}
  2448. </if>
  2449. <if test="organizeID != null and organizeID != ''">
  2450. AND cso.organizeID = #{organizeID}
  2451. </if>
  2452. <if test="receiver != null and receiver != ''">
  2453. AND bou.shouHuoRen LIKE concat('%',#{receiver},'%')
  2454. </if>
  2455. <if test="startTime != null and startTime != ''">
  2456. AND cso.orderTime <![CDATA[ >= ]]> #{startTime}
  2457. </if>
  2458. <if test="endTime != null and endTime != ''">
  2459. AND cso.orderTime <![CDATA[ <= ]]> #{endTime}
  2460. </if>
  2461. <if test="startConfirmTime != null and startConfirmTime != ''">
  2462. AND cso.confirmTime <![CDATA[ >= ]]> #{startConfirmTime}
  2463. </if>
  2464. <if test="endConfirmTime != null and endConfirmTime != ''">
  2465. AND cso.confirmTime <![CDATA[ <= ]]> #{endConfirmTime}
  2466. </if>
  2467. <if test="returnedPurchaseStatus != null and returnedPurchaseStatus != ''">
  2468. AND
  2469. <if test="returnedPurchaseStatus == 1">
  2470. exists
  2471. </if>
  2472. <if test="returnedPurchaseStatus == 0">
  2473. not exists
  2474. </if>
  2475. (select 1 from cm_returned_purchase
  2476. where status = 1 and shopOrderId = cso.shopOrderId and delFlag= 0)
  2477. </if>
  2478. </where>
  2479. ORDER BY cso.shopOrderID DESC
  2480. </select>
  2481. <select id="findCmProfit" resultType="com.caimei.modules.order.entity.OtherFeeDto">
  2482. select IF((SELECT SUM(cdr.receiptAmount)
  2483. FROM cm_discern_receipt cdr
  2484. LEFT JOIN cm_receipt_order_relation cror ON cdr.id = cror.receiptId
  2485. WHERE cdr.receiptType IN (10, 11)
  2486. AND cdr.receiptStatus NOT IN (1, 4, 5)
  2487. AND cdr.delflag = 0
  2488. AND cror.shopOrderId = acso.shopOrderId) > 0, 0,
  2489. (SELECT acso.needpayAmount
  2490. - SUM(IFNULL(op.costprice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
  2491. - SUM(IFNULL(op.organizeCostPrice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
  2492. - SUM(IFNULL(op.cmCostPrice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
  2493. - (IFNULL(SUM(acso.shopPostFee +
  2494. IF(acso.differenceType = 1, acso.differencePrice, 0) -
  2495. IF(acso.differenceType = 2, acso.differencePrice, 0)),
  2496. 0))
  2497. FROM cm_order_product op
  2498. WHERE op.shopOrderId = acso.shopOrderId)) as cmProfit,
  2499. acso.onlinePayWays,
  2500. ifnull(acso.cmAccountType,0) as cmAccountType
  2501. from cm_shop_order acso
  2502. where acso.shopOrderId = #{shopOrderId}
  2503. </select>
  2504. <insert id="addCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder" useGeneratedKeys="true"
  2505. keyProperty="shopOrderID">
  2506. insert into cm_shop_order
  2507. <trim prefix="(" suffix=")" suffixOverrides=",">
  2508. <if test="shopOrderID != null and shopOrderID != ''">shopOrderID,</if>
  2509. <if test="shopOrderNo != null and shopOrderNo != ''">shopOrderNo,</if>
  2510. <if test="orderNo != null and orderNo != ''">orderNo,</if>
  2511. <if test="orderID != null">orderID,</if>
  2512. <if test="organizeID != null">organizeID,</if>
  2513. <if test="isColdChina != null">isColdChina,</if>
  2514. <if test="userID != null">userID,</if>
  2515. <if test="shopID != null">shopID,</if>
  2516. <if test="orderPromotionsId != null">orderPromotionsId,</if>
  2517. <if test="orderType != null">orderType,</if>
  2518. <if test="orderSubmitType != null">orderSubmitType,</if>
  2519. <if test="presentNum != null">presentNum,</if>
  2520. <if test="itemCount != null">itemCount,</if>
  2521. <if test="outStoreNum != null">outStoreNum,</if>
  2522. <if test="outStoreTimes != null">outStoreTimes,</if>
  2523. <if test="townID != null">townID,</if>
  2524. <if test="note != null and note != ''">note,</if>
  2525. <if test="eachDiscount != null">eachDiscount,</if>
  2526. <if test="realPay != null">realPay,</if>
  2527. <if test="receiptAmount != null">receiptAmount,</if>
  2528. <if test="accountAmount != null">accountAmount,</if>
  2529. <if test="productAmount != null">productAmount,</if>
  2530. <if test="totalAmount != null">totalAmount,</if>
  2531. <if test="needPayAmount != null">needPayAmount,</if>
  2532. <if test="discountAmount != null">discountAmount,</if>
  2533. <if test="preferential != null">preferential,</if>
  2534. <if test="promotionFullReduction != null">promotionFullReduction,</if>
  2535. <if test="payFlag != null and payFlag != ''">payFlag,</if>
  2536. <if test="orderTime != null and orderTime != ''">orderTime,</if>
  2537. <if test="payTime != null and payTime != ''">payTime,</if>
  2538. <if test="finishTime != null and finishTime != ''">finishTime,</if>
  2539. <if test="autoOverTimeMills != null">autoOverTimeMills,</if>
  2540. <if test="settleStatus != null and settleStatus != ''">settleStatus,</if>
  2541. <if test="payStatus != null and payStatus != ''">payStatus,</if>
  2542. <if test="receiptStatus != null and receiptStatus != ''">receiptStatus,</if>
  2543. <if test="sendOutStatus != null and sendOutStatus != ''">sendOutStatus,</if>
  2544. <if test="refundStatus != null">refundStatus,</if>
  2545. <if test="returnGoodsStatus != null">returnGoodsStatus,</if>
  2546. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">receiveGoodsTime,</if>
  2547. <if test="autoReceiveTimeMills != null">autoReceiveTimeMills,</if>
  2548. <if test="totalAddedValueTax != null">totalAddedValueTax,</if>
  2549. <if test="canRefundAmount != null">canRefundAmount,</if>
  2550. <if test="refundAmount != null">refundAmount,</if>
  2551. <if test="clubID != null">clubID,</if>
  2552. <if test="spID != null">spID,</if>
  2553. <if test="mainSpID != null">mainSpID,</if>
  2554. <if test="orderBeanAmount != null">orderBeanAmount,</if>
  2555. <if test="useBeanAmount != null">useBeanAmount,</if>
  2556. <if test="useBeanFlag != null">useBeanFlag,</if>
  2557. <if test="canRefundFlag != null">canRefundFlag,</if>
  2558. <if test="useBalanceFlag != null">useBalanceFlag,</if>
  2559. <if test="canRefundBeans != null">canRefundBeans,</if>
  2560. <if test="freePostageFee != null">freePostageFee,</if>
  2561. <if test="freePostageTicketID != null">freePostageTicketID,</if>
  2562. <if test="brokerage != null">brokerage,</if>
  2563. <if test="delFlag != null and delFlag != ''">delFlag,</if>
  2564. <if test="refundsAmount != null">refundsAmount,</if>
  2565. <if test="orderStatusFlag != null and orderStatusFlag != ''">orderStatusFlag,</if>
  2566. <if test="buyStatus != null and buyStatus != ''">buyStatus,</if>
  2567. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">deliveryTimeMills,</if>
  2568. <if test="orderDeliveryID != null">orderDeliveryID,</if>
  2569. <if test="splitFlag != null and splitFlag != ''">splitFlag,</if>
  2570. <if test="paying != null and paying != ''">paying,</if>
  2571. <if test="shopProductAmount != null">shopProductAmount,</if>
  2572. <if test="shopPostFee != null">shopPostFee,</if>
  2573. <if test="shopPostFlag != null and shopPostFlag != ''">shopPostFlag,</if>
  2574. <if test="shopTaxFee != null">shopTaxFee,</if>
  2575. <if test="payCmAmount != null">payCmAmount,</if>
  2576. <if test="shouldPayShopAmount != null">shouldPayShopAmount,</if>
  2577. <if test="payedShopAmount != null">payedShopAmount,</if>
  2578. <if test="shopOtherFee != null">shopOtherFee,</if>
  2579. <if test="receiptedFlag != null and receiptedFlag != ''">receiptedFlag,</if>
  2580. <if test="receiptedType != null and receiptedType != ''">receiptedType,</if>
  2581. <if test="costType != null and costType != ''">costType,</if>
  2582. <if test="proportional != null">proportional,</if>
  2583. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">modifyShouldPayNote,</if>
  2584. <if test="modifyShouldPayUserID != null">modifyShouldPayUserID,</if>
  2585. <if test="modifyShouldPayDate != null">modifyShouldPayDate,</if>
  2586. <if test="zeroCostFlag != null">zeroCostFlag,</if>
  2587. <if test="differenceType != null and differenceType != ''">differenceType,</if>
  2588. <if test="differencePrice != null">differencePrice,</if>
  2589. <if test="svipShopReduction != null">svipShopReduction,</if>
  2590. <if test="splitCode != null and splitCode != ''">splitCode,</if>
  2591. <if test="paySuccessCounter != null">paySuccessCounter,</if>
  2592. <if test="onlinePayWays != null and onlinePayWays != ''">onlinePayWays,</if>
  2593. <if test="status != null and status != ''">shopStatus,</if>
  2594. </trim>
  2595. <trim prefix="values (" suffix=")" suffixOverrides=",">
  2596. <if test="shopOrderID != null and shopOrderID != ''">#{shopOrderID},</if>
  2597. <if test="shopOrderNo != null and shopOrderNo != ''">#{shopOrderNo},</if>
  2598. <if test="orderNo != null and orderNo != ''">#{orderNo},</if>
  2599. <if test="orderID != null">#{orderID},</if>
  2600. <if test="organizeID != null">#{organizeID},</if>
  2601. <if test="isColdChina != null">#{isColdChina},</if>
  2602. <if test="userID != null">#{userID},</if>
  2603. <if test="shopID != null">#{shopID},</if>
  2604. <if test="orderPromotionsId != null">#{orderPromotionsId},</if>
  2605. <if test="orderType != null">#{orderType},</if>
  2606. <if test="orderSubmitType != null">#{orderSubmitType},</if>
  2607. <if test="presentNum != null">#{presentNum},</if>
  2608. <if test="itemCount != null">#{itemCount},</if>
  2609. <if test="outStoreNum != null">#{outStoreNum},</if>
  2610. <if test="outStoreTimes != null">#{outStoreTimes},</if>
  2611. <if test="townID != null">#{townID},</if>
  2612. <if test="note != null and note != ''">#{note},</if>
  2613. <if test="eachDiscount != null">#{eachDiscount},</if>
  2614. <if test="realPay != null">#{realPay},</if>
  2615. <if test="receiptAmount != null">#{receiptAmount},</if>
  2616. <if test="accountAmount != null">#{accountAmount},</if>
  2617. <if test="productAmount != null">#{productAmount},</if>
  2618. <if test="totalAmount != null">#{totalAmount},</if>
  2619. <if test="needPayAmount != null">#{needPayAmount},</if>
  2620. <if test="discountAmount != null">#{discountAmount},</if>
  2621. <if test="preferential != null">#{preferential},</if>
  2622. <if test="promotionFullReduction != null">#{promotionFullReduction},</if>
  2623. <if test="payFlag != null and payFlag != ''">#{payFlag},</if>
  2624. <if test="orderTime != null and orderTime != ''">#{orderTime},</if>
  2625. <if test="payTime != null and payTime != ''">#{payTime},</if>
  2626. <if test="finishTime != null and finishTime != ''">#{finishTime},</if>
  2627. <if test="autoOverTimeMills != null">#{autoOverTimeMills},</if>
  2628. <if test="settleStatus != null and settleStatus != ''">#{settleStatus},</if>
  2629. <if test="payStatus != null and payStatus != ''">#{payStatus},</if>
  2630. <if test="receiptStatus != null and receiptStatus != ''">#{receiptStatus},</if>
  2631. <if test="sendOutStatus != null and sendOutStatus != ''">#{sendOutStatus},</if>
  2632. <if test="refundStatus != null">#{refundStatus},</if>
  2633. <if test="returnGoodsStatus != null">#{returnGoodsStatus},</if>
  2634. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">#{receiveGoodsTime},</if>
  2635. <if test="autoReceiveTimeMills != null">#{autoReceiveTimeMills},</if>
  2636. <if test="totalAddedValueTax != null">#{totalAddedValueTax},</if>
  2637. <if test="canRefundAmount != null">#{canRefundAmount},</if>
  2638. <if test="refundAmount != null">#{refundAmount},</if>
  2639. <if test="clubID != null">#{clubID},</if>
  2640. <if test="spID != null">#{spID},</if>
  2641. <if test="mainSpID != null">#{mainSpID},</if>
  2642. <if test="orderBeanAmount != null">#{orderBeanAmount},</if>
  2643. <if test="useBeanAmount != null">#{useBeanAmount},</if>
  2644. <if test="useBeanFlag != null">#{useBeanFlag},</if>
  2645. <if test="canRefundFlag != null">#{canRefundFlag},</if>
  2646. <if test="useBalanceFlag != null">#{useBalanceFlag},</if>
  2647. <if test="canRefundBeans != null">#{canRefundBeans},</if>
  2648. <if test="freePostageFee != null">#{freePostageFee},</if>
  2649. <if test="freePostageTicketID != null">#{freePostageTicketID},</if>
  2650. <if test="brokerage != null">#{brokerage},</if>
  2651. <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
  2652. <if test="refundsAmount != null">#{refundsAmount},</if>
  2653. <if test="orderStatusFlag != null and orderStatusFlag != ''">#{orderStatusFlag},</if>
  2654. <if test="buyStatus != null and buyStatus != ''">#{buyStatus},</if>
  2655. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">#{deliveryTimeMills},</if>
  2656. <if test="orderDeliveryID != null">#{orderDeliveryID},</if>
  2657. <if test="splitFlag != null and splitFlag != ''">#{splitFlag},</if>
  2658. <if test="paying != null and paying != ''">#{paying},</if>
  2659. <if test="shopProductAmount != null">#{shopProductAmount},</if>
  2660. <if test="shopPostFee != null">#{shopPostFee},</if>
  2661. <if test="shopPostFlag != null and shopPostFlag != ''">#{shopPostFlag},</if>
  2662. <if test="shopTaxFee != null">#{shopTaxFee},</if>
  2663. <if test="payCmAmount != null">#{payCmAmount},</if>
  2664. <if test="shouldPayShopAmount != null">#{shouldPayShopAmount},</if>
  2665. <if test="payedShopAmount != null">#{payedShopAmount},</if>
  2666. <if test="shopOtherFee != null">#{shopOtherFee},</if>
  2667. <if test="receiptedFlag != null and receiptedFlag != ''">#{receiptedFlag},</if>
  2668. <if test="receiptedType != null and receiptedType != ''">#{receiptedType},</if>
  2669. <if test="costType != null and costType != ''">#{costType},</if>
  2670. <if test="proportional != null">#{proportional},</if>
  2671. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">#{modifyShouldPayNote},</if>
  2672. <if test="modifyShouldPayUserID != null">#{modifyShouldPayUserID},</if>
  2673. <if test="modifyShouldPayDate != null">#{modifyShouldPayDate},</if>
  2674. <if test="zeroCostFlag != null">#{zeroCostFlag},</if>
  2675. <if test="differenceType != null and differenceType != ''">#{differenceType},</if>
  2676. <if test="differencePrice != null">#{differencePrice},</if>
  2677. <if test="svipShopReduction != null">#{svipShopReduction},</if>
  2678. <if test="splitCode != null and splitCode != ''">#{splitCode},</if>
  2679. <if test="paySuccessCounter != null">#{paySuccessCounter},</if>
  2680. <if test="onlinePayWays != null and onlinePayWays != ''">#{onlinePayWays},</if>
  2681. <if test="status != null and status != ''">#{status},</if>
  2682. </trim>
  2683. </insert>
  2684. <update id="updateCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder">
  2685. update cm_shop_order
  2686. <trim prefix="SET" suffixOverrides=",">
  2687. <if test="shopOrderNo != null and shopOrderNo != ''">shopOrderNo = #{shopOrderNo},</if>
  2688. <if test="orderNo != null and orderNo != ''">orderNo = #{orderNo},</if>
  2689. <if test="orderID != null">orderID = #{orderID},</if>
  2690. <if test="organizeID != null">organizeID = #{organizeID},</if>
  2691. <if test="isColdChina != null">isColdChina = #{isColdChina},</if>
  2692. <if test="userID != null">userID = #{userID},</if>
  2693. <if test="shopID != null">shopID = #{shopID},</if>
  2694. <if test="orderPromotionsId != null">orderPromotionsId = #{orderPromotionsId},</if>
  2695. <if test="orderType != null">orderType = #{orderType},</if>
  2696. <if test="orderSubmitType != null">orderSubmitType = #{orderSubmitType},</if>
  2697. <if test="presentNum != null">presentNum = #{presentNum},</if>
  2698. <if test="itemCount != null">itemCount = #{itemCount},</if>
  2699. <if test="outStoreNum != null">outStoreNum = #{outStoreNum},</if>
  2700. <if test="outStoreTimes != null">outStoreTimes = #{outStoreTimes},</if>
  2701. <if test="townID != null">townID = #{townID},</if>
  2702. <if test="note != null and note != ''">note = #{note},</if>
  2703. <if test="eachDiscount != null">eachDiscount = #{eachDiscount},</if>
  2704. <if test="realPay != null">realPay = #{realPay},</if>
  2705. <if test="receiptAmount != null">receiptAmount = #{receiptAmount},</if>
  2706. <if test="accountAmount != null">accountAmount = #{accountAmount},</if>
  2707. <if test="productAmount != null">productAmount = #{productAmount},</if>
  2708. <if test="totalAmount != null">totalAmount = #{totalAmount},</if>
  2709. <if test="needPayAmount != null">needPayAmount = #{needPayAmount},</if>
  2710. <if test="discountAmount != null">discountAmount = #{discountAmount},</if>
  2711. <if test="preferential != null">preferential = #{preferential},</if>
  2712. <if test="promotionFullReduction != null">promotionFullReduction = #{promotionFullReduction},</if>
  2713. <if test="payFlag != null and payFlag != ''">payFlag = #{payFlag},</if>
  2714. <if test="orderTime != null and orderTime != ''">orderTime = #{orderTime},</if>
  2715. <if test="payTime != null and payTime != ''">payTime = #{payTime},</if>
  2716. <if test="finishTime != null and finishTime != ''">finishTime = #{finishTime},</if>
  2717. <if test="autoOverTimeMills != null">autoOverTimeMills = #{autoOverTimeMills},</if>
  2718. <if test="settleStatus != null and settleStatus != ''">settleStatus = #{settleStatus},</if>
  2719. <if test="payStatus != null and payStatus != ''">payStatus = #{payStatus},</if>
  2720. <if test="receiptStatus != null and receiptStatus != ''">receiptStatus = #{receiptStatus},</if>
  2721. <if test="sendOutStatus != null and sendOutStatus != ''">sendOutStatus = #{sendOutStatus},</if>
  2722. <if test="refundStatus != null">refundStatus = #{refundStatus},</if>
  2723. <if test="returnGoodsStatus != null">returnGoodsStatus = #{returnGoodsStatus},</if>
  2724. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">receiveGoodsTime = #{receiveGoodsTime},</if>
  2725. <if test="autoReceiveTimeMills != null">autoReceiveTimeMills = #{autoReceiveTimeMills},</if>
  2726. <if test="totalAddedValueTax != null">totalAddedValueTax = #{totalAddedValueTax},</if>
  2727. <if test="canRefundAmount != null">canRefundAmount = #{canRefundAmount},</if>
  2728. <if test="refundAmount != null">refundAmount = #{refundAmount},</if>
  2729. <if test="clubID != null">clubID = #{clubID},</if>
  2730. <if test="spID != null">spID = #{spID},</if>
  2731. <if test="mainSpID != null">mainSpID = #{mainSpID},</if>
  2732. <if test="orderBeanAmount != null">orderBeanAmount = #{orderBeanAmount},</if>
  2733. <if test="useBeanAmount != null">useBeanAmount = #{useBeanAmount},</if>
  2734. <if test="useBeanFlag != null">useBeanFlag = #{useBeanFlag},</if>
  2735. <if test="canRefundFlag != null">canRefundFlag = #{canRefundFlag},</if>
  2736. <if test="useBalanceFlag != null">useBalanceFlag = #{useBalanceFlag},</if>
  2737. <if test="canRefundBeans != null">canRefundBeans = #{canRefundBeans},</if>
  2738. <if test="freePostageFee != null">freePostageFee = #{freePostageFee},</if>
  2739. <if test="freePostageTicketID != null">freePostageTicketID = #{freePostageTicketID},</if>
  2740. <if test="brokerage != null">brokerage = #{brokerage},</if>
  2741. <if test="delFlag != null and delFlag != ''">delFlag = #{delFlag},</if>
  2742. <if test="refundsAmount != null">refundsAmount = #{refundsAmount},</if>
  2743. <if test="orderStatusFlag != null and orderStatusFlag != ''">orderStatusFlag = #{orderStatusFlag},</if>
  2744. <if test="buyStatus != null and buyStatus != ''">buyStatus = #{buyStatus},</if>
  2745. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">deliveryTimeMills = #{deliveryTimeMills},
  2746. </if>
  2747. <if test="orderDeliveryID != null">orderDeliveryID = #{orderDeliveryID},</if>
  2748. <if test="splitFlag != null and splitFlag != ''">splitFlag = #{splitFlag},</if>
  2749. <if test="paying != null and paying != ''">paying = #{paying},</if>
  2750. <if test="shopProductAmount != null">shopProductAmount = #{shopProductAmount},</if>
  2751. <if test="shopPostFee != null">shopPostFee = #{shopPostFee},</if>
  2752. <if test="shopPostFlag != null and shopPostFlag != ''">shopPostFlag = #{shopPostFlag},</if>
  2753. <if test="shopTaxFee != null">shopTaxFee = #{shopTaxFee},</if>
  2754. <if test="payCmAmount != null">payCmAmount = #{payCmAmount},</if>
  2755. <if test="shouldPayShopAmount != null">shouldPayShopAmount = #{shouldPayShopAmount},</if>
  2756. <if test="payedShopAmount != null">payedShopAmount = #{payedShopAmount},</if>
  2757. <if test="shopOtherFee != null">shopOtherFee = #{shopOtherFee},</if>
  2758. <if test="receiptedFlag != null and receiptedFlag != ''">receiptedFlag = #{receiptedFlag},</if>
  2759. <if test="receiptedType != null and receiptedType != ''">receiptedType = #{receiptedType},</if>
  2760. <if test="costType != null and costType != ''">costType = #{costType},</if>
  2761. <if test="proportional != null">proportional = #{proportional},</if>
  2762. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">modifyShouldPayNote =
  2763. #{modifyShouldPayNote},
  2764. </if>
  2765. <if test="modifyShouldPayUserID != null">modifyShouldPayUserID = #{modifyShouldPayUserID},</if>
  2766. <if test="modifyShouldPayDate != null">modifyShouldPayDate = #{modifyShouldPayDate},</if>
  2767. <if test="zeroCostFlag != null">zeroCostFlag = #{zeroCostFlag},</if>
  2768. <if test="differenceType != null and differenceType != ''">differenceType = #{differenceType},</if>
  2769. <if test="differencePrice != null">differencePrice = #{differencePrice},</if>
  2770. <if test="svipShopReduction != null">svipShopReduction = #{svipShopReduction},</if>
  2771. <if test="splitCode != null and splitCode != ''">splitCode = #{splitCode},</if>
  2772. <if test="paySuccessCounter != null">paySuccessCounter = #{paySuccessCounter},</if>
  2773. <if test="onlinePayWays != null and onlinePayWays != ''">onlinePayWays = #{onlinePayWays},</if>
  2774. <if test="status != null and status != ''">shopStatus = #{status},</if>
  2775. </trim>
  2776. where shopOrderID = #{shopOrderID}
  2777. </update>
  2778. <update id="updateDelCmShopOrderByShopOrderIDs" parameterType="String">
  2779. update cm_shop_order set delFlag=#{delFlag} where shopOrderID in
  2780. <foreach item="shopOrderID" collection="shopOrderIDs" open="(" separator="," close=")">
  2781. #{shopOrderID}
  2782. </foreach>
  2783. </update>
  2784. <update id="updateStatus">
  2785. UPDATE cm_shop_order
  2786. SET shopStatus = #{status},
  2787. closeTime = NOW(),
  2788. closeReason = #{closeReason}
  2789. WHERE shopOrderID = #{shopOrderID}
  2790. </update>
  2791. <delete id="delCmShopOrderByShopOrderID" parameterType="String">
  2792. delete
  2793. from cm_shop_order
  2794. where shopOrderID = #{shopOrderID}
  2795. </delete>
  2796. <delete id="delCmShopOrderByShopOrderIDs" parameterType="String">
  2797. delete from cm_shop_order where shopOrderID in
  2798. <foreach item="shopOrderID" collection="shopOrderIDs" open="(" separator="," close=")">
  2799. #{shopOrderID}
  2800. </foreach>
  2801. </delete>
  2802. </mapper>