| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485 |
- <?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="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.create_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="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 (
- isnull( `o`.`input_order_sn` )
- OR (
- NOT (
- `o`.`input_order_sn` IN ( SELECT `top_old_order`.`input_order_sn` FROM `top_old_order` ))))
- <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="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="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="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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) = 0 ) 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,cpt.project_name,cb.business_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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) = 0 ) 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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) = 0 ) 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,cpt.project_name,cb.business_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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) = 0 ) 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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) = 0 ) 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,cpt.project_name,cb.business_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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) = 0 ) 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,cpt.project_name,cb.business_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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) = 0
- )
- <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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) = 0 ) 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,cpt.project_name,cb.business_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 tenant_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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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="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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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`.`education_type_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
- AND vo.check_time BETWEEN #{startTime}
- AND #{endTime}
- <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.tenant_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 tenant_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( * ) 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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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( * ),0)+(
- SELECT
- IFNULL(COUNT(o.order_id),0) AS orderNum
- FROM
- `order` o
- WHERE
- o.`status` = 1
- AND o.order_status = 1
- AND (
- o.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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>
- ))
- 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 tenant_id = #{customerId}
- </if>
- <if test="createSysUserId != null and createSysUserId != ''">
- AND create_sys_user_id = #{createSysUserId}
- </if>
- </select>
- <select id="getNumStatisticsTotalWithBo" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
- resultType="java.lang.Long">
- 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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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>
- )) 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.tenant_id = #{customerId}
- </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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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>
- ) 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>
- </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.tenant_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`.`education_type_id` = `cpt`.`id`
- )))
- LEFT JOIN `course_business` `cb` ON ((
- `g`.`business_id` = `cb`.`id`
- )))
- WHERE
- og.pay_status != 1
- AND (
- o.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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.tenant_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`.`education_type_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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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( og.order_goods_id ),0)+ (
- SELECT
- IFNULL(COUNT( otg.order_goods_id ),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.tenant_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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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`.`education_type_id` = `cpt`.`id`
- )))
- LEFT JOIN `course_business` `cb` ON ((
- `g`.`business_id` = `cb`.`id`
- )))
- WHERE
- og.pay_status != 1
- AND (
- o.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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.Long" resultType="java.lang.Long">
- 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( * ) 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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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.old_customer_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`.`education_type_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`.`education_type_id` = `cpt`.`id`
- )))
- LEFT JOIN `course_business` `cb` ON ((
- `g`.`business_id` = `cb`.`id`
- )))
- WHERE
- og.pay_status != 1
- AND (
- o.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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.old_customer_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="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.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) = 0
- )
- <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`.`education_type_id` = `cpt`.`id`
- )))
- LEFT JOIN `course_business` `cb` ON ((
- `g`.`business_id` = `cb`.`id`
- )))
- WHERE
- og.pay_status != 1
- AND (
- o.input_order_sn IS NULL
- OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 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>
|