feat: 支持第三方卡券收到订单后自动核销

This commit is contained in:
yml2213
2026-11-05 15:19:39 +08:00
parent 1df88cc639
commit 92ceb9697b
11 changed files with 323 additions and 30 deletions
@@ -4,7 +4,7 @@
* 设计口径(2026-10-31 v2):
* · 渠道由 L1 规则决定,不再由「有没有任务」反推;
* · 没有命中规则的新单落在「待分类」,收入进未分类桶,不产生成本噪音;
* · 第三方卡券是「只统计」渠道:不建任务、不发领取页。
* · 第三方卡券由外部卡券库履约:不建内部任务、不发领取页,但支持平台券自动核销。
*/
import {
DeleteOutlined,
@@ -66,7 +66,7 @@ import { ADMIN_DEFAULT_PAGE_SIZE, buildAdminTablePagination } from '@/utils/admi
const CHANNEL_OPTIONS = [
{ value: 'work_order', label: '接单平台' },
{ value: 'affiliate_dash', label: '自动发货' },
{ value: 'third_party_voucher', label: '第三方卡券(仅统计)' },
{ value: 'third_party_voucher', label: '第三方卡券' },
{ value: 'manual', label: '人工客服' },
]
@@ -46,11 +46,13 @@ const MODE_OPTIONS: Record<
Array<{ value: VoucherConsumeMode; label: string }>
> = {
affiliate_dash: [
{ value: 'after_order_received', label: '收到订单后' },
{ value: 'after_link_generated', label: '领取链接生成后' },
{ value: 'after_task_created', label: '履约任务创建后' },
{ value: 'manual', label: '人工核销' },
],
work_order: [
{ value: 'after_order_received', label: '收到订单后' },
{ value: 'after_work_order_published_or_assigned', label: '发布或指派后' },
{ value: 'after_work_order_published', label: '仅发布后' },
{ value: 'after_work_order_assigned', label: '仅指派后' },
@@ -58,10 +60,14 @@ const MODE_OPTIONS: Record<
{ value: 'manual', label: '人工核销' },
],
manual: [
{ value: 'after_order_received', label: '收到订单后' },
{ value: 'after_task_created', label: '人工任务创建后' },
{ value: 'manual', label: '人工核销' },
],
third_party_voucher: [{ value: 'manual', label: '未接入自动核销' }],
third_party_voucher: [
{ value: 'after_order_received', label: '收到订单后' },
{ value: 'manual', label: '人工核销' },
],
}
type PolicyRow = {
@@ -186,7 +192,6 @@ export default function VoucherConsumePolicyPanel() {
<Switch
size="small"
checked={row.policy.enabled}
disabled={row.channel === 'third_party_voucher'}
onChange={(enabled) => updateChannel(row.provider, row.channel, { enabled })}
/>
),
@@ -198,7 +203,7 @@ export default function VoucherConsumePolicyPanel() {
<Select
value={row.policy.mode}
options={MODE_OPTIONS[row.channel]}
disabled={row.channel === 'third_party_voucher' || !row.policy.enabled}
disabled={!row.policy.enabled}
onChange={(mode) => updateChannel(row.provider, row.channel, { mode })}
style={{ width: '100%' }}
/>
@@ -213,7 +218,7 @@ export default function VoucherConsumePolicyPanel() {
max={3600}
precision={0}
value={row.policy.delaySeconds}
disabled={row.channel === 'third_party_voucher' || !row.policy.enabled}
disabled={!row.policy.enabled}
onChange={(value) =>
updateChannel(row.provider, row.channel, {
delaySeconds: Math.max(0, Number(value || 0)),
@@ -148,6 +148,7 @@ export type VoucherConsumeChannel =
| 'third_party_voucher'
export type VoucherConsumeMode =
| 'manual'
| 'after_order_received'
| 'after_link_generated'
| 'after_task_created'
| 'after_work_order_published'
@@ -161,6 +162,7 @@ export type VoucherChannelConsumePolicy = {
}
export type VoucherConsumePolicy = {
version: number
enabled: boolean
platforms: Record<
VoucherConsumeProvider,