TradeOrderMapper.xml 143 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974
  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.yc.ship.module.trade.dal.mysql.order.TradeOrderMapper">
  4. <resultMap id="MiddleWareDtoResultMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
  5. <id property="id" column="id"/>
  6. <result property="orderNo" column="order_no"/>
  7. <result property="voyageId" column="voyage_id"/>
  8. <result property="bindId" column="bindId"/>
  9. <result property="isRead" column="isRead"/>
  10. <result property="sourceName" column="source_name"/>
  11. <result property="externalOrderNo" column="external_order_no"/>
  12. <result property="routePlanId" column="route_plan_id"/>
  13. <result property="routePlanName" column="route_plan_name"/>
  14. <result property="visitorType" column="visitor_type"/>
  15. <result property="travelDate" column="travel_date"/>
  16. <result property="sellMethod" column="sell_method"/>
  17. <result property="sourceName" column="source_name"/>
  18. <result property="sellerId" column="seller_id"/>
  19. <result property="memberId" column="member_id"/>
  20. <result property="amount" column="amount"/>
  21. <result property="payAmount" column="pay_amount"/>
  22. <result property="paymentStatus" column="pay_status"/>
  23. <result property="paymentType" column="payment_type"/>
  24. <result property="orderStatus" column="order_status"/>
  25. <result property="paymentDate" column="payment_date"/>
  26. <result property="areaManagerId" column="area_manager_id"/>
  27. <result property="storeName" column="store_name"/>
  28. <result property="contactName" column="contactName"/>
  29. <result property="shareName" column="share_name"/>
  30. <result property="isBind" column="is_bind"/>
  31. <result property="credentialNo" column="credentialNo"/>
  32. <result property="city" column="city"/>
  33. <result property="province" column="province"/>
  34. <result property="county" column="county"/>
  35. <result property="createTime" column="create_time"/>
  36. <result property="mobile" column="mobile"/>
  37. <result property="auditState" column="audit_state"/>
  38. <result property="storeId" column="store_id"/>
  39. <result property="sourceId" column="source_id"/>
  40. <result property="isMarketing" column="is_marketing"/>
  41. <result property="isMarketingUse" column="is_marketing_use"/>
  42. <result property="remark" column="remark"/>
  43. <result property="dispatchStatus" column="dispatch_status"/>
  44. <result property="isInvoice" column="is_invoice"/>
  45. <result property="isChangeOrder" column="is_change_order"/>
  46. <result property="refundAmount" column="refund_amount"/>
  47. <result property="confirmType" column="confirm_type"/>
  48. <result property="travelStatus" column="travel_status"/>
  49. <result property="finishStatus" column="finish_status"/>
  50. <result property="agencyGroupId" column="agency_group_id"/>
  51. <collection property="orderPayList" resultMap="orderPayList"/>
  52. <collection property="insuranceList" resultMap="insuranceResultMap"/>
  53. <collection property="contractList" resultMap="contractResultMap"/>
  54. </resultMap>
  55. <resultMap id="MiddleWareDtoResultMap2" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderPdaRespVO">
  56. <id property="id" column="id"/>
  57. <result property="orderNo" column="order_no"/>
  58. <result property="bindId" column="bindId"/>
  59. <result property="isRead" column="isRead"/>
  60. <result property="sourceName" column="source_name"/>
  61. <result property="externalOrderNo" column="external_order_no"/>
  62. <result property="routePlanId" column="route_plan_id"/>
  63. <result property="routePlanName" column="route_plan_name"/>
  64. <result property="visitorType" column="visitor_type"/>
  65. <result property="travelDate" column="travel_date"/>
  66. <result property="sellMethod" column="sell_method"/>
  67. <result property="sourceName" column="source_name"/>
  68. <result property="sellerId" column="seller_id"/>
  69. <result property="memberId" column="member_id"/>
  70. <result property="amount" column="amount"/>
  71. <result property="payAmount" column="pay_amount"/>
  72. <result property="paymentStatus" column="pay_status"/>
  73. <result property="paymentType" column="payment_type"/>
  74. <result property="orderStatus" column="order_status"/>
  75. <result property="paymentDate" column="payment_date"/>
  76. <result property="areaManagerId" column="area_manager_id"/>
  77. <result property="storeName" column="store_name"/>
  78. <result property="contactName" column="contactName"/>
  79. <result property="shareName" column="share_name"/>
  80. <result property="isBind" column="is_bind"/>
  81. <result property="credentialNo" column="credentialNo"/>
  82. <result property="city" column="city"/>
  83. <result property="province" column="province"/>
  84. <result property="county" column="county"/>
  85. <result property="createTime" column="create_time"/>
  86. <result property="mobile" column="mobile"/>
  87. <result property="auditState" column="audit_state"/>
  88. <result property="storeId" column="store_id"/>
  89. <result property="sourceId" column="source_id"/>
  90. <result property="isMarketing" column="is_marketing"/>
  91. <result property="isMarketingUse" column="is_marketing_use"/>
  92. <result property="remark" column="remark"/>
  93. <result property="dispatchStatus" column="dispatch_status"/>
  94. <result property="isInvoice" column="is_invoice"/>
  95. <result property="isChangeOrder" column="is_change_order"/>
  96. <result property="refundAmount" column="refund_amount"/>
  97. <result property="confirmType" column="confirm_type"/>
  98. <result property="travelStatus" column="travel_status"/>
  99. <result property="finishStatus" column="finish_status"/>
  100. <result property="agencyGroupId" column="agency_group_id"/>
  101. <collection property="orderPayList" resultMap="orderPayList"/>
  102. <collection property="insuranceList" resultMap="insuranceResultMap"/>
  103. <collection property="contractList" resultMap="contractResultMap"/>
  104. </resultMap>
  105. <resultMap id="orderPayList" type="com.yc.ship.module.trade.api.dto.TradeOrderPayDTO">
  106. <id property="id" column="payId"/>
  107. <result property="orderId" column="id"/>
  108. <result property="payAmount" column="payAmount"/>
  109. <result property="paymentNo" column="payment_no"/>
  110. <result property="payStatus" column="pay_status"/>
  111. <result property="paymentType" column="payment_type"/>
  112. <result property="paymentDate" column="payment_date"/>
  113. </resultMap>
  114. <resultMap id="insuranceResultMap" type="com.yc.ship.module.trade.dal.dataobject.insurance.InsuranceDO">
  115. <id property="id" column="insuranceId"/>
  116. <result property="orderId" column="id"/>
  117. <result property="policyNo" column="policy_no"/>
  118. <result property="proposalNo" column="proposal_no"/>
  119. <result property="insuranceNo" column="insurance_no"/>
  120. <result property="insuranceStatus" column="insurance_status"/>
  121. <result property="insuredNum" column="insured_num"/>
  122. <result property="insuranceEffectDate" column="insurance_effect_date"/>
  123. <result property="electronicPolicy" column="electronic_policy"/>
  124. </resultMap>
  125. <resultMap id="contractResultMap" type="com.yc.ship.module.trade.dal.dataobject.contract.ContractDO">
  126. <id property="id" column="contractId"/>
  127. <result property="orderId" column="id"/>
  128. <result property="contractNo" column="contract_no"/>
  129. <result property="status" column="status"/>
  130. <result property="touristsCount" column="tourists_count"/>
  131. <result property="contractUrl" column="contract_url"/>
  132. <result property="operateName" column="operate_name"/>
  133. <result property="signerName" column="signer_name"/>
  134. <result property="signerMobile" column="signer_mobile"/>
  135. <result property="signingTime" column="signing_time"/>
  136. <result property="signingUrl" column="signing_url"/>
  137. <result property="viewUrl" column="view_url"/>
  138. </resultMap>
  139. <resultMap id="RefundResultMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
  140. <id property="id" column="id"/>
  141. <result property="orderNo" column="order_no"/>
  142. <result property="sourceName" column="source_name"/>
  143. <result property="externalOrderNo" column="external_order_no"/>
  144. <result property="routePlanId" column="route_plan_id"/>
  145. <result property="visitorType" column="visitor_type"/>
  146. <result property="travelDate" column="travel_date"/>
  147. <result property="sellMethod" column="sell_method"/>
  148. <result property="sourceName" column="source_name"/>
  149. <result property="sellerId" column="seller_id"/>
  150. <result property="memberId" column="member_id"/>
  151. <result property="amount" column="amount"/>
  152. <result property="payAmount" column="pay_amount"/>
  153. <result property="orderStatus" column="order_status"/>
  154. <result property="paymentDate" column="payment_date"/>
  155. <result property="contactName" column="contact_name"/>
  156. <result property="credentialNo" column="credential_no"/>
  157. <result property="mobile" column="mobile"/>
  158. <result property="remark" column="remark"/>
  159. <collection property="tradeDetailList" resultMap="tradeDetailResultMap"/>
  160. </resultMap>
  161. <resultMap id="tradeDetailResultMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeDetailRespVO">
  162. <id property="orderId" column="id"/>
  163. <result property="id" column="detailId"/>
  164. <result property="voucherCode" column="voucher_code"/>
  165. <result property="voucherStatus" column="voucher_status"/>
  166. <result property="productName" column="product_name"/>
  167. <result property="specType" column="spec_type"/>
  168. <collection property="visitors" resultMap="visitorResultMap"/>
  169. </resultMap>
  170. <resultMap id="visitorResultMap" type="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
  171. <id property="detailId" column="detailId"/>
  172. <result property="id" column="visitorId"/>
  173. <result property="credentialNo" column="credential_no"/>
  174. <result property="credentialType" column="credential_type"/>
  175. <result property="name" column="name"/>
  176. </resultMap>
  177. <select id="getCategoryTreeList" resultType="com.yc.ship.module.product.api.dto.CategoryRespDTO">
  178. SELECT id,parent_id parentId,cate_name cateName,sort_num sortNum from product_category WHERE type = 1 AND use_status = 1 AND deleted = 0 AND tenant_id = #{tenantId} order by sort_num
  179. </select>
  180. <select id="getCategoryOTATreeList" resultType="com.yc.ship.module.product.api.dto.CategoryRespDTO">
  181. SELECT id,parent_id parentId,cate_name cateName,sort_num sortNum from product_category WHERE type = 1 AND use_status = 1 AND deleted = 0
  182. </select>
  183. <select id="selectTouristExportHead"
  184. resultType="java.util.Map">
  185. SELECT
  186. SUM(a.num) AS totalOrders,
  187. SUM(a.num1) AS adultNum,
  188. SUM(a.num2) AS childBabyNum,
  189. SUM(a.num3) AS withNum,
  190. SUM(a.num4) AS leaderNum,
  191. SUM(a.num5) AS babyNum,
  192. SUM(a.payAmount) AS totalPayAmount,
  193. SUM(a.actual_amount) AS totalActualAmount,
  194. SUM(a.deposi) as deposi,
  195. IFNULL((
  196. SELECT GROUP_CONCAT(CONCAT( nationalityName, '(', num, ')') SEPARATOR ' ')
  197. FROM (
  198. SELECT
  199. IFNULL(NULLIF(tv.nationality, ''), 1) AS nationalityCode,
  200. IFNULL(NULLIF(ar.name, ''), '中国') AS nationalityName,
  201. COUNT(1) AS num
  202. FROM trade_order td
  203. INNER JOIN trade_order_user tou ON td.id = tou.order_id AND tou.deleted = 0
  204. LEFT JOIN trade_visitor tv ON td.id = tv.order_id AND tv.deleted = 0
  205. LEFT JOIN trade_detail tdl ON tv.detail_id = tdl.id AND tdl.deleted = 0
  206. LEFT JOIN trade_order_room_model torm ON tv.room_index_id = torm.room_index_id AND torm.deleted = 0 AND td.id = torm.order_id
  207. LEFT JOIN resource_room_model rrm ON torm.room_model_id = rrm.id
  208. LEFT JOIN product_spu ps ON ps.id = tdl.product_id
  209. LEFT JOIN ota_distributor od ON od.id = td.source_id
  210. LEFT JOIN (select m2.order_id,sum(m2.refund_amount) refund_amount,sum(m2.origin_amount) origin_amount from trade_refund m2 where m2.refund_status = 6 and m2.refund_method !=2 GROUP BY m2.order_id) tr on td.id = tr.order_id
  211. LEFT JOIN area ar ON tv.nationality = ar.id
  212. WHERE td.deleted = 0
  213. AND tou.deleted = 0
  214. AND tv.type IS NOT NULL
  215. <include refid="commonWhereConditions"/>
  216. GROUP BY nationalityCode
  217. ) nationality_stats
  218. ), '') AS nationalityStats,
  219. IFNULL((
  220. SELECT GROUP_CONCAT(CONCAT(roomName, '(', roomNum, ')') SEPARATOR ',')
  221. FROM (
  222. SELECT
  223. CONCAT(rrm.name, torm.floor, 'F') AS roomName,
  224. torm.floor AS floor,
  225. COUNT(DISTINCT torm.room_index_id) AS roomNum
  226. FROM trade_order td
  227. INNER JOIN trade_order_user tou ON td.id = tou.order_id AND tou.deleted = 0
  228. LEFT JOIN trade_visitor tv ON td.id = tv.order_id AND tv.deleted = 0
  229. LEFT JOIN trade_detail tdl ON tv.detail_id = tdl.id AND tdl.deleted = 0
  230. LEFT JOIN trade_order_room_model torm ON tv.room_index_id = torm.room_index_id AND torm.deleted = 0 AND td.id = torm.order_id
  231. LEFT JOIN resource_room_model rrm ON torm.room_model_id = rrm.id
  232. LEFT JOIN product_spu ps ON ps.id = tdl.product_id
  233. LEFT JOIN ota_distributor od ON od.id = td.source_id
  234. LEFT JOIN (select m2.order_id,sum(m2.refund_amount) refund_amount,sum(m2.origin_amount) origin_amount from trade_refund m2 where m2.refund_status = 6 and m2.refund_method !=2 GROUP BY m2.order_id) tr on td.id = tr.order_id
  235. WHERE td.deleted = 0
  236. AND tou.deleted = 0
  237. AND tv.type IS NOT NULL
  238. <include refid="commonWhereConditions"/>
  239. GROUP BY rrm.name, torm.floor
  240. ORDER BY torm.floor
  241. ) room_stats
  242. ), '') AS roomStats,
  243. (
  244. SELECT COUNT(DISTINCT torm.room_index_id)
  245. FROM trade_order td
  246. INNER JOIN trade_order_user tou ON td.id = tou.order_id AND tou.deleted = 0
  247. LEFT JOIN trade_visitor tv ON td.id = tv.order_id AND tv.deleted = 0
  248. LEFT JOIN trade_detail tdl ON tv.detail_id = tdl.id AND tdl.deleted = 0
  249. LEFT JOIN trade_order_room_model torm ON tv.room_index_id = torm.room_index_id AND torm.deleted = 0 AND td.id = torm.order_id
  250. LEFT JOIN resource_room_model rrm ON torm.room_model_id = rrm.id
  251. LEFT JOIN product_spu ps ON ps.id = tdl.product_id
  252. LEFT JOIN ota_distributor od ON od.id = td.source_id
  253. LEFT JOIN (select m2.order_id,sum(m2.refund_amount) refund_amount,sum(m2.origin_amount) origin_amount from trade_refund m2 where m2.refund_status = 6 and m2.refund_method !=2 GROUP BY m2.order_id) tr on td.id = tr.order_id
  254. WHERE td.deleted = 0
  255. AND tou.deleted = 0
  256. AND tv.type IS NOT NULL
  257. <include refid="commonWhereConditions"/>
  258. ) AS totalRooms
  259. FROM (
  260. SELECT
  261. COUNT(1) AS num,
  262. SUM(CASE WHEN tv.type IN ('adultPlus', 'adultTake') or tv.type IS NULL or tv.type = '' THEN 1 ELSE 0 END) AS num1,
  263. SUM(CASE WHEN tv.type IN ('childTake','childPlus','childNonTake') THEN 1 ELSE 0 END) AS num2,
  264. SUM(CASE WHEN tv.type = 'with' THEN 1 ELSE 0 END) AS num3,
  265. SUM(CASE WHEN tv.type = 'leader' THEN 1 ELSE 0 END) AS num4,
  266. SUM(CASE WHEN tv.type IN ('babyTake','babyPlus','babyNonTake') THEN 1 ELSE 0 END) AS num5,
  267. td.pay_amount AS payAmount,
  268. td.deposi,
  269. IFNULL(topay.actual_amount, 0) AS actual_amount
  270. FROM trade_order td
  271. INNER JOIN trade_order_user tou ON td.id = tou.order_id AND tou.deleted = 0
  272. LEFT JOIN trade_visitor tv ON td.id = tv.order_id AND tv.deleted = 0
  273. LEFT JOIN trade_detail tdl ON tv.detail_id = tdl.id AND tdl.deleted = 0
  274. LEFT JOIN product_spu ps ON ps.id = tdl.product_id
  275. LEFT JOIN ota_distributor od ON od.id = td.source_id
  276. LEFT JOIN (select m2.order_id,sum(m2.refund_amount) refund_amount,sum(m2.origin_amount) origin_amount from trade_refund m2 where m2.refund_status = 6 and m2.refund_method !=2 GROUP BY m2.order_id) tr on td.id = tr.order_id
  277. left join trade_order_room_model torm on tv.room_index_id = torm.room_index_id and torm.deleted =0 AND td.id = torm.order_id
  278. LEFT JOIN (
  279. SELECT order_id, SUM(pay_amount) AS actual_amount
  280. FROM trade_order_pay
  281. WHERE pay_status = 1 or order_type = 2
  282. GROUP BY order_id
  283. ) topay ON td.id = topay.order_id
  284. WHERE
  285. td.deleted = 0
  286. AND tv.type IS NOT NULL
  287. <include refid="commonWhereConditions"/>
  288. GROUP BY td.id, td.pay_amount) a
  289. </select>
  290. <!-- 公共查询条件 -->
  291. <sql id="commonWhereConditions">
  292. <if test="vo.orderStatus!=null and vo.orderStatus.size()>0">
  293. AND td.order_status IN
  294. <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
  295. #{item}
  296. </foreach>
  297. </if>
  298. <if test="vo.tenantId!=null">
  299. AND td.tenant_id = #{vo.tenantId}
  300. </if>
  301. <choose>
  302. <when test="vo.orderNo != null and vo.orderNo.length() == 4">
  303. AND td.order_no LIKE CONCAT('%',#{vo.orderNo})
  304. </when>
  305. <when test="vo.orderNo != null and vo.orderNo != ''">
  306. AND td.order_no = #{vo.orderNo}
  307. </when>
  308. <otherwise>
  309. </otherwise>
  310. </choose>
  311. <if test="vo.memberId != null and vo.memberId != ''">
  312. AND td.member_id = #{vo.memberId}
  313. </if>
  314. <if test="vo.voyageId != null and vo.voyageId != ''">
  315. AND td.voyage_id = #{vo.voyageId}
  316. </if>
  317. <if test="vo.shipId != null and vo.shipId != ''">
  318. AND td.ship_id = #{vo.shipId}
  319. </if>
  320. <if test="vo.routeId != null and vo.routeId != ''">
  321. AND EXISTS (SELECT 1 FROM product_voyage top WHERE top.id = td.voyage_id AND top.route_id = #{vo.routeId})
  322. </if>
  323. <if test="vo.dispatchStatus != null">
  324. AND td.dispatch_status = #{vo.dispatchStatus}
  325. </if>
  326. <if test="vo.payType != null">
  327. AND EXISTS (SELECT 1 FROM trade_order_pay top WHERE top.order_id = td.id AND top.payment_type = #{vo.payType})
  328. </if>
  329. <if test="vo.otaCateId != null and vo.otaCateId != ''">
  330. AND od.ota_category_id = #{vo.otaCateId}
  331. </if>
  332. <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
  333. AND od.ota_category_id IN
  334. <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
  335. #{item}
  336. </foreach>
  337. </if>
  338. <if test="vo.otaId != null and vo.otaId != ''">
  339. AND td.source_id = #{vo.otaId}
  340. </if>
  341. <if test="vo.otaIds != null and vo.otaIds.size()>0">
  342. AND td.source_id IN
  343. <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
  344. #{item}
  345. </foreach>
  346. </if>
  347. <if test="vo.storeId != null and vo.storeId != ''">
  348. AND td.store_id = #{vo.storeId}
  349. </if>
  350. <if test="vo.productTag != null and vo.productTag != ''">
  351. AND ps.product_tag = #{vo.productTag}
  352. </if>
  353. <if test="vo.productTag2 != null and vo.productTag2 != ''">
  354. AND ps.product_tag2 = #{vo.productTag2}
  355. </if>
  356. <if test="vo.productTag3 != null and vo.productTag3 != ''">
  357. AND ps.product_tag3 = #{vo.productTag3}
  358. </if>
  359. <if test="vo.productTag4 != null and vo.productTag4 != ''">
  360. AND ps.product_tag4 = #{vo.productTag4}
  361. </if>
  362. <if test="vo.cateIds!=null and vo.cateIds.size()>0 and (vo.planIds==null or vo.planIds.size()==0)">
  363. AND tdl.product_id IN
  364. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  365. #{item}
  366. </foreach>
  367. </if>
  368. <if test="vo.externalOrderNo != null and vo.externalOrderNo != ''">
  369. AND td.external_order_no = #{vo.externalOrderNo}
  370. </if>
  371. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  372. AND EXISTS (SELECT tv.id FROM trade_visitor tv WHERE tv.detail_id = tdl.id AND tv.credential_no = #{vo.credentialNo})
  373. </if>
  374. <if test="vo.userName != null and vo.userName != ''">
  375. AND EXISTS (SELECT tv.id FROM trade_visitor tv WHERE tv.detail_id = tdl.id AND tv.name = #{vo.userName})
  376. </if>
  377. <choose>
  378. <when test="vo.mobile != null and vo.mobile.length() == 4">
  379. AND tou.mobile LIKE CONCAT('%',#{vo.mobile})
  380. </when>
  381. <when test="vo.mobile != null and vo.mobile != ''">
  382. AND tou.mobile = #{vo.mobile}
  383. </when>
  384. <otherwise>
  385. </otherwise>
  386. </choose>
  387. <if test="vo.contactName != null and vo.contactName != ''">
  388. AND tou.contact_name = #{vo.contactName}
  389. </if>
  390. <if test="vo.travelDate != null and vo.travelDate != ''">
  391. AND td.travel_date = #{vo.travelDate}
  392. </if>
  393. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  394. AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  395. </if>
  396. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  397. AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  398. </if>
  399. <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
  400. AND td.create_time <![CDATA[ >= ]]> #{vo.orderDateStart}
  401. </if>
  402. <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
  403. AND td.create_time <![CDATA[ <= ]]> #{vo.orderDateEnd}
  404. </if>
  405. <if test="vo.orderDate != null and vo.orderDate != ''">
  406. AND td.create_time = #{vo.orderDate}
  407. </if>
  408. <if test="vo.sellerId != null and vo.sellerId != ''">
  409. AND td.seller_id = #{vo.sellerId}
  410. </if>
  411. <if test="vo.shareName != null and vo.shareName != ''">
  412. AND td.share_name LIKE CONCAT('%',#{vo.shareName},'%')
  413. </if>
  414. <if test="vo.voucherCode != null and vo.voucherCode != ''">
  415. AND tdl.voucher_code = #{vo.voucherCode}
  416. </if>
  417. <if test="vo.sellMethod != null and vo.sellMethod != ''">
  418. AND td.sell_method = #{vo.sellMethod}
  419. </if>
  420. <if test="vo.productName != null and vo.productName != ''">
  421. AND tdl.product_name LIKE CONCAT('%',#{vo.productName}, '%')
  422. </if>
  423. <if test="vo.isFullPay == 0">
  424. AND td.is_full_pay = #{vo.isFullPay}
  425. </if>
  426. <if test="vo.isComment != null">
  427. AND td.is_comment = #{vo.isComment}
  428. </if>
  429. <if test="vo.sourceId != null and vo.sourceId != ''">
  430. AND td.source_id = #{vo.sourceId}
  431. </if>
  432. <if test="vo.distributorId != null and vo.distributorId != ''">
  433. AND td.source_id = #{vo.distributorId}
  434. </if>
  435. <if test="vo.sourceName != null and vo.sourceName != ''">
  436. AND td.source_name LIKE CONCAT('%',#{vo.sourceName}, '%')
  437. </if>
  438. <if test="vo.travelStatus != null">
  439. AND td.travel_status = #{vo.travelStatus}
  440. </if>
  441. <if test="vo.roomModelId != null and vo.roomModelId != ''">
  442. AND torm.room_model_id = #{vo.roomModelId}
  443. </if>
  444. <if test="vo.floor != null and vo.floor != ''">
  445. AND torm.floor = #{vo.floor}
  446. </if>
  447. <if test="vo.orderRefundDateStart != null and vo.orderRefundDateEnd != ''">
  448. AND EXISTS (SELECT 1 FROM trade_refund tr WHERE tr.order_id=td.id AND tr.refund_status = 6 AND tr.refund_time BETWEEN #{vo.orderRefundDateStart} and #{vo.orderRefundDateEnd})
  449. </if>
  450. </sql>
  451. <select id="getDailyBusinessStatisticsPage"
  452. resultType="com.yc.ship.module.trade.controller.admin.business.vo.DailyBusinessStatisticsRespVO">
  453. SELECT
  454. td.source_id AS sourceId,
  455. td.source_name as sourceName,
  456. IFNULL(tot.free_num, 0) AS freeNum,
  457. 0 AS freeCount,
  458. IFNULL(topay.actual_amount, 0) AS actualAmount,
  459. COUNT(1) AS totalCount,
  460. SUM(CASE WHEN tv.type IN ('adultPlus', 'adultTake') THEN 1 ELSE 0 END) AS adultCount,
  461. SUM(CASE WHEN tv.type IN ('childTake','childPlus','childNonTake') THEN 1 ELSE 0 END) AS childCount,
  462. SUM(CASE WHEN tv.type = 'with' THEN 1 ELSE 0 END) AS withCount,
  463. SUM(CASE WHEN tv.type = 'leader' THEN 1 ELSE 0 END) AS leaderCount,
  464. SUM(CASE WHEN tv.type IN ('babyTake','babyPlus','babyNonTake') THEN 1 ELSE 0 END) AS infantCount,
  465. COUNT(1) - IFNULL(tot.free_num, 0) AS validCount
  466. FROM trade_order td
  467. INNER JOIN trade_order_user tou ON td.id = tou.order_id AND tou.deleted = 0
  468. LEFT JOIN trade_detail tdl ON td.id = tdl.order_id AND tdl.deleted = 0
  469. LEFT JOIN trade_visitor tv ON tdl.id = tv.detail_id AND tv.deleted = 0
  470. left join trade_order_total tot on td.id = tot.old_order_id and tot.deleted = 0
  471. LEFT JOIN (SELECT order_id, SUM(pay_amount) AS actual_amount
  472. FROM trade_order_pay
  473. WHERE pay_status = 1 GROUP BY order_id) topay ON td.id = topay.order_id
  474. WHERE
  475. td.deleted = 0
  476. AND tv.type IS NOT NULL
  477. AND td.order_status > 0
  478. <if test="vo.voyageId != null and vo.voyageId != ''">
  479. AND td.voyage_id = #{vo.voyageId}
  480. </if>
  481. <if test="vo.routeId != null and vo.routeId != ''">
  482. AND exists (select 1 from product_voyage top where top.id = td.voyage_id and top.route_id = #{vo.routeId})
  483. </if>
  484. GROUP BY td.source_id;
  485. </select>
  486. <select id="findOrderIdsByCondition" resultType="java.lang.Long">
  487. SELECT DISTINCT td.id
  488. FROM trade_order td
  489. INNER JOIN trade_order_user tou ON td.id = tou.order_id AND tou.deleted = 0
  490. LEFT JOIN trade_detail tdl ON td.id = tdl.order_id AND tdl.deleted = 0
  491. LEFT JOIN product_spu ps ON ps.id = tdl.product_id and ps.deleted=0
  492. LEFT JOIN ota_distributor od ON od.id = td.source_id and od.deleted=0
  493. <if test="vo.categoryIds != null and vo.categoryIds.size() > 0">
  494. INNER JOIN ota_distributor_category_his his
  495. ON his.distributor_id = od.id
  496. AND his.deleted = 0
  497. AND td.create_time <![CDATA[ >= ]]> his.start_time
  498. AND td.create_time <![CDATA[ <= ]]> IFNULL(his.end_time, NOW())
  499. AND his.ota_category_id IN
  500. <foreach collection="vo.categoryIds" item="item" open="(" separator="," close=")">#{item}</foreach>
  501. </if>
  502. LEFT JOIN trade_order_room_model torm ON torm.order_id = td.id and torm.deleted=0
  503. WHERE td.deleted = 0
  504. <if test="vo.orderStatus!=null and vo.orderStatus.size()>0">
  505. and td.order_status in
  506. <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
  507. #{item}
  508. </foreach>
  509. </if>
  510. <if test="vo.tenantId!=null">
  511. AND td.tenant_id = #{vo.tenantId}
  512. </if>
  513. <choose>
  514. <when test="vo.orderNo != null and vo.orderNo.length() == 4">
  515. AND td.order_no like concat('%',#{vo.orderNo})
  516. </when>
  517. <when test="vo.orderNo != null and vo.orderNo != ''">
  518. AND td.order_no = #{vo.orderNo}
  519. </when>
  520. <otherwise>
  521. </otherwise>
  522. </choose>
  523. <if test="vo.memberId != null and vo.memberId != ''">
  524. AND td.member_id = #{vo.memberId}
  525. </if>
  526. <if test="vo.voyageId != null and vo.voyageId != ''">
  527. AND td.voyage_id = #{vo.voyageId}
  528. </if>
  529. <if test="vo.shipId != null and vo.shipId != ''">
  530. AND td.ship_id = #{vo.shipId}
  531. </if>
  532. <if test="vo.routeId != null and vo.routeId != ''">
  533. AND exists (select 1 from product_voyage top where top.id = td.voyage_id and top.route_id = #{vo.routeId})
  534. </if>
  535. <if test="vo.dispatchStatus != null">
  536. AND td.dispatch_status = #{vo.dispatchStatus}
  537. </if>
  538. <if test="vo.payType != null">
  539. AND exists (select 1 from trade_order_pay top where top.order_id = td.id and top.payment_type = #{vo.payType})
  540. </if>
  541. <if test="vo.otaCateId != null and vo.otaCateId != ''">
  542. AND od.ota_category_id = #{vo.otaCateId}
  543. </if>
  544. <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
  545. and od.ota_category_id in
  546. <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
  547. #{item}
  548. </foreach>
  549. </if>
  550. <if test="vo.otaId != null and vo.otaId != ''">
  551. AND td.source_id = #{vo.otaId}
  552. </if>
  553. <if test="vo.otaIds != null and vo.otaIds.size()>0">
  554. AND td.source_id IN
  555. <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
  556. #{item}
  557. </foreach>
  558. </if>
  559. <if test="vo.storeId != null and vo.storeId != ''">
  560. AND td.store_id = #{vo.storeId}
  561. </if>
  562. <if test="vo.productTag != null and vo.productTag != ''">
  563. AND ps.product_tag = #{vo.productTag}
  564. </if>
  565. <if test="vo.productTag2 != null and vo.productTag2 != ''">
  566. AND ps.product_tag2 = #{vo.productTag2}
  567. </if>
  568. <if test="vo.productTag3 != null and vo.productTag3 != ''">
  569. AND ps.product_tag3 = #{vo.productTag3}
  570. </if>
  571. <if test="vo.productTag4 != null and vo.productTag4 != ''">
  572. AND ps.product_tag4 = #{vo.productTag4}
  573. </if>
  574. <if test="vo.cateIds!=null and vo.cateIds.size()>0 and (vo.planIds==null or vo.planIds.size()==0)">
  575. AND tdl.product_id in
  576. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  577. #{item}
  578. </foreach>
  579. </if>
  580. <if test="vo.additiveIds!=null and vo.additiveIds.size()>0">
  581. and tdl.product_id in
  582. <foreach collection="vo.additiveIds" item="item" separator="," open="(" close=")">
  583. #{item}
  584. </foreach>
  585. </if>
  586. <if test="vo.externalOrderNo != null and vo.externalOrderNo != ''">
  587. AND td.external_order_no = #{vo.externalOrderNo}
  588. </if>
  589. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  590. AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.credential_no = #{vo.credentialNo})
  591. </if>
  592. <if test="vo.userName != null and vo.userName != ''">
  593. AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.name = #{vo.userName})
  594. </if>
  595. <choose>
  596. <when test="vo.mobile != null and vo.mobile.length() == 4">
  597. AND tou.mobile like concat('%',#{vo.mobile})
  598. </when>
  599. <when test="vo.mobile != null and vo.mobile != ''">
  600. AND tou.mobile = #{vo.mobile}
  601. </when>
  602. <otherwise>
  603. </otherwise>
  604. </choose>
  605. <if test="vo.contactName != null and vo.contactName != ''">
  606. AND tou.contact_name = #{vo.contactName}
  607. </if>
  608. <if test="vo.travelDate != null and vo.travelDate != ''">
  609. AND td.travel_date = #{vo.travelDate}
  610. </if>
  611. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  612. AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  613. </if>
  614. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  615. AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  616. </if>
  617. <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
  618. AND td.create_time <![CDATA[ >= ]]> #{vo.orderDateStart}
  619. </if>
  620. <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
  621. AND td.create_time <![CDATA[ <= ]]> #{vo.orderDateEnd}
  622. </if>
  623. <if test="vo.orderDate != null and vo.orderDate != ''">
  624. AND td.create_time = #{vo.orderDate}
  625. </if>
  626. <if test="vo.sellerId != null and vo.sellerId != ''">
  627. AND td.seller_id = #{vo.sellerId}
  628. </if>
  629. <if test="vo.shareName != null and vo.shareName != ''">
  630. AND td.share_name like concat('%',#{vo.shareName},'%')
  631. </if>
  632. <if test="vo.voucherCode != null and vo.voucherCode != ''">
  633. AND tdl.voucher_code = #{vo.voucherCode}
  634. </if>
  635. <if test="vo.sellMethod != null and vo.sellMethod != ''">
  636. AND td.sell_method = #{vo.sellMethod}
  637. </if>
  638. <if test="vo.productName != null and vo.productName != ''">
  639. AND tdl.product_name like concat('%',#{vo.productName}, '%')
  640. </if>
  641. <if test="vo.isFullPay == 0">
  642. AND td.is_full_pay = #{vo.isFullPay}
  643. </if>
  644. <if test="vo.isComment != null">
  645. AND td.is_comment = #{vo.isComment}
  646. </if>
  647. <if test="vo.sourceId != null and vo.sourceId != ''">
  648. AND td.source_id = #{vo.sourceId}
  649. </if>
  650. <if test="vo.paymentStatus != null">
  651. AND td.pay_status = #{vo.paymentStatus}
  652. </if>
  653. <if test="vo.distributorId != null and vo.distributorId != ''">
  654. AND td.source_id = #{vo.distributorId}
  655. </if>
  656. <if test="vo.sourceName != null and vo.sourceName != ''">
  657. AND td.source_name like concat('%',#{vo.sourceName}, '%')
  658. </if>
  659. <if test="vo.travelStatus != null">
  660. AND td.travel_status = #{vo.travelStatus}
  661. </if>
  662. <if test="vo.roomModelId != null and vo.roomModelId != ''">
  663. AND torm.room_model_id = #{vo.roomModelId}
  664. </if>
  665. <if test="vo.roomModelIds!=null and vo.roomModelIds.size()>0">
  666. and torm.room_model_id in
  667. <foreach collection="vo.roomModelIds" item="item" separator="," open="(" close=")">
  668. #{item}
  669. </foreach>
  670. </if>
  671. <if test="vo.floor != null and vo.floor != ''">
  672. AND torm.floor = #{vo.floor}
  673. </if>
  674. <if test="vo.isInsure != null and vo.isInsure != ''">
  675. AND td.is_insure = #{vo.isInsure}
  676. </if>
  677. <if test="vo.orderRefundDateStart != null and vo.orderRefundDateEnd != ''">
  678. AND exists (select 1 from trade_refund tr where tr.order_id=td.id and tr.refund_status = 6 and tr.refund_time BETWEEN #{vo.orderRefundDateStart} and #{vo.orderRefundDateEnd} )
  679. </if>
  680. ORDER BY
  681. <choose>
  682. <!-- 有前端排序:只使用前端多字段排序 -->
  683. <when test="vo.sortField != null and vo.sortField != '' and vo.sortOrder != null and vo.sortOrder != ''">
  684. <foreach collection="vo.sortField.split(',')" index="index" item="field" separator=",">
  685. <choose>
  686. <when test="field == 'orderSort'">td.order_sort</when>
  687. <when test="field == 'sourceName'">td.source_id</when>
  688. <when test="field == 'voyage.name'">
  689. (SELECT pv.name FROM product_voyage pv WHERE pv.id = td.voyage_id AND pv.deleted = 0)
  690. </when>
  691. <when test="field == 'totalPerson'">
  692. (SELECT COUNT(DISTINCT v1.id)
  693. FROM trade_visitor v1
  694. WHERE v1.order_id = td.id
  695. AND v1.deleted = 0)
  696. </when>
  697. </choose>
  698. ${vo.sortOrder.split(',')[index]}
  699. </foreach>
  700. </when>
  701. <!-- 无前端排序:默认排序 -->
  702. <otherwise>
  703. td.create_time DESC
  704. </otherwise>
  705. </choose>
  706. </select>
  707. <select id="findOrderDetailByIds"
  708. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
  709. SELECT td.*,
  710. tins.res_msg,
  711. toa.audit_time auditTime,
  712. tou.contact_name,
  713. tou.credential_no,
  714. tou.mobile,
  715. count(tdl.id) num,
  716. sum(CASE WHEN tdl.voucher_status IN (1,2,3,4,6,8,9) THEN 1 ELSE 0 END) realnum,
  717. (tr.origin_amount - tr.refund_amount) feeAmount,
  718. tdl.product_name,
  719. tdl.spec_type,
  720. ifnull(tr.origin_amount - tr.refund_amount, 0) realAmount,
  721. tr.refund_amount refundAmount,
  722. ps.product_tag productTag,
  723. ps.product_tag2 productTag2
  724. FROM trade_order td
  725. INNER JOIN trade_order_user tou ON td.id = tou.order_id AND tou.deleted = 0
  726. LEFT JOIN trade_detail tdl ON td.id = tdl.order_id AND tdl.deleted = 0
  727. LEFT JOIN product_spu ps ON ps.id = tdl.product_id and ps.deleted = 0
  728. LEFT JOIN trade_order_audit toa ON toa.order_id = td.id AND toa.audit_status = 1 AND toa.deleted = 0
  729. LEFT JOIN (
  730. SELECT order_id,
  731. sum(refund_amount) refund_amount,
  732. sum(origin_amount) origin_amount
  733. FROM trade_refund
  734. WHERE refund_status = 6 AND refund_method != 2 AND deleted = 0
  735. GROUP BY order_id
  736. ) tr ON td.id = tr.order_id
  737. LEFT JOIN trade_insurance tins ON tins.order_id = td.id AND tins.deleted = 0
  738. WHERE td.id IN
  739. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  740. #{id}
  741. </foreach>
  742. GROUP BY td.id
  743. ORDER BY
  744. <choose>
  745. <!-- 有前端排序:只使用前端多字段排序 -->
  746. <when test="vo.sortField != null and vo.sortField != '' and vo.sortOrder != null and vo.sortOrder != ''">
  747. <foreach collection="vo.sortField.split(',')" index="index" item="field" separator=",">
  748. <choose>
  749. <when test="field == 'orderSort'">td.order_sort</when>
  750. <when test="field == 'sourceName'">td.source_id</when>
  751. <when test="field == 'voyage.name'">
  752. (SELECT pv.name FROM product_voyage pv WHERE pv.id = td.voyage_id AND pv.deleted = 0)
  753. </when>
  754. <when test="field == 'totalPerson'">
  755. (SELECT COUNT(DISTINCT v1.id)
  756. FROM trade_visitor v1
  757. WHERE v1.order_id = td.id
  758. AND v1.deleted = 0)
  759. </when>
  760. </choose>
  761. ${vo.sortOrder.split(',')[index]}
  762. </foreach>
  763. </when>
  764. <!-- 无前端排序:默认排序 -->
  765. <otherwise>
  766. td.create_time DESC
  767. </otherwise>
  768. </choose>
  769. </select>
  770. <select id="getTradeOrderUserPage"
  771. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
  772. SELECT td.*,tins.res_msg,toa.audit_time auditTime,tou.contact_name,tou.credential_no,tou.mobile,count(tdl.id) num,sum(CASE WHEN tdl.voucher_status in (1,2,3,4,6,8,9) THEN 1 ELSE 0 END) realnum,(tr.origin_amount-tr.refund_amount) feeAmount,tdl.product_name,tdl.spec_type,ifnull(tr.origin_amount-tr.refund_amount,0) realAmount
  773. ,tr.refund_amount refundAmount,
  774. ps.product_tag productTag,ps.product_tag2 productTag2,ps.product_tag3 productTag3,ps.product_tag4 productTag4
  775. FROM trade_order td
  776. INNER JOIN trade_order_user tou on td.id = tou.order_id
  777. left JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
  778. left JOIN product_spu ps on ps.id = tdl.product_id
  779. LEFT JOIN ota_distributor od on od.id = td.source_id
  780. LEFT JOIN trade_order_audit toa on toa.order_id = td.id and toa.audit_status = 1
  781. LEFT JOIN (select m2.order_id,sum(m2.refund_amount) refund_amount,sum(m2.origin_amount) origin_amount from trade_refund m2 where m2.refund_status = 6 and m2.refund_method !=2 GROUP BY m2.order_id) tr on td.id = tr.order_id
  782. LEFT JOIN trade_order_room_model torm on torm.order_id = td.id
  783. left join trade_insurance tins on tins.order_id = td.id
  784. where td.deleted = 0 and tou.deleted = 0 and (tins.deleted = 0 or tins.deleted is null)
  785. <if test="vo.orderStatus!=null and vo.orderStatus.size()>0">
  786. and td.order_status in
  787. <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
  788. #{item}
  789. </foreach>
  790. </if>
  791. <if test="vo.tenantId!=null">
  792. AND td.tenant_id = #{vo.tenantId}
  793. </if>
  794. <choose>
  795. <when test="vo.orderNo != null and vo.orderNo.length() == 4">
  796. AND td.order_no like concat('%',#{vo.orderNo})
  797. </when>
  798. <when test="vo.orderNo != null and vo.orderNo != ''">
  799. AND td.order_no = #{vo.orderNo}
  800. </when>
  801. <otherwise>
  802. </otherwise>
  803. </choose>
  804. <if test="vo.memberId != null and vo.memberId != ''">
  805. AND td.member_id = #{vo.memberId}
  806. </if>
  807. <if test="vo.voyageId != null and vo.voyageId != ''">
  808. AND td.voyage_id = #{vo.voyageId}
  809. </if>
  810. <if test="vo.shipId != null and vo.shipId != ''">
  811. AND td.ship_id = #{vo.shipId}
  812. </if>
  813. <if test="vo.routeId != null and vo.routeId != ''">
  814. AND exists (select 1 from product_voyage top where top.id = td.voyage_id and top.route_id = #{vo.routeId})
  815. </if>
  816. <if test="vo.dispatchStatus != null">
  817. AND td.dispatch_status = #{vo.dispatchStatus}
  818. </if>
  819. <if test="vo.payType != null">
  820. AND exists (select 1 from trade_order_pay top where top.order_id = td.id and top.payment_type = #{vo.payType})
  821. </if>
  822. <if test="vo.otaCateId != null and vo.otaCateId != ''">
  823. AND od.ota_category_id = #{vo.otaCateId}
  824. </if>
  825. <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
  826. and od.ota_category_id in
  827. <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
  828. #{item}
  829. </foreach>
  830. </if>
  831. <if test="vo.otaId != null and vo.otaId != ''">
  832. AND td.source_id = #{vo.otaId}
  833. </if>
  834. <if test="vo.otaIds != null and vo.otaIds.size()>0">
  835. AND td.source_id IN
  836. <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
  837. #{item}
  838. </foreach>
  839. </if>
  840. <if test="vo.storeId != null and vo.storeId != ''">
  841. AND td.store_id = #{vo.storeId}
  842. </if>
  843. <if test="vo.productTag != null and vo.productTag != ''">
  844. AND ps.product_tag = #{vo.productTag}
  845. </if>
  846. <if test="vo.productTag2 != null and vo.productTag2 != ''">
  847. AND ps.product_tag2 = #{vo.productTag2}
  848. </if>
  849. <if test="vo.productTag3 != null and vo.productTag3 != ''">
  850. AND ps.product_tag3 = #{vo.productTag3}
  851. </if>
  852. <if test="vo.productTag4 != null and vo.productTag4 != ''">
  853. AND ps.product_tag4 = #{vo.productTag4}
  854. </if>
  855. <if test="vo.cateIds!=null and vo.cateIds.size()>0 and (vo.planIds==null or vo.planIds.size()==0)">
  856. AND tdl.product_id in
  857. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  858. #{item}
  859. </foreach>
  860. </if>
  861. <if test="vo.externalOrderNo != null and vo.externalOrderNo != ''">
  862. AND td.external_order_no = #{vo.externalOrderNo}
  863. </if>
  864. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  865. AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.credential_no = #{vo.credentialNo})
  866. </if>
  867. <if test="vo.userName != null and vo.userName != ''">
  868. AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.name = #{vo.userName})
  869. </if>
  870. <choose>
  871. <when test="vo.mobile != null and vo.mobile.length() == 4">
  872. AND tou.mobile like concat('%',#{vo.mobile})
  873. </when>
  874. <when test="vo.mobile != null and vo.mobile != ''">
  875. AND tou.mobile = #{vo.mobile}
  876. </when>
  877. <otherwise>
  878. </otherwise>
  879. </choose>
  880. <if test="vo.contactName != null and vo.contactName != ''">
  881. AND tou.contact_name = #{vo.contactName}
  882. </if>
  883. <if test="vo.travelDate != null and vo.travelDate != ''">
  884. AND td.travel_date = #{vo.travelDate}
  885. </if>
  886. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  887. AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  888. </if>
  889. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  890. AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  891. </if>
  892. <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
  893. AND td.create_time <![CDATA[ >= ]]> #{vo.orderDateStart}
  894. </if>
  895. <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
  896. AND td.create_time <![CDATA[ <= ]]> #{vo.orderDateEnd}
  897. </if>
  898. <if test="vo.orderDate != null and vo.orderDate != ''">
  899. AND td.create_time = #{vo.orderDate}
  900. </if>
  901. <if test="vo.sellerId != null and vo.sellerId != ''">
  902. AND td.seller_id = #{vo.sellerId}
  903. </if>
  904. <if test="vo.shareName != null and vo.shareName != ''">
  905. AND td.share_name like concat('%',#{vo.shareName},'%')
  906. </if>
  907. <if test="vo.voucherCode != null and vo.voucherCode != ''">
  908. AND tdl.voucher_code = #{vo.voucherCode}
  909. </if>
  910. <if test="vo.sellMethod != null and vo.sellMethod != ''">
  911. AND td.sell_method = #{vo.sellMethod}
  912. </if>
  913. <if test="vo.productName != null and vo.productName != ''">
  914. AND tdl.product_name like concat('%',#{vo.productName}, '%')
  915. </if>
  916. <if test="vo.isFullPay == 0">
  917. AND td.is_full_pay = #{vo.isFullPay}
  918. </if>
  919. <if test="vo.isComment != null">
  920. AND td.is_comment = #{vo.isComment}
  921. </if>
  922. <if test="vo.sourceId != null and vo.sourceId != ''">
  923. AND td.source_id = #{vo.sourceId}
  924. </if>
  925. <if test="vo.paymentStatus != null">
  926. AND td.pay_status = #{vo.paymentStatus}
  927. </if>
  928. <if test="vo.distributorId != null and vo.distributorId != ''">
  929. AND td.source_id = #{vo.distributorId}
  930. </if>
  931. <if test="vo.sourceName != null and vo.sourceName != ''">
  932. AND td.source_name like concat('%',#{vo.sourceName}, '%')
  933. </if>
  934. <if test="vo.travelStatus != null">
  935. AND td.travel_status = #{vo.travelStatus}
  936. </if>
  937. <if test="vo.roomModelId != null and vo.roomModelId != ''">
  938. AND torm.room_model_id = #{vo.roomModelId}
  939. </if>
  940. <if test="vo.floor != null and vo.floor != ''">
  941. AND torm.floor = #{vo.floor}
  942. </if>
  943. <if test="vo.isInsure != null and vo.isInsure != ''">
  944. AND td.is_insure = #{vo.isInsure}
  945. </if>
  946. <if test="vo.orderRefundDateStart != null and vo.orderRefundDateEnd != ''">
  947. AND exists (select 1 from trade_refund tr where tr.order_id=td.id and tr.refund_status = 6 and tr.refund_time BETWEEN #{vo.orderRefundDateStart} and #{vo.orderRefundDateEnd} )
  948. </if>
  949. GROUP BY td.id
  950. ORDER BY td.create_time DESC
  951. </select>
  952. <select id="getTradeOrderUserCount" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderCountRespVO">
  953. SELECT count(DISTINCT td.id) orderNum,sum(if(tdl.voucher_status in (1,2,3,4,6,8,9), quantity_of_one,0)) totalNum,
  954. sum(if(tdl.spec_type='full' and tdl.voucher_status in (1,2,3,4,6,8,9), quantity_of_one,0)) fullNum,
  955. sum(if(tdl.spec_type='half' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) halfNum,
  956. sum(if(tdl.spec_type='free' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) freeNum,
  957. sum(if(tdl.spec_type='common' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) commonNum,
  958. sum(if(tdl.spec_type='car_seat' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) carSeatNum,
  959. sum(if(tdl.spec_type='car_yd' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) carYdNum,
  960. sum(if(tdl.spec_type='other' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) otherNum,
  961. sum(if(tdl.spec_type='carrying_children' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) carryingChildrenNum,
  962. sum(tdl.actual_price) totalPayAmount
  963. FROM trade_order td
  964. INNER JOIN trade_order_user tou on td.id = tou.order_id
  965. INNER JOIN trade_detail tdl on td.id = tdl.order_id
  966. INNER JOIN product_spu ps on ps.id = tdl.product_id
  967. LEFT JOIN ota_distributor od on od.id = td.source_id
  968. where 1= 1
  969. <if test="vo.orderStatus!=null and vo.orderStatus.size()>0">
  970. and td.order_status in
  971. <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
  972. #{item}
  973. </foreach>
  974. </if>
  975. <if test="vo.tenantId!=null">
  976. AND td.tenant_id = #{vo.tenantId}
  977. </if>
  978. <choose>
  979. <when test="vo.orderNo != null and vo.orderNo.length() == 4">
  980. AND td.order_no like concat('%',#{vo.orderNo})
  981. </when>
  982. <when test="vo.orderNo != null and vo.orderNo != ''">
  983. AND td.order_no = #{vo.orderNo}
  984. </when>
  985. <otherwise>
  986. </otherwise>
  987. </choose>
  988. <if test="vo.memberId != null and vo.memberId != ''">
  989. AND td.member_id = #{vo.memberId}
  990. </if>
  991. <if test="vo.productTag != null and vo.productTag != ''">
  992. AND ps.product_tag = #{vo.productTag}
  993. </if>
  994. <if test="vo.productTag2 != null and vo.productTag2 != ''">
  995. AND ps.product_tag2 = #{vo.productTag2}
  996. </if>
  997. <if test="vo.productTag3 != null and vo.productTag3 != ''">
  998. AND ps.product_tag3 = #{vo.productTag3}
  999. </if>
  1000. <if test="vo.productTag4 != null and vo.productTag4 != ''">
  1001. AND ps.product_tag4 = #{vo.productTag4}
  1002. </if>
  1003. <if test="vo.dispatchStatus != null">
  1004. AND td.dispatch_status = #{vo.dispatchStatus}
  1005. </if>
  1006. <if test="vo.payType != null">
  1007. AND exists (select 1 from trade_order_pay top where top.order_id = td.id and top.payment_type = #{vo.payType})
  1008. </if>
  1009. <if test="vo.otaCateId != null and vo.otaCateId != ''">
  1010. AND od.ota_category_id = #{vo.otaCateId}
  1011. </if>
  1012. <if test="vo.planIds!=null and vo.planIds.size()>0 and vo.cateIds!=null and vo.cateIds.size()>0">
  1013. AND (td.route_plan_id in
  1014. <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
  1015. #{item}
  1016. </foreach>
  1017. or tdl.product_id in
  1018. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  1019. #{item}
  1020. </foreach>
  1021. )
  1022. </if>
  1023. <if test="vo.cateIds!=null and vo.cateIds.size()>0 and (vo.planIds==null or vo.planIds.size()==0)">
  1024. AND tdl.product_id in
  1025. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  1026. #{item}
  1027. </foreach>
  1028. </if>
  1029. <if test="vo.planIds!=null and vo.planIds.size()>0 and (vo.cateIds==null or vo.cateIds.size()==0)">
  1030. and td.route_plan_id in
  1031. <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
  1032. #{item}
  1033. </foreach>
  1034. </if>
  1035. <if test="vo.otaId != null and vo.otaId != ''">
  1036. AND td.source_id = #{vo.otaId}
  1037. </if>
  1038. <if test="vo.otaIds != null and vo.otaIds.size()>0">
  1039. AND td.source_id IN
  1040. <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
  1041. #{item}
  1042. </foreach>
  1043. </if>
  1044. <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
  1045. and od.ota_category_id in
  1046. <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
  1047. #{item}
  1048. </foreach>
  1049. </if>
  1050. <if test="vo.storeId != null and vo.storeId != ''">
  1051. AND td.store_id = #{vo.storeId}
  1052. </if>
  1053. <if test="vo.externalOrderNo != null and vo.externalOrderNo != ''">
  1054. AND td.external_order_no = #{vo.externalOrderNo}
  1055. </if>
  1056. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  1057. AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.credential_no = #{vo.credentialNo})
  1058. </if>
  1059. <if test="vo.userName != null and vo.userName != ''">
  1060. AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.name = #{vo.userName})
  1061. </if>
  1062. <choose>
  1063. <when test="vo.mobile != null and vo.mobile.length() == 4">
  1064. AND tou.mobile like concat('%',#{vo.mobile})
  1065. </when>
  1066. <when test="vo.mobile != null and vo.mobile != ''">
  1067. AND tou.mobile = #{vo.mobile}
  1068. </when>
  1069. <otherwise>
  1070. </otherwise>
  1071. </choose>
  1072. <if test="vo.contactName != null and vo.contactName != ''">
  1073. AND tou.contact_name = #{vo.contactName}
  1074. </if>
  1075. <if test="vo.travelDate != null and vo.travelDate != ''">
  1076. AND td.travel_date = #{vo.travelDate}
  1077. </if>
  1078. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  1079. AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  1080. </if>
  1081. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  1082. AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  1083. </if>
  1084. <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
  1085. AND td.create_time <![CDATA[ >= ]]> #{vo.orderDateStart}
  1086. </if>
  1087. <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
  1088. AND td.create_time <![CDATA[ <= ]]> #{vo.orderDateEnd}
  1089. </if>
  1090. <if test="vo.orderDate != null and vo.orderDate != ''">
  1091. AND td.create_time = #{vo.orderDate}
  1092. </if>
  1093. <if test="vo.sellerId != null and vo.sellerId != ''">
  1094. AND td.seller_id = #{vo.sellerId}
  1095. </if>
  1096. <if test="vo.shareName != null and vo.shareName != ''">
  1097. AND td.share_name like concat('%',#{vo.shareName},'%')
  1098. </if>
  1099. <if test="vo.voucherCode != null and vo.voucherCode != ''">
  1100. AND tdl.voucher_code = #{vo.voucherCode}
  1101. </if>
  1102. <if test="vo.sellMethod != null and vo.sellMethod != ''">
  1103. AND td.sell_method = #{vo.sellMethod}
  1104. </if>
  1105. <if test="vo.productName != null and vo.productName != ''">
  1106. AND tdl.product_name like concat('%',#{vo.productName}, '%')
  1107. </if>
  1108. <if test="vo.isFullPay == 0">
  1109. AND td.is_full_pay = #{vo.isFullPay}
  1110. </if>
  1111. <if test="vo.isComment != null">
  1112. AND td.is_comment = #{vo.isComment}
  1113. </if>
  1114. <if test="vo.sourceId != null and vo.sourceId != ''">
  1115. AND td.source_id = #{vo.sourceId}
  1116. </if>
  1117. <if test="vo.sourceName != null and vo.sourceName != ''">
  1118. AND td.source_name like concat('%',#{vo.sourceName}, '%')
  1119. </if>
  1120. <if test="vo.travelStatus != null">
  1121. AND td.travel_status = #{vo.travelStatus}
  1122. </if>
  1123. <if test="vo.orderRefundDateStart != null and vo.orderRefundDateEnd != ''">
  1124. AND exists (select 1 from trade_refund tr where tr.order_id=td.id and tr.refund_status = 6 and tr.refund_time BETWEEN #{vo.orderRefundDateStart} and #{vo.orderRefundDateEnd} )
  1125. </if>
  1126. </select>
  1127. <select id="getPaidOrderPage"
  1128. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
  1129. SELECT td.*, op.pay_amount payAmount, op.refund_amount refundAmount, op.pay_status paymentStatus, op.payment_type paymentType, op.payment_date paymentDate
  1130. FROM trade_order td
  1131. INNER JOIN trade_order_pay op on op.order_id = td.id
  1132. where td.order_status <![CDATA[ >= ]]> 6 and td.order_status <![CDATA[ <= ]]> 11
  1133. <if test="vo.orderNo != null and vo.orderNo != ''">
  1134. AND td.order_no = #{vo.orderNo}
  1135. </if>
  1136. <if test="vo.payType != null">
  1137. AND op.payment_type = #{vo.payType}
  1138. </if>
  1139. <if test="vo.storeId != null and vo.storeId != ''">
  1140. AND td.store_id = #{vo.storeId}
  1141. </if>
  1142. <if test="vo.travelDate != null and vo.travelDate != ''">
  1143. AND td.travel_date = #{vo.travelDate}
  1144. </if>
  1145. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  1146. AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  1147. </if>
  1148. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  1149. AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  1150. </if>
  1151. <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
  1152. AND op.payment_date <![CDATA[ >= ]]> #{vo.orderDateStart}
  1153. </if>
  1154. <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
  1155. AND op.payment_date <![CDATA[ <= ]]> #{vo.orderDateEnd}
  1156. </if>
  1157. <if test="vo.orderDate != null and vo.orderDate != ''">
  1158. AND td.create_time = #{vo.orderDate}
  1159. </if>
  1160. <if test="vo.sellerId != null and vo.sellerId != ''">
  1161. AND td.seller_id = #{vo.sellerId}
  1162. </if>
  1163. <if test="vo.sellMethod != null and vo.sellMethod != ''">
  1164. AND td.sell_method = #{vo.sellMethod}
  1165. </if>
  1166. ORDER BY td.create_time DESC
  1167. </select>
  1168. <select id="getRefundDetailPage"
  1169. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeDetailRespVO">
  1170. SELECT td.*,tv.credential_no,tv.`name`,tv.mobile,tor.order_no
  1171. FROM trade_detail td
  1172. INNER JOIN trade_visitor tv on tv.detail_id = td.id
  1173. LEFT JOIN trade_order tor on tor.id = td.order_id
  1174. where 1= 1
  1175. <if test="vo.name != null and vo.name != ''">
  1176. AND tv.name = #{vo.name}
  1177. </if>
  1178. <if test="vo.orderNo != null and vo.orderNo != ''">
  1179. AND tor.order_no = #{vo.orderNo}
  1180. </if>
  1181. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  1182. AND tv.credential_no = #{vo.credentialNo}
  1183. </if>
  1184. <if test="vo.mobile != null and vo.mobile != ''">
  1185. AND tv.mobile = #{vo.mobile}
  1186. </if>
  1187. <if test="vo.orderStatus != null and vo.orderStatus != ''">
  1188. AND tor.order_status = #{vo.orderStatus}
  1189. </if>
  1190. </select>
  1191. <select id="getRefundRecordPage"
  1192. resultType="com.yc.ship.module.trade.controller.admin.order.vo.refund.RefundRespVO">
  1193. SELECT tr.*,td.order_no, ou.mobile,td.travel_date, ou.contact_name ,tdl.product_name
  1194. FROM trade_refund tr
  1195. INNER JOIN trade_order td on tr.order_id = td.id
  1196. inner join product_voyage pv on td.voyage_id = pv.id
  1197. inner join trade_order_user ou on ou.order_id = td.id
  1198. INNER JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
  1199. LEFT JOIN ota_distributor od on od.id = td.source_id
  1200. where 1= 1
  1201. <if test="vo.shipId != null and vo.shipId != ''">
  1202. AND td.ship_id = #{vo.shipId}
  1203. </if>
  1204. <if test="vo.voyageId != null and vo.voyageId != ''">
  1205. AND td.voyage_id = #{vo.voyageId}
  1206. </if>
  1207. <if test="vo.routeId != null and vo.routeId != ''">
  1208. AND pv.route_id = #{vo.routeId}
  1209. </if>
  1210. <if test="vo.orderNo != null and vo.orderNo != ''">
  1211. AND td.order_no = #{vo.orderNo}
  1212. </if>
  1213. <if test="vo.refundStatus!=null and vo.refundStatus.size()>0">
  1214. and tr.refund_status in
  1215. <foreach collection="vo.refundStatus" item="item" separator="," open="(" close=")">
  1216. #{item}
  1217. </foreach>
  1218. </if>
  1219. <if test="vo.refundMethod != null and vo.refundMethod != ''">
  1220. AND tr.refund_method = #{vo.refundMethod}
  1221. </if>
  1222. <if test="vo.refundUserId!=null and vo.refundUserId.size()>0">
  1223. and tr.refund_user in
  1224. <foreach collection="vo.refundUserId" item="item" separator="," open="(" close=")">
  1225. #{item}
  1226. </foreach>
  1227. </if>
  1228. <if test="vo.refundChannel != null">
  1229. AND tr.refund_channel = #{vo.refundChannel}
  1230. </if>
  1231. <if test="vo.mobile != null and vo.mobile != ''">
  1232. AND ou.mobile = #{vo.mobile}
  1233. </if>
  1234. <if test="vo.sourceId != null and vo.sourceId != ''">
  1235. AND td.source_id = #{vo.sourceId}
  1236. </if>
  1237. <if test="vo.travelDate != null and vo.travelDate != ''">
  1238. AND td.travel_date = #{vo.travelDate}
  1239. </if>
  1240. <if test="vo.productName != null and vo.productName != ''">
  1241. AND tdl.product_name like concat('%',#{vo.productName}, '%')
  1242. </if>
  1243. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  1244. AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  1245. </if>
  1246. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  1247. AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  1248. </if>
  1249. <if test="vo.refundTime != null and vo.refundTime != ''">
  1250. AND tr.refund_time = #{vo.refundTime}
  1251. </if>
  1252. <if test="vo.refundTimeStart != null and vo.refundTimeStart != ''">
  1253. AND tr.refund_time <![CDATA[ >= ]]> #{vo.refundTimeStart}
  1254. </if>
  1255. <if test="vo.refundTimeEnd != null and vo.refundTimeEnd != ''">
  1256. AND tr.refund_time <![CDATA[ <= ]]> #{vo.refundTimeEnd}
  1257. </if>
  1258. <if test="vo.otaId != null and vo.otaId != ''">
  1259. AND td.source_id = #{vo.otaId}
  1260. </if>
  1261. <if test="vo.otaIds != null and vo.otaIds.size()>0">
  1262. AND td.source_id IN
  1263. <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
  1264. #{item}
  1265. </foreach>
  1266. </if>
  1267. <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
  1268. and od.ota_category_id in
  1269. <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
  1270. #{item}
  1271. </foreach>
  1272. </if>
  1273. <if test="vo.cateIds!=null and vo.cateIds.size()>0 and vo.planIds==null">
  1274. AND tdl.product_id in
  1275. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  1276. #{item}
  1277. </foreach>
  1278. </if>
  1279. <if test="vo.planIds!=null and vo.planIds.size()>0 and (vo.cateIds==null or vo.cateIds.size()==0)">
  1280. and td.route_plan_id in
  1281. <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
  1282. #{item}
  1283. </foreach>
  1284. </if>
  1285. group by tr.id
  1286. ORDER BY tr.create_time DESC
  1287. </select>
  1288. <select id="getOrderInfo" resultMap="MiddleWareDtoResultMap">
  1289. SELECT td.id,td.voyage_id,td.is_read isRead,td.pay_amount,td.order_no,td.external_order_no,td.visitor_type,td.travel_date,td.sell_method,td.source_id,td.source_name,td.store_id,td.seller_id,td.member_id,td.amount,td.order_status,td.remark,td.share_name,td.create_time,td.is_marketing,td.is_marketing_use,
  1290. tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,tou.county,tou.province,tou.city,td.agency_group_id,
  1291. top.id payId,top.pay_amount payAmount,top.pay_status,top.payment_type,top.payment_date,top.payment_no,
  1292. td.store_name,td.is_invoice, td.confirm_type, td.travel_status, tr.refund_amount,td.finish_status,
  1293. ti.id insuranceId,ti.policy_no,ti.proposal_no,ti.insurance_no,ti.insurance_status,ti.insured_num,ti.insurance_effect_date,ti.electronic_policy,
  1294. tc.id contractId,tc.contract_no,tc.`status`,tc.tourists_count,tc.contract_url,tc.operate_name,tc.signer_name,tc.signer_mobile,tc.signing_time
  1295. FROM trade_order td
  1296. INNER JOIN trade_order_user tou on td.id = tou.order_id
  1297. left JOIN trade_order_pay top on td.id = top.order_id AND top.pay_status = 1 and top.deleted = 0
  1298. left JOIN trade_insurance ti on td.id = ti.order_id
  1299. left JOIN trade_contract tc on td.id = tc.order_id
  1300. LEFT JOIN (select m2.order_id,sum(m1.refund_amount) refund_amount from trade_refund_detail m1
  1301. inner join trade_refund m2 on m1.refund_id = m2.id where m2.order_id = #{id} and m1.refund_status = 6 GROUP BY m2.order_id) tr on td.id = tr.order_id
  1302. where 1= 1
  1303. AND td.id = #{id}
  1304. </select>
  1305. <select id="getPdaOrderInfo" resultMap="MiddleWareDtoResultMap2">
  1306. SELECT td.id,td.is_read isRead,td.pay_amount,td.order_no,td.external_order_no,td.route_plan_id,rt.name route_plan_name,td.visitor_type,td.travel_date,td.sell_method,td.source_id,td.source_name,td.store_id,td.seller_id,td.member_id,td.amount,td.order_status,td.remark,td.share_name,td.create_time,td.is_bind,td.area_manager_id,td.is_marketing,td.is_marketing_use,
  1307. tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,tou.county,tou.province,tou.city,td.is_change_order,td.agency_group_id,
  1308. top.id payId,top.pay_amount payAmount,top.pay_status,top.payment_type,top.payment_date,top.payment_no,
  1309. td.store_name,td.dispatch_status,td.is_invoice, td.confirm_type, td.travel_status, tr.refund_amount,td.finish_status,
  1310. ti.id insuranceId,ti.policy_no,ti.proposal_no,ti.insurance_no,ti.insurance_status,ti.insured_num,ti.insurance_effect_date,ti.electronic_policy,
  1311. tc.id contractId,tc.contract_no,tc.`status`,tc.tourists_count,tc.contract_url,tc.operate_name,tc.signer_name,tc.signer_mobile,tc.signing_time,tc.signing_url,tc.view_url
  1312. FROM trade_order td
  1313. INNER JOIN trade_order_user tou on td.id = tou.order_id
  1314. left JOIN trade_order_pay top on td.id = top.order_id AND top.pay_status = 1 and top.deleted = 0
  1315. left JOIN trade_insurance ti on td.id = ti.order_id
  1316. left JOIN trade_contract tc on td.id = tc.order_id
  1317. left JOIN product_route_plan rt on rt.id = td.route_plan_id
  1318. LEFT JOIN (select m2.order_id,sum(m1.refund_amount) refund_amount from trade_refund_detail m1
  1319. inner join trade_refund m2 on m1.refund_id = m2.id where m2.order_id = #{id} and m1.refund_status = 6 GROUP BY m2.order_id) tr on td.id = tr.order_id
  1320. where 1= 1
  1321. AND td.id = #{id}
  1322. </select>
  1323. <select id="getMarketingApplyOrderPage" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
  1324. SELECT td.id,td.pay_amount,td.order_no,td.external_order_no,td.route_plan_id,td.visitor_type,td.travel_date,td.sell_method,td.source_name,td.source_id,td.seller_id,td.member_id,td.amount,td.order_status,td.remark,td.share_name,td.create_time,td.is_bind,td.area_manager_id,td.agency_group_id,
  1325. tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,
  1326. td.store_name,td.store_id,pma.audit_state,pma.use_audit_state,pma.type auditType,pma.id marketingAuditId,pma.is_execute,pma.error_text,pmk.name marketingName,pmk.policy_type policyType,pma.remark auditRemark,pma.file_url fileUrl
  1327. FROM
  1328. product_marketing_audit pma
  1329. INNER JOIN trade_order td on pma.order_id = td.id
  1330. inner join trade_detail ttd on td.id = ttd.order_id
  1331. INNER JOIN trade_order_user tou ON td.id = tou.order_id
  1332. LEFT JOIN product_marketing pmk ON pmk.id = pma.marketing_id
  1333. WHERE 1 = 1 AND td.order_status != 11 and
  1334. pma.travel_id in (SELECT DISTINCT travel_id FROM product_marketing_pm WHERE user_id = #{vo.userId} and deleted = 0)
  1335. <if test="vo.ids.size()>0">
  1336. and pma.travel_id in
  1337. <foreach collection="vo.ids" item="item" separator="," open="(" close=")">
  1338. #{item}
  1339. </foreach>
  1340. </if>
  1341. <if test="vo.orderNo != null and vo.orderNo != ''">
  1342. AND td.order_no = #{vo.orderNo}
  1343. </if>
  1344. <if test="vo.policyType != null and vo.policyType != ''">
  1345. AND pmk.policy_type = #{vo.policyType}
  1346. </if>
  1347. <if test="vo.productName != null and vo.productName != ''">
  1348. AND ttd.product_name like concat('%',#{vo.productName}, '%')
  1349. </if>
  1350. <if test="vo.marketingName != null and vo.marketingName != ''">
  1351. AND pmk.name like concat('%',#{vo.marketingName}, '%')
  1352. </if>
  1353. <if test="vo.isExecute != null and vo.isExecute != ''">
  1354. AND pma.is_execute = #{vo.isExecute}
  1355. </if>
  1356. <if test="vo.distributorId != null and vo.distributorId != ''">
  1357. AND pma.agency_id = #{vo.distributorId}
  1358. </if>
  1359. <if test="vo.storeId != null and vo.storeId != ''">
  1360. AND pma.store_id = #{vo.storeId}
  1361. </if>
  1362. <if test="vo.orderStartTime != null and vo.orderStartTime != ''">
  1363. AND td.travel_date <![CDATA[ >= ]]> #{vo.orderStartTime}
  1364. </if>
  1365. <if test="vo.orderEndTime != null and vo.orderEndTime != ''">
  1366. AND td.travel_date <![CDATA[ <= ]]> #{vo.orderEndTime}
  1367. </if>
  1368. <if test="vo.auditState != null ">
  1369. AND pma.audit_state = #{vo.auditState}
  1370. </if>
  1371. GROUP BY pma.id,td.id
  1372. order by pma.create_time desc
  1373. </select>
  1374. <select id="getStoresMarketingOrderPage" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeMarketOrderRespVO">
  1375. SELECT td.id,td.pay_amount,td.order_no,td.external_order_no,td.route_plan_id,td.visitor_type,td.travel_date,td.sell_method,td.source_name,td.source_id,td.seller_id,td.member_id,td.amount,td.order_status,td.remark,td.share_name,td.create_time,td.is_bind,td.area_manager_id,td.agency_group_id,
  1376. tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,
  1377. td.store_name,td.store_id,pma.audit_state,pma.use_audit_state,pma.type auditType,pma.id marketingAuditId,pma.remark auditRemark,pma.is_execute,pma.error_text,pma.file_url fileUrl,if(pms.id is null,null, pmk.`name`) marketingName,if(pms.id is null,null, pmk.policy_type) policyType
  1378. FROM
  1379. product_marketing_audit pma
  1380. INNER JOIN trade_order td on pma.order_id = td.id
  1381. INNER JOIN trade_detail tdl on td.id = tdl.order_id
  1382. INNER JOIN trade_order_user tou ON td.id = tou.order_id
  1383. LEFT JOIN product_marketing_pool_spu pms on td.id = pms.order_id
  1384. LEFT JOIN product_marketing pmk ON pmk.id = pma.marketing_id
  1385. WHERE 1 = 1
  1386. <if test="vo.storeId != null">
  1387. and pma.store_id = #{vo.storeId}
  1388. </if>
  1389. <if test="vo.distributorId != null">
  1390. and td.source_id = #{vo.distributorId}
  1391. </if>
  1392. <if test="vo.ids.size()>0">
  1393. and pma.travel_id in
  1394. <foreach collection="vo.ids" item="item" separator="," open="(" close=")">
  1395. #{item}
  1396. </foreach>
  1397. </if>
  1398. <if test="vo.isExecute != null">
  1399. and pma.is_execute = #{vo.isExecute}
  1400. </if>
  1401. <if test="vo.policyType != null and vo.policyType != ''">
  1402. AND pmk.policy_type = #{vo.policyType}
  1403. </if>
  1404. <if test="vo.marketingName != null and vo.marketingName != ''">
  1405. AND pmk.name like concat('%',#{vo.marketingName}, '%')
  1406. </if>
  1407. <if test="vo.auditState != null">
  1408. and pma.audit_state = #{vo.auditState}
  1409. </if>
  1410. <if test="vo.useAuditState != null">
  1411. and pma.use_audit_state = #{vo.useAuditState}
  1412. </if>
  1413. <if test="vo.orderNo != null and vo.orderNo != ''">
  1414. AND td.order_no = #{vo.orderNo}
  1415. </if>
  1416. <if test="vo.travelDate != null and vo.travelDate != ''">
  1417. AND td.travel_date = #{vo.travelDate}
  1418. </if>
  1419. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  1420. AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  1421. </if>
  1422. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  1423. AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  1424. </if>
  1425. <if test="vo.productName != null and vo.productName != ''">
  1426. AND tdl.product_name like concat('%',#{vo.productName}, '%')
  1427. </if>
  1428. GROUP BY pma.id
  1429. order by pma.create_time desc
  1430. </select>
  1431. <select id="getStoresMarketingOrderDesc" resultType="java.util.Map">
  1432. SELECT td.id,td.pay_amount,td.order_no,td.external_order_no,td.route_plan_id,td.visitor_type,td.travel_date,td.sell_method,td.source_name,td.source_id,td.seller_id,td.member_id,td.amount,td.order_status,td.remark,td.share_name,td.create_time,td.is_bind,td.area_manager_id,td.agency_group_id,
  1433. tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,
  1434. td.store_name,td.store_id,pma.audit_state,pma.use_audit_state,pma.type auditType,pma.id marketingAuditId,pma.remark auditRemark,pma.is_execute,pma.error_text,pma.file_url fileUrl
  1435. FROM
  1436. product_marketing_audit pma
  1437. INNER JOIN trade_order td on pma.order_id = td.id
  1438. INNER JOIN trade_detail tdl on td.id = tdl.order_id
  1439. INNER JOIN trade_order_user tou ON td.id = tou.order_id
  1440. LEFT JOIN product_marketing pmk ON pmk.id = pma.marketing_id
  1441. WHERE 1 = 1
  1442. <if test="vo.storeId != null">
  1443. and pma.store_id = #{vo.storeId}
  1444. </if>
  1445. <if test="vo.ids.size()>0">
  1446. and pma.travel_id in
  1447. <foreach collection="vo.ids" item="item" separator="," open="(" close=")">
  1448. #{item}
  1449. </foreach>
  1450. </if>
  1451. <if test="vo.isExecute != null">
  1452. and pma.is_execute = #{vo.isExecute}
  1453. </if>
  1454. <if test="vo.policyType != null and vo.policyType != ''">
  1455. AND pmk.policy_type = #{vo.policyType}
  1456. </if>
  1457. <if test="vo.marketingName != null and vo.marketingName != ''">
  1458. AND pmk.name like concat('%',#{vo.marketingName}, '%')
  1459. </if>
  1460. <if test="vo.auditState != null">
  1461. and pma.audit_state = #{vo.auditState}
  1462. </if>
  1463. <if test="vo.useAuditState != null">
  1464. and pma.use_audit_state = #{vo.useAuditState}
  1465. </if>
  1466. <if test="vo.orderNo != null and vo.orderNo != ''">
  1467. AND td.order_no = #{vo.orderNo}
  1468. </if>
  1469. <if test="vo.travelDate != null and vo.travelDate != ''">
  1470. AND td.travel_date = #{vo.travelDate}
  1471. </if>
  1472. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  1473. AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  1474. </if>
  1475. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  1476. AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  1477. </if>
  1478. <if test="vo.productName != null and vo.productName != ''">
  1479. AND tdl.product_name like concat('%',#{vo.productName}, '%')
  1480. </if>
  1481. GROUP BY pma.id
  1482. order by pma.create_time desc
  1483. </select>
  1484. <select id="selectBindMarketing" resultType="java.lang.Long">
  1485. SELECT tob.bind_id
  1486. FROM
  1487. trade_order_bind tob
  1488. WHERE
  1489. tob.type = 7 AND tob.deleted = 0 AND tob.order_id = #{orderId}
  1490. </select>
  1491. <select id="selectBindUseMarketing" resultType="java.lang.Long">
  1492. SELECT tob.bind_id
  1493. FROM
  1494. trade_order_bind tob
  1495. WHERE
  1496. tob.type = 8 AND tob.deleted = 0 AND tob.order_id = #{orderId}
  1497. </select>
  1498. <select id="selectOrderIdByOrderNo" resultType="java.lang.Long">
  1499. SELECT id FROM trade_order WHERE order_no = #{orderNo}
  1500. </select>
  1501. <select id="getRefundOrderInfo" resultMap="RefundResultMap">
  1502. SELECT td.id,td.order_no,td.external_order_no,td.route_plan_id,td.visitor_type,td.travel_date,td.sell_method,td.source_name,td.seller_id,td.member_id,td.amount,td.pay_amount,td.order_status,td.payment_date,td.remark,
  1503. tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,
  1504. tdl.id detailId,tdl.voucher_code,tdl.voucher_status,tdl.product_name,tdl.spec_type,
  1505. tv.id visitorId,tv.credential_no,tv.credential_type,tv.`name`
  1506. FROM trade_order td
  1507. INNER JOIN trade_order_user tou on td.id = tou.order_id
  1508. INNER JOIN trade_detail tdl on td.id = tdl.order_id
  1509. INNER JOIN trade_visitor tv on tdl.id = tv.detail_id
  1510. where 1= 1
  1511. <if test="id != null and id != ''">
  1512. AND td.id = #{id}
  1513. </if>
  1514. </select>
  1515. <select id="getTradeOrderByExpire" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  1516. select * from trade_order where order_status =14 and travel_date <![CDATA[ <= ]]> #{expiretime}
  1517. </select>
  1518. <select id="getPageRefundRecord"
  1519. resultType="com.yc.ship.module.trade.controller.admin.order.vo.refund.RefundRecordRespVO">
  1520. SELECT trr.*,td.order_no, td.id orderId, td.travel_date
  1521. FROM trade_refund_record trr
  1522. left join trade_order_pay top on trr.order_pay_id = top.id
  1523. left join trade_refund tr on trr.refund_id = tr.id
  1524. left join trade_order td on td.id = top.order_id
  1525. left join product_voyage pv on td.voyage_id = pv.id
  1526. LEFT JOIN ota_distributor od on od.id = td.source_id
  1527. where 1= 1
  1528. <if test="vo.shipId != null and vo.shipId != ''">
  1529. AND td.ship_id = #{vo.shipId}
  1530. </if>
  1531. <if test="vo.voyageId != null and vo.voyageId != ''">
  1532. AND td.voyage_id = #{vo.voyageId}
  1533. </if>
  1534. <if test="vo.routeId != null and vo.routeId != ''">
  1535. AND pv.route_id = #{vo.routeId}
  1536. </if>
  1537. <if test="vo.orderNo != null and vo.orderNo != ''">
  1538. AND td.order_no = #{vo.orderNo}
  1539. </if>
  1540. <if test="vo.refundNo != null and vo.refundNo != ''">
  1541. AND trr.refund_no = #{vo.refundNo}
  1542. </if>
  1543. <if test="vo.paymentNo != null and vo.paymentNo != ''">
  1544. AND trr.payment_no = #{vo.paymentNo}
  1545. </if>
  1546. <if test="vo.refundStatus != null and vo.refundStatus != ''">
  1547. AND trr.refund_status = #{vo.refundStatus}
  1548. </if>
  1549. <if test="vo.refundId != null and vo.refundId != ''">
  1550. AND trr.refund_id = #{vo.refundId}
  1551. </if>
  1552. <if test="vo.openId != null and vo.openId != ''">
  1553. AND trr.openId = #{vo.openId}
  1554. </if>
  1555. <if test="vo.otaId != null and vo.otaId != ''">
  1556. AND td.source_id = #{vo.otaId}
  1557. </if>
  1558. <!--<if test="vo.otaIds != null and vo.otaIds.size()>0">
  1559. AND td.source_id IN
  1560. <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
  1561. #{item}
  1562. </foreach>
  1563. </if>-->
  1564. <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
  1565. and od.ota_category_id in
  1566. <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
  1567. #{item}
  1568. </foreach>
  1569. </if>
  1570. <if test="vo.sourceId != null and vo.sourceId != ''">
  1571. AND td.source_id = #{vo.sourceId}
  1572. </if>
  1573. <if test="vo.travelDate != null and vo.travelDate != ''">
  1574. AND td.travel_date = #{vo.travelDate}
  1575. </if>
  1576. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  1577. AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  1578. </if>
  1579. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  1580. AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  1581. </if>
  1582. <if test="vo.refundTime != null and vo.refundTime != ''">
  1583. AND trr.refund_time = #{vo.refundTime}
  1584. </if>
  1585. <if test="vo.refundTimeStart != null and vo.refundTimeStart != ''">
  1586. AND trr.refund_time <![CDATA[ >= ]]> #{vo.refundTimeStart}
  1587. </if>
  1588. <if test="vo.refundTimeEnd != null and vo.refundTimeEnd != ''">
  1589. AND trr.refund_time <![CDATA[ <= ]]> #{vo.refundTimeEnd}
  1590. </if>
  1591. ORDER BY trr.create_time DESC
  1592. </select>
  1593. <select id="getPrintTemp"
  1594. resultType="com.yc.ship.module.trade.controller.admin.order.vo.otc.PrintRespVO">
  1595. SELECT pt.* FROM print_temp pt where pt.template_code = #{printTemp}
  1596. </select>
  1597. <select id="queryCanInvoicedOrderPage"
  1598. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
  1599. SELECT
  1600. o.order_no,
  1601. o.travel_date,
  1602. o.order_status,
  1603. o.amount,
  1604. o.create_time,
  1605. o.external_order_no,
  1606. o.id,
  1607. o.is_invoice,
  1608. o.item_id,
  1609. o.payment_date,
  1610. o.remark,
  1611. o.seller_id,
  1612. o.sell_method,
  1613. o.share_name,
  1614. o.source_id,
  1615. o.source_name,
  1616. o.store_id,
  1617. o.store_name,
  1618. o.visitor_type,
  1619. tou.contact_name,
  1620. tou.credential_no,
  1621. tou.mobile,
  1622. td.product_name,
  1623. count(
  1624. DISTINCT
  1625. CASE
  1626. WHEN (
  1627. td.voucher_status in (3,6,7,8)
  1628. OR ( td.voucher_status = 9 AND td.check_status = 1 )
  1629. ) THEN
  1630. td.id ELSE null
  1631. END
  1632. ) AS num,
  1633. o.pay_amount - SUM( ifnull(trd.refund_amount,0) ) - SUM(
  1634. CASE
  1635. WHEN ( td.voucher_status in (1,2) )
  1636. AND DATE_FORMAT( td.validity_end_date, '%Y-%c-%d' ) >= DATE_FORMAT( NOW( ), '%Y-%c-%d' ) THEN
  1637. td.actual_price ELSE 0
  1638. END
  1639. ) AS pay_amount
  1640. FROM
  1641. trade_order o
  1642. INNER JOIN trade_detail td ON td.order_id = o.id
  1643. LEFT JOIN trade_refund_detail trd ON trd.trade_detail_id = td.id
  1644. AND trd.refund_status = 6
  1645. INNER JOIN trade_order_user tou ON o.id = tou.order_id
  1646. LEFT JOIN trade_invoice_detail i ON i.order_no = o.order_no
  1647. LEFT JOIN trade_invoice ii ON i.invoice_id = ii.id AND ii.invoice_status IN (1,3)
  1648. INNER JOIN (select p2.order_no,p1.payment_type from trade_order_pay p1 inner join trade_order p2 on p1.order_id = p2.id where p1.pay_status=1 GROUP BY order_id) op ON op.order_no = o.order_no LEFT JOIN (select p2.order_no,p1.* from ota_bill_order p1 inner join trade_order p2 on p1.order_id = p2.id) obo ON obo.order_no = o.order_no
  1649. LEFT JOIN ota_bill_store obs ON obs.id = obo.bill_store_id AND obs.bill_status=1
  1650. where td.use_date >= DATE_SUB(NOW(), INTERVAL #{canInvoicedDay} DAY)
  1651. and o.is_invoice in (0,2) and o.deleted =0
  1652. and o.order_status in (1,6,7,8,9,11,12)
  1653. <if test="vo.orderNo != null and vo.orderNo != ''">
  1654. AND o.order_no = #{vo.orderNo}
  1655. </if>
  1656. <if test="vo.sourceId != null and vo.sourceId != ''">
  1657. AND o.source_id = #{vo.sourceId}
  1658. </if>
  1659. <if test="vo.storeId != null and vo.storeId != ''">
  1660. AND o.store_id = #{vo.storeId}
  1661. </if>
  1662. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  1663. AND tou.credential_no = #{vo.credentialNo}
  1664. </if>
  1665. <if test="vo.mobile != null and vo.mobile != ''">
  1666. AND tou.mobile = #{vo.mobile}
  1667. </if>
  1668. <if test="vo.contactName != null and vo.contactName != ''">
  1669. AND tou.contact_name = #{vo.contactName}
  1670. </if>
  1671. <if test="vo.travelDate != null and vo.travelDate != ''">
  1672. AND o.travel_date = #{vo.travelDate}
  1673. </if>
  1674. <if test="vo.sellerId != null and vo.sellerId != ''">
  1675. AND o.seller_id = #{vo.sellerId}
  1676. </if>
  1677. <if test="vo.voucherCode != null and vo.voucherCode != ''">
  1678. AND td.voucher_code = #{vo.voucherCode}
  1679. </if>
  1680. <if test="vo.sellMethod != null and vo.sellMethod != ''">
  1681. AND o.sell_method = #{vo.sellMethod}
  1682. </if>
  1683. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  1684. AND td.use_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  1685. </if>
  1686. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  1687. AND td.use_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  1688. </if>
  1689. <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
  1690. AND o.payment_date <![CDATA[ >= ]]> #{vo.orderDateStart}
  1691. </if>
  1692. <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
  1693. AND o.payment_date <![CDATA[ <= ]]> #{vo.orderDateEnd}
  1694. </if>
  1695. <if test="vo.productName != null and vo.productName != ''">
  1696. AND td.product_name like concat('%',#{vo.productName}, '%')
  1697. </if>
  1698. AND ii.id IS NULL
  1699. AND (op.payment_type != 6 OR (o.is_bill=2 AND obs.id IS NOT NULL))
  1700. AND date_format(NOW(), '%Y-%m-%d') > date_format(o.travel_date, '%Y-%m-%d')
  1701. GROUP BY
  1702. o.order_no
  1703. HAVING
  1704. SUM(CASE WHEN td.voucher_status IN (1,2) AND td.validity_end_date >= CURDATE() THEN 1 ELSE 0 END) = 0
  1705. AND pay_amount > 0
  1706. ORDER BY
  1707. o.travel_date DESC
  1708. </select>
  1709. <select id="getOrderByVoucherCode"
  1710. resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  1711. SELECT o.* FROM trade_order o
  1712. inner join trade_detail d on d.order_id = o.id
  1713. where (o.order_status = 6 or o.order_status = 7) and d.voucher_code = #{voucherCode} limit 1
  1714. </select>
  1715. <select id="getOrderByExternalOrderNo" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  1716. select t1.* from trade_order t1 inner join trade_supplier_order t2 on t1.id = t2.order_id where t2.trade_no=#{tradeNo} limit 1
  1717. </select>
  1718. <select id="getOtcOrderByExternalOrderNo" resultType="java.util.Map">
  1719. select t2.* from trade_order t1 inner join trade_supplier_order t2 on t1.id = t2.order_id where t1.order_no=#{tradeNo} limit 1
  1720. </select>
  1721. <select id="getTradeOrderByVoucherCode" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  1722. SELECT o.* FROM trade_order o inner join trade_detail d on d.order_id = o.id where d.voucher_code = #{voucherCode} limit 1
  1723. </select>
  1724. <select id="getOrderByCardNo"
  1725. resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  1726. SELECT
  1727. o.*
  1728. FROM
  1729. trade_order o
  1730. INNER JOIN trade_detail d ON d.order_id = o.id
  1731. INNER JOIN trade_visitor v ON v.detail_id = d.id
  1732. WHERE
  1733. o.travel_date >= CURDATE()
  1734. and d.voucher_status in (1,2,3,4,8,9)
  1735. and v.credential_no = #{cardNo}
  1736. </select>
  1737. <select id="getOrderByDetailBase"
  1738. resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  1739. SELECT o.* FROM trade_order o
  1740. inner join trade_detail d on d.order_id = o.id
  1741. inner join trade_detail_base tdb on tdb.detail_id = d.id
  1742. where (o.order_status = 6 or o.order_status = 7) and tdb.id = #{baseId} limit 1
  1743. </select>
  1744. <select id="getAccountOrderPage"
  1745. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
  1746. SELECT td.*,tou.contact_name,tou.credential_no,tou.mobile,COUNT(tdl.id) num,tdl.product_name,tdl.spec_type
  1747. FROM trade_order td
  1748. INNER JOIN trade_order_user tou on td.id = tou.order_id
  1749. INNER JOIN trade_detail tdl on td.id = tdl.order_id
  1750. where 1= 1 AND td.order_status NOT IN (-2, -1, 0, 1, 2, 12) AND td.is_account = 0
  1751. <if test="vo.orderNo != null and vo.orderNo != ''">
  1752. AND td.order_no = #{vo.orderNo}
  1753. </if>
  1754. <if test="vo.contactName != null and vo.contactName != ''">
  1755. AND tou.contact_name = #{vo.contactName}
  1756. </if>
  1757. <if test="vo.travelDate != null and vo.travelDate != ''">
  1758. AND td.travel_date = #{vo.travelDate}
  1759. </if>
  1760. GROUP BY td.id
  1761. ORDER BY td.create_time DESC
  1762. </select>
  1763. <update id="updateOrderStatus">
  1764. UPDATE trade_order SET order_status = #{orderStatus}, sync_status = '0' WHERE id = #{orderId} and order_status != #{orderStatus}
  1765. </update>
  1766. <update id="updateOrderIsAccount">
  1767. UPDATE trade_order SET is_account = #{isAccount} , sync_status = '0' WHERE id = #{orderId}
  1768. </update>
  1769. <update id="updateOrderDeleted">
  1770. UPDATE trade_order SET deleted = #{deleted}, sync_status = '0' WHERE id = #{orderId}
  1771. </update>
  1772. <resultMap id="OrderAndDetailResultMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderPdaRespVO">
  1773. <id property="id" column="id"/>
  1774. <result property="orderNo" column="order_no"/>
  1775. <result property="sourceName" column="source_name"/>
  1776. <result property="externalOrderNo" column="external_order_no"/>
  1777. <result property="routePlanId" column="route_plan_id"/>
  1778. <result property="visitorType" column="visitor_type"/>
  1779. <result property="travelDate" column="travel_date"/>
  1780. <result property="sellMethod" column="sell_method"/>
  1781. <result property="sourceName" column="source_name"/>
  1782. <result property="sellerId" column="seller_id"/>
  1783. <result property="memberId" column="member_id"/>
  1784. <result property="amount" column="amount"/>
  1785. <result property="payAmount" column="pay_amount"/>
  1786. <result property="orderStatus" column="order_status"/>
  1787. <result property="paymentDate" column="payment_date"/>
  1788. <result property="contactName" column="contact_name"/>
  1789. <result property="credentialNo" column="credential_no"/>
  1790. <result property="mobile" column="mobile"/>
  1791. <result property="remark" column="remark"/>
  1792. <collection property="tradeDetailList" resultMap="tradeDetailMap"/>
  1793. </resultMap>
  1794. <resultMap id="tradeDetailMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeDetailRespVO">
  1795. <result property="id" column="detailId"/>
  1796. <result property="orderId" column="order_id"/>
  1797. <result property="voucherCode" column="voucher_code"/>
  1798. <result property="voucherStatus" column="voucher_status"/>
  1799. <result property="useDate" column="use_date"/>
  1800. <result property="validityStartDate" column="validity_start_date"/>
  1801. <result property="validityEndDate" column="validity_end_date"/>
  1802. <result property="usageDays" column="usage_days"/>
  1803. <result property="checkStatus" column="check_status"/>
  1804. <result property="takeStatus" column="take_status"/>
  1805. <result property="refundStatus" column="refund_status"/>
  1806. <result property="verifyTime" column="verify_time"/>
  1807. <result property="activateStatus" column="activate_status"/>
  1808. <result property="activateDays" column="activate_days"/>
  1809. <result property="activateTime" column="activate_time"/>
  1810. <result property="productId" column="product_id"/>
  1811. <result property="productName" column="product_name"/>
  1812. <result property="specType" column="spec_type"/>
  1813. <collection property="detailBaseList" resultMap="tradeDetailBaseResMap"/>
  1814. </resultMap>
  1815. <resultMap id="tradeDetailBaseResMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.DetailBaseRespVO">
  1816. <result property="id" column="detail_base_id"/>
  1817. <result property="detailId" column="detailId"/>
  1818. <result property="productBaseId" column="product_base_id"/>
  1819. <result property="productBaseName" column="product_base_name"/>
  1820. <result property="productBaseType" column="product_base_type"/>
  1821. <result property="productResourceId" column="product_resource_id"/>
  1822. <result property="productResourceName" column="product_resource_name"/>
  1823. <result property="supplierProductId" column="supplier_product_id"/>
  1824. <result property="supplierId" column="supplier_id"/>
  1825. <result property="supplierName" column="supplier_name"/>
  1826. <result property="isSystemDirect" column="is_system_direct"/>
  1827. <result property="useStatus" column="use_status"/>
  1828. <result property="checkStatus" column="base_check_status"/>
  1829. <result property="verifyTime" column="base_verify_time"/>
  1830. <result property="price" column="base_price"/>
  1831. <result property="usageCount" column="usage_count"/>
  1832. <result property="productResourcePrice" column="product_resource_price"/>
  1833. <result property="projectId" column="project_id"/>
  1834. <result property="projectName" column="project_name"/>
  1835. <result property="specificationId" column="specification_id"/>
  1836. <result property="specificationName" column="specification_name"/>
  1837. <result property="specType" column="base_spec_type"/>
  1838. <result property="supplierVoucherCode" column="supplier_voucher_code"/>
  1839. <result property="platSupplierOrderId" column="plat_supplier_order_id"/>
  1840. </resultMap>
  1841. <select id="getOrderAndDetailInfo" resultMap="OrderAndDetailResultMap">
  1842. SELECT distinct td.id,td.order_no,td.external_order_no,td.route_plan_id,td.visitor_type,td.travel_date,td.sell_method,td.source_name,td.seller_id,td.member_id,td.amount,td.pay_amount,td.order_status,td.payment_date,td.remark,
  1843. tou.contact_name,tou.credential_no,tou.mobile,
  1844. tdl.id detailId,tdl.voucher_code,tdl.voucher_status,tdl.product_name,tdl.spec_type,tdl.validity_start_date,tdl.validity_end_date,
  1845. tdb.id detail_base_id,tdb.detail_id,tdb.product_base_id,tdb.product_base_name,tdb.product_base_type,tdb.product_resource_id,tdb.product_resource_name,tdb.supplier_product_id,tdb.supplier_id,
  1846. tdb.supplier_name,tdb.is_system_direct,tdb.use_status,tdb.check_status base_check_status,tdb.verify_time base_verify_time,tdb.price base_price,tdb.usage_count,tdb.product_resource_price,tdb.project_id,tdb.project_name,
  1847. tdb.specification_id,tdb.specification_name,tdb.spec_type base_spec_type,tdb.supplier_voucher_code,tdb.plat_supplier_order_id
  1848. FROM trade_order td
  1849. INNER JOIN trade_order_user tou on td.id = tou.order_id and td.deleted = 0
  1850. INNER JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
  1851. INNER JOIN trade_visitor tv on tv.detail_id = tdl.id and tv.deleted = 0
  1852. inner join trade_detail_base tdb on tdl.id = tdb.detail_id
  1853. where 1= 1 and td.order_status >= 6 and td.order_status <![CDATA[ <= ]]> 9
  1854. and td.sell_method != 3 and td.sell_method != 4
  1855. and tdl.validity_start_date <![CDATA[ <= ]]> NOW()
  1856. and tdl.validity_end_date <![CDATA[ >= ]]> NOW()
  1857. <if test="channelId != null and channelId != ''">
  1858. and tdb.product_base_id in (select product_id from product_check_channel where channel_id=#{channelId} and deleted = 0)
  1859. </if>
  1860. <if test="orderNo != null and orderNo != ''">
  1861. AND td.order_no = #{orderNo}
  1862. </if>
  1863. <choose>
  1864. <when test="phone != null and phone.length() == 4">
  1865. AND tou.mobile like concat('%',#{phone})
  1866. </when>
  1867. <when test="phone != null and phone != ''">
  1868. AND tou.mobile = #{phone}
  1869. </when>
  1870. <otherwise>
  1871. </otherwise>
  1872. </choose>
  1873. <choose>
  1874. <when test="cardNo != null and cardNo.length() == 4">
  1875. AND tv.credential_no like concat('%',#{cardNo})
  1876. </when>
  1877. <when test="cardNo != null and cardNo != ''">
  1878. AND tv.credential_no = #{cardNo}
  1879. </when>
  1880. <otherwise>
  1881. </otherwise>
  1882. </choose>
  1883. ORDER BY td.travel_date DESC
  1884. </select>
  1885. <select id="getPlatOrderNo" resultType="java.lang.String">
  1886. select t3.order_no from trade_order t1
  1887. inner join trade_supplier_order t2 on t1.id = t2.order_id
  1888. inner join trade_order t3 on t2.trade_no = t3.external_order_no
  1889. where t1.order_no = #{orderNo}
  1890. </select>
  1891. <select id="getTotalPayByOrderNo" resultType="java.math.BigDecimal">
  1892. select sum(t2.pay_amount) from trade_order t1 inner join trade_order_pay t2 on t1.id = t2.order_id
  1893. where t1.order_no = #{orderNo} and t2.pay_status = 1
  1894. </select>
  1895. <select id="getCheckOrder" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
  1896. SELECT td.id,td.order_no,td.external_order_no,td.route_plan_id,td.travel_status,plan.name as route_plan_name,td.visitor_type,td.travel_date,
  1897. td.sell_method,td.source_name,td.seller_id,td.member_id,td.amount,td.pay_amount,td.order_status,
  1898. td.payment_date,td.remark, tou.contact_name,tou.credential_no,tou.mobile,td.is_add_order
  1899. FROM trade_order td
  1900. INNER JOIN trade_order_user tou on td.id = tou.order_id and td.deleted = 0
  1901. INNER JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
  1902. left join product_route_plan plan on td.route_plan_id = plan.id
  1903. <if test="vo.type != null and vo.dispatchId == null and vo.type == 'boat'">
  1904. left join dispatch_operate_plan_boat_order_detail_base dopbodb on td.id = dopbodb.order_id and dopbodb.deleted = 0
  1905. </if>
  1906. <if test="vo.type != null and vo.dispatchId == null and vo.type == 'car'">
  1907. left join dispatch_car_dispatch_order_detail_base dcdodb on td.id = dcdodb.order_id and dcdodb.deleted = 0
  1908. </if>
  1909. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  1910. INNER JOIN trade_visitor tv on tv.detail_id = tdl.id and tv.deleted = 0
  1911. </if>
  1912. where 1=1
  1913. <choose>
  1914. <when test="vo.orderStatus != null">
  1915. AND td.order_status = #{vo.orderStatus}
  1916. </when>
  1917. <otherwise>
  1918. and td.order_status in (6,7,8,9,10,13)
  1919. </otherwise>
  1920. </choose>
  1921. <choose>
  1922. <when test="vo.travelDate != null and vo.travelDate != ''">
  1923. AND DATE_FORMAT(tdl.validity_start_date, '%Y-%m-%d') <![CDATA[ <= ]]> #{vo.travelDate}
  1924. AND DATE_FORMAT(tdl.validity_end_date, '%Y-%m-%d') <![CDATA[ >= ]]> #{vo.travelDate}
  1925. </when>
  1926. <otherwise>
  1927. and tdl.validity_start_date <![CDATA[ <= ]]> NOW()
  1928. and tdl.validity_end_date <![CDATA[ >= ]]> NOW()
  1929. </otherwise>
  1930. </choose>
  1931. <choose>
  1932. <when test="vo.orderNo != null and vo.orderNo.length() == 4">
  1933. AND td.order_no like concat('%',#{vo.orderNo})
  1934. </when>
  1935. <when test="vo.orderNo != null and vo.orderNo != ''">
  1936. AND td.order_no = #{vo.orderNo}
  1937. </when>
  1938. <otherwise>
  1939. </otherwise>
  1940. </choose>
  1941. <choose>
  1942. <when test="vo.phone != null and vo.phone.length() == 4">
  1943. AND tou.mobile like concat('%',#{vo.phone})
  1944. </when>
  1945. <when test="vo.phone != null and vo.phone != ''">
  1946. AND tou.mobile = #{vo.phone}
  1947. </when>
  1948. <otherwise>
  1949. </otherwise>
  1950. </choose>
  1951. <choose>
  1952. <when test="vo.credentialNo != null and vo.credentialNo.length() == 4">
  1953. AND tv.credential_no like concat('%',#{vo.credentialNo})
  1954. </when>
  1955. <when test="vo.credentialNo != null and vo.credentialNo != ''">
  1956. AND tv.credential_no = #{vo.credentialNo}
  1957. </when>
  1958. <otherwise>
  1959. </otherwise>
  1960. </choose>
  1961. <if test="vo.type != null and vo.dispatchId != null and vo.type == 'boat'">
  1962. AND td.id in (SELECT DISTINCT order_id FROM dispatch_operate_plan_boat_order_detail_base
  1963. WHERE plan_id = #{vo.dispatchId} and deleted = 0)
  1964. </if>
  1965. <if test="vo.type != null and vo.dispatchId != null and vo.type == 'car'">
  1966. AND td.id in (SELECT DISTINCT order_id FROM dispatch_car_dispatch_order_detail_base
  1967. WHERE car_dispatch_id = #{vo.dispatchId} and deleted = 0)
  1968. </if>
  1969. <if test="vo.travelStatus != null">
  1970. AND td.travel_status = #{vo.travelStatus}
  1971. </if>
  1972. <if test="vo.voucherCode != null and vo.voucherCode != ''">
  1973. AND tdl.voucher_code = #{vo.voucherCode}
  1974. </if>
  1975. <if test="vo.productName != null and vo.productName != ''">
  1976. AND tdl.product_name like concat('%',#{vo.productName}, '%')
  1977. </if>
  1978. <if test="vo.sellMethod != null">
  1979. AND td.sell_method = #{vo.sellMethod}
  1980. </if>
  1981. <if test="vo.planIds!=null and vo.planIds.size()>0 and vo.cateIds!=null and vo.cateIds.size()>0">
  1982. AND (td.route_plan_id in
  1983. <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
  1984. #{item}
  1985. </foreach>
  1986. or tdl.product_id in
  1987. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  1988. #{item}
  1989. </foreach>
  1990. )
  1991. </if>
  1992. <if test="vo.cateIds!=null and vo.cateIds.size()>0 and vo.planIds==null">
  1993. AND tdl.product_id in
  1994. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  1995. #{item}
  1996. </foreach>
  1997. </if>
  1998. <if test="vo.planIds!=null and vo.planIds.size()>0 and (vo.cateIds==null or vo.cateIds.size()==0)">
  1999. and td.route_plan_id in
  2000. <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
  2001. #{item}
  2002. </foreach>
  2003. </if>
  2004. group by td.id
  2005. ORDER BY td.create_time DESC
  2006. </select>
  2007. <select id="countCheckOrder" resultType="java.lang.Integer">
  2008. SELECT count(DISTINCT td.id) num FROM trade_order td
  2009. INNER JOIN trade_detail tdl ON td.id = tdl.order_id
  2010. INNER JOIN trade_order_user tou ON td.id = tou.order_id
  2011. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  2012. INNER JOIN trade_visitor tv on tv.detail_id = tdl.id and tv.deleted = 0
  2013. </if>
  2014. where 1=1
  2015. <choose>
  2016. <when test="vo.orderStatus != null">
  2017. AND td.order_status = #{vo.orderStatus}
  2018. </when>
  2019. <otherwise>
  2020. and td.order_status in (6,7,8,9,10,13)
  2021. </otherwise>
  2022. </choose>
  2023. <choose>
  2024. <when test="vo.travelDate != null and vo.travelDate != ''">
  2025. AND DATE_FORMAT(tdl.validity_start_date, '%Y-%m-%d') <![CDATA[ <= ]]> #{vo.travelDate}
  2026. AND DATE_FORMAT(tdl.validity_end_date, '%Y-%m-%d') <![CDATA[ >= ]]> #{vo.travelDate}
  2027. </when>
  2028. <otherwise>
  2029. and tdl.validity_start_date <![CDATA[ <= ]]> NOW()
  2030. and tdl.validity_end_date <![CDATA[ >= ]]> NOW()
  2031. </otherwise>
  2032. </choose>
  2033. <choose>
  2034. <when test="vo.orderNo != null and vo.orderNo.length() == 4">
  2035. AND td.order_no like concat('%',#{vo.orderNo})
  2036. </when>
  2037. <when test="vo.orderNo != null and vo.orderNo != ''">
  2038. AND td.order_no = #{vo.orderNo}
  2039. </when>
  2040. <otherwise>
  2041. </otherwise>
  2042. </choose>
  2043. <choose>
  2044. <when test="vo.phone != null and vo.phone.length() == 4">
  2045. AND tou.mobile like concat('%',#{vo.phone})
  2046. </when>
  2047. <when test="vo.phone != null and vo.phone != ''">
  2048. AND tou.mobile = #{vo.phone}
  2049. </when>
  2050. <otherwise>
  2051. </otherwise>
  2052. </choose>
  2053. <choose>
  2054. <when test="vo.credentialNo != null and vo.credentialNo.length() == 4">
  2055. AND tv.credential_no like concat('%',#{vo.credentialNo})
  2056. </when>
  2057. <when test="vo.credentialNo != null and vo.credentialNo != ''">
  2058. AND tv.credential_no = #{vo.credentialNo}
  2059. </when>
  2060. <otherwise>
  2061. </otherwise>
  2062. </choose>
  2063. <if test="vo.type != null and vo.dispatchId != null and vo.type == 'boat'">
  2064. AND td.id in (SELECT DISTINCT order_id FROM dispatch_operate_plan_boat_order_detail_base
  2065. WHERE plan_id = #{vo.dispatchId} and deleted = 0)
  2066. </if>
  2067. <if test="vo.type != null and vo.dispatchId != null and vo.type == 'car'">
  2068. AND td.id in (SELECT DISTINCT order_id FROM dispatch_car_dispatch_order_detail_base
  2069. WHERE car_dispatch_id = #{vo.dispatchId} and deleted = 0)
  2070. </if>
  2071. <if test="vo.travelStatus != null">
  2072. AND td.travel_status = #{vo.travelStatus}
  2073. </if>
  2074. <if test="vo.voucherCode != null and vo.voucherCode != ''">
  2075. AND tdl.voucher_code = #{vo.voucherCode}
  2076. </if>
  2077. <if test="vo.productName != null and vo.productName != ''">
  2078. AND tdl.product_name like concat('%',#{vo.productName}, '%')
  2079. </if>
  2080. <if test="vo.sellMethod != null">
  2081. AND td.sell_method = #{vo.sellMethod}
  2082. </if>
  2083. <if test="vo.planIds!=null and vo.planIds.size()>0 and vo.cateIds!=null and vo.cateIds.size()>0">
  2084. AND (td.route_plan_id in
  2085. <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
  2086. #{item}
  2087. </foreach>
  2088. or tdl.product_id in
  2089. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  2090. #{item}
  2091. </foreach>
  2092. )
  2093. </if>
  2094. <if test="vo.cateIds!=null and vo.cateIds.size()>0 and vo.planIds==null">
  2095. AND tdl.product_id in
  2096. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  2097. #{item}
  2098. </foreach>
  2099. </if>
  2100. <if test="vo.planIds!=null and vo.planIds.size()>0 and (vo.cateIds==null or vo.cateIds.size()==0)">
  2101. and td.route_plan_id in
  2102. <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
  2103. #{item}
  2104. </foreach>
  2105. </if>
  2106. </select>
  2107. <select id="selectStoreMachineProductList"
  2108. resultType="java.lang.Long">
  2109. SELECT t1.product_id FROM otc_agency_store_machine_product t1
  2110. where 1=1
  2111. <if test="vo.storeId != null and vo.storeId != ''">
  2112. AND t1.store_id = #{vo.storeId}
  2113. </if>
  2114. <if test="vo.machineId != null and vo.machineId != ''">
  2115. AND t1.machine_id = #{vo.machineId}
  2116. </if>
  2117. </select>
  2118. <select id="orderListByOta" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  2119. SELECT
  2120. t1.*
  2121. FROM
  2122. trade_order t1
  2123. inner join trade_detail t3 on t1.id = t3.order_id
  2124. inner join trade_visitor t4 on t3.id = t4.detail_id
  2125. INNER JOIN trade_order_user t2 ON t2.order_id = t1.id
  2126. WHERE
  2127. t1.sell_method = 0
  2128. AND t1.order_status in (6,7,8,9,10,13)
  2129. AND t1.tenant_id = #{tenantId}
  2130. AND t1.travel_date = #{travelDate}
  2131. <if test="credentialNo != null and credentialNo != ''">
  2132. AND t4.credential_no = #{credentialNo}
  2133. </if>
  2134. <if test="mobile != null and mobile != ''">
  2135. AND t2.mobile = #{mobile}
  2136. </if>
  2137. ORDER BY
  2138. t1.payment_date DESC
  2139. </select>
  2140. <select id="orderList" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  2141. SELECT
  2142. t1.*
  2143. FROM
  2144. trade_order t1
  2145. INNER JOIN trade_order_user t2 ON t2.order_id = t1.id
  2146. INNER JOIN trade_detail td on t1.id = td.order_id
  2147. INNER JOIN trade_visitor v on v.detail_id = td.id
  2148. WHERE
  2149. 1 = 1
  2150. <if test="orderStatus!=null and orderStatus.size()>0">
  2151. AND t1.order_status in
  2152. <foreach collection="orderStatus" item="item" separator="," open="(" close=")">
  2153. #{item}
  2154. </foreach>
  2155. </if>
  2156. AND t1.tenant_id = #{tenantId}
  2157. AND t1.travel_date = #{travelDate}
  2158. <if test="credentialNo != null and credentialNo != ''">
  2159. AND v.credential_no = #{credentialNo}
  2160. </if>
  2161. <if test="mobile != null and mobile != ''">
  2162. AND t2.mobile = #{mobile}
  2163. </if>
  2164. group by t1.id
  2165. ORDER BY
  2166. t1.payment_date DESC
  2167. </select>
  2168. <select id="queryOneByOrderNo" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  2169. SELECT DISTINCT o2.*
  2170. FROM trade_order o
  2171. INNER JOIN trade_detail d on d.order_id = o.id
  2172. INNER JOIN trade_detail_base db ON db.detail_id = d.id
  2173. INNER JOIN trade_detail d2 ON db.supplier_voucher_code = d2.voucher_code
  2174. INNER JOIN trade_order o2 ON d2.order_id = o2.id
  2175. WHERE o.order_no = #{orderNo}
  2176. union all
  2177. SELECT o.* FROM trade_order o WHERE o.sell_method in (0,1,4,6,7) and o.order_no = #{orderNo}
  2178. </select>
  2179. <select id="updateAppletProductSellNum">
  2180. update applet_product t1 inner JOIN applet_product_group t2 ON t1.id = t2.applet_product_id
  2181. and t2.deleted =0
  2182. set t1.sell_num = t1.sell_num+#{sellNum} where t2.product_id = #{productId}
  2183. </select>
  2184. <select id="selectCanBindOrderList" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  2185. SELECT o.id,o.is_bind
  2186. FROM trade_order o
  2187. INNER JOIN trade_detail d ON d.order_id = o.id
  2188. INNER JOIN trade_order_user u on o.id = u.order_id
  2189. WHERE
  2190. o.order_status > 5 AND o.deleted = 0
  2191. AND (o.is_bind IS NULL or o.is_bind = 0 ) and o.id != #{vo.orderId}
  2192. AND o.travel_date = #{vo.travelDate}
  2193. AND d.product_id = #{vo.productId}
  2194. <if test="vo.routePlanId !=null">
  2195. And o.route_plan_id = #{vo.routePlanId}
  2196. </if>
  2197. AND u.mobile = #{vo.mobile}
  2198. GROUP BY o.id
  2199. </select>
  2200. <update id="deleteOrderById">
  2201. delete from trade_order where id = #{orderId}
  2202. </update>
  2203. <update id="deleteOrderByOrderNo">
  2204. update from trade_order where order_no = #{orderNo}
  2205. </update>
  2206. <select id="getInvoiceOrderCount" resultType="java.lang.Integer">
  2207. select count(1) num from trade_invoice t1 inner join trade_invoice_detail t2 on t1.id = t2.invoice_id
  2208. and t1.invoice_status in (1,3)
  2209. where t2.order_no = #{orderNo} and t1.deleted = 0
  2210. </select>
  2211. <select id="selectPlatPayAmountByOriginOrderNo" resultType="java.util.Map">
  2212. select sum(tod.pay_amount) totalPayAmount
  2213. from trade_order tod
  2214. where tod.external_origin_order_no =#{originOrderNo} and tod.order_status>=6
  2215. </select>
  2216. <select id="selectChangeCountByOrderId" resultType="java.lang.Integer">
  2217. select count(*) totalCount
  2218. from trade_order tod
  2219. inner join trade_order_bind tb on tod.id = tb.order_id and tb.type = 2 and tb.deleted =0
  2220. inner join trade_order tod1 on tod1.id = tb.bind_id
  2221. where tod.id = #{orderId} and tod1.order_status>=6
  2222. </select>
  2223. <update id="updateOrderFinishStatus">
  2224. update trade_order tod,
  2225. (select tod.id
  2226. from trade_order tod
  2227. inner join trade_detail td on tod.id = td.order_id
  2228. where tod.sell_method in
  2229. <foreach collection="sellMethodList" item="item" separator="," open="(" close=")">
  2230. #{item}
  2231. </foreach>
  2232. and tod.order_status >=6
  2233. and td.validity_end_date = #{endDate}
  2234. and not EXISTS (
  2235. select 1
  2236. from trade_detail td1
  2237. where td1.validity_end_date > #{endDate} and td1.order_id = tod.id and td1.refund_status != 1
  2238. )
  2239. ) t
  2240. set tod.finish_status = 1
  2241. where tod.id = t.id
  2242. </update>
  2243. <select id="getSupplierCheckOrder" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
  2244. SELECT td.id,td.order_no,td.external_order_no,td.route_plan_id,plan.name as route_plan_name,td.visitor_type,td.travel_date,
  2245. td.sell_method,td.source_name,td.seller_id,td.member_id,td.amount,td.pay_amount,td.order_status,
  2246. td.payment_date,td.remark, tou.contact_name,tou.credential_no,tou.mobile
  2247. FROM trade_order td
  2248. INNER JOIN trade_order_user tou on td.id = tou.order_id and td.deleted = 0
  2249. INNER JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
  2250. INNER JOIN trade_detail_base tdb on tdb.detail_id = tdl.id
  2251. left join product_route_plan plan on td.route_plan_id = plan.id
  2252. <if test="vo.type != null and vo.dispatchId == null and vo.type == 'boat'">
  2253. inner join dispatch_operate_plan_boat_order_detail_base dopbodb on td.id = dopbodb.order_id and dopbodb.deleted = 0
  2254. </if>
  2255. <if test="vo.type != null and vo.dispatchId == null and vo.type == 'car'">
  2256. inner join dispatch_car_dispatch_order_detail_base dcdodb on td.id = dcdodb.order_id and dcdodb.deleted = 0
  2257. </if>
  2258. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  2259. INNER JOIN trade_visitor tv on tv.detail_id = tdl.id and tv.deleted = 0
  2260. </if>
  2261. where supplier_id in (
  2262. select t2.id from product_supplier_user t1 inner join product_supplier t2 on t1.supplier_id = t2.id
  2263. where t1.user_id=#{vo.userId} and t1.deleted =0
  2264. )
  2265. <choose>
  2266. <when test="vo.orderStatus != null">
  2267. AND td.order_status = #{vo.orderStatus}
  2268. </when>
  2269. <otherwise>
  2270. and td.order_status in (6,7,8,9,10,13)
  2271. </otherwise>
  2272. </choose>
  2273. <choose>
  2274. <when test="vo.travelDate != null and vo.travelDate != ''">
  2275. AND DATE_FORMAT(tdl.validity_start_date, '%Y-%m-%d') <![CDATA[ <= ]]> #{vo.travelDate}
  2276. AND DATE_FORMAT(tdl.validity_end_date, '%Y-%m-%d') <![CDATA[ >= ]]> #{vo.travelDate}
  2277. </when>
  2278. <otherwise>
  2279. and tdl.validity_start_date <![CDATA[ <= ]]> NOW()
  2280. and tdl.validity_end_date <![CDATA[ >= ]]> NOW()
  2281. </otherwise>
  2282. </choose>
  2283. <choose>
  2284. <when test="vo.orderNo != null and vo.orderNo.length() == 4">
  2285. AND td.order_no like concat('%',#{vo.orderNo})
  2286. </when>
  2287. <when test="vo.orderNo != null and vo.orderNo != ''">
  2288. AND td.order_no = #{vo.orderNo}
  2289. </when>
  2290. <otherwise>
  2291. </otherwise>
  2292. </choose>
  2293. <choose>
  2294. <when test="vo.phone != null and vo.phone.length() == 4">
  2295. AND tou.mobile like concat('%',#{vo.phone})
  2296. </when>
  2297. <when test="vo.phone != null and vo.phone != ''">
  2298. AND tou.mobile = #{vo.phone}
  2299. </when>
  2300. <otherwise>
  2301. </otherwise>
  2302. </choose>
  2303. <choose>
  2304. <when test="vo.credentialNo != null and vo.credentialNo.length() == 4">
  2305. AND tv.credential_no like concat('%',#{vo.credentialNo})
  2306. </when>
  2307. <when test="vo.credentialNo != null and vo.credentialNo != ''">
  2308. AND tv.credential_no = #{vo.credentialNo}
  2309. </when>
  2310. <otherwise>
  2311. </otherwise>
  2312. </choose>
  2313. <if test="vo.type != null and vo.dispatchId != null and vo.type == 'boat'">
  2314. AND td.id in (SELECT DISTINCT order_id FROM dispatch_operate_plan_boat_order_detail_base
  2315. WHERE plan_id = #{vo.dispatchId} and deleted = 0)
  2316. </if>
  2317. <if test="vo.type != null and vo.dispatchId != null and vo.type == 'car'">
  2318. AND td.id in (SELECT DISTINCT order_id FROM dispatch_car_dispatch_order_detail_base
  2319. WHERE car_dispatch_id = #{vo.dispatchId} and deleted = 0)
  2320. </if>
  2321. <if test="vo.voucherCode != null and vo.voucherCode != ''">
  2322. AND tdl.voucher_code = #{vo.voucherCode}
  2323. </if>
  2324. <if test="vo.checkType != null and vo.checkType == 1">
  2325. AND tdb.use_status in (1,2)
  2326. </if>
  2327. <if test="vo.checkType != null and vo.checkType == 2">
  2328. AND tdb.use_status in (3,6,8)
  2329. </if>
  2330. <if test="vo.productName != null and vo.productName != ''">
  2331. AND tdl.product_name like concat('%',#{vo.productName}, '%')
  2332. </if>
  2333. <if test="vo.sellMethod != null">
  2334. AND td.sell_method = #{vo.sellMethod}
  2335. </if>
  2336. <if test="vo.planIds!=null and vo.planIds.size()>0 and vo.cateIds!=null and vo.cateIds.size()>0">
  2337. AND (td.route_plan_id in
  2338. <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
  2339. #{item}
  2340. </foreach>
  2341. or tdl.product_id in
  2342. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  2343. #{item}
  2344. </foreach>
  2345. )
  2346. </if>
  2347. <if test="vo.cateIds!=null and vo.cateIds.size()>0 and vo.planIds==null">
  2348. AND tdl.product_id in
  2349. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  2350. #{item}
  2351. </foreach>
  2352. </if>
  2353. <if test="vo.planIds!=null and vo.planIds.size()>0 and (vo.cateIds==null or vo.cateIds.size()==0)">
  2354. and td.route_plan_id in
  2355. <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
  2356. #{item}
  2357. </foreach>
  2358. </if>
  2359. group by td.id
  2360. ORDER BY td.create_time DESC
  2361. </select>
  2362. <select id="getOtaTradeOrderPage"
  2363. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeDetailRespVO">
  2364. SELECT td.*,tor.order_no,pbr.check_start_date,pbr.check_end_date
  2365. FROM trade_detail td
  2366. LEFT JOIN product_basic_rule pbr on td.product_id = pbr.id
  2367. LEFT JOIN trade_order tor on tor.id = td.order_id
  2368. where 1= 1 AND
  2369. EXISTS (select * from product_sale_channel sc where sc.product_id = td.product_id and sc.channel_id = 0)
  2370. <if test="vo.productName != null and vo.productName != ''">
  2371. AND td.product_name = #{vo.productName}
  2372. </if>
  2373. <if test="vo.orderNo != null and vo.orderNo != ''">
  2374. AND tor.order_no = #{vo.orderNo}
  2375. </if>
  2376. <if test="vo.orderStatus != null and vo.orderStatus != ''">
  2377. AND tor.order_status = #{vo.orderStatus}
  2378. </if>
  2379. <if test="vo.paymentDateStart != null">
  2380. AND tor.payment_date <![CDATA[ >= ]]> #{vo.paymentDateStart}
  2381. </if>
  2382. <if test="vo.paymentDateEnd != null">
  2383. AND tor.payment_date <![CDATA[ <= ]]> #{vo.paymentDateEnd}
  2384. </if>
  2385. <if test="vo.type == 1">
  2386. AND tor.source_id = #{distributorId}
  2387. </if>
  2388. GROUP BY td.voucher_code
  2389. ORDER BY td.create_time DESC
  2390. </select>
  2391. <select id="regionStatic" resultType="java.util.Map">
  2392. select t4.id,t4.`name`,t6.province,t6.city,count(DISTINCT t3.id) num from trade_order t1 inner join trade_detail t2 on t1.id = t2.order_id
  2393. inner join trade_visitor t3 on t2.visitor_id = t3.id
  2394. inner join ota_distributor t4 on t1.source_id = t4.id
  2395. inner join ota_distributor_region t5 on t4.id = t5.distributor_id
  2396. and (left(t3.credential_no,2) = t5.distributor_region_id or left(t3.credential_no,4) = t5.distributor_region_id)
  2397. inner join ota_region t6 on ((t5.distributor_region_id = province_code and LEVEL=1) or t5.distributor_region_id = left(t6.id,4) )
  2398. where t2.voucher_status in (1,2,3,4,6,8,9)
  2399. <if test="vo.startDate != null and vo.startDate!=''">
  2400. AND t2.use_date <![CDATA[ >= ]]> #{vo.startDate}
  2401. </if>
  2402. <if test="vo.endDate != null and vo.endDate!=''">
  2403. AND t2.use_date <![CDATA[ <= ]]> #{vo.endDate}
  2404. </if>
  2405. GROUP BY t4.id
  2406. order by num desc
  2407. </select>
  2408. <select id="queryOrderByLast" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  2409. SELECT * FROM trade_order WHERE order_no = #{orderNo} and deleted = 1 ORDER BY update_time DESC limit 1
  2410. </select>
  2411. <select id="queryOrderById" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  2412. SELECT * FROM trade_order WHERE id = #{orderId} ORDER BY update_time DESC limit 1
  2413. </select>
  2414. <select id="selectConfirmationCountry"
  2415. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderConfirmationCountryRespVO">
  2416. SELECT
  2417. t5.room_model_type_id,
  2418. t3.short_name room_model_short_name,
  2419. t3.NAME room_model_name,
  2420. ifnull( t1.nationality, 1 ) nationality,
  2421. ifnull( t4.NAME, '中国' ) nationality_name,
  2422. t1.room_model_id,
  2423. t1.type,
  2424. ifnull(t1.floor,'0') floor,
  2425. count( t1.id ) num,
  2426. ifnull(t2.actual_price,0) actual_price
  2427. FROM
  2428. trade_visitor t1
  2429. LEFT JOIN trade_detail t2 ON t1.id = t2.visitor_id
  2430. AND t2.product_type = 0
  2431. AND t1.deleted = 0
  2432. LEFT JOIN resource_room_model t3 ON t1.room_model_id = t3.id
  2433. AND t3.deleted = 0
  2434. LEFT JOIN area t4 ON t1.nationality = t4.id
  2435. LEFT JOIN trade_order_room_model t5 ON t1.room_index_id = t5.room_index_id
  2436. AND t5.deleted = 0
  2437. LEFT JOIN product_price_room_model_type t6 ON t5.room_model_type_id = t6.id
  2438. WHERE
  2439. t1.order_id = #{orderId}
  2440. GROUP BY
  2441. t1.room_model_id,
  2442. t1.floor,
  2443. t1.type,
  2444. t1.nationality,
  2445. t5.room_model_type_id
  2446. ORDER BY
  2447. floor DESC
  2448. </select>
  2449. <select id="getOrderCount" resultType="java.util.Map">
  2450. select GROUP_CONCAT(num,'*',name) name,sum(num1) num1,sum(num2) num2,sum(num3) num3,sum(num4) num4 from (
  2451. SELECT sum(CASE WHEN tv.type='adultPlus' or tv.type='adultTake' THEN 1 ELSE 0 END) num1,
  2452. sum(CASE WHEN tv.type='babyTake' or tv.type='babyPlus' or tv.type='babyNonTake' or tv.type='childTake' or tv.type='childPlus' or tv.type='childNonTake' THEN 1 ELSE 0 END) num2,
  2453. sum(CASE WHEN tv.type='with' THEN 1 ELSE 0 END) num3,
  2454. sum(CASE WHEN tv.type='leader' THEN 1 ELSE 0 END) num4,
  2455. CONCAT(rrm.short_name,'(',tv.floor,'F)') name ,count(1) num
  2456. FROM trade_order td
  2457. INNER JOIN trade_order_user tou on td.id = tou.order_id
  2458. left JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
  2459. left join trade_visitor tv on tdl.id = tv.detail_id
  2460. left JOIN product_spu ps on ps.id = tdl.product_id
  2461. LEFT JOIN ota_distributor od on od.id = td.source_id
  2462. left join trade_order_room_model tm on tv.room_index_id = tm.room_index_id and tm.deleted =0 AND td.id = tm.order_id
  2463. left join resource_room_model rrm on tm.room_model_id = rrm.id
  2464. LEFT JOIN (select m2.order_id,sum(m2.refund_amount) refund_amount,sum(m2.origin_amount) origin_amount from trade_refund m2 where m2.refund_status = 6 and m2.refund_method !=2 GROUP BY m2.order_id) tr on td.id = tr.order_id
  2465. where td.deleted = 0 and tou.deleted = 0 and td.order_status >0 and tv.type is not null
  2466. <if test="vo.orderStatus!=null and vo.orderStatus.size()>0">
  2467. and td.order_status in
  2468. <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
  2469. #{item}
  2470. </foreach>
  2471. </if>
  2472. <if test="vo.tenantId!=null">
  2473. AND td.tenant_id = #{vo.tenantId}
  2474. </if>
  2475. <choose>
  2476. <when test="vo.orderNo != null and vo.orderNo.length() == 4">
  2477. AND td.order_no like concat('%',#{vo.orderNo})
  2478. </when>
  2479. <when test="vo.orderNo != null and vo.orderNo != ''">
  2480. AND td.order_no = #{vo.orderNo}
  2481. </when>
  2482. <otherwise>
  2483. </otherwise>
  2484. </choose>
  2485. <if test="vo.externalOriginOrderNo != null and vo.externalOriginOrderNo != ''">
  2486. AND td.external_origin_order_no = #{vo.externalOriginOrderNo}
  2487. </if>
  2488. <if test="vo.memberId != null and vo.memberId != ''">
  2489. AND td.member_id = #{vo.memberId}
  2490. </if>
  2491. <if test="vo.voyageId != null and vo.voyageId != ''">
  2492. AND td.voyage_id = #{vo.voyageId}
  2493. </if>
  2494. <if test="vo.shipId != null and vo.shipId != ''">
  2495. AND td.ship_id = #{vo.shipId}
  2496. </if>
  2497. <if test="vo.routeId != null and vo.routeId != ''">
  2498. AND exists (select 1 from product_voyage top where top.id = td.voyage_id and top.route_id = #{vo.routeId})
  2499. </if>
  2500. <if test="vo.dispatchStatus != null">
  2501. AND td.dispatch_status = #{vo.dispatchStatus}
  2502. </if>
  2503. <if test="vo.payType != null">
  2504. AND exists (select 1 from trade_order_pay top where top.order_id = td.id and top.payment_type = #{vo.payType})
  2505. </if>
  2506. <if test="vo.otaCateId != null and vo.otaCateId != ''">
  2507. AND od.ota_category_id = #{vo.otaCateId}
  2508. </if>
  2509. <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
  2510. and od.ota_category_id in
  2511. <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
  2512. #{item}
  2513. </foreach>
  2514. </if>
  2515. <if test="vo.otaId != null and vo.otaId != ''">
  2516. AND td.source_id = #{vo.otaId}
  2517. </if>
  2518. <if test="vo.otaIds != null and vo.otaIds.size()>0">
  2519. AND td.source_id IN
  2520. <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
  2521. #{item}
  2522. </foreach>
  2523. </if>
  2524. <if test="vo.storeId != null and vo.storeId != ''">
  2525. AND td.store_id = #{vo.storeId}
  2526. </if>
  2527. <if test="vo.productTag != null and vo.productTag != ''">
  2528. AND ps.product_tag = #{vo.productTag}
  2529. </if>
  2530. <if test="vo.productTag2 != null and vo.productTag2 != ''">
  2531. AND ps.product_tag2 = #{vo.productTag2}
  2532. </if>
  2533. <if test="vo.productTag3 != null and vo.productTag3 != ''">
  2534. AND ps.product_tag3 = #{vo.productTag3}
  2535. </if>
  2536. <if test="vo.productTag4 != null and vo.productTag4 != ''">
  2537. AND ps.product_tag4 = #{vo.productTag4}
  2538. </if>
  2539. <if test="vo.cateIds!=null and vo.cateIds.size()>0 and (vo.planIds==null or vo.planIds.size()==0)">
  2540. AND tdl.product_id in
  2541. <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
  2542. #{item}
  2543. </foreach>
  2544. </if>
  2545. <if test="vo.externalOrderNo != null and vo.externalOrderNo != ''">
  2546. AND td.external_order_no = #{vo.externalOrderNo}
  2547. </if>
  2548. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  2549. AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.credential_no = #{vo.credentialNo})
  2550. </if>
  2551. <if test="vo.userName != null and vo.userName != ''">
  2552. AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.name = #{vo.userName})
  2553. </if>
  2554. <choose>
  2555. <when test="vo.mobile != null and vo.mobile.length() == 4">
  2556. AND tou.mobile like concat('%',#{vo.mobile})
  2557. </when>
  2558. <when test="vo.mobile != null and vo.mobile != ''">
  2559. AND tou.mobile = #{vo.mobile}
  2560. </when>
  2561. <otherwise>
  2562. </otherwise>
  2563. </choose>
  2564. <if test="vo.contactName != null and vo.contactName != ''">
  2565. AND tou.contact_name = #{vo.contactName}
  2566. </if>
  2567. <if test="vo.travelDate != null and vo.travelDate != ''">
  2568. AND td.travel_date = #{vo.travelDate}
  2569. </if>
  2570. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  2571. AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
  2572. </if>
  2573. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  2574. AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
  2575. </if>
  2576. <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
  2577. AND td.create_time <![CDATA[ >= ]]> #{vo.orderDateStart}
  2578. </if>
  2579. <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
  2580. AND td.create_time <![CDATA[ <= ]]> #{vo.orderDateEnd}
  2581. </if>
  2582. <if test="vo.orderDate != null and vo.orderDate != ''">
  2583. AND td.create_time = #{vo.orderDate}
  2584. </if>
  2585. <if test="vo.sellerId != null and vo.sellerId != ''">
  2586. AND td.seller_id = #{vo.sellerId}
  2587. </if>
  2588. <if test="vo.shareName != null and vo.shareName != ''">
  2589. AND td.share_name like concat('%',#{vo.shareName},'%')
  2590. </if>
  2591. <if test="vo.voucherCode != null and vo.voucherCode != ''">
  2592. AND tdl.voucher_code = #{vo.voucherCode}
  2593. </if>
  2594. <if test="vo.sellMethod != null and vo.sellMethod != ''">
  2595. AND td.sell_method = #{vo.sellMethod}
  2596. </if>
  2597. <if test="vo.productName != null and vo.productName != ''">
  2598. AND tdl.product_name like concat('%',#{vo.productName}, '%')
  2599. </if>
  2600. <if test="vo.isFullPay == 0">
  2601. AND td.is_full_pay = #{vo.isFullPay}
  2602. </if>
  2603. <if test="vo.isComment != null">
  2604. AND td.is_comment = #{vo.isComment}
  2605. </if>
  2606. <if test="vo.sourceId != null and vo.sourceId != ''">
  2607. AND td.source_id = #{vo.sourceId}
  2608. </if>
  2609. <if test="vo.distributorId != null and vo.distributorId != ''">
  2610. AND td.source_id = #{vo.distributorId}
  2611. </if>
  2612. <if test="vo.sourceName != null and vo.sourceName != ''">
  2613. AND td.source_name like concat('%',#{vo.sourceName}, '%')
  2614. </if>
  2615. <if test="vo.travelStatus != null">
  2616. AND td.travel_status = #{vo.travelStatus}
  2617. </if>
  2618. <if test="vo.orderRefundDateStart != null and vo.orderRefundDateEnd != ''">
  2619. AND exists (select 1 from trade_refund tr where tr.order_id=td.id and tr.refund_status = 6 and tr.refund_time BETWEEN #{vo.orderRefundDateStart} and #{vo.orderRefundDateEnd} )
  2620. </if>
  2621. GROUP BY rrm.short_name,tv.floor
  2622. ) p
  2623. </select>
  2624. <select id="selectTotalByOrderIds" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.OrderTotalRespVO">
  2625. select sum(adult_total_num) adultTotalNum, sum(child_total_num) childTotalNum, sum(baby_total_num) babyTotalNum,
  2626. sum(with_total_num) withTotalNum, sum(leader_total_num) leaderTotalNum, sum(free_num) freeNum,
  2627. sum(order_money) orderMoney, sum(real_money) realMoney, sum(other_money) otherMoney,
  2628. sum(adjust_total_money) adjustTotalMoney, sum(with_amount) withTotalNumMoney,
  2629. sum(leader_amount) leaderTotalMoney, sum(free_amount) freeAmount, sum(service_money) serviceMoney,
  2630. sum(up_floor_total_num) upFloorTotalNum, sum(up_floor_total_money) upFloorTotalMoney,
  2631. sum(plus_total_num) plusTotalNum, sum(collection_service_money) collectionServiceMoney,
  2632. sum(use_room_total_num) totalRoomNum,sum(free_amount) freeAmount from trade_order_total
  2633. where 1=1
  2634. AND old_order_id in
  2635. <foreach collection="orderIds" item="item" separator="," open="(" close=")">
  2636. #{item}
  2637. </foreach>
  2638. </select>
  2639. <!-- 查询游客名单导出基础信息(船名、航期、航向) -->
  2640. <select id="selectTouristExportBase" resultType="java.util.Map">
  2641. SELECT
  2642. rs.name as shipName,
  2643. pv.start_time as travelDate,
  2644. rr.direction as direction
  2645. FROM trade_order tor
  2646. LEFT JOIN product_voyage pv ON tor.voyage_id = pv.id
  2647. LEFT JOIN resource_ship rs ON pv.ship_id = rs.id
  2648. LEFT JOIN resource_route rr ON pv.route_id = rr.id
  2649. LEFT JOIN ota_distributor od on od.id = tor.source_id
  2650. WHERE tor.deleted = 0
  2651. <if test="vo.orderNo != null and vo.orderNo != ''">
  2652. AND tor.order_no = #{vo.orderNo}
  2653. </if>
  2654. <if test="vo.voyageId != null and vo.voyageId != ''">
  2655. AND tor.voyage_id = #{vo.voyageId}
  2656. </if>
  2657. <if test="vo.shipId != null and vo.shipId != ''">
  2658. AND pv.ship_id = #{vo.shipId}
  2659. </if>
  2660. <if test="vo.routeId != null and vo.routeId != ''">
  2661. AND pv.route_id = #{vo.routeId}
  2662. </if>
  2663. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  2664. AND pv.start_time &gt;= #{vo.travelDateStart}
  2665. </if>
  2666. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  2667. AND pv.start_time &lt;= #{vo.travelDateEnd}
  2668. </if>
  2669. <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
  2670. AND tor.create_time &gt;= #{vo.orderDateStart}
  2671. </if>
  2672. <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
  2673. AND tor.create_time &lt;= #{vo.orderDateEnd}
  2674. </if>
  2675. <if test="vo.orderStatus != null and vo.orderStatus.size() > 0">
  2676. AND tor.order_status IN
  2677. <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
  2678. #{item}
  2679. </foreach>
  2680. </if>
  2681. <if test="vo.otaId != null and vo.otaId != ''">
  2682. AND tor.source_id = #{vo.otaId}
  2683. </if>
  2684. <if test="vo.otaIds != null and vo.otaIds.size()>0">
  2685. AND tor.source_id IN
  2686. <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
  2687. #{item}
  2688. </foreach>
  2689. </if>
  2690. <if test="vo.otaCateId != null and vo.otaCateId != ''">
  2691. AND od.ota_category_id = #{vo.otaCateId}
  2692. </if>
  2693. <if test="vo.otaCateIds != null and vo.otaCateIds.size() > 0">
  2694. AND od.ota_category_id IN
  2695. <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
  2696. #{item}
  2697. </foreach>
  2698. </if>
  2699. <if test="vo.contactName != null and vo.contactName != ''">
  2700. AND tor.link_man LIKE CONCAT('%', #{vo.contactName}, '%')
  2701. </if>
  2702. <if test="vo.mobile != null and vo.mobile != ''">
  2703. AND tor.link_mobile = #{vo.mobile}
  2704. </if>
  2705. LIMIT 1
  2706. </select>
  2707. <select id="selectAppPage" resultType="com.yc.ship.module.trade.controller.app.otc.vo.AppTradeOrderRespNewVO">
  2708. select t1.id, t1.order_no, t3.img, t1.ship_id, t3.`name` ship_name, t3.short_name ship_short_name,t4.`name` route_name, t4.direction, t1.voyage_id, t2.`name` voyage_name,t2.boarding_time,t2.start_time,t2.leave_time, t1.order_status, t1.amount price from trade_order t1 LEFT JOIN product_voyage t2 on t1.voyage_id = t2.id
  2709. LEFT JOIN resource_ship t3 on t1.ship_id = t3.id
  2710. LEFT JOIN resource_route t4 on t2.route_id = t4.id
  2711. where t1.deleted = 0
  2712. and member_id = #{pageReqVO.memberId}
  2713. <if test="pageReqVO.orderStatus != null and pageReqVO.orderStatus != ''">
  2714. and order_status = #{pageReqVO.orderStatus}
  2715. </if>
  2716. order by t1.create_time desc
  2717. </select>
  2718. <select id="selectMyItinerary"
  2719. resultType="com.yc.ship.module.trade.controller.app.otc.vo.AppMyItineraryVO">
  2720. SELECT
  2721. t1.id order_id,
  2722. t1.order_no,
  2723. t1.ship_id,
  2724. t4.name ship_name,
  2725. t1.voyage_id,
  2726. t2.`name` voyage_name,
  2727. t2.route_id,
  2728. t3.`name` route_name,
  2729. t2.boarding_time,
  2730. t2.start_time,
  2731. t2.leave_time,
  2732. t3.direction,
  2733. t5.room_model_id,
  2734. t5.floor,
  2735. t5.room_id
  2736. FROM
  2737. trade_order t1
  2738. LEFT JOIN product_voyage t2 ON t1.voyage_id = t2.id
  2739. LEFT JOIN resource_route t3 ON t2.route_id = t3.id
  2740. LEFT JOIN resource_ship t4 ON t2.ship_id = t4.id
  2741. left join trade_visitor t5 on t1.id = t5.order_id
  2742. WHERE
  2743. t1.deleted = 0
  2744. and t1.order_status in (3,6,7,8,9)
  2745. <choose>
  2746. <when test="keyword != null and keyword != ''">
  2747. and (t5.mobile = #{keyword} or t5.credential_no = #{keyword})
  2748. </when>
  2749. <otherwise>
  2750. and member_id = #{memberId}
  2751. </otherwise>
  2752. </choose>
  2753. <if test="status != null and status != ''">
  2754. <if test="status == '1' or status == 1">
  2755. and t2.boarding_time > now()
  2756. </if>
  2757. <if test="status == '2' or status == 2">
  2758. and t2.boarding_time &lt;= now() and t2.leave_time > now()
  2759. </if>
  2760. <if test="status == '3' or status == 3">
  2761. and t2.leave_time &lt; now()
  2762. </if>
  2763. </if>
  2764. order by t2.boarding_time asc
  2765. </select>
  2766. <select id="selectTotal1ByOrderIds"
  2767. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.OrderTotalRespVO">
  2768. select sum(deposi) deposi, sum(damaged) damaged, sum(supplement_amount) supplement_amount,
  2769. sum(pay_amount) pay_amount, sum(real_pay_amount) real_pay_amount,sum(pay_amount - real_pay_amount) unpaid_amount from trade_order
  2770. where 1=1 and id in
  2771. <foreach collection="orderIds" item="item" separator="," open="(" close=")">
  2772. #{item}
  2773. </foreach>
  2774. </select>
  2775. <select id="selectItineraryDetail"
  2776. resultType="com.yc.ship.module.trade.controller.app.otc.vo.AppItineraryDetailVO">
  2777. SELECT
  2778. t1.id order_id,
  2779. t1.order_no,
  2780. t2.boarding_time,
  2781. t2.start_time,
  2782. t2.leave_time,
  2783. t2.route_id,
  2784. t3.`name` route_name,
  2785. t3.on_dock_id,
  2786. t4.`name` on_dock_name
  2787. FROM
  2788. trade_order t1
  2789. LEFT JOIN product_voyage t2 ON t1.voyage_id = t2.id
  2790. LEFT JOIN resource_route t3 ON t2.route_id = t3.id
  2791. LEFT JOIN resource_dock t4 ON t3.on_dock_id = t4.id
  2792. WHERE
  2793. 1=1 and
  2794. t1.id = #{orderId}
  2795. </select>
  2796. <select id="selectTotal2ByOrderIds"
  2797. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.OrderTotalRespVO">
  2798. SELECT
  2799. ifnull( sum( CASE WHEN type = 'adultTake' OR type = 'adultPlus' or type IS NULL or type = '' THEN num ELSE 0 END ), 0 ) AS adultTotalNum,
  2800. ifnull( sum( CASE WHEN type = 'childTake' OR type = 'childNonTake' OR type = 'childPlus' THEN num ELSE 0 END ), 0 ) AS childTotalNum,
  2801. ifnull( sum( CASE WHEN type = 'babyTake' OR type = 'babyNonTake' OR type = 'babyPlus' THEN num ELSE 0 END ), 0 ) AS babyTotalNum,
  2802. ifnull( sum( CASE WHEN type = 'leader' THEN num ELSE 0 END ), 0 ) AS leaderTotalNum,
  2803. ifnull( sum( CASE WHEN type = 'with' THEN num ELSE 0 END ), 0 ) AS withTotalNum,
  2804. ifnull( sum( num ), 0 ) AS totalNum
  2805. FROM
  2806. ( SELECT type, count( 1 ) num FROM trade_visitor WHERE deleted = 0
  2807. and order_id in
  2808. <foreach collection="orderIds" item="item" separator="," open="(" close=")">
  2809. #{item}
  2810. </foreach>
  2811. GROUP BY type ) a
  2812. </select>
  2813. <select id="selectCanBuyInsuranceOrder" resultType="java.lang.Long">
  2814. select id
  2815. from trade_order
  2816. where deleted = 0
  2817. and order_status in (1,6)
  2818. and (is_insure is null)
  2819. and travel_date BETWEEN now() and CONCAT(DATE_ADD(CURDATE(),INTERVAL 2 DAY), ' 23:59:59')
  2820. </select>
  2821. <select id="queryOrderLink" resultType="java.util.Map">
  2822. select distinct td.link_mobile from trade_order td
  2823. LEFT JOIN product_voyage pv ON td.voyage_id = pv.id
  2824. LEFT JOIN resource_route rr ON pv.route_id = rr.id
  2825. where DATE_FORMAT(td.travel_date, '%Y-%m-%d') = DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL (-#{day}) DAY), '%Y-%m-%d')
  2826. and td.deleted='0' and td.link_mobile is not null and td.order_status in (0,1,2,3,6,7,8,9,12,13,14,15)
  2827. and rr.direction = #{direction} and td.voyage_id = #{voyageId}
  2828. </select>
  2829. <select id="queryOrderJzPhone" resultType="java.util.Map">
  2830. select distinct tzd.phone from trade_order td
  2831. left join trade_order_jz tz on tz.order_id = td.id
  2832. left join trade_order_jz_detail tzd on tzd.jz_id = tz.id and tzd.deleted='0'
  2833. LEFT JOIN product_voyage pv ON td.voyage_id = pv.id
  2834. LEFT JOIN resource_route rr ON pv.route_id = rr.id
  2835. where DATE_FORMAT(td.travel_date, '%Y-%m-%d') = DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL (-#{day}) DAY), '%Y-%m-%d')
  2836. and td.deleted='0' and tzd.phone is not null and td.order_status in (0,1,2,3,6,7,8,9,12,13,14,15)
  2837. and rr.direction = #{direction} and td.voyage_id = #{voyageId}
  2838. </select>
  2839. <select id="queryOrderVisitorMobile" resultType="java.util.Map">
  2840. select distinct tv.mobile from trade_order td
  2841. left join trade_visitor tv on tv.order_id = td.id
  2842. LEFT JOIN product_voyage pv ON td.voyage_id = pv.id
  2843. LEFT JOIN resource_route rr ON pv.route_id = rr.id
  2844. where DATE_FORMAT(td.travel_date, '%Y-%m-%d') = DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL (-#{day}) DAY), '%Y-%m-%d')
  2845. and td.deleted='0' and (tv.mobile is not null and tv.mobile !='') and tv.deleted='0'
  2846. and td.order_status in (0,1,2,3,6,7,8,9,12,13,14,15) and rr.direction = #{direction} and td.voyage_id = #{voyageId}
  2847. </select>
  2848. <select id="getTradeJz" resultType="java.util.Map">
  2849. select t1.use_date,t3.batch_no,t3.jz_id,t3.`name`,t3.phone,t2.id visitorId,t3.id_card,t3.remark,t4.jz_link_name,t4.jz_address,t4.jz_link_phone from trade_detail t1 inner join trade_visitor t2 on t1.id = t2.detail_id
  2850. inner join trade_order_jz_detail t3 on t2.id = t3.visitor_id
  2851. inner join trade_order_jz t4 on t3.jz_id = t4.id
  2852. where t1.deleted=0 and t2.deleted=0 and t3.deleted =0
  2853. and t3.extend_order_no is null and DATE_FORMAT(t1.travel_date, '%Y-%m-%d') = DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL (1) DAY), '%Y-%m-%d')
  2854. </select>
  2855. <select id="getCanContractOrder" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
  2856. SELECT * FROM trade_order WHERE is_contract is null and travel_date BETWEEN CONCAT(DATE_ADD(CURDATE(),INTERVAL 1 DAY),' 00:00:00') and CONCAT(DATE_ADD(CURDATE(),INTERVAL 2 DAY), ' 23:59:59')
  2857. </select>
  2858. </mapper>