ShopOrderMapper.xml 155 KB

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