报表相关 增加退款后,报表中需要体现

This commit is contained in:
wyn
2026-06-18 17:37:43 +08:00
parent 156862a0c5
commit 7dc1241064
23 changed files with 1162 additions and 155 deletions

View File

@@ -41,13 +41,82 @@
</select>
<select id="getIncome" resultType="map">
select ucbl.pay_type,SUM(ucbl.fee) fee
from user_course_buy_log ucbl
left join buy_order bo on bo.order_sn = ucbl.order_sn
where DATE_FORMAT(ucbl.pay_time,'%Y-%m') = SUBSTR(#{date},1,7) and ucbl.del_flag = 0
and (ucbl.user_id not in (select id from user where tester_flag = 1) or ( ucbl.user_id in (select id from user where tester_flag = 1) and ucbl.pay_type in ('微信','支付宝') and ucbl.create_time>='2026-05-06 00:00:00'))
GROUP BY ucbl.pay_type
</select>
<select id="getRefund" resultType="map">
select pay_type,SUM(fee) fee
from user_course_buy_log
where DATE_FORMAT(pay_time,'%Y-%m') = SUBSTR(#{date},1,7) and del_flag = 0
and user_id not in (select id from user where tester_flag = 1)
from (
select IF(bo.payment_method='1','App微信',IF(bo.payment_method='2','App支付宝',IF(bo.payment_method='4','App天医币','其他'))) pay_type,
bor.fee
from buy_order_refund bor
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
where bo.order_status = '6'
and DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
and (bo.user_id not in (select id from user where tester_flag = 1)
or (bo.user_id in (select id from user where tester_flag = 1) and bo.payment_method in ('1','2') and bo.create_time>='2026-05-06 00:00:00'))
and exists (
select 1 from buy_order_product bop
inner join shop_product sp on sp.product_id = bop.product_id
where bop.order_id = bo.order_id and sp.goods_type = '05'
)
) t
GROUP BY pay_type
</select>
<select id="getSameMonthRefund" resultType="map">
select pay_type,SUM(fee) fee
from (
select IF(bo.payment_method='1','微信',IF(bo.payment_method='2','支付宝',IF(bo.payment_method='4','天医币','其他'))) pay_type,
bor.fee
from buy_order_refund bor
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
where bo.order_status = '6'
and DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
and DATE_FORMAT(IF(bo.success_time is null,bo.create_time,bo.success_time),'%Y-%m') = SUBSTR(#{date},1,7)
and (bo.user_id not in (select id from user where tester_flag = 1)
or (bo.user_id in (select id from user where tester_flag = 1) and bo.payment_method in ('1','2') and bo.create_time>='2026-05-06 00:00:00'))
and exists (
select 1 from buy_order_product bop
inner join shop_product sp on sp.product_id = bop.product_id
where bop.order_id = bo.order_id and sp.goods_type = '05'
)
) t
GROUP BY pay_type
</select>
<select id="getRefundInfo" resultType="map">
select IFNULL(bor.wx_refund_no,bor.refund_no) as refund_no,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,
IFNULL(c.title,IFNULL(sp.product_name,'')) ctitle,IFNULL(cc.title,'') cctitle,
IFNULL(spc.days,0) totalDays,'' startTime,'' endTime,
IF(bo.order_type='relearn','复读','order') type,
IF(bo.payment_method='1','微信',IF(bo.payment_method='2','支付宝',IF(bo.payment_method='4','天医币','其他'))) payType,
DATE_FORMAT(IF(bo.success_time is null,bo.create_time,bo.success_time),'%Y-%m-%d %H:%i:%s') payTime,
bo.order_sn orderSn,pzo.trade_no zfbOrder,
0 beginDay,IFNULL(spc.days,0) days,
ROUND(bor.fee/(select count(1) from buy_order_product bop2
inner join shop_product sp2 on sp2.product_id = bop2.product_id
where bop2.order_id = bo.order_id and sp2.goods_type = '05'),2) fee,
if(bo.remark like '%退%',bo.remark,if(bor.remark is null,'',bor.remark)) remark,
DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') refundTime,
'已退款' orderStatus
from buy_order_refund bor
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
inner join buy_order_product bop on bop.order_id = bo.order_id
inner join shop_product sp on sp.product_id = bop.product_id and sp.goods_type = '05'
left join shop_product_course spc on spc.product_id = sp.product_id and spc.del_flag = 0
left join course c on c.id = spc.course_id
left join course_catalogue cc on cc.id = spc.catalogue_id
left join user u on u.id = bo.user_id
left join pay_zfb_order pzo on pzo.relevanceOid = bo.order_sn and pzo.trade_no is not null
where bo.order_status = '6'
and DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
and (bo.user_id not in (select id from user where tester_flag = 1)
or (bo.user_id in (select id from user where tester_flag = 1) and bo.payment_method in ('1','2') and bo.create_time>='2026-05-06 00:00:00'))
order by bor.create_time asc
</select>
<select id="getUserCourseBuyInfoTotal" resultType="map">
select if(ROUND(SUM(fee),2) is null,0,ROUND(SUM(fee),2)) fee,
if(ROUND(SUM(alreadyTanxiao),2) is null,0,ROUND(SUM(alreadyTanxiao),2)) alreadyTanxiao,