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/WalletReduceMapper.xml | 66 ++++++++++++++++++++++++++++++--
1 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/src/main/resources/mapper/wallet/WalletReduceMapper.xml b/src/main/resources/mapper/wallet/WalletReduceMapper.xml
index fd03188..de9febc 100644
--- a/src/main/resources/mapper/wallet/WalletReduceMapper.xml
+++ b/src/main/resources/mapper/wallet/WalletReduceMapper.xml
@@ -52,8 +52,8 @@
on oi.order_id=o.id
left join t_code_value check_type
on check_type.value=oic.type and check_type.type_code='CHECK_TYPE'
- where
- o.deleted=0
+ where o.deleted=0
+ and oic.type in ('lack','replace')
and o.status_backend not in ('PENDING','CANCEL','REFUND')
and oic.deleted=0 and oic.audit_status='AGREED' and oi.deleted=0 and o.deleted=0
and o.payment_time >= #{dto.walletOnlineTime}
@@ -72,11 +72,48 @@
<if test="dto.endDate != null">
and DATE_FORMAT(o.payment_time, '%Y-%m-%d') <= #{dto.endDate}
</if>
+ union
+ select oic.id as id ,
+ oic.deduct_amount AS fee,
+ oic.audit_time AS audit_time,
+ o.payment_time as payment_time,
+ oic.type as type,
+ check_type.label as type_name,
+ o.order_no as order_no,
+ oi.supplier_id as supplier_id
+ from t_order_item_check oic
+ left join t_order_item oi
+ on oic.order_item_id=oi.id
+ left join t_order o
+ on oi.order_id=o.id
+ left join t_code_value check_type
+ on check_type.value=oic.type and check_type.type_code='CHECK_TYPE'
+ where o.deleted=0
+ and oic.type in ('reduce')
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oic.deleted=0 and oic.audit_status='AGREED' and oi.deleted=0 and o.deleted=0
+ and o.payment_time >= #{dto.walletOnlineTime}
+ <if test="dto.supplierId != null">
+ and oi.supplier_id = #{dto.supplierId}
+ </if>
+ <!-- <if test="dto.startDate != null">-->
+ <!-- and DATE_FORMAT(oic.audit_time, '%Y-%m-%d') >= #{dto.startDate}-->
+ <!-- </if>-->
+ <!-- <if test="dto.endDate != null">-->
+ <!-- and DATE_FORMAT(oic.audit_time, '%Y-%m-%d') <= #{dto.endDate}-->
+ <!-- </if>-->
+ <if test="dto.startDate != null">
+ and DATE_FORMAT(o.payment_time, '%Y-%m-%d') >= #{dto.startDate}
+ </if>
+ <if test="dto.endDate != null">
+ and DATE_FORMAT(o.payment_time, '%Y-%m-%d') <= #{dto.endDate}
+ </if>
+
) t
order by audit_time desc
</select>
- <select id="getCheckReduceAmount" resultType="java.math.BigDecimal">
+ <select id="getCheckLackReplaceAmount" resultType="java.math.BigDecimal">
select sum(oic.num*oi.supplier_price)
from t_order_item_check oic
left join t_order_item oi
@@ -86,6 +123,7 @@
left join t_code_value check_type
on check_type.value=oic.type and check_type.type_code='CHECK_TYPE'
where o.deleted=0
+ and oic.type in ('lack','replace')
and o.status_backend not in ('PENDING','CANCEL','REFUND')
and oic.deleted=0 and oic.audit_status='AGREED' and oi.deleted=0 and o.deleted=0
and oi.supplier_id = #{dto.supplierId}
@@ -103,15 +141,33 @@
and oi.supplier_id = #{dto.supplierId}
and o.payment_time >= #{dto.startTime}
</select>
+
<select id="getStationFeeAmount" resultType="java.math.BigDecimal">
SELECT sum(ois.station_fee)
FROM t_order_item_settlement ois
- join t_order_item oi on oi.id = ois.order_item_id
- left join t_order o on oi.order_id=o.id
+ join t_order_item oi on oi.id = ois.order_item_id
+ left join t_order o on oi.order_id=o.id
where o.deleted=0
and o.status_backend not in ('PENDING','CANCEL','REFUND')
and ois.deleted=0 and oi.deleted=0
and oi.supplier_id = #{dto.supplierId}
and o.payment_time >= #{dto.startTime}
</select>
+ <select id="getCheckReduceAmount" resultType="java.math.BigDecimal">
+ select sum(oic.deduct_amount)
+ from t_order_item_check oic
+ left join t_order_item oi
+ on oic.order_item_id=oi.id
+ left join t_order o
+ on oi.order_id=o.id
+ left join t_code_value check_type
+ on check_type.value=oic.type and check_type.type_code='CHECK_TYPE'
+ where o.deleted=0
+ and oic.type in ('reduce')
+ and o.status_backend not in ('PENDING','CANCEL','REFUND')
+ and oic.deleted=0 and oic.audit_status='AGREED' and oi.deleted=0 and o.deleted=0
+ and oi.supplier_id = #{dto.supplierId}
+ and o.payment_time >= #{dto.startTime}
+
+ </select>
</mapper>
--
Gitblit v1.9.3