fix(订单中心):首页统计问题再次优化
This commit is contained in:
+28
-25
@@ -181,7 +181,7 @@ public interface DashboardMapper {
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"AND o.order_status IN (3, 8)",
|
||||
"AND o.order_status IN (1, 3, 4, 5, 6, 7, 8, 9)",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -450,74 +450,77 @@ public interface DashboardMapper {
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" '平台分账' as type,",
|
||||
" COALESCE(SUM(os.platform_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
" COALESCE(SUM(CASE WHEN o.order_status IN (1, 3, 4, 5, 6, 7, 8, 9) THEN o.order_amount * 0.3 ELSE 0 END), 0) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" '景区分账' as type,",
|
||||
" COALESCE(SUM(os.tourism_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
" COALESCE(SUM(CASE WHEN o.order_status IN (1, 3, 4, 5, 6, 7, 8, 9) THEN o.order_amount * 0.7 ELSE 0 END), 0) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"UNION ALL",
|
||||
"SELECT",
|
||||
" '退款金额' as type,",
|
||||
" COALESCE(SUM(os.refund_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
" COALESCE(SUM(CASE WHEN o.order_status = 8 THEN o.order_amount ELSE 0 END), 0) as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
" AND q.is_test = 0",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND os.qrcode_id = #{p.qrcodeId}",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND os.device_sn = #{p.deviceSn}",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND os.create_time >= #{p.startTime}",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND os.create_time <= #{p.endTime}",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"</script>"
|
||||
})
|
||||
|
||||
+9
-3
@@ -208,9 +208,15 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
List<DistributionDataVO> orderDistribution = dashboardMapper.getOrderDistribution(params);
|
||||
chartStats.setOrderDistribution(orderDistribution);
|
||||
|
||||
// 获取收入构成数据
|
||||
List<IncomeDataVO> incomeBreakdown = dashboardMapper.getIncomeBreakdown(params);
|
||||
chartStats.setIncomeBreakdown(incomeBreakdown);
|
||||
// 获取收入构成数据
|
||||
List<IncomeDataVO> incomeBreakdown = dashboardMapper.getIncomeBreakdown(params);
|
||||
chartStats.setIncomeBreakdown(incomeBreakdown);
|
||||
|
||||
// 添加收入统计调试日志
|
||||
log.info("收入构成统计 - 参数: {}, 结果数量: {}", params, incomeBreakdown.size());
|
||||
for (IncomeDataVO item : incomeBreakdown) {
|
||||
log.info("收入构成 - 类型: {}, 金额: {}", item.getType(), item.getValue());
|
||||
}
|
||||
|
||||
// 获取二维码订单数量数据
|
||||
List<QrcodeOrderDataVO> qrcodeOrderCount = dashboardMapper.getQrcodeOrderCount(params);
|
||||
|
||||
@@ -212,6 +212,9 @@ const Welcome: React.FC = () => {
|
||||
|
||||
// 根据时间筛选状态动态显示标题
|
||||
const getOrderTitle = () => {
|
||||
if (hasTimeRange) {
|
||||
return '区间收款数量';
|
||||
}
|
||||
return '总收款数量';
|
||||
};
|
||||
|
||||
@@ -574,11 +577,11 @@ const Welcome: React.FC = () => {
|
||||
value={orderStats.totalOrders || 0}
|
||||
/>
|
||||
<Statistic
|
||||
title="总净收款数量"
|
||||
value={orderStats.totalPaidOrders || 0}
|
||||
title={hasTimeRange ? "区间净收款数量" : "总净收款数量"}
|
||||
value={(orderStats.totalOrders || 0) - (orderStats.refundedOrders || 0)}
|
||||
/>
|
||||
<Statistic
|
||||
title="总退款订单数"
|
||||
title={hasTimeRange ? "区间退款订单数" : "总退款订单数"}
|
||||
value={orderStats.refundedOrders || 0}
|
||||
/>
|
||||
</div>
|
||||
@@ -603,7 +606,7 @@ const Welcome: React.FC = () => {
|
||||
<span>收入统计</span>
|
||||
</div>
|
||||
<Statistic
|
||||
title="订单总金额 (完成+退款)"
|
||||
title="订单总金额 (有效订单)"
|
||||
value={(orderStats.totalAmount || 0) / 100}
|
||||
precision={2}
|
||||
prefix="¥"
|
||||
@@ -622,6 +625,7 @@ const Welcome: React.FC = () => {
|
||||
prefix="¥"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user