feat(fulfillment): 增加订单匹配起算时间
This commit is contained in:
@@ -11,10 +11,16 @@ export const platformFulfillmentApi = {
|
||||
api.get<PlatformFulfillmentSettings, PlatformFulfillmentSettings>(
|
||||
'/platform-fulfillment/settings',
|
||||
),
|
||||
updateSettings: (leaseDurationMinutes: number | null) =>
|
||||
updateSettings: (data: {
|
||||
leaseDurationMinutes: number | null;
|
||||
orderMatchStartedAt: string | null;
|
||||
}) =>
|
||||
api.put<PlatformFulfillmentSettings, PlatformFulfillmentSettings>(
|
||||
'/platform-fulfillment/settings',
|
||||
{ lease_duration_minutes: leaseDurationMinutes },
|
||||
{
|
||||
lease_duration_minutes: data.leaseDurationMinutes,
|
||||
order_match_started_at: data.orderMatchStartedAt,
|
||||
},
|
||||
),
|
||||
listTasks: (params: {
|
||||
status?: string;
|
||||
|
||||
@@ -2120,6 +2120,7 @@ export interface PlatformFulfillmentAccount {
|
||||
|
||||
export interface PlatformFulfillmentSettings {
|
||||
leaseDurationMinutes: number | null;
|
||||
orderMatchStartedAt: string | null;
|
||||
updatedAt: string | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Alert, Button, Card, Descriptions, Drawer, Empty, Input, InputNumber, Modal, QRCode, Segmented, Select, Space, Switch, Table, Tabs, Tag, Timeline, Typography } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import { Alert, Button, Card, DatePicker, Descriptions, Drawer, Empty, Input, InputNumber, Modal, QRCode, Segmented, Select, Space, Switch, Table, Tabs, Tag, Timeline, Typography } from 'antd';
|
||||
import { CheckCircleOutlined, CopyOutlined, CreditCardOutlined, GiftOutlined, LinkOutlined, QrcodeOutlined, ReloadOutlined, SettingOutlined, ShoppingOutlined, SyncOutlined, UndoOutlined, UserSwitchOutlined } from '@ant-design/icons';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { douyuApi, platformFulfillmentApi } from '../api/modules';
|
||||
@@ -267,6 +269,7 @@ export default function PlatformFulfillmentPage() {
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const [leaseDurationMode, setLeaseDurationMode] = useState<'unlimited' | 'minutes' | 'hours'>('unlimited');
|
||||
const [leaseDurationValue, setLeaseDurationValue] = useState<number | null>(60);
|
||||
const [orderMatchStartedAt, setOrderMatchStartedAt] = useState<Dayjs | null>(null);
|
||||
const [savingSettings, setSavingSettings] = useState(false);
|
||||
const [douyuActionLoading, setDouyuActionLoading] = useState('');
|
||||
const [douyuActionType, setDouyuActionType] = useState('');
|
||||
@@ -542,6 +545,9 @@ export default function PlatformFulfillmentPage() {
|
||||
setLeaseDurationMode('minutes');
|
||||
setLeaseDurationValue(minutes);
|
||||
}
|
||||
setOrderMatchStartedAt(
|
||||
settings?.orderMatchStartedAt ? dayjs(settings.orderMatchStartedAt) : null,
|
||||
);
|
||||
setSettingsOpen(true);
|
||||
};
|
||||
|
||||
@@ -556,12 +562,19 @@ export default function PlatformFulfillmentPage() {
|
||||
message.warning('租约时长至少为 1 分钟');
|
||||
return;
|
||||
}
|
||||
if (!orderMatchStartedAt) {
|
||||
message.warning('请选择订单匹配起算时间');
|
||||
return;
|
||||
}
|
||||
setSavingSettings(true);
|
||||
try {
|
||||
const result = await platformFulfillmentApi.updateSettings(minutes);
|
||||
const result = await platformFulfillmentApi.updateSettings({
|
||||
leaseDurationMinutes: minutes,
|
||||
orderMatchStartedAt: orderMatchStartedAt.toISOString(),
|
||||
});
|
||||
setSettings(result);
|
||||
setSettingsOpen(false);
|
||||
message.success(`租约设置已更新为${leaseDurationLabel(result.leaseDurationMinutes)}`);
|
||||
message.success('履约同步设置已更新');
|
||||
if (selectedId) await loadDetail(selectedId);
|
||||
await loadTasks();
|
||||
} catch (error) {
|
||||
@@ -742,6 +755,7 @@ export default function PlatformFulfillmentPage() {
|
||||
</div>
|
||||
<Space wrap>
|
||||
<Tag>账号租约:{leaseDurationLabel(settings?.leaseDurationMinutes)}</Tag>
|
||||
<Tag>订单起算:{settings?.orderMatchStartedAt ? formatTime(settings.orderMatchStartedAt) : '-'}</Tag>
|
||||
<Button
|
||||
icon={<SettingOutlined />}
|
||||
disabled={!can('platform_fulfillment:admin')}
|
||||
@@ -1064,13 +1078,29 @@ export default function PlatformFulfillmentPage() {
|
||||
|
||||
<Modal
|
||||
open={settingsOpen}
|
||||
title="账号租约设置"
|
||||
title="履约同步与租约设置"
|
||||
okText="保存设置"
|
||||
confirmLoading={savingSettings}
|
||||
onOk={() => void saveLeaseSettings()}
|
||||
onCancel={() => setSettingsOpen(false)}
|
||||
>
|
||||
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
||||
<div>
|
||||
<Text strong>订单匹配起算时间</Text>
|
||||
<DatePicker
|
||||
showTime
|
||||
allowClear={false}
|
||||
value={orderMatchStartedAt}
|
||||
onChange={setOrderMatchStartedAt}
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
style={{ width: '100%', marginTop: 8 }}
|
||||
/>
|
||||
<Text type="secondary">
|
||||
只同步此时间之后支付的 order_site 人工订单,历史任务保留但不再展示或自动处理。
|
||||
</Text>
|
||||
</div>
|
||||
<div>
|
||||
<Text strong>账号租约</Text>
|
||||
<Segmented
|
||||
block
|
||||
value={leaseDurationMode}
|
||||
@@ -1091,10 +1121,11 @@ export default function PlatformFulfillmentPage() {
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message={`当前设置:${leaseDurationLabel(settings?.leaseDurationMinutes)}`}
|
||||
message={`订单起算:${settings?.orderMatchStartedAt ? formatTime(settings.orderMatchStartedAt) : '-'};账号租约:${leaseDurationLabel(settings?.leaseDurationMinutes)}`}
|
||||
description="保存后会立即同步当前所有活跃租约。无限制模式不会自动回收,任务完成、释放或取消时仍会正常释放账号。"
|
||||
/>
|
||||
</Space>
|
||||
|
||||
Reference in New Issue
Block a user