fix(订单中心):首页统计数据规则修改
This commit is contained in:
+62
-16
@@ -17,7 +17,7 @@ public interface DashboardMapper {
|
|||||||
"SELECT COUNT(*) as count",
|
"SELECT COUNT(*) as count",
|
||||||
"FROM orders o",
|
"FROM orders o",
|
||||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||||
"WHERE o.is_del = 0",
|
"WHERE 1=1",
|
||||||
"<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>",
|
||||||
@@ -45,7 +45,7 @@ public interface DashboardMapper {
|
|||||||
"SELECT COUNT(*) as count",
|
"SELECT COUNT(*) as count",
|
||||||
"FROM orders o",
|
"FROM orders o",
|
||||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||||
"WHERE o.is_del = 0",
|
"WHERE 1=1",
|
||||||
"<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>",
|
||||||
@@ -68,7 +68,7 @@ public interface DashboardMapper {
|
|||||||
"SELECT COUNT(*) as count",
|
"SELECT COUNT(*) as count",
|
||||||
"FROM orders o",
|
"FROM orders o",
|
||||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||||
"WHERE o.is_del = 0",
|
"WHERE 1=1",
|
||||||
"<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>",
|
||||||
@@ -91,7 +91,7 @@ public interface DashboardMapper {
|
|||||||
"SELECT COUNT(*) as count",
|
"SELECT COUNT(*) as count",
|
||||||
"FROM orders o",
|
"FROM orders o",
|
||||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||||
"WHERE o.is_del = 0",
|
"WHERE 1=1",
|
||||||
"<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>",
|
||||||
@@ -121,11 +121,11 @@ public interface DashboardMapper {
|
|||||||
"SELECT COALESCE(SUM(o.order_amount), 0) as amount",
|
"SELECT COALESCE(SUM(o.order_amount), 0) as amount",
|
||||||
"FROM orders o",
|
"FROM orders o",
|
||||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||||
"WHERE o.is_del = 0",
|
"WHERE 1=1",
|
||||||
"<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 = 3",
|
"AND o.order_status IN (3, 8)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -201,14 +201,14 @@ public interface DashboardMapper {
|
|||||||
|
|
||||||
@Select({
|
@Select({
|
||||||
"<script>",
|
"<script>",
|
||||||
"SELECT COALESCE(SUM(CAST(r.refund_amount AS SIGNED)), 0) as amount",
|
"SELECT COALESCE(SUM(o.order_amount), 0) as amount",
|
||||||
"FROM orders_refund r",
|
"FROM orders o",
|
||||||
"JOIN orders o ON r.order_no = o.order_no",
|
|
||||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||||
"WHERE r.status = 8",
|
"WHERE 1=1",
|
||||||
"<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 = 8",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -219,10 +219,10 @@ public interface DashboardMapper {
|
|||||||
" AND o.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 r.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 r.create_time <= #{p.endTime}",
|
" AND o.create_time <= #{p.endTime}",
|
||||||
"</if>",
|
"</if>",
|
||||||
"</script>"
|
"</script>"
|
||||||
})
|
})
|
||||||
@@ -233,11 +233,11 @@ public interface DashboardMapper {
|
|||||||
"<script>",
|
"<script>",
|
||||||
"SELECT",
|
"SELECT",
|
||||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||||
" 'orders' as type,",
|
" 'created' as type,",
|
||||||
" COUNT(*) as value",
|
" COUNT(*) as value",
|
||||||
"FROM orders o",
|
"FROM orders o",
|
||||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||||
"WHERE o.is_del = 0",
|
"WHERE 1=1",
|
||||||
"<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>",
|
||||||
@@ -252,7 +252,53 @@ public interface DashboardMapper {
|
|||||||
" AND o.device_sn = #{p.deviceSn}",
|
" AND o.device_sn = #{p.deviceSn}",
|
||||||
"</if>",
|
"</if>",
|
||||||
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||||
"ORDER BY date",
|
"UNION ALL",
|
||||||
|
"SELECT",
|
||||||
|
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||||
|
" 'completed' as type,",
|
||||||
|
" COUNT(*) 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 q.is_test = 0",
|
||||||
|
"</if>",
|
||||||
|
" AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)",
|
||||||
|
" AND o.order_status = 3",
|
||||||
|
"<if test='p.tourismId != null'>",
|
||||||
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
|
"</if>",
|
||||||
|
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||||
|
" AND o.code_id = #{p.qrcodeId}",
|
||||||
|
"</if>",
|
||||||
|
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||||
|
" AND o.device_sn = #{p.deviceSn}",
|
||||||
|
"</if>",
|
||||||
|
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||||
|
"UNION ALL",
|
||||||
|
"SELECT",
|
||||||
|
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||||
|
" 'refunded' as type,",
|
||||||
|
" COUNT(*) 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 q.is_test = 0",
|
||||||
|
"</if>",
|
||||||
|
" AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)",
|
||||||
|
" AND o.order_status = 8",
|
||||||
|
"<if test='p.tourismId != null'>",
|
||||||
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
|
"</if>",
|
||||||
|
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||||
|
" AND o.code_id = #{p.qrcodeId}",
|
||||||
|
"</if>",
|
||||||
|
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||||
|
" AND o.device_sn = #{p.deviceSn}",
|
||||||
|
"</if>",
|
||||||
|
"GROUP BY DATE_FORMAT(o.create_time, '%Y-%m-%d')",
|
||||||
|
"ORDER BY date, type",
|
||||||
"</script>"
|
"</script>"
|
||||||
})
|
})
|
||||||
List<TrendDataVO> getOrderTrend(@Param("p") Map<String, Object> params);
|
List<TrendDataVO> getOrderTrend(@Param("p") Map<String, Object> params);
|
||||||
@@ -276,7 +322,7 @@ public interface DashboardMapper {
|
|||||||
" COUNT(*) as value",
|
" COUNT(*) as value",
|
||||||
"FROM orders o",
|
"FROM orders o",
|
||||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||||
"WHERE o.is_del = 0",
|
"WHERE 1=1",
|
||||||
"<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>",
|
||||||
|
|||||||
@@ -157,6 +157,9 @@ const Welcome: React.FC = () => {
|
|||||||
const filterOptions = statistics.filterOptions || {};
|
const filterOptions = statistics.filterOptions || {};
|
||||||
|
|
||||||
// 使用后端返回的基础数据
|
// 使用后端返回的基础数据
|
||||||
|
// 订单总金额:orderStatus=3+orderStatus=8的总金额(包含逻辑删除记录)
|
||||||
|
// 退款金额:orderStatus=8的总金额(包含逻辑删除记录)
|
||||||
|
// 净收入:总金额 - 退款金额
|
||||||
const totalAmount = orderStats.totalAmount || 0;
|
const totalAmount = orderStats.totalAmount || 0;
|
||||||
const refundAmount = orderStats.refundAmount || 0;
|
const refundAmount = orderStats.refundAmount || 0;
|
||||||
const netIncome = orderStats.netIncome || 0;
|
const netIncome = orderStats.netIncome || 0;
|
||||||
@@ -179,6 +182,16 @@ const Welcome: React.FC = () => {
|
|||||||
areaStyle: {
|
areaStyle: {
|
||||||
fillOpacity: 0.6,
|
fillOpacity: 0.6,
|
||||||
},
|
},
|
||||||
|
color: ['#1890ff', '#52c41a', '#faad14'],
|
||||||
|
xAxis: {
|
||||||
|
type: 'time',
|
||||||
|
tickCount: 7,
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
label: {
|
||||||
|
formatter: (v: any) => `${v}单`,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// 订单分布配置
|
// 订单分布配置
|
||||||
@@ -339,7 +352,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="¥"
|
||||||
@@ -395,7 +408,7 @@ const Welcome: React.FC = () => {
|
|||||||
{/* 图表展示 */}
|
{/* 图表展示 */}
|
||||||
<Row gutter={[16, 16]} className={styles.chartsRow}>
|
<Row gutter={[16, 16]} className={styles.chartsRow}>
|
||||||
<Col xs={24} lg={16}>
|
<Col xs={24} lg={16}>
|
||||||
<Card title="订单趋势" loading={loading}>
|
<Card title="订单趋势(创建/完成/退款)" loading={loading}>
|
||||||
<Area {...orderTrendConfig} height={300} />
|
<Area {...orderTrendConfig} height={300} />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
|||||||
Reference in New Issue
Block a user