fix:无人船

This commit is contained in:
2026-04-07 22:21:37 +08:00
parent 982e4364d5
commit a338cf7d02
112 changed files with 8255 additions and 611 deletions
+2
View File
@@ -42,6 +42,8 @@ export default [
{ path: '/orders/ctripOrder.html', component: '@/pages/orders/CtripOrder' },
// 携程退款管理
{ path: '/orders/ctripRefund.html', component: '@/pages/orders/CtripRefund' },
// 携程分销订单管理
{ path: '/orders/ctripDistOrder.html', component: '@/pages/orders/CtripDistOrder' },
// 订单状态超时监控配置
{ path: '/orders/statusTimeoutConfig.html', component: '@/pages/orders/StatusTimeoutConfig' },
],
Binary file not shown.
@@ -1,27 +1,24 @@
import React, { useState, useCallback, useRef } from 'react';
import React, { useState, useCallback, useRef, useEffect } from 'react';
import {
Modal,
Upload,
Button,
Progress,
List,
Typography,
Space,
Alert,
message,
Spin,
Tag,
Result,
Tabs,
Badge,
} from 'antd';
import {
InboxOutlined,
FileOutlined,
CheckCircleOutlined,
CloseCircleOutlined,
LoadingOutlined,
FolderOpenOutlined,
FileOutlined,
ReloadOutlined,
} from '@ant-design/icons';
import type { UploadFile } from 'antd/es/upload/interface';
import {
uploadSingleFile,
completeUpload,
@@ -29,8 +26,7 @@ import {
} from '@/services/threeDModel';
import styles from './ModelUploadModal.less';
const { Dragger } = Upload;
const { Text, Paragraph } = Typography;
const { Text } = Typography;
interface ModelUploadModalProps {
visible: boolean;
@@ -39,152 +35,262 @@ interface ModelUploadModalProps {
onComplete: () => void;
}
interface FileUploadItem {
interface FileItem {
file: File;
relativePath: string;
status: 'pending' | 'uploading' | 'success' | 'error';
progress: number;
url?: string;
error?: string;
}
type FileStatus = 'pending' | 'uploading' | 'success' | 'error';
// 虚拟列表配置
const ITEM_HEIGHT = 44;
const CONTAINER_HEIGHT = 400;
const VISIBLE_COUNT = Math.ceil(CONTAINER_HEIGHT / ITEM_HEIGHT);
const BUFFER = 5;
// 并发上传数
const CONCURRENCY = 5;
const ModelUploadModal: React.FC<ModelUploadModalProps> = ({
visible,
model,
onCancel,
onComplete,
}) => {
const [fileList, setFileList] = useState<FileUploadItem[]>([]);
const [uploading, setUploading] = useState(false);
const [uploadComplete, setUploadComplete] = useState(false);
const [overallProgress, setOverallProgress] = useState(0);
const [scrollTop, setScrollTop] = useState(0);
const [stats, setStats] = useState({ total: 0, success: 0, error: 0 });
const [activeTab, setActiveTab] = useState<'all' | 'failed'>('all');
const [, setRenderTick] = useState(0);
const filesRef = useRef<FileItem[]>([]);
const statusRef = useRef<Map<number, FileStatus>>(new Map());
const progressRef = useRef<Map<number, number>>(new Map());
const errorRef = useRef<Map<number, string>>(new Map());
const abortRef = useRef(false);
const successCountRef = useRef(0);
const failCountRef = useRef(0);
const tickTimerRef = useRef<ReturnType<typeof setInterval> | null>(null);
const uploadStartedRef = useRef(false);
const startRenderTick = () => {
tickTimerRef.current = setInterval(() => {
setRenderTick((t) => t + 1);
}, 200);
};
const stopRenderTick = () => {
if (tickTimerRef.current) {
clearInterval(tickTimerRef.current);
tickTimerRef.current = null;
}
};
useEffect(() => {
return () => stopRenderTick();
}, []);
// 重置状态
const resetState = () => {
setFileList([]);
filesRef.current = [];
statusRef.current = new Map();
progressRef.current = new Map();
errorRef.current = new Map();
abortRef.current = false;
successCountRef.current = 0;
failCountRef.current = 0;
uploadStartedRef.current = false;
stopRenderTick();
setUploading(false);
setUploadComplete(false);
setOverallProgress(0);
abortRef.current = false;
setScrollTop(0);
setActiveTab('all');
setStats({ total: 0, success: 0, error: 0 });
setRenderTick(0);
};
// 处理文件夹选择
const handleFolderSelect = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
const files = e.target.files;
if (!files || files.length === 0) return;
const items: FileUploadItem[] = [];
const items: FileItem[] = [];
for (let i = 0; i < files.length; i++) {
const file = files[i];
// webkitRelativePath 包含完整的相对路径
const relativePath = (file as any).webkitRelativePath || file.name;
items.push({
file,
relativePath,
status: 'pending',
progress: 0,
});
items.push({ file, relativePath });
}
// 检查是否包含tileset.json
const hasTileset = items.some(
(item) =>
item.relativePath.endsWith('tileset.json') &&
!item.relativePath.includes('/Block/')
!item.relativePath.includes('/Block/'),
);
if (!hasTileset) {
message.warning('未检测到根目录下的tileset.json文件,请确保选择了正确的3D Tiles文件夹');
}
setFileList(items);
filesRef.current = items;
statusRef.current = new Map();
progressRef.current = new Map();
errorRef.current = new Map();
successCountRef.current = 0;
failCountRef.current = 0;
uploadStartedRef.current = false;
setStats({ total: items.length, success: 0, error: 0 });
setActiveTab('all');
setUploadComplete(false);
setScrollTop(0);
setRenderTick((t) => t + 1);
}, []);
// 开始上传
const handleUpload = async () => {
if (!model?.id || fileList.length === 0) {
if (!model?.id || filesRef.current.length === 0) {
message.error('请先选择文件');
return;
}
setUploading(true);
uploadStartedRef.current = true;
abortRef.current = false;
successCountRef.current = 0;
failCountRef.current = 0;
let successCount = 0;
let failCount = 0;
const files = filesRef.current;
const total = files.length;
const sharedIndex = { value: 0 };
// 更新文件列表
const updateFileStatus = (
index: number,
status: FileUploadItem['status'],
progress: number,
url?: string,
error?: string
) => {
setFileList((prev) => {
const newList = [...prev];
newList[index] = { ...newList[index], status, progress, url, error };
return newList;
});
startRenderTick();
const worker = async () => {
while (sharedIndex.value < total && !abortRef.current) {
const i = sharedIndex.value++;
const item = files[i];
statusRef.current.set(i, 'uploading');
progressRef.current.set(i, 0);
try {
const result = await uploadSingleFile(
model.id,
item.file,
item.relativePath,
(percent) => {
progressRef.current.set(i, percent);
},
);
if (result.resp_code === 0) {
statusRef.current.set(i, 'success');
successCountRef.current++;
} else {
throw new Error(result.resp_msg || '上传失败');
}
} catch (err: any) {
statusRef.current.set(i, 'error');
errorRef.current.set(i, err.message);
failCountRef.current++;
}
const done = successCountRef.current + failCountRef.current;
setOverallProgress(Math.round((done / total) * 100));
if (done % 20 === 0 || done === total) {
setStats({
total,
success: successCountRef.current,
error: failCountRef.current,
});
}
}
};
// 逐个上传文件
for (let i = 0; i < fileList.length; i++) {
if (abortRef.current) break;
await Promise.all(Array.from({ length: CONCURRENCY }, worker));
const item = fileList[i];
updateFileStatus(i, 'uploading', 0);
stopRenderTick();
try {
const result = await uploadSingleFile(
model.id,
item.file,
item.relativePath,
(percent) => {
updateFileStatus(i, 'uploading', percent);
}
);
const finalSuccess = successCountRef.current;
const finalFail = failCountRef.current;
setStats({ total, success: finalSuccess, error: finalFail });
setRenderTick((t) => t + 1);
if (result.resp_code === 0) {
updateFileStatus(i, 'success', 100, result.datas);
successCount++;
} else {
throw new Error(result.resp_msg || '上传失败');
}
} catch (error: any) {
updateFileStatus(i, 'error', 0, undefined, error.message);
failCount++;
}
// 更新总进度
setOverallProgress(Math.round(((i + 1) / fileList.length) * 100));
}
// 如果全部成功,调用完成接口
if (successCount === fileList.length) {
if (finalSuccess === total) {
try {
await completeUpload(model.id);
message.success('所有文件上传完成!');
setUploadComplete(true);
} catch (error) {
} catch {
message.error('更新状态失败');
}
} else if (failCount > 0) {
message.warning(`上传完成,成功 ${successCount} 个,失败 ${failCount} 个`);
} else if (finalFail > 0) {
// 自动切到失败列表,方便用户逐个重试
setActiveTab('failed');
message.warning(`上传完成,成功 ${finalSuccess} 个,失败 ${finalFail} 个`);
}
setUploading(false);
};
// 取消上传
// 重试单个失败文件
const handleRetryFile = async (index: number) => {
if (!model?.id || uploading) return;
const item = filesRef.current[index];
if (!item) return;
statusRef.current.set(index, 'uploading');
progressRef.current.set(index, 0);
errorRef.current.delete(index);
failCountRef.current = Math.max(0, failCountRef.current - 1);
setRenderTick((t) => t + 1);
try {
const result = await uploadSingleFile(
model.id,
item.file,
item.relativePath,
(percent) => {
progressRef.current.set(index, percent);
setRenderTick((t) => t + 1);
},
);
if (result.resp_code === 0) {
statusRef.current.set(index, 'success');
successCountRef.current++;
} else {
throw new Error(result.resp_msg || '上传失败');
}
} catch (err: any) {
statusRef.current.set(index, 'error');
errorRef.current.set(index, err.message);
failCountRef.current++;
}
const total = filesRef.current.length;
const newSuccess = successCountRef.current;
const newFail = failCountRef.current;
setStats({ total, success: newSuccess, error: newFail });
setRenderTick((t) => t + 1);
// 全部成功时自动完成
if (newSuccess === total && newFail === 0) {
try {
await completeUpload(model.id);
message.success('所有文件上传完成!');
setUploadComplete(true);
} catch {
message.error('更新状态失败');
}
}
};
const handleAbort = () => {
abortRef.current = true;
message.info('正在取消上传...');
};
// 关闭弹窗
const handleClose = () => {
if (uploading) {
Modal.confirm({
@@ -208,16 +314,6 @@ const ModelUploadModal: React.FC<ModelUploadModalProps> = ({
}
};
// 统计信息
const stats = {
total: fileList.length,
success: fileList.filter((f) => f.status === 'success').length,
error: fileList.filter((f) => f.status === 'error').length,
pending: fileList.filter((f) => f.status === 'pending').length,
uploading: fileList.filter((f) => f.status === 'uploading').length,
totalSize: fileList.reduce((sum, f) => sum + f.file.size, 0),
};
const formatSize = (bytes: number) => {
if (bytes === 0) return '0 B';
const k = 1024;
@@ -226,6 +322,127 @@ const ModelUploadModal: React.FC<ModelUploadModalProps> = ({
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
};
// 全部文件的虚拟列表计算
const files = filesRef.current;
const totalCount = files.length;
const startIndex = Math.max(0, Math.floor(scrollTop / ITEM_HEIGHT) - BUFFER);
const endIndex = Math.min(totalCount - 1, startIndex + VISIBLE_COUNT + BUFFER * 2);
const visibleItems = files.slice(startIndex, endIndex + 1).map((item, offset) => {
const idx = startIndex + offset;
return {
index: idx,
file: item.file,
relativePath: item.relativePath,
status: statusRef.current.get(idx) ?? ('pending' as FileStatus),
progress: progressRef.current.get(idx) ?? 0,
error: errorRef.current.get(idx),
};
});
// 失败文件列表(直接从 statusRef 收集,无需虚拟列表)
const failedItems: Array<{
index: number;
file: File;
relativePath: string;
error: string;
status: FileStatus;
progress: number;
}> = [];
statusRef.current.forEach((status, idx) => {
if (status === 'error' || status === 'uploading') {
const f = filesRef.current[idx];
if (f) {
failedItems.push({
index: idx,
file: f.file,
relativePath: f.relativePath,
error: errorRef.current.get(idx) ?? '',
status,
progress: progressRef.current.get(idx) ?? 0,
});
}
}
});
failedItems.sort((a, b) => a.index - b.index);
const totalSize = files.reduce((sum, f) => sum + f.file.size, 0);
const getStatusIcon = (status: FileStatus) => {
switch (status) {
case 'uploading':
return <LoadingOutlined spin style={{ color: '#1890ff' }} />;
case 'success':
return <CheckCircleOutlined style={{ color: '#52c41a' }} />;
case 'error':
return <CloseCircleOutlined style={{ color: '#ff4d4f' }} />;
default:
return <FileOutlined style={{ color: '#bfbfbf' }} />;
}
};
const renderFileRow = (item: {
index: number;
file: File;
relativePath: string;
status: FileStatus;
progress: number;
error?: string;
}) => (
<div
key={item.index}
style={{
display: 'flex',
alignItems: 'center',
padding: '0 12px',
height: ITEM_HEIGHT,
borderBottom: '1px solid #f5f5f5',
fontSize: 13,
background: '#fff',
}}
>
<Space size={6} style={{ flex: 1, minWidth: 0 }}>
{getStatusIcon(item.status)}
<Text
ellipsis={{ tooltip: item.relativePath }}
style={{ maxWidth: 420, fontSize: 13 }}
>
{item.relativePath}
</Text>
</Space>
<div style={{ flexShrink: 0, marginLeft: 8, textAlign: 'right' }}>
{item.status === 'uploading' ? (
<Text type="secondary" style={{ fontSize: 12 }}>
{item.progress}%
</Text>
) : item.status === 'error' ? (
<Space size={4}>
<Text
type="danger"
style={{ fontSize: 12, maxWidth: 140, display: 'inline-block' }}
ellipsis={{ tooltip: item.error }}
>
{item.error}
</Text>
<Button
type="link"
size="small"
icon={<ReloadOutlined />}
disabled={uploading}
onClick={() => handleRetryFile(item.index)}
style={{ padding: '0 4px', fontSize: 12 }}
title="重试上传"
/>
</Space>
) : (
<Text type="secondary" style={{ fontSize: 12 }}>
{formatSize(item.file.size)}
</Text>
)}
</div>
</div>
);
return (
<Modal
title={`上传模型文件 - ${model?.modelName || ''}`}
@@ -240,7 +457,7 @@ const ModelUploadModal: React.FC<ModelUploadModalProps> = ({
) : (
<Space>
<Button onClick={handleClose}>{uploading ? '取消' : '关闭'}</Button>
{!uploading && fileList.length > 0 && (
{!uploading && totalCount > 0 && !uploadStartedRef.current && (
<Button type="primary" onClick={handleUpload}>
开始上传
</Button>
@@ -260,12 +477,12 @@ const ModelUploadModal: React.FC<ModelUploadModalProps> = ({
<Result
status="success"
title="上传完成"
subTitle={`成功上传 ${stats.success} 个文件,共 ${formatSize(stats.totalSize)}`}
subTitle={`成功上传 ${stats.success} 个文件,共 ${formatSize(totalSize)}`}
/>
) : (
<>
{/* 文件选择区域 */}
{fileList.length === 0 && (
{totalCount === 0 && (
<div className={styles.selectArea}>
<Alert
message="请选择3D Tiles模型文件夹"
@@ -297,19 +514,23 @@ const ModelUploadModal: React.FC<ModelUploadModalProps> = ({
)}
{/* 文件列表 */}
{fileList.length > 0 && (
{totalCount > 0 && (
<>
{/* 统计信息 */}
<div className={styles.statsBar}>
<Space split={<span style={{ color: '#d9d9d9' }}>|</span>}>
<Text>共 {stats.total} 个文件</Text>
<Text>总大小 {formatSize(stats.totalSize)}</Text>
<Text>总大小 {formatSize(totalSize)}</Text>
{stats.success > 0 && (
<Text type="success">成功 {stats.success}</Text>
)}
{stats.error > 0 && <Text type="danger">失败 {stats.error}</Text>}
{stats.uploading > 0 && (
<Text type="warning">上传中 {stats.uploading}</Text>
{stats.error > 0 && (
<Text type="danger">失败 {stats.error}</Text>
)}
{uploading && (
<Text type="warning">
剩余 {stats.total - stats.success - stats.error}
</Text>
)}
</Space>
</div>
@@ -319,67 +540,93 @@ const ModelUploadModal: React.FC<ModelUploadModalProps> = ({
<Progress
percent={overallProgress}
status="active"
strokeColor={{
'0%': '#108ee9',
'100%': '#87d068',
}}
style={{ marginBottom: 16 }}
strokeColor={{ '0%': '#108ee9', '100%': '#87d068' }}
style={{ marginBottom: 8 }}
/>
)}
{/* 文件列表 */}
<div className={styles.fileList}>
<List
size="small"
dataSource={fileList}
renderItem={(item, index) => (
<List.Item
className={`${styles.fileItem} ${styles[item.status]}`}
>
<div className={styles.fileInfo}>
<Space>
{item.status === 'pending' && <FileOutlined />}
{item.status === 'uploading' && (
<LoadingOutlined spin />
)}
{item.status === 'success' && (
<CheckCircleOutlined style={{ color: '#52c41a' }} />
)}
{item.status === 'error' && (
<CloseCircleOutlined style={{ color: '#ff4d4f' }} />
)}
<Text
ellipsis={{ tooltip: item.relativePath }}
style={{ maxWidth: 400 }}
>
{item.relativePath}
</Text>
</Space>
<Text type="secondary" style={{ fontSize: 12 }}>
{formatSize(item.file.size)}
</Text>
{/* Tab:全部文件 / 失败文件 */}
<Tabs
activeKey={activeTab}
onChange={(key) => {
setActiveTab(key as 'all' | 'failed');
setScrollTop(0);
}}
size="small"
style={{ marginBottom: 0 }}
items={[
{
key: 'all',
label: `全部文件 (${totalCount})`,
children: (
<div
style={{
height: CONTAINER_HEIGHT,
overflow: 'auto',
border: '1px solid #f0f0f0',
borderRadius: 4,
}}
onScroll={(e) => setScrollTop(e.currentTarget.scrollTop)}
>
<div style={{ height: totalCount * ITEM_HEIGHT, position: 'relative' }}>
{visibleItems.map((item) => (
<div
key={item.index}
style={{
position: 'absolute',
top: item.index * ITEM_HEIGHT,
left: 0,
right: 0,
}}
>
{renderFileRow(item)}
</div>
))}
</div>
</div>
{item.status === 'uploading' && (
<Progress
percent={item.progress}
size="small"
style={{ width: 100 }}
/>
)}
{item.status === 'error' && (
<Text type="danger" style={{ fontSize: 12 }}>
{item.error}
</Text>
)}
</List.Item>
)}
style={{ maxHeight: 400, overflow: 'auto' }}
/>
</div>
),
},
{
key: 'failed',
label: (
<Badge count={stats.error} size="small" offset={[6, -2]}>
<span style={{ paddingRight: stats.error > 0 ? 12 : 0 }}>失败文件</span>
</Badge>
),
children:
failedItems.length === 0 ? (
<div
style={{
height: CONTAINER_HEIGHT,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: '#bfbfbf',
border: '1px solid #f0f0f0',
borderRadius: 4,
}}
>
暂无失败文件
</div>
) : (
<div
style={{
height: CONTAINER_HEIGHT,
overflow: 'auto',
border: '1px solid #f0f0f0',
borderRadius: 4,
}}
>
{failedItems.map((item) => renderFileRow(item))}
</div>
),
},
]}
/>
{/* 重新选择 */}
{!uploading && (
<div style={{ marginTop: 16, textAlign: 'center' }}>
<div style={{ marginTop: 8, textAlign: 'center' }}>
<input
type="file"
id="folderInputReset"
@@ -0,0 +1,27 @@
import React from 'react';
import { Tag } from 'antd';
import {
CTRIP_DIST_ORDER_STATUS_OPTIONS,
CONSUME_STATUS_OPTIONS,
REFUND_STATUS_OPTIONS,
findLabel,
findColor,
} from './constants';
export const CtripDistOrderStatusTag: React.FC<{ value?: string }> = ({ value }) => {
const label = findLabel(CTRIP_DIST_ORDER_STATUS_OPTIONS, value);
const color = findColor(CTRIP_DIST_ORDER_STATUS_OPTIONS, value);
return <Tag color={color}>{label}</Tag>;
};
export const ConsumeStatusTag: React.FC<{ value?: number }> = ({ value }) => {
const label = findLabel(CONSUME_STATUS_OPTIONS, value);
const color = findColor(CONSUME_STATUS_OPTIONS, value);
return <Tag color={color}>{label}</Tag>;
};
export const RefundStatusTag: React.FC<{ value?: number }> = ({ value }) => {
const label = findLabel(REFUND_STATUS_OPTIONS, value);
const color = findColor(REFUND_STATUS_OPTIONS, value);
return <Tag color={color}>{label}</Tag>;
};
@@ -0,0 +1,83 @@
import React from 'react';
import type { ProColumns } from '@ant-design/pro-components';
import { CtripDistOrderStatusTag, ConsumeStatusTag, RefundStatusTag } from './Tags';
export interface CtripDistOrderItem {
id: number;
tenantId?: string;
orderNo?: string;
ctripOrderId?: number;
ctripProductId?: number;
ctripPackageId?: number;
ctripResourceId?: number;
distributorOrderId?: string;
orderAmount?: number | string;
currency?: string;
ctripOrderStatus?: string;
consumeStatus?: number;
consumeTime?: string;
refundStatus?: number;
refundTime?: string;
refundAmount?: number | string;
errorMsg?: string;
retryCount?: number;
remark?: string;
createTime?: string;
updateTime?: string;
}
const formatAmount = (amount: any): string => {
if (amount === undefined || amount === null || amount === '') return '-';
const num = parseFloat(String(amount));
return isNaN(num) ? '-' : num.toFixed(2);
};
export const buildCtripDistOrderColumns = (): ProColumns<CtripDistOrderItem>[] => [
{ dataIndex: 'index', valueType: 'indexBorder', width: 56 },
{ title: 'ID', dataIndex: 'id', width: 80 },
{ title: '本地订单号', dataIndex: 'orderNo', width: 200, copyable: true, ellipsis: true },
{ title: '分销商订单号', dataIndex: 'distributorOrderId', width: 200, copyable: true, ellipsis: true },
{ title: '携程订单ID', dataIndex: 'ctripOrderId', width: 160, copyable: true, ellipsis: true },
{ title: '携程产品ID', dataIndex: 'ctripProductId', width: 140 },
{
title: '订单金额',
dataIndex: 'orderAmount',
width: 120,
render: (v, record) => <span>{record.currency || 'CNY'} {formatAmount(v)}</span>,
},
{
title: '携程订单状态',
dataIndex: 'ctripOrderStatus',
width: 120,
render: (v) => <CtripDistOrderStatusTag value={v as string} />,
},
{
title: '核销状态',
dataIndex: 'consumeStatus',
width: 100,
render: (v) => <ConsumeStatusTag value={v as number} />,
},
{ title: '核销时间', dataIndex: 'consumeTime', width: 180, valueType: 'dateTime' },
{
title: '退款状态',
dataIndex: 'refundStatus',
width: 100,
render: (v) => <RefundStatusTag value={v as number} />,
},
{ title: '退款时间', dataIndex: 'refundTime', width: 180, valueType: 'dateTime' },
{
title: '退款金额',
dataIndex: 'refundAmount',
width: 120,
render: (v, record) => {
if (v === undefined || v === null || v === '') return '-';
return <span>{record.currency || 'CNY'} {formatAmount(v)}</span>;
},
},
{ title: '租户ID', dataIndex: 'tenantId', width: 140, ellipsis: true },
{ title: '重试次数', dataIndex: 'retryCount', width: 90 },
{ title: '错误信息', dataIndex: 'errorMsg', width: 200, ellipsis: true },
{ title: '备注', dataIndex: 'remark', width: 150, ellipsis: true },
{ title: '创建时间', dataIndex: 'createTime', width: 180, valueType: 'dateTime' },
{ title: '更新时间', dataIndex: 'updateTime', width: 180, valueType: 'dateTime' },
];
@@ -0,0 +1,26 @@
// 携程分销订单 - 携程侧订单状态(ctripOrderStatus 字符串枚举)
export const CTRIP_DIST_ORDER_STATUS_OPTIONS: { label: string; value: string; color?: string }[] = [
{ label: '创建中', value: 'CREATING', color: 'processing' },
{ label: '已确认', value: 'CONFIRMED', color: 'success' },
{ label: '创建失败', value: 'CREATE_FAILED', color: 'error' },
{ label: '已取消', value: 'CANCELLED', color: 'default' },
];
// 核销状态
export const CONSUME_STATUS_OPTIONS: { label: string; value: number; color?: string }[] = [
{ label: '未核销', value: 0, color: 'default' },
{ label: '已核销', value: 1, color: 'success' },
];
// 退款状态
export const REFUND_STATUS_OPTIONS: { label: string; value: number; color?: string }[] = [
{ label: '未退款', value: 0, color: 'default' },
{ label: '已退款', value: 1, color: 'success' },
{ label: '退款失败', value: 2, color: 'error' },
];
export const findLabel = <T extends { label: string; value: V }, V>(arr: T[], v?: V) =>
arr.find((o) => o.value === v)?.label || '未知';
export const findColor = <T extends { color?: string; value: V }, V>(arr: T[], v?: V) =>
arr.find((o) => o.value === v)?.color;
@@ -0,0 +1,76 @@
import React, { useRef, useMemo, useState } from 'react';
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
import type { ActionType } from '@ant-design/pro-components';
import { ordersApi } from '@/services/orders';
import { GlassCard, SearchBarPlus } from '@/components/ui';
import {
CTRIP_DIST_ORDER_STATUS_OPTIONS,
CONSUME_STATUS_OPTIONS,
REFUND_STATUS_OPTIONS,
} from './components/constants';
import { buildCtripDistOrderColumns, CtripDistOrderItem } from './components/buildColumns';
const CtripDistOrderPage: React.FC = () => {
const actionRef = useRef<ActionType>();
const [searchParams, setSearchParams] = useState<Record<string, any>>({});
const handleSearch = (values: Record<string, any>) => {
setSearchParams(values);
actionRef.current?.reset?.();
};
const columns = useMemo(() => buildCtripDistOrderColumns(), []);
return (
<PageContainer header={{ title: '携程分销订单管理' }}>
<SearchBarPlus
defaultCollapsed={false}
split
span={6}
showTenant={false}
onFinish={handleSearch}
hideReset
>
<ProFormText name="orderNo" label="本地订单号" placeholder="请输入本地订单号" />
<ProFormText name="ctripOrderId" label="携程订单ID" placeholder="请输入携程订单ID" />
<ProFormText name="ctripProductId" label="携程产品ID" placeholder="请输入携程产品ID" />
<ProFormSelect
name="ctripOrderStatus"
label="携程订单状态"
options={CTRIP_DIST_ORDER_STATUS_OPTIONS}
allowClear
/>
<ProFormSelect
name="consumeStatus"
label="核销状态"
options={CONSUME_STATUS_OPTIONS}
allowClear
/>
<ProFormSelect
name="refundStatus"
label="退款状态"
options={REFUND_STATUS_OPTIONS}
allowClear
/>
</SearchBarPlus>
<GlassCard>
<ProTable<CtripDistOrderItem>
rowKey="id"
headerTitle="携程分销订单列表"
actionRef={actionRef}
request={(p) => {
const params = { ...p, ...searchParams };
return ordersApi.ctripDistOrderList(params as any);
}}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true, defaultPageSize: 20 }}
scroll={{ x: 2200 }}
/>
</GlassCard>
</PageContainer>
);
};
export default CtripDistOrderPage;
@@ -30,6 +30,8 @@ export interface QrcodeItem {
photoCount?: number;
tourismFileIds?: number[];
qrDescribe?: string;
enableCtripOrder?: number; // 是否创建携程订单(0:否,1:是)
ctripProductId?: string; // 携程产品ID(enableCtripOrder=1 时必填)
}
export interface QrcodeFormProps {
open: boolean;
@@ -24,6 +24,8 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
isTest: 0, // 是否测试二维码:0=否 1=是
qrcodeType: 1, // 二维码类型:1=游客扫码 2=临时扫码 3=自定义
showVideoEditOnly: 0, // 是否仅显示一键成片:0=否 1=是
enableCtripOrder: 0, // 是否创建携程订单:0=否 1=是
ctripProductId: '', // 携程产品ID
materialCount: 1,
vlogCount: 0,
videoCount: 0,
@@ -167,7 +169,7 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
tourismId: (sanitizedInitial as any)?.tourismId ?? defaultTourismId,
};
const toNum = (v: any) => (typeof v === 'string' ? Number(v) : v);
['status', 'enableVideoEdit', 'isTest', 'qrcodeType', 'showVideoEditOnly', 'materialCount', 'vlogCount', 'videoCount', 'photoCount'].forEach((k) => {
['status', 'enableVideoEdit', 'isTest', 'qrcodeType', 'showVideoEditOnly', 'enableCtripOrder', 'materialCount', 'vlogCount', 'videoCount', 'photoCount'].forEach((k) => {
if (init[k] !== undefined) init[k] = toNum(init[k]);
});
if (init.templateId !== undefined && init.templateId !== null) {
@@ -318,6 +320,33 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
colProps={{ span: 12 }}
/>
{/* 携程订单联动 */}
<ProFormSelect
name="enableCtripOrder"
label="创建携程订单"
options={[
{ label: '否', value: 0 },
{ label: '是', value: 1 },
]}
tooltip="选择'是'后,用户下单时将同步创建携程分销订单"
colProps={{ span: 12 }}
/>
<ProForm.Item shouldUpdate={(prev, curr) => prev.enableCtripOrder !== curr.enableCtripOrder} noStyle>
{({ getFieldValue }) => {
const enabled = getFieldValue('enableCtripOrder') === 1;
return (
<ProFormText
name="ctripProductId"
label="携程产品ID"
placeholder="请输入携程产品ID"
rules={enabled ? [{ required: true, message: '请输入携程产品ID' }] : []}
fieldProps={{ disabled: !enabled }}
colProps={{ span: 12 }}
/>
);
}}
</ProForm.Item>
{/* 统计 */}
<ProFormDigit name="vlogCount" label="Vlog数量" min={0} fieldProps={{ precision: 0 }} colProps={{ span: 12 }} />
<ProFormDigit name="videoCount" label="视频数量" min={0} fieldProps={{ precision: 0 }} colProps={{ span: 12 }} />
@@ -66,6 +66,7 @@ const TourismForm: React.FC<TourismFormProps> = ({ open, title, initialValues, o
]}
initialValue={1}
/>
<ProFormTextArea name="tourismDesc" label="描述" />
</ModalForm>
);
@@ -623,6 +623,26 @@ export const ordersApi = {
return { data: data?.data || [], total: data?.count || 0 };
},
// ==================== 携程分销订单管理 ====================
// 分页查询携程分销订单列表
ctripDistOrderList: async (params: {
current?: number;
pageSize?: number;
orderNo?: string;
ctripOrderId?: number;
ctripProductId?: number;
ctripOrderStatus?: string;
consumeStatus?: number;
refundStatus?: number;
tenantId?: string;
}) => {
const { current, pageSize, ...rest } = params || {};
const res = await request('/api-coupon/ctrip/dist/order/list', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
const data = (res as any)?.data;
return { data: data?.data || [], total: data?.count || 0 };
},
// ==================== 订单状态超时监控配置 ====================
// 获取超时配置列表