fix(订单中心):首页统计数据规则修改,时间筛选无效bug修复
This commit is contained in:
+61
@@ -75,4 +75,65 @@ public class DashboardController {
|
||||
return Result.failed("获取二维码选项失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "测试时间参数传递")
|
||||
@GetMapping("/test-time-params")
|
||||
public Result<Map<String, Object>> testTimeParams(
|
||||
@Parameter(description = "景区ID") @RequestParam(required = false) Long tourismId,
|
||||
@Parameter(description = "二维码ID") @RequestParam(required = false) String qrcodeId,
|
||||
@Parameter(description = "设备编号") @RequestParam(required = false) String deviceSn,
|
||||
@Parameter(description = "开始时间") @RequestParam(required = false) String startTime,
|
||||
@Parameter(description = "结束时间") @RequestParam(required = false) String endTime,
|
||||
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("tourismId", tourismId);
|
||||
params.put("qrcodeId", qrcodeId);
|
||||
params.put("deviceSn", deviceSn);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
params.put("includeTestQrcodes", includeTestQrcodes);
|
||||
|
||||
// 测试各个统计方法
|
||||
Long totalOrders = dashboardMapper.getTotalOrders(params);
|
||||
Long totalAmount = dashboardMapper.getTotalAmount(params);
|
||||
Long refundAmount = dashboardMapper.getRefundAmount(params);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("params", params);
|
||||
result.put("totalOrders", totalOrders);
|
||||
result.put("totalAmount", totalAmount);
|
||||
result.put("refundAmount", refundAmount);
|
||||
|
||||
return Result.succeed(result, "测试时间参数成功");
|
||||
} catch (Exception e) {
|
||||
log.error("测试时间参数失败", e);
|
||||
return Result.failed("测试失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "调试数据库时间查询")
|
||||
@GetMapping("/debug-time-query")
|
||||
public Result<Map<String, Object>> debugTimeQuery(
|
||||
@Parameter(description = "开始时间") @RequestParam(required = false) String startTime,
|
||||
@Parameter(description = "结束时间") @RequestParam(required = false) String endTime) {
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
|
||||
// 直接查询数据库中的时间范围数据
|
||||
List<Map<String, Object>> timeRangeData = dashboardMapper.debugTimeRangeQuery(params);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("params", params);
|
||||
result.put("timeRangeData", timeRangeData);
|
||||
result.put("dataCount", timeRangeData.size());
|
||||
|
||||
return Result.succeed(result, "调试时间查询成功");
|
||||
} catch (Exception e) {
|
||||
log.error("调试时间查询失败", e);
|
||||
return Result.failed("调试失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+42
-3
@@ -241,7 +241,12 @@ public interface DashboardMapper {
|
||||
"<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)",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -263,8 +268,13 @@ public interface DashboardMapper {
|
||||
"<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.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -286,8 +296,13 @@ public interface DashboardMapper {
|
||||
"<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.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
@@ -454,4 +469,28 @@ public interface DashboardMapper {
|
||||
"</script>"
|
||||
})
|
||||
List<FilterOptions.OptionItem> getDeviceOptions(@Param("p") Map<String, Object> params);
|
||||
|
||||
// 调试时间范围查询
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" o.id,",
|
||||
" o.order_no,",
|
||||
" o.order_amount,",
|
||||
" o.order_status,",
|
||||
" o.create_time,",
|
||||
" o.tourism_id",
|
||||
"FROM orders o",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
"<if test='p.endTime != null and p.endTime != \"\"'>",
|
||||
" AND o.create_time <= #{p.endTime}",
|
||||
"</if>",
|
||||
"ORDER BY o.create_time DESC",
|
||||
"LIMIT 20",
|
||||
"</script>"
|
||||
})
|
||||
List<Map<String, Object>> debugTimeRangeQuery(@Param("p") Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { PageContainer } from '@ant-design/pro-components';
|
||||
import { Card, Row, Col, Statistic, Progress, Typography, Select, DatePicker, Space, Button, Switch } from 'antd';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { dashboard, getQrcodeOptions } from '@/services/orders/api';
|
||||
import { Area, Column, Pie } from '@ant-design/plots';
|
||||
import { Line, Column, Pie } from '@ant-design/plots';
|
||||
import {
|
||||
ShoppingCartOutlined,
|
||||
PayCircleOutlined,
|
||||
@@ -168,7 +168,7 @@ const Welcome: React.FC = () => {
|
||||
const platformAmount = Math.round(netIncome * platformRate);
|
||||
const tourismAmount = netIncome - platformAmount;
|
||||
|
||||
// 订单趋势配置
|
||||
// 订单趋势配置 - 改为折线图
|
||||
const orderTrendConfig = {
|
||||
data: chartStats.orderTrend || [],
|
||||
xField: 'date',
|
||||
@@ -179,8 +179,13 @@ const Welcome: React.FC = () => {
|
||||
legend: {
|
||||
position: 'top' as const,
|
||||
},
|
||||
areaStyle: {
|
||||
fillOpacity: 0.6,
|
||||
// 移除面积图样式,改为折线图
|
||||
line: {
|
||||
size: 2,
|
||||
},
|
||||
point: {
|
||||
size: 4,
|
||||
shape: 'circle',
|
||||
},
|
||||
color: ['#1890ff', '#52c41a', '#faad14'],
|
||||
xAxis: {
|
||||
@@ -192,6 +197,13 @@ const Welcome: React.FC = () => {
|
||||
formatter: (v: any) => `${v}单`,
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
shared: true,
|
||||
showCrosshairs: true,
|
||||
crosshairs: {
|
||||
type: 'xy' as const,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 订单分布配置
|
||||
@@ -408,8 +420,8 @@ const Welcome: React.FC = () => {
|
||||
{/* 图表展示 */}
|
||||
<Row gutter={[16, 16]} className={styles.chartsRow}>
|
||||
<Col xs={24} lg={16}>
|
||||
<Card title="订单趋势(创建/完成/退款)" loading={loading}>
|
||||
<Area {...orderTrendConfig} height={300} />
|
||||
<Card title="订单趋势折线图(创建/完成/退款)" loading={loading}>
|
||||
<Line {...orderTrendConfig} height={300} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={24} lg={8}>
|
||||
|
||||
Reference in New Issue
Block a user