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

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

@@ -67,7 +67,7 @@
left join shop_product sp on sp.product_id = bop.product_id
where
( u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (bo.payment_method='1' or bo.payment_method='2') and bo.create_time>='2026-05-06 00:00:00') )
and bo.order_status in (1,2,3,4) and sp.goods_type != '05' and bo.real_money > 0
and bo.order_status in (1,2,3,4,6) and sp.goods_type != '05' and bo.real_money > 0
<if test="orderType != null and orderType!= ''">
<if test="orderType == 'lsorder' ">
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >= 37867))
@@ -90,7 +90,47 @@
) s
group by payType
</select>
<select id="getRefund" resultType="map">
select payType,count(1) count,SUM(price) totalPrice from (
select q.*,pzo.trade_no zfbOrder
from (
select t.createTime,t.name,t.tel,t.orderSn,t.orderStatus,t.payType,t.refundFee,
t.refundFee-(select IF(SUM(if(sp2.activity_price&lt;sp2.price,sp2.activity_price,sp2.price)) is NULL,0,SUM(if(sp2.activity_price&lt;sp2.price,sp2.activity_price,sp2.price))) from shop_product sp2 where sp2.goods_type = '05' and sp2.product_id in (GROUP_CONCAT(sp.product_id SEPARATOR ','))) price,
GROUP_CONCAT(sp.product_name SEPARATOR ', ') productName,t.remark
from (
select bo.order_id,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,bo.order_sn orderSn,
IF(bo.payment_method=1,'微信',IF(bo.payment_method=2,'支付宝',IF(bo.payment_method=4,'天医币','0'))) payType,
'已退款' orderStatus,bor.fee refundFee,if(bo.remark like '%退%',bo.remark,'') remark
from buy_order_refund bor
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
left join user u on u.id = bo.user_id
left join buy_order_product bop on bop.order_id = bo.order_id
left join shop_product sp on sp.product_id = bop.product_id
where
( u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (bo.payment_method='1' or bo.payment_method='2') and bo.create_time>='2026-05-06 00:00:00') )
and bo.order_status = '6' and sp.goods_type != '05' and bo.real_money > 0
<if test="orderType != null and orderType!= ''">
<if test="orderType == 'lsorder' ">
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >= 37867))
and bo.order_type = 'lsorder'
</if>
<if test="orderType == 'order' ">
and (bo.order_type = 'order'
or (bo.order_type = 'lsorder' and bo.payment_method = '4')
or (bo.order_type = 'lsorder' and bo.payment_method = '2' and bo.order_id &lt; 37867))
</if>
</if>
and DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
group by bo.order_sn
) t
left join buy_order_product bop on bop.order_id = t.order_id
left join shop_product sp on sp.product_id = bop.product_id
group by t.orderSn
) q
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
) s
group by payType
</select>
<select id="exportPhysicalBuyOrderInfo" resultType="map">
select q.*,pzo.trade_no zfbOrder
from (
@@ -110,7 +150,7 @@
and bo.order_status in (1,2,3,4,6) and sp.goods_type != '05' and bo.real_money > 0
<if test="orderType != null and orderType!= ''">
<if test="orderType == 'lsorder' ">
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >37867))
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >= 37867))
and bo.order_type = 'lsorder'
</if>
<if test="orderType == 'order' ">
@@ -128,6 +168,44 @@
) q
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
</select>
<select id="exportPhysicalBuyOrderRefundInfo" resultType="map">
select q.*,pzo.trade_no zfbOrder
from (
select t.createTime,t.name,t.tel,t.orderSn,t.orderStatus,t.payType,t.orderPrice,
t.orderPrice-(select IF(SUM(if(sp2.activity_price&lt;sp2.price,sp2.activity_price,sp2.price)) is NULL,0,SUM(if(sp2.activity_price&lt;sp2.price,sp2.activity_price,sp2.price))) from shop_product sp2 where sp2.goods_type = '05' and sp2.product_id in (GROUP_CONCAT(sp.product_id SEPARATOR ','))) price,
GROUP_CONCAT(sp.product_name SEPARATOR ', ') productName,IF(count(1)=1,bop.quantity,'') quantity,t.remark,t.refund_no
from (
select bo.order_id,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,bo.order_sn orderSn,
IF(bo.payment_method=1,'微信',IF(bo.payment_method=2,'支付宝',IF(bo.payment_method=4,'天医币','0'))) payType,
'已退款' orderStatus,bor.fee orderPrice,if(bo.remark like '%退%',bo.remark,'') remark,IFNULL(bor.wx_refund_no,bor.refund_no) as refund_no
from buy_order_refund bor
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
left join user u on u.id = bo.user_id
left join buy_order_product bop on bop.order_id = bo.order_id
left join shop_product sp on sp.product_id = bop.product_id
where
( u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (bo.payment_method='1' or bo.payment_method='2') and bo.create_time>='2026-05-06 00:00:00') )
and bo.order_status = '6' and sp.goods_type != '05' and bo.real_money > 0
<if test="orderType != null and orderType!= ''">
<if test="orderType == 'lsorder' ">
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >= 37867))
and bo.order_type = 'lsorder'
</if>
<if test="orderType == 'order' ">
and (bo.order_type = 'order'
or (bo.order_type = 'lsorder' and bo.payment_method = '4')
or (bo.order_type = 'lsorder' and bo.payment_method = '2' and bo.order_id &lt; 37867))
</if>
</if>
and DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
group by bo.order_sn
) t
left join buy_order_product bop on bop.order_id = t.order_id
left join shop_product sp on sp.product_id = bop.product_id
group by t.orderSn
) q
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
</select>
<select id="queryListByOrderIds" resultType="com.peanut.modules.common.entity.BuyOrder">

View File

@@ -39,7 +39,43 @@
from transaction_details td
left join user u on u.id = td.user_id
where DATE_FORMAT(td.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
and td.user_id not in (select id from user where tester_flag = 1)
and td.user_id not in (select id from user where tester_flag = 1) and u.del_flag=0
) t
left join buy_order bo on bo.order_sn = t.payNo
left join buy_order_product bop on bop.order_id = bo.order_id
left join shop_product sp on sp.product_id = bop.product_id
left join vip_buy_config vbc on vbc.id = bo.vip_buy_config_id
group by t.id
order by t.createTime
) q
left join pay_zfb_order pzo on pzo.relevanceOid = q.payNo and pzo.trade_no is not null
) s
group by type,payMethod,goodsType
</select>
<select id="getRefundTransactionDetails" resultType="map">
select type,payMethod,goodsType,SUM(changeAmount) amount
from (
select q.*,pzo.trade_no zfbOrder
from (
select t.*,
IF(bo.order_type='relearn','课程',
IF(bo.order_type='trainingClass','培训班',
IF(bo.order_type='vip','VIP',
IF((GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',')='05'),
IF((GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,%'),'实物、课程','课程'),
'实物')))) goodsType,
IF(IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ',')) is NULL,'',IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ','))) productName
from (
select bor.id,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel
,'订单退款' type,'天医币' payMethod,bo.order_sn payNo
,bor.fee changeAmount,IF(bor.remark is NULL,'',bor.remark) note
from buy_order_refund bor
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
left join user u on u.id = bor.user_id
where DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
and bo.order_status = '6'
and bo.payment_method = '4'
and bor.user_id not in (select id from user where tester_flag = 1)
) t
left join buy_order bo on bo.order_sn = t.payNo
left join buy_order_product bop on bop.order_id = bo.order_id