From 5ff8fb8bd9d298def47437b24e77c8879cdc37d2 Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期四, 14 十一月 2024 09:36:39 +0800
Subject: [PATCH] 1.定时任务-待付款-15分钟 2.领券中心:根据领取次数判断是否已领取 3.付款:优惠券自动领取最大优惠券
---
src/main/resources/mapper/wallet/WalletMapper.xml | 55 ++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 38 insertions(+), 17 deletions(-)
diff --git a/src/main/resources/mapper/wallet/WalletMapper.xml b/src/main/resources/mapper/wallet/WalletMapper.xml
index 9131387..3e88bfa 100644
--- a/src/main/resources/mapper/wallet/WalletMapper.xml
+++ b/src/main/resources/mapper/wallet/WalletMapper.xml
@@ -23,9 +23,7 @@
</resultMap>
<select id="getWaittingSettlementAmount" resultType="java.math.BigDecimal">
- <!-- <include refid="supplier_settlement_amount"></include>-->
- <include refid="supplier_settlement_amount_timing"></include>
-
+ <include refid="supplier_settlement_amount_timing3"></include>
</select>
<!-- 总交易额-->
@@ -42,16 +40,6 @@
<!-- 待结算-->
- <sql id="supplier_settlement_amount">
- SELECT IFNULL(sum(settlement_amount),0) AS settlement_amount
- FROM t_order_settlement OS
- WHERE OS.DELETED=0
- AND OS.TYPE='supplier'
- AND OS.status='PENDING'
- AND USER_ID=#{dto.userId}
- </sql>
-
-
<sql id="supplier_settlement_amount_timing">
select
sum(t2.final_price) as settlement_amount
@@ -60,8 +48,7 @@
t.order_item_id,
t.supplier_id,
t.supplier_price,
- t.num-t.reduce_num-t.replace_num-t.lack_num as final_num,
- t.supplier_price*(t.num-t.reduce_num-t.replace_num-t.lack_num )-t.fee_supplier-t.station_fee as final_price,
+ t.supplier_price*(t.num-t.replace_num-t.lack_num )- t.deduct_amount -t.fee_supplier-t.station_fee as final_price,
t.fee_supplier,
t.station_fee
from (
@@ -72,7 +59,42 @@
o.payment_time,
oi.supplier_price,
oi.num as num,
- IFNULL( (select oic.num from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'reduce' and oic.audit_status='AGREED'),0) as reduce_num,
+ IFNULL( (select oic.deduct_amount from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'reduce' and oic.audit_status='AGREED'),0) as deduct_amount,
+ IFNULL( (select oic.num from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'replace' and oic.audit_status='AGREED'),0) as replace_num,
+ IFNULL( (select oic.num from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'lack' and oic.audit_status='AGREED'),0) as lack_num,
+ IFNULL( (select ois.fee_supplier from t_order_item_sales ois where ois.deleted=0 and ois.order_item_id = oi.id and ois.status='AGREED'),0) as fee_supplier,
+ IFNULL( (select ois.station_fee from t_order_item_settlement ois where ois.deleted=0 and ois.order_item_id = oi.id ),0) as station_fee
+ FROM t_order_item oi
+ LEFT JOIN t_order o ON oi.order_id = o.id
+ WHERE o.deleted=0
+ and o.status_backend not in ('PENDING','CANCEL','REFUND','COMPLETED','EVALUATE')
+ and oi.supplier_id = #{dto.supplierId}
+ ) t
+ ) t2
+
+
+ </sql>
+
+ <sql id="supplier_settlement_amount_timing3">
+ select
+ sum(t2.final_price) as settlement_amount
+ from(
+ select
+ t.order_item_id,
+ t.supplier_id,
+ t.supplier_price,
+ t.supplier_price*(t.num-t.replace_num-t.lack_num )- t.deduct_amount -t.fee_supplier-t.station_fee as final_price,
+ t.fee_supplier,
+ t.station_fee
+ from (
+ SELECT
+ o.order_no,
+ oi.id as order_item_id,
+ oi.supplier_id,
+ o.payment_time,
+ oi.supplier_price,
+ oi.num as num,
+ IFNULL( (select oic.deduct_amount from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'reduce' and oic.audit_status='AGREED'),0) as deduct_amount,
IFNULL( (select oic.num from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'replace' and oic.audit_status='AGREED'),0) as replace_num,
IFNULL( (select oic.num from t_order_item_check oic where oic.deleted=0 and oic.order_item_id = oi.id and oic.type = 'lack' and oic.audit_status='AGREED'),0) as lack_num,
IFNULL( (select ois.fee_supplier from t_order_item_sales ois where ois.deleted=0 and ois.order_item_id = oi.id and ois.status='AGREED'),0) as fee_supplier,
@@ -84,7 +106,6 @@
and oi.supplier_id = #{dto.supplierId}
) t
) t2
-
</sql>
</mapper>
--
Gitblit v1.9.3