手续费: - 新增 fee_type 字段(rate/fixed),百分比与固定金额二选一,不再叠加 - calculateServiceFee 按 fee_type 分支计算 - 商户创建/更新校验 fee_type,订单落库快照 fee_type - 前端表单改为下拉选择手续费类型,动态显示对应输入框 - 测试拆为 TestFeeRate + TestFeeFixed 清理旧链路: - 删除旧 Skin/Order/ShipLog 模型及 OrderService/SkinService - Dashboard 迁移到 FulfillmentService - 上游 /api/open/v1 改为基于 FulfillmentOrder 实现,接口契约不变 - 推送留痕改用 AuditLog,不再建 ShipLog 表 - 删除前端 Skins/Orders/ShipLogs/Distributors 页面及路由、菜单、API、类型 - 新增迁移 003: 添加 fee_type 列并 DROP 旧表
90 lines
2.5 KiB
TypeScript
90 lines
2.5 KiB
TypeScript
import { useEffect, useState } from 'react'
|
|
import { Card, Col, Row, Statistic, Typography, Spin, message } from 'antd'
|
|
import {
|
|
ShopOutlined,
|
|
ShoppingOutlined,
|
|
DollarOutlined,
|
|
PercentageOutlined,
|
|
ClockCircleOutlined,
|
|
} from '@ant-design/icons'
|
|
import { dashboardApi } from '../api'
|
|
import type { DashboardStats } from '../types'
|
|
|
|
export default function Dashboard() {
|
|
const [stats, setStats] = useState<DashboardStats | null>(null)
|
|
const [loading, setLoading] = useState(true)
|
|
|
|
useEffect(() => {
|
|
dashboardApi
|
|
.stats()
|
|
.then(setStats)
|
|
.catch((e) => message.error(e.message))
|
|
.finally(() => setLoading(false))
|
|
}, [])
|
|
|
|
if (loading) {
|
|
return (
|
|
<div style={{ textAlign: 'center', padding: 80 }}>
|
|
<Spin size="large" />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<Typography.Title level={4} style={{ marginTop: 0 }}>
|
|
数据概览
|
|
</Typography.Title>
|
|
<Row gutter={[16, 16]}>
|
|
<Col xs={24} sm={12} lg={8}>
|
|
<Card>
|
|
<Statistic title="商户商品" value={stats?.product_count ?? 0} prefix={<ShoppingOutlined />} />
|
|
</Card>
|
|
</Col>
|
|
<Col xs={24} sm={12} lg={8}>
|
|
<Card>
|
|
<Statistic title="平台商户" value={stats?.merchant_count ?? 0} prefix={<ShopOutlined />} />
|
|
</Card>
|
|
</Col>
|
|
<Col xs={24} sm={12} lg={8}>
|
|
<Card>
|
|
<Statistic title="订单总数" value={stats?.order_count ?? 0} prefix={<ShoppingOutlined />} />
|
|
</Card>
|
|
</Col>
|
|
<Col xs={24} sm={12} lg={8}>
|
|
<Card>
|
|
<Statistic
|
|
title="成交金额"
|
|
value={stats?.total_sales ?? 0}
|
|
precision={2}
|
|
prefix={<DollarOutlined />}
|
|
suffix="元"
|
|
/>
|
|
</Card>
|
|
</Col>
|
|
<Col xs={24} sm={12} lg={8}>
|
|
<Card>
|
|
<Statistic
|
|
title="平台手续费"
|
|
value={stats?.total_fees ?? 0}
|
|
precision={2}
|
|
prefix={<PercentageOutlined />}
|
|
suffix="元"
|
|
/>
|
|
</Card>
|
|
</Col>
|
|
<Col xs={24} sm={12} lg={8}>
|
|
<Card>
|
|
<Statistic
|
|
title="待处理订单"
|
|
value={stats?.pending_order_count ?? 0}
|
|
prefix={<ClockCircleOutlined />}
|
|
valueStyle={{ color: (stats?.pending_order_count ?? 0) > 0 ? '#cf1322' : undefined }}
|
|
/>
|
|
</Card>
|
|
</Col>
|
|
</Row>
|
|
</div>
|
|
)
|
|
}
|