| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.yc.ship.module.trade.dal.mysql.order.TradeOrderMapper">
- <resultMap id="MiddleWareDtoResultMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
- <id property="id" column="id"/>
- <result property="orderNo" column="order_no"/>
- <result property="voyageId" column="voyage_id"/>
- <result property="bindId" column="bindId"/>
- <result property="isRead" column="isRead"/>
- <result property="sourceName" column="source_name"/>
- <result property="externalOrderNo" column="external_order_no"/>
- <result property="externalOriginOrderNo" column="external_origin_order_no"/>
- <result property="routePlanId" column="route_plan_id"/>
- <result property="routePlanName" column="route_plan_name"/>
- <result property="visitorType" column="visitor_type"/>
- <result property="travelDate" column="travel_date"/>
- <result property="sellMethod" column="sell_method"/>
- <result property="sourceName" column="source_name"/>
- <result property="sellerId" column="seller_id"/>
- <result property="memberId" column="member_id"/>
- <result property="amount" column="amount"/>
- <result property="payAmount" column="pay_amount"/>
- <result property="paymentStatus" column="pay_status"/>
- <result property="paymentType" column="payment_type"/>
- <result property="orderStatus" column="order_status"/>
- <result property="paymentDate" column="payment_date"/>
- <result property="areaManagerId" column="area_manager_id"/>
- <result property="storeName" column="store_name"/>
- <result property="contactName" column="contactName"/>
- <result property="shareName" column="share_name"/>
- <result property="isBind" column="is_bind"/>
- <result property="credentialNo" column="credentialNo"/>
- <result property="city" column="city"/>
- <result property="province" column="province"/>
- <result property="county" column="county"/>
- <result property="createTime" column="create_time"/>
- <result property="mobile" column="mobile"/>
- <result property="auditState" column="audit_state"/>
- <result property="storeId" column="store_id"/>
- <result property="sourceId" column="source_id"/>
- <result property="isMarketing" column="is_marketing"/>
- <result property="isMarketingUse" column="is_marketing_use"/>
- <result property="remark" column="remark"/>
- <result property="dispatchStatus" column="dispatch_status"/>
- <result property="isInvoice" column="is_invoice"/>
- <result property="isChangeOrder" column="is_change_order"/>
- <result property="refundAmount" column="refund_amount"/>
- <result property="confirmType" column="confirm_type"/>
- <result property="travelStatus" column="travel_status"/>
- <result property="finishStatus" column="finish_status"/>
- <result property="agencyGroupId" column="agency_group_id"/>
- <collection property="orderPayList" resultMap="orderPayList"/>
- <collection property="insuranceList" resultMap="insuranceResultMap"/>
- <collection property="contractList" resultMap="contractResultMap"/>
- </resultMap>
- <resultMap id="MiddleWareDtoResultMap2" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderPdaRespVO">
- <id property="id" column="id"/>
- <result property="orderNo" column="order_no"/>
- <result property="bindId" column="bindId"/>
- <result property="isRead" column="isRead"/>
- <result property="sourceName" column="source_name"/>
- <result property="externalOrderNo" column="external_order_no"/>
- <result property="externalOriginOrderNo" column="external_origin_order_no"/>
- <result property="routePlanId" column="route_plan_id"/>
- <result property="routePlanName" column="route_plan_name"/>
- <result property="visitorType" column="visitor_type"/>
- <result property="travelDate" column="travel_date"/>
- <result property="sellMethod" column="sell_method"/>
- <result property="sourceName" column="source_name"/>
- <result property="sellerId" column="seller_id"/>
- <result property="memberId" column="member_id"/>
- <result property="amount" column="amount"/>
- <result property="payAmount" column="pay_amount"/>
- <result property="paymentStatus" column="pay_status"/>
- <result property="paymentType" column="payment_type"/>
- <result property="orderStatus" column="order_status"/>
- <result property="paymentDate" column="payment_date"/>
- <result property="areaManagerId" column="area_manager_id"/>
- <result property="storeName" column="store_name"/>
- <result property="contactName" column="contactName"/>
- <result property="shareName" column="share_name"/>
- <result property="isBind" column="is_bind"/>
- <result property="credentialNo" column="credentialNo"/>
- <result property="city" column="city"/>
- <result property="province" column="province"/>
- <result property="county" column="county"/>
- <result property="createTime" column="create_time"/>
- <result property="mobile" column="mobile"/>
- <result property="auditState" column="audit_state"/>
- <result property="storeId" column="store_id"/>
- <result property="sourceId" column="source_id"/>
- <result property="isMarketing" column="is_marketing"/>
- <result property="isMarketingUse" column="is_marketing_use"/>
- <result property="remark" column="remark"/>
- <result property="dispatchStatus" column="dispatch_status"/>
- <result property="isInvoice" column="is_invoice"/>
- <result property="isChangeOrder" column="is_change_order"/>
- <result property="refundAmount" column="refund_amount"/>
- <result property="confirmType" column="confirm_type"/>
- <result property="travelStatus" column="travel_status"/>
- <result property="finishStatus" column="finish_status"/>
- <result property="agencyGroupId" column="agency_group_id"/>
- <collection property="orderPayList" resultMap="orderPayList"/>
- <collection property="insuranceList" resultMap="insuranceResultMap"/>
- <collection property="contractList" resultMap="contractResultMap"/>
- </resultMap>
- <resultMap id="orderPayList" type="com.yc.ship.module.trade.api.dto.TradeOrderPayDTO">
- <id property="id" column="payId"/>
- <result property="orderId" column="id"/>
- <result property="payAmount" column="payAmount"/>
- <result property="paymentNo" column="payment_no"/>
- <result property="payStatus" column="pay_status"/>
- <result property="paymentType" column="payment_type"/>
- <result property="paymentDate" column="payment_date"/>
- </resultMap>
- <resultMap id="insuranceResultMap" type="com.yc.ship.module.trade.dal.dataobject.insurance.InsuranceDO">
- <id property="id" column="insuranceId"/>
- <result property="orderId" column="id"/>
- <result property="policyNo" column="policy_no"/>
- <result property="proposalNo" column="proposal_no"/>
- <result property="insuranceNo" column="insurance_no"/>
- <result property="insuranceStatus" column="insurance_status"/>
- <result property="insuredNum" column="insured_num"/>
- <result property="insuranceEffectDate" column="insurance_effect_date"/>
- <result property="electronicPolicy" column="electronic_policy"/>
- </resultMap>
- <resultMap id="contractResultMap" type="com.yc.ship.module.trade.dal.dataobject.contract.ContractDO">
- <id property="id" column="contractId"/>
- <result property="orderId" column="id"/>
- <result property="contractNo" column="contract_no"/>
- <result property="status" column="status"/>
- <result property="touristsCount" column="tourists_count"/>
- <result property="contractUrl" column="contract_url"/>
- <result property="operateName" column="operate_name"/>
- <result property="signerName" column="signer_name"/>
- <result property="signerMobile" column="signer_mobile"/>
- <result property="signingTime" column="signing_time"/>
- <result property="signingUrl" column="signing_url"/>
- <result property="viewUrl" column="view_url"/>
- </resultMap>
- <resultMap id="RefundResultMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
- <id property="id" column="id"/>
- <result property="orderNo" column="order_no"/>
- <result property="sourceName" column="source_name"/>
- <result property="externalOrderNo" column="external_order_no"/>
- <result property="routePlanId" column="route_plan_id"/>
- <result property="visitorType" column="visitor_type"/>
- <result property="travelDate" column="travel_date"/>
- <result property="sellMethod" column="sell_method"/>
- <result property="sourceName" column="source_name"/>
- <result property="sellerId" column="seller_id"/>
- <result property="memberId" column="member_id"/>
- <result property="amount" column="amount"/>
- <result property="payAmount" column="pay_amount"/>
- <result property="orderStatus" column="order_status"/>
- <result property="paymentDate" column="payment_date"/>
- <result property="contactName" column="contact_name"/>
- <result property="credentialNo" column="credential_no"/>
- <result property="mobile" column="mobile"/>
- <result property="remark" column="remark"/>
- <collection property="tradeDetailList" resultMap="tradeDetailResultMap"/>
- </resultMap>
- <resultMap id="tradeDetailResultMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeDetailRespVO">
- <id property="orderId" column="id"/>
- <result property="id" column="detailId"/>
- <result property="voucherCode" column="voucher_code"/>
- <result property="voucherStatus" column="voucher_status"/>
- <result property="productName" column="product_name"/>
- <result property="specType" column="spec_type"/>
- <collection property="visitors" resultMap="visitorResultMap"/>
- </resultMap>
- <resultMap id="visitorResultMap" type="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
- <id property="detailId" column="detailId"/>
- <result property="id" column="visitorId"/>
- <result property="credentialNo" column="credential_no"/>
- <result property="credentialType" column="credential_type"/>
- <result property="name" column="name"/>
- </resultMap>
- <select id="getCategoryTreeList" resultType="com.yc.ship.module.product.api.dto.CategoryRespDTO">
- 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
- </select>
- <select id="getCategoryOTATreeList" resultType="com.yc.ship.module.product.api.dto.CategoryRespDTO">
- SELECT id,parent_id parentId,cate_name cateName,sort_num sortNum from product_category WHERE type = 1 AND use_status = 1 AND deleted = 0
- </select>
- <select id="getTradeOrderUserPage"
- resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
- SELECT td.*,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
- ,tr.refund_amount refundAmount,
- ps.product_tag productTag,ps.product_tag2 productTag2,ps.product_tag3 productTag3,ps.product_tag4 productTag4
- FROM trade_order td
- INNER JOIN trade_order_user tou on td.id = tou.order_id
- left JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
- left JOIN product_spu ps on ps.id = tdl.product_id
- LEFT JOIN ota_distributor od on od.id = td.source_id
- LEFT JOIN trade_order_audit toa on toa.order_id = td.id and toa.audit_status = 1
- 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
- LEFT JOIN trade_order_room_model torm on torm.order_id = td.id
- where td.deleted = 0 and tou.deleted = 0
- <if test="vo.orderStatus!=null and vo.orderStatus.size()>0">
- and td.order_status in
- <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.tenantId!=null">
- AND td.tenant_id = #{vo.tenantId}
- </if>
- <choose>
- <when test="vo.orderNo != null and vo.orderNo.length() == 4">
- AND td.order_no like concat('%',#{vo.orderNo})
- </when>
- <when test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="vo.externalOriginOrderNo != null and vo.externalOriginOrderNo != ''">
- AND td.external_origin_order_no = #{vo.externalOriginOrderNo}
- </if>
- <if test="vo.memberId != null and vo.memberId != ''">
- AND td.member_id = #{vo.memberId}
- </if>
- <if test="vo.voyageId != null and vo.voyageId != ''">
- AND td.voyage_id = #{vo.voyageId}
- </if>
- <if test="vo.shipId != null and vo.shipId != ''">
- AND td.ship_id = #{vo.shipId}
- </if>
- <if test="vo.routeId != null and vo.routeId != ''">
- AND exists (select 1 from product_voyage top where top.id = td.voyage_id and top.route_id = #{vo.routeId})
- </if>
- <if test="vo.dispatchStatus != null">
- AND td.dispatch_status = #{vo.dispatchStatus}
- </if>
- <if test="vo.payType != null">
- AND exists (select 1 from trade_order_pay top where top.order_id = td.id and top.payment_type = #{vo.payType})
- </if>
- <if test="vo.otaCateId != null and vo.otaCateId != ''">
- AND od.ota_category_id = #{vo.otaCateId}
- </if>
- <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
- and od.ota_category_id in
- <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.otaId != null and vo.otaId != ''">
- AND td.source_id = #{vo.otaId}
- </if>
- <if test="vo.storeId != null and vo.storeId != ''">
- AND td.store_id = #{vo.storeId}
- </if>
- <if test="vo.productTag != null and vo.productTag != ''">
- AND ps.product_tag = #{vo.productTag}
- </if>
- <if test="vo.productTag2 != null and vo.productTag2 != ''">
- AND ps.product_tag2 = #{vo.productTag2}
- </if>
- <if test="vo.productTag3 != null and vo.productTag3 != ''">
- AND ps.product_tag3 = #{vo.productTag3}
- </if>
- <if test="vo.productTag4 != null and vo.productTag4 != ''">
- AND ps.product_tag4 = #{vo.productTag4}
- </if>
- <if test="vo.cateIds!=null and vo.cateIds.size()>0 and (vo.planIds==null or vo.planIds.size()==0)">
- AND tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.externalOrderNo != null and vo.externalOrderNo != ''">
- AND td.external_order_no = #{vo.externalOrderNo}
- </if>
- <if test="vo.credentialNo != null and vo.credentialNo != ''">
- AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.credential_no = #{vo.credentialNo})
- </if>
- <if test="vo.userName != null and vo.userName != ''">
- AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.name = #{vo.userName})
- </if>
- <choose>
- <when test="vo.mobile != null and vo.mobile.length() == 4">
- AND tou.mobile like concat('%',#{vo.mobile})
- </when>
- <when test="vo.mobile != null and vo.mobile != ''">
- AND tou.mobile = #{vo.mobile}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="vo.contactName != null and vo.contactName != ''">
- AND tou.contact_name = #{vo.contactName}
- </if>
- <if test="vo.travelDate != null and vo.travelDate != ''">
- AND td.travel_date = #{vo.travelDate}
- </if>
- <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
- AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
- </if>
- <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
- AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
- </if>
- <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
- AND td.create_time <![CDATA[ >= ]]> #{vo.orderDateStart}
- </if>
- <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
- AND td.create_time <![CDATA[ <= ]]> #{vo.orderDateEnd}
- </if>
- <if test="vo.orderDate != null and vo.orderDate != ''">
- AND td.create_time = #{vo.orderDate}
- </if>
- <if test="vo.sellerId != null and vo.sellerId != ''">
- AND td.seller_id = #{vo.sellerId}
- </if>
- <if test="vo.shareName != null and vo.shareName != ''">
- AND td.share_name like concat('%',#{vo.shareName},'%')
- </if>
- <if test="vo.voucherCode != null and vo.voucherCode != ''">
- AND tdl.voucher_code = #{vo.voucherCode}
- </if>
- <if test="vo.sellMethod != null and vo.sellMethod != ''">
- AND td.sell_method = #{vo.sellMethod}
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND tdl.product_name like concat('%',#{vo.productName}, '%')
- </if>
- <if test="vo.isFullPay == 0">
- AND td.is_full_pay = #{vo.isFullPay}
- </if>
- <if test="vo.isComment != null">
- AND td.is_comment = #{vo.isComment}
- </if>
- <if test="vo.sourceId != null and vo.sourceId != ''">
- AND td.source_id = #{vo.sourceId}
- </if>
- <if test="vo.distributorId != null and vo.distributorId != ''">
- AND td.source_id = #{vo.distributorId}
- </if>
- <if test="vo.sourceName != null and vo.sourceName != ''">
- AND td.source_name like concat('%',#{vo.sourceName}, '%')
- </if>
- <if test="vo.travelStatus != null">
- AND td.travel_status = #{vo.travelStatus}
- </if>
- <if test="vo.roomModelId != null and vo.roomModelId != ''">
- AND torm.room_model_id = #{vo.roomModelId}
- </if>
- <if test="vo.floor != null and vo.floor != ''">
- AND torm.floor = #{vo.floor}
- </if>
- <if test="vo.orderRefundDateStart != null and vo.orderRefundDateEnd != ''">
- 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} )
- </if>
- GROUP BY td.id
- ORDER BY td.create_time DESC
- </select>
- <select id="getTradeOrderUserCount" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderCountRespVO">
- SELECT count(DISTINCT td.id) orderNum,sum(if(tdl.voucher_status in (1,2,3,4,6,8,9), quantity_of_one,0)) totalNum,
- sum(if(tdl.spec_type='full' and tdl.voucher_status in (1,2,3,4,6,8,9), quantity_of_one,0)) fullNum,
- sum(if(tdl.spec_type='half' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) halfNum,
- sum(if(tdl.spec_type='free' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) freeNum,
- sum(if(tdl.spec_type='common' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) commonNum,
- sum(if(tdl.spec_type='car_seat' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) carSeatNum,
- sum(if(tdl.spec_type='car_yd' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) carYdNum,
- sum(if(tdl.spec_type='other' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) otherNum,
- sum(if(tdl.spec_type='carrying_children' and tdl.voucher_status in (1,2,3,4,6,8,9),quantity_of_one,0)) carryingChildrenNum,
- sum(tdl.actual_price) totalPayAmount
- FROM trade_order td
- INNER JOIN trade_order_user tou on td.id = tou.order_id
- INNER JOIN trade_detail tdl on td.id = tdl.order_id
- INNER JOIN product_spu ps on ps.id = tdl.product_id
- LEFT JOIN ota_distributor od on od.id = td.source_id
- where 1= 1
- <if test="vo.orderStatus!=null and vo.orderStatus.size()>0">
- and td.order_status in
- <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.tenantId!=null">
- AND td.tenant_id = #{vo.tenantId}
- </if>
- <choose>
- <when test="vo.orderNo != null and vo.orderNo.length() == 4">
- AND td.order_no like concat('%',#{vo.orderNo})
- </when>
- <when test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="vo.externalOriginOrderNo != null and vo.externalOriginOrderNo != ''">
- AND td.external_origin_order_no = #{vo.externalOriginOrderNo}
- </if>
- <if test="vo.memberId != null and vo.memberId != ''">
- AND td.member_id = #{vo.memberId}
- </if>
- <if test="vo.productTag != null and vo.productTag != ''">
- AND ps.product_tag = #{vo.productTag}
- </if>
- <if test="vo.productTag2 != null and vo.productTag2 != ''">
- AND ps.product_tag2 = #{vo.productTag2}
- </if>
- <if test="vo.productTag3 != null and vo.productTag3 != ''">
- AND ps.product_tag3 = #{vo.productTag3}
- </if>
- <if test="vo.productTag4 != null and vo.productTag4 != ''">
- AND ps.product_tag4 = #{vo.productTag4}
- </if>
- <if test="vo.dispatchStatus != null">
- AND td.dispatch_status = #{vo.dispatchStatus}
- </if>
- <if test="vo.payType != null">
- AND exists (select 1 from trade_order_pay top where top.order_id = td.id and top.payment_type = #{vo.payType})
- </if>
- <if test="vo.otaCateId != null and vo.otaCateId != ''">
- AND od.ota_category_id = #{vo.otaCateId}
- </if>
- <if test="vo.planIds!=null and vo.planIds.size()>0 and vo.cateIds!=null and vo.cateIds.size()>0">
- AND (td.route_plan_id in
- <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- or tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- )
- </if>
- <if test="vo.cateIds!=null and vo.cateIds.size()>0 and (vo.planIds==null or vo.planIds.size()==0)">
- AND tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.planIds!=null and vo.planIds.size()>0 and (vo.cateIds==null or vo.cateIds.size()==0)">
- and td.route_plan_id in
- <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.otaId != null and vo.otaId != ''">
- AND td.source_id = #{vo.otaId}
- </if>
- <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
- and od.ota_category_id in
- <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.storeId != null and vo.storeId != ''">
- AND td.store_id = #{vo.storeId}
- </if>
- <if test="vo.externalOrderNo != null and vo.externalOrderNo != ''">
- AND td.external_order_no = #{vo.externalOrderNo}
- </if>
- <if test="vo.credentialNo != null and vo.credentialNo != ''">
- AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.credential_no = #{vo.credentialNo})
- </if>
- <if test="vo.userName != null and vo.userName != ''">
- AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.name = #{vo.userName})
- </if>
- <choose>
- <when test="vo.mobile != null and vo.mobile.length() == 4">
- AND tou.mobile like concat('%',#{vo.mobile})
- </when>
- <when test="vo.mobile != null and vo.mobile != ''">
- AND tou.mobile = #{vo.mobile}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="vo.contactName != null and vo.contactName != ''">
- AND tou.contact_name = #{vo.contactName}
- </if>
- <if test="vo.travelDate != null and vo.travelDate != ''">
- AND td.travel_date = #{vo.travelDate}
- </if>
- <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
- AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
- </if>
- <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
- AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
- </if>
- <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
- AND td.create_time <![CDATA[ >= ]]> #{vo.orderDateStart}
- </if>
- <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
- AND td.create_time <![CDATA[ <= ]]> #{vo.orderDateEnd}
- </if>
- <if test="vo.orderDate != null and vo.orderDate != ''">
- AND td.create_time = #{vo.orderDate}
- </if>
- <if test="vo.sellerId != null and vo.sellerId != ''">
- AND td.seller_id = #{vo.sellerId}
- </if>
- <if test="vo.shareName != null and vo.shareName != ''">
- AND td.share_name like concat('%',#{vo.shareName},'%')
- </if>
- <if test="vo.voucherCode != null and vo.voucherCode != ''">
- AND tdl.voucher_code = #{vo.voucherCode}
- </if>
- <if test="vo.sellMethod != null and vo.sellMethod != ''">
- AND td.sell_method = #{vo.sellMethod}
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND tdl.product_name like concat('%',#{vo.productName}, '%')
- </if>
- <if test="vo.isFullPay == 0">
- AND td.is_full_pay = #{vo.isFullPay}
- </if>
- <if test="vo.isComment != null">
- AND td.is_comment = #{vo.isComment}
- </if>
- <if test="vo.sourceId != null and vo.sourceId != ''">
- AND td.source_id = #{vo.sourceId}
- </if>
- <if test="vo.sourceName != null and vo.sourceName != ''">
- AND td.source_name like concat('%',#{vo.sourceName}, '%')
- </if>
- <if test="vo.travelStatus != null">
- AND td.travel_status = #{vo.travelStatus}
- </if>
- <if test="vo.orderRefundDateStart != null and vo.orderRefundDateEnd != ''">
- 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} )
- </if>
- </select>
- <select id="getPaidOrderPage"
- resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
- SELECT td.*, op.pay_amount payAmount, op.refund_amount refundAmount, op.pay_status paymentStatus, op.payment_type paymentType, op.payment_date paymentDate
- FROM trade_order td
- INNER JOIN trade_order_pay op on op.order_id = td.id
- where td.order_status <![CDATA[ >= ]]> 6 and td.order_status <![CDATA[ <= ]]> 11
- <if test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </if>
- <if test="vo.payType != null">
- AND op.payment_type = #{vo.payType}
- </if>
- <if test="vo.storeId != null and vo.storeId != ''">
- AND td.store_id = #{vo.storeId}
- </if>
- <if test="vo.travelDate != null and vo.travelDate != ''">
- AND td.travel_date = #{vo.travelDate}
- </if>
- <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
- AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
- </if>
- <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
- AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
- </if>
- <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
- AND op.payment_date <![CDATA[ >= ]]> #{vo.orderDateStart}
- </if>
- <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
- AND op.payment_date <![CDATA[ <= ]]> #{vo.orderDateEnd}
- </if>
- <if test="vo.orderDate != null and vo.orderDate != ''">
- AND td.create_time = #{vo.orderDate}
- </if>
- <if test="vo.sellerId != null and vo.sellerId != ''">
- AND td.seller_id = #{vo.sellerId}
- </if>
- <if test="vo.sellMethod != null and vo.sellMethod != ''">
- AND td.sell_method = #{vo.sellMethod}
- </if>
- ORDER BY td.create_time DESC
- </select>
- <select id="getRefundDetailPage"
- resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeDetailRespVO">
- SELECT td.*,tv.credential_no,tv.`name`,tv.mobile,tor.order_no
- FROM trade_detail td
- INNER JOIN trade_visitor tv on tv.detail_id = td.id
- LEFT JOIN trade_order tor on tor.id = td.order_id
- where 1= 1
- <if test="vo.name != null and vo.name != ''">
- AND tv.name = #{vo.name}
- </if>
- <if test="vo.orderNo != null and vo.orderNo != ''">
- AND tor.order_no = #{vo.orderNo}
- </if>
- <if test="vo.credentialNo != null and vo.credentialNo != ''">
- AND tv.credential_no = #{vo.credentialNo}
- </if>
- <if test="vo.mobile != null and vo.mobile != ''">
- AND tv.mobile = #{vo.mobile}
- </if>
- <if test="vo.orderStatus != null and vo.orderStatus != ''">
- AND tor.order_status = #{vo.orderStatus}
- </if>
- </select>
- <select id="getRefundRecordPage"
- resultType="com.yc.ship.module.trade.controller.admin.order.vo.refund.RefundRespVO">
- SELECT tr.*,td.order_no, ou.mobile,td.travel_date, ou.contact_name ,tdl.product_name
- FROM trade_refund tr
- INNER JOIN trade_order td on tr.order_id = td.id
- inner join product_voyage pv on td.voyage_id = pv.id
- inner join trade_order_user ou on ou.order_id = td.id
- INNER JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
- LEFT JOIN ota_distributor od on od.id = td.source_id
- where 1= 1
- <if test="vo.shipId != null and vo.shipId != ''">
- AND td.ship_id = #{vo.shipId}
- </if>
- <if test="vo.voyageId != null and vo.voyageId != ''">
- AND td.voyage_id = #{vo.voyageId}
- </if>
- <if test="vo.routeId != null and vo.routeId != ''">
- AND pv.route_id = #{vo.routeId}
- </if>
- <if test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </if>
- <if test="vo.refundStatus!=null and vo.refundStatus.size()>0">
- and tr.refund_status in
- <foreach collection="vo.refundStatus" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.refundMethod != null and vo.refundMethod != ''">
- AND tr.refund_method = #{vo.refundMethod}
- </if>
- <if test="vo.refundUserId!=null and vo.refundUserId.size()>0">
- and tr.refund_user in
- <foreach collection="vo.refundUserId" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.refundChannel != null">
- AND tr.refund_channel = #{vo.refundChannel}
- </if>
- <if test="vo.mobile != null and vo.mobile != ''">
- AND ou.mobile = #{vo.mobile}
- </if>
- <if test="vo.sourceId != null and vo.sourceId != ''">
- AND td.source_id = #{vo.sourceId}
- </if>
- <if test="vo.travelDate != null and vo.travelDate != ''">
- AND td.travel_date = #{vo.travelDate}
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND tdl.product_name like concat('%',#{vo.productName}, '%')
- </if>
- <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
- AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
- </if>
- <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
- AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
- </if>
- <if test="vo.refundTime != null and vo.refundTime != ''">
- AND tr.refund_time = #{vo.refundTime}
- </if>
- <if test="vo.refundTimeStart != null and vo.refundTimeStart != ''">
- AND tr.refund_time <![CDATA[ >= ]]> #{vo.refundTimeStart}
- </if>
- <if test="vo.refundTimeEnd != null and vo.refundTimeEnd != ''">
- AND tr.refund_time <![CDATA[ <= ]]> #{vo.refundTimeEnd}
- </if>
- <if test="vo.otaId != null and vo.otaId != ''">
- AND td.source_id = #{vo.otaId}
- </if>
- <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
- and od.ota_category_id in
- <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.cateIds!=null and vo.cateIds.size()>0 and vo.planIds==null">
- AND tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.planIds!=null and vo.planIds.size()>0 and (vo.cateIds==null or vo.cateIds.size()==0)">
- and td.route_plan_id in
- <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by tr.id
- ORDER BY tr.create_time DESC
- </select>
- <select id="getOrderInfo" resultMap="MiddleWareDtoResultMap">
- 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,
- tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,tou.county,tou.province,tou.city,td.agency_group_id,
- top.id payId,top.pay_amount payAmount,top.pay_status,top.payment_type,top.payment_date,top.payment_no,
- td.store_name,td.is_invoice, td.confirm_type, td.travel_status, tr.refund_amount,td.finish_status,
- 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,
- 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
- FROM trade_order td
- INNER JOIN trade_order_user tou on td.id = tou.order_id
- left JOIN trade_order_pay top on td.id = top.order_id AND top.pay_status = 1 and top.deleted = 0
- left JOIN trade_insurance ti on td.id = ti.order_id
- left JOIN trade_contract tc on td.id = tc.order_id
- LEFT JOIN (select m2.order_id,sum(m1.refund_amount) refund_amount from trade_refund_detail m1
- 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
- where 1= 1
- AND td.id = #{id}
- </select>
- <select id="getPdaOrderInfo" resultMap="MiddleWareDtoResultMap2">
- SELECT td.id,td.is_read isRead,td.pay_amount,td.order_no,td.external_order_no,td.external_origin_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,
- tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,tou.county,tou.province,tou.city,td.is_change_order,td.agency_group_id,
- top.id payId,top.pay_amount payAmount,top.pay_status,top.payment_type,top.payment_date,top.payment_no,
- td.store_name,td.dispatch_status,td.is_invoice, td.confirm_type, td.travel_status, tr.refund_amount,td.finish_status,
- 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,
- 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
- FROM trade_order td
- INNER JOIN trade_order_user tou on td.id = tou.order_id
- left JOIN trade_order_pay top on td.id = top.order_id AND top.pay_status = 1 and top.deleted = 0
- left JOIN trade_insurance ti on td.id = ti.order_id
- left JOIN trade_contract tc on td.id = tc.order_id
- left JOIN product_route_plan rt on rt.id = td.route_plan_id
- LEFT JOIN (select m2.order_id,sum(m1.refund_amount) refund_amount from trade_refund_detail m1
- 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
- where 1= 1
- AND td.id = #{id}
- </select>
- <select id="getMarketingApplyOrderPage" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
- 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,
- tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,
- 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
- FROM
- product_marketing_audit pma
- INNER JOIN trade_order td on pma.order_id = td.id
- inner join trade_detail ttd on td.id = ttd.order_id
- INNER JOIN trade_order_user tou ON td.id = tou.order_id
- LEFT JOIN product_marketing pmk ON pmk.id = pma.marketing_id
- WHERE 1 = 1 AND td.order_status != 11 and
- pma.travel_id in (SELECT DISTINCT travel_id FROM product_marketing_pm WHERE user_id = #{vo.userId} and deleted = 0)
- <if test="vo.ids.size()>0">
- and pma.travel_id in
- <foreach collection="vo.ids" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </if>
- <if test="vo.policyType != null and vo.policyType != ''">
- AND pmk.policy_type = #{vo.policyType}
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND ttd.product_name like concat('%',#{vo.productName}, '%')
- </if>
- <if test="vo.marketingName != null and vo.marketingName != ''">
- AND pmk.name like concat('%',#{vo.marketingName}, '%')
- </if>
- <if test="vo.isExecute != null and vo.isExecute != ''">
- AND pma.is_execute = #{vo.isExecute}
- </if>
- <if test="vo.distributorId != null and vo.distributorId != ''">
- AND pma.agency_id = #{vo.distributorId}
- </if>
- <if test="vo.storeId != null and vo.storeId != ''">
- AND pma.store_id = #{vo.storeId}
- </if>
- <if test="vo.orderStartTime != null and vo.orderStartTime != ''">
- AND td.travel_date <![CDATA[ >= ]]> #{vo.orderStartTime}
- </if>
- <if test="vo.orderEndTime != null and vo.orderEndTime != ''">
- AND td.travel_date <![CDATA[ <= ]]> #{vo.orderEndTime}
- </if>
- <if test="vo.auditState != null ">
- AND pma.audit_state = #{vo.auditState}
- </if>
- GROUP BY pma.id,td.id
- order by pma.create_time desc
- </select>
- <select id="getStoresMarketingOrderPage" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeMarketOrderRespVO">
- 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,
- tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,
- 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
- FROM
- product_marketing_audit pma
- INNER JOIN trade_order td on pma.order_id = td.id
- INNER JOIN trade_detail tdl on td.id = tdl.order_id
- INNER JOIN trade_order_user tou ON td.id = tou.order_id
- LEFT JOIN product_marketing_pool_spu pms on td.id = pms.order_id
- LEFT JOIN product_marketing pmk ON pmk.id = pma.marketing_id
- WHERE 1 = 1
- <if test="vo.storeId != null">
- and pma.store_id = #{vo.storeId}
- </if>
- <if test="vo.distributorId != null">
- and td.source_id = #{vo.distributorId}
- </if>
- <if test="vo.ids.size()>0">
- and pma.travel_id in
- <foreach collection="vo.ids" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.isExecute != null">
- and pma.is_execute = #{vo.isExecute}
- </if>
- <if test="vo.policyType != null and vo.policyType != ''">
- AND pmk.policy_type = #{vo.policyType}
- </if>
- <if test="vo.marketingName != null and vo.marketingName != ''">
- AND pmk.name like concat('%',#{vo.marketingName}, '%')
- </if>
- <if test="vo.auditState != null">
- and pma.audit_state = #{vo.auditState}
- </if>
- <if test="vo.useAuditState != null">
- and pma.use_audit_state = #{vo.useAuditState}
- </if>
- <if test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </if>
- <if test="vo.travelDate != null and vo.travelDate != ''">
- AND td.travel_date = #{vo.travelDate}
- </if>
- <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
- AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
- </if>
- <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
- AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND tdl.product_name like concat('%',#{vo.productName}, '%')
- </if>
- GROUP BY pma.id
- order by pma.create_time desc
- </select>
- <select id="getStoresMarketingOrderDesc" resultType="java.util.Map">
- 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,
- tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,
- 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
- FROM
- product_marketing_audit pma
- INNER JOIN trade_order td on pma.order_id = td.id
- INNER JOIN trade_detail tdl on td.id = tdl.order_id
- INNER JOIN trade_order_user tou ON td.id = tou.order_id
- LEFT JOIN product_marketing pmk ON pmk.id = pma.marketing_id
- WHERE 1 = 1
- <if test="vo.storeId != null">
- and pma.store_id = #{vo.storeId}
- </if>
- <if test="vo.ids.size()>0">
- and pma.travel_id in
- <foreach collection="vo.ids" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.isExecute != null">
- and pma.is_execute = #{vo.isExecute}
- </if>
- <if test="vo.policyType != null and vo.policyType != ''">
- AND pmk.policy_type = #{vo.policyType}
- </if>
- <if test="vo.marketingName != null and vo.marketingName != ''">
- AND pmk.name like concat('%',#{vo.marketingName}, '%')
- </if>
- <if test="vo.auditState != null">
- and pma.audit_state = #{vo.auditState}
- </if>
- <if test="vo.useAuditState != null">
- and pma.use_audit_state = #{vo.useAuditState}
- </if>
- <if test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </if>
- <if test="vo.travelDate != null and vo.travelDate != ''">
- AND td.travel_date = #{vo.travelDate}
- </if>
- <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
- AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
- </if>
- <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
- AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND tdl.product_name like concat('%',#{vo.productName}, '%')
- </if>
- GROUP BY pma.id
- order by pma.create_time desc
- </select>
- <select id="selectBindMarketing" resultType="java.lang.Long">
- SELECT tob.bind_id
- FROM
- trade_order_bind tob
- WHERE
- tob.type = 7 AND tob.deleted = 0 AND tob.order_id = #{orderId}
- </select>
- <select id="selectBindUseMarketing" resultType="java.lang.Long">
- SELECT tob.bind_id
- FROM
- trade_order_bind tob
- WHERE
- tob.type = 8 AND tob.deleted = 0 AND tob.order_id = #{orderId}
- </select>
- <select id="selectOrderIdByOrderNo" resultType="java.lang.Long">
- SELECT id FROM trade_order WHERE order_no = #{orderNo}
- </select>
- <select id="getRefundOrderInfo" resultMap="RefundResultMap">
- 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,
- tou.contact_name contactName,tou.credential_no credentialNo,tou.mobile,
- tdl.id detailId,tdl.voucher_code,tdl.voucher_status,tdl.product_name,tdl.spec_type,
- tv.id visitorId,tv.credential_no,tv.credential_type,tv.`name`
- FROM trade_order td
- INNER JOIN trade_order_user tou on td.id = tou.order_id
- INNER JOIN trade_detail tdl on td.id = tdl.order_id
- INNER JOIN trade_visitor tv on tdl.id = tv.detail_id
- where 1= 1
- <if test="id != null and id != ''">
- AND td.id = #{id}
- </if>
- </select>
- <select id="getTradeOrderByExpire" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- select * from trade_order where order_status =14 and travel_date <![CDATA[ <= ]]> #{expiretime}
- </select>
- <select id="getPageRefundRecord"
- resultType="com.yc.ship.module.trade.controller.admin.order.vo.refund.RefundRecordRespVO">
- SELECT trr.*,td.order_no, td.id orderId, td.travel_date
- FROM trade_refund_record trr
- left join trade_order_pay top on trr.order_pay_id = top.id
- left join trade_refund tr on trr.refund_id = tr.id
- left join trade_order td on td.id = top.order_id
- left join product_voyage pv on td.voyage_id = pv.id
- LEFT JOIN ota_distributor od on od.id = td.source_id
- where 1= 1
- <if test="vo.shipId != null and vo.shipId != ''">
- AND td.ship_id = #{vo.shipId}
- </if>
- <if test="vo.voyageId != null and vo.voyageId != ''">
- AND td.voyage_id = #{vo.voyageId}
- </if>
- <if test="vo.routeId != null and vo.routeId != ''">
- AND pv.route_id = #{vo.routeId}
- </if>
- <if test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </if>
- <if test="vo.refundNo != null and vo.refundNo != ''">
- AND trr.refund_no = #{vo.refundNo}
- </if>
- <if test="vo.paymentNo != null and vo.paymentNo != ''">
- AND trr.payment_no = #{vo.paymentNo}
- </if>
- <if test="vo.refundStatus != null and vo.refundStatus != ''">
- AND trr.refund_status = #{vo.refundStatus}
- </if>
- <if test="vo.refundId != null and vo.refundId != ''">
- AND trr.refund_id = #{vo.refundId}
- </if>
- <if test="vo.openId != null and vo.openId != ''">
- AND trr.openId = #{vo.openId}
- </if>
- <if test="vo.otaId != null and vo.otaId != ''">
- AND td.source_id = #{vo.otaId}
- </if>
- <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
- and od.ota_category_id in
- <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.sourceId != null and vo.sourceId != ''">
- AND td.source_id = #{vo.sourceId}
- </if>
- <if test="vo.travelDate != null and vo.travelDate != ''">
- AND td.travel_date = #{vo.travelDate}
- </if>
- <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
- AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
- </if>
- <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
- AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
- </if>
- <if test="vo.refundTime != null and vo.refundTime != ''">
- AND trr.refund_time = #{vo.refundTime}
- </if>
- <if test="vo.refundTimeStart != null and vo.refundTimeStart != ''">
- AND trr.refund_time <![CDATA[ >= ]]> #{vo.refundTimeStart}
- </if>
- <if test="vo.refundTimeEnd != null and vo.refundTimeEnd != ''">
- AND trr.refund_time <![CDATA[ <= ]]> #{vo.refundTimeEnd}
- </if>
- ORDER BY trr.create_time DESC
- </select>
- <select id="getPrintTemp"
- resultType="com.yc.ship.module.trade.controller.admin.order.vo.otc.PrintRespVO">
- SELECT pt.* FROM print_temp pt where pt.template_code = #{printTemp}
- </select>
- <select id="queryCanInvoicedOrderPage"
- resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
- SELECT
- o.order_no,
- o.travel_date,
- o.order_status,
- o.amount,
- o.create_time,
- o.external_order_no,
- o.id,
- o.is_invoice,
- o.item_id,
- o.payment_date,
- o.remark,
- o.seller_id,
- o.sell_method,
- o.share_name,
- o.source_id,
- o.source_name,
- o.store_id,
- o.store_name,
- o.visitor_type,
- tou.contact_name,
- tou.credential_no,
- tou.mobile,
- td.product_name,
- count(
- DISTINCT
- CASE
- WHEN (
- td.voucher_status in (3,6,7,8)
- OR ( td.voucher_status = 9 AND td.check_status = 1 )
- ) THEN
- td.id ELSE null
- END
- ) AS num,
- o.pay_amount - SUM( ifnull(trd.refund_amount,0) ) - SUM(
- CASE
- WHEN ( td.voucher_status in (1,2) )
- AND DATE_FORMAT( td.validity_end_date, '%Y-%c-%d' ) >= DATE_FORMAT( NOW( ), '%Y-%c-%d' ) THEN
- td.actual_price ELSE 0
- END
- ) AS pay_amount
- FROM
- trade_order o
- INNER JOIN trade_detail td ON td.order_id = o.id
- LEFT JOIN trade_refund_detail trd ON trd.trade_detail_id = td.id
- AND trd.refund_status = 6
- INNER JOIN trade_order_user tou ON o.id = tou.order_id
- LEFT JOIN trade_invoice_detail i ON i.order_no = o.order_no
- LEFT JOIN trade_invoice ii ON i.invoice_id = ii.id AND ii.invoice_status IN (1,3)
- LEFT JOIN (select order_id,payment_type from trade_order_pay where pay_status=1 GROUP BY order_id) op ON op.order_id = o.id
- LEFT JOIN ota_bill_order obo ON obo.order_id = o.id
- LEFT JOIN ota_bill_store obs ON obs.id = obo.bill_store_id AND obs.bill_status=1
- where td.use_date >= DATE_SUB(NOW(), INTERVAL #{canInvoicedDay} DAY)
- and o.is_invoice in (0,2)
- and o.order_status in (6,7,8,9,11,12)
- <if test="vo.orderNo != null and vo.orderNo != ''">
- AND o.order_no = #{vo.orderNo}
- </if>
- <if test="vo.sourceId != null and vo.sourceId != ''">
- AND o.source_id = #{vo.sourceId}
- </if>
- <if test="vo.storeId != null and vo.storeId != ''">
- AND o.store_id = #{vo.storeId}
- </if>
- <if test="vo.credentialNo != null and vo.credentialNo != ''">
- AND tou.credential_no = #{vo.credentialNo}
- </if>
- <if test="vo.mobile != null and vo.mobile != ''">
- AND tou.mobile = #{vo.mobile}
- </if>
- <if test="vo.contactName != null and vo.contactName != ''">
- AND tou.contact_name = #{vo.contactName}
- </if>
- <if test="vo.travelDate != null and vo.travelDate != ''">
- AND o.travel_date = #{vo.travelDate}
- </if>
- <if test="vo.sellerId != null and vo.sellerId != ''">
- AND o.seller_id = #{vo.sellerId}
- </if>
- <if test="vo.voucherCode != null and vo.voucherCode != ''">
- AND td.voucher_code = #{vo.voucherCode}
- </if>
- <if test="vo.sellMethod != null and vo.sellMethod != ''">
- AND o.sell_method = #{vo.sellMethod}
- </if>
- <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
- AND td.use_date <![CDATA[ >= ]]> #{vo.travelDateStart}
- </if>
- <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
- AND td.use_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
- </if>
- <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
- AND o.payment_date <![CDATA[ >= ]]> #{vo.orderDateStart}
- </if>
- <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
- AND o.payment_date <![CDATA[ <= ]]> #{vo.orderDateEnd}
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND td.product_name like concat('%',#{vo.productName}, '%')
- </if>
- AND ii.id IS NULL
- AND (op.payment_type != 6 OR (o.is_bill=2 AND obs.id IS NOT NULL))
- AND date_format(NOW(), '%Y-%m-%d') > date_format(o.travel_date, '%Y-%m-%d')
- GROUP BY
- o.order_no
- HAVING
- SUM(CASE WHEN td.voucher_status IN (1,2) AND td.validity_end_date >= CURDATE() THEN 1 ELSE 0 END) = 0
- AND pay_amount > 0
- ORDER BY
- o.travel_date DESC
- </select>
- <select id="getOrderByVoucherCode"
- resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- SELECT o.* FROM trade_order o
- inner join trade_detail d on d.order_id = o.id
- where (o.order_status = 6 or o.order_status = 7) and d.voucher_code = #{voucherCode} limit 1
- </select>
- <select id="getOrderByExternalOrderNo" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- 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
- </select>
- <select id="getOtcOrderByExternalOrderNo" resultType="java.util.Map">
- 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
- </select>
- <select id="getTradeOrderByVoucherCode" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- SELECT o.* FROM trade_order o inner join trade_detail d on d.order_id = o.id where d.voucher_code = #{voucherCode} limit 1
- </select>
- <select id="getOrderByCardNo"
- resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- SELECT
- o.*
- FROM
- trade_order o
- INNER JOIN trade_detail d ON d.order_id = o.id
- INNER JOIN trade_visitor v ON v.detail_id = d.id
- WHERE
- o.travel_date >= CURDATE()
- and d.voucher_status in (1,2,3,4,8,9)
- and v.credential_no = #{cardNo}
- </select>
- <select id="getOrderByDetailBase"
- resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- SELECT o.* FROM trade_order o
- inner join trade_detail d on d.order_id = o.id
- inner join trade_detail_base tdb on tdb.detail_id = d.id
- where (o.order_status = 6 or o.order_status = 7) and tdb.id = #{baseId} limit 1
- </select>
- <select id="getAccountOrderPage"
- resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
- SELECT td.*,tou.contact_name,tou.credential_no,tou.mobile,COUNT(tdl.id) num,tdl.product_name,tdl.spec_type
- FROM trade_order td
- INNER JOIN trade_order_user tou on td.id = tou.order_id
- INNER JOIN trade_detail tdl on td.id = tdl.order_id
- where 1= 1 AND td.order_status NOT IN (-2, -1, 0, 1, 2, 12) AND td.is_account = 0
- <if test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </if>
- <if test="vo.contactName != null and vo.contactName != ''">
- AND tou.contact_name = #{vo.contactName}
- </if>
- <if test="vo.travelDate != null and vo.travelDate != ''">
- AND td.travel_date = #{vo.travelDate}
- </if>
- GROUP BY td.id
- ORDER BY td.create_time DESC
- </select>
- <update id="updateOrderStatus">
- UPDATE trade_order SET order_status = #{orderStatus} WHERE id = #{orderId} and order_status != #{orderStatus}
- </update>
- <update id="updateOrderIsAccount">
- UPDATE trade_order SET is_account = #{isAccount} WHERE id = #{orderId}
- </update>
- <update id="updateOrderDeleted">
- UPDATE trade_order SET deleted = #{deleted},update_time = now() WHERE id = #{orderId}
- </update>
- <resultMap id="OrderAndDetailResultMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderPdaRespVO">
- <id property="id" column="id"/>
- <result property="orderNo" column="order_no"/>
- <result property="sourceName" column="source_name"/>
- <result property="externalOrderNo" column="external_order_no"/>
- <result property="routePlanId" column="route_plan_id"/>
- <result property="visitorType" column="visitor_type"/>
- <result property="travelDate" column="travel_date"/>
- <result property="sellMethod" column="sell_method"/>
- <result property="sourceName" column="source_name"/>
- <result property="sellerId" column="seller_id"/>
- <result property="memberId" column="member_id"/>
- <result property="amount" column="amount"/>
- <result property="payAmount" column="pay_amount"/>
- <result property="orderStatus" column="order_status"/>
- <result property="paymentDate" column="payment_date"/>
- <result property="contactName" column="contact_name"/>
- <result property="credentialNo" column="credential_no"/>
- <result property="mobile" column="mobile"/>
- <result property="remark" column="remark"/>
- <collection property="tradeDetailList" resultMap="tradeDetailMap"/>
- </resultMap>
- <resultMap id="tradeDetailMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeDetailRespVO">
- <result property="id" column="detailId"/>
- <result property="orderId" column="order_id"/>
- <result property="voucherCode" column="voucher_code"/>
- <result property="voucherStatus" column="voucher_status"/>
- <result property="useDate" column="use_date"/>
- <result property="validityStartDate" column="validity_start_date"/>
- <result property="validityEndDate" column="validity_end_date"/>
- <result property="usageDays" column="usage_days"/>
- <result property="checkStatus" column="check_status"/>
- <result property="takeStatus" column="take_status"/>
- <result property="refundStatus" column="refund_status"/>
- <result property="verifyTime" column="verify_time"/>
- <result property="activateStatus" column="activate_status"/>
- <result property="activateDays" column="activate_days"/>
- <result property="activateTime" column="activate_time"/>
- <result property="productId" column="product_id"/>
- <result property="productName" column="product_name"/>
- <result property="specType" column="spec_type"/>
- <collection property="detailBaseList" resultMap="tradeDetailBaseResMap"/>
- </resultMap>
- <resultMap id="tradeDetailBaseResMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.DetailBaseRespVO">
- <result property="id" column="detail_base_id"/>
- <result property="detailId" column="detailId"/>
- <result property="productBaseId" column="product_base_id"/>
- <result property="productBaseName" column="product_base_name"/>
- <result property="productBaseType" column="product_base_type"/>
- <result property="productResourceId" column="product_resource_id"/>
- <result property="productResourceName" column="product_resource_name"/>
- <result property="supplierProductId" column="supplier_product_id"/>
- <result property="supplierId" column="supplier_id"/>
- <result property="supplierName" column="supplier_name"/>
- <result property="isSystemDirect" column="is_system_direct"/>
- <result property="useStatus" column="use_status"/>
- <result property="checkStatus" column="base_check_status"/>
- <result property="verifyTime" column="base_verify_time"/>
- <result property="price" column="base_price"/>
- <result property="usageCount" column="usage_count"/>
- <result property="productResourcePrice" column="product_resource_price"/>
- <result property="projectId" column="project_id"/>
- <result property="projectName" column="project_name"/>
- <result property="specificationId" column="specification_id"/>
- <result property="specificationName" column="specification_name"/>
- <result property="specType" column="base_spec_type"/>
- <result property="supplierVoucherCode" column="supplier_voucher_code"/>
- <result property="platSupplierOrderId" column="plat_supplier_order_id"/>
- </resultMap>
- <select id="getOrderAndDetailInfo" resultMap="OrderAndDetailResultMap">
- 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,
- tou.contact_name,tou.credential_no,tou.mobile,
- tdl.id detailId,tdl.voucher_code,tdl.voucher_status,tdl.product_name,tdl.spec_type,tdl.validity_start_date,tdl.validity_end_date,
- 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,
- 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,
- tdb.specification_id,tdb.specification_name,tdb.spec_type base_spec_type,tdb.supplier_voucher_code,tdb.plat_supplier_order_id
- FROM trade_order td
- INNER JOIN trade_order_user tou on td.id = tou.order_id and td.deleted = 0
- INNER JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
- INNER JOIN trade_visitor tv on tv.detail_id = tdl.id and tv.deleted = 0
- inner join trade_detail_base tdb on tdl.id = tdb.detail_id
- where 1= 1 and td.order_status >= 6 and td.order_status <![CDATA[ <= ]]> 9
- and td.sell_method != 3 and td.sell_method != 4
- and tdl.validity_start_date <![CDATA[ <= ]]> NOW()
- and tdl.validity_end_date <![CDATA[ >= ]]> NOW()
- <if test="channelId != null and channelId != ''">
- and tdb.product_base_id in (select product_id from product_check_channel where channel_id=#{channelId} and deleted = 0)
- </if>
- <if test="orderNo != null and orderNo != ''">
- AND td.order_no = #{orderNo}
- </if>
- <choose>
- <when test="phone != null and phone.length() == 4">
- AND tou.mobile like concat('%',#{phone})
- </when>
- <when test="phone != null and phone != ''">
- AND tou.mobile = #{phone}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <choose>
- <when test="cardNo != null and cardNo.length() == 4">
- AND tv.credential_no like concat('%',#{cardNo})
- </when>
- <when test="cardNo != null and cardNo != ''">
- AND tv.credential_no = #{cardNo}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- ORDER BY td.travel_date DESC
- </select>
- <select id="getPlatOrderNo" resultType="java.lang.String">
- select t3.order_no from trade_order t1
- inner join trade_supplier_order t2 on t1.id = t2.order_id
- inner join trade_order t3 on t2.trade_no = t3.external_order_no
- where t1.order_no = #{orderNo}
- </select>
- <select id="getTotalPayByOrderNo" resultType="java.math.BigDecimal">
- select sum(t2.pay_amount) from trade_order t1 inner join trade_order_pay t2 on t1.id = t2.order_id
- where t1.order_no = #{orderNo} and t2.pay_status = 1
- </select>
- <select id="getCheckOrder" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
- 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,
- 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, tou.contact_name,tou.credential_no,tou.mobile,td.is_add_order
- FROM trade_order td
- INNER JOIN trade_order_user tou on td.id = tou.order_id and td.deleted = 0
- INNER JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
- left join product_route_plan plan on td.route_plan_id = plan.id
- <if test="vo.type != null and vo.dispatchId == null and vo.type == 'boat'">
- left join dispatch_operate_plan_boat_order_detail_base dopbodb on td.id = dopbodb.order_id and dopbodb.deleted = 0
- </if>
- <if test="vo.type != null and vo.dispatchId == null and vo.type == 'car'">
- left join dispatch_car_dispatch_order_detail_base dcdodb on td.id = dcdodb.order_id and dcdodb.deleted = 0
- </if>
- <if test="vo.credentialNo != null and vo.credentialNo != ''">
- INNER JOIN trade_visitor tv on tv.detail_id = tdl.id and tv.deleted = 0
- </if>
- where 1=1
- <choose>
- <when test="vo.orderStatus != null">
- AND td.order_status = #{vo.orderStatus}
- </when>
- <otherwise>
- and td.order_status in (6,7,8,9,10,13)
- </otherwise>
- </choose>
- <choose>
- <when test="vo.travelDate != null and vo.travelDate != ''">
- AND DATE_FORMAT(tdl.validity_start_date, '%Y-%m-%d') <![CDATA[ <= ]]> #{vo.travelDate}
- AND DATE_FORMAT(tdl.validity_end_date, '%Y-%m-%d') <![CDATA[ >= ]]> #{vo.travelDate}
- </when>
- <otherwise>
- and tdl.validity_start_date <![CDATA[ <= ]]> NOW()
- and tdl.validity_end_date <![CDATA[ >= ]]> NOW()
- </otherwise>
- </choose>
- <choose>
- <when test="vo.orderNo != null and vo.orderNo.length() == 4">
- AND td.order_no like concat('%',#{vo.orderNo})
- </when>
- <when test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <choose>
- <when test="vo.phone != null and vo.phone.length() == 4">
- AND tou.mobile like concat('%',#{vo.phone})
- </when>
- <when test="vo.phone != null and vo.phone != ''">
- AND tou.mobile = #{vo.phone}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <choose>
- <when test="vo.credentialNo != null and vo.credentialNo.length() == 4">
- AND tv.credential_no like concat('%',#{vo.credentialNo})
- </when>
- <when test="vo.credentialNo != null and vo.credentialNo != ''">
- AND tv.credential_no = #{vo.credentialNo}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="vo.type != null and vo.dispatchId != null and vo.type == 'boat'">
- AND td.id in (SELECT DISTINCT order_id FROM dispatch_operate_plan_boat_order_detail_base
- WHERE plan_id = #{vo.dispatchId} and deleted = 0)
- </if>
- <if test="vo.type != null and vo.dispatchId != null and vo.type == 'car'">
- AND td.id in (SELECT DISTINCT order_id FROM dispatch_car_dispatch_order_detail_base
- WHERE car_dispatch_id = #{vo.dispatchId} and deleted = 0)
- </if>
- <if test="vo.travelStatus != null">
- AND td.travel_status = #{vo.travelStatus}
- </if>
- <if test="vo.voucherCode != null and vo.voucherCode != ''">
- AND tdl.voucher_code = #{vo.voucherCode}
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND tdl.product_name like concat('%',#{vo.productName}, '%')
- </if>
- <if test="vo.sellMethod != null">
- AND td.sell_method = #{vo.sellMethod}
- </if>
- <if test="vo.planIds!=null and vo.planIds.size()>0 and vo.cateIds!=null and vo.cateIds.size()>0">
- AND (td.route_plan_id in
- <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- or tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- )
- </if>
- <if test="vo.cateIds!=null and vo.cateIds.size()>0 and vo.planIds==null">
- AND tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.planIds!=null and vo.planIds.size()>0 and (vo.cateIds==null or vo.cateIds.size()==0)">
- and td.route_plan_id in
- <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by td.id
- ORDER BY td.create_time DESC
- </select>
- <select id="countCheckOrder" resultType="java.lang.Integer">
- SELECT count(DISTINCT td.id) num FROM trade_order td
- INNER JOIN trade_detail tdl ON td.id = tdl.order_id
- INNER JOIN trade_order_user tou ON td.id = tou.order_id
- <if test="vo.credentialNo != null and vo.credentialNo != ''">
- INNER JOIN trade_visitor tv on tv.detail_id = tdl.id and tv.deleted = 0
- </if>
- where 1=1
- <choose>
- <when test="vo.orderStatus != null">
- AND td.order_status = #{vo.orderStatus}
- </when>
- <otherwise>
- and td.order_status in (6,7,8,9,10,13)
- </otherwise>
- </choose>
- <choose>
- <when test="vo.travelDate != null and vo.travelDate != ''">
- AND DATE_FORMAT(tdl.validity_start_date, '%Y-%m-%d') <![CDATA[ <= ]]> #{vo.travelDate}
- AND DATE_FORMAT(tdl.validity_end_date, '%Y-%m-%d') <![CDATA[ >= ]]> #{vo.travelDate}
- </when>
- <otherwise>
- and tdl.validity_start_date <![CDATA[ <= ]]> NOW()
- and tdl.validity_end_date <![CDATA[ >= ]]> NOW()
- </otherwise>
- </choose>
- <choose>
- <when test="vo.orderNo != null and vo.orderNo.length() == 4">
- AND td.order_no like concat('%',#{vo.orderNo})
- </when>
- <when test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <choose>
- <when test="vo.phone != null and vo.phone.length() == 4">
- AND tou.mobile like concat('%',#{vo.phone})
- </when>
- <when test="vo.phone != null and vo.phone != ''">
- AND tou.mobile = #{vo.phone}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <choose>
- <when test="vo.credentialNo != null and vo.credentialNo.length() == 4">
- AND tv.credential_no like concat('%',#{vo.credentialNo})
- </when>
- <when test="vo.credentialNo != null and vo.credentialNo != ''">
- AND tv.credential_no = #{vo.credentialNo}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="vo.type != null and vo.dispatchId != null and vo.type == 'boat'">
- AND td.id in (SELECT DISTINCT order_id FROM dispatch_operate_plan_boat_order_detail_base
- WHERE plan_id = #{vo.dispatchId} and deleted = 0)
- </if>
- <if test="vo.type != null and vo.dispatchId != null and vo.type == 'car'">
- AND td.id in (SELECT DISTINCT order_id FROM dispatch_car_dispatch_order_detail_base
- WHERE car_dispatch_id = #{vo.dispatchId} and deleted = 0)
- </if>
- <if test="vo.travelStatus != null">
- AND td.travel_status = #{vo.travelStatus}
- </if>
- <if test="vo.voucherCode != null and vo.voucherCode != ''">
- AND tdl.voucher_code = #{vo.voucherCode}
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND tdl.product_name like concat('%',#{vo.productName}, '%')
- </if>
- <if test="vo.sellMethod != null">
- AND td.sell_method = #{vo.sellMethod}
- </if>
- <if test="vo.planIds!=null and vo.planIds.size()>0 and vo.cateIds!=null and vo.cateIds.size()>0">
- AND (td.route_plan_id in
- <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- or tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- )
- </if>
- <if test="vo.cateIds!=null and vo.cateIds.size()>0 and vo.planIds==null">
- AND tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.planIds!=null and vo.planIds.size()>0 and (vo.cateIds==null or vo.cateIds.size()==0)">
- and td.route_plan_id in
- <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="selectStoreMachineProductList"
- resultType="java.lang.Long">
- SELECT t1.product_id FROM otc_agency_store_machine_product t1
- where 1=1
- <if test="vo.storeId != null and vo.storeId != ''">
- AND t1.store_id = #{vo.storeId}
- </if>
- <if test="vo.machineId != null and vo.machineId != ''">
- AND t1.machine_id = #{vo.machineId}
- </if>
- </select>
- <select id="orderListByOta" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- SELECT
- t1.*
- FROM
- trade_order t1
- inner join trade_detail t3 on t1.id = t3.order_id
- inner join trade_visitor t4 on t3.id = t4.detail_id
- INNER JOIN trade_order_user t2 ON t2.order_id = t1.id
- WHERE
- t1.sell_method = 0
- AND t1.order_status in (6,7,8,9,10,13)
- AND t1.tenant_id = #{tenantId}
- AND t1.travel_date = #{travelDate}
- <if test="credentialNo != null and credentialNo != ''">
- AND t4.credential_no = #{credentialNo}
- </if>
- <if test="mobile != null and mobile != ''">
- AND t2.mobile = #{mobile}
- </if>
- ORDER BY
- t1.payment_date DESC
- </select>
- <select id="orderList" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- SELECT
- t1.*
- FROM
- trade_order t1
- INNER JOIN trade_order_user t2 ON t2.order_id = t1.id
- INNER JOIN trade_detail td on t1.id = td.order_id
- INNER JOIN trade_visitor v on v.detail_id = td.id
- WHERE
- 1 = 1
- <if test="orderStatus!=null and orderStatus.size()>0">
- AND t1.order_status in
- <foreach collection="orderStatus" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND t1.tenant_id = #{tenantId}
- AND t1.travel_date = #{travelDate}
- <if test="credentialNo != null and credentialNo != ''">
- AND v.credential_no = #{credentialNo}
- </if>
- <if test="mobile != null and mobile != ''">
- AND t2.mobile = #{mobile}
- </if>
- group by t1.id
- ORDER BY
- t1.payment_date DESC
- </select>
- <select id="queryOneByOrderNo" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- SELECT DISTINCT o2.*
- FROM trade_order o
- INNER JOIN trade_detail d on d.order_id = o.id
- INNER JOIN trade_detail_base db ON db.detail_id = d.id
- INNER JOIN trade_detail d2 ON db.supplier_voucher_code = d2.voucher_code
- INNER JOIN trade_order o2 ON d2.order_id = o2.id
- WHERE o.order_no = #{orderNo}
- union all
- SELECT o.* FROM trade_order o WHERE o.sell_method in (0,1,4,6,7) and o.order_no = #{orderNo}
- </select>
- <select id="updateAppletProductSellNum">
- update applet_product t1 inner JOIN applet_product_group t2 ON t1.id = t2.applet_product_id
- and t2.deleted =0
- set t1.sell_num = t1.sell_num+#{sellNum} where t2.product_id = #{productId}
- </select>
- <select id="selectCanBindOrderList" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- SELECT o.id,o.is_bind
- FROM trade_order o
- INNER JOIN trade_detail d ON d.order_id = o.id
- INNER JOIN trade_order_user u on o.id = u.order_id
- WHERE
- o.order_status > 5 AND o.deleted = 0
- AND (o.is_bind IS NULL or o.is_bind = 0 ) and o.id != #{vo.orderId}
- AND o.travel_date = #{vo.travelDate}
- AND d.product_id = #{vo.productId}
- <if test="vo.routePlanId !=null">
- And o.route_plan_id = #{vo.routePlanId}
- </if>
- AND u.mobile = #{vo.mobile}
- GROUP BY o.id
- </select>
- <update id="deleteOrderById">
- delete from trade_order where id = #{orderId}
- </update>
- <update id="deleteOrderByOrderNo">
- update from trade_order where order_no = #{orderNo}
- </update>
- <select id="getInvoiceOrderCount" resultType="java.lang.Integer">
- select count(1) num from trade_invoice t1 inner join trade_invoice_detail t2 on t1.id = t2.invoice_id
- and t1.invoice_status in (1,3)
- where t2.order_no = #{orderNo} and t1.deleted = 0
- </select>
- <select id="selectPlatPayAmountByOriginOrderNo" resultType="java.util.Map">
- select sum(tod.pay_amount) totalPayAmount
- from trade_order tod
- where tod.external_origin_order_no =#{originOrderNo} and tod.order_status>=6
- </select>
- <select id="selectChangeCountByOrderId" resultType="java.lang.Integer">
- select count(*) totalCount
- from trade_order tod
- inner join trade_order_bind tb on tod.id = tb.order_id and tb.type = 2 and tb.deleted =0
- inner join trade_order tod1 on tod1.id = tb.bind_id
- where tod.id = #{orderId} and tod1.order_status>=6
- </select>
- <update id="updateOrderFinishStatus">
- update trade_order tod,
- (select tod.id
- from trade_order tod
- inner join trade_detail td on tod.id = td.order_id
- where tod.sell_method in
- <foreach collection="sellMethodList" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- and tod.order_status >=6
- and td.validity_end_date = #{endDate}
- and not EXISTS (
- select 1
- from trade_detail td1
- where td1.validity_end_date > #{endDate} and td1.order_id = tod.id and td1.refund_status != 1
- )
- ) t
- set tod.finish_status = 1
- where tod.id = t.id
- </update>
- <select id="getSupplierCheckOrder" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespVO">
- 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,
- 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, tou.contact_name,tou.credential_no,tou.mobile
- FROM trade_order td
- INNER JOIN trade_order_user tou on td.id = tou.order_id and td.deleted = 0
- INNER JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
- INNER JOIN trade_detail_base tdb on tdb.detail_id = tdl.id
- left join product_route_plan plan on td.route_plan_id = plan.id
- <if test="vo.type != null and vo.dispatchId == null and vo.type == 'boat'">
- inner join dispatch_operate_plan_boat_order_detail_base dopbodb on td.id = dopbodb.order_id and dopbodb.deleted = 0
- </if>
- <if test="vo.type != null and vo.dispatchId == null and vo.type == 'car'">
- inner join dispatch_car_dispatch_order_detail_base dcdodb on td.id = dcdodb.order_id and dcdodb.deleted = 0
- </if>
- <if test="vo.credentialNo != null and vo.credentialNo != ''">
- INNER JOIN trade_visitor tv on tv.detail_id = tdl.id and tv.deleted = 0
- </if>
- where supplier_id in (
- select t2.id from product_supplier_user t1 inner join product_supplier t2 on t1.supplier_id = t2.id
- where t1.user_id=#{vo.userId} and t1.deleted =0
- )
- <choose>
- <when test="vo.orderStatus != null">
- AND td.order_status = #{vo.orderStatus}
- </when>
- <otherwise>
- and td.order_status in (6,7,8,9,10,13)
- </otherwise>
- </choose>
- <choose>
- <when test="vo.travelDate != null and vo.travelDate != ''">
- AND DATE_FORMAT(tdl.validity_start_date, '%Y-%m-%d') <![CDATA[ <= ]]> #{vo.travelDate}
- AND DATE_FORMAT(tdl.validity_end_date, '%Y-%m-%d') <![CDATA[ >= ]]> #{vo.travelDate}
- </when>
- <otherwise>
- and tdl.validity_start_date <![CDATA[ <= ]]> NOW()
- and tdl.validity_end_date <![CDATA[ >= ]]> NOW()
- </otherwise>
- </choose>
- <choose>
- <when test="vo.orderNo != null and vo.orderNo.length() == 4">
- AND td.order_no like concat('%',#{vo.orderNo})
- </when>
- <when test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <choose>
- <when test="vo.phone != null and vo.phone.length() == 4">
- AND tou.mobile like concat('%',#{vo.phone})
- </when>
- <when test="vo.phone != null and vo.phone != ''">
- AND tou.mobile = #{vo.phone}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <choose>
- <when test="vo.credentialNo != null and vo.credentialNo.length() == 4">
- AND tv.credential_no like concat('%',#{vo.credentialNo})
- </when>
- <when test="vo.credentialNo != null and vo.credentialNo != ''">
- AND tv.credential_no = #{vo.credentialNo}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="vo.type != null and vo.dispatchId != null and vo.type == 'boat'">
- AND td.id in (SELECT DISTINCT order_id FROM dispatch_operate_plan_boat_order_detail_base
- WHERE plan_id = #{vo.dispatchId} and deleted = 0)
- </if>
- <if test="vo.type != null and vo.dispatchId != null and vo.type == 'car'">
- AND td.id in (SELECT DISTINCT order_id FROM dispatch_car_dispatch_order_detail_base
- WHERE car_dispatch_id = #{vo.dispatchId} and deleted = 0)
- </if>
- <if test="vo.voucherCode != null and vo.voucherCode != ''">
- AND tdl.voucher_code = #{vo.voucherCode}
- </if>
- <if test="vo.checkType != null and vo.checkType == 1">
- AND tdb.use_status in (1,2)
- </if>
- <if test="vo.checkType != null and vo.checkType == 2">
- AND tdb.use_status in (3,6,8)
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND tdl.product_name like concat('%',#{vo.productName}, '%')
- </if>
- <if test="vo.sellMethod != null">
- AND td.sell_method = #{vo.sellMethod}
- </if>
- <if test="vo.planIds!=null and vo.planIds.size()>0 and vo.cateIds!=null and vo.cateIds.size()>0">
- AND (td.route_plan_id in
- <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- or tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- )
- </if>
- <if test="vo.cateIds!=null and vo.cateIds.size()>0 and vo.planIds==null">
- AND tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.planIds!=null and vo.planIds.size()>0 and (vo.cateIds==null or vo.cateIds.size()==0)">
- and td.route_plan_id in
- <foreach collection="vo.planIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by td.id
- ORDER BY td.create_time DESC
- </select>
- <select id="getOtaTradeOrderPage"
- resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeDetailRespVO">
- SELECT td.*,tor.order_no,pbr.check_start_date,pbr.check_end_date
- FROM trade_detail td
- LEFT JOIN product_basic_rule pbr on td.product_id = pbr.id
- LEFT JOIN trade_order tor on tor.id = td.order_id
- where 1= 1 AND
- EXISTS (select * from product_sale_channel sc where sc.product_id = td.product_id and sc.channel_id = 0)
- <if test="vo.productName != null and vo.productName != ''">
- AND td.product_name = #{vo.productName}
- </if>
- <if test="vo.orderNo != null and vo.orderNo != ''">
- AND tor.order_no = #{vo.orderNo}
- </if>
- <if test="vo.orderStatus != null and vo.orderStatus != ''">
- AND tor.order_status = #{vo.orderStatus}
- </if>
- <if test="vo.paymentDateStart != null">
- AND tor.payment_date <![CDATA[ >= ]]> #{vo.paymentDateStart}
- </if>
- <if test="vo.paymentDateEnd != null">
- AND tor.payment_date <![CDATA[ <= ]]> #{vo.paymentDateEnd}
- </if>
- <if test="vo.type == 1">
- AND tor.source_id = #{distributorId}
- </if>
- GROUP BY td.voucher_code
- ORDER BY td.create_time DESC
- </select>
- <select id="regionStatic" resultType="java.util.Map">
- 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
- inner join trade_visitor t3 on t2.id = t3.detail_id
- inner join ota_distributor t4 on t1.source_id = t4.id
- inner join ota_distributor_region t5 on t4.id = t5.distributor_id
- and (left(t3.credential_no,2) = t5.distributor_region_id or left(t3.credential_no,4) = t5.distributor_region_id)
- inner join ota_region t6 on ((t5.distributor_region_id = province_code and LEVEL=1) or t5.distributor_region_id = left(t6.id,4) )
- where t2.voucher_status in (1,2,3,4,6,8,9)
- <if test="vo.startDate != null and vo.startDate!=''">
- AND t2.use_date <![CDATA[ >= ]]> #{vo.startDate}
- </if>
- <if test="vo.endDate != null and vo.endDate!=''">
- AND t2.use_date <![CDATA[ <= ]]> #{vo.endDate}
- </if>
- GROUP BY t4.id
- order by num desc
- </select>
- <select id="queryOrderByLast" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- SELECT * FROM trade_order WHERE order_no = #{orderNo} and deleted = 1 ORDER BY update_time DESC limit 1
- </select>
- <select id="queryOrderById" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO">
- SELECT * FROM trade_order WHERE id = #{orderId} ORDER BY update_time DESC limit 1
- </select>
- <select id="selectConfirmationCountry"
- resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderConfirmationCountryRespVO">
- SELECT
- t1.real_money actual_price,
- t1.room_model_id,
- t2.short_name room_model_short_name,
- t2.NAME room_model_name,
- t3.type,
- ifnull( t3.nationality, 1 ) nationality,
- t3.floor,
- IFNULL( t4.`name`, '中国' ) nationality_name,
- count( t3.id ) num
- FROM
- trade_order_room_model t1
- LEFT JOIN resource_room_model t2 ON t1.room_model_id = t2.id
- LEFT JOIN trade_visitor t3 ON t1.room_index_id = t3.room_index_id
- LEFT JOIN area t4 ON t3.nationality = t4.id
- WHERE
- t1.order_id = #{orderId}
- AND t1.deleted = 0
- GROUP BY
- t1.room_model_id,
- t1.floor,
- t3.type
- ORDER BY
- floor DESC
- </select>
- <select id="getOrderCount" resultType="java.util.Map">
- select GROUP_CONCAT(num,'*',name) name,sum(num1) num1,sum(num2) num2,sum(num3) num3,sum(num4) num4 from (
- SELECT sum(CASE WHEN tv.type='adultPlus' or tv.type='adultTake' THEN 1 ELSE 0 END) num1,
- 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,
- sum(CASE WHEN tv.type='with' THEN 1 ELSE 0 END) num3,
- sum(CASE WHEN tv.type='leader' THEN 1 ELSE 0 END) num4,
- CONCAT(rrm.short_name,'(',tv.floor,'F)') name ,count(1) num
- FROM trade_order td
- INNER JOIN trade_order_user tou on td.id = tou.order_id
- left JOIN trade_detail tdl on td.id = tdl.order_id and tdl.deleted = 0
- left join trade_visitor tv on tdl.id = tv.detail_id
- left JOIN product_spu ps on ps.id = tdl.product_id
- LEFT JOIN ota_distributor od on od.id = td.source_id
- left join trade_order_room_model tm on tv.room_index_id = tm.room_index_id and tm.deleted =0
- left join resource_room_model rrm on tm.room_model_id = rrm.id
- 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
- where td.deleted = 0 and tou.deleted = 0 and td.order_status >0 and tv.type is not null
- <if test="vo.orderStatus!=null and vo.orderStatus.size()>0">
- and td.order_status in
- <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.tenantId!=null">
- AND td.tenant_id = #{vo.tenantId}
- </if>
- <choose>
- <when test="vo.orderNo != null and vo.orderNo.length() == 4">
- AND td.order_no like concat('%',#{vo.orderNo})
- </when>
- <when test="vo.orderNo != null and vo.orderNo != ''">
- AND td.order_no = #{vo.orderNo}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="vo.externalOriginOrderNo != null and vo.externalOriginOrderNo != ''">
- AND td.external_origin_order_no = #{vo.externalOriginOrderNo}
- </if>
- <if test="vo.memberId != null and vo.memberId != ''">
- AND td.member_id = #{vo.memberId}
- </if>
- <if test="vo.voyageId != null and vo.voyageId != ''">
- AND td.voyage_id = #{vo.voyageId}
- </if>
- <if test="vo.shipId != null and vo.shipId != ''">
- AND td.ship_id = #{vo.shipId}
- </if>
- <if test="vo.routeId != null and vo.routeId != ''">
- AND exists (select 1 from product_voyage top where top.id = td.voyage_id and top.route_id = #{vo.routeId})
- </if>
- <if test="vo.dispatchStatus != null">
- AND td.dispatch_status = #{vo.dispatchStatus}
- </if>
- <if test="vo.payType != null">
- AND exists (select 1 from trade_order_pay top where top.order_id = td.id and top.payment_type = #{vo.payType})
- </if>
- <if test="vo.otaCateId != null and vo.otaCateId != ''">
- AND od.ota_category_id = #{vo.otaCateId}
- </if>
- <if test="vo.otaCateIds!=null and vo.otaCateIds.size()>0">
- and od.ota_category_id in
- <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.otaId != null and vo.otaId != ''">
- AND td.source_id = #{vo.otaId}
- </if>
- <if test="vo.storeId != null and vo.storeId != ''">
- AND td.store_id = #{vo.storeId}
- </if>
- <if test="vo.productTag != null and vo.productTag != ''">
- AND ps.product_tag = #{vo.productTag}
- </if>
- <if test="vo.productTag2 != null and vo.productTag2 != ''">
- AND ps.product_tag2 = #{vo.productTag2}
- </if>
- <if test="vo.productTag3 != null and vo.productTag3 != ''">
- AND ps.product_tag3 = #{vo.productTag3}
- </if>
- <if test="vo.productTag4 != null and vo.productTag4 != ''">
- AND ps.product_tag4 = #{vo.productTag4}
- </if>
- <if test="vo.cateIds!=null and vo.cateIds.size()>0 and (vo.planIds==null or vo.planIds.size()==0)">
- AND tdl.product_id in
- <foreach collection="vo.cateIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.externalOrderNo != null and vo.externalOrderNo != ''">
- AND td.external_order_no = #{vo.externalOrderNo}
- </if>
- <if test="vo.credentialNo != null and vo.credentialNo != ''">
- AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.credential_no = #{vo.credentialNo})
- </if>
- <if test="vo.userName != null and vo.userName != ''">
- AND exists (select tv.id from trade_visitor tv where tv.detail_id = tdl.id and tv.name = #{vo.userName})
- </if>
- <choose>
- <when test="vo.mobile != null and vo.mobile.length() == 4">
- AND tou.mobile like concat('%',#{vo.mobile})
- </when>
- <when test="vo.mobile != null and vo.mobile != ''">
- AND tou.mobile = #{vo.mobile}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="vo.contactName != null and vo.contactName != ''">
- AND tou.contact_name = #{vo.contactName}
- </if>
- <if test="vo.travelDate != null and vo.travelDate != ''">
- AND td.travel_date = #{vo.travelDate}
- </if>
- <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
- AND td.travel_date <![CDATA[ >= ]]> #{vo.travelDateStart}
- </if>
- <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
- AND td.travel_date <![CDATA[ <= ]]> #{vo.travelDateEnd}
- </if>
- <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
- AND td.create_time <![CDATA[ >= ]]> #{vo.orderDateStart}
- </if>
- <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
- AND td.create_time <![CDATA[ <= ]]> #{vo.orderDateEnd}
- </if>
- <if test="vo.orderDate != null and vo.orderDate != ''">
- AND td.create_time = #{vo.orderDate}
- </if>
- <if test="vo.sellerId != null and vo.sellerId != ''">
- AND td.seller_id = #{vo.sellerId}
- </if>
- <if test="vo.shareName != null and vo.shareName != ''">
- AND td.share_name like concat('%',#{vo.shareName},'%')
- </if>
- <if test="vo.voucherCode != null and vo.voucherCode != ''">
- AND tdl.voucher_code = #{vo.voucherCode}
- </if>
- <if test="vo.sellMethod != null and vo.sellMethod != ''">
- AND td.sell_method = #{vo.sellMethod}
- </if>
- <if test="vo.productName != null and vo.productName != ''">
- AND tdl.product_name like concat('%',#{vo.productName}, '%')
- </if>
- <if test="vo.isFullPay == 0">
- AND td.is_full_pay = #{vo.isFullPay}
- </if>
- <if test="vo.isComment != null">
- AND td.is_comment = #{vo.isComment}
- </if>
- <if test="vo.sourceId != null and vo.sourceId != ''">
- AND td.source_id = #{vo.sourceId}
- </if>
- <if test="vo.distributorId != null and vo.distributorId != ''">
- AND td.source_id = #{vo.distributorId}
- </if>
- <if test="vo.sourceName != null and vo.sourceName != ''">
- AND td.source_name like concat('%',#{vo.sourceName}, '%')
- </if>
- <if test="vo.travelStatus != null">
- AND td.travel_status = #{vo.travelStatus}
- </if>
- <if test="vo.orderRefundDateStart != null and vo.orderRefundDateEnd != ''">
- 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} )
- </if>
- GROUP BY rrm.short_name,tv.floor
- ) p
- </select>
- <select id="selectTotalByOrderIds" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.OrderTotalRespVO">
- select sum(adult_total_num) adultTotalNum, sum(child_total_num) childTotalNum, sum(baby_total_num) babyTotalNum,
- sum(with_total_num) withTotalNum, sum(leader_total_num) leaderTotalNum, sum(free_num) freeNum,
- sum(order_money) orderMoney, sum(real_money) realMoney, sum(other_money) otherMoney,
- sum(adjust_total_money) adjustTotalMoney, sum(with_amount) withTotalNumMoney,
- sum(leader_amount) leaderTotalMoney, sum(free_amount) freeAmount, sum(service_money) serviceMoney,
- sum(up_floor_total_num) upFloorTotalNum, sum(up_floor_total_money) upFloorTotalMoney,
- sum(plus_total_num) plusTotalNum, sum(collection_service_money) collectionServiceMoney,
- sum(use_room_total_num) totalRoomNum,sum(free_amount) freeAmount from trade_order_total
- where 1=1
- AND old_order_id in
- <foreach collection="orderIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </select>
- </mapper>
|