ShopOrderMapper.xml 168 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192
  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.shopOrderId = a.shopOrderId and cror.delFlag = 0
  752. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id and cdr.delFlag = 0
  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 IF(EXISTS(SELECT splitStatus
  1006. FROM cm_receipt_order_relation
  1007. WHERE shopOrderId = #{shopOrderId} AND splitStatus = 1),
  1008. (SELECT SUM(csa.splitAccount)
  1009. FROM cm_split_account csa
  1010. WHERE csa.type = 4 AND csa.shopOrderId = #{shopOrderId}),
  1011. IFNULL(SUM(cpsr.payCmAmount), 0))
  1012. FROM cm_pay_shop cps
  1013. LEFT JOIN cm_pay_shop_record cpsr ON cps.id = cpsr.payShopID
  1014. WHERE cpsr.delFlag = 0
  1015. AND cpsr.shopOrderID = #{shopOrderId}
  1016. </select>
  1017. <select id="returnedPurchaseFeeByShopOrderId" resultType="java.lang.Double">
  1018. SELECT IFNULL(SUM(crp.returnedPurchaseFee), 0)
  1019. FROM cm_returned_purchase crp
  1020. LEFT JOIN cm_returned_purchase_product crpp ON crp.id = crpp.returnedID
  1021. WHERE crp.delFlag = 0
  1022. AND crp.status = 2
  1023. AND crp.shopOrderId = #{shopOrderId}
  1024. </select>
  1025. <select id="findSplitCount" resultType="java.lang.Integer">
  1026. SELECT COUNT(*)
  1027. FROM cm_split_account
  1028. WHERE shopOrderId = #{shopOrderId}
  1029. </select>
  1030. <select id="findPayOrderListByIDs" resultType="newShopOrder">
  1031. select distinct<include refid="shopOrderColumns"/>,
  1032. co.payTotalFee AS payTotalFee,
  1033. co.promotionFullReduction,
  1034. ifnull(a.cmShopOtherFee,0) as cmShopOtherFee,
  1035. ifnull(a.cmAccountType,0) as cmAccountType,
  1036. bou.name AS buyer,
  1037. ifnull(a.supplierFreight,0) as supplierFreight,
  1038. ifnull(a.rebateOrder,0) as rebateOrder,
  1039. s.name AS shopName,
  1040. (select sum((num+presentNum)*cmCostPrice) from cm_order_product where shopOrderId = a.shopOrderId) as
  1041. allServeAmount
  1042. from cm_shop_order a
  1043. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  1044. left join bp_order_userinfo bou on bou.orderId = a.orderID
  1045. left join cm_order co on co.orderID = a.orderID
  1046. left join shop s on s.shopID = a.shopID
  1047. <where>
  1048. <if test="ids != null and ids != ''">
  1049. and a.shopOrderID in
  1050. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  1051. #{id}
  1052. </foreach>
  1053. </if>
  1054. </where>
  1055. ORDER BY a.shopOrderID DESC
  1056. </select>
  1057. <select id="findByRefundID" resultType="newShopOrder">
  1058. select distinct<include refid="shopOrderColumns"/>,
  1059. co.payTotalFee AS payTotalFee,
  1060. bou.name AS buyer,
  1061. s.name AS shopName
  1062. from cm_shop_order a
  1063. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  1064. left join bp_order_userinfo bou on bou.orderId = a.orderID
  1065. left join cm_order co on co.orderID = a.orderID
  1066. left join shop s on s.shopID = a.shopID
  1067. where a.shopOrderID in
  1068. (select crsr.shopOrderID
  1069. from cm_refund_shop_record crsr
  1070. left join cm_refund_shop crs on crsr.refundShopID = crs.id
  1071. where crs.id = #{refundShopID} and crsr.shopOrderID is not null)
  1072. ORDER BY a.shopOrderID DESC
  1073. </select>
  1074. <select id="updatePayShopAmount">
  1075. UPDATE cm_shop_order
  1076. <set>
  1077. <if test="shopProductAmount != null">
  1078. shopProductAmount = #{shopProductAmount},
  1079. </if>
  1080. <if test="shopPostFee != null">
  1081. shopPostFee = #{shopPostFee},
  1082. </if>
  1083. <if test="shopTaxFee != null">
  1084. shopTaxFee = #{shopTaxFee},
  1085. </if>
  1086. <if test="shouldPayShopAmount != null">
  1087. shouldPayShopAmount = #{shouldPayShopAmount},
  1088. </if>
  1089. <if test="shopOtherFee != null">
  1090. shopOtherFee = #{shopOtherFee},
  1091. </if>
  1092. <if test="payStatus != null">
  1093. payStatus = #{payStatus},
  1094. </if>
  1095. <if test="payedShopAmount != null">
  1096. payedShopAmount = #{payedShopAmount}
  1097. </if>
  1098. <if test="status != null and status != ''">
  1099. shopStatus = #{status},
  1100. </if>
  1101. </set>
  1102. WHERE shopOrderID = #{shopOrderID}
  1103. </select>
  1104. <select id="findByShopOrderIDs" resultType="newShopOrder">
  1105. select distinct
  1106. co.rebateFee as rebateFee,
  1107. co.userBeans as userBeans,
  1108. a.shopOrderID AS shopOrderID,
  1109. a.shopStatus AS status,
  1110. a.shopPostFlag AS shopPostFlag,
  1111. a.orderID AS orderID,
  1112. a.organizeID AS organizeID,
  1113. a.shopOrderNo AS shopOrderNo,
  1114. a.orderNo AS orderNo,
  1115. a.userID AS userID,
  1116. a.shopID AS shopID,
  1117. a.isColdChina AS isColdChina,
  1118. a.itemCount AS itemCount,
  1119. a.townID AS townID,
  1120. a.productAmount AS productAmount,
  1121. a.discountAmount AS discountAmount,
  1122. a.accountAmount AS accountAmount,
  1123. a.totalAmount AS totalAmount,
  1124. a.payFlag AS payFlag,
  1125. a.payTime AS payTime,
  1126. a.finishTime AS finishTime,
  1127. a.refundStatus AS refundStatus,
  1128. a.needPayAmount AS needPayAmount,
  1129. a.splitCode,
  1130. ifnull(a.realPay, a.needPayAmount) AS realPay,
  1131. a.eachDiscount AS eachDiscount,
  1132. IFNULL((SELECT SUM(cror.associateAmount)
  1133. FROM cm_receipt_order_relation cror
  1134. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  1135. WHERE cror.shopOrderId = a.shopOrderId
  1136. AND cror.relationType = '2'
  1137. AND cdr.receiptType = 1
  1138. AND cdr.delFlag = 0
  1139. AND cror.delFlag = 0
  1140. AND cdr.receiptStatus IN (2, 3)
  1141. AND cdr.payWay != 3)
  1142. , 0) AS receiptAmount,
  1143. (ifnull(a.realPay,a.needPayAmount) - ifnull(a.receiptAmount,0)) as restAmount,
  1144. a.receiptStatus as shopReceiptStatus,
  1145. a.receiptStatus as ReceiptStatus,
  1146. a.canRefundAmount AS canRefundAmount,
  1147. a.refundAmount AS refundAmount,
  1148. a.clubID AS clubID,
  1149. a.spID AS spID,
  1150. a.mainSpID AS mainSpID,
  1151. a.orderBeanAmount AS orderBeanAmount,
  1152. a.useBeanAmount AS useBeanAmount,
  1153. a.useBeanFlag AS useBeanFlag,
  1154. a.canRefundFlag AS canRefundFlag,
  1155. a.useBalanceFlag AS useBalanceFlag,
  1156. a.canRefundBeans AS canRefundBeans,
  1157. a.freePostageFee AS freePostageFee,
  1158. a.freePostageTicketID AS freePostageTicketID,
  1159. a.brokerage AS brokerage,
  1160. a.delFlag AS delFlag,
  1161. a.refundsAmount AS refundsAmount,
  1162. a.orderStatusFlag AS orderStatusFlag,
  1163. a.buyStatus AS buyStatus,
  1164. a.orderSubmitType AS orderSubmitType,
  1165. a.orderType AS orderType,
  1166. a.orderTime AS orderTime,
  1167. a.deliveryTimeMills AS deliveryTimeMills,
  1168. a.presentNum AS presentNum,
  1169. a.preferential AS preferential,
  1170. a.outStoreNum AS outStoreNum,
  1171. IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
  1172. a.splitFlag AS splitFlag,
  1173. a.autoReceiveTimeMills AS autoReceiveTimeMills,
  1174. a.autoOverTimeMills AS autoOverTimeMills,
  1175. a.receiveGoodsTime AS receiveGoodsTime,
  1176. a.totalAddedValueTax AS totalAddedValueTax,
  1177. a.note AS note,
  1178. a.payStatus AS payStatus,
  1179. a.sendOutStatus AS sendOutStatus,
  1180. a.shopProductAmount AS shopProductAmount,
  1181. ifnull(a.shopPostFee, 0) AS shopPostFee,
  1182. ifnull(a.shopTaxFee,0) AS shopTaxFee,
  1183. a.shouldPayShopAmount AS shouldPayShopAmount,
  1184. a.payedShopAmount AS payedShopAmount,
  1185. a.paying AS paying,
  1186. a.costType AS costType,
  1187. a.settleStatus AS settleStatus,
  1188. a.modifyShouldPayNote AS modifyShouldPayNote,
  1189. a.orderPromotionsId AS orderPromotionsId,
  1190. a.differenceType AS differenceType,
  1191. a.differencePrice AS differencePrice,
  1192. a.proportional AS proportional,
  1193. ifnull(a.promotionFullReduction, 0) As promotionFullReduction,
  1194. ifnull(a.couponAmount, 0) As couponAmount,
  1195. a.zeroCostFlag AS zeroCostFlag,
  1196. co.payTotalFee AS payTotalFee,
  1197. co.promotionFullReduction AS promotionFullReduction,
  1198. a.onlinePayWays,
  1199. ifnull(a.cmAccountType,0) as cmAccountType,
  1200. ifnull(IF(cpsr.status!=1 AND paymentType=3,cpsr.payAmount,a.shopOtherFee), 0) AS shopOtherFee,
  1201. ifnull(IF(cpsr.status!=1 AND paymentType=3,cpsr.payCmAmount,a.cmShopOtherFee),0) AS cmShopOtherFee,
  1202. ifnull(a.supplierFreight,0) as supplierFreight,
  1203. ifnull(a.rebateOrder,0) as rebateOrder,
  1204. bou.name AS buyer,
  1205. s.name AS shopName,
  1206. c.name AS clubName
  1207. from cm_shop_order a
  1208. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  1209. left join bp_order_userinfo bou on bou.orderId = a.orderID
  1210. left join cm_order co on co.orderID = a.orderID
  1211. left join shop s on s.shopID = a.shopID
  1212. left join club c on c.userID = a.userID
  1213. <if test="shopOrderIDs != null and shopOrderIDs.size() > 0">
  1214. where a.shopOrderID in
  1215. <foreach collection="shopOrderIDs" separator="," item="shopOrderID" open="(" close=")">
  1216. #{shopOrderID}
  1217. </foreach>
  1218. </if>
  1219. <if test="payShopId != null and payShopId != ''">
  1220. and cpsr.payShopId = #{payShopId}
  1221. </if>
  1222. group by a.shopOrderID
  1223. </select>
  1224. <update id="updatePaying">
  1225. update cm_shop_order
  1226. set paying = #{paying}
  1227. where shopOrderID = #{shopOrderID}
  1228. </update>
  1229. <update id="outPaying">
  1230. update cm_shop_order
  1231. set paying = '0'
  1232. where shopOrderID in
  1233. (select cpsr.shopOrderID
  1234. from cm_pay_shop_record cpsr
  1235. left join cm_pay_shop cps on cps.id = cpsr.payShopID
  1236. where cps.id = #{payShopID}
  1237. and cps.delFlag = '0'
  1238. and cpsr.delFlag = '0'
  1239. and cpsr.shopOrderID is not null)
  1240. </update>
  1241. <update id="inPaying">
  1242. update cm_shop_order
  1243. set paying = '1'
  1244. where shopOrderID in
  1245. (select cpsr.shopOrderID
  1246. from cm_pay_shop_record cpsr
  1247. left join cm_pay_shop cps on cps.id = cpsr.payShopID
  1248. where cps.id = #{payShopID}
  1249. and cps.delFlag = '0'
  1250. and cpsr.delFlag = '0'
  1251. and cpsr.shopOrderID is not null)
  1252. </update>
  1253. <update id="updatePayStatus">
  1254. update cm_shop_order
  1255. set payStatus = #{payStatus}
  1256. where shopOrderID = #{shopOrderID}
  1257. </update>
  1258. <select id="findPayStatusByOrderID" resultType="string">
  1259. select payStatus
  1260. from cm_shop_order
  1261. where orderID = #{orderID}
  1262. AND shopID != 998
  1263. </select>
  1264. <select id="getPayingStatus" resultType="string">
  1265. select ifnull(paying, '0')
  1266. from cm_shop_order
  1267. where shopOrderID in
  1268. (select cpsr.shopOrderID
  1269. from cm_pay_shop_record cpsr
  1270. left join cm_pay_shop cps on cps.id = cpsr.payShopID
  1271. where cps.id = #{payShopID}
  1272. and cps.delFlag = '0'
  1273. and cpsr.delFlag = '0'
  1274. and cpsr.shopOrderID is not null)
  1275. </select>
  1276. <select id="findSiblingPostFeeOrder" resultType="newShopOrder">
  1277. select
  1278. <include refid="shopOrderColumns"/>
  1279. from cm_shop_order a
  1280. left join cm_order co on co.orderID = a.orderID
  1281. where a.orderID = #{orderID} and a.shopID = 998
  1282. </select>
  1283. <select id="findShopOrderNos" resultType="java.lang.String">
  1284. SELECT CONCAT(shopOrderNo, '(', shopOrderID, ')') AS result
  1285. FROM cm_shop_order
  1286. WHERE orderID = #{orderID}
  1287. and shopId != 998
  1288. </select>
  1289. <select id="findIncome" resultType="java.lang.Double">
  1290. SELECT ROUND(IFNULL((
  1291. co.payTotalFee - (IFNULL((SELECT ROUND(SUM((IFNULL(op.costPrice, 0) *
  1292. (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0))) +
  1293. IFNULL(op.shouldPayTotalTax, 0)),
  1294. 2)
  1295. FROM cm_order_product op
  1296. LEFT JOIN cm_shop_order cso ON cso.shopOrderID = op.shopOrderID
  1297. WHERE cso.orderID = co.orderID
  1298. AND op.productID != 999
  1299. GROUP BY cso.orderID), 0))
  1300. - (SELECT IFNULL(SUM(cso.shopOtherFee), 0)
  1301. FROM cm_shop_order cso
  1302. WHERE cso.orderID = co.orderID)
  1303. - IFNULL((SELECT SUM(shopPostFee + IF(differenceType = 1, differencePrice, 0) -
  1304. IF(differenceType = 2, differencePrice, 0))
  1305. FROM cm_shop_order
  1306. WHERE orderID = co.orderID), 0)
  1307. + IFNULL((SELECT SUM(cpsr.wipePayment)
  1308. FROM cm_pay_shop_record cpsr
  1309. WHERE cpsr.shopOrderID IN (SELECT cso.shopOrderID
  1310. FROM cm_shop_order cso
  1311. WHERE cso.orderID = co.orderID)
  1312. AND cpsr.delFlag = 0
  1313. AND (cpsr.`status` = 1 OR cpsr.`status` = 0)), 0)
  1314. + IFNULL(co.rebateFee, 0)
  1315. ), 0), 2) AS "采美总佣金"
  1316. FROM cm_order co
  1317. WHERE co.orderID = #{orderID}
  1318. </select>
  1319. <update id="updateByShopOtherFee">
  1320. UPDATE cm_shop_order
  1321. SET shopOtherFee = #{shopOtherFee},
  1322. cmShopOtherFee = #{profit}
  1323. WHERE shopOrderID = #{shopOrderId}
  1324. </update>
  1325. <update id="updateByDifferencePrice">
  1326. UPDATE cm_shop_order
  1327. SET differenceType = #{type},
  1328. differencePrice = #{differencePrice}
  1329. WHERE shopOrderID = #{shopOrderId}
  1330. </update>
  1331. <select id="findSplitList" resultType="newShopOrder">
  1332. SELECT co.couponAmount AS couponAmount,
  1333. co.userBeans AS userBeans,
  1334. a.shopOrderID AS shopOrderID,
  1335. a.orderID AS orderID,
  1336. a.organizeID AS organizeID,
  1337. a.shopOrderNo AS shopOrderNo,
  1338. a.orderNo AS orderNo,
  1339. a.userID AS userID,
  1340. a.shopID AS shopID,
  1341. a.itemCount AS itemCount,
  1342. a.townID AS townID,
  1343. a.productAmount AS productAmount,
  1344. a.discountAmount AS discountAmount,
  1345. a.accountAmount AS accountAmount,
  1346. a.totalAmount AS totalAmount,
  1347. a.payFlag AS payFlag,
  1348. a.payTime AS payTime,
  1349. a.finishTime AS finishTime,
  1350. a.refundStatus AS refundStatus,
  1351. a.needPayAmount AS needPayAmount,
  1352. a.canRefundAmount AS canRefundAmount,
  1353. a.refundAmount AS refundAmount,
  1354. a.clubID AS clubID,
  1355. a.spID AS spID,
  1356. a.mainSpID AS mainSpID,
  1357. a.orderBeanAmount AS orderBeanAmount,
  1358. a.useBeanAmount AS useBeanAmount,
  1359. a.useBeanFlag AS useBeanFlag,
  1360. a.canRefundFlag AS canRefundFlag,
  1361. a.useBalanceFlag AS useBalanceFlag,
  1362. a.canRefundBeans AS canRefundBeans,
  1363. a.freePostageFee AS freePostageFee,
  1364. a.freePostageTicketID AS freePostageTicketID,
  1365. a.brokerage AS brokerage,
  1366. a.delFlag AS delFlag,
  1367. a.refundsAmount AS refundsAmount,
  1368. a.orderStatusFlag AS orderStatusFlag,
  1369. a.buyStatus AS buyStatus,
  1370. a.orderSubmitType AS orderSubmitType,
  1371. a.orderType AS orderType,
  1372. a.orderTime AS orderTime,
  1373. a.deliveryTimeMills AS deliveryTimeMills,
  1374. a.presentNum AS presentNum,
  1375. a.preferential AS preferential,
  1376. a.outStoreNum AS outStoreNum,
  1377. IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
  1378. a.splitFlag AS splitFlag,
  1379. a.autoReceiveTimeMills AS autoReceiveTimeMills,
  1380. a.autoOverTimeMills AS autoOverTimeMills,
  1381. a.receiveGoodsTime AS receiveGoodsTime,
  1382. a.totalAddedValueTax AS totalAddedValueTax,
  1383. a.note AS note,
  1384. a.payStatus AS payStatus,
  1385. a.sendOutStatus AS sendOutStatus,
  1386. a.shopProductAmount AS shopProductAmount,
  1387. a.shopPostFee AS shopPostFee,
  1388. a.shopTaxFee AS shopTaxFee,
  1389. a.shouldPayShopAmount AS shouldPayShopAmount,
  1390. a.payedShopAmount AS payedShopAmount,
  1391. a.shopOtherFee AS shopOtherFee,
  1392. a.paying AS paying,
  1393. a.costType AS costType,
  1394. a.modifyShouldPayNote AS modifyShouldPayNote,
  1395. a.orderPromotionsId AS orderPromotionsId,
  1396. a.differenceType AS differenceType,
  1397. a.differencePrice AS differencePrice,
  1398. a.proportional AS proportional,
  1399. a.promotionFullReduction AS promotionFullReduction,
  1400. a.zeroCostFlag AS zeroCostFlag,
  1401. co.payTotalFee AS payTotalFee,
  1402. co.status AS STATUS,
  1403. bou.name AS buyer,
  1404. s.name AS shopName,
  1405. c.name AS clubName,
  1406. a.onlinePayWays,
  1407. ifnull(a.cmShopOtherFee, 0) as cmShopOtherFee,
  1408. ifnull(a.cmAccountType, 0) as cmAccountType
  1409. FROM cm_shop_order a
  1410. LEFT JOIN cm_pay_shop_record cpsr ON a.shopOrderID = cpsr.shopOrderID
  1411. LEFT JOIN bp_order_userinfo bou ON bou.orderId = a.orderID
  1412. LEFT JOIN cm_order co ON co.orderID = a.orderID
  1413. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
  1414. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  1415. LEFT JOIN shop s ON s.shopID = a.shopID
  1416. LEFT JOIN club c ON c.userID = a.userID
  1417. WHERE co.organizeID = 0
  1418. AND a.refundStatus = 1
  1419. AND co.delFlag = 0
  1420. AND co.orderType != 2
  1421. AND a.delFlag = 0
  1422. AND a.shopID != 998
  1423. AND (a.organizeID != 4 or a.organizeID is null)
  1424. AND cdr.payWay = 1
  1425. AND cdr.receiptDate <![CDATA[ <= ]]> NOW()
  1426. AND cror.relationType = 2
  1427. AND cror.delFlag = 0
  1428. AND cror.mbOrderId IS NOT NULL
  1429. AND cror.splitStatus = 0
  1430. AND a.receiptStatus = 3
  1431. AND a.splitCode != 'E1807059160'
  1432. AND co.orderID NOT IN (SELECT orderID
  1433. FROM cm_order_product
  1434. WHERE productID IN
  1435. (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069)
  1436. GROUP BY orderID)
  1437. GROUP BY a.shopOrderID
  1438. ORDER BY a.shopOrderID DESC
  1439. </select>
  1440. <select id="getOpenidListByPermission" resultType="java.lang.String">
  1441. SELECT openid
  1442. FROM `wechat_user`
  1443. WHERE unionid = #{unionid}
  1444. </select>
  1445. <select id="FromUnionId" resultType="java.lang.String">
  1446. SELECT unionID
  1447. FROM `cm_order`
  1448. WHERE orderID = #{orderId}
  1449. </select>
  1450. <select id="UnionId" resultType="java.lang.String">
  1451. SELECT unionID
  1452. FROM `cm_order`
  1453. WHERE userID = #{userID}
  1454. ORDER BY orderID DESC
  1455. LIMIT 1
  1456. </select>
  1457. <select id="getProductOrder" resultType="java.lang.String">
  1458. SELECT productID
  1459. FROM `cm_order_product`
  1460. WHERE orderID = #{orderid}
  1461. </select>
  1462. <select id="payWay" resultType="java.lang.Integer">
  1463. SELECT cdr.payWay
  1464. FROM cm_shop_order a
  1465. LEFT JOIN cm_order co ON co.orderID = a.orderID
  1466. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
  1467. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  1468. WHERE a.shopOrderID = #{shopOrderID}
  1469. </select>
  1470. <select id="findSettlementList" resultType="com.caimei.modules.order.entity.NewShopOrder">
  1471. SELECT co.couponAmount AS couponAmount,
  1472. co.userBeans AS userBeans,
  1473. a.shopOrderID AS shopOrderID,
  1474. a.orderID AS orderID,
  1475. a.organizeID AS organizeID,
  1476. a.shopOrderNo AS shopOrderNo,
  1477. a.orderNo AS orderNo,
  1478. a.userID AS userID,
  1479. a.shopID AS shopID,
  1480. a.itemCount AS itemCount,
  1481. a.townID AS townID,
  1482. a.productAmount AS productAmount,
  1483. a.discountAmount AS discountAmount,
  1484. a.accountAmount AS accountAmount,
  1485. a.totalAmount AS totalAmount,
  1486. a.payFlag AS payFlag,
  1487. a.payTime AS payTime,
  1488. a.finishTime AS finishTime,
  1489. a.refundStatus AS refundStatus,
  1490. a.needPayAmount AS needPayAmount,
  1491. a.canRefundAmount AS canRefundAmount,
  1492. a.refundAmount AS refundAmount,
  1493. a.clubID AS clubID,
  1494. a.spID AS spID,
  1495. a.mainSpID AS mainSpID,
  1496. a.orderBeanAmount AS orderBeanAmount,
  1497. a.useBeanAmount AS useBeanAmount,
  1498. a.useBeanFlag AS useBeanFlag,
  1499. a.canRefundFlag AS canRefundFlag,
  1500. a.useBalanceFlag AS useBalanceFlag,
  1501. a.canRefundBeans AS canRefundBeans,
  1502. a.freePostageFee AS freePostageFee,
  1503. a.freePostageTicketID AS freePostageTicketID,
  1504. a.brokerage AS brokerage,
  1505. a.delFlag AS delFlag,
  1506. a.refundsAmount AS refundsAmount,
  1507. a.orderStatusFlag AS orderStatusFlag,
  1508. a.buyStatus AS buyStatus,
  1509. a.orderSubmitType AS orderSubmitType,
  1510. a.orderType AS orderType,
  1511. a.orderTime AS orderTime,
  1512. a.deliveryTimeMills AS deliveryTimeMills,
  1513. a.presentNum AS presentNum,
  1514. a.preferential AS preferential,
  1515. a.outStoreNum AS outStoreNum,
  1516. IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
  1517. a.splitFlag AS splitFlag,
  1518. a.autoReceiveTimeMills AS autoReceiveTimeMills,
  1519. a.autoOverTimeMills AS autoOverTimeMills,
  1520. a.receiveGoodsTime AS receiveGoodsTime,
  1521. a.totalAddedValueTax AS totalAddedValueTax,
  1522. a.note AS note,
  1523. a.payStatus AS payStatus,
  1524. a.sendOutStatus AS sendOutStatus,
  1525. a.shopProductAmount AS shopProductAmount,
  1526. a.shopPostFee AS shopPostFee,
  1527. a.shopTaxFee AS shopTaxFee,
  1528. a.shouldPayShopAmount AS shouldPayShopAmount,
  1529. a.payedShopAmount AS payedShopAmount,
  1530. a.shopOtherFee AS shopOtherFee,
  1531. a.paying AS paying,
  1532. a.costType AS costType,
  1533. a.modifyShouldPayNote AS modifyShouldPayNote,
  1534. a.orderPromotionsId AS orderPromotionsId,
  1535. a.differenceType AS differenceType,
  1536. a.differencePrice AS differencePrice,
  1537. a.proportional AS proportional,
  1538. a.promotionFullReduction AS promotionFullReduction,
  1539. a.zeroCostFlag AS zeroCostFlag,
  1540. a.settleStatus AS settleStatus,
  1541. co.payTotalFee AS payTotalFee,
  1542. co.status AS STATUS,
  1543. bou.name AS buyer,
  1544. s.name AS shopName,
  1545. c.name AS clubName,
  1546. a.onlinePayWays,
  1547. ifnull(a.cmAccountType,0) as cmAccountType,
  1548. ifnull(a.cmShopOtherFee,0) as cmShopOtherFee
  1549. FROM cm_shop_order a
  1550. LEFT JOIN cm_pay_shop_record cpsr ON a.shopOrderID = cpsr.shopOrderID
  1551. LEFT JOIN bp_order_userinfo bou ON bou.orderId = a.orderID
  1552. LEFT JOIN cm_order co ON co.orderID = a.orderID
  1553. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
  1554. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  1555. LEFT JOIN cm_split_account csa on csa.shopOrderId = a.shopOrderID
  1556. LEFT JOIN shop s ON s.shopID = a.shopID
  1557. LEFT JOIN club c ON c.userID = a.userID
  1558. WHERE co.organizeID = 0
  1559. AND co.refundType != 2
  1560. AND co.delFlag = 0
  1561. AND co.orderType != 2
  1562. AND co.receiptStatus = 3
  1563. AND a.delFlag = 0
  1564. AND a.refundStatus = 1
  1565. AND a.shopID != 998
  1566. AND (a.organizeID!=4 or a.organizeID is null)
  1567. AND cdr.payWay = 1
  1568. AND cror.relationType = 2
  1569. AND a.settleStatus in (1,2)
  1570. AND csa.settleStatus = 0
  1571. AND cror.delFlag = 0
  1572. AND cror.mbOrderId IS NOT NULL
  1573. AND cror.splitStatus = 1
  1574. AND a.splitCode != 'E1807059160'
  1575. <if test="startTime != null and startTime != ''">
  1576. AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
  1577. </if>
  1578. <if test="endTime != null and endTime != ''">
  1579. AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
  1580. </if>
  1581. <if test="orderID != null and orderID != ''">
  1582. AND a.orderID = #{orderID}
  1583. </if>
  1584. <if test="orderNo != null and orderNo != ''">
  1585. AND a.orderNo like concat('%', #{orderNo} ,'%')
  1586. </if>
  1587. <if test="ps != null and ps.length>0 ">
  1588. AND a.settleStatus in
  1589. <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
  1590. #{item}
  1591. </foreach>
  1592. </if>
  1593. <if test="shopName != null and shopName != ''">
  1594. AND s.name like concat('%', #{shopName} ,'%')
  1595. </if>
  1596. <if test="clubName != null and clubName != ''">
  1597. AND c.name like concat('%', #{clubName} ,'%')
  1598. </if>
  1599. <if test="shopOrderID != null and shopOrderID != ''">
  1600. AND a.shopOrderID = #{shopOrderID}
  1601. </if>
  1602. <if test="shopOrderNo != null and shopOrderNo != ''">
  1603. AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
  1604. </if>
  1605. GROUP BY a.shopOrderID
  1606. ORDER BY a.shopOrderID DESC
  1607. </select>
  1608. <select id="findSettleRecord" resultType="com.caimei.modules.order.entity.SettleRecord">
  1609. select settleAmount, settleType, settleTime
  1610. from cm_settle_record
  1611. where shopOrderId = #{shopOrderID}
  1612. </select>
  1613. <select id="findListByShopOrderId" resultType="com.caimei.modules.order.entity.NewShopOrder">
  1614. SELECT<include refid="shopOrderColumns"/>,
  1615. b.name as shopName,
  1616. oa.id as orderArchiveId,
  1617. co.receiptStatus
  1618. FROM cm_shop_order a
  1619. left join shop b on a.shopID = b.shopID
  1620. left join cm_order_archive oa on a.shopOrderID = oa.shopOrderId
  1621. left join cm_order co on co.orderID = a.orderID
  1622. WHERE a.shopOrderId = #{onlineShopOrderId}
  1623. ORDER BY a.shopOrderNo DESC
  1624. </select>
  1625. <resultMap type="com.caimei.modules.order.entity.NewShopOrder" id="CmShopOrderResult">
  1626. <result property="shopOrderID" column="shopOrderID"/>
  1627. <result property="shopOrderNo" column="shopOrderNo"/>
  1628. <result property="orderNo" column="orderNo"/>
  1629. <result property="orderID" column="orderID"/>
  1630. <result property="organizeID" column="organizeID"/>
  1631. <result property="isColdChina" column="isColdChina"/>
  1632. <result property="userID" column="userID"/>
  1633. <result property="shopID" column="shopID"/>
  1634. <result property="orderPromotionsId" column="orderPromotionsId"/>
  1635. <result property="orderType" column="orderType"/>
  1636. <result property="orderSubmitType" column="orderSubmitType"/>
  1637. <result property="presentNum" column="presentNum"/>
  1638. <result property="itemCount" column="itemCount"/>
  1639. <result property="outStoreNum" column="outStoreNum"/>
  1640. <result property="outStoreTimes" column="outStoreTimes"/>
  1641. <result property="townID" column="townID"/>
  1642. <result property="note" column="note"/>
  1643. <result property="eachDiscount" column="eachDiscount"/>
  1644. <result property="realPay" column="realPay"/>
  1645. <result property="receiptAmount" column="receiptAmount"/>
  1646. <result property="accountAmount" column="accountAmount"/>
  1647. <result property="productAmount" column="productAmount"/>
  1648. <result property="totalAmount" column="totalAmount"/>
  1649. <result property="needPayAmount" column="needPayAmount"/>
  1650. <result property="discountAmount" column="discountAmount"/>
  1651. <result property="preferential" column="preferential"/>
  1652. <result property="promotionFullReduction" column="promotionFullReduction"/>
  1653. <result property="payFlag" column="payFlag"/>
  1654. <result property="orderTime" column="orderTime"/>
  1655. <result property="payTime" column="payTime"/>
  1656. <result property="finishTime" column="finishTime"/>
  1657. <result property="autoOverTimeMills" column="autoOverTimeMills"/>
  1658. <result property="settleStatus" column="settleStatus"/>
  1659. <result property="payStatus" column="payStatus"/>
  1660. <result property="receiptStatus" column="receiptStatus"/>
  1661. <result property="sendOutStatus" column="sendOutStatus"/>
  1662. <result property="refundStatus" column="refundStatus"/>
  1663. <result property="returnGoodsStatus" column="returnGoodsStatus"/>
  1664. <result property="receiveGoodsTime" column="receiveGoodsTime"/>
  1665. <result property="autoReceiveTimeMills" column="autoReceiveTimeMills"/>
  1666. <result property="totalAddedValueTax" column="totalAddedValueTax"/>
  1667. <result property="canRefundAmount" column="canRefundAmount"/>
  1668. <result property="refundAmount" column="refundAmount"/>
  1669. <result property="clubID" column="clubID"/>
  1670. <result property="spID" column="spID"/>
  1671. <result property="mainSpID" column="mainSpID"/>
  1672. <result property="orderBeanAmount" column="orderBeanAmount"/>
  1673. <result property="useBeanAmount" column="useBeanAmount"/>
  1674. <result property="useBeanFlag" column="useBeanFlag"/>
  1675. <result property="canRefundFlag" column="canRefundFlag"/>
  1676. <result property="useBalanceFlag" column="useBalanceFlag"/>
  1677. <result property="canRefundBeans" column="canRefundBeans"/>
  1678. <result property="freePostageFee" column="freePostageFee"/>
  1679. <result property="freePostageTicketID" column="freePostageTicketID"/>
  1680. <result property="brokerage" column="brokerage"/>
  1681. <result property="delFlag" column="delFlag"/>
  1682. <result property="refundsAmount" column="refundsAmount"/>
  1683. <result property="orderStatusFlag" column="orderStatusFlag"/>
  1684. <result property="buyStatus" column="buyStatus"/>
  1685. <result property="deliveryTimeMills" column="deliveryTimeMills"/>
  1686. <result property="orderDeliveryID" column="orderDeliveryID"/>
  1687. <result property="splitFlag" column="splitFlag"/>
  1688. <result property="paying" column="paying"/>
  1689. <result property="shopProductAmount" column="shopProductAmount"/>
  1690. <result property="shopPostFee" column="shopPostFee"/>
  1691. <result property="shopPostFlag" column="shopPostFlag"/>
  1692. <result property="shopTaxFee" column="shopTaxFee"/>
  1693. <result property="payCmAmount" column="payCmAmount"/>
  1694. <result property="shouldPayShopAmount" column="shouldPayShopAmount"/>
  1695. <result property="payedShopAmount" column="payedShopAmount"/>
  1696. <result property="shopOtherFee" column="shopOtherFee"/>
  1697. <result property="receiptedFlag" column="receiptedFlag"/>
  1698. <result property="receiptedType" column="receiptedType"/>
  1699. <result property="costType" column="costType"/>
  1700. <result property="proportional" column="proportional"/>
  1701. <result property="modifyShouldPayNote" column="modifyShouldPayNote"/>
  1702. <result property="modifyShouldPayUserID" column="modifyShouldPayUserID"/>
  1703. <result property="modifyShouldPayDate" column="modifyShouldPayDate"/>
  1704. <result property="zeroCostFlag" column="zeroCostFlag"/>
  1705. <result property="differenceType" column="differenceType"/>
  1706. <result property="differencePrice" column="differencePrice"/>
  1707. <result property="svipShopReduction" column="svipShopReduction"/>
  1708. <result property="splitCode" column="splitCode"/>
  1709. <result property="paySuccessCounter" column="paySuccessCounter"/>
  1710. <result property="onlinePayWays" column="onlinePayWays"/>
  1711. <result property="status" column="shopStatus"/>
  1712. </resultMap>
  1713. <sql id="selectCmShopOrderVo">
  1714. select cm_shop_order.shopOrderID,
  1715. cm_shop_order.shopOrderNo,
  1716. cm_shop_order.orderNo,
  1717. cm_shop_order.orderID,
  1718. cm_shop_order.organizeID,
  1719. cm_shop_order.isColdChina,
  1720. cm_shop_order.userID,
  1721. cm_shop_order.shopID,
  1722. cm_shop_order.orderPromotionsId,
  1723. cm_shop_order.orderType,
  1724. cm_shop_order.orderSubmitType,
  1725. cm_shop_order.presentNum,
  1726. cm_shop_order.itemCount,
  1727. cm_shop_order.outStoreNum,
  1728. cm_shop_order.outStoreTimes,
  1729. cm_shop_order.townID,
  1730. cm_shop_order.note,
  1731. ifnull(cm_shop_order.accountAmount, 0) AS accountAmount,
  1732. ifnull(cm_shop_order.productAmount, 0) AS productAmount,
  1733. ifnull(cm_shop_order.totalAmount, 0) AS totalAmount,
  1734. ifnull(cm_shop_order.needPayAmount, 0) AS needPayAmount,
  1735. ifnull(cm_shop_order.discountAmount, 0) AS discountAmount,
  1736. ifnull(cm_shop_order.preferential, 0) AS preferential,
  1737. ifnull(cm_shop_order.promotionFullReduction, 0) AS promotionFullReduction,
  1738. cm_shop_order.payFlag,
  1739. cm_shop_order.orderTime,
  1740. cm_shop_order.payTime,
  1741. cm_shop_order.finishTime,
  1742. cm_shop_order.autoOverTimeMills,
  1743. cm_shop_order.settleStatus,
  1744. cm_shop_order.payStatus,
  1745. cm_shop_order.sendOutStatus,
  1746. cm_shop_order.refundStatus,
  1747. cm_shop_order.shopStatus,
  1748. cm_shop_order.returnGoodsStatus,
  1749. cm_shop_order.receiveGoodsTime,
  1750. cm_shop_order.autoReceiveTimeMills,
  1751. ifnull(cm_shop_order.totalAddedValueTax, 0) AS totalAddedValueTax,
  1752. cm_shop_order.canRefundAmount,
  1753. cm_shop_order.refundAmount,
  1754. cm_shop_order.clubID,
  1755. cm_shop_order.spID,
  1756. cm_shop_order.mainSpID,
  1757. cm_shop_order.orderBeanAmount,
  1758. cm_shop_order.useBeanAmount,
  1759. cm_shop_order.useBeanFlag,
  1760. cm_shop_order.canRefundFlag,
  1761. cm_shop_order.useBalanceFlag,
  1762. cm_shop_order.canRefundBeans,
  1763. ifnull(cm_shop_order.freePostageFee, 0) AS freePostageFee,
  1764. cm_shop_order.freePostageTicketID,
  1765. ifnull(cm_shop_order.brokerage, 0) AS brokerage,
  1766. cm_shop_order.delFlag,
  1767. ifnull(cm_shop_order.refundsAmount, 0) AS refundsAmount,
  1768. cm_shop_order.orderStatusFlag,
  1769. cm_shop_order.buyStatus,
  1770. cm_shop_order.deliveryTimeMills,
  1771. cm_shop_order.confirmTime,
  1772. cm_shop_order.updateTime,
  1773. cm_shop_order.orderDeliveryID,
  1774. cm_shop_order.splitFlag,
  1775. cm_shop_order.receiptedFlag,
  1776. cm_shop_order.receiptedType,
  1777. cm_shop_order.paying,
  1778. ifnull(cm_shop_order.shopProductAmount, 0) AS shopProductAmount,
  1779. ifnull(cm_shop_order.shopPostFee, 0) AS shopPostFee,
  1780. cm_shop_order.shopPostFlag,
  1781. ifnull(cm_shop_order.shopTaxFee, 0) AS shopTaxFee,
  1782. ifnull(cm_shop_order.payCmAmount, 0) AS payCmAmount,
  1783. ifnull(cm_shop_order.shouldPayShopAmount, 0) AS shouldPayShopAmount,
  1784. ifnull(cm_shop_order.payedShopAmount, 0) AS payedShopAmount,
  1785. ifnull(cm_shop_order.shopOtherFee, 0) AS shopOtherFee,
  1786. cm_shop_order.costType,
  1787. ifnull(cm_shop_order.proportional, 0) AS proportional,
  1788. cm_shop_order.modifyShouldPayNote,
  1789. cm_shop_order.modifyShouldPayUserID,
  1790. cm_shop_order.modifyShouldPayDate,
  1791. cm_shop_order.zeroCostFlag,
  1792. cm_shop_order.differenceType,
  1793. ifnull(cm_shop_order.differencePrice, 0) AS differencePrice,
  1794. ifnull(cm_shop_order.svipShopReduction, 0) AS svipShopReduction,
  1795. ifnull(cm_shop_order.shopRefundAmount, 0) AS shopRefundAmount,
  1796. cm_shop_order.splitCode,
  1797. cm_shop_order.paySuccessCounter,
  1798. cm_shop_order.onlinePayWays,
  1799. cm_shop_order.receiptStatus,
  1800. ifnull(cm_shop_order.receiptAmount, 0) AS receiptAmount,
  1801. ifnull(cm_shop_order.eachDiscount, 0) AS eachDiscount,
  1802. ifnull(cm_shop_order.realPay, 0) AS realPay,
  1803. cm_shop_order.discountFee,
  1804. cm_shop_order.fee
  1805. </sql>
  1806. <select id="getByCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder"
  1807. resultMap="CmShopOrderResult">
  1808. <include refid="selectCmShopOrderVo"/>
  1809. from cm_shop_order AS cm_shop_order
  1810. <where>cm_shop_order.delFlag = 0
  1811. <if test="shopOrderID != null and shopOrderID != ''">
  1812. and cm_shop_order.shopOrderID
  1813. = #{shopOrderID}
  1814. </if>
  1815. <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
  1816. <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
  1817. <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
  1818. <foreach item="shopOrderIDIn"
  1819. collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
  1820. open="(" separator="," close=")">
  1821. #{shopOrderIDIn}
  1822. </foreach>
  1823. </if>
  1824. <if test="shopOrderNo != null and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
  1825. <if test="orderNo != null and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
  1826. <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
  1827. <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
  1828. <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
  1829. <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
  1830. <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
  1831. <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
  1832. <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
  1833. <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
  1834. <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
  1835. <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
  1836. <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
  1837. <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
  1838. <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
  1839. <if test="note != null and note != ''">and cm_shop_order.note = #{note}</if>
  1840. <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
  1841. <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
  1842. <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
  1843. <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
  1844. <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
  1845. <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
  1846. <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
  1847. <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
  1848. <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
  1849. <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
  1850. #{promotionFullReduction}
  1851. </if>
  1852. <if test="payFlag != null and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
  1853. <if test="orderTime != null and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
  1854. <if test="payTime != null and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
  1855. <if test="finishTime != null and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
  1856. <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
  1857. <if test="settleStatus != null and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
  1858. </if>
  1859. <if test="payStatus != null and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
  1860. <if test="receiptStatus != null and receiptStatus != ''">and cm_shop_order.receiptStatus =
  1861. #{receiptStatus}
  1862. </if>
  1863. <if test="sendOutStatus != null and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
  1864. #{sendOutStatus}
  1865. </if>
  1866. <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
  1867. <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
  1868. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
  1869. #{receiveGoodsTime}
  1870. </if>
  1871. <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
  1872. </if>
  1873. <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
  1874. <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
  1875. <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
  1876. <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
  1877. <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
  1878. <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
  1879. <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
  1880. <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
  1881. <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
  1882. <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
  1883. <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
  1884. <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
  1885. <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
  1886. <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
  1887. <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
  1888. <if test="delFlag != null and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
  1889. <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
  1890. <if test="orderStatusFlag != null and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
  1891. #{orderStatusFlag}
  1892. </if>
  1893. <if test="buyStatus != null and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
  1894. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
  1895. #{deliveryTimeMills}
  1896. </if>
  1897. <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
  1898. <if test="splitFlag != null and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
  1899. <if test="paying != null and paying != ''">and cm_shop_order.paying = #{paying}</if>
  1900. <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
  1901. <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
  1902. <if test="shopPostFlag != null and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
  1903. </if>
  1904. <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
  1905. <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
  1906. <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
  1907. <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
  1908. <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
  1909. <if test="receiptedFlag != null and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
  1910. #{receiptedFlag}
  1911. </if>
  1912. <if test="receiptedType != null and receiptedType != ''">and cm_shop_order.receiptedType =
  1913. #{receiptedType}
  1914. </if>
  1915. <if test="costType != null and costType != ''">and cm_shop_order.costType = #{costType}</if>
  1916. <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
  1917. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
  1918. = #{modifyShouldPayNote}
  1919. </if>
  1920. <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
  1921. #{modifyShouldPayUserID}
  1922. </if>
  1923. <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
  1924. <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
  1925. <if test="differenceType != null and differenceType != ''">and cm_shop_order.differenceType =
  1926. #{differenceType}
  1927. </if>
  1928. <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
  1929. <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
  1930. <if test="splitCode != null and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
  1931. <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
  1932. <if test="onlinePayWays != null and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
  1933. #{onlinePayWays}
  1934. </if>
  1935. <if test="status != null and status != ''">and cm_shop_order.shopStatus = #{status}</if>
  1936. </where>
  1937. group by cm_shop_order.shopOrderID
  1938. order by cm_shop_order.orderTime desc
  1939. limit 0,1
  1940. </select>
  1941. <select id="getCmShopOrderList" parameterType="com.caimei.modules.order.entity.NewShopOrder"
  1942. resultMap="CmShopOrderResult">
  1943. <include refid="selectCmShopOrderVo"/>
  1944. from cm_shop_order AS cm_shop_order
  1945. <where>cm_shop_order.delFlag = 0
  1946. <if test="shopOrderID != null and shopOrderID != ''">
  1947. and cm_shop_order.shopOrderID
  1948. = #{shopOrderID}
  1949. </if>
  1950. <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
  1951. <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
  1952. <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
  1953. <foreach item="shopOrderIDIn"
  1954. collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
  1955. open="(" separator="," close=")">
  1956. #{shopOrderIDIn}
  1957. </foreach>
  1958. </if>
  1959. <if test="shopOrderNo != null and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
  1960. <if test="orderNo != null and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
  1961. <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
  1962. <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
  1963. <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
  1964. <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
  1965. <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
  1966. <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
  1967. <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
  1968. <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
  1969. <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
  1970. <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
  1971. <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
  1972. <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
  1973. <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
  1974. <if test="note != null and note != ''">and cm_shop_order.note = #{note}</if>
  1975. <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
  1976. <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
  1977. <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
  1978. <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
  1979. <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
  1980. <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
  1981. <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
  1982. <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
  1983. <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
  1984. <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
  1985. #{promotionFullReduction}
  1986. </if>
  1987. <if test="payFlag != null and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
  1988. <if test="orderTime != null and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
  1989. <if test="payTime != null and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
  1990. <if test="finishTime != null and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
  1991. <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
  1992. <if test="settleStatus != null and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
  1993. </if>
  1994. <if test="payStatus != null and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
  1995. <if test="receiptStatus != null and receiptStatus != ''">and cm_shop_order.receiptStatus =
  1996. #{receiptStatus}
  1997. </if>
  1998. <if test="sendOutStatus != null and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
  1999. #{sendOutStatus}
  2000. </if>
  2001. <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
  2002. <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
  2003. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
  2004. #{receiveGoodsTime}
  2005. </if>
  2006. <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
  2007. </if>
  2008. <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
  2009. <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
  2010. <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
  2011. <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
  2012. <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
  2013. <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
  2014. <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
  2015. <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
  2016. <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
  2017. <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
  2018. <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
  2019. <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
  2020. <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
  2021. <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
  2022. <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
  2023. <if test="delFlag != null and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
  2024. <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
  2025. <if test="orderStatusFlag != null and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
  2026. #{orderStatusFlag}
  2027. </if>
  2028. <if test="buyStatus != null and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
  2029. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
  2030. #{deliveryTimeMills}
  2031. </if>
  2032. <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
  2033. <if test="splitFlag != null and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
  2034. <if test="paying != null and paying != ''">and cm_shop_order.paying = #{paying}</if>
  2035. <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
  2036. <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
  2037. <if test="shopPostFlag != null and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
  2038. </if>
  2039. <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
  2040. <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
  2041. <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
  2042. <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
  2043. <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
  2044. <if test="receiptedFlag != null and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
  2045. #{receiptedFlag}
  2046. </if>
  2047. <if test="receiptedType != null and receiptedType != ''">and cm_shop_order.receiptedType =
  2048. #{receiptedType}
  2049. </if>
  2050. <if test="costType != null and costType != ''">and cm_shop_order.costType = #{costType}</if>
  2051. <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
  2052. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
  2053. = #{modifyShouldPayNote}
  2054. </if>
  2055. <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
  2056. #{modifyShouldPayUserID}
  2057. </if>
  2058. <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
  2059. <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
  2060. <if test="differenceType != null and differenceType != ''">and cm_shop_order.differenceType =
  2061. #{differenceType}
  2062. </if>
  2063. <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
  2064. <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
  2065. <if test="splitCode != null and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
  2066. <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
  2067. <if test="onlinePayWays != null and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
  2068. #{onlinePayWays}
  2069. </if>
  2070. <if test="status != null and status != ''">and cm_shop_order.shopStatus = #{status}</if>
  2071. </where>
  2072. group by cm_shop_order.shopOrderID
  2073. order by cm_shop_order.orderTime desc
  2074. </select>
  2075. <select id="getCmShopOrderCount" parameterType="com.caimei.modules.order.entity.NewShopOrder" resultType="String">
  2076. select count(1)
  2077. from cm_shop_order AS cm_shop_order
  2078. <where>cm_shop_order.delFlag = 0
  2079. <if test="shopOrderID != null and shopOrderID != ''">
  2080. and cm_shop_order.shopOrderID
  2081. = #{shopOrderID}
  2082. </if>
  2083. <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
  2084. <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
  2085. <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
  2086. <foreach item="shopOrderIDIn"
  2087. collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
  2088. open="(" separator="," close=")">
  2089. #{shopOrderIDIn}
  2090. </foreach>
  2091. </if>
  2092. <if test="shopOrderNo != null and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
  2093. <if test="orderNo != null and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
  2094. <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
  2095. <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
  2096. <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
  2097. <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
  2098. <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
  2099. <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
  2100. <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
  2101. <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
  2102. <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
  2103. <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
  2104. <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
  2105. <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
  2106. <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
  2107. <if test="note != null and note != ''">and cm_shop_order.note = #{note}</if>
  2108. <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
  2109. <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
  2110. <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
  2111. <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
  2112. <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
  2113. <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
  2114. <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
  2115. <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
  2116. <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
  2117. <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
  2118. #{promotionFullReduction}
  2119. </if>
  2120. <if test="payFlag != null and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
  2121. <if test="orderTime != null and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
  2122. <if test="payTime != null and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
  2123. <if test="finishTime != null and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
  2124. <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
  2125. <if test="settleStatus != null and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
  2126. </if>
  2127. <if test="payStatus != null and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
  2128. <if test="receiptStatus != null and receiptStatus != ''">and cm_shop_order.receiptStatus =
  2129. #{receiptStatus}
  2130. </if>
  2131. <if test="sendOutStatus != null and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
  2132. #{sendOutStatus}
  2133. </if>
  2134. <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
  2135. <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
  2136. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
  2137. #{receiveGoodsTime}
  2138. </if>
  2139. <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
  2140. </if>
  2141. <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
  2142. <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
  2143. <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
  2144. <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
  2145. <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
  2146. <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
  2147. <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
  2148. <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
  2149. <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
  2150. <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
  2151. <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
  2152. <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
  2153. <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
  2154. <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
  2155. <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
  2156. <if test="delFlag != null and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
  2157. <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
  2158. <if test="orderStatusFlag != null and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
  2159. #{orderStatusFlag}
  2160. </if>
  2161. <if test="buyStatus != null and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
  2162. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
  2163. #{deliveryTimeMills}
  2164. </if>
  2165. <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
  2166. <if test="splitFlag != null and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
  2167. <if test="paying != null and paying != ''">and cm_shop_order.paying = #{paying}</if>
  2168. <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
  2169. <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
  2170. <if test="shopPostFlag != null and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
  2171. </if>
  2172. <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
  2173. <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
  2174. <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
  2175. <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
  2176. <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
  2177. <if test="receiptedFlag != null and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
  2178. #{receiptedFlag}
  2179. </if>
  2180. <if test="receiptedType != null and receiptedType != ''">and cm_shop_order.receiptedType =
  2181. #{receiptedType}
  2182. </if>
  2183. <if test="costType != null and costType != ''">and cm_shop_order.costType = #{costType}</if>
  2184. <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
  2185. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
  2186. = #{modifyShouldPayNote}
  2187. </if>
  2188. <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
  2189. #{modifyShouldPayUserID}
  2190. </if>
  2191. <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
  2192. <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
  2193. <if test="differenceType != null and differenceType != ''">and cm_shop_order.differenceType =
  2194. #{differenceType}
  2195. </if>
  2196. <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
  2197. <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
  2198. <if test="splitCode != null and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
  2199. <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
  2200. <if test="onlinePayWays != null and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
  2201. #{onlinePayWays}
  2202. </if>
  2203. <if test="status != null and status != ''">and cm_shop_order.shopStatus = #{status}</if>
  2204. </where>
  2205. group by cm_shop_order.shopOrderID
  2206. </select>
  2207. <select id="getCmShopOrderByShopOrderID" parameterType="String" resultMap="CmShopOrderResult">
  2208. <include refid="selectCmShopOrderVo"/>
  2209. from cm_shop_order AS cm_shop_order
  2210. where cm_shop_order.delFlag = 0 and cm_shop_order.shopOrderID = #{shopOrderID}
  2211. </select>
  2212. <select id="getByIds" parameterType="com.caimei.modules.order.entity.NewShopOrder" resultType="String">
  2213. select shopOrderID
  2214. from cm_shop_order AS cm_shop_order
  2215. <where>cm_shop_order.delFlag = 0
  2216. <if test="shopOrderID != null and shopOrderID != ''">
  2217. and cm_shop_order.shopOrderID
  2218. = #{shopOrderID}
  2219. </if>
  2220. <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
  2221. <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
  2222. <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
  2223. <foreach item="shopOrderIDIn"
  2224. collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
  2225. open="(" separator="," close=")">
  2226. #{shopOrderIDIn}
  2227. </foreach>
  2228. </if>
  2229. <if test="shopOrderNo != null and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
  2230. <if test="orderNo != null and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
  2231. <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
  2232. <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
  2233. <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
  2234. <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
  2235. <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
  2236. <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
  2237. <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
  2238. <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
  2239. <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
  2240. <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
  2241. <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
  2242. <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
  2243. <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
  2244. <if test="note != null and note != ''">and cm_shop_order.note = #{note}</if>
  2245. <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
  2246. <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
  2247. <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
  2248. <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
  2249. <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
  2250. <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
  2251. <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
  2252. <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
  2253. <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
  2254. <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
  2255. #{promotionFullReduction}
  2256. </if>
  2257. <if test="payFlag != null and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
  2258. <if test="orderTime != null and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
  2259. <if test="payTime != null and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
  2260. <if test="finishTime != null and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
  2261. <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
  2262. <if test="settleStatus != null and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
  2263. </if>
  2264. <if test="payStatus != null and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
  2265. <if test="receiptStatus != null and receiptStatus != ''">and cm_shop_order.receiptStatus =
  2266. #{receiptStatus}
  2267. </if>
  2268. <if test="sendOutStatus != null and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
  2269. #{sendOutStatus}
  2270. </if>
  2271. <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
  2272. <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
  2273. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
  2274. #{receiveGoodsTime}
  2275. </if>
  2276. <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
  2277. </if>
  2278. <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
  2279. <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
  2280. <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
  2281. <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
  2282. <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
  2283. <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
  2284. <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
  2285. <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
  2286. <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
  2287. <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
  2288. <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
  2289. <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
  2290. <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
  2291. <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
  2292. <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
  2293. <if test="delFlag != null and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
  2294. <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
  2295. <if test="orderStatusFlag != null and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
  2296. #{orderStatusFlag}
  2297. </if>
  2298. <if test="buyStatus != null and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
  2299. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
  2300. #{deliveryTimeMills}
  2301. </if>
  2302. <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
  2303. <if test="splitFlag != null and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
  2304. <if test="paying != null and paying != ''">and cm_shop_order.paying = #{paying}</if>
  2305. <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
  2306. <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
  2307. <if test="shopPostFlag != null and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
  2308. </if>
  2309. <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
  2310. <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
  2311. <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
  2312. <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
  2313. <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
  2314. <if test="receiptedFlag != null and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
  2315. #{receiptedFlag}
  2316. </if>
  2317. <if test="receiptedType != null and receiptedType != ''">and cm_shop_order.receiptedType =
  2318. #{receiptedType}
  2319. </if>
  2320. <if test="costType != null and costType != ''">and cm_shop_order.costType = #{costType}</if>
  2321. <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
  2322. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
  2323. = #{modifyShouldPayNote}
  2324. </if>
  2325. <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
  2326. #{modifyShouldPayUserID}
  2327. </if>
  2328. <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
  2329. <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
  2330. <if test="differenceType != null and differenceType != ''">and cm_shop_order.differenceType =
  2331. #{differenceType}
  2332. </if>
  2333. <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
  2334. <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
  2335. <if test="splitCode != null and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
  2336. <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
  2337. <if test="onlinePayWays != null and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
  2338. #{onlinePayWays}
  2339. </if>
  2340. <if test="status != null and status != ''">and cm_shop_order.shopStatus = #{status}</if>
  2341. </where>
  2342. group by cm_shop_order.shopOrderID
  2343. </select>
  2344. <select id="getById" parameterType="com.caimei.modules.order.entity.NewShopOrder" resultType="String">
  2345. select shopOrderID
  2346. from cm_shop_order AS cm_shop_order
  2347. <where>cm_shop_order.delFlag = 0
  2348. <if test="shopOrderID != null and shopOrderID != ''">
  2349. and cm_shop_order.shopOrderID
  2350. = #{shopOrderID}
  2351. </if>
  2352. <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
  2353. <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
  2354. <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
  2355. <foreach item="shopOrderIDIn"
  2356. collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
  2357. open="(" separator="," close=")">
  2358. #{shopOrderIDIn}
  2359. </foreach>
  2360. </if>
  2361. <if test="shopOrderNo != null and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
  2362. <if test="orderNo != null and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
  2363. <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
  2364. <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
  2365. <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
  2366. <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
  2367. <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
  2368. <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
  2369. <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
  2370. <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
  2371. <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
  2372. <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
  2373. <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
  2374. <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
  2375. <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
  2376. <if test="note != null and note != ''">and cm_shop_order.note = #{note}</if>
  2377. <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
  2378. <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
  2379. <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
  2380. <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
  2381. <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
  2382. <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
  2383. <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
  2384. <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
  2385. <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
  2386. <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
  2387. #{promotionFullReduction}
  2388. </if>
  2389. <if test="payFlag != null and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
  2390. <if test="orderTime != null and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
  2391. <if test="payTime != null and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
  2392. <if test="finishTime != null and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
  2393. <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
  2394. <if test="settleStatus != null and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
  2395. </if>
  2396. <if test="payStatus != null and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
  2397. <if test="receiptStatus != null and receiptStatus != ''">and cm_shop_order.receiptStatus =
  2398. #{receiptStatus}
  2399. </if>
  2400. <if test="sendOutStatus != null and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
  2401. #{sendOutStatus}
  2402. </if>
  2403. <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
  2404. <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
  2405. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
  2406. #{receiveGoodsTime}
  2407. </if>
  2408. <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
  2409. </if>
  2410. <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
  2411. <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
  2412. <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
  2413. <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
  2414. <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
  2415. <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
  2416. <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
  2417. <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
  2418. <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
  2419. <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
  2420. <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
  2421. <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
  2422. <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
  2423. <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
  2424. <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
  2425. <if test="delFlag != null and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
  2426. <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
  2427. <if test="orderStatusFlag != null and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
  2428. #{orderStatusFlag}
  2429. </if>
  2430. <if test="buyStatus != null and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
  2431. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
  2432. #{deliveryTimeMills}
  2433. </if>
  2434. <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
  2435. <if test="splitFlag != null and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
  2436. <if test="paying != null and paying != ''">and cm_shop_order.paying = #{paying}</if>
  2437. <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
  2438. <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
  2439. <if test="shopPostFlag != null and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
  2440. </if>
  2441. <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
  2442. <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
  2443. <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
  2444. <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
  2445. <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
  2446. <if test="receiptedFlag != null and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
  2447. #{receiptedFlag}
  2448. </if>
  2449. <if test="receiptedType != null and receiptedType != ''">and cm_shop_order.receiptedType =
  2450. #{receiptedType}
  2451. </if>
  2452. <if test="costType != null and costType != ''">and cm_shop_order.costType = #{costType}</if>
  2453. <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
  2454. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
  2455. = #{modifyShouldPayNote}
  2456. </if>
  2457. <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
  2458. #{modifyShouldPayUserID}
  2459. </if>
  2460. <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
  2461. <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
  2462. <if test="differenceType != null and differenceType != ''">and cm_shop_order.differenceType =
  2463. #{differenceType}
  2464. </if>
  2465. <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
  2466. <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
  2467. <if test="splitCode != null and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
  2468. <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
  2469. <if test="onlinePayWays != null and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
  2470. #{onlinePayWays}
  2471. </if>
  2472. <if test="status != null and status != ''">and cm_shop_order.shopStatus = #{status}</if>
  2473. </where>
  2474. group by cm_shop_order.shopOrderID
  2475. limit 0,1
  2476. </select>
  2477. <select id="getShopOrderlist" resultType="com.caimei.modules.order.entity.NewShopOrder">
  2478. select cso.shopOrderID,
  2479. cso.shopOrderNo,
  2480. cso.orderId,
  2481. cso.orderNo,
  2482. cso.organizeID,
  2483. cso.userID,
  2484. cso.clubID,
  2485. cso.orderType,
  2486. bou.shouHuoRen AS receiver,
  2487. co.orderSource,
  2488. cso.needPayAmount,
  2489. cso.orderTime,
  2490. cso.confirmTime,
  2491. cso.payStatus,
  2492. cso.sendOutStatus,
  2493. cso.receiptStatus,
  2494. cso.refundStatus,
  2495. cso.shopStatus,
  2496. u.name AS buyer,
  2497. (case when co.orderType = '0' then
  2498. (select case status when 91 then '采美默认协销经理(官方账号)' else linkMan end from serviceprovider where serviceProviderID
  2499. = co.spID)
  2500. else
  2501. ''
  2502. end) AS spName,
  2503. co.rebateFlag,
  2504. cso.closeTime,
  2505. (SELECT COUNT(*) FROM cm_returned_purchase
  2506. WHERE shopOrderId = cso.shopOrderId AND status =1 AND delFLag = 0) AS returnedPurchaseStatus,
  2507. co.closeReason AS closeReason
  2508. from cm_shop_order cso
  2509. left join cm_order co on cso.orderId = co.orderId
  2510. left join bp_order_userinfo bou on bou.orderId = cso.orderId
  2511. <if test="productName != null and productName != ''">
  2512. LEFT JOIN cm_order_product cop ON cso.shopOrderId = cop.shopOrderId
  2513. LEFT JOIN product p ON cop.productID = p.productID
  2514. </if>
  2515. LEFT JOIN user u ON u.userID = cso.userID
  2516. left join club c on c.clubId = cso.clubId
  2517. <where>
  2518. cso.delFlag = 0
  2519. and co.delflag = 0
  2520. and cso.orderType != 2
  2521. <if test="serviceProviderId != null and serviceProviderId != 0">
  2522. and cso.orderType = 0
  2523. and co.spID = #{serviceProviderId}
  2524. </if>
  2525. <if test="shopOrderNo != null and shopOrderNo != ''">
  2526. AND cso.shopOrderNo = #{shopOrderNo}
  2527. </if>
  2528. <if test="shopOrderID != null and shopOrderID != ''">
  2529. AND cso.shopOrderID = #{shopOrderID}
  2530. </if>
  2531. <if test="clubID != null">
  2532. and c.clubId = #{clubID}
  2533. </if>
  2534. <if test="orderNo != null and orderNo != ''">
  2535. AND cso.orderNo = #{orderNo}
  2536. </if>
  2537. <if test="orderID != null and orderID != ''">
  2538. AND cso.orderID = #{orderID}
  2539. </if>
  2540. <if test="buyer != null and buyer != ''">
  2541. AND u.name LIKE concat('%',#{buyer},'%')
  2542. </if>
  2543. <if test="status != null">
  2544. AND cso.shopStatus = #{status}
  2545. </if>
  2546. <if test="productName != null and productName != ''">
  2547. and (p.name like CONCAT('%',#{productName},'%') OR p.aliasName LIKE CONCAT('%',#{productName},'%'))
  2548. </if>
  2549. <if test="receiptStatus != null and receiptStatus != ''">
  2550. AND cso.receiptStatus = #{receiptStatus}
  2551. </if>
  2552. <if test="sendOutStatus != null and sendOutStatus != ''">
  2553. AND cso.sendOutStatus = #{sendOutStatus}
  2554. </if>
  2555. <if test="payStatus != null and payStatus != ''">
  2556. AND cso.payStatus = #{payStatus}
  2557. </if>
  2558. <if test="refundStatus != null and refundStatus != ''">
  2559. AND cso.refundStatus = #{refundStatus}
  2560. </if>
  2561. <if test="orderType != null">
  2562. AND cso.orderType = #{orderType}
  2563. </if>
  2564. <if test="spID != null and spID != ''">
  2565. AND co.spId = #{spID}
  2566. </if>
  2567. <if test="rebateFlag != null and rebateFlag != ''">
  2568. AND co.rebateFlag = #{rebateFlag}
  2569. </if>
  2570. <if test="orderSource != null and orderSource != ''">
  2571. AND co.orderSource = #{orderSource}
  2572. </if>
  2573. <if test="organizeID != null and organizeID != ''">
  2574. AND cso.organizeID = #{organizeID}
  2575. </if>
  2576. <if test="receiver != null and receiver != ''">
  2577. AND bou.shouHuoRen LIKE concat('%',#{receiver},'%')
  2578. </if>
  2579. <if test="startTime != null and startTime != ''">
  2580. AND cso.orderTime <![CDATA[ >= ]]> #{startTime}
  2581. </if>
  2582. <if test="endTime != null and endTime != ''">
  2583. AND cso.orderTime <![CDATA[ <= ]]> #{endTime}
  2584. </if>
  2585. <if test="startConfirmTime != null and startConfirmTime != ''">
  2586. AND cso.confirmTime <![CDATA[ >= ]]> #{startConfirmTime}
  2587. </if>
  2588. <if test="endConfirmTime != null and endConfirmTime != ''">
  2589. AND cso.confirmTime <![CDATA[ <= ]]> #{endConfirmTime}
  2590. </if>
  2591. <if test="returnedPurchaseStatus != null and returnedPurchaseStatus != ''">
  2592. AND
  2593. <if test="returnedPurchaseStatus == 1">
  2594. exists
  2595. </if>
  2596. <if test="returnedPurchaseStatus == 0">
  2597. not exists
  2598. </if>
  2599. (select 1 from cm_returned_purchase
  2600. where status = 1 and shopOrderId = cso.shopOrderId and delFlag= 0)
  2601. </if>
  2602. </where>
  2603. ORDER BY cso.shopOrderID DESC
  2604. </select>
  2605. <select id="findCmProfit" resultType="com.caimei.modules.order.entity.OtherFeeDto">
  2606. select IF((SELECT SUM(cdr.receiptAmount)
  2607. FROM cm_discern_receipt cdr
  2608. LEFT JOIN cm_receipt_order_relation cror ON cdr.id = cror.receiptId
  2609. WHERE cdr.receiptType IN (10, 11)
  2610. AND cdr.receiptStatus NOT IN (1, 4, 5)
  2611. AND cdr.delflag = 0
  2612. AND cror.shopOrderId = acso.shopOrderId) > 0, 0,
  2613. (SELECT acso.needpayAmount
  2614. - SUM(IFNULL(op.costprice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
  2615. - SUM(IFNULL(op.organizeCostPrice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
  2616. - SUM(IFNULL(op.cmCostPrice, 0) * (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0)))
  2617. - (IFNULL(SUM(acso.supplierFreight +
  2618. IF(acso.differenceType = 1, acso.differencePrice, 0) -
  2619. IF(acso.differenceType = 2, acso.differencePrice, 0)),
  2620. 0))
  2621. + IFNULL(acso.shopPostFee, 0)
  2622. FROM cm_order_product op
  2623. WHERE op.shopOrderId = acso.shopOrderId)) as cmProfit,
  2624. acso.onlinePayWays,
  2625. ifnull(acso.cmAccountType, 0) as cmAccountType
  2626. from cm_shop_order acso
  2627. where acso.shopOrderId = #{shopOrderId}
  2628. </select>
  2629. <select id="findByShopOrderIDsNot" resultType="com.caimei.modules.order.entity.NewShopOrder">
  2630. select distinct
  2631. co.rebateFee as rebateFee,
  2632. co.userBeans as userBeans,
  2633. a.shopOrderID AS shopOrderID,
  2634. a.shopStatus AS status,
  2635. a.shopPostFlag AS shopPostFlag,
  2636. a.orderID AS orderID,
  2637. a.organizeID AS organizeID,
  2638. a.shopOrderNo AS shopOrderNo,
  2639. a.orderNo AS orderNo,
  2640. a.userID AS userID,
  2641. a.shopID AS shopID,
  2642. a.isColdChina AS isColdChina,
  2643. a.itemCount AS itemCount,
  2644. a.townID AS townID,
  2645. a.productAmount AS productAmount,
  2646. a.discountAmount AS discountAmount,
  2647. a.accountAmount AS accountAmount,
  2648. a.totalAmount AS totalAmount,
  2649. a.payFlag AS payFlag,
  2650. a.payTime AS payTime,
  2651. a.finishTime AS finishTime,
  2652. a.refundStatus AS refundStatus,
  2653. a.needPayAmount AS needPayAmount,
  2654. a.splitCode,
  2655. ifnull(a.realPay, a.needPayAmount) AS realPay,
  2656. a.eachDiscount AS eachDiscount,
  2657. IFNULL((SELECT SUM(cror.associateAmount)
  2658. FROM cm_receipt_order_relation cror
  2659. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
  2660. WHERE cror.shopOrderId = a.shopOrderId
  2661. AND cror.relationType = '2'
  2662. AND cdr.receiptType = 1
  2663. AND cdr.delFlag = 0
  2664. AND cror.delFlag = 0
  2665. AND cdr.receiptStatus IN (2, 3)
  2666. AND cdr.payWay != 3)
  2667. , 0) AS receiptAmount,
  2668. (ifnull(a.realPay,a.needPayAmount) - ifnull(a.receiptAmount,0)) as restAmount,
  2669. a.receiptStatus as shopReceiptStatus,
  2670. a.receiptStatus as ReceiptStatus,
  2671. a.canRefundAmount AS canRefundAmount,
  2672. a.refundAmount AS refundAmount,
  2673. a.clubID AS clubID,
  2674. a.spID AS spID,
  2675. a.mainSpID AS mainSpID,
  2676. a.orderBeanAmount AS orderBeanAmount,
  2677. a.useBeanAmount AS useBeanAmount,
  2678. a.useBeanFlag AS useBeanFlag,
  2679. a.canRefundFlag AS canRefundFlag,
  2680. a.useBalanceFlag AS useBalanceFlag,
  2681. a.canRefundBeans AS canRefundBeans,
  2682. a.freePostageFee AS freePostageFee,
  2683. a.freePostageTicketID AS freePostageTicketID,
  2684. a.brokerage AS brokerage,
  2685. a.delFlag AS delFlag,
  2686. a.refundsAmount AS refundsAmount,
  2687. a.orderStatusFlag AS orderStatusFlag,
  2688. a.buyStatus AS buyStatus,
  2689. a.orderSubmitType AS orderSubmitType,
  2690. a.orderType AS orderType,
  2691. a.orderTime AS orderTime,
  2692. a.deliveryTimeMills AS deliveryTimeMills,
  2693. a.presentNum AS presentNum,
  2694. a.preferential AS preferential,
  2695. a.outStoreNum AS outStoreNum,
  2696. IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
  2697. a.splitFlag AS splitFlag,
  2698. a.autoReceiveTimeMills AS autoReceiveTimeMills,
  2699. a.autoOverTimeMills AS autoOverTimeMills,
  2700. a.receiveGoodsTime AS receiveGoodsTime,
  2701. a.totalAddedValueTax AS totalAddedValueTax,
  2702. a.note AS note,
  2703. a.payStatus AS payStatus,
  2704. a.sendOutStatus AS sendOutStatus,
  2705. a.shopProductAmount AS shopProductAmount,
  2706. ifnull(a.shopPostFee, 0) AS shopPostFee,
  2707. ifnull(a.shopTaxFee,0) AS shopTaxFee,
  2708. a.shouldPayShopAmount AS shouldPayShopAmount,
  2709. a.payedShopAmount AS payedShopAmount,
  2710. a.paying AS paying,
  2711. a.costType AS costType,
  2712. a.settleStatus AS settleStatus,
  2713. a.modifyShouldPayNote AS modifyShouldPayNote,
  2714. a.orderPromotionsId AS orderPromotionsId,
  2715. a.differenceType AS differenceType,
  2716. a.differencePrice AS differencePrice,
  2717. a.proportional AS proportional,
  2718. ifnull(a.promotionFullReduction, 0) As promotionFullReduction,
  2719. ifnull(a.couponAmount, 0) As couponAmount,
  2720. a.zeroCostFlag AS zeroCostFlag,
  2721. co.payTotalFee AS payTotalFee,
  2722. co.promotionFullReduction AS promotionFullReduction,
  2723. a.onlinePayWays,
  2724. ifnull(a.cmAccountType,0) as cmAccountType,
  2725. ifnull(a.shopOtherFee, 0) AS shopOtherFee,
  2726. ifnull(a.cmShopOtherFee,0) AS cmShopOtherFee,
  2727. ifnull(a.supplierFreight,0) as supplierFreight,
  2728. ifnull(a.rebateOrder,0) as rebateOrder,
  2729. bou.name AS buyer,
  2730. s.name AS shopName,
  2731. c.name AS clubName
  2732. from cm_shop_order a
  2733. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  2734. left join bp_order_userinfo bou on bou.orderId = a.orderID
  2735. left join cm_order co on co.orderID = a.orderID
  2736. left join shop s on s.shopID = a.shopID
  2737. left join club c on c.userID = a.userID
  2738. <if test="ids != null and ids.size() > 0">
  2739. where a.shopOrderID in
  2740. <foreach collection="ids" separator="," item="shopOrderID" open="(" close=")">
  2741. #{shopOrderID}
  2742. </foreach>
  2743. </if>
  2744. </select>
  2745. <select id="findPayOtherList" resultType="com.caimei.modules.order.entity.NewShopOrder">
  2746. select<include refid="shopOrderColumns"/>,
  2747. co.payTotalFee AS payTotalFee,
  2748. ifnull(a.supplierFreight,0) as supplierFreight,
  2749. ifnull(a.rebateOrder,0) as rebateOrder,
  2750. bou.name AS buyer,
  2751. s.name AS shopName,
  2752. c.name AS clubName,
  2753. a.onlinePayWays,
  2754. ifnull(a.cmAccountType,0) as cmAccountType,
  2755. cdr.payWay AS payWay,
  2756. ifnull(a.cmShopOtherFee,0) as cmShopOtherFee
  2757. from cm_shop_order a
  2758. left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
  2759. left join bp_order_userinfo bou on bou.orderId = a.orderID
  2760. left join cm_order co on co.orderID = a.orderID
  2761. LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId and cror.delFlag = 0
  2762. LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id and cdr.delFlag = 0
  2763. left join shop s on s.shopID = a.shopID
  2764. LEFT JOIN club c ON c.userID = a.userID
  2765. <where>
  2766. s.AccountOwnership = 1
  2767. and a.shopStatus not in (4, 5)
  2768. and IFNULL(cdr.receiptType,0) not in (10,11)
  2769. and cdr.payWay = 2
  2770. <if test="startTime != null and startTime != ''">
  2771. AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
  2772. </if>
  2773. <if test="endTime != null and endTime != ''">
  2774. AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
  2775. </if>
  2776. <if test="orderID != null and orderID != ''">
  2777. AND a.orderID = #{orderID}
  2778. </if>
  2779. <if test="organizeID != null and organizeID != 9999">
  2780. AND co.organizeID = #{organizeID}
  2781. </if>
  2782. <if test="organizeID == 9999 ">
  2783. AND co.orderType = 2
  2784. </if>
  2785. <if test="orderNo != null and orderNo != ''">
  2786. AND a.orderNo like concat('%', #{orderNo} ,'%')
  2787. </if>
  2788. <if test="ps != null and ps.length>0 ">
  2789. AND a.payStatus in
  2790. <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
  2791. #{item}
  2792. </foreach>
  2793. </if>
  2794. <if test="shopName != null and shopName != ''">
  2795. AND s.name like concat('%', #{shopName} ,'%')
  2796. </if>
  2797. <if test="buyer != null and buyer != ''">
  2798. AND bou.name like concat('%', #{buyer} ,'%')
  2799. </if>
  2800. <if test="clubName != null and clubName != ''">
  2801. AND c.name like concat('%', #{clubName} ,'%')
  2802. </if>
  2803. <if test="shopOrderID != null and shopOrderID != ''">
  2804. AND a.shopOrderID = #{shopOrderID}
  2805. </if>
  2806. <if test="shopOrderNo != null and shopOrderNo != ''">
  2807. AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
  2808. </if>
  2809. <if test="operatingMode != null and operatingMode == '1'.toString()">
  2810. and a.payStatus != 3 and co.status NOT IN (6,7)
  2811. </if>
  2812. <if test="operatingMode != null and operatingMode == '2'.toString()">
  2813. and a.payStatus != 1 and co.status != 6
  2814. </if>
  2815. <if test="operatingMode != null and operatingMode == '3'.toString()">
  2816. and a.payStatus = 3 and co.status NOT IN (6,7)
  2817. </if>
  2818. and a.shopStatus != 0
  2819. and co.delFlag = 0
  2820. and a.delFlag = 0
  2821. and (a.organizeID!=4 or a.organizeID is null)
  2822. and a.shopID != 998
  2823. and co.orderID not in (
  2824. SELECT orderID FROM cm_order_product WHERE productID IN
  2825. (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
  2826. )
  2827. </where>
  2828. group by a.shopOrderID
  2829. ORDER BY a.shopOrderID DESC
  2830. </select>
  2831. <insert id="addCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder" useGeneratedKeys="true"
  2832. keyProperty="shopOrderID">
  2833. insert into cm_shop_order
  2834. <trim prefix="(" suffix=")" suffixOverrides=",">
  2835. <if test="shopOrderID != null and shopOrderID != ''">shopOrderID,</if>
  2836. <if test="shopOrderNo != null and shopOrderNo != ''">shopOrderNo,</if>
  2837. <if test="orderNo != null and orderNo != ''">orderNo,</if>
  2838. <if test="orderID != null">orderID,</if>
  2839. <if test="organizeID != null">organizeID,</if>
  2840. <if test="isColdChina != null">isColdChina,</if>
  2841. <if test="userID != null">userID,</if>
  2842. <if test="shopID != null">shopID,</if>
  2843. <if test="orderPromotionsId != null">orderPromotionsId,</if>
  2844. <if test="orderType != null">orderType,</if>
  2845. <if test="orderSubmitType != null">orderSubmitType,</if>
  2846. <if test="presentNum != null">presentNum,</if>
  2847. <if test="itemCount != null">itemCount,</if>
  2848. <if test="outStoreNum != null">outStoreNum,</if>
  2849. <if test="outStoreTimes != null">outStoreTimes,</if>
  2850. <if test="townID != null">townID,</if>
  2851. <if test="note != null and note != ''">note,</if>
  2852. <if test="eachDiscount != null">eachDiscount,</if>
  2853. <if test="realPay != null">realPay,</if>
  2854. <if test="receiptAmount != null">receiptAmount,</if>
  2855. <if test="accountAmount != null">accountAmount,</if>
  2856. <if test="productAmount != null">productAmount,</if>
  2857. <if test="totalAmount != null">totalAmount,</if>
  2858. <if test="needPayAmount != null">needPayAmount,</if>
  2859. <if test="discountAmount != null">discountAmount,</if>
  2860. <if test="preferential != null">preferential,</if>
  2861. <if test="promotionFullReduction != null">promotionFullReduction,</if>
  2862. <if test="payFlag != null and payFlag != ''">payFlag,</if>
  2863. <if test="orderTime != null and orderTime != ''">orderTime,</if>
  2864. <if test="payTime != null and payTime != ''">payTime,</if>
  2865. <if test="finishTime != null and finishTime != ''">finishTime,</if>
  2866. <if test="autoOverTimeMills != null">autoOverTimeMills,</if>
  2867. <if test="settleStatus != null and settleStatus != ''">settleStatus,</if>
  2868. <if test="payStatus != null and payStatus != ''">payStatus,</if>
  2869. <if test="receiptStatus != null and receiptStatus != ''">receiptStatus,</if>
  2870. <if test="sendOutStatus != null and sendOutStatus != ''">sendOutStatus,</if>
  2871. <if test="refundStatus != null">refundStatus,</if>
  2872. <if test="returnGoodsStatus != null">returnGoodsStatus,</if>
  2873. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">receiveGoodsTime,</if>
  2874. <if test="autoReceiveTimeMills != null">autoReceiveTimeMills,</if>
  2875. <if test="totalAddedValueTax != null">totalAddedValueTax,</if>
  2876. <if test="canRefundAmount != null">canRefundAmount,</if>
  2877. <if test="refundAmount != null">refundAmount,</if>
  2878. <if test="clubID != null">clubID,</if>
  2879. <if test="spID != null">spID,</if>
  2880. <if test="mainSpID != null">mainSpID,</if>
  2881. <if test="orderBeanAmount != null">orderBeanAmount,</if>
  2882. <if test="useBeanAmount != null">useBeanAmount,</if>
  2883. <if test="useBeanFlag != null">useBeanFlag,</if>
  2884. <if test="canRefundFlag != null">canRefundFlag,</if>
  2885. <if test="useBalanceFlag != null">useBalanceFlag,</if>
  2886. <if test="canRefundBeans != null">canRefundBeans,</if>
  2887. <if test="freePostageFee != null">freePostageFee,</if>
  2888. <if test="freePostageTicketID != null">freePostageTicketID,</if>
  2889. <if test="brokerage != null">brokerage,</if>
  2890. <if test="delFlag != null and delFlag != ''">delFlag,</if>
  2891. <if test="refundsAmount != null">refundsAmount,</if>
  2892. <if test="orderStatusFlag != null and orderStatusFlag != ''">orderStatusFlag,</if>
  2893. <if test="buyStatus != null and buyStatus != ''">buyStatus,</if>
  2894. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">deliveryTimeMills,</if>
  2895. <if test="orderDeliveryID != null">orderDeliveryID,</if>
  2896. <if test="splitFlag != null and splitFlag != ''">splitFlag,</if>
  2897. <if test="paying != null and paying != ''">paying,</if>
  2898. <if test="shopProductAmount != null">shopProductAmount,</if>
  2899. <if test="shopPostFee != null">shopPostFee,</if>
  2900. <if test="shopPostFlag != null and shopPostFlag != ''">shopPostFlag,</if>
  2901. <if test="shopTaxFee != null">shopTaxFee,</if>
  2902. <if test="payCmAmount != null">payCmAmount,</if>
  2903. <if test="shouldPayShopAmount != null">shouldPayShopAmount,</if>
  2904. <if test="payedShopAmount != null">payedShopAmount,</if>
  2905. <if test="shopOtherFee != null">shopOtherFee,</if>
  2906. <if test="receiptedFlag != null and receiptedFlag != ''">receiptedFlag,</if>
  2907. <if test="receiptedType != null and receiptedType != ''">receiptedType,</if>
  2908. <if test="costType != null and costType != ''">costType,</if>
  2909. <if test="proportional != null">proportional,</if>
  2910. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">modifyShouldPayNote,</if>
  2911. <if test="modifyShouldPayUserID != null">modifyShouldPayUserID,</if>
  2912. <if test="modifyShouldPayDate != null">modifyShouldPayDate,</if>
  2913. <if test="zeroCostFlag != null">zeroCostFlag,</if>
  2914. <if test="differenceType != null and differenceType != ''">differenceType,</if>
  2915. <if test="differencePrice != null">differencePrice,</if>
  2916. <if test="svipShopReduction != null">svipShopReduction,</if>
  2917. <if test="splitCode != null and splitCode != ''">splitCode,</if>
  2918. <if test="paySuccessCounter != null">paySuccessCounter,</if>
  2919. <if test="onlinePayWays != null and onlinePayWays != ''">onlinePayWays,</if>
  2920. <if test="status != null and status != ''">shopStatus,</if>
  2921. </trim>
  2922. <trim prefix="values (" suffix=")" suffixOverrides=",">
  2923. <if test="shopOrderID != null and shopOrderID != ''">#{shopOrderID},</if>
  2924. <if test="shopOrderNo != null and shopOrderNo != ''">#{shopOrderNo},</if>
  2925. <if test="orderNo != null and orderNo != ''">#{orderNo},</if>
  2926. <if test="orderID != null">#{orderID},</if>
  2927. <if test="organizeID != null">#{organizeID},</if>
  2928. <if test="isColdChina != null">#{isColdChina},</if>
  2929. <if test="userID != null">#{userID},</if>
  2930. <if test="shopID != null">#{shopID},</if>
  2931. <if test="orderPromotionsId != null">#{orderPromotionsId},</if>
  2932. <if test="orderType != null">#{orderType},</if>
  2933. <if test="orderSubmitType != null">#{orderSubmitType},</if>
  2934. <if test="presentNum != null">#{presentNum},</if>
  2935. <if test="itemCount != null">#{itemCount},</if>
  2936. <if test="outStoreNum != null">#{outStoreNum},</if>
  2937. <if test="outStoreTimes != null">#{outStoreTimes},</if>
  2938. <if test="townID != null">#{townID},</if>
  2939. <if test="note != null and note != ''">#{note},</if>
  2940. <if test="eachDiscount != null">#{eachDiscount},</if>
  2941. <if test="realPay != null">#{realPay},</if>
  2942. <if test="receiptAmount != null">#{receiptAmount},</if>
  2943. <if test="accountAmount != null">#{accountAmount},</if>
  2944. <if test="productAmount != null">#{productAmount},</if>
  2945. <if test="totalAmount != null">#{totalAmount},</if>
  2946. <if test="needPayAmount != null">#{needPayAmount},</if>
  2947. <if test="discountAmount != null">#{discountAmount},</if>
  2948. <if test="preferential != null">#{preferential},</if>
  2949. <if test="promotionFullReduction != null">#{promotionFullReduction},</if>
  2950. <if test="payFlag != null and payFlag != ''">#{payFlag},</if>
  2951. <if test="orderTime != null and orderTime != ''">#{orderTime},</if>
  2952. <if test="payTime != null and payTime != ''">#{payTime},</if>
  2953. <if test="finishTime != null and finishTime != ''">#{finishTime},</if>
  2954. <if test="autoOverTimeMills != null">#{autoOverTimeMills},</if>
  2955. <if test="settleStatus != null and settleStatus != ''">#{settleStatus},</if>
  2956. <if test="payStatus != null and payStatus != ''">#{payStatus},</if>
  2957. <if test="receiptStatus != null and receiptStatus != ''">#{receiptStatus},</if>
  2958. <if test="sendOutStatus != null and sendOutStatus != ''">#{sendOutStatus},</if>
  2959. <if test="refundStatus != null">#{refundStatus},</if>
  2960. <if test="returnGoodsStatus != null">#{returnGoodsStatus},</if>
  2961. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">#{receiveGoodsTime},</if>
  2962. <if test="autoReceiveTimeMills != null">#{autoReceiveTimeMills},</if>
  2963. <if test="totalAddedValueTax != null">#{totalAddedValueTax},</if>
  2964. <if test="canRefundAmount != null">#{canRefundAmount},</if>
  2965. <if test="refundAmount != null">#{refundAmount},</if>
  2966. <if test="clubID != null">#{clubID},</if>
  2967. <if test="spID != null">#{spID},</if>
  2968. <if test="mainSpID != null">#{mainSpID},</if>
  2969. <if test="orderBeanAmount != null">#{orderBeanAmount},</if>
  2970. <if test="useBeanAmount != null">#{useBeanAmount},</if>
  2971. <if test="useBeanFlag != null">#{useBeanFlag},</if>
  2972. <if test="canRefundFlag != null">#{canRefundFlag},</if>
  2973. <if test="useBalanceFlag != null">#{useBalanceFlag},</if>
  2974. <if test="canRefundBeans != null">#{canRefundBeans},</if>
  2975. <if test="freePostageFee != null">#{freePostageFee},</if>
  2976. <if test="freePostageTicketID != null">#{freePostageTicketID},</if>
  2977. <if test="brokerage != null">#{brokerage},</if>
  2978. <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
  2979. <if test="refundsAmount != null">#{refundsAmount},</if>
  2980. <if test="orderStatusFlag != null and orderStatusFlag != ''">#{orderStatusFlag},</if>
  2981. <if test="buyStatus != null and buyStatus != ''">#{buyStatus},</if>
  2982. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">#{deliveryTimeMills},</if>
  2983. <if test="orderDeliveryID != null">#{orderDeliveryID},</if>
  2984. <if test="splitFlag != null and splitFlag != ''">#{splitFlag},</if>
  2985. <if test="paying != null and paying != ''">#{paying},</if>
  2986. <if test="shopProductAmount != null">#{shopProductAmount},</if>
  2987. <if test="shopPostFee != null">#{shopPostFee},</if>
  2988. <if test="shopPostFlag != null and shopPostFlag != ''">#{shopPostFlag},</if>
  2989. <if test="shopTaxFee != null">#{shopTaxFee},</if>
  2990. <if test="payCmAmount != null">#{payCmAmount},</if>
  2991. <if test="shouldPayShopAmount != null">#{shouldPayShopAmount},</if>
  2992. <if test="payedShopAmount != null">#{payedShopAmount},</if>
  2993. <if test="shopOtherFee != null">#{shopOtherFee},</if>
  2994. <if test="receiptedFlag != null and receiptedFlag != ''">#{receiptedFlag},</if>
  2995. <if test="receiptedType != null and receiptedType != ''">#{receiptedType},</if>
  2996. <if test="costType != null and costType != ''">#{costType},</if>
  2997. <if test="proportional != null">#{proportional},</if>
  2998. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">#{modifyShouldPayNote},</if>
  2999. <if test="modifyShouldPayUserID != null">#{modifyShouldPayUserID},</if>
  3000. <if test="modifyShouldPayDate != null">#{modifyShouldPayDate},</if>
  3001. <if test="zeroCostFlag != null">#{zeroCostFlag},</if>
  3002. <if test="differenceType != null and differenceType != ''">#{differenceType},</if>
  3003. <if test="differencePrice != null">#{differencePrice},</if>
  3004. <if test="svipShopReduction != null">#{svipShopReduction},</if>
  3005. <if test="splitCode != null and splitCode != ''">#{splitCode},</if>
  3006. <if test="paySuccessCounter != null">#{paySuccessCounter},</if>
  3007. <if test="onlinePayWays != null and onlinePayWays != ''">#{onlinePayWays},</if>
  3008. <if test="status != null and status != ''">#{status},</if>
  3009. </trim>
  3010. </insert>
  3011. <update id="updateCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder">
  3012. update cm_shop_order
  3013. <trim prefix="SET" suffixOverrides=",">
  3014. <if test="shopOrderNo != null and shopOrderNo != ''">shopOrderNo = #{shopOrderNo},</if>
  3015. <if test="orderNo != null and orderNo != ''">orderNo = #{orderNo},</if>
  3016. <if test="orderID != null">orderID = #{orderID},</if>
  3017. <if test="organizeID != null">organizeID = #{organizeID},</if>
  3018. <if test="isColdChina != null">isColdChina = #{isColdChina},</if>
  3019. <if test="userID != null">userID = #{userID},</if>
  3020. <if test="shopID != null">shopID = #{shopID},</if>
  3021. <if test="orderPromotionsId != null">orderPromotionsId = #{orderPromotionsId},</if>
  3022. <if test="orderType != null">orderType = #{orderType},</if>
  3023. <if test="orderSubmitType != null">orderSubmitType = #{orderSubmitType},</if>
  3024. <if test="presentNum != null">presentNum = #{presentNum},</if>
  3025. <if test="itemCount != null">itemCount = #{itemCount},</if>
  3026. <if test="outStoreNum != null">outStoreNum = #{outStoreNum},</if>
  3027. <if test="outStoreTimes != null">outStoreTimes = #{outStoreTimes},</if>
  3028. <if test="townID != null">townID = #{townID},</if>
  3029. <if test="note != null and note != ''">note = #{note},</if>
  3030. <if test="eachDiscount != null">eachDiscount = #{eachDiscount},</if>
  3031. <if test="realPay != null">realPay = #{realPay},</if>
  3032. <if test="receiptAmount != null">receiptAmount = #{receiptAmount},</if>
  3033. <if test="accountAmount != null">accountAmount = #{accountAmount},</if>
  3034. <if test="productAmount != null">productAmount = #{productAmount},</if>
  3035. <if test="totalAmount != null">totalAmount = #{totalAmount},</if>
  3036. <if test="needPayAmount != null">needPayAmount = #{needPayAmount},</if>
  3037. <if test="discountAmount != null">discountAmount = #{discountAmount},</if>
  3038. <if test="preferential != null">preferential = #{preferential},</if>
  3039. <if test="promotionFullReduction != null">promotionFullReduction = #{promotionFullReduction},</if>
  3040. <if test="payFlag != null and payFlag != ''">payFlag = #{payFlag},</if>
  3041. <if test="orderTime != null and orderTime != ''">orderTime = #{orderTime},</if>
  3042. <if test="payTime != null and payTime != ''">payTime = #{payTime},</if>
  3043. <if test="finishTime != null and finishTime != ''">finishTime = #{finishTime},</if>
  3044. <if test="autoOverTimeMills != null">autoOverTimeMills = #{autoOverTimeMills},</if>
  3045. <if test="settleStatus != null and settleStatus != ''">settleStatus = #{settleStatus},</if>
  3046. <if test="payStatus != null and payStatus != ''">payStatus = #{payStatus},</if>
  3047. <if test="receiptStatus != null and receiptStatus != ''">receiptStatus = #{receiptStatus},</if>
  3048. <if test="sendOutStatus != null and sendOutStatus != ''">sendOutStatus = #{sendOutStatus},</if>
  3049. <if test="refundStatus != null">refundStatus = #{refundStatus},</if>
  3050. <if test="returnGoodsStatus != null">returnGoodsStatus = #{returnGoodsStatus},</if>
  3051. <if test="receiveGoodsTime != null and receiveGoodsTime != ''">receiveGoodsTime = #{receiveGoodsTime},</if>
  3052. <if test="autoReceiveTimeMills != null">autoReceiveTimeMills = #{autoReceiveTimeMills},</if>
  3053. <if test="totalAddedValueTax != null">totalAddedValueTax = #{totalAddedValueTax},</if>
  3054. <if test="canRefundAmount != null">canRefundAmount = #{canRefundAmount},</if>
  3055. <if test="refundAmount != null">refundAmount = #{refundAmount},</if>
  3056. <if test="clubID != null">clubID = #{clubID},</if>
  3057. <if test="spID != null">spID = #{spID},</if>
  3058. <if test="mainSpID != null">mainSpID = #{mainSpID},</if>
  3059. <if test="orderBeanAmount != null">orderBeanAmount = #{orderBeanAmount},</if>
  3060. <if test="useBeanAmount != null">useBeanAmount = #{useBeanAmount},</if>
  3061. <if test="useBeanFlag != null">useBeanFlag = #{useBeanFlag},</if>
  3062. <if test="canRefundFlag != null">canRefundFlag = #{canRefundFlag},</if>
  3063. <if test="useBalanceFlag != null">useBalanceFlag = #{useBalanceFlag},</if>
  3064. <if test="canRefundBeans != null">canRefundBeans = #{canRefundBeans},</if>
  3065. <if test="freePostageFee != null">freePostageFee = #{freePostageFee},</if>
  3066. <if test="freePostageTicketID != null">freePostageTicketID = #{freePostageTicketID},</if>
  3067. <if test="brokerage != null">brokerage = #{brokerage},</if>
  3068. <if test="delFlag != null and delFlag != ''">delFlag = #{delFlag},</if>
  3069. <if test="refundsAmount != null">refundsAmount = #{refundsAmount},</if>
  3070. <if test="orderStatusFlag != null and orderStatusFlag != ''">orderStatusFlag = #{orderStatusFlag},</if>
  3071. <if test="buyStatus != null and buyStatus != ''">buyStatus = #{buyStatus},</if>
  3072. <if test="deliveryTimeMills != null and deliveryTimeMills != ''">deliveryTimeMills = #{deliveryTimeMills},
  3073. </if>
  3074. <if test="orderDeliveryID != null">orderDeliveryID = #{orderDeliveryID},</if>
  3075. <if test="splitFlag != null and splitFlag != ''">splitFlag = #{splitFlag},</if>
  3076. <if test="paying != null and paying != ''">paying = #{paying},</if>
  3077. <if test="shopProductAmount != null">shopProductAmount = #{shopProductAmount},</if>
  3078. <if test="shopPostFee != null">shopPostFee = #{shopPostFee},</if>
  3079. <if test="shopPostFlag != null and shopPostFlag != ''">shopPostFlag = #{shopPostFlag},</if>
  3080. <if test="shopTaxFee != null">shopTaxFee = #{shopTaxFee},</if>
  3081. <if test="payCmAmount != null">payCmAmount = #{payCmAmount},</if>
  3082. <if test="shouldPayShopAmount != null">shouldPayShopAmount = #{shouldPayShopAmount},</if>
  3083. <if test="payedShopAmount != null">payedShopAmount = #{payedShopAmount},</if>
  3084. <if test="shopOtherFee != null">shopOtherFee = #{shopOtherFee},</if>
  3085. <if test="receiptedFlag != null and receiptedFlag != ''">receiptedFlag = #{receiptedFlag},</if>
  3086. <if test="receiptedType != null and receiptedType != ''">receiptedType = #{receiptedType},</if>
  3087. <if test="costType != null and costType != ''">costType = #{costType},</if>
  3088. <if test="proportional != null">proportional = #{proportional},</if>
  3089. <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">modifyShouldPayNote =
  3090. #{modifyShouldPayNote},
  3091. </if>
  3092. <if test="modifyShouldPayUserID != null">modifyShouldPayUserID = #{modifyShouldPayUserID},</if>
  3093. <if test="modifyShouldPayDate != null">modifyShouldPayDate = #{modifyShouldPayDate},</if>
  3094. <if test="zeroCostFlag != null">zeroCostFlag = #{zeroCostFlag},</if>
  3095. <if test="differenceType != null and differenceType != ''">differenceType = #{differenceType},</if>
  3096. <if test="differencePrice != null">differencePrice = #{differencePrice},</if>
  3097. <if test="svipShopReduction != null">svipShopReduction = #{svipShopReduction},</if>
  3098. <if test="splitCode != null and splitCode != ''">splitCode = #{splitCode},</if>
  3099. <if test="paySuccessCounter != null">paySuccessCounter = #{paySuccessCounter},</if>
  3100. <if test="onlinePayWays != null and onlinePayWays != ''">onlinePayWays = #{onlinePayWays},</if>
  3101. <if test="status != null and status != ''">shopStatus = #{status},</if>
  3102. </trim>
  3103. where shopOrderID = #{shopOrderID}
  3104. </update>
  3105. <update id="updateDelCmShopOrderByShopOrderIDs" parameterType="String">
  3106. update cm_shop_order set delFlag=#{delFlag} where shopOrderID in
  3107. <foreach item="shopOrderID" collection="shopOrderIDs" open="(" separator="," close=")">
  3108. #{shopOrderID}
  3109. </foreach>
  3110. </update>
  3111. <update id="updateStatus">
  3112. UPDATE cm_shop_order
  3113. SET shopStatus = #{status},
  3114. closeTime = NOW(),
  3115. closeReason = #{closeReason}
  3116. WHERE shopOrderID = #{shopOrderID}
  3117. </update>
  3118. <delete id="delCmShopOrderByShopOrderID" parameterType="String">
  3119. delete
  3120. from cm_shop_order
  3121. where shopOrderID = #{shopOrderID}
  3122. </delete>
  3123. <delete id="delCmShopOrderByShopOrderIDs" parameterType="String">
  3124. delete from cm_shop_order where shopOrderID in
  3125. <foreach item="shopOrderID" collection="shopOrderIDs" open="(" separator="," close=")">
  3126. #{shopOrderID}
  3127. </foreach>
  3128. </delete>
  3129. </mapper>