From 3a6ac2949244e6a3f70e165cd3802f1d90b78819 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期四, 24 十月 2024 11:20:41 +0800 Subject: [PATCH] 格式化SQL语句 --- pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml | 68 +++++++++++++++++++++++++-------- 1 files changed, 51 insertions(+), 17 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 785e7b2..9499940 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> <!--鏍规嵁浜ゆ槗鏃ユ湡鑾峰彇鎬昏处璁板綍鍒楄〃锛堝緟鐢熸垚鐨勶級 --> @@ -198,7 +200,7 @@ </if> <if test = "auditStatus != null and auditStatus > 0"> - AND audit_status = ${auditStatus} + AND audit_status = #{auditStatus} </if> <if test = "operateDateStart != null and operateDateStop != null"> @@ -210,17 +212,18 @@ <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇鎬昏处璁板綍--> <select id="getGenerals" resultType="com.dy.pipIrrGlobal.voSe.VoGeneral"> SELECT - CAST(id AS char) AS generalId, - CAST(cashier_id AS char) AS cashierId, + id AS generalId, + cashier_id AS cashierId, cashier_name AS cashierName, trade_amount AS tradeAmount, gift, refund_amount AS refundAmount, + (trade_amount + gift - refund_amount) AS totalAmount, Date(operate_date) AS operateDate, (CASE - WHEN audit_status = 1 THEN "鏈鏍�" - WHEN audit_status = 2 THEN "鍚屾剰" - WHEN audit_status = 3 THEN "椹冲洖" + WHEN audit_status = 1 THEN '鏈鏍�' + WHEN audit_status = 2 THEN '鍚屾剰' + WHEN audit_status = 3 THEN '椹冲洖' END) AS auditStatus FROM se_general <where> @@ -229,7 +232,7 @@ </if> <if test = "auditStatus != null and auditStatus > 0"> - AND audit_status = ${auditStatus} + AND audit_status = #{auditStatus} </if> <if test = "operateDateStart != null and operateDateStop != null"> @@ -247,22 +250,23 @@ <!--鑾峰彇鎸囧畾鏃ユ湡銆佹寚瀹氭敹閾跺憳銆佹寚瀹氭敮浠樻柟寮忓疄鏀堕噾棰濆悎璁�--> <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> <if test = "paymentId != null and paymentId >0"> - AND ope.payment_id = ${paymentId} + AND ope.payment_id = #{paymentId} </if> <if test = "cashierId != null and cashierId >0"> - AND ope.operator = ${cashierId} + 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> <!-- 璐㈠姟瀵硅处瀹℃牳椤碉紝鏀堕摱鍛�+鏃ユ湡鍒嗙粍锛屾帓闄や氦鏄撶被鍨嬪垎缁勶紝璁板綍鏁�--> @@ -283,17 +287,47 @@ <!--寮�鍗$郴缁熶氦鏄撶粺璁★紝鏀堕摱鍛�+鏃ユ湡+绫诲瀷鍒嗙粍--> <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 '杩旇繕' + 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) + 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鍙婃棩鏈熻幏鍙栬储鍔″璐浜ゆ槗鏄庣粏璁板綍鏁�--> @@ -303,7 +337,7 @@ FROM v_trade_details <where> <if test = "cashierId != null and cashierId > 0"> - AND cashierId = ${cashierId} + AND cashierId = #{cashierId} </if> <if test = "tradeDate != null"> @@ -317,7 +351,7 @@ SELECT * FROM v_trade_details <where> <if test = "cashierId != null and cashierId > 0"> - AND cashierId = ${cashierId} + AND cashierId = #{cashierId} </if> <if test = "tradeDate != null"> -- Gitblit v1.8.0