From 1a2b07f01ba4616fd9e894dddf474b56d020158c Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 07 四月 2025 15:18:51 +0800
Subject: [PATCH] 整理版本

---
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml |   55 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml
index 977aa19..fbed989 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml
@@ -140,7 +140,9 @@
     SELECT
       DISTINCT Date(ope.operate_dt) AS operateDate
     FROM se_card_operate ope
-    WHERE Date(ope.operate_dt) NOT IN(SELECT operate_date FROM se_general) AND Date(ope.operate_dt) != CURDATE()
+    WHERE Date(ope.operate_dt) NOT IN(SELECT operate_date FROM se_general)
+<!--      鍙栨秷褰撳ぉ闄愬埗-->
+<!--      AND Date(ope.operate_dt) != CURDATE()-->
   </select>
 
   <!--鏍规嵁浜ゆ槗鏃ユ湡鑾峰彇鎬昏处璁板綍鍒楄〃锛堝緟鐢熸垚鐨勶級  -->
@@ -155,7 +157,7 @@
         1 AS auditStatus
     FROM se_card_operate ope
         INNER JOIN ba_user us ON ope.operator = us.id
-    WHERE Date(ope.operate_dt) = #{operateDate}
+    WHERE Date(ope.operate_dt) = #{operateDate} AND ope.operate_valid = 2
     GROUP BY ope.operator, Date(ope.operate_dt)
 
     UNION ALL
@@ -216,7 +218,7 @@
         trade_amount AS tradeAmount,
         gift,
         refund_amount AS refundAmount,
-        (trade_amount + gift + refund_amount) AS totalAmount,
+        (trade_amount + gift - refund_amount) AS totalAmount,
         Date(operate_date) AS operateDate,
         (CASE
           WHEN audit_status = 1 THEN '鏈鏍�'
@@ -248,9 +250,10 @@
   <!--鑾峰彇鎸囧畾鏃ユ湡銆佹寚瀹氭敹閾跺憳銆佹寚瀹氭敮浠樻柟寮忓疄鏀堕噾棰濆悎璁�-->
   <select id="getPaymentSums" resultType="java.lang.Float">
     SELECT
-    SUM(ope.trade_amount) AS tradeAmount
+        (SUM(ope.trade_amount) + SUM(ope.card_cost)) AS tradeAmount
     FROM se_card_operate ope
     <where>
+      AND ope.operate_valid = 2
       <if test = "tradeDate != null and tradeDate !=''">
         AND Date(ope.operate_dt) = #{tradeDate}
       </if>
@@ -263,7 +266,7 @@
         AND ope.operator = #{cashierId}
       </if>
     </where>
-    GROUP BY ope.payment_id,  Date(ope.operate_dt)
+<!--    GROUP BY ope.payment_id,  Date(ope.operate_dt)-->
   </select>
 
   <!--  璐㈠姟瀵硅处瀹℃牳椤碉紝鏀堕摱鍛�+鏃ユ湡鍒嗙粍锛屾帓闄や氦鏄撶被鍨嬪垎缁勶紝璁板綍鏁�-->
@@ -284,17 +287,48 @@
 
   <!--寮�鍗$郴缁熶氦鏄撶粺璁★紝鏀堕摱鍛�+鏃ユ湡+绫诲瀷鍒嗙粍-->
   <select id="getSummaries" resultType="com.dy.pipIrrGlobal.voSe.VoTransactionStatistics">
-    SELECT * FROM v_trade_summary
+    SELECT
+        CASE
+            WHEN ope.operate_type = 1 THEN '寮�鍗�'
+            WHEN ope.operate_type = 2 THEN '鍏呭��'
+            WHEN ope.operate_type = 3 THEN '閿�鍗�'
+            WHEN ope.operate_type = 4 THEN '琛ュ崱'
+            WHEN ope.operate_type = 5 THEN '杩旇繕'
+            WHEN ope.operate_type = 10 THEN '鍙嶅啓'
+        END AS operateType,
+        Date(ope.operate_dt) AS tradeDate,
+        COUNT(*) AS count,
+        (IFNULL(SUM(ope.trade_amount), 0) + IFNULL(SUM(ope.card_cost), 0)) AS received,
+        IFNULL(SUM(ope.gift), 0) AS gift,
+        IFNULL(sum(ope.refund_amount),0) AS refundAmount,
+        us.id AS cashierId
+    FROM se_card_operate ope
+        INNER JOIN ba_user us ON us.id = ope.operator
     <where>
+      AND ope.operate_type IN(1,2,3,4,5,10)
+      AND ope.operate_valid = 2
       <if test = "cashierId != null and cashierId > 0">
-        AND cashierId = #{cashierId}
+        AND us.id = #{cashierId}
       </if>
 
       <if test = "timeStart != null and timeStop != null">
-        AND Date(tradeDate) BETWEEN #{timeStart} AND #{timeStop}
+        AND Date(ope.operate_dt) BETWEEN #{timeStart} AND #{timeStop}
       </if>
     </where>
+    GROUP BY ope.operate_type,  Date(ope.operate_dt), us.id
     ORDER BY tradeDate
+
+<!--    SELECT * FROM v_trade_summary-->
+<!--    <where>-->
+<!--      <if test = "cashierId != null and cashierId > 0">-->
+<!--        AND cashierId = #{cashierId}-->
+<!--      </if>-->
+
+<!--      <if test = "timeStart != null and timeStop != null">-->
+<!--        AND Date(tradeDate) BETWEEN #{timeStart} AND #{timeStop}-->
+<!--      </if>-->
+<!--    </where>-->
+<!--    ORDER BY tradeDate-->
   </select>
 
   <!--  鏍规嵁鏀堕摱鍛業D鍙婃棩鏈熻幏鍙栬储鍔″璐浜ゆ槗鏄庣粏璁板綍鏁�-->
@@ -332,4 +366,9 @@
       </if>
     </trim>
   </select>
+  <!-- 鍒犻櫎浠婂ぉ鐨勬�昏处-->
+  <delete id="deleteTodayGeneral">
+    DELETE FROM se_general
+    WHERE operate_date = DATE(NOW())
+  </delete>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0