| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234 |
- <?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="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="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="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="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="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="java.lang.String">
- 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>
- GROUP BY
- too.old_customer_id UNION ALL
- SELECT
- SUM( o.order_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>
- 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.order_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>
- 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>
- 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="java.lang.Long"
- resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsDetailTotalVo">
- 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.order_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>
- )) 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>
- ) + (
- 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>
- )) 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.order_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="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.order_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="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_no,allu.create_username
- </if>
- FROM
- (
- SELECT
- tenant_id,
- SUM( order_received - order_refunded ) money2
- <if test="tenantId != null and tenantId != ''">
- , create_no,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_no
- </if>
- UNION ALL
- SELECT
- og.tenant_id,
- IFNULL( SUM( og.goods_received ), 0 ) money2
- <if test="tenantId != null and tenantId != ''">
- ,'' AS create_no, '' 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_no,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="createNo != null and createNo != ''">
- AND 1=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="createNo != null and createNo != ''">
- AND vo.create_no = #{createNo}
- </if>
- <if test="customerId != null and customerId != ''">
- AND vo.tenant_id = #{customerId}
- </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_no,allu.create_username
- </if>
- FROM
- (
- SELECT
- tenant_id,
- COUNT( * ) order_num2
- <if test="tenantId != null and tenantId != ''">
- , create_no,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_no
- </if>
- UNION ALL
- SELECT
- og.tenant_id,
- COUNT( * ) order_num2
- <if test="tenantId != null and tenantId != ''">
- ,'' AS create_no, '' 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_no,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="createNo != null and createNo != ''">
- 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="createNo != null and createNo != ''">
- AND create_no = #{createNo}
- </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.tenant_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="createNo != null and createNo != ''">
- AND oo.create_no = #{createNo}
- </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="createNo != null and createNo != ''">
- 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( ouu.order_goods_id ),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="createNo != null and createNo != ''">
- AND oo.create_no = #{createNo}
- </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( nou.order_goods_id ) 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="createNo != null and createNo != ''">
- AND 1=0
- </if>
- ) nou
- GROUP BY
- nou.business_name
- ) allu
- 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>
- )
- 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="createNo != null and createNo != ''">
- 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_no,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_no,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>
- AND tenant_id IS NOT NULL
- GROUP BY
- tenant_id
- <if test="tenantId != null and tenantId != ''">
- , create_no
- </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_no, '' 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 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_no,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="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,
- 2 AS order_type,
- COUNT( * ) 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="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="getStatisticsTenantView" 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,
- 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
- <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>
- UNION ALL
- SELECT
- o.order_id as order_id,
- o.create_time as timeStr,
- o.order_price as money,
- null as create_username,
- st.tenant_name
- FROM
- `order` o
- LEFT JOIN sys_tenant st ON o.tenant_id = st.tenant_id
- 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="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="createNo != null and createNo != ''">
- AND o.create_no = #{createNo}
- </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="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="createNo != null and createNo != ''">
- AND too.create_no = #{createNo}
- </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="createNo != null and createNo != ''">
- 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_no,
- create_username
- FROM
- top_old_order
- WHERE
- 1=1
- <if test="tenantId != null and tenantId != ''">
- AND tenant_id = #{tenantId}
- </if>
- AND create_no IS NOT NULL
- GROUP BY
- create_no,
- create_username
- </select>
- </mapper>
|