fix(分润管理):前端功能实现,统计功能实现
This commit is contained in:
+14
@@ -3,11 +3,13 @@ package com.central.order.controller;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.model.ProfitSharing;
|
||||
import com.central.order.model.vo.ProfitSharingStatisticsVO;
|
||||
import com.central.order.service.IProfitSharingService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -45,4 +47,16 @@ public class ProfitSharingController {
|
||||
return Result.failed("分账执行失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取分账统计数据")
|
||||
@GetMapping("/statistics")
|
||||
public Result<ProfitSharingStatisticsVO> getStatistics() {
|
||||
try {
|
||||
ProfitSharingStatisticsVO statistics = profitSharingService.getStatistics();
|
||||
return Result.succeed(statistics);
|
||||
} catch (Exception e) {
|
||||
log.error("获取分账统计数据失败", e);
|
||||
return Result.failed("获取统计数据失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -45,16 +45,16 @@ public interface DashboardMapper {
|
||||
})
|
||||
Long getTodayIncome();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM waylines WHERE is_del = 0")
|
||||
@Select("SELECT COUNT(*) FROM device-center.wayline_file WHERE is_del = 0")
|
||||
Long getTotalWaylines();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM waylines WHERE is_del = 0 AND last_use_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)")
|
||||
@Select("SELECT COUNT(*) FROM device-center.wayline_file WHERE is_del = 0 AND last_use_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)")
|
||||
Long getActiveWaylines();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM devices WHERE is_del = 0")
|
||||
@Select("SELECT COUNT(*) FROM device-center.manage_device WHERE is_del = 0")
|
||||
Long getTotalDevices();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM devices WHERE is_del = 0 AND status = 1")
|
||||
@Select("SELECT COUNT(*) FROM device-center.manage_device WHERE is_del = 0 AND status = 1")
|
||||
Long getOnlineDevices();
|
||||
|
||||
@Select({
|
||||
|
||||
+34
@@ -3,7 +3,41 @@ package com.central.order.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.order.model.ProfitSharing;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface ProfitSharingMapper extends BaseMapper<ProfitSharing> {
|
||||
// 获取总体统计
|
||||
@Select("SELECT " +
|
||||
"COUNT(*) as total_count, " +
|
||||
"SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) as success_count, " +
|
||||
"SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as fail_count, " +
|
||||
"SUM(qrcode_amount) as total_amount " +
|
||||
"FROM profit_sharing")
|
||||
Map<String, Object> getTotalStatistics();
|
||||
|
||||
// 获取每日金额趋势
|
||||
@Select("SELECT " +
|
||||
"DATE_FORMAT(create_time, '%Y-%m-%d') as date, " +
|
||||
"'DAY' as type, " +
|
||||
"SUM(qrcode_amount) as amount " +
|
||||
"FROM profit_sharing " +
|
||||
"WHERE create_time >= #{startTime} " +
|
||||
"GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')")
|
||||
List<Map<String, Object>> getDailyAmountTrend(@Param("startTime") Date startTime);
|
||||
|
||||
// 获取每日成功率
|
||||
@Select("SELECT " +
|
||||
"DATE_FORMAT(create_time, '%Y-%m-%d') as date, " +
|
||||
"'DAY' as type, " +
|
||||
"ROUND(SUM(CASE WHEN status = 2 THEN 1 ELSE 0 END) * 100.0 / COUNT(*), 2) as value " +
|
||||
"FROM profit_sharing " +
|
||||
"WHERE create_time >= #{startTime} " +
|
||||
"GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')")
|
||||
List<Map<String, Object>> getDailySuccessRate(@Param("startTime") Date startTime);
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.central.order.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.Builder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Schema(description = "分账统计数据")
|
||||
public class ProfitSharingStatisticsVO {
|
||||
@Schema(description = "总分账笔数")
|
||||
private Long totalCount;
|
||||
|
||||
@Schema(description = "成功笔数")
|
||||
private Long successCount;
|
||||
|
||||
@Schema(description = "失败笔数")
|
||||
private Long failCount;
|
||||
|
||||
@Schema(description = "总分账金额(分)")
|
||||
private Long totalAmount;
|
||||
|
||||
@Schema(description = "金额趋势数据")
|
||||
private List<TrendData> amountTrend;
|
||||
|
||||
@Schema(description = "成功率数据")
|
||||
private List<RateData> successRate;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public static class TrendData {
|
||||
@Schema(description = "日期")
|
||||
private String date;
|
||||
|
||||
@Schema(description = "类型(DAY-日,WEEK-周,MONTH-月)")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "金额(分)")
|
||||
private Long amount;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public static class RateData {
|
||||
@Schema(description = "日期")
|
||||
private String date;
|
||||
|
||||
@Schema(description = "类型(DAY-日,WEEK-周,MONTH-月)")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "成功率(0-100)")
|
||||
private Double value;
|
||||
}
|
||||
}
|
||||
+3
@@ -6,6 +6,7 @@ import com.central.order.model.Order;
|
||||
import com.central.order.model.ProfitSharing;
|
||||
import com.central.order.model.ProfitSharingResult;
|
||||
import com.central.order.model.QrCode;
|
||||
import com.central.order.model.vo.ProfitSharingStatisticsVO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -54,4 +55,6 @@ public interface IProfitSharingService extends ISuperService<ProfitSharing> {
|
||||
* 查询分账状态
|
||||
*/
|
||||
ProfitSharingResult queryProfitSharingStatus(String orderNo);
|
||||
|
||||
ProfitSharingStatisticsVO getStatistics();
|
||||
}
|
||||
|
||||
+3
-3
@@ -29,10 +29,10 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
statistics.setIncomeStats(getIncomeStatistics());
|
||||
|
||||
// 3. 获取航线统计
|
||||
statistics.setWaylineStats(getWaylineStatistics());
|
||||
// statistics.setWaylineStats(getWaylineStatistics());
|
||||
|
||||
// 4. 获取设备统计
|
||||
statistics.setDeviceStats(getDeviceStatistics());
|
||||
// statistics.setDeviceStats(getDeviceStatistics());
|
||||
|
||||
// 5. 获取图表统计
|
||||
statistics.setChartStats(getChartStatistics());
|
||||
@@ -156,7 +156,7 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
stats.setOrderTrend(dashboardMapper.getOrderTrend());
|
||||
|
||||
// 获取设备分布
|
||||
stats.setDeviceDistribution(dashboardMapper.getDeviceDistribution());
|
||||
// stats.setDeviceDistribution(dashboardMapper.getDeviceDistribution());
|
||||
|
||||
// 获取收入构成
|
||||
stats.setIncomeData(dashboardMapper.getIncomeData());
|
||||
|
||||
+68
@@ -14,6 +14,7 @@ import com.central.order.model.Order;
|
||||
import com.central.order.model.ProfitSharing;
|
||||
import com.central.order.model.ProfitSharingResult;
|
||||
import com.central.order.model.QrCode;
|
||||
import com.central.order.model.vo.ProfitSharingStatisticsVO;
|
||||
import com.central.order.service.IProfitSharingService;
|
||||
import com.central.order.service.IQrCodeService;
|
||||
import com.wechat.pay.java.service.profitsharing.ProfitsharingService;
|
||||
@@ -21,6 +22,7 @@ import com.wechat.pay.java.service.profitsharing.model.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@@ -59,6 +61,9 @@ public class ProfitSharingServiceImpl extends SuperServiceImpl<ProfitSharingMapp
|
||||
@Value("${wechat.pay.platform-rate:0.30}")
|
||||
private String platformRate;
|
||||
|
||||
@Autowired
|
||||
private ProfitSharingMapper profitSharingMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ProfitSharing createProfitSharing(Order order) {
|
||||
@@ -693,4 +698,67 @@ public class ProfitSharingServiceImpl extends SuperServiceImpl<ProfitSharingMapp
|
||||
throw new BusinessException("分账金额不能超过订单总额");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfitSharingStatisticsVO getStatistics() {
|
||||
try {
|
||||
// 1. 获取总体统计
|
||||
Map<String, Object> totalStats = profitSharingMapper.getTotalStatistics();
|
||||
|
||||
// 2. 获取最近30天的数据
|
||||
Date startTime = DateUtils.addDays(new Date(), -30);
|
||||
|
||||
// 3. 获取趋势数据
|
||||
List<Map<String, Object>> dailyTrend = profitSharingMapper.getDailyAmountTrend(startTime);
|
||||
List<ProfitSharingStatisticsVO.TrendData> amountTrend = convertToTrendData(dailyTrend);
|
||||
|
||||
// 4. 获取成功率数据
|
||||
List<Map<String, Object>> dailyRate = profitSharingMapper.getDailySuccessRate(startTime);
|
||||
List<ProfitSharingStatisticsVO.RateData> successRate = convertToRateData(dailyRate);
|
||||
|
||||
// 5. 构建返回数据
|
||||
return ProfitSharingStatisticsVO.builder()
|
||||
.totalCount(getLongValue(totalStats, "total_count"))
|
||||
.successCount(getLongValue(totalStats, "success_count"))
|
||||
.failCount(getLongValue(totalStats, "fail_count"))
|
||||
.totalAmount(getLongValue(totalStats, "total_amount"))
|
||||
.amountTrend(amountTrend)
|
||||
.successRate(successRate)
|
||||
.build();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取分账统计数据失败", e);
|
||||
throw new BusinessException("获取统计数据失败");
|
||||
}
|
||||
}
|
||||
|
||||
private List<ProfitSharingStatisticsVO.TrendData> convertToTrendData(List<Map<String, Object>> dailyTrend) {
|
||||
return dailyTrend.stream()
|
||||
.map(map -> ProfitSharingStatisticsVO.TrendData.builder()
|
||||
.date(String.valueOf(map.get("date")))
|
||||
.type(String.valueOf(map.get("type")))
|
||||
.amount(getLongValue(map, "amount"))
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<ProfitSharingStatisticsVO.RateData> convertToRateData(List<Map<String, Object>> dailyRate) {
|
||||
return dailyRate.stream()
|
||||
.map(map -> ProfitSharingStatisticsVO.RateData.builder()
|
||||
.date(String.valueOf(map.get("date")))
|
||||
.type(String.valueOf(map.get("type")))
|
||||
.value(getDoubleValue(map, "value"))
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Long getLongValue(Map<String, Object> map, String key) {
|
||||
Object value = map.get(key);
|
||||
return value == null ? 0L : Long.valueOf(String.valueOf(value));
|
||||
}
|
||||
|
||||
private Double getDoubleValue(Map<String, Object> map, String key) {
|
||||
Object value = map.get(key);
|
||||
return value == null ? 0.0 : Double.valueOf(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,43 +9,43 @@
|
||||
export default {
|
||||
dev: {
|
||||
'/api-uaa/': {
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-user/': {
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-log/': {
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-search/': {
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-generator/': {
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-file/': {
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-order/': {
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api-device/': {
|
||||
target: 'http://119.45.169.13:9900',
|
||||
// target: 'http://127.0.0.1:9900',
|
||||
// target: 'http://119.45.169.13:9900',
|
||||
target: 'http://127.0.0.1:9900',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -103,7 +103,15 @@
|
||||
{
|
||||
path: '/orders/statistics.html',
|
||||
component: './orders/statistics',
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/orders/profitSharing.html',
|
||||
component: './orders/ProfitSharing',
|
||||
},
|
||||
{
|
||||
path: '/orders/profit-sharing/statistics.html',
|
||||
component: './orders/ProfitSharing/Statistics',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import { PageContainer, ProDescriptions } from '@ant-design/pro-components';
|
||||
import { Card, Divider, Button, message } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useParams, history } from 'umi';
|
||||
import { getProfitSharingDetail, executeProfitSharing } from '@/services/orders/api';
|
||||
|
||||
const ProfitSharingDetail: React.FC = () => {
|
||||
const { orderNo } = useParams<{ orderNo: string }>();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [detail, setDetail] = useState<ORDERS.ProfitSharing>();
|
||||
|
||||
const fetchDetail = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await getProfitSharingDetail(orderNo);
|
||||
if (result.resp_code === 0) {
|
||||
setDetail(result.data);
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('获取详情失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchDetail();
|
||||
}, [orderNo]);
|
||||
|
||||
const handleExecute = async () => {
|
||||
try {
|
||||
const result = await executeProfitSharing(orderNo);
|
||||
if (result.resp_code === 0) {
|
||||
message.success('分账执行成功');
|
||||
fetchDetail();
|
||||
} else {
|
||||
message.error(result.resp_msg || '分账执行失败');
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('分账执行失败');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
onBack={() => history.goBack()}
|
||||
extra={
|
||||
detail?.status === 3 && detail?.retryTimes < 3 && (
|
||||
<Button type="primary" onClick={handleExecute}>
|
||||
重试分账
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
>
|
||||
<Card loading={loading}>
|
||||
<ProDescriptions
|
||||
column={2}
|
||||
title="订单信息"
|
||||
>
|
||||
<ProDescriptions.Item label="订单编号">{detail?.orderNo}</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="微信支付订单号">{detail?.transactionId}</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="订单总额">
|
||||
¥{detail?.totalAmount ? (detail.totalAmount / 100).toFixed(2) : '-'}
|
||||
</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="创建时间">{detail?.createTime}</ProDescriptions.Item>
|
||||
</ProDescriptions>
|
||||
|
||||
<Divider />
|
||||
|
||||
<ProDescriptions
|
||||
column={2}
|
||||
title="分账信息"
|
||||
>
|
||||
<ProDescriptions.Item label="分账状态">
|
||||
{STATUS_MAP[detail?.status]?.text}
|
||||
</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="分账单号">{detail?.profitSharingId}</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="平台分账金额">
|
||||
¥{detail?.platformAmount ? (detail.platformAmount / 100).toFixed(2) : '-'}
|
||||
</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="二维码分账金额">
|
||||
¥{detail?.qrCodeAmount ? (detail.qrCodeAmount / 100).toFixed(2) : '-'}
|
||||
</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="实际分账金额">
|
||||
¥{detail?.receiverAmount ? (detail.receiverAmount / 100).toFixed(2) : '-'}
|
||||
</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="分账完成时间">{detail?.finishTime}</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="分账账号">{detail?.payeeAccount}</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="账号类型">
|
||||
{detail?.payeeType === 'MERCHANT_ID' ? '商户ID' : '个人openid'}
|
||||
</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="分账描述">{detail?.description}</ProDescriptions.Item>
|
||||
{detail?.status === 3 && (
|
||||
<ProDescriptions.Item label="失败原因" span={2}>
|
||||
{detail?.failReason}
|
||||
</ProDescriptions.Item>
|
||||
)}
|
||||
<ProDescriptions.Item label="重试次数">{detail?.retryTimes || 0}</ProDescriptions.Item>
|
||||
<ProDescriptions.Item label="最后重试时间">{detail?.lastRetryTime}</ProDescriptions.Item>
|
||||
</ProDescriptions>
|
||||
</Card>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProfitSharingDetail;
|
||||
@@ -0,0 +1,35 @@
|
||||
.chartCard {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.secondRow {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.iconTotal {
|
||||
color: #1890ff;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.iconSuccess {
|
||||
color: #52c41a;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.iconFail {
|
||||
color: #ff4d4f;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.iconAmount {
|
||||
color: #faad14;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
:global {
|
||||
.ant-card {
|
||||
.ant-card-head {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
import { PageContainer, StatisticCard } from '@ant-design/pro-components';
|
||||
import { Card, Row, Col, Tabs, DatePicker } from 'antd';
|
||||
import { Area, Column } from '@ant-design/plots';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { getProfitSharingStatistics } from '@/services/orders/api';
|
||||
import styles from './Statistics.less';
|
||||
import {
|
||||
TransactionOutlined,
|
||||
CheckCircleOutlined,
|
||||
CloseCircleOutlined,
|
||||
PayCircleOutlined,
|
||||
} from '@ant-design/icons';
|
||||
|
||||
const { Divider } = StatisticCard;
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
const Statistics: React.FC = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [timeRange, setTimeRange] = useState<[string, string]>(['', '']);
|
||||
const [statistics, setStatistics] = useState<any>({});
|
||||
const [activeTab, setActiveTab] = useState<string>('day');
|
||||
|
||||
// 获取统计数据
|
||||
const fetchStatistics = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await getProfitSharingStatistics({
|
||||
startTime: timeRange[0],
|
||||
endTime: timeRange[1],
|
||||
type: activeTab,
|
||||
});
|
||||
if (result.resp_code === 0) {
|
||||
setStatistics(result.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取统计数据失败:', error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchStatistics();
|
||||
}, [timeRange, activeTab]);
|
||||
|
||||
// 金额趋势图配置
|
||||
const amountTrendConfig = {
|
||||
data: statistics.amountTrend || [],
|
||||
xField: 'date',
|
||||
yField: 'amount',
|
||||
seriesField: 'type',
|
||||
smooth: true,
|
||||
animation: true,
|
||||
legend: {
|
||||
position: 'top',
|
||||
},
|
||||
yAxis: {
|
||||
label: {
|
||||
formatter: (val: string) => `¥${(Number(val) / 100).toFixed(2)}`,
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
formatter: (datum: any) => {
|
||||
return {
|
||||
name: datum.type,
|
||||
value: `¥${(datum.amount / 100).toFixed(2)}`,
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 成功率统计图配置
|
||||
const successRateConfig = {
|
||||
data: statistics.successRate || [],
|
||||
xField: 'date',
|
||||
yField: 'value',
|
||||
seriesField: 'type',
|
||||
isGroup: true,
|
||||
columnStyle: {
|
||||
radius: [4, 4, 0, 0],
|
||||
},
|
||||
label: {
|
||||
position: 'middle',
|
||||
style: {
|
||||
fill: '#FFFFFF',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
{/* 总体统计卡片 */}
|
||||
<StatisticCard.Group direction="row">
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: '总分账笔数',
|
||||
value: statistics.totalCount || 0,
|
||||
icon: <TransactionOutlined className={styles.iconTotal} />,
|
||||
}}
|
||||
/>
|
||||
<Divider type="vertical" />
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: '成功笔数',
|
||||
value: statistics.successCount || 0,
|
||||
icon: <CheckCircleOutlined className={styles.iconSuccess} />,
|
||||
}}
|
||||
/>
|
||||
<Divider type="vertical" />
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: '失败笔数',
|
||||
value: statistics.failCount || 0,
|
||||
icon: <CloseCircleOutlined className={styles.iconFail} />,
|
||||
}}
|
||||
/>
|
||||
<Divider type="vertical" />
|
||||
<StatisticCard
|
||||
statistic={{
|
||||
title: '总分账金额',
|
||||
value: statistics.totalAmount ? (statistics.totalAmount / 100).toFixed(2) : '0.00',
|
||||
prefix: '¥',
|
||||
icon: <PayCircleOutlined className={styles.iconAmount} />,
|
||||
}}
|
||||
/>
|
||||
</StatisticCard.Group>
|
||||
|
||||
{/* 时间维度统计 */}
|
||||
<Card
|
||||
className={styles.chartCard}
|
||||
title="分账统计"
|
||||
extra={
|
||||
<RangePicker
|
||||
onChange={(dates) => {
|
||||
if (dates) {
|
||||
setTimeRange([
|
||||
dates[0]?.format('YYYY-MM-DD') || '',
|
||||
dates[1]?.format('YYYY-MM-DD') || '',
|
||||
]);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
items={[
|
||||
{ key: 'day', label: '日统计' },
|
||||
{ key: 'week', label: '周统计' },
|
||||
{ key: 'month', label: '月统计' },
|
||||
]}
|
||||
/>
|
||||
|
||||
<Row gutter={24}>
|
||||
<Col span={24}>
|
||||
<Card title="分账金额趋势" loading={loading}>
|
||||
<Area {...amountTrendConfig} height={300} />
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={24} className={styles.secondRow}>
|
||||
<Col span={24}>
|
||||
<Card title="分账成功率统计" loading={loading}>
|
||||
<Column {...successRateConfig} height={300} />
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default Statistics;
|
||||
+42
-1
@@ -3,9 +3,10 @@ import {
|
||||
ProForm,
|
||||
ProFormSelect,
|
||||
ProFormText,
|
||||
ProFormDigit,
|
||||
} from '@ant-design/pro-components';
|
||||
import React, { useEffect } from 'react';
|
||||
import { STATUS_OPTIONS } from '../index';
|
||||
import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS } from '../index';
|
||||
|
||||
export type UpdateFormProps = {
|
||||
onSubmit: (values: ORDERS.Qrcode) => Promise<void>;
|
||||
@@ -105,6 +106,46 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
||||
rules={[{ required: true, message: '请选择状态' }]}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group title="分账配置">
|
||||
<ProFormText
|
||||
width="md"
|
||||
name="payeeAccount"
|
||||
label="分账账号"
|
||||
placeholder="请输入分账接收账号"
|
||||
rules={[{ required: true, message: '请输入分账账号' }]}
|
||||
/>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="payeeType"
|
||||
label="账号类型"
|
||||
options={PAYEE_TYPE_OPTIONS}
|
||||
rules={[{ required: true, message: '请选择账号类型' }]}
|
||||
/>
|
||||
<ProFormDigit
|
||||
width="md"
|
||||
name="profitRate"
|
||||
label="分账比例"
|
||||
min={0}
|
||||
max={100}
|
||||
fieldProps={{
|
||||
precision: 2,
|
||||
suffix: '%',
|
||||
}}
|
||||
rules={[
|
||||
{ required: true, message: '请输入分账比例' },
|
||||
{ type: 'number', min: 0, max: 100, message: '比例必须在0-100之间' },
|
||||
]}
|
||||
/>
|
||||
{values?.payeeStatus === 2 && (
|
||||
<ProFormText
|
||||
width="md"
|
||||
name="payeeFailReason"
|
||||
label="验证失败原因"
|
||||
disabled
|
||||
/>
|
||||
)}
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -20,3 +20,26 @@
|
||||
.query-filter {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.ant-form {
|
||||
.ant-form-item-group-title {
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
margin-bottom: 16px;
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.payee-status {
|
||||
&-0 {
|
||||
color: #d9d9d9;
|
||||
}
|
||||
&-1 {
|
||||
color: #52c41a;
|
||||
}
|
||||
&-2 {
|
||||
color: #ff4d4f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ import {
|
||||
ProForm,
|
||||
ProFormSelect,
|
||||
ProFormText,
|
||||
ProFormDigit,
|
||||
ProTable,
|
||||
QueryFilter,
|
||||
Tooltip,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Typography, Popconfirm, Space, message, Image, Button, Tag } from 'antd';
|
||||
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
||||
@@ -28,6 +30,19 @@ export const DEVICE_OPTIONS = [
|
||||
{ label: '5YSZMBS0030BJ8', value: '5YSZMBS0030BJ8' },
|
||||
] as const;
|
||||
|
||||
// 添加账号类型常量
|
||||
export const PAYEE_TYPE_OPTIONS = [
|
||||
{ label: '商户ID', value: 'MERCHANT_ID' },
|
||||
{ label: '个人openid', value: 'PERSONAL_OPENID' },
|
||||
] as const;
|
||||
|
||||
// 添加账号状态常量
|
||||
export const PAYEE_STATUS_OPTIONS = [
|
||||
{ label: '未验证', value: 0 },
|
||||
{ label: '已验证', value: 1 },
|
||||
{ label: '验证失败', value: 2 },
|
||||
] as const;
|
||||
|
||||
const handleApiRequest = async (
|
||||
apiCall: () => Promise<any>,
|
||||
loadingMessage: string,
|
||||
@@ -267,6 +282,47 @@ const TableList: React.FC = () => {
|
||||
width: 80,
|
||||
render: (status) => renderStatus(status),
|
||||
},
|
||||
{
|
||||
title: '分账账号',
|
||||
dataIndex: 'payeeAccount',
|
||||
width: 140,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '账号类型',
|
||||
dataIndex: 'payeeType',
|
||||
width: 100,
|
||||
valueEnum: {
|
||||
'MERCHANT_ID': { text: '商户ID' },
|
||||
'PERSONAL_OPENID': { text: '个人openid' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '分账比例',
|
||||
dataIndex: 'profitRate',
|
||||
width: 100,
|
||||
render: (val) => val ? `${val}%` : '-',
|
||||
},
|
||||
{
|
||||
title: '验证状态',
|
||||
dataIndex: 'payeeStatus',
|
||||
width: 100,
|
||||
render: (status, record) => {
|
||||
const statusMap = {
|
||||
0: { color: 'default', text: '未验证' },
|
||||
1: { color: 'success', text: '已验证' },
|
||||
2: { color: 'error', text: '验证失败' },
|
||||
};
|
||||
const { color, text } = statusMap[status] || statusMap[0];
|
||||
return record.payeeFailReason ? (
|
||||
<Tooltip title={record.payeeFailReason}>
|
||||
<Tag color={color}>{text}</Tag>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Tag color={color}>{text}</Tag>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
@@ -447,6 +503,38 @@ const TableList: React.FC = () => {
|
||||
rules={[{ required: true, message: '请选择状态' }]}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group title="分账配置">
|
||||
<ProFormText
|
||||
width="md"
|
||||
name="payeeAccount"
|
||||
label="分账账号"
|
||||
placeholder="请输入分账接收账号"
|
||||
rules={[{ required: true, message: '请输入分账账号' }]}
|
||||
/>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="payeeType"
|
||||
label="账号类型"
|
||||
options={PAYEE_TYPE_OPTIONS}
|
||||
rules={[{ required: true, message: '请选择账号类型' }]}
|
||||
/>
|
||||
<ProFormDigit
|
||||
width="md"
|
||||
name="profitRate"
|
||||
label="分账比例"
|
||||
min={0}
|
||||
max={100}
|
||||
fieldProps={{
|
||||
precision: 2,
|
||||
suffix: '%',
|
||||
}}
|
||||
rules={[
|
||||
{ required: true, message: '请输入分账比例' },
|
||||
{ type: 'number', min: 0, max: 100, message: '比例必须在0-100之间' },
|
||||
]}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
<UpdateForm
|
||||
onSubmit={async (values) => {
|
||||
|
||||
@@ -179,3 +179,41 @@ export async function dashboard() {
|
||||
});
|
||||
}
|
||||
|
||||
/** 分页查询分账记录 */
|
||||
export async function profitSharingList(params: {
|
||||
page: number;
|
||||
limit: number;
|
||||
[key: string]: any;
|
||||
}) {
|
||||
return request('/api-order/profitSharing/list', {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取分账记录详情 */
|
||||
export async function getProfitSharingDetail(orderNo: string) {
|
||||
return request(`/api-order/profitSharing/${orderNo}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
/** 执行分账 */
|
||||
export async function executeProfitSharing(orderNo: string) {
|
||||
return request(`/api-order/profitSharing/execute/${orderNo}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取分账统计数据 */
|
||||
export async function getProfitSharingStatistics(params: {
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
type: 'day' | 'week' | 'month';
|
||||
}) {
|
||||
return request('/api-order/profitSharing/statistics', {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,11 @@ declare namespace ORDERS {
|
||||
status: number;
|
||||
tenantId?: string;
|
||||
updateTime?: string;
|
||||
payeeAccount?: string;
|
||||
payeeType?: 'MERCHANT_ID' | 'PERSONAL_OPENID';
|
||||
profitRate?: number;
|
||||
payeeStatus?: number;
|
||||
payeeFailReason?: string;
|
||||
}
|
||||
|
||||
type HomeCarousel = {
|
||||
@@ -138,6 +143,30 @@ declare namespace ORDERS {
|
||||
value: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface ProfitSharing {
|
||||
id: number;
|
||||
orderId: string;
|
||||
orderNo: string;
|
||||
transactionId: string;
|
||||
profitSharingId: string;
|
||||
totalAmount: number;
|
||||
platformAmount: number;
|
||||
qrCodeAmount: number;
|
||||
status: number;
|
||||
codeId: string;
|
||||
payeeAccount: string;
|
||||
payeeType: string;
|
||||
description: string;
|
||||
failReason: string;
|
||||
receiverAmount: number;
|
||||
finishTime: string;
|
||||
outOrderNo: string;
|
||||
retryTimes: number;
|
||||
lastRetryTime: string;
|
||||
createTime: string;
|
||||
updateTime: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace API {
|
||||
|
||||
Reference in New Issue
Block a user