feat: 1:订单列表添加排队信息
2:订单超时短信告警
3:中科低空订单完成通知
This commit is contained in:
@@ -42,6 +42,8 @@ export default [
|
||||
{ path: '/orders/ctripOrder.html', component: '@/pages/orders/CtripOrder' },
|
||||
// 携程退款管理
|
||||
{ path: '/orders/ctripRefund.html', component: '@/pages/orders/CtripRefund' },
|
||||
// 订单状态超时监控配置
|
||||
{ path: '/orders/statusTimeoutConfig.html', component: '@/pages/orders/StatusTimeoutConfig' },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,435 @@
|
||||
import React, { useRef, useState, useEffect } from 'react';
|
||||
import { PageContainer, ProTable, type ActionType, ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
Button,
|
||||
Space,
|
||||
Tag,
|
||||
message,
|
||||
Switch,
|
||||
Modal,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
Select,
|
||||
Tooltip,
|
||||
Card,
|
||||
Row,
|
||||
Col,
|
||||
Statistic,
|
||||
} from 'antd';
|
||||
import {
|
||||
PlusOutlined,
|
||||
ReloadOutlined,
|
||||
ClockCircleOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { ordersApi } from '@/services/orders';
|
||||
|
||||
// 订单状态映射
|
||||
const ORDER_STATUS_MAP: Record<number, { text: string; color: string }> = {
|
||||
0: { text: '待支付', color: 'default' },
|
||||
1: { text: '已支付排队中', color: 'processing' },
|
||||
2: { text: '已取消', color: 'default' },
|
||||
3: { text: '设备执行完成', color: 'cyan' },
|
||||
4: { text: '正在服务中', color: 'blue' },
|
||||
5: { text: '素材上传中', color: 'orange' },
|
||||
6: { text: '素材上传完成', color: 'green' },
|
||||
7: { text: '退款中', color: 'volcano' },
|
||||
8: { text: '已退款', color: 'purple' },
|
||||
9: { text: '退款失败', color: 'red' },
|
||||
10: { text: '部分退款', color: 'magenta' },
|
||||
};
|
||||
|
||||
// 告警级别映射
|
||||
const ALERT_LEVEL_MAP: Record<string, { text: string; color: string }> = {
|
||||
INFO: { text: '信息', color: 'blue' },
|
||||
WARNING: { text: '警告', color: 'orange' },
|
||||
CRITICAL: { text: '严重', color: 'red' },
|
||||
};
|
||||
|
||||
interface StatusTimeoutConfig {
|
||||
id?: number;
|
||||
orderStatus: number;
|
||||
statusName: string;
|
||||
timeoutMinutes: number;
|
||||
alertLevel: string;
|
||||
alertInterval: number;
|
||||
maxAlertCount: number;
|
||||
isEnabled: number;
|
||||
notifyPhones?: string;
|
||||
smsTemplateId?: string;
|
||||
remark?: string;
|
||||
tenantId?: string;
|
||||
}
|
||||
|
||||
const StatusTimeoutConfigPage: React.FC = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [dataSource, setDataSource] = useState<StatusTimeoutConfig[]>([]);
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
const [editingRecord, setEditingRecord] = useState<StatusTimeoutConfig | null>(null);
|
||||
const [statistics, setStatistics] = useState({ total: 0, enabled: 0 });
|
||||
const [form] = Form.useForm();
|
||||
const actionRef = useRef<ActionType>();
|
||||
|
||||
const loadData = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = await ordersApi.getStatusTimeoutConfigList();
|
||||
setDataSource(data || []);
|
||||
const enabled = (data || []).filter((item: StatusTimeoutConfig) => item.isEnabled === 1).length;
|
||||
setStatistics({ total: data?.length || 0, enabled });
|
||||
} catch (error) {
|
||||
message.error('加载配置失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
const handleToggle = async (record: StatusTimeoutConfig) => {
|
||||
try {
|
||||
await ordersApi.toggleStatusTimeoutConfig(record.id!);
|
||||
message.success(record.isEnabled === 1 ? '已禁用' : '已启用');
|
||||
loadData();
|
||||
} catch (error) {
|
||||
message.error('操作失败');
|
||||
}
|
||||
};
|
||||
|
||||
const handleRefreshCache = async () => {
|
||||
try {
|
||||
await ordersApi.refreshStatusTimeoutConfigCache();
|
||||
message.success('缓存已刷新');
|
||||
} catch (error) {
|
||||
message.error('刷新缓存失败');
|
||||
}
|
||||
};
|
||||
|
||||
const handleEdit = (record: StatusTimeoutConfig) => {
|
||||
setEditingRecord(record);
|
||||
form.setFieldsValue(record);
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
const handleAdd = () => {
|
||||
setEditingRecord(null);
|
||||
form.resetFields();
|
||||
form.setFieldsValue({
|
||||
alertLevel: 'WARNING',
|
||||
alertInterval: 30,
|
||||
maxAlertCount: 3,
|
||||
isEnabled: 1,
|
||||
tenantId: 'webApp',
|
||||
});
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
try {
|
||||
const values = await form.validateFields();
|
||||
await ordersApi.saveStatusTimeoutConfig({ ...editingRecord, ...values });
|
||||
message.success('保存成功,缓存已自动刷新');
|
||||
setModalVisible(false);
|
||||
loadData();
|
||||
} catch (error) {
|
||||
message.error('保存失败');
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = (record: StatusTimeoutConfig) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: `确定要删除「${record.statusName}」的监控配置吗?`,
|
||||
onOk: async () => {
|
||||
try {
|
||||
await ordersApi.deleteStatusTimeoutConfig(record.id!);
|
||||
message.success('删除成功');
|
||||
loadData();
|
||||
} catch (error) {
|
||||
message.error('删除失败');
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const formatTimeout = (minutes: number) => {
|
||||
if (minutes >= 1440) {
|
||||
const days = Math.floor(minutes / 1440);
|
||||
const remain = minutes % 1440;
|
||||
return `${days}天${remain > 0 ? ` ${remain}分钟` : ''}`;
|
||||
}
|
||||
if (minutes >= 60) {
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const remain = minutes % 60;
|
||||
return `${hours}小时${remain > 0 ? ` ${remain}分钟` : ''}`;
|
||||
}
|
||||
return `${minutes}分钟`;
|
||||
};
|
||||
|
||||
const columns: ProColumns<StatusTimeoutConfig>[] = [
|
||||
{
|
||||
title: '订单状态',
|
||||
dataIndex: 'orderStatus',
|
||||
width: 160,
|
||||
render: (_, record) => {
|
||||
const status = ORDER_STATUS_MAP[record.orderStatus];
|
||||
return (
|
||||
<Space>
|
||||
<Tag color={status?.color}>{record.orderStatus}</Tag>
|
||||
<span>{record.statusName}</span>
|
||||
</Space>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '超时时间',
|
||||
dataIndex: 'timeoutMinutes',
|
||||
width: 120,
|
||||
render: (_, record) => (
|
||||
<Tooltip title={`${record.timeoutMinutes} 分钟`}>
|
||||
<Space>
|
||||
<ClockCircleOutlined />
|
||||
{formatTimeout(record.timeoutMinutes)}
|
||||
</Space>
|
||||
</Tooltip>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '告警级别',
|
||||
dataIndex: 'alertLevel',
|
||||
width: 100,
|
||||
render: (_, record) => {
|
||||
const level = ALERT_LEVEL_MAP[record.alertLevel];
|
||||
return <Tag color={level?.color}>{level?.text || record.alertLevel}</Tag>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '告警间隔',
|
||||
dataIndex: 'alertInterval',
|
||||
width: 100,
|
||||
render: (_, record) => `${record.alertInterval} 分钟`,
|
||||
},
|
||||
{
|
||||
title: '最大告警次数',
|
||||
dataIndex: 'maxAlertCount',
|
||||
width: 110,
|
||||
render: (_, record) => `${record.maxAlertCount} 次`,
|
||||
},
|
||||
{
|
||||
title: '通知手机号',
|
||||
dataIndex: 'notifyPhones',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
render: (_, record) => record.notifyPhones || <span style={{ color: '#999' }}>未配置</span>,
|
||||
},
|
||||
{
|
||||
title: '短信模板ID',
|
||||
dataIndex: 'smsTemplateId',
|
||||
width: 140,
|
||||
ellipsis: true,
|
||||
render: (_, record) => record.smsTemplateId || <span style={{ color: '#999' }}>未配置</span>,
|
||||
},
|
||||
{
|
||||
title: '租户ID',
|
||||
dataIndex: 'tenantId',
|
||||
width: 100,
|
||||
render: (_, record) => record.tenantId || <span style={{ color: '#999' }}>未设置</span>,
|
||||
},
|
||||
{
|
||||
title: '启用状态',
|
||||
dataIndex: 'isEnabled',
|
||||
width: 100,
|
||||
render: (_, record) => (
|
||||
<Switch
|
||||
checked={record.isEnabled === 1}
|
||||
onChange={() => handleToggle(record)}
|
||||
checkedChildren="启用"
|
||||
unCheckedChildren="禁用"
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'remark',
|
||||
width: 200,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<Button type="link" size="small" icon={<EditOutlined />} onClick={() => handleEdit(record)}>
|
||||
编辑
|
||||
</Button>
|
||||
<Button type="link" size="small" danger icon={<DeleteOutlined />} onClick={() => handleDelete(record)}>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
header={{ title: '订单状态超时监控配置' }}
|
||||
extra={[
|
||||
<Button key="refresh" icon={<ReloadOutlined />} onClick={handleRefreshCache}>
|
||||
刷新缓存
|
||||
</Button>,
|
||||
<Button key="add" type="primary" icon={<PlusOutlined />} onClick={handleAdd}>
|
||||
新增配置
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
<Card style={{ marginBottom: 16 }}>
|
||||
<Row gutter={24}>
|
||||
<Col span={6}>
|
||||
<Statistic title="配置总数" value={statistics.total} />
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Statistic title="已启用" value={statistics.enabled} valueStyle={{ color: '#52c41a' }} />
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Statistic title="已禁用" value={statistics.total - statistics.enabled} valueStyle={{ color: '#999' }} />
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
<ProTable<StatusTimeoutConfig>
|
||||
actionRef={actionRef}
|
||||
columns={columns}
|
||||
dataSource={dataSource}
|
||||
loading={loading}
|
||||
rowKey="id"
|
||||
search={false}
|
||||
pagination={false}
|
||||
scroll={{ x: 1400 }}
|
||||
options={{ reload: loadData }}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
title={editingRecord ? '编辑配置' : '新增配置'}
|
||||
open={modalVisible}
|
||||
onOk={handleSave}
|
||||
onCancel={() => setModalVisible(false)}
|
||||
width={600}
|
||||
destroyOnClose
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item
|
||||
name="orderStatus"
|
||||
label="订单状态"
|
||||
rules={[{ required: true, message: '请选择订单状态' }]}
|
||||
>
|
||||
<Select placeholder="请选择订单状态" disabled={!!editingRecord}>
|
||||
{Object.entries(ORDER_STATUS_MAP).map(([key, value]) => (
|
||||
<Select.Option key={key} value={Number(key)}>
|
||||
{key} - {value.text}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item
|
||||
name="statusName"
|
||||
label="状态名称"
|
||||
rules={[{ required: true, message: '请输入状态名称' }]}
|
||||
>
|
||||
<Input placeholder="请输入状态名称" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item
|
||||
name="timeoutMinutes"
|
||||
label="超时时间(分钟)"
|
||||
rules={[{ required: true, message: '请输入超时时间' }]}
|
||||
>
|
||||
<InputNumber min={1} max={99999} style={{ width: '100%' }} placeholder="请输入超时时间" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item
|
||||
name="alertLevel"
|
||||
label="告警级别"
|
||||
rules={[{ required: true, message: '请选择告警级别' }]}
|
||||
>
|
||||
<Select placeholder="请选择告警级别">
|
||||
<Select.Option value="INFO">信息</Select.Option>
|
||||
<Select.Option value="WARNING">警告</Select.Option>
|
||||
<Select.Option value="CRITICAL">严重</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item
|
||||
name="alertInterval"
|
||||
label="告警间隔(分钟)"
|
||||
rules={[{ required: true, message: '请输入告警间隔' }]}
|
||||
>
|
||||
<InputNumber min={1} max={9999} style={{ width: '100%' }} placeholder="请输入告警间隔" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item
|
||||
name="maxAlertCount"
|
||||
label="最大告警次数"
|
||||
rules={[{ required: true, message: '请输入最大告警次数' }]}
|
||||
>
|
||||
<InputNumber min={1} max={99} style={{ width: '100%' }} placeholder="请输入最大告警次数" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Form.Item
|
||||
name="notifyPhones"
|
||||
label="通知手机号"
|
||||
extra="多个手机号用英文逗号分隔"
|
||||
>
|
||||
<Input placeholder="请输入通知手机号,多个用逗号分隔" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="smsTemplateId"
|
||||
label="短信模板ID"
|
||||
extra="阿里云短信模板ID"
|
||||
>
|
||||
<Input placeholder="请输入阿里云短信模板ID" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="tenantId"
|
||||
label="租户ID"
|
||||
rules={[{ required: true, message: '请输入租户ID' }]}
|
||||
>
|
||||
<Input placeholder="请输入租户ID" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="remark" label="备注">
|
||||
<Input.TextArea rows={2} placeholder="请输入备注" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="isEnabled" label="启用状态" valuePropName="checked">
|
||||
<Switch checkedChildren="启用" unCheckedChildren="禁用" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default StatusTimeoutConfigPage;
|
||||
@@ -622,4 +622,42 @@ export const ordersApi = {
|
||||
const data = (res as any)?.data;
|
||||
return { data: data?.data || [], total: data?.count || 0 };
|
||||
},
|
||||
|
||||
// ==================== 订单状态超时监控配置 ====================
|
||||
|
||||
// 获取超时配置列表
|
||||
getStatusTimeoutConfigList: async (params?: { tenantId?: string }) => {
|
||||
const res = await request('/api-order/order/status/timeout/config/all', { method: 'GET', params });
|
||||
return (res as any)?.data || [];
|
||||
},
|
||||
|
||||
// 获取启用的配置列表
|
||||
getEnabledStatusTimeoutConfigs: async (params?: { tenantId?: string }) => {
|
||||
const res = await request('/api-order/order/status/timeout/config/list', { method: 'GET', params });
|
||||
return (res as any)?.data || [];
|
||||
},
|
||||
|
||||
// 保存超时配置
|
||||
saveStatusTimeoutConfig: async (data: any) => {
|
||||
const res = await request('/api-order/order/status/timeout/config/save', { method: 'POST', data });
|
||||
return res;
|
||||
},
|
||||
|
||||
// 删除超时配置
|
||||
deleteStatusTimeoutConfig: async (id: number) => {
|
||||
const res = await request(`/api-order/order/status/timeout/config/${id}`, { method: 'DELETE' });
|
||||
return res;
|
||||
},
|
||||
|
||||
// 切换配置启用状态
|
||||
toggleStatusTimeoutConfig: async (id: number) => {
|
||||
const res = await request(`/api-order/order/status/timeout/config/toggle/${id}`, { method: 'POST' });
|
||||
return res;
|
||||
},
|
||||
|
||||
// 刷新配置缓存
|
||||
refreshStatusTimeoutConfigCache: async (tenantId?: string) => {
|
||||
const res = await request('/api-order/order/status/timeout/config/refresh', { method: 'POST', params: { tenantId } });
|
||||
return res;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user