refactor(fulfillment): 移除飞飞/乐玩通道,仅保留 affiliate_dash
新单只路由 affiliate_dash(未命中走 manual_dispatch);历史飞飞/乐玩任务保留只读 stub,避免订单重同步失败。同步清理 cloudtentacles 调度、Admin 写路径与相关 env。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,203 +0,0 @@
|
||||
import { buildClaimUrl } from '../../claim/claim-service.js'
|
||||
import { shouldEnsureKuaishouCloudClaimLink, TASK_STATUS } from '../../../domain/task-status.js'
|
||||
import {
|
||||
confirmKuaishouCloudTaskRole,
|
||||
dispatchKuaishouCloudFulfillmentTask,
|
||||
ensureTaskClaimLink,
|
||||
prepareKuaishouCloudFulfillmentTask,
|
||||
rebindKuaishouCloudTaskRole,
|
||||
redeemKuaishouCloudTask,
|
||||
refreshKuaishouCloudTaskRoleInfo,
|
||||
returnKuaishouCloudFulfillmentTask,
|
||||
} from '../kuaishou-cloud/index.js'
|
||||
import {
|
||||
FULFILLMENT_EXECUTOR_KEYS,
|
||||
type FulfillmentActionOptions,
|
||||
type FulfillmentActionResult,
|
||||
type FulfillmentDeliveryLink,
|
||||
type FulfillmentExecutor,
|
||||
type FulfillmentPrepareDeps,
|
||||
} from './types.js'
|
||||
import type { TaskRow } from '../../../types/repository/rows.js'
|
||||
|
||||
export const kuaishouCloudExecutor: FulfillmentExecutor = {
|
||||
key: FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD,
|
||||
preparePaidTask,
|
||||
resolveDeliveryLink,
|
||||
prepareBinding,
|
||||
rebindRole,
|
||||
refreshRole,
|
||||
confirmRole,
|
||||
redeemTask,
|
||||
dispatchTask,
|
||||
returnNumber,
|
||||
}
|
||||
|
||||
async function preparePaidTask(
|
||||
task: TaskRow,
|
||||
deps: FulfillmentPrepareDeps,
|
||||
): Promise<TaskRow | null> {
|
||||
const now = deps.nowIso()
|
||||
|
||||
if (shouldEnsureKuaishouCloudClaimLink(task.task_status)) {
|
||||
if (!task.primary_claim_token_id && !String(task.claim_token || '').trim()) {
|
||||
const claimToken = await deps.createTaskClaimToken(task.id)
|
||||
return deps.updateTask(task.id, {
|
||||
claim_token: claimToken.token,
|
||||
claim_expires_at: claimToken.expired_at,
|
||||
user_action_status: 'pending_claim',
|
||||
updated_at: now,
|
||||
})
|
||||
}
|
||||
|
||||
return task
|
||||
}
|
||||
|
||||
const claimToken = await deps.createTaskClaimToken(task.id)
|
||||
|
||||
return deps.updateTask(task.id, {
|
||||
task_status: TASK_STATUS.PENDING_BINDING_PREPARE,
|
||||
claim_token: claimToken.token,
|
||||
claim_expires_at: claimToken.expired_at,
|
||||
user_action_status: 'pending_claim',
|
||||
last_error: task.last_error || '领取链接已生成,等待电子凭证流程推进',
|
||||
updated_at: now,
|
||||
})
|
||||
}
|
||||
|
||||
async function resolveDeliveryLink(task: TaskRow): Promise<FulfillmentDeliveryLink | null> {
|
||||
const primaryToken = String(task.primary_claim_token || task.claim_token || '').trim()
|
||||
const expireTime = task.primary_claim_expires_at || task.claim_expires_at || ''
|
||||
|
||||
if (primaryToken) {
|
||||
return {
|
||||
claimUrl: buildClaimUrl(primaryToken),
|
||||
expireTime,
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const ensured = await ensureTaskClaimLink(task)
|
||||
return {
|
||||
claimUrl: String(ensured.claimUrl || '').trim(),
|
||||
expireTime: ensured.expiredAt || expireTime,
|
||||
}
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function prepareBinding(
|
||||
task: TaskRow,
|
||||
options: FulfillmentActionOptions = {},
|
||||
): Promise<FulfillmentActionResult> {
|
||||
// 后台/显式 force:旧号可被 CT 回收,忽略退号失败并取新号+新绑链
|
||||
const force = options.force === true || String(options.source || '').includes('admin_')
|
||||
const result = await prepareKuaishouCloudFulfillmentTask(task, {
|
||||
source: options.source || 'executor_prepare_binding',
|
||||
actor: options.actor,
|
||||
force,
|
||||
})
|
||||
return {
|
||||
task: result.task || task,
|
||||
claimUrl: result.claimUrl,
|
||||
token: result.token,
|
||||
flow: result.flow,
|
||||
previousVnRelease: (result as { previousVnRelease?: string }).previousVnRelease,
|
||||
}
|
||||
}
|
||||
|
||||
async function rebindRole(
|
||||
task: TaskRow,
|
||||
options: FulfillmentActionOptions = {},
|
||||
): Promise<FulfillmentActionResult> {
|
||||
const result = await rebindKuaishouCloudTaskRole(task, {
|
||||
source: options.source || 'executor_rebind_role',
|
||||
actor: options.actor,
|
||||
})
|
||||
return {
|
||||
task: result.task || task,
|
||||
claimUrl: result.claimUrl,
|
||||
token: result.token,
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshRole(
|
||||
task: TaskRow,
|
||||
options: FulfillmentActionOptions = {},
|
||||
): Promise<FulfillmentActionResult> {
|
||||
const result = await refreshKuaishouCloudTaskRoleInfo(task, {
|
||||
source: options.source || 'executor_refresh_role',
|
||||
actor: options.actor,
|
||||
recordEvent: options.recordEvent !== false,
|
||||
forceProbe: options.forceProbe === true,
|
||||
})
|
||||
return {
|
||||
task: result.task || task,
|
||||
roleInfo: result.roleInfo,
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmRole(
|
||||
task: TaskRow,
|
||||
options: FulfillmentActionOptions = {},
|
||||
): Promise<FulfillmentActionResult> {
|
||||
const result = await confirmKuaishouCloudTaskRole(task, {
|
||||
source: options.source || 'executor_confirm_role',
|
||||
actor: options.actor,
|
||||
errorCodePrefix: options.errorCodePrefix,
|
||||
forceProbe: options.forceProbe !== false,
|
||||
})
|
||||
return {
|
||||
task: result.task,
|
||||
alreadySettled: result.alreadySettled,
|
||||
}
|
||||
}
|
||||
|
||||
async function redeemTask(
|
||||
task: TaskRow,
|
||||
options: FulfillmentActionOptions = {},
|
||||
): Promise<FulfillmentActionResult> {
|
||||
const result = await redeemKuaishouCloudTask(task, {
|
||||
source: options.source || 'executor_redeem',
|
||||
actor: options.actor,
|
||||
autoFinalize: options.autoFinalize !== false,
|
||||
errorCodePrefix: options.errorCodePrefix,
|
||||
})
|
||||
return {
|
||||
task: result.task,
|
||||
alreadySettled: result.alreadySettled,
|
||||
concurrentSkipped: result.concurrentSkipped,
|
||||
}
|
||||
}
|
||||
|
||||
async function dispatchTask(
|
||||
task: TaskRow,
|
||||
options: FulfillmentActionOptions = {},
|
||||
): Promise<FulfillmentActionResult> {
|
||||
const result = await dispatchKuaishouCloudFulfillmentTask(task, {
|
||||
source: options.source || 'executor_dispatch',
|
||||
actor: options.actor,
|
||||
autoFinalize: options.autoFinalize === true,
|
||||
})
|
||||
return {
|
||||
task: result.task || task,
|
||||
flow: result.flow,
|
||||
}
|
||||
}
|
||||
|
||||
async function returnNumber(
|
||||
task: TaskRow,
|
||||
options: FulfillmentActionOptions = {},
|
||||
): Promise<FulfillmentActionResult> {
|
||||
const result = await returnKuaishouCloudFulfillmentTask(task, {
|
||||
source: options.source || 'executor_return_number',
|
||||
actor: options.actor,
|
||||
// 未显式传入时保持默认 true(发货收尾);admin 清理会传 false
|
||||
consumeIndustryVoucher: options.consumeIndustryVoucher,
|
||||
})
|
||||
return {
|
||||
task: result.task || task,
|
||||
flow: result.flow,
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import { buildClaimUrl } from '../../claim/claim-service.js'
|
||||
import { TASK_STATUS } from '../../../domain/task-status.js'
|
||||
import { prepareKuaishouFeifeiTask } from '../kuaishou-feifei/index.js'
|
||||
import {
|
||||
FULFILLMENT_EXECUTOR_KEYS,
|
||||
type FulfillmentDeliveryLink,
|
||||
type FulfillmentExecutor,
|
||||
type FulfillmentPrepareDeps,
|
||||
} from './types.js'
|
||||
import type { TaskRow } from '../../../types/repository/rows.js'
|
||||
|
||||
/**
|
||||
* @deprecated 待移除,快手飞飞直充渠道已废弃,不再使用。
|
||||
*/
|
||||
export const kuaishouFeifeiExecutor: FulfillmentExecutor = {
|
||||
key: FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI,
|
||||
preparePaidTask,
|
||||
resolveDeliveryLink,
|
||||
}
|
||||
|
||||
async function preparePaidTask(
|
||||
task: TaskRow,
|
||||
deps: FulfillmentPrepareDeps,
|
||||
): Promise<TaskRow | null> {
|
||||
try {
|
||||
let workingTask = task
|
||||
if (!task.primary_claim_token_id && !String(task.claim_token || '').trim()) {
|
||||
const claimToken = await deps.createTaskClaimToken(task.id)
|
||||
workingTask =
|
||||
(await deps.updateTask(task.id, {
|
||||
claim_token: claimToken.token,
|
||||
claim_expires_at: claimToken.expired_at,
|
||||
user_action_status: 'pending_claim',
|
||||
updated_at: deps.nowIso(),
|
||||
})) || task
|
||||
}
|
||||
|
||||
return await prepareKuaishouFeifeiTask(workingTask)
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : 'kuaishou-feifei 订单创建失败'
|
||||
const updatedTask = await deps.updateTask(task.id, {
|
||||
task_status: TASK_STATUS.MANUAL_REVIEW,
|
||||
user_action_status: 'not_required',
|
||||
last_error: message,
|
||||
result_code: 'kuaishou_feifei_prepare_failed',
|
||||
result_message: message,
|
||||
updated_at: deps.nowIso(),
|
||||
})
|
||||
await deps.notifyTaskAutoManualReview({
|
||||
task: updatedTask || task,
|
||||
reason: message,
|
||||
source: 'kuaishou_feifei_prepare_failed',
|
||||
})
|
||||
return updatedTask
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对外(91 等)统一返回本站领取链接,不再返回 feifei H5 或短链。
|
||||
*/
|
||||
async function resolveDeliveryLink(task: TaskRow): Promise<FulfillmentDeliveryLink | null> {
|
||||
const primaryToken = String(task.primary_claim_token || task.claim_token || '').trim()
|
||||
const expireTime = String(task.primary_claim_expires_at || task.claim_expires_at || '').trim()
|
||||
|
||||
if (!primaryToken) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
claimUrl: buildClaimUrl(primaryToken),
|
||||
expireTime,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { FULFILLMENT_EXECUTOR_KEYS, type FulfillmentExecutor } from './types.js'
|
||||
import type { TaskRow } from '../../../types/repository/rows.js'
|
||||
|
||||
const RETIRED_MESSAGE = '该履约通道已下线,请转人工处理'
|
||||
|
||||
/**
|
||||
* 历史飞飞 / 乐玩任务只读 stub:
|
||||
* - prepare 幂等 no-op(避免订单重同步因 throw 整单失败)
|
||||
* - 不提供发货 / 领取链接
|
||||
*/
|
||||
function createLegacyRetiredExecutor(key: string): FulfillmentExecutor {
|
||||
return {
|
||||
key,
|
||||
async preparePaidTask(task: TaskRow) {
|
||||
return task
|
||||
},
|
||||
async resolveDeliveryLink() {
|
||||
return null
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const legacyLewanExecutor = createLegacyRetiredExecutor(
|
||||
FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD,
|
||||
)
|
||||
|
||||
export const legacyFeifeiExecutor = createLegacyRetiredExecutor(
|
||||
FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI,
|
||||
)
|
||||
|
||||
export const RETIRED_FULFILLMENT_MESSAGE = RETIRED_MESSAGE
|
||||
@@ -1,35 +1,15 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import {
|
||||
getFulfillmentExecutor,
|
||||
prepareFulfillmentBinding,
|
||||
redeemFulfillmentTask,
|
||||
dispatchFulfillmentTask,
|
||||
confirmFulfillmentRole,
|
||||
rebindFulfillmentRole,
|
||||
refreshFulfillmentRole,
|
||||
returnFulfillmentNumber,
|
||||
} from './registry.js'
|
||||
import { getFulfillmentExecutor } from './registry.js'
|
||||
import { FULFILLMENT_EXECUTOR_KEYS } from './types.js'
|
||||
import type { TaskRow } from '../../../types/repository/rows.js'
|
||||
|
||||
function makeTask(executorKey: string): TaskRow {
|
||||
return {
|
||||
id: 1,
|
||||
executor_key: executorKey,
|
||||
} as TaskRow
|
||||
}
|
||||
|
||||
test('getFulfillmentExecutor 映射 lewan / industry / feifei / affiliate_dash / manual', () => {
|
||||
test('getFulfillmentExecutor 映射 affiliate_dash / manual / retired stubs', () => {
|
||||
assert.equal(
|
||||
getFulfillmentExecutor(FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD)?.key,
|
||||
FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD,
|
||||
)
|
||||
assert.equal(
|
||||
getFulfillmentExecutor(FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_INDUSTRY)?.key,
|
||||
FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD,
|
||||
)
|
||||
assert.equal(getFulfillmentExecutor(FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_INDUSTRY), null)
|
||||
assert.equal(
|
||||
getFulfillmentExecutor(FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI)?.key,
|
||||
FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI,
|
||||
@@ -50,35 +30,21 @@ test('affiliate_dash executor 暴露 preparePaidTask 与 resolveDeliveryLink', (
|
||||
assert.ok(executor)
|
||||
assert.equal(typeof executor.preparePaidTask, 'function')
|
||||
assert.equal(typeof executor.resolveDeliveryLink, 'function')
|
||||
// affiliate_dash 不需要 lewan 专属动作
|
||||
assert.equal(executor.prepareBinding, undefined)
|
||||
assert.equal(executor.redeemTask, undefined)
|
||||
})
|
||||
|
||||
test('lewan executor 暴露完整履约动作', () => {
|
||||
const executor = getFulfillmentExecutor(FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD)
|
||||
assert.ok(executor)
|
||||
assert.equal(typeof executor.prepareBinding, 'function')
|
||||
assert.equal(typeof executor.rebindRole, 'function')
|
||||
assert.equal(typeof executor.refreshRole, 'function')
|
||||
assert.equal(typeof executor.confirmRole, 'function')
|
||||
assert.equal(typeof executor.redeemTask, 'function')
|
||||
assert.equal(typeof executor.dispatchTask, 'function')
|
||||
assert.equal(typeof executor.returnNumber, 'function')
|
||||
})
|
||||
test('retired lewan/feifei stubs prepare 幂等 no-op,不返回领取链接', async () => {
|
||||
const lewan = getFulfillmentExecutor(FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD)
|
||||
const feifei = getFulfillmentExecutor(FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI)
|
||||
assert.ok(lewan?.preparePaidTask)
|
||||
assert.ok(feifei?.resolveDeliveryLink)
|
||||
|
||||
test('feifei / manual 不支持 lewan 专属动作时 registry 返回 null', async () => {
|
||||
const feifei = makeTask(FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI)
|
||||
const manual = makeTask(FULFILLMENT_EXECUTOR_KEYS.MANUAL_DISPATCH)
|
||||
|
||||
assert.equal(await prepareFulfillmentBinding(feifei), null)
|
||||
assert.equal(await rebindFulfillmentRole(feifei), null)
|
||||
assert.equal(await refreshFulfillmentRole(feifei), null)
|
||||
assert.equal(await confirmFulfillmentRole(feifei), null)
|
||||
assert.equal(await redeemFulfillmentTask(feifei), null)
|
||||
assert.equal(await dispatchFulfillmentTask(feifei), null)
|
||||
assert.equal(await returnFulfillmentNumber(feifei), null)
|
||||
|
||||
assert.equal(await redeemFulfillmentTask(manual), null)
|
||||
assert.equal(await dispatchFulfillmentTask(manual), null)
|
||||
const task = { id: 1, executor_key: FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD } as any
|
||||
assert.equal(await lewan.preparePaidTask!(task, {} as any), task)
|
||||
assert.equal(
|
||||
await feifei.resolveDeliveryLink!({
|
||||
id: 2,
|
||||
executor_key: FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI,
|
||||
} as any),
|
||||
null,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import { isPaidPreparationStableStatus } from '../../../domain/task-status.js'
|
||||
import { kuaishouCloudExecutor } from './kuaishou-cloud-executor.js'
|
||||
import { kuaishouFeifeiExecutor } from './kuaishou-feifei-executor.js'
|
||||
import { manualDispatchExecutor } from './manual-executor.js'
|
||||
import { affiliateDashExecutor } from './affiliate-dash-executor.js'
|
||||
import { legacyFeifeiExecutor, legacyLewanExecutor } from './legacy-retired-executor.js'
|
||||
import { manualDispatchExecutor } from './manual-executor.js'
|
||||
import {
|
||||
FULFILLMENT_EXECUTOR_KEYS,
|
||||
isManualDispatchExecutor,
|
||||
normalizeExecutorKey,
|
||||
type FulfillmentActionOptions,
|
||||
type FulfillmentDeliveryLink,
|
||||
type FulfillmentExecutor,
|
||||
type FulfillmentPrepareDeps,
|
||||
@@ -15,11 +13,10 @@ import {
|
||||
import type { TaskRow } from '../../../types/repository/rows.js'
|
||||
|
||||
const EXECUTORS = new Map<string, FulfillmentExecutor>([
|
||||
[FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD, kuaishouCloudExecutor],
|
||||
[FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_INDUSTRY, kuaishouCloudExecutor],
|
||||
[FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI, kuaishouFeifeiExecutor],
|
||||
[FULFILLMENT_EXECUTOR_KEYS.AFFILIATE_DASH, affiliateDashExecutor],
|
||||
[FULFILLMENT_EXECUTOR_KEYS.MANUAL_DISPATCH, manualDispatchExecutor],
|
||||
[FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD, legacyLewanExecutor],
|
||||
[FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI, legacyFeifeiExecutor],
|
||||
])
|
||||
|
||||
export function getFulfillmentExecutor(executorKey: unknown): FulfillmentExecutor | null {
|
||||
@@ -56,52 +53,3 @@ export async function resolveFulfillmentDeliveryLink(
|
||||
|
||||
return executor.resolveDeliveryLink(task)
|
||||
}
|
||||
|
||||
async function runExecutorAction(
|
||||
task: TaskRow,
|
||||
method:
|
||||
| 'prepareBinding'
|
||||
| 'rebindRole'
|
||||
| 'refreshRole'
|
||||
| 'confirmRole'
|
||||
| 'redeemTask'
|
||||
| 'dispatchTask'
|
||||
| 'returnNumber',
|
||||
options: FulfillmentActionOptions = {},
|
||||
) {
|
||||
const executor = getFulfillmentExecutor(task.executor_key)
|
||||
const handler = executor?.[method]
|
||||
if (!handler) {
|
||||
return null
|
||||
}
|
||||
|
||||
return handler(task, options)
|
||||
}
|
||||
|
||||
export function prepareFulfillmentBinding(task: TaskRow, options: FulfillmentActionOptions = {}) {
|
||||
return runExecutorAction(task, 'prepareBinding', options)
|
||||
}
|
||||
|
||||
export function rebindFulfillmentRole(task: TaskRow, options: FulfillmentActionOptions = {}) {
|
||||
return runExecutorAction(task, 'rebindRole', options)
|
||||
}
|
||||
|
||||
export function refreshFulfillmentRole(task: TaskRow, options: FulfillmentActionOptions = {}) {
|
||||
return runExecutorAction(task, 'refreshRole', options)
|
||||
}
|
||||
|
||||
export function confirmFulfillmentRole(task: TaskRow, options: FulfillmentActionOptions = {}) {
|
||||
return runExecutorAction(task, 'confirmRole', options)
|
||||
}
|
||||
|
||||
export function redeemFulfillmentTask(task: TaskRow, options: FulfillmentActionOptions = {}) {
|
||||
return runExecutorAction(task, 'redeemTask', options)
|
||||
}
|
||||
|
||||
export function dispatchFulfillmentTask(task: TaskRow, options: FulfillmentActionOptions = {}) {
|
||||
return runExecutorAction(task, 'dispatchTask', options)
|
||||
}
|
||||
|
||||
export function returnFulfillmentNumber(task: TaskRow, options: FulfillmentActionOptions = {}) {
|
||||
return runExecutorAction(task, 'returnNumber', options)
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@ import type { TaskRow } from '../../../types/repository/rows.js'
|
||||
|
||||
export const FULFILLMENT_EXECUTOR_KEYS = {
|
||||
MANUAL_DISPATCH: 'manual_dispatch',
|
||||
KUAISHOU_CLOUD: 'kuaishou_ct_assisted',
|
||||
KUAISHOU_INDUSTRY: 'kuaishou-industry',
|
||||
KUAISHOU_FEIFEI: 'kuaishou_feifei',
|
||||
AFFILIATE_DASH: 'affiliate_dash',
|
||||
/** @deprecated 已下线,仅历史任务 / stub 识别 */
|
||||
KUAISHOU_CLOUD: 'kuaishou_ct_assisted',
|
||||
/** @deprecated 已下线,仅历史任务识别 */
|
||||
KUAISHOU_INDUSTRY: 'kuaishou-industry',
|
||||
/** @deprecated 已下线,仅历史任务 / stub 识别 */
|
||||
KUAISHOU_FEIFEI: 'kuaishou_feifei',
|
||||
} as const
|
||||
|
||||
export type FulfillmentExecutorKey =
|
||||
@@ -38,11 +41,6 @@ export type FulfillmentActionOptions = {
|
||||
actor?: unknown
|
||||
autoFinalize?: boolean
|
||||
errorCodePrefix?: string
|
||||
/**
|
||||
* 退号时是否顺带核销行业电子凭证。
|
||||
* - true/默认:发货收尾(claim autoFinalize)
|
||||
* - false:仅清理虚拟号(admin 退号),与核销无关
|
||||
*/
|
||||
consumeIndustryVoucher?: boolean
|
||||
[key: string]: unknown
|
||||
}
|
||||
@@ -56,62 +54,12 @@ export type FulfillmentExecutor = {
|
||||
key: FulfillmentExecutorKey
|
||||
preparePaidTask?: (task: TaskRow, deps: FulfillmentPrepareDeps) => Promise<TaskRow | null>
|
||||
resolveDeliveryLink?: (task: TaskRow) => Promise<FulfillmentDeliveryLink | null>
|
||||
/** lewan:准备绑定资源(虚拟号 / bindUrl) */
|
||||
prepareBinding?: (
|
||||
task: TaskRow,
|
||||
options?: FulfillmentActionOptions,
|
||||
) => Promise<FulfillmentActionResult>
|
||||
/** lewan:换绑角色 */
|
||||
rebindRole?: (
|
||||
task: TaskRow,
|
||||
options?: FulfillmentActionOptions,
|
||||
) => Promise<FulfillmentActionResult>
|
||||
/** lewan:刷新角色信息 */
|
||||
refreshRole?: (
|
||||
task: TaskRow,
|
||||
options?: FulfillmentActionOptions,
|
||||
) => Promise<FulfillmentActionResult>
|
||||
/** lewan:确认角色(UID 匹配后落 ROLE_CONFIRMED) */
|
||||
confirmRole?: (
|
||||
task: TaskRow,
|
||||
options?: FulfillmentActionOptions,
|
||||
) => Promise<FulfillmentActionResult>
|
||||
/** lewan:一键兑换(状态机 + dispatch) */
|
||||
redeemTask?: (
|
||||
task: TaskRow,
|
||||
options?: FulfillmentActionOptions,
|
||||
) => Promise<FulfillmentActionResult>
|
||||
/** lewan:后台/系统发货(不经 claim 一键兑换) */
|
||||
dispatchTask?: (
|
||||
task: TaskRow,
|
||||
options?: FulfillmentActionOptions,
|
||||
) => Promise<FulfillmentActionResult>
|
||||
/**
|
||||
* lewan:退还虚拟号。
|
||||
* 默认可顺带核销;admin 清理请传 consumeIndustryVoucher: false。
|
||||
*/
|
||||
returnNumber?: (
|
||||
task: TaskRow,
|
||||
options?: FulfillmentActionOptions,
|
||||
) => Promise<FulfillmentActionResult>
|
||||
}
|
||||
|
||||
export function normalizeExecutorKey(value: unknown): FulfillmentExecutorKey {
|
||||
return String(value || '').trim() as FulfillmentExecutorKey
|
||||
}
|
||||
|
||||
export function isKuaishouCloudExecutor(value: unknown): boolean {
|
||||
const executorKey = normalizeExecutorKey(value)
|
||||
return (
|
||||
executorKey === FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD ||
|
||||
executorKey === FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_INDUSTRY
|
||||
)
|
||||
}
|
||||
|
||||
export function isKuaishouFeifeiExecutor(value: unknown): boolean {
|
||||
return normalizeExecutorKey(value) === FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI
|
||||
}
|
||||
|
||||
export function isAffiliateDashExecutor(value: unknown): boolean {
|
||||
return normalizeExecutorKey(value) === FULFILLMENT_EXECUTOR_KEYS.AFFILIATE_DASH
|
||||
}
|
||||
@@ -119,3 +67,12 @@ export function isAffiliateDashExecutor(value: unknown): boolean {
|
||||
export function isManualDispatchExecutor(value: unknown): boolean {
|
||||
return normalizeExecutorKey(value) === FULFILLMENT_EXECUTOR_KEYS.MANUAL_DISPATCH
|
||||
}
|
||||
|
||||
export function isRetiredFulfillmentExecutor(value: unknown): boolean {
|
||||
const executorKey = normalizeExecutorKey(value)
|
||||
return (
|
||||
executorKey === FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_CLOUD ||
|
||||
executorKey === FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_FEIFEI ||
|
||||
executorKey === FULFILLMENT_EXECUTOR_KEYS.KUAISHOU_INDUSTRY
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user