feat: 修改首页,添加景区订单列表统计

This commit is contained in:
2025-10-21 19:05:26 +08:00
parent 57ce4301fa
commit 37d15d17ef
3 changed files with 97 additions and 67 deletions
@@ -14,6 +14,6 @@ public class DashboardStatisticsVO {
@Schema(description = "图表统计") @Schema(description = "图表统计")
private ChartStatistics chartStats; private ChartStatistics chartStats;
@Schema(description = "筛选选项") /* @Schema(description = "筛选选项")
private FilterOptions filterOptions; private FilterOptions filterOptions;*/
} }
@@ -47,7 +47,7 @@ public class DashboardServiceImpl implements IDashboardService {
DashboardStatisticsVO emptyStats = new DashboardStatisticsVO(); DashboardStatisticsVO emptyStats = new DashboardStatisticsVO();
emptyStats.setOrderStats(new OrderStatisticsVO()); emptyStats.setOrderStats(new OrderStatisticsVO());
emptyStats.setChartStats(new ChartStatistics()); emptyStats.setChartStats(new ChartStatistics());
emptyStats.setFilterOptions(new FilterOptions()); //emptyStats.setFilterOptions(new FilterOptions());
return emptyStats; return emptyStats;
} }
@@ -81,7 +81,7 @@ public class DashboardServiceImpl implements IDashboardService {
// 2. 获取图表统计 // 2. 获取图表统计
statistics.setChartStats(getChartStatistics(params)); statistics.setChartStats(getChartStatistics(params));
// 3. 获取筛选选项 // 3. 获取筛选选项
statistics.setFilterOptions(getFilterOptions(params)); // statistics.setFilterOptions(getFilterOptions(params));
} catch (Exception e) { } catch (Exception e) {
log.error("获取仪表盘统计数据失败", e); log.error("获取仪表盘统计数据失败", e);
} }
+88 -58
View File
@@ -147,7 +147,7 @@ const Welcome: React.FC = () => {
if (rangeType === 'date') { if (rangeType === 'date') {
unit = 'hour'; unit = 'hour';
fmtLabel = (m: moment.Moment) => m.format('HH:00'); fmtLabel = (m: moment.Moment) => m.format('HH:00');
apiStatType = 'hour'; apiStatType = 'date';
} else { } else {
// 月、年、周都按天显示 // 月、年、周都按天显示
unit = 'day'; unit = 'day';
@@ -194,9 +194,15 @@ const Welcome: React.FC = () => {
dataMap[type][date] = value; dataMap[type][date] = value;
}); });
// 获取接口返回的实际数据范围
const actualDates = [...new Set(seriesData.map((item: any) => item.date))].sort();
// 如果没有数据,使用生成的labels;否则使用实际数据范围
const effectiveLabels = actualDates.length > 0 ? actualDates : labels;
// 填充所有时间点,缺失的补 0 // 填充所有时间点,缺失的补 0
const lineSeries: { date: string; value: number; type: string }[] = []; const lineSeries: { date: string; value: number; type: string }[] = [];
labels.forEach((label) => { effectiveLabels.forEach((label) => {
targetTypes.forEach((type) => { targetTypes.forEach((type) => {
lineSeries.push({ lineSeries.push({
date: label, date: label,
@@ -337,6 +343,11 @@ const Welcome: React.FC = () => {
const platformAmountYuan = Number(((netIncomeYuan * platformSharePercent) / 100).toFixed(2)); const platformAmountYuan = Number(((netIncomeYuan * platformSharePercent) / 100).toFixed(2));
const scenicAmountYuan = Number((netIncomeYuan - platformAmountYuan).toFixed(2)); const scenicAmountYuan = Number((netIncomeYuan - platformAmountYuan).toFixed(2));
const axisLeft = 40;
const axisTop = 40;
const axisBottom = 370;
const axisRight = 1850;
// 首次加载/筛选变化 // 首次加载/筛选变化
useEffect(() => { useEffect(() => {
if (!tenantId) return; if (!tenantId) return;
@@ -388,9 +399,9 @@ const Welcome: React.FC = () => {
</Row> </Row>
</Card> </Card>
{/* 概览卡片:左侧订单数统计 + 右侧金额统计 */} {/* 概览卡片:总订单 / 金额 / 分账 */}
<Row gutter={[16, 16]}> <Row gutter={[16, 16]}>
<Col xs={24} md={12}> <Col xs={24} lg={8} xl={8}>
<Card loading={pageLoading} style={{ height: '100%' }}> <Card loading={pageLoading} style={{ height: '100%' }}>
<Space direction="vertical" style={{ width: '100%' }} size={12}> <Space direction="vertical" style={{ width: '100%' }} size={12}>
<Text strong>总订单概览</Text> <Text strong>总订单概览</Text>
@@ -415,7 +426,7 @@ const Welcome: React.FC = () => {
</Space> </Space>
</Card> </Card>
</Col> </Col>
<Col xs={24} md={12}> <Col xs={24} lg={8} xl={8}>
<Card loading={pageLoading} style={{ height: '100%' }}> <Card loading={pageLoading} style={{ height: '100%' }}>
<Space direction="vertical" style={{ width: '100%' }} size={12}> <Space direction="vertical" style={{ width: '100%' }} size={12}>
<Text strong>金额统计</Text> <Text strong>金额统计</Text>
@@ -441,12 +452,8 @@ const Welcome: React.FC = () => {
</Space> </Space>
</Card> </Card>
</Col> </Col>
</Row> <Col xs={24} lg={8} xl={8}>
<Card className="modern-card" loading={pageLoading} style={{ height: '100%' }}>
{/* 分账计算 + 景区订单数量统计 */}
<Row gutter={[16, 16]} style={{ marginTop: 16 }}>
<Col xs={24} lg={12}>
<Card className="modern-card">
<Space direction="vertical" style={{ width: '100%' }} size={12}> <Space direction="vertical" style={{ width: '100%' }} size={12}>
<Row align="middle" justify="space-between" gutter={[8, 8]}> <Row align="middle" justify="space-between" gutter={[8, 8]}>
<Col flex="none"><Text strong>分账计算</Text></Col> <Col flex="none"><Text strong>分账计算</Text></Col>
@@ -495,11 +502,6 @@ const Welcome: React.FC = () => {
</Space> </Space>
</Card> </Card>
</Col> </Col>
<Col xs={24} lg={12}>
<Card title="景区订单数量统计" loading={pageLoading} style={{ height: '100%' }}>
<Column {...scenicOrderConfig} />
</Card>
</Col>
</Row> </Row>
{/* 订单趋势 - 单独一列 */} {/* 订单趋势 - 单独一列 */}
@@ -509,33 +511,33 @@ const Welcome: React.FC = () => {
<div <div
style={{ style={{
width: '100%', width: '100%',
height: rangeType === 'year' ? 600 : 500, height: 450,
padding: '10px 0', padding: '10px 0',
position: 'relative' position: 'relative'
}} }}
onMouseLeave={() => setTooltipData(null)} onMouseLeave={() => setTooltipData(null)}
> >
<svg width="100%" height="100%" viewBox={`0 0 ${rangeType === 'year' ? 1200 : 1100} ${rangeType === 'year' ? 600 : 500}`}> <svg width="100%" height="100%" viewBox={`0 0 1900 450`}>
{/* 绘制坐标轴 */} {/* 绘制坐标轴 */}
<line <line
x1="60" x1={axisLeft}
y1={rangeType === 'year' ? 520 : 430} y1={axisBottom}
x2={rangeType === 'year' ? 1150 : 1050} x2={axisRight}
y2={rangeType === 'year' ? 520 : 430} y2={axisBottom}
stroke="#e8e8e8" stroke="#e8e8e8"
strokeWidth="1" strokeWidth="1"
/> />
<line <line
x1="60" x1={axisLeft}
y1="40" y1={axisTop}
x2="60" x2={axisLeft}
y2={rangeType === 'year' ? 520 : 430} y2={axisBottom}
stroke="#e8e8e8" stroke="#e8e8e8"
strokeWidth="1" strokeWidth="1"
/> />
{/* 图例 */} {/* 图例 */}
<g transform="translate(60, 10)"> <g transform={`translate(${axisLeft}, 10)`}>
<circle cx="0" cy="5" r="4" fill="#1677FF"/> <circle cx="0" cy="5" r="4" fill="#1677FF"/>
<text x="10" y="8" fontSize="12" fill="#666">订单创建</text> <text x="10" y="8" fontSize="12" fill="#666">订单创建</text>
@@ -550,8 +552,8 @@ const Welcome: React.FC = () => {
{(() => { {(() => {
const allDates = [...new Set(orderLineSeries.map(item => item.date))].sort(); const allDates = [...new Set(orderLineSeries.map(item => item.date))].sort();
const maxValue = Math.max(...orderLineSeries.map(item => item.value), 1); const maxValue = Math.max(...orderLineSeries.map(item => item.value), 1);
const chartRight = rangeType === 'year' ? 1150 : 1050; const chartRight = axisRight;
const xStep = (chartRight - 60) / Math.max(allDates.length - 1, 1); const xStep = (chartRight - axisLeft) / Math.max(allDates.length - 1, 1);
// Y轴刻度和标签 // Y轴刻度和标签
const ySteps = 5; const ySteps = 5;
@@ -562,24 +564,24 @@ const Welcome: React.FC = () => {
{/* Y轴刻度和标签 */} {/* Y轴刻度和标签 */}
{Array.from({ length: ySteps + 1 }, (_, i) => { {Array.from({ length: ySteps + 1 }, (_, i) => {
const value = i * yStepValue; const value = i * yStepValue;
const chartBottom = rangeType === 'year' ? 520 : 430; const chartBottom = axisBottom;
const chartTop = 40; const chartTop = axisTop;
const chartHeight = chartBottom - chartTop; const chartHeight = chartBottom - chartTop;
const y = chartBottom - (value / maxValue) * chartHeight; const y = chartBottom - (value / maxValue) * chartHeight;
return ( return (
<g key={i}> <g key={i}>
<line <line
x1="55" y1={y} x2="60" y2={y} x1={axisLeft - 5} y1={y} x2={axisLeft} y2={y}
stroke="#e8e8e8" strokeWidth="1" stroke="#e8e8e8" strokeWidth="1"
/> />
<text <text
x="45" y={y + 4} x={axisLeft - 15} y={y + 4}
fontSize="10" fill="#666" textAnchor="end" fontSize="10" fill="#666" textAnchor="end"
> >
{value} {value}
</text> </text>
<line <line
x1="60" y1={y} x2={chartRight - 50} y2={y} x1={axisLeft} y1={y} x2={chartRight - 50} y2={y}
stroke="#f0f0f0" strokeWidth="1" strokeDasharray="3,3" stroke="#f0f0f0" strokeWidth="1" strokeDasharray="3,3"
/> />
</g> </g>
@@ -591,9 +593,9 @@ const Welcome: React.FC = () => {
// 根据日期数量和时间范围计算显示策略 // 根据日期数量和时间范围计算显示策略
let maxLabels = 12; let maxLabels = 12;
if (rangeType === 'year') { if (rangeType === 'year') {
maxLabels = 20; // 年视图时可以显示更多标签,因为有更宽的空间 maxLabels = 24; // 年视图显示月份标记,每月1-2个标签
} else if (rangeType === 'month') { } else if (rangeType === 'month') {
maxLabels = 15; maxLabels = Math.min(allDates.length, 31);
} else if (rangeType === 'week') { } else if (rangeType === 'week') {
maxLabels = 10; maxLabels = 10;
} }
@@ -602,13 +604,26 @@ const Welcome: React.FC = () => {
return allDates.map((date, index) => { return allDates.map((date, index) => {
// 判断是否显示此标签 // 判断是否显示此标签
const shouldShow = index === 0 || let shouldShow = index === 0 || index === allDates.length - 1;
index === allDates.length - 1 ||
index % labelInterval === 0; // 年视图特殊处理:优先显示每月1日或15日
if (rangeType === 'year') {
if (date.includes('-')) {
const parts = date.split('-');
if (parts.length >= 3) {
const day = parseInt(parts[2]);
// 显示每月1日,或者每月中间的某个日期
shouldShow = shouldShow || day === 1 || day === 15;
}
}
} else {
// 其他视图按间隔显示
shouldShow = shouldShow || index % labelInterval === 0;
}
if (!shouldShow) return null; if (!shouldShow) return null;
const x = 60 + index * xStep; const x = axisLeft + index * xStep;
// 智能格式化日期显示 // 智能格式化日期显示
let displayText = date; let displayText = date;
@@ -621,7 +636,13 @@ const Welcome: React.FC = () => {
const parts = date.split('-'); const parts = date.split('-');
if (parts.length >= 3) { if (parts.length >= 3) {
if (rangeType === 'year') { if (rangeType === 'year') {
displayText = `${parts[1]}-${parts[2]}`; // 月-日 const day = parseInt(parts[2]);
// 年视图:每月1日显示"月月",其他日期显示"月-日"
if (day === 1) {
displayText = `${parseInt(parts[1])}月`;
} else {
displayText = `${parts[1]}-${parts[2]}`;
}
} else if (rangeType === 'month') { } else if (rangeType === 'month') {
displayText = `${parts[1]}-${parts[2]}`; // 月-日 displayText = `${parts[1]}-${parts[2]}`; // 月-日
} else { } else {
@@ -630,7 +651,7 @@ const Welcome: React.FC = () => {
} }
} }
const chartBottom = rangeType === 'year' ? 520 : 430; const chartBottom = axisBottom;
return ( return (
<g key={index}> <g key={index}>
<text <text
@@ -657,10 +678,10 @@ const Welcome: React.FC = () => {
return datesWithData.map((date, dateIndex) => { return datesWithData.map((date, dateIndex) => {
const actualDateIndex = allDates.indexOf(date); const actualDateIndex = allDates.indexOf(date);
const x = 60 + actualDateIndex * xStep; const x = axisLeft + actualDateIndex * xStep;
const chartBottom = rangeType === 'year' ? 520 : 430; const chartBottom = axisBottom;
const chartTop = 40; const chartTop = axisTop;
const chartHeight = chartBottom - chartTop; const chartHeight = chartBottom - chartTop;
return ( return (
<rect <rect
@@ -673,8 +694,8 @@ const Welcome: React.FC = () => {
style={{ cursor: 'pointer' }} style={{ cursor: 'pointer' }}
onMouseEnter={(e: any) => { onMouseEnter={(e: any) => {
const svgRect = e.currentTarget.closest('svg').getBoundingClientRect(); const svgRect = e.currentTarget.closest('svg').getBoundingClientRect();
const svgWidth = rangeType === 'year' ? 1200 : 1100; const svgWidth = 1900;
const svgHeight = rangeType === 'year' ? 600 : 500; const svgHeight = 450;
const tooltipX = (e.clientX - svgRect.left) * (svgWidth / svgRect.width); const tooltipX = (e.clientX - svgRect.left) * (svgWidth / svgRect.width);
const tooltipY = (e.clientY - svgRect.top) * (svgHeight / svgRect.height); const tooltipY = (e.clientY - svgRect.top) * (svgHeight / svgRect.height);
@@ -683,7 +704,7 @@ const Welcome: React.FC = () => {
if (allDataForDate.length > 0) { if (allDataForDate.length > 0) {
const contentLines = allDataForDate.map(item => { const contentLines = allDataForDate.map(item => {
const colorMap = { const colorMap: Record<string, string> = {
'订单创建': '#1677FF', '订单创建': '#1677FF',
'订单完成': '#52C41A', '订单完成': '#52C41A',
'退款': '#FF4D4F' '退款': '#FF4D4F'
@@ -753,11 +774,11 @@ const Welcome: React.FC = () => {
const pathData = (() => { const pathData = (() => {
if (filledData.length === 0) return ''; if (filledData.length === 0) return '';
const chartBottom = rangeType === 'year' ? 520 : 430; const chartBottom = axisBottom;
const chartTop = 40; const chartTop = axisTop;
const chartHeight = chartBottom - chartTop; const chartHeight = chartBottom - chartTop;
const points = filledData.map((item, index) => { const points = filledData.map((item, index) => {
const x = 60 + index * xStep; const x = axisLeft + index * xStep;
const y = chartBottom - (item.value / maxValue) * chartHeight; const y = chartBottom - (item.value / maxValue) * chartHeight;
return { x, y }; return { x, y };
}); });
@@ -820,9 +841,9 @@ const Welcome: React.FC = () => {
if (item.value <= 0) return null; if (item.value <= 0) return null;
const dateIndex = allDates.indexOf(item.date); const dateIndex = allDates.indexOf(item.date);
const x = 60 + dateIndex * xStep; const x = axisLeft + dateIndex * xStep;
const chartBottom = rangeType === 'year' ? 520 : 430; const chartBottom = axisBottom;
const chartTop = 40; const chartTop = axisTop;
const chartHeight = chartBottom - chartTop; const chartHeight = chartBottom - chartTop;
const y = chartBottom - (item.value / maxValue) * chartHeight; const y = chartBottom - (item.value / maxValue) * chartHeight;
return ( return (
@@ -851,9 +872,9 @@ const Welcome: React.FC = () => {
{tooltipData && ( {tooltipData && (
<line <line
x1={tooltipData.lineX} x1={tooltipData.lineX}
y1="40" y1={axisTop}
x2={tooltipData.lineX} x2={tooltipData.lineX}
y2={rangeType === 'year' ? 520 : 430} y2={axisBottom}
stroke="#999" stroke="#999"
strokeWidth="1" strokeWidth="1"
strokeDasharray="5,5" strokeDasharray="5,5"
@@ -867,8 +888,8 @@ const Welcome: React.FC = () => {
<div <div
style={{ style={{
position: 'absolute', position: 'absolute',
left: `${(tooltipData.x / (rangeType === 'year' ? 1200 : 1100)) * 100}%`, left: `${(tooltipData.x / 1900) * 100}%`,
top: `${(tooltipData.y / (rangeType === 'year' ? 600 : 500)) * 100}%`, top: `${(tooltipData.y / 450) * 100}%`,
transform: 'translate(-50%, 0)', transform: 'translate(-50%, 0)',
backgroundColor: 'rgba(0, 0, 0, 0.8)', backgroundColor: 'rgba(0, 0, 0, 0.8)',
color: '#fff', color: '#fff',
@@ -888,6 +909,15 @@ const Welcome: React.FC = () => {
</Col> </Col>
</Row> </Row>
{/* 景区订单数量统计:单行展示 */}
<Row gutter={[16, 16]} style={{ marginTop: 16 }}>
<Col xs={24}>
<Card title="景区订单数量统计" loading={pageLoading} style={{ height: '100%' }}>
<Column {...scenicOrderConfig} />
</Card>
</Col>
</Row>
{/* 订单状态分布 + 订单列表 */} {/* 订单状态分布 + 订单列表 */}
<Row gutter={[16, 16]} style={{ marginTop: 16 }}> <Row gutter={[16, 16]} style={{ marginTop: 16 }}>
<Col xs={24} md={12}> <Col xs={24} md={12}>