ShopOrderMapper.xml 168 KB

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