feat(platform-fulfillment): 按任务状态配置租约释放
This commit is contained in:
@@ -29,12 +29,23 @@ export const platformFulfillmentApi = {
|
||||
),
|
||||
updateSettings: (data: {
|
||||
leaseDurationMinutes: number | null;
|
||||
completedReleaseDelayMinutes: number | null;
|
||||
manualCompletedReleaseDelayMinutes: number | null;
|
||||
presaleWaitingReleaseTtlMinutes: number | null;
|
||||
manualRequiredLeaseTtlMinutes: number | null;
|
||||
orderMatchStartedAt: string | null;
|
||||
}) =>
|
||||
api.put<PlatformFulfillmentSettings, PlatformFulfillmentSettings>(
|
||||
'/platform-fulfillment/settings',
|
||||
{
|
||||
lease_duration_minutes: data.leaseDurationMinutes,
|
||||
completed_release_delay_minutes: data.completedReleaseDelayMinutes,
|
||||
manual_completed_release_delay_minutes:
|
||||
data.manualCompletedReleaseDelayMinutes,
|
||||
presale_waiting_release_ttl_minutes:
|
||||
data.presaleWaitingReleaseTtlMinutes,
|
||||
manual_required_lease_ttl_minutes:
|
||||
data.manualRequiredLeaseTtlMinutes,
|
||||
order_match_started_at: data.orderMatchStartedAt,
|
||||
},
|
||||
),
|
||||
|
||||
@@ -2354,6 +2354,10 @@ export interface PlatformFulfillmentAccount {
|
||||
|
||||
export interface PlatformFulfillmentSettings {
|
||||
leaseDurationMinutes: number | null;
|
||||
completedReleaseDelayMinutes: number | null;
|
||||
manualCompletedReleaseDelayMinutes: number | null;
|
||||
presaleWaitingReleaseTtlMinutes: number | null;
|
||||
manualRequiredLeaseTtlMinutes: number | null;
|
||||
orderMatchStartedAt: string | null;
|
||||
updatedAt: string | null;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
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 { Alert, Button, Card, Col, DatePicker, Descriptions, Drawer, Empty, Input, InputNumber, Modal, QRCode, Row, Segmented, Select, Space, Switch, Table, Tabs, Tag, Timeline, Typography } from 'antd';
|
||||
import { CheckCircleOutlined, CopyOutlined, CreditCardOutlined, DownloadOutlined, 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';
|
||||
@@ -389,6 +389,10 @@ 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 [completedReleaseDelay, setCompletedReleaseDelay] = useState<number | null>(30);
|
||||
const [manualCompletedReleaseDelay, setManualCompletedReleaseDelay] = useState<number | null>(120);
|
||||
const [presaleWaitingReleaseTtl, setPresaleWaitingReleaseTtl] = useState<number | null>(null);
|
||||
const [manualRequiredLeaseTtl, setManualRequiredLeaseTtl] = useState<number | null>(null);
|
||||
const [orderMatchStartedAt, setOrderMatchStartedAt] = useState<Dayjs | null>(null);
|
||||
const [savingSettings, setSavingSettings] = useState(false);
|
||||
const [douyuActionLoading, setDouyuActionLoading] = useState('');
|
||||
@@ -974,6 +978,16 @@ export default function PlatformFulfillmentPage() {
|
||||
setOrderMatchStartedAt(
|
||||
settings?.orderMatchStartedAt ? dayjs(settings.orderMatchStartedAt) : null,
|
||||
);
|
||||
setCompletedReleaseDelay(settings?.completedReleaseDelayMinutes ?? 30);
|
||||
setManualCompletedReleaseDelay(
|
||||
settings?.manualCompletedReleaseDelayMinutes ?? 120,
|
||||
);
|
||||
setPresaleWaitingReleaseTtl(
|
||||
settings?.presaleWaitingReleaseTtlMinutes ?? null,
|
||||
);
|
||||
setManualRequiredLeaseTtl(
|
||||
settings?.manualRequiredLeaseTtlMinutes ?? null,
|
||||
);
|
||||
setSettingsOpen(true);
|
||||
};
|
||||
|
||||
@@ -996,6 +1010,10 @@ export default function PlatformFulfillmentPage() {
|
||||
try {
|
||||
const result = await platformFulfillmentApi.updateSettings({
|
||||
leaseDurationMinutes: minutes,
|
||||
completedReleaseDelayMinutes: completedReleaseDelay,
|
||||
manualCompletedReleaseDelayMinutes: manualCompletedReleaseDelay,
|
||||
presaleWaitingReleaseTtlMinutes: presaleWaitingReleaseTtl,
|
||||
manualRequiredLeaseTtlMinutes: manualRequiredLeaseTtl,
|
||||
orderMatchStartedAt: orderMatchStartedAt.toISOString(),
|
||||
});
|
||||
setSettings(result);
|
||||
@@ -1305,7 +1323,7 @@ export default function PlatformFulfillmentPage() {
|
||||
<Text type="secondary">系统自动检测账号并选号;只有缺货、CK 异常或资格失败时转人工处理。客户扫码绑定后,运营可直接开通宝典、充值或兑换皮肤。</Text>
|
||||
</div>
|
||||
<Space wrap>
|
||||
<Tag>账号租约:{leaseDurationLabel(settings?.leaseDurationMinutes)}</Tag>
|
||||
<Tag>进行中租约:{leaseDurationLabel(settings?.leaseDurationMinutes)}</Tag>
|
||||
<Tag>订单起算:{settings?.orderMatchStartedAt ? formatTime(settings.orderMatchStartedAt) : '-'}</Tag>
|
||||
<Button
|
||||
icon={<SettingOutlined />}
|
||||
@@ -1839,7 +1857,7 @@ export default function PlatformFulfillmentPage() {
|
||||
</Text>
|
||||
</div>
|
||||
<div>
|
||||
<Text strong>账号租约</Text>
|
||||
<Text strong>进行中任务兜底 TTL</Text>
|
||||
<Segmented
|
||||
block
|
||||
value={leaseDurationMode}
|
||||
@@ -1860,12 +1878,73 @@ export default function PlatformFulfillmentPage() {
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
) : null}
|
||||
<Text type="secondary">
|
||||
默认无限制。这里的 TTL 只作用于普通进行中状态,不会覆盖预售等待开放和人工处理状态。
|
||||
</Text>
|
||||
</div>
|
||||
<div>
|
||||
<Text strong>终态释放与特殊状态策略</Text>
|
||||
<Text type="secondary">
|
||||
留空表示永久保留;0 表示命中该状态后立即释放。
|
||||
</Text>
|
||||
<Row gutter={12} style={{ marginTop: 8 }}>
|
||||
<Col span={12}>
|
||||
<Text type="secondary">自动兑换完成保留</Text>
|
||||
<InputNumber
|
||||
min={0}
|
||||
precision={0}
|
||||
value={completedReleaseDelay}
|
||||
onChange={setCompletedReleaseDelay}
|
||||
placeholder="留空=永久"
|
||||
addonAfter="分钟"
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Text type="secondary">人工兑换完成保留</Text>
|
||||
<InputNumber
|
||||
min={0}
|
||||
precision={0}
|
||||
value={manualCompletedReleaseDelay}
|
||||
onChange={setManualCompletedReleaseDelay}
|
||||
placeholder="留空=永久"
|
||||
addonAfter="分钟"
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={12} style={{ marginTop: 8 }}>
|
||||
<Col span={12}>
|
||||
<Text type="secondary">预售等待开放 TTL</Text>
|
||||
<InputNumber
|
||||
min={0}
|
||||
precision={0}
|
||||
value={presaleWaitingReleaseTtl}
|
||||
onChange={setPresaleWaitingReleaseTtl}
|
||||
placeholder="留空=永久"
|
||||
addonAfter="分钟"
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Text type="secondary">人工处理 TTL</Text>
|
||||
<InputNumber
|
||||
min={0}
|
||||
precision={0}
|
||||
value={manualRequiredLeaseTtl}
|
||||
onChange={setManualRequiredLeaseTtl}
|
||||
placeholder="留空=永久"
|
||||
addonAfter="分钟"
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message={`订单起算:${settings?.orderMatchStartedAt ? formatTime(settings.orderMatchStartedAt) : '-'};账号租约:${leaseDurationLabel(settings?.leaseDurationMinutes)}`}
|
||||
description="保存后会立即同步当前所有活跃租约。无限制模式不会自动回收,任务完成、释放或取消时仍会正常释放账号。"
|
||||
message="按任务状态应用租约策略"
|
||||
description="保存后会按每个任务当前状态重新计算租约,不会把所有预售、人工和进行中任务统一套用同一个 TTL。"
|
||||
/>
|
||||
</Space>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user