| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571 |
- <?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.zhongzheng.modules.top.goods.mapper.TopOldOrderMapper">
- <resultMap type="com.zhongzheng.modules.top.goods.domain.TopOldOrder" id="TopOrderResult">
- <result property="orderId" column="order_id"/>
- <result property="orderSn" column="order_sn"/>
- <result property="userId" column="user_id"/>
- <result property="orderPrice" column="order_price"/>
- <result property="orderGeneral" column="order_general"/>
- <result property="orderStatus" column="order_status"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="payTime" column="pay_time"/>
- <result property="payType" column="pay_type"/>
- <result property="transid" column="transid"/>
- <result property="cancelTime" column="cancel_time"/>
- <result property="finishTime" column="finish_time"/>
- <result property="orderType" column="order_type"/>
- <result property="payPrice" column="pay_price"/>
- <result property="orderFrom" column="order_from"/>
- <result property="createUsername" column="create_username"/>
- <result property="status" column="status"/>
- <result property="createSysUserId" column="create_sys_user_id"/>
- <result property="inputOrderSn" column="input_order_sn"/>
- <result property="payStatus" column="pay_status"/>
- <result property="checkStatus" column="check_status"/>
- <result property="refundStatus" column="refund_status"/>
- <result property="creditStatus" column="credit_status"/>
- <result property="invoiceStatus" column="invoice_status"/>
- <result property="orderProfit" column="order_profit"/>
- <result property="orderCost" column="order_cost"/>
- <result property="orderRefund" column="order_refund"/>
- <result property="orderRefunded" column="order_refunded"/>
- <result property="orderUncollected" column="order_uncollected"/>
- <result property="orderReceived" column="order_received"/>
- <result property="remark" column="remark"/>
- <result property="costJson" column="cost_json"/>
- <result property="buyTime" column="buy_time"/>
- </resultMap>
- <select id="queryList" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo"
- resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
- SELECT
- vto.*
- FROM
- <if test="businessFullName != null and businessFullName != '' and ((userCard == null or userCard == '') and (userName == null or userName == ''))">
- ( SELECT DISTINCT order_sn
- FROM `v_top_order_business` where INSTR( business_full_name,#{businessFullName} ) > 0
- ) a
- LEFT JOIN v_top_order vto ON a.order_sn = vto.order_sn
- </if>
- <if test="((userCard != null and userCard != '') or (userName != null and userName != '')) and (businessFullName == null or businessFullName == '')">
- ( SELECT DISTINCT order_sn
- FROM `v_top_order_card` where 1=1
- <if test="userCard != null and userCard != ''">
- AND user_card = #{userCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- </if>
- <if test="userName != null and userName != ''">
- AND user_name LIKE CONCAT( '%', #{userName}, '%' )
- </if>
- ) a
- LEFT JOIN v_top_order vto ON a.order_sn = vto.order_sn
- </if>
- <if test="((userCard != null and userCard != '') or (userName != null and userName != '')) and businessFullName != null and businessFullName != ''">
- ( SELECT DISTINCT order_sn
- FROM (
- SELECT
- DISTINCT order_sn
- FROM
- ( SELECT order_sn FROM v_top_order_business WHERE INSTR( business_full_name,#{businessFullName} ) > 0 UNION
- ALL SELECT order_sn FROM v_top_order_card
- WHERE 1 = 1
- <if test="userCard != null and userCard != ''">
- AND user_card = #{userCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- </if>
- <if test="userName != null and userName != ''">
- AND user_name LIKE CONCAT( '%', #{userName}, '%' )
- </if>
- ) b
- ) m
- ) a
- LEFT JOIN v_top_order vto ON a.order_sn = vto.order_sn
- </if>
- <if test="(userCard == null or userCard == '') and (businessFullName == null or businessFullName == '') and (userName == null or userName == '')">
- v_top_order vto
- </if>
- WHERE vto.`status` in (0,1)
- <if test="operationType != null">
- AND vto.operation_type = #{operationType}
- </if>
- <if test="checkStatus != null and checkStatus.size()!=0 ">
- AND vto.check_status in
- <foreach collection="checkStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="refundStatus != null">
- AND vto.refund_status = #{refundStatus}
- </if>
- <if test="refundStatusList != null and refundStatusList.size()!=0 ">
- AND vto.refund_status in
- <foreach collection="refundStatusList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="creditStatus != null and creditStatus == 0">
- AND vto.order_received <![CDATA[ < ]]> vto.pay_price
- </if>
- <if test="creditStatus != null and creditStatus == 1">
- AND vto.pay_price = vto.order_received
- </if>
- <if test="finishStatus != null">
- AND vto.finish_status = #{finishStatus}
- </if>
- <if test="invoiceStatus != null and invoiceStatus != ''">
- AND vto.invoice_status = #{invoiceStatus}
- </if>
- <if test="orderOrg != null and orderOrg != ''">
- AND vto.order_org LIKE CONCAT( '%', #{orderOrg}, '%' )
- </if>
- <if test="purchaseOrg != null and purchaseOrg != ''">
- AND vto.purchase_org LIKE CONCAT( '%', #{purchaseOrg}, '%' )
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND vto.create_sys_user_id LIKE CONCAT( '%', #{createNo}, '%' )
- </if>
- <if test="startTime != null and startTime != ''">
- AND vto.buy_time <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND vto.buy_time <![CDATA[ <= ]]> #{endTime}
- </if>
- <if test="checkStartTime != null and checkStartTime != ''">
- AND vto.check_time <![CDATA[ >= ]]> #{checkStartTime}
- </if>
- <if test="checkEndTime != null and checkEndTime != ''">
- AND vto.check_time <![CDATA[ <= ]]> #{checkEndTime}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND vto.order_sn = #{orderSn}
- </if>
- <if test="repairSign != null and repairSign != '' and repairSign == 1">
- AND vto.repair_money_total <![CDATA[ > ]]> 0
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND vto.tenant_id = #{tenantId}
- </if>
- <if test="studentCheckStatus != null">
- AND (vto.order_from != 1
- AND (SELECT COUNT(too.order_sn)
- FROM top_old_order_goods too
- WHERE vto.order_sn = too.order_sn AND too.rel_sign_id IS NOT NULL AND too.check_status = #{studentCheckStatus}) > 0)
- </if>
- <if test="orderSnList != null and orderSnList.size()!=0 ">
- AND vto.order_sn in
- <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="keyword != null and keyword != ''">
- AND (
- vto.order_sn LIKE CONCAT( '%', #{keyword}, '%' )
- OR vto.create_no LIKE CONCAT( '%', #{keyword}, '%' )
- OR vto.purchase_org LIKE CONCAT( '%', #{keyword}, '%' ))
- </if>
- order by vto.update_time DESC
- </select>
- <select id="queryList_COUNT" resultType="Long">
- SELECT
- ((SELECT
- COUNT( DISTINCT ot.order_sn ) AS num
- FROM
- top_old_order ot
- LEFT JOIN top_old_order_goods otg ON ot.order_sn = otg.order_sn
- WHERE
- 1 = 1 AND ot.`status` = 1
- <if test="businessFullName != null and businessFullName != ''">
- AND INSTR( otg.business_full_name , #{businessFullName} ) > 0
- </if>
- <if test="userCard != null and userCard != ''">
- AND otg.user_card = #{userCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- </if>
- <if test="operationType != null">
- AND ot.operation_type = #{operationType}
- </if>
- <if test="userName != null and userName != ''">
- AND otg.user_name LIKE CONCAT( '%', #{userName}, '%' )
- </if>
- <if test="checkStatus != null and checkStatus.size()!=0 ">
- AND ot.check_status in
- <foreach collection="checkStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="refundStatus != null">
- AND ot.refund_status = #{refundStatus}
- </if>
- <if test="refundStatusList != null and refundStatusList.size()!=0 ">
- AND ot.refund_status in
- <foreach collection="refundStatusList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderOrg != null and orderOrg != ''">
- AND ot.order_org LIKE CONCAT( '%', #{orderOrg}, '%' )
- </if>
- <if test="purchaseOrg != null and purchaseOrg != ''">
- AND vto.purchase_org LIKE CONCAT( '%', #{purchaseOrg}, '%' )
- </if>
- <if test="createNo != null and createNo != ''">
- AND vto.create_no LIKE CONCAT( '%', #{createNo}, '%' )
- </if>
- <if test="checkStartTime != null and checkStartTime != ''">
- AND ot.check_time <![CDATA[ >= ]]> #{checkStartTime}
- </if>
- <if test="checkEndTime != null and checkEndTime != ''">
- AND ot.check_time <![CDATA[ <= ]]> #{checkEndTime}
- </if>
- <if test="creditStatus != null and creditStatus != '' and creditStatus == 0">
- AND ot.order_received <![CDATA[ < ]]> ot.pay_price
- </if>
- <if test="creditStatus != null and creditStatus != '' and creditStatus == 1">
- AND ot.pay_price = ot.order_received
- </if>
- <if test="invoiceStatus != null and invoiceStatus != ''">
- AND ot.invoice_status = #{invoiceStatus}
- </if>
- <if test="startTime != null and startTime != ''">
- AND ot.create_time <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND ot.create_time <![CDATA[ <= ]]> #{endTime}
- </if>
- <if test="repairSign != null and repairSign != '' and repairSign == 1">
- AND ot.repair_money_total <![CDATA[ > ]]> 0
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND ot.order_sn = #{orderSn}
- </if>
- <if test="finishStatus != null">
- AND ot.finish_status = #{finishStatus}
- </if>
- <if test="studentCheckStatus != null">
- AND (SELECT COUNT(too.order_sn)
- FROM top_old_order_goods too
- WHERE ot.order_sn = too.order_sn AND too.rel_sign_id IS NOT NULL AND too.check_status = #{studentCheckStatus}) > 0
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND ot.tenant_id = #{tenantId}
- </if>
- <if test="orderSnList != null and orderSnList.size()!=0 ">
- AND ot.order_sn in
- <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="keyword != null and keyword != ''">
- AND (
- ot.order_sn LIKE CONCAT( '%', #{keyword}, '%' )
- OR ot.create_no LIKE CONCAT( '%', #{keyword}, '%' )
- OR ot.purchase_org LIKE CONCAT( '%', #{keyword}, '%' ))
- </if>
- ) + (SELECT
- COUNT( DISTINCT o.order_sn ) AS num
- FROM
- `order` o
- LEFT JOIN order_goods og ON o.order_sn = og.order_sn
- LEFT JOIN `user` u ON o.user_id = u.user_id
- WHERE
- 1 = 1 AND o.`status` IN (0,1)
- AND ( `o`.`order_type` != 4 )
- AND ( `o`.`org_sign` != 1 )
- <if test="businessFullName != null and businessFullName != ''">
- AND (
- SELECT
- COUNT(g.goods_id)
- FROM
- goods g
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- WHERE
- og.goods_id = g.goods_id
- AND
- INSTR( CONCAT('学校业务', cet.education_name, cb.business_name, cpt.project_name),#{businessFullName}) > 0) > 0
- </if>
- <if test="userCard != null and userCard != ''">
- AND u.id_card = #{userCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- </if>
- <if test="userName != null and userName != ''">
- AND u.realname LIKE CONCAT( '%', #{userName}, '%' )
- </if>
- <if test="checkStatus != null and checkStatus.size()!=0 ">
- AND o.check_status in
- <foreach collection="checkStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="operationType != null">
- AND o.operation_type = #{operationType}
- </if>
- <if test="refundStatus != null">
- AND o.order_refund_status = #{refundStatus}
- </if>
- <if test="refundStatusList != null and refundStatusList.size()!=0 ">
- AND o.order_refund_status in
- <foreach collection="refundStatusList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderOrg != null and orderOrg != ''">
- AND 'C端云学堂' LIKE CONCAT( '%', #{orderOrg}, '%' )
- </if>
- <if test="checkStartTime != null and checkStartTime != ''">
- AND o.pay_time <![CDATA[ >= ]]> #{checkStartTime}
- </if>
- <if test="checkEndTime != null and checkEndTime != ''">
- AND o.pay_time <![CDATA[ <= ]]> #{checkEndTime}
- </if>
- <if test="creditStatus != null and creditStatus != '' and creditStatus == 0">
- AND o.order_received <![CDATA[ < ]]> o.pay_price
- </if>
- <if test="creditStatus != null and creditStatus != '' and creditStatus == 1">
- AND o.pay_price = o.order_received
- </if>
- <if test="repairSign != null and repairSign != '' and repairSign == 1">
- AND o.order_id = 0
- </if>
- <if test="studentCheckStatus != null">
- AND o.order_id = 0
- </if>
- <if test="invoiceStatus != null and invoiceStatus != ''">
- AND o.invoice_status = #{invoiceStatus}
- </if>
- <if test="finishStatus != null">
- AND o.finish_status = #{finishStatus}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="startTime != null and startTime != ''">
- AND o.create_time <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="startTime == null">
- AND o.create_time <![CDATA[ > ]]> #{filtrationTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <![CDATA[ <= ]]> #{endTime}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND o.order_sn = #{orderSn}
- </if>
- <if test="orderSnList != null and orderSnList.size()!=0 ">
- AND o.order_sn in
- <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="keyword != null and keyword != ''">
- AND o.order_sn LIKE CONCAT( '%', #{keyword}, '%' )
- </if>
- )) as number
- </select>
- <select id="queryById" parameterType="java.lang.String"
- resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
- SELECT *
- FROM v_top_order
- WHERE order_sn = #{orderSn}
- </select>
- <select id="queryBusinessBySn" parameterType="java.lang.String" resultType="java.lang.String">
- SELECT DISTINCT business_name
- FROM v_top_order_business
- WHERE order_sn = #{orderSn}
- </select>
- <select id="queryBusinessFullNameBySn" parameterType="java.lang.String" resultType="java.lang.String">
- SELECT DISTINCT business_full_name
- FROM top_old_order_goods
- WHERE order_sn = #{orderSn}
- AND `status` = 1
- AND check_status = 1
- </select>
- <select id="queryByOrderSns" parameterType="java.lang.String"
- resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
- SELECT * FROM v_top_order WHERE 1 =1
- <if test="orderSnList != null and orderSnList.size()!=0 ">
- AND order_sn in
- <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="queryReceiveUnSum" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo"
- resultType="long">
- SELECT
- IFNULL(sum(
- too.order_uncollected),0)
- FROM
- top_old_order too
- LEFT JOIN sys_tenant st ON too.tenant_id = st.tenant_id
- LEFT JOIN top_order_rec_note rn ON too.tenant_id = rn.tenant_id and too.order_sn = rn.order_sn
- where too.check_status=1 AND too.order_uncollected >0
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="startTime != null and startTime != ''">
- AND too.buy_time <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.buy_time <![CDATA[ <= ]]> #{endTime}
- </if>
- <if test="keyNo != null and keyNo != ''">
- AND (st.tenant_name like concat('%', #{keyNo}, '%') or too.create_no like concat('%', #{keyNo}, '%'))
- </if>
- <if test="creditStatus != null and creditStatus != ''">
- AND too.credit_status = #{creditStatus}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND too.order_sn = #{orderSn}
- </if>
- <if test="badBill != null and badBill == 1 and badBillList != null and badBillList.size()!=0 ">
- AND
- <foreach collection="badBillList" item="item" index="index" open="(" close=")" separator="or">
- (too.check_time BETWEEN #{item.startTime} and #{item.endTime})
- </foreach>
- </if>
- <if test="badBill != null and badBill == 2 and badBillList != null and badBillList.size()!=0 ">
- AND
- <foreach collection="badBillList" item="item" index="index" open="(" close=")" separator="or">
- (too.check_time NOT BETWEEN #{item.startTime} and #{item.endTime})
- </foreach>
- </if>
- ORDER BY too.buy_time DESC
- </select>
- <select id="queryReceiveList" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo"
- resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
- SELECT
- too.*,
- st.tenant_name,
- rn.id as note_id,
- rn.note_type,
- rn.day_time,
- rn.week_time,
- rn.month_time,
- rn.last_time,
- rn.exceed_type
- FROM
- top_old_order too
- LEFT JOIN sys_tenant st ON too.tenant_id = st.tenant_id
- LEFT JOIN top_order_rec_note rn ON too.tenant_id = rn.tenant_id and too.order_sn = rn.order_sn
- where too.check_status=1 AND too.order_uncollected >0
- <if test="operationType != null and operationType != ''">
- AND too.operation_type = #{operationType}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="startTime != null and startTime != ''">
- AND too.buy_time <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.buy_time <![CDATA[ <= ]]> #{endTime}
- </if>
- <if test="keyNo != null and keyNo != ''">
- AND (st.tenant_name like concat('%', #{keyNo}, '%') or too.create_no like concat('%', #{keyNo}, '%'))
- </if>
- <if test="creditStatus != null and creditStatus != ''">
- AND too.credit_status = #{creditStatus}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND too.order_sn = #{orderSn}
- </if>
- <if test="badBill != null and badBill == 1 and badBillList != null and badBillList.size()!=0 ">
- AND
- <foreach collection="badBillList" item="item" index="index" open="(" close=")" separator="or">
- (too.check_time BETWEEN #{item.startTime} and #{item.endTime})
- </foreach>
- </if>
- <if test="badBill != null and badBill == 2 and badBillList != null and badBillList.size()!=0 ">
- AND
- <foreach collection="badBillList" item="item" index="index" open="(" close=")" separator="or">
- (too.check_time NOT BETWEEN #{item.startTime} and #{item.endTime})
- </foreach>
- </if>
- ORDER BY too.buy_time DESC
- </select>
- <select id="queryDivSellerList" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo"
- resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
- SELECT
- too.*,
- st.tenant_name,
- r.role_name,
- cl.check_status as divide_check_status
- FROM
- v_top_order too
- LEFT JOIN sys_tenant st ON too.tenant_id = st.tenant_id
- LEFT JOIN top_old_order_check_log cl ON too.order_sn = cl.order_sn
- AND cl.check_sign = 1
- AND ( too.divide_model + 1 ) = cl.check_from
- LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
- where 1=1 AND too.divide_model = 2
- <if test="startTime != null and startTime != ''">
- AND too.create_time <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.create_time <![CDATA[ <= ]]> #{endTime}
- </if>
- <if test="keyNo != null and keyNo != ''">
- AND (too.tenant_id like concat('%', #{keyNo}, '%') or too.create_no like concat('%', #{keyNo}, '%'))
- </if>
- <if test="divideStatusList != null and divideStatusList.size()!=0 ">
- AND too.divide_status in
- <foreach collection="divideStatusList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="divideStatus != null and divideStatus != ''">
- AND too.divide_status = #{divideStatus}
- </if>
- <if test="roleId != null and roleId != ''">
- AND cl.role_id = #{roleId}
- </if>
- ORDER BY too.order_id DESC
- </select>
- <select id="queryTenantList" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo"
- resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
- SELECT
- too.*,
- st.tenant_name,
- r.role_name,
- cl.check_status as divide_check_status
- FROM
- top_old_order too
- LEFT JOIN sys_tenant st ON too.tenant_id = st.tenant_id
- LEFT JOIN top_old_order_check_log cl ON too.order_sn = cl.order_sn
- AND cl.check_sign = 1
- AND ( too.divide_model + 1 ) = cl.check_from
- LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
- where 1=1 AND too.divide_model = 1
- <if test="startTime != null and startTime != ''">
- AND too.create_time <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.create_time <![CDATA[ <= ]]> #{endTime}
- </if>
- <if test="keyNo != null and keyNo != ''">
- AND (too.tenant_id like concat('%', #{keyNo}, '%') or too.create_no like concat('%', #{keyNo}, '%'))
- </if>
- <if test="divideStatusList != null and divideStatusList.size()!=0 ">
- AND too.divide_status in
- <foreach collection="divideStatusList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="divideStatus != null and divideStatus != ''">
- AND too.divide_status = #{divideStatus}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="roleId != null and roleId != ''">
- AND cl.role_id = #{roleId}
- </if>
- ORDER BY too.order_id DESC
- </select>
- <select id="tenantMoneyTotal" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo"
- resultType="java.math.BigDecimal">
- SELECT IFNULL(SUM(too.divide_company_money), 0)
- FROM v_top_order too
- WHERE too.divide_model = 1
- AND too.divide_status = 5
- </select>
- <select id="tenantSellerTotal" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo"
- resultType="java.math.BigDecimal">
- SELECT IFNULL(SUM(too.divide_seller_money), 0)
- FROM v_top_order too
- WHERE too.divide_model = 2
- AND too.divide_status = 5
- </select>
- <select id="queryListAll" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
- SELECT *
- FROM v_top_order
- </select>
- <select id="getOrderBySn" parameterType="java.lang.String"
- resultType="com.zhongzheng.modules.top.goods.domain.TopOldOrder">
- SELECT *
- FROM v_top_order
- WHERE order_sn = #{orderSn}
- </select>
- <select id="logList" parameterType="com.zhongzheng.modules.top.financial.bo.TopOrderLogQueryBo"
- resultType="com.zhongzheng.modules.top.financial.vo.TopOrderLogVo">
- SELECT *
- FROM top_order_log
- WHERE order_sn = #{orderSn}
- </select>
- <select id="getRefundOrder" parameterType="java.lang.String"
- resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderRefundVo">
- SELECT *
- FROM v_top_order_refund
- WHERE order_sn = #{orderSn}
- </select>
- <select id="getRefundOrderByBo" parameterType="com.zhongzheng.modules.top.financial.bo.RefundOrderBo"
- resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderRefundVo">
- SELECT * FROM v_top_order_refund WHERE order_sn = #{orderSn} AND status = 1
- <if test="periodStatus != null and periodStatus != ''">
- AND period_status = #{periodStatus}
- </if>
- </select>
- <select id="getOrderSnByBusiness" parameterType="java.lang.String" resultType="java.lang.String">
- SELECT DISTINCT order_sn
- FROM v_top_order_business
- WHERE INSTR(business_full_name, #{businessName}) > 0
- </select>
- <select id="getOrderInvoiceList" parameterType="com.zhongzheng.modules.top.goods.vo.TopOldOrderInvoiceVo" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderInvoiceVo">
- SELECT
- create_time AS applyUpTime,
- `status` AS invoiceStatus,
- update_time AS invoiceTime,
- oss_pdf_url AS ossPdfUrl,
- content
- FROM
- top_nuo_mplatform_log
- WHERE
- INSTR(order_no_list,#{orderSn})
- </select>
- <select id="getMoneyStatistics" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsMoneyVo">
- SELECT
- *
- FROM
- (
- SELECT
- SUM( too.order_received - too.order_refunded ) AS money,
- too.old_customer_id AS customer_id,
- (
- SELECT
- tod.purchase_org
- FROM
- top_old_order tod
- WHERE
- tod.old_customer_id = too.old_customer_id
- AND tod.`status` = 1
- AND tod.check_status = 1
- LIMIT 1
- ) AS customer_name
- FROM
- top_old_order too
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- AND too.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND too.old_customer_id = #{customerId}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (SELECT COUNT(DISTINCT oog.order_sn) FROM top_old_order_goods oog WHERE too.order_sn = oog.order_sn AND INSTR(oog.business_full_name,#{businessName}) ) > 0
- </if>
- <if test="customerName != null and customerName != ''">
- AND too.purchase_org LIKE CONCAT('%',#{customerName},'%')
- </if>
- GROUP BY
- too.old_customer_id UNION ALL
- SELECT
- SUM( o.pay_price ) AS money,
- o.tenant_id AS customer_id,
- ( SELECT tenant_name FROM sys_tenant st WHERE st.tenant_id = o.tenant_id LIMIT 1 ) AS customer_name
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- COUNT(DISTINCT og.order_sn)
- FROM order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- WHERE o.order_sn = og.order_sn
- AND INSTR(CONCAT(cet.education_name,cb.business_name,cpt.project_name),#{businessName}) ) > 0
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerName != null and customerName != ''">
- AND (SELECT COUNT(s.tenant_id) FROM sys_tenant s WHERE o.tenant_id = s.tenant_id AND s.tenant_name LIKE CONCAT('%',#{customerName},'%')) > 0
- </if>
- GROUP BY
- o.tenant_id
- ) a
- WHERE
- 1 = 1
- ORDER BY
- a.money DESC
- </select>
- <select id="getMoneyStatisticsTotal" parameterType="java.lang.Long"
- resultType="java.math.BigDecimal">
- SELECT
- (
- SELECT
- SUM( too.order_received - too.order_refunded ) AS money
- FROM
- top_old_order too
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- AND too.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- ) + (
- SELECT
- SUM( o.pay_price ) AS money
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- ) money_total
- </select>
- <select id="getNumStatistics" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsNumVo">
- SELECT
- *
- FROM
- (
- SELECT
- COUNT(too.order_id) AS orderNum,
- too.old_customer_id AS customer_id,
- (
- SELECT
- tod.purchase_org
- FROM
- top_old_order tod
- WHERE
- tod.old_customer_id = too.old_customer_id
- AND tod.`status` = 1
- AND tod.check_status = 1
- LIMIT 1
- ) AS customer_name
- FROM
- top_old_order too
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- AND too.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND too.old_customer_id = #{customerId}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (SELECT COUNT(DISTINCT oog.order_sn) FROM top_old_order_goods oog WHERE too.order_sn = oog.order_sn AND INSTR(oog.business_full_name,#{businessName}) ) > 0
- </if>
- <if test="customerName != null and customerName != ''">
- AND too.purchase_org LIKE CONCAT('%',#{customerName},'%')
- </if>
- GROUP BY
- too.old_customer_id UNION ALL
- SELECT
- COUNT(o.order_id) AS orderNum,
- o.tenant_id AS customer_id,
- ( SELECT tenant_name FROM sys_tenant st WHERE st.tenant_id = o.tenant_id LIMIT 1 ) AS customer_name
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- COUNT(DISTINCT og.order_sn)
- FROM order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- WHERE o.order_sn = og.order_sn
- AND INSTR(CONCAT(cet.education_name,cb.business_name,cpt.project_name),#{businessName}) ) > 0
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerName != null and customerName != ''">
- AND (SELECT COUNT(s.tenant_id) FROM sys_tenant s WHERE o.tenant_id = s.tenant_id AND s.tenant_name LIKE CONCAT('%',#{customerName},'%')) > 0
- </if>
- GROUP BY
- o.tenant_id
- ) a
- WHERE
- 1 = 1
- ORDER BY
- a.orderNum DESC
- </select>
- <select id="getNumStatisticsTotal" parameterType="java.lang.Long"
- resultType="java.lang.Long">
- SELECT
- (
- SELECT
- COUNT(too.order_id) AS orderNum
- FROM
- top_old_order too
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- AND too.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- ) + (
- SELECT
- COUNT(o.order_id) AS orderNum
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- ) num_total
- </select>
- <select id="getDetailStatisticsTotal" parameterType="com.zhongzheng.modules.top.order.bo.TopDetailStatisticsTotal"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsDetailTotalVo">
- SELECT
- ((
- SELECT
- IFNULL(SUM( too.order_received - too.order_refunded ),0) AS money
- FROM
- top_old_order too
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- AND too.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND too.old_customer_id = #{customerId}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (SELECT COUNT(DISTINCT oog.order_sn) FROM top_old_order_goods oog WHERE too.order_sn = oog.order_sn AND INSTR(oog.business_full_name,#{businessName}) ) > 0
- </if>
- <if test="customerName != null and customerName != ''">
- AND too.purchase_org LIKE CONCAT('%',#{customerName},'%')
- </if>
- ) + (
- SELECT
- IFNULL(SUM( o.pay_price ),0) AS money
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- COUNT(DISTINCT og.order_sn)
- FROM order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- WHERE o.order_sn = og.order_sn
- AND INSTR(CONCAT(cet.education_name,cb.business_name,cpt.project_name),#{businessName}) ) > 0
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerName != null and customerName != ''">
- AND (SELECT COUNT(s.tenant_id) FROM sys_tenant s WHERE o.tenant_id = s.tenant_id AND s.tenant_name LIKE CONCAT('%',#{customerName},'%')) > 0
- </if>
- )) moneyTotal,
- ((
- SELECT
- COUNT(too.order_id) AS orderNum
- FROM
- top_old_order too
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- AND too.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND too.old_customer_id = #{customerId}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (SELECT COUNT(DISTINCT oog.order_sn) FROM top_old_order_goods oog WHERE too.order_sn = oog.order_sn AND INSTR(oog.business_full_name,#{businessName}) ) > 0
- </if>
- <if test="customerName != null and customerName != ''">
- AND too.purchase_org LIKE CONCAT('%',#{customerName},'%')
- </if>
- ) + (
- SELECT
- COUNT(o.order_id) AS orderNum
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- COUNT(DISTINCT og.order_sn)
- FROM order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- WHERE o.order_sn = og.order_sn
- AND INSTR(CONCAT(cet.education_name,cb.business_name,cpt.project_name),#{businessName}) ) > 0
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerName != null and customerName != ''">
- AND (SELECT COUNT(s.tenant_id) FROM sys_tenant s WHERE o.tenant_id = s.tenant_id AND s.tenant_name LIKE CONCAT('%',#{customerName},'%')) > 0
- </if>
- )) orderNumTotal
- </select>
- <select id="getStatisticsView" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsViewBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsTwoVo">
- SELECT
- COUNT(a.order_id) AS orderNum,
- SUM(a.money) AS money,
- any_value(a.timeStr) AS orderTime,
- <if test="viewSign != null and viewSign == 1">
- DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m-%d') AS timeStr
- </if>
- <if test="viewSign != null and viewSign == 2">
- DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%U') AS timeStr
- </if>
- <if test="viewSign != null and viewSign == 3">
- DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m') AS timeStr
- </if>
- FROM (
- SELECT
- too.order_id as order_id,
- too.check_time as timeStr,
- too.order_received - too.order_refunded as money
- FROM
- top_old_order too
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND too.old_customer_id IS NOT NULL
- AND too.old_customer_id = #{customerId}
- </if>
- UNION ALL
- SELECT
- o.order_id as order_id,
- o.create_time as timeStr,
- o.pay_price as money
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND o.org_sign != 1
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- AND o.tenant_id IS NOT NULL
- </if>
- ) a WHERE 1=1
- <if test="viewSign != null and viewSign == 1">
- GROUP BY DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m-%d')
- </if>
- <if test="viewSign != null and viewSign == 2">
- GROUP BY DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%U')
- </if>
- <if test="viewSign != null and viewSign == 3">
- GROUP BY DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m')
- </if>
- </select>
- <select id="getDetailStatistics" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsViewBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsDetailVo">
- SELECT
- 1 AS orderType,
- COUNT(too.order_id) AS orderNum,
- SUM( too.order_received - too.order_refunded ) AS money,
- too.old_customer_id AS customer_id,
- (
- SELECT
- tod.purchase_org
- FROM
- top_old_order tod
- WHERE
- tod.old_customer_id = too.old_customer_id
- AND tod.`status` = 1
- AND tod.check_status = 1
- LIMIT 1
- ) AS customer_name
- FROM
- top_old_order too
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- AND too.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND too.old_customer_id = #{customerId}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (SELECT COUNT(DISTINCT oog.order_sn) FROM top_old_order_goods oog WHERE too.order_sn = oog.order_sn AND INSTR(oog.business_full_name,#{businessName}) ) > 0
- </if>
- <if test="customerName != null and customerName != ''">
- AND too.purchase_org LIKE CONCAT('%',#{customerName},'%')
- </if>
- GROUP BY
- too.old_customer_id UNION ALL
- SELECT
- 2 AS orderType,
- COUNT(o.order_id) AS orderNum,
- SUM( o.pay_price ) AS money,
- o.tenant_id AS customer_id,
- ( SELECT tenant_name FROM sys_tenant st WHERE st.tenant_id = o.tenant_id LIMIT 1 ) AS customer_name
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- COUNT(DISTINCT og.order_sn)
- FROM order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- WHERE o.order_sn = og.order_sn
- AND INSTR(CONCAT(cet.education_name,cb.business_name,cpt.project_name),#{businessName}) ) > 0
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerName != null and customerName != ''">
- AND (SELECT COUNT(s.tenant_id) FROM sys_tenant s WHERE o.tenant_id = s.tenant_id AND s.tenant_name LIKE CONCAT('%',#{customerName},'%')) > 0
- </if>
- GROUP BY
- o.tenant_id
- </select>
- <select id="getTenantStatistics" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsMoneyVo">
- SELECT
- vo.*,
- st.tenant_name
- FROM
- (
- SELECT
- allu.tenant_id,
- SUM( allu.money2 ) money
- <if test="tenantId != null and tenantId != ''">
- , allu.create_sys_user_id,allu.create_username
- </if>
- FROM
- (
- SELECT
- tenant_id,
- SUM( order_received - order_refunded ) money2
- <if test="tenantId != null and tenantId != ''">
- , create_sys_user_id,any_value(create_username) as create_username
- </if>
- FROM
- top_old_order
- WHERE
- 1 = 1
- AND `status` = 1
- AND check_status = 1
- AND old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND old_customer_id = #{customerId}
- </if>
- GROUP BY
- tenant_id
- <if test="tenantId != null and tenantId != ''">
- , create_sys_user_id
- </if>
- UNION ALL
- SELECT
- og.tenant_id,
- IFNULL( SUM( og.goods_received ), 0 ) money2
- <if test="tenantId != null and tenantId != ''">
- ,'' AS create_sys_user_id, '' as create_username
- </if>
- FROM
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND og.refund_status != 2
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- AND og.pay_status != 1
- GROUP BY
- og.tenant_id
- ) allu
- GROUP BY
- allu.tenant_id
- <if test="tenantId != null and tenantId != ''">
- , allu.create_sys_user_id,allu.create_username
- </if>
- ORDER BY
- money DESC
- ) vo
- LEFT JOIN sys_tenant st ON vo.tenant_id = st.tenant_id
- </select>
- <select id="getSingleTenantStatistics" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="java.math.BigDecimal">
- SELECT
- (IFNULL(SUM( vo.order_received - vo.order_refunded ),0)+(
- SELECT
- IFNULL(SUM( og.goods_received ),0)
- FROM
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND og.refund_status != 2
- AND og.pay_status != 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND 1=0
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- count(*)
- FROM
- (
- SELECT
- concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
- g.goods_id
- FROM
- `goods` `g`
- LEFT JOIN `course_education_type` `cet` ON `g`.`education_type_id` = `cet`.`id`
- LEFT JOIN `course_project_type` `cpt` ON `g`.`project_id` = `cpt`.`id`
- LEFT JOIN `course_business` `cb` ON `g`.`business_id` = `cb`.`id`
- ) oug
- WHERE
- oug.goods_id = og.goods_id
- AND oug.business_name = #{businessName}
- )>0
- </if>
- )) money
- FROM
- top_old_order vo
- WHERE
- 1 = 1
- AND vo.`status` = 1
- AND vo.check_status = 1
- AND vo.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND vo.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND vo.check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND vo.tenant_id = #{tenantId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND vo.create_sys_user_id = #{createSysUserId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND vo.old_customer_id = #{customerId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- count(*)
- FROM
- (
- SELECT
- `otg`.`order_sn` AS `order_sn`,
- concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
- FROM
- `top_old_order_goods` `otg`
- ) ouu
- WHERE
- ouu.order_sn = vo.order_sn
- AND ouu.business_name = #{businessName}
- ) >0
- </if>
- </select>
- <select id="getTenantStatisticsOrderNum" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsNumVo">
- SELECT
- vo.*,
- st.tenant_name
- FROM
- (
- SELECT
- allu.tenant_id,
- SUM(order_num2) order_num
- <if test="tenantId != null and tenantId != ''">
- , allu.create_sys_user_id,allu.create_username
- </if>
- FROM
- (
- SELECT
- tenant_id,
- COUNT( * ) order_num2
- <if test="tenantId != null and tenantId != ''">
- , create_sys_user_id,any_value(create_username) as create_username
- </if>
- FROM
- top_old_order
- WHERE
- 1 = 1
- AND `status` = 1
- AND check_status = 1
- AND old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND old_customer_id = #{customerId}
- </if>
- GROUP BY
- tenant_id
- <if test="tenantId != null and tenantId != ''">
- , create_sys_user_id
- </if>
- UNION ALL
- SELECT
- og.tenant_id,
- COUNT( DISTINCT o.order_sn ) order_num2
- <if test="tenantId != null and tenantId != ''">
- ,'' AS create_sys_user_id, '' as create_username
- </if>
- FROM
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND og.refund_status != 2
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- AND og.pay_status != 1
- GROUP BY
- og.tenant_id
- ) allu
- GROUP BY
- allu.tenant_id
- <if test="tenantId != null and tenantId != ''">
- , allu.create_sys_user_id,allu.create_username
- </if>
- ORDER BY
- order_num DESC
- ) vo
- LEFT JOIN sys_tenant st ON vo.tenant_id = st.tenant_id
- </select>
- <select id="getSingleTenantStatisticsOrderNum" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="java.lang.Long">
- SELECT
- (IFNULL(COUNT( DISTINCT order_sn),0)+(
- SELECT
- IFNULL(COUNT(DISTINCT o.order_sn),0) AS orderNum
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND 1=0
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- count(*)
- FROM
- (
- SELECT
- concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
- g.goods_id,
- og.order_sn
- FROM
- order_goods og LEFT JOIN `goods` `g` on og.goods_id = `g`.goods_id
- LEFT JOIN `course_education_type` `cet` ON `g`.`education_type_id` = `cet`.`id`
- LEFT JOIN `course_project_type` `cpt` ON `g`.`project_id` = `cpt`.`id`
- LEFT JOIN `course_business` `cb` ON `g`.`business_id` = `cb`.`id`
- ) oug
- WHERE
- o.order_sn = oug.order_sn
- AND oug.business_name = #{businessName}
- )>0
- </if>
- ))
- FROM
- top_old_order too
- WHERE
- 1 = 1
- AND `status` = 1
- AND check_status = 1
- AND old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND old_customer_id = #{customerId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND create_sys_user_id = #{createSysUserId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- count(*)
- FROM
- (
- SELECT
- `otg`.`order_sn` AS `order_sn`,
- concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
- FROM
- `top_old_order_goods` `otg`
- ) ouu
- WHERE
- ouu.order_sn = too.order_sn
- AND ouu.business_name = #{businessName}
- ) >0
- </if>
- </select>
- <select id="getNumStatisticsTotalWithBo" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="java.math.BigDecimal">
- SELECT
- (IFNULL(COUNT(too.order_id),0)+(
- SELECT
- IFNULL(COUNT(o.order_id),0) AS orderNum
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- count(*)
- FROM
- (
- SELECT
- concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
- g.goods_id,
- og.order_sn
- FROM
- order_goods og LEFT JOIN `goods` `g` on og.goods_id = `g`.goods_id
- LEFT JOIN `course_education_type` `cet` ON `g`.`education_type_id` = `cet`.`id`
- LEFT JOIN `course_project_type` `cpt` ON `g`.`project_id` = `cpt`.`id`
- LEFT JOIN `course_business` `cb` ON `g`.`business_id` = `cb`.`id`
- ) oug
- WHERE
- o.order_sn = oug.order_sn
- AND oug.business_name = #{businessName}
- )>0
- </if>
- )) AS orderNum
- FROM
- top_old_order too
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- AND too.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND too.old_customer_id = #{customerId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- count(*)
- FROM
- (
- SELECT
- `otg`.`order_sn` AS `order_sn`,
- concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
- FROM
- `top_old_order_goods` `otg`
- ) ouu
- WHERE
- ouu.order_sn = too.order_sn
- AND ouu.business_name = #{businessName}
- ) >0
- </if>
- </select>
- <select id="getMoneyStatisticsWithBo" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="java.math.BigDecimal">
- SELECT
- IFNULL(SUM( too.order_received - too.order_refunded ),0)+ (
- SELECT
- IFNULL(SUM( og.goods_received ),0) AS money
- FROM
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND og.refund_status != 2
- AND og.pay_status != 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND 1=0
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- count(*)
- FROM
- (
- SELECT
- concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
- g.goods_id
- FROM
- `goods` `g`
- LEFT JOIN `course_education_type` `cet` ON `g`.`education_type_id` = `cet`.`id`
- LEFT JOIN `course_project_type` `cpt` ON `g`.`project_id` = `cpt`.`id`
- LEFT JOIN `course_business` `cb` ON `g`.`business_id` = `cb`.`id`
- ) oug
- WHERE
- og.goods_id = oug.goods_id
- AND oug.business_name = #{businessName}
- )>0
- </if>
- ) AS money
- FROM
- top_old_order too
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- AND too.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND too.old_customer_id = #{customerId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND too.create_sys_user_id = #{createSysUserId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- count(*)
- FROM
- (
- SELECT
- `otg`.`order_sn` AS `order_sn`,
- concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
- FROM
- `top_old_order_goods` `otg`
- ) ouu
- WHERE
- ouu.order_sn = too.order_sn
- AND ouu.business_name = #{businessName}
- ) >0
- </if>
- </select>
- <select id="getBusinessOrderMoney" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsMoneyVo">
- SELECT
- allu.business_name,
- SUM( allu.money ) money
- FROM
- (
- SELECT
- ouu.business_name,
- IFNULL( SUM( oo.order_received - oo.order_refunded ), 0 ) money
- FROM
- (
- SELECT
- ou.order_sn,
- ou.business_name
- FROM
- (
- SELECT
- `otg`.`order_sn` AS `order_sn`,
- concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
- FROM
- `top_old_order_goods` `otg`
- ) ou
- GROUP BY
- ou.order_sn,
- ou.business_name
- ) ouu
- LEFT JOIN top_old_order oo ON ouu.order_sn = oo.order_sn
- WHERE
- oo.`status` = 1
- AND oo.check_status = 1
- AND oo.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND oo.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND oo.check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND oo.tenant_id = #{tenantId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND oo.create_sys_user_id = #{createSysUserId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND ouu.business_name = #{businessName}
- </if>
- <if test="customerId != null and customerId != ''">
- AND oo.old_customer_id = #{customerId}
- </if>
- GROUP BY
- ouu.business_name UNION ALL
- SELECT
- nou.business_name,
- SUM( nou.goods_received ) AS money
- FROM
- (
- SELECT
- `og`.`order_sn` AS `order_sn`,
- concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
- og.goods_received
- FROM
- ((((
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- LEFT JOIN `goods` `g` ON ((
- `og`.`goods_id` = `g`.`goods_id`
- )))
- LEFT JOIN `course_education_type` `cet` ON ((
- `g`.`education_type_id` = `cet`.`id`
- )))
- LEFT JOIN `course_project_type` `cpt` ON ((
- `g`.`project_id` = `cpt`.`id`
- )))
- LEFT JOIN `course_business` `cb` ON ((
- `g`.`business_id` = `cb`.`id`
- )))
- WHERE
- og.pay_status != 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND og.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND og.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND og.tenant_id = #{tenantId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND 1=0
- </if>
- <if test="customerId != null and customerId != ''">
- AND og.tenant_id = #{customerId}
- </if>
- AND og.refund_status != 2
- ) nou
- WHERE 1=1
- <if test="businessName != null and businessName != ''">
- AND nou.business_name = #{businessName}
- </if>
- GROUP BY
- nou.business_name
- ) allu
- GROUP BY
- allu.business_name
- ORDER BY
- money DESC
- </select>
- <select id="getBusinessOrderNum" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsNumVo">
- SELECT
- allu.business_name,
- SUM( allu.order_num ) order_num
- FROM
- (
- SELECT
- ouu.business_name,
- IFNULL(COUNT(DISTINCT ouu.order_sn ),0) order_num
- FROM
- (
- SELECT
- `otg`.`order_sn` AS `order_sn`,
- `otg`.`order_goods_id` AS `order_goods_id`,
- concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
- FROM
- `top_old_order_goods` `otg`
- ) ouu
- LEFT JOIN top_old_order oo ON ouu.order_sn = oo.order_sn
- WHERE
- oo.`status` = 1
- AND oo.check_status = 1
- AND oo.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND oo.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND oo.check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND oo.tenant_id = #{tenantId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND oo.create_sys_user_id = #{createSysUserId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND oo.old_customer_id = #{customerId}
- </if>
- GROUP BY
- ouu.business_name UNION ALL
- SELECT
- nou.business_name,
- COUNT(DISTINCT nou.order_sn ) order_num
- FROM
- (
- SELECT
- `og`.`order_sn` AS `order_sn`,
- concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
- og.order_goods_id
- FROM
- ((((
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- LEFT JOIN `goods` `g` ON ((
- `og`.`goods_id` = `g`.`goods_id`
- )))
- LEFT JOIN `course_education_type` `cet` ON ((
- `g`.`education_type_id` = `cet`.`id`
- )))
- LEFT JOIN `course_project_type` `cpt` ON ((
- `g`.`project_id` = `cpt`.`id`
- )))
- LEFT JOIN `course_business` `cb` ON ((
- `g`.`business_id` = `cb`.`id`
- )))
- WHERE
- og.pay_status != 1
- AND og.refund_status != 2
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND og.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND og.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND og.tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND og.tenant_id = #{customerId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND 1=0
- </if>
- ) nou
- GROUP BY
- nou.business_name
- ) allu
- where 1=1
- <if test="businessName != null and businessName != ''">
- AND allu.business_name = #{businessName}
- </if>
- GROUP BY
- allu.business_name
- ORDER BY
- order_num DESC
- </select>
- <select id="getOrderGoodsNumStatisticsTotalWithBo" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="java.lang.Long">
- SELECT
- IFNULL(COUNT( DISTINCT og.order_sn ),0)+ (
- SELECT
- IFNULL(COUNT( DISTINCT otg.order_sn ),0) order_num
- FROM
- `top_old_order_goods` `otg`
- LEFT JOIN top_old_order oo ON otg.order_sn = oo.order_sn
- WHERE
- oo.`status` = 1
- AND oo.check_status = 1
- AND oo.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND oo.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND oo.check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND oo.tenant_id = #{tenantId}
- </if>
- <if test="createNo != null and createNo != ''">
- AND oo.create_no = #{createNo}
- </if>
- <if test="customerId != null and customerId != ''">
- AND oo.old_customer_id = #{customerId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND oo.create_sys_user_id = #{createSysUserId}
- </if>
- )
- order_num
- FROM
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND og.refund_status != 2
- AND og.pay_status != 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND og.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND og.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND og.tenant_id = #{tenantId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND 1=0
- </if>
- <if test="customerId != null and customerId != ''">
- AND og.tenant_id = #{customerId}
- </if>
- </select>
- <select id="getBusinessList" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="string">
- SELECT
- allu.business_name
- FROM
- (
- SELECT
- ouu.business_name,
- IFNULL( SUM( oo.order_received - oo.order_refunded ), 0 ) money
- FROM
- (
- SELECT
- ou.order_sn,
- ou.business_name
- FROM
- (
- SELECT
- `otg`.`order_sn` AS `order_sn`,
- concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
- FROM
- `top_old_order_goods` `otg`
- ) ou
- GROUP BY
- ou.order_sn,
- ou.business_name
- ) ouu
- LEFT JOIN top_old_order oo ON ouu.order_sn = oo.order_sn
- WHERE
- oo.`status` = 1
- AND oo.check_status = 1
- GROUP BY
- ouu.business_name UNION ALL
- SELECT
- nou.business_name,
- SUM( nou.goods_received ) AS money
- FROM
- (
- SELECT
- `og`.`order_sn` AS `order_sn`,
- concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
- og.goods_received
- FROM
- ((((
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- LEFT JOIN `goods` `g` ON ((
- `og`.`goods_id` = `g`.`goods_id`
- )))
- LEFT JOIN `course_education_type` `cet` ON ((
- `g`.`education_type_id` = `cet`.`id`
- )))
- LEFT JOIN `course_project_type` `cpt` ON ((
- `g`.`project_id` = `cpt`.`id`
- )))
- LEFT JOIN `course_business` `cb` ON ((
- `g`.`business_id` = `cb`.`id`
- )))
- WHERE
- og.pay_status != 1
- AND o.org_sign != 1
- AND o.tenant_id IS NOT NULL
- AND og.refund_status != 2
- ) nou
- WHERE
- 1 = 1
- GROUP BY
- nou.business_name
- ) allu
- WHERE
- allu.business_name IS NOT NULL
- GROUP BY
- allu.business_name
- ORDER BY
- SUM( allu.money ) DESC
- </select>
- <select id="getOrderTenant" parameterType="java.lang.String" resultType="java.lang.String">
- SELECT tenant_id FROM top_old_order WHERE old_customer_id = #{customerId} LIMIT 1
- </select>
- <select id="getCustomerList" resultType="com.zhongzheng.modules.top.order.vo.TopOrderCustomerVo">
- SELECT
- too.old_customer_id as customerId,
- ( SELECT purchase_org FROM v_top_order vto WHERE vto.old_customer_id = too.old_customer_id LIMIT 1 ) as customerName
- FROM
- v_top_order too
- WHERE
- too.`status` = 1
- AND too.old_customer_id IS NOT NULL
- GROUP BY
- too.old_customer_id
- </select>
- <select id="getTenantDetailList" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsDetailVo">
- SELECT
- vo.*,
- st.tenant_name
- FROM
- (
- SELECT
- allu.tenant_id,
- ANY_VALUE(allu.order_type) order_type,
- SUM( allu.money2 ) money,
- SUM(order_num2) order_num
- <if test="tenantId != null and tenantId != ''">
- , allu.create_sys_user_id,allu.create_username
- </if>
- FROM
- (
- SELECT
- tenant_id,
- 1 AS order_type,
- SUM( order_received - order_refunded ) money2,
- COUNT( * ) order_num2
- <if test="tenantId != null and tenantId != ''">
- , create_sys_user_id,any_value(create_username) as create_username
- </if>
- FROM
- top_old_order too
- WHERE
- 1 = 1
- AND `status` = 1
- AND check_status = 1
- AND old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND old_customer_id = #{customerId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND too.create_sys_user_id = #{createSysUserId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- count(*)
- FROM
- (
- SELECT
- `otg`.`order_sn` AS `order_sn`,
- concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
- FROM
- `top_old_order_goods` `otg`
- ) ouu
- WHERE
- ouu.order_sn = too.order_sn
- AND ouu.business_name = #{businessName}
- ) >0
- </if>
- AND tenant_id IS NOT NULL
- GROUP BY
- tenant_id
- <if test="tenantId != null and tenantId != ''">
- , create_sys_user_id
- </if>
- UNION ALL
- SELECT
- og.tenant_id,
- 2 AS order_type,
- IFNULL( SUM( og.goods_received ), 0 ) money2,
- COUNT(DISTINCT o.order_sn) order_num2
- <if test="tenantId != null and tenantId != ''">
- ,'' AS create_sys_user_id, '' as create_username
- </if>
- FROM
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND og.refund_status != 2
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND 1=0
- </if>
- <if test="businessName != null and businessName != ''">
- AND (
- SELECT
- count(*)
- FROM
- (
- SELECT
- concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
- g.goods_id
- FROM
- `goods` `g`
- LEFT JOIN `course_education_type` `cet` ON `g`.`education_type_id` = `cet`.`id`
- LEFT JOIN `course_project_type` `cpt` ON `g`.`project_id` = `cpt`.`id`
- LEFT JOIN `course_business` `cb` ON `g`.`business_id` = `cb`.`id`
- ) oug
- WHERE
- oug.goods_id = og.goods_id
- AND oug.business_name = #{businessName}
- )>0
- </if>
- AND o.tenant_id IS NOT NULL
- AND og.pay_status != 1
- GROUP BY
- og.tenant_id
- ) allu
- GROUP BY
- allu.tenant_id
- <if test="tenantId != null and tenantId != ''">
- , allu.create_sys_user_id,allu.create_username
- </if>
- ORDER BY
- tenant_id DESC
- ) vo
- LEFT JOIN sys_tenant st ON vo.tenant_id = st.tenant_id
- </select>
- <select id="getBusinessDetailList" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsDetailVo">
- SELECT
- allu.business_name,
- SUM( allu.money ) money,
- SUM( allu.order_num ) order_num
- FROM
- (
- SELECT
- ouu.business_name,
- IFNULL( SUM( oo.order_received - oo.order_refunded ), 0 ) money,
- 1 AS order_type,
- COUNT( * ) order_num
- FROM
- (
- SELECT
- ou.order_sn,
- ou.business_name
- FROM
- (
- SELECT
- `otg`.`order_sn` AS `order_sn`,
- concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
- FROM
- `top_old_order_goods` `otg`
- ) ou
- GROUP BY
- ou.order_sn,
- ou.business_name
- ) ouu
- LEFT JOIN top_old_order oo ON ouu.order_sn = oo.order_sn
- WHERE
- oo.`status` = 1
- AND oo.check_status = 1
- AND oo.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND oo.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND oo.check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND oo.tenant_id = #{tenantId}
- </if>
- <if test="createNo != null and createNo != ''">
- AND oo.create_no = #{createNo}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND oo.create_sys_user_id = #{createSysUserId}
- </if>
- <if test="businessName != null and businessName != ''">
- AND ouu.business_name = #{businessName}
- </if>
- <if test="customerId != null and customerId != ''">
- AND oo.old_customer_id = #{customerId}
- </if>
- GROUP BY
- ouu.business_name UNION ALL
- SELECT
- nou.business_name,
- SUM( nou.goods_received ) AS money,
- 2 AS order_type,
- COUNT(DISTINCT nou.order_sn ) order_num
- FROM
- (
- SELECT
- `og`.`order_sn` AS `order_sn`,
- concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
- og.goods_received
- FROM
- ((((
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- LEFT JOIN `goods` `g` ON ((
- `og`.`goods_id` = `g`.`goods_id`
- )))
- LEFT JOIN `course_education_type` `cet` ON ((
- `g`.`education_type_id` = `cet`.`id`
- )))
- LEFT JOIN `course_project_type` `cpt` ON ((
- `g`.`project_id` = `cpt`.`id`
- )))
- LEFT JOIN `course_business` `cb` ON ((
- `g`.`business_id` = `cb`.`id`
- )))
- WHERE
- og.pay_status != 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND og.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND og.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND og.tenant_id = #{tenantId}
- </if>
- <if test="createNo != null and createNo != ''">
- AND 1=0
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND 1=0
- </if>
- <if test="customerId != null and customerId != ''">
- AND o.tenant_id = #{customerId}
- </if>
- AND og.refund_status != 2
- ) nou
- WHERE 1=1
- <if test="businessName != null and businessName != ''">
- AND nou.business_name = #{businessName}
- </if>
- GROUP BY
- nou.business_name
- ) allu
- GROUP BY
- allu.business_name
- ORDER BY
- order_num DESC
- </select>
- <select id="getStatisticsTenantView" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsViewBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsTwoVo">
- SELECT
- COUNT(DISTINCT a.order_id) AS orderNum,
- SUM(a.money) AS money,
- any_value(a.timeStr) AS orderTime,
- any_value(a.create_username) AS create_username,
- any_value(a.tenant_name) AS tenant_name,
- <if test="viewSign != null and viewSign == 1">
- DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m-%d') AS timeStr
- </if>
- <if test="viewSign != null and viewSign == 2">
- DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%U') AS timeStr
- </if>
- <if test="viewSign != null and viewSign == 3">
- DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m') AS timeStr
- </if>
- FROM (
- SELECT
- too.order_id as order_id,
- too.check_time as timeStr,
- too.order_received - too.order_refunded as money,
- too.create_username,
- st.tenant_name
- FROM
- top_old_order too LEFT JOIN sys_tenant st ON too.tenant_id = st.tenant_id
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- AND too.old_customer_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="createNo != null and createNo != ''">
- AND too.create_no = #{createNo}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND too.create_sys_user_id = #{createSysUserId}
- </if>
- UNION ALL
- SELECT
- o.order_id as order_id,
- o.create_time as timeStr,
- og.goods_received as money,
- null as create_username,
- st.tenant_name
- FROM
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- LEFT JOIN sys_tenant st ON o.tenant_id = st.tenant_id
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND og.refund_status != 2
- AND og.pay_status != 1
- AND o.org_sign != 1
- <if test="startTime != null and startTime != ''">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND o.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND 1=0
- </if>
- ) a WHERE 1=1
- <if test="viewSign != null and viewSign == 1">
- GROUP BY DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m-%d')
- </if>
- <if test="viewSign != null and viewSign == 2">
- GROUP BY DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%U')
- </if>
- <if test="viewSign != null and viewSign == 3">
- GROUP BY DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m')
- </if>
- ORDER BY timeStr
- </select>
- <select id="getStatisticsBusinessView" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsViewBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsTwoVo">
- SELECT
- COUNT(a.order_sn) AS orderNum,
- SUM(a.money) AS money,
- any_value(a.timeStr) AS orderTime,
- any_value(a.create_username) AS create_username,
- any_value(a.tenant_name) AS tenant_name,
- <if test="viewSign != null and viewSign == 1">
- DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m-%d') AS timeStr
- </if>
- <if test="viewSign != null and viewSign == 2">
- DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%U') AS timeStr
- </if>
- <if test="viewSign != null and viewSign == 3">
- DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m') AS timeStr
- </if>
- FROM (
- SELECT
- too.order_sn,
- concat(
- substr(( SELECT otg.business_full_name FROM `top_old_order_goods` `otg` WHERE otg.order_sn = too.order_sn LIMIT 1 ), 5, 4 ),
- '-',(
- SELECT
- otg.business_name
- FROM
- `top_old_order_goods` `otg`
- WHERE
- otg.order_sn = too.order_sn
- LIMIT 1
- )
- ) AS `business_name`,
- too.order_received - too.order_refunded AS money,
- too.check_time as timeStr,
- too.create_username,
- st.tenant_name
- FROM
- top_old_order too
- LEFT JOIN sys_tenant st ON too.tenant_id = st.tenant_id
- WHERE
- too.`status` = 1
- AND too.check_status = 1
- <if test="startTime != null and startTime != ''">
- AND too.check_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND too.check_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND too.create_sys_user_id = #{createSysUserId}
- </if>
- UNION ALL
- SELECT
- `og`.`order_sn` AS `order_sn`,
- concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
- og.goods_received as money,
- og.create_time as timeStr,
- null as create_username,
- st.tenant_name
- FROM
- ((((
- `order` o
- LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
- LEFT JOIN sys_tenant st ON o.tenant_id = st.tenant_id
- LEFT JOIN `goods` `g` ON ((
- `og`.`goods_id` = `g`.`goods_id`
- )))
- LEFT JOIN `course_education_type` `cet` ON ((
- `g`.`education_type_id` = `cet`.`id`
- )))
- LEFT JOIN `course_project_type` `cpt` ON ((
- `g`.`project_id` = `cpt`.`id`
- )))
- LEFT JOIN `course_business` `cb` ON ((
- `g`.`business_id` = `cb`.`id`
- )))
- WHERE
- og.pay_status != 1
- AND o.org_sign != 1 AND o.tenant_id IS NOT NULL
- <if test="startTime != null and startTime != ''">
- AND og.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND og.create_time <= #{endTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND og.tenant_id = #{tenantId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND 1=0
- </if>
- <if test="customerId != null and customerId != ''">
- AND og.tenant_id = #{customerId}
- </if>
- AND og.refund_status != 2
- ) a WHERE 1=1
- <if test="businessName != null and businessName != ''">
- AND a.business_name = #{businessName}
- </if>
- <if test="viewSign != null and viewSign == 1">
- GROUP BY DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m-%d')
- </if>
- <if test="viewSign != null and viewSign == 2">
- GROUP BY DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%U')
- </if>
- <if test="viewSign != null and viewSign == 3">
- GROUP BY DATE_FORMAT(FROM_UNIXTIME(a.timeStr), '%Y-%m')
- </if>
- </select>
- <select id="getTenantCreateList" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsViewBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsTwoVo">
- SELECT
- create_username,
- create_sys_user_id
- FROM
- top_old_order
- WHERE
- 1=1
- <if test="tenantId != null and tenantId != ''">
- AND tenant_id = #{tenantId}
- </if>
- AND create_sys_user_id IS NOT NULL
- GROUP BY
- create_sys_user_id,
- create_username
- </select>
- </mapper>
|