From d81d4ff55fb4a47745cd521a27426b9f81cc8f9a Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期一, 21 十月 2024 16:53:49 +0800
Subject: [PATCH] 1.小程序-供应商:统计-新增本月售后订单,本月售后扎数,总成交扎数

---
 src/main/resources/mapper/report/OrderReportMapper.xml |   43 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/src/main/resources/mapper/report/OrderReportMapper.xml b/src/main/resources/mapper/report/OrderReportMapper.xml
index 783a239..c1a53c1 100644
--- a/src/main/resources/mapper/report/OrderReportMapper.xml
+++ b/src/main/resources/mapper/report/OrderReportMapper.xml
@@ -607,11 +607,17 @@
         , ( <include refid="cur_mon_replace_num"></include> ) as cur_mon_replace_num
         , (	<include refid="last_mon_replace_num"></include> ) as last_mon_replace_num
 
+        , (	<include refid="all_supplier_flower_num"></include> ) as all_supplier_flower_num
+        , (	<include refid="cur_mon_after_sale_order_num"></include> ) as cur_mon_after_sale_order_num
+        , (	<include refid="cur_mon_after_sale_flower_num"></include> ) as cur_mon_after_sale_flower_num
+
     </select>
 
     <!--供应商总价款-->
     <sql id="all_supplier_amount">
-        select IFNULL(sum(oi.supplier_price*oi.num),0) as supplier_amount from t_order_item oi where oi.supplier_id=287
+        select IFNULL(sum(oi.supplier_price*oi.num),0) as supplier_amount
+        from t_order_item oi
+        where oi.supplier_id= #{dto.supplierId}
     </sql>
     <!--本月成交:本月售卖的底价合计-->
     <sql id="cur_mon_supplier_amount">
@@ -723,4 +729,39 @@
         and o.payment_time &lt;= DATE_FORMAT(DATE_SUB(DATE_FORMAT(CURRENT_DATE(), '%Y-%m-01'), INTERVAL 1 DAY), '%Y-%m-%d 17:00:00')
     </sql>
 
+    <!-- 总成交扎数-->
+    <sql id="all_supplier_flower_num">
+        select IFNULL(sum(oi.num),0) as all_supplier_flower_num
+        from t_order_item oi
+        where oi.supplier_id= #{dto.supplierId}
+    </sql>
+
+    <!-- 本月售后订单-->
+    <sql id="cur_mon_after_sale_order_num">
+        select IFNULL(count(distinct o.id),0) as cur_mon_after_sale_order_num
+        from t_order_item oi
+        left join t_order_item_sales ois
+        on oi.id=ois.order_item_id
+        left join t_order o
+        on oi.order_id = o.id
+        where oi.deleted=0 and ois.DELETEd=0 and ois.STATUS='AGREED'
+        and oi.supplier_id=#{dto.supplierId}
+        and o.payment_time &gt; DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
+        and o.payment_time &lt;= DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
+
+    </sql>
+
+    <!-- 本月售后扎数-->
+    <sql id="cur_mon_after_sale_flower_num">
+        select IFNULL(sum(ois.num),0) as cur_mon_after_sale_flower_num
+        from t_order_item oi
+        left join t_order_item_sales ois
+        on oi.id=ois.order_item_id
+        left join t_order o
+        on oi.order_id = o.id
+        where oi.deleted=0 and ois.DELETEd=0 and ois.STATUS='AGREED'
+          and oi.supplier_id=#{dto.supplierId}
+          and o.payment_time &gt; DATE_FORMAT(LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH)), '%Y-%m-%d 17:00:00')
+          and o.payment_time &lt;= DATE_FORMAT(LAST_DAY(CURRENT_DATE()), '%Y-%m-%d 17:00:00')
+    </sql>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3