| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093 |
- <?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.route_plan_id,
- o.seller_id,
- o.sell_method,
- o.share_name,
- o.source_id,
- o.source_name,
- o.store_id,
- o.store_name,
- o.visitor_type,
- ps.cost_price,
- 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
- INNER JOIN product_spu ps ON ps.id = td.product_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.validity_end_date >= DATE_SUB(NOW(), INTERVAL #{canInvoicedDay} DAY)
- and o.is_invoice in (0,2)
- and o.order_status in (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 = 2031362252762136577
- 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>
- </mapper>
|