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