refactor(fulfillment): 移除飞飞/乐玩通道,仅保留 affiliate_dash
新单只路由 affiliate_dash(未命中走 manual_dispatch);历史飞飞/乐玩任务保留只读 stub,避免订单重同步失败。同步清理 cloudtentacles 调度、Admin 写路径与相关 env。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,25 +2,14 @@ import {
|
||||
TASK_STATUS,
|
||||
hasKuaishouCloudRedeemResultStatus,
|
||||
isKuaishouCloudCompletedStatus,
|
||||
isKuaishouCloudRoleConfirmedStatus,
|
||||
normalizeTaskStatus,
|
||||
} from '@/domain/task-status'
|
||||
import type {
|
||||
ClaimAffiliateDashFlowInfo,
|
||||
ClaimDetailData,
|
||||
ClaimKuaishouCloudFlowInfo,
|
||||
ClaimKuaishouFeifeiFlowInfo,
|
||||
} from '@/types/claim'
|
||||
import type { ClaimAffiliateDashFlowInfo, ClaimDetailData } from '@/types/claim'
|
||||
|
||||
export type ResultVariant = 'success' | 'warning' | 'info'
|
||||
export type ClaimSnapshot = ReturnType<typeof createClaimSnapshot>
|
||||
|
||||
export function createClaimSnapshot(
|
||||
detail: ClaimDetailData | null,
|
||||
options: { rebindingRole?: boolean } = {},
|
||||
) {
|
||||
const flow = detail?.kuaishouCloudFulfillment || null
|
||||
const feifei = detail?.kuaishouFeifei || null
|
||||
export function createClaimSnapshot(detail: ClaimDetailData | null) {
|
||||
const affiliateDash = detail?.affiliateDash || null
|
||||
const order = detail?.order || null
|
||||
const orderItem = detail?.orderItem || null
|
||||
@@ -30,9 +19,8 @@ export function createClaimSnapshot(
|
||||
|
||||
const expectedUid = String(claimIdentity?.expectedUid || '').trim()
|
||||
const hasExpectedUid = Boolean(expectedUid || claimIdentity?.ready)
|
||||
const roleName = flow?.role.name || flow?.binding.roleName || ''
|
||||
const roleId = flow?.role.rid || flow?.binding.roleId || ''
|
||||
const isFeifeiFlow = detail?.flowType === 'kuaishou_feifei'
|
||||
const channelOffline = Boolean(detail?.channelOffline)
|
||||
const channelOfflineMessage = String(detail?.channelOfflineMessage || '').trim()
|
||||
const isAffiliateDashFlow = detail?.flowType === 'affiliate_dash'
|
||||
const affiliateDashExpectedUid = String(
|
||||
expectedUid || affiliateDash?.expectedGameAccount || affiliateDash?.gameAccount || '',
|
||||
@@ -55,78 +43,45 @@ export function createClaimSnapshot(
|
||||
const isAffiliateDashReadyToSubmit = Boolean(
|
||||
isAffiliateDashBound && isAffiliateDashUidMatched && !isAffiliateDashBindMismatch,
|
||||
)
|
||||
const isBindUrlExpired = isDateExpired(flow?.binding.bindExpiresAt || '')
|
||||
const isBindingPrepared =
|
||||
flow?.binding.prepareStatus === 'ready' &&
|
||||
Boolean(String(flow?.binding.bindUrl || '').trim()) &&
|
||||
!isBindUrlExpired
|
||||
const isBindingPreparing = flow?.binding.prepareStatus === 'pending'
|
||||
const isRoleReady = Boolean(roleName || roleId)
|
||||
const isUidMatched =
|
||||
Boolean(expectedUid) && Boolean(roleId) && normalizeUid(expectedUid) === normalizeUid(roleId)
|
||||
const confirmRoleDisabledReason = resolveConfirmRoleDisabledReason({
|
||||
isBindingPrepared,
|
||||
isRoleReady,
|
||||
isUidMatched,
|
||||
expectedUid,
|
||||
roleId,
|
||||
rebindingRole: Boolean(options.rebindingRole),
|
||||
})
|
||||
const isRoleConfirmed = isKuaishouCloudRoleConfirmedStatus(task?.status)
|
||||
const isDispatched = String(flow?.dispatch.status || '').trim() === 'success'
|
||||
const normalizedStatus = normalizeTaskStatus(task?.status)
|
||||
const isRedeemFailed =
|
||||
normalizedStatus === TASK_STATUS.MANUAL_REVIEW ||
|
||||
normalizedStatus === TASK_STATUS.FAILED ||
|
||||
normalizedStatus === TASK_STATUS.CLOSED ||
|
||||
String(flow?.dispatch.status || '').trim() === 'failed' ||
|
||||
(isFeifeiFlow && [40, 50].includes(Number(feifei?.rechargeStatus || 0))) ||
|
||||
(isAffiliateDashFlow &&
|
||||
['ship_failed', 'cancelled'].includes(String(affiliateDash?.orderStatus || '').trim()))
|
||||
const isCompleted =
|
||||
isKuaishouCloudCompletedStatus(task?.status) ||
|
||||
(isFeifeiFlow && Number(feifei?.rechargeStatus || 0) === 30)
|
||||
const isCompleted = isKuaishouCloudCompletedStatus(task?.status)
|
||||
const hasRedeemResult =
|
||||
isDispatched ||
|
||||
hasKuaishouCloudRedeemResultStatus(task?.status) ||
|
||||
(isFeifeiFlow && [30, 40, 50, 60].includes(Number(feifei?.rechargeStatus || 0))) ||
|
||||
(isAffiliateDashFlow &&
|
||||
['delivered', 'ship_failed', 'cancelled'].includes(
|
||||
String(affiliateDash?.orderStatus || '').trim(),
|
||||
))
|
||||
const currentStep = resolveCurrentStep({
|
||||
channelOffline,
|
||||
hasExpectedUid,
|
||||
hasRedeemResult,
|
||||
isRoleConfirmed,
|
||||
isFeifeiFlow,
|
||||
isAffiliateDashFlow,
|
||||
isAffiliateDashReadyToSubmit,
|
||||
})
|
||||
const progressText = resolveProgressText({
|
||||
feifei,
|
||||
isFeifeiFlow,
|
||||
isAffiliateDashFlow,
|
||||
channelOffline,
|
||||
channelOfflineMessage,
|
||||
affiliateDash,
|
||||
isAffiliateDashFlow,
|
||||
hasExpectedUid,
|
||||
expectedUid,
|
||||
hasRedeemResult,
|
||||
isRoleConfirmed,
|
||||
isBindingPrepared,
|
||||
isUidMatched,
|
||||
isAffiliateDashReadyToSubmit,
|
||||
isAffiliateDashBindMismatch,
|
||||
})
|
||||
const resultTitle = resolveResultTitle({
|
||||
isRedeemFailed,
|
||||
isCompleted,
|
||||
isDispatched,
|
||||
isAffiliateDashFlow,
|
||||
affiliateDash,
|
||||
})
|
||||
const resultDescription = resolveResultDescription({
|
||||
detail,
|
||||
flow,
|
||||
feifei,
|
||||
affiliateDash,
|
||||
task,
|
||||
isRedeemFailed,
|
||||
@@ -134,13 +89,13 @@ export function createClaimSnapshot(
|
||||
})
|
||||
const resultVariant: ResultVariant = isRedeemFailed
|
||||
? 'warning'
|
||||
: isCompleted || isDispatched
|
||||
: isCompleted
|
||||
? 'success'
|
||||
: 'info'
|
||||
|
||||
return {
|
||||
flow,
|
||||
feifei,
|
||||
flow: null as null,
|
||||
feifei: null as null,
|
||||
affiliateDash,
|
||||
order,
|
||||
orderItem,
|
||||
@@ -149,9 +104,11 @@ export function createClaimSnapshot(
|
||||
claimIdentity,
|
||||
expectedUid,
|
||||
hasExpectedUid,
|
||||
roleName,
|
||||
roleId,
|
||||
isFeifeiFlow,
|
||||
channelOffline,
|
||||
channelOfflineMessage,
|
||||
roleName: '',
|
||||
roleId: '',
|
||||
isFeifeiFlow: false,
|
||||
isAffiliateDashFlow,
|
||||
affiliateDashExpectedUid,
|
||||
affiliateDashBoundAccount,
|
||||
@@ -159,14 +116,14 @@ export function createClaimSnapshot(
|
||||
isAffiliateDashUidMatched,
|
||||
isAffiliateDashBindMismatch,
|
||||
isAffiliateDashReadyToSubmit,
|
||||
isBindUrlExpired,
|
||||
isBindingPrepared,
|
||||
isBindingPreparing,
|
||||
isRoleReady,
|
||||
isUidMatched,
|
||||
confirmRoleDisabledReason,
|
||||
isRoleConfirmed,
|
||||
isDispatched,
|
||||
isBindUrlExpired: false,
|
||||
isBindingPrepared: false,
|
||||
isBindingPreparing: false,
|
||||
isRoleReady: false,
|
||||
isUidMatched: false,
|
||||
confirmRoleDisabledReason: '',
|
||||
isRoleConfirmed: false,
|
||||
isDispatched: false,
|
||||
isRedeemFailed,
|
||||
isCompleted,
|
||||
hasRedeemResult,
|
||||
@@ -184,37 +141,16 @@ export function normalizeUid(value: unknown) {
|
||||
.replace(/\s+/g, '')
|
||||
}
|
||||
|
||||
function resolveConfirmRoleDisabledReason(options: {
|
||||
isBindingPrepared: boolean
|
||||
isRoleReady: boolean
|
||||
isUidMatched: boolean
|
||||
expectedUid: string
|
||||
roleId: string
|
||||
rebindingRole: boolean
|
||||
}) {
|
||||
if (!options.isBindingPrepared) {
|
||||
return '绑定二维码还在准备中,请稍后自动刷新'
|
||||
}
|
||||
if (!options.isRoleReady) {
|
||||
return '请先扫码绑定自己的角色,并刷新角色信息'
|
||||
}
|
||||
if (!options.isUidMatched) {
|
||||
return `当前绑定角色 ID(${options.roleId || '-'})与填写 UID(${options.expectedUid || '-'})不一致`
|
||||
}
|
||||
if (options.rebindingRole) {
|
||||
return '正在换绑角色,请稍候'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function resolveCurrentStep(options: {
|
||||
channelOffline: boolean
|
||||
hasExpectedUid: boolean
|
||||
hasRedeemResult: boolean
|
||||
isRoleConfirmed: boolean
|
||||
isFeifeiFlow: boolean
|
||||
isAffiliateDashFlow: boolean
|
||||
isAffiliateDashReadyToSubmit: boolean
|
||||
}) {
|
||||
if (options.channelOffline) {
|
||||
return 1
|
||||
}
|
||||
if (!options.hasExpectedUid) {
|
||||
return 1
|
||||
}
|
||||
@@ -227,26 +163,22 @@ function resolveCurrentStep(options: {
|
||||
}
|
||||
return 3
|
||||
}
|
||||
if (!options.isFeifeiFlow && options.isRoleConfirmed) {
|
||||
return 3
|
||||
}
|
||||
return 2
|
||||
}
|
||||
|
||||
function resolveProgressText(options: {
|
||||
feifei: ClaimKuaishouFeifeiFlowInfo | null
|
||||
channelOffline: boolean
|
||||
channelOfflineMessage: string
|
||||
affiliateDash: ClaimAffiliateDashFlowInfo | null
|
||||
isFeifeiFlow: boolean
|
||||
isAffiliateDashFlow: boolean
|
||||
hasExpectedUid: boolean
|
||||
expectedUid: string
|
||||
hasRedeemResult: boolean
|
||||
isRoleConfirmed: boolean
|
||||
isBindingPrepared: boolean
|
||||
isUidMatched: boolean
|
||||
isAffiliateDashReadyToSubmit: boolean
|
||||
isAffiliateDashBindMismatch: boolean
|
||||
}) {
|
||||
if (options.channelOffline) {
|
||||
return options.channelOfflineMessage || '该履约渠道已下线'
|
||||
}
|
||||
if (!options.hasExpectedUid) {
|
||||
return '请填写游戏编号'
|
||||
}
|
||||
@@ -267,28 +199,12 @@ function resolveProgressText(options: {
|
||||
}
|
||||
return '已绑定,请提交发货'
|
||||
}
|
||||
if (options.isFeifeiFlow) {
|
||||
return options.feifei?.rechargeStatusLabel || `UID ${options.expectedUid},请打开领取链接`
|
||||
}
|
||||
if (options.hasRedeemResult) {
|
||||
return '兑换结果已生成'
|
||||
}
|
||||
if (options.isRoleConfirmed) {
|
||||
return '角色已确认,等待兑换'
|
||||
}
|
||||
if (!options.isBindingPrepared) {
|
||||
return '绑定链接准备中,请稍候'
|
||||
}
|
||||
if (options.isUidMatched) {
|
||||
return 'UID 已匹配,请确认兑换'
|
||||
}
|
||||
return '请完成扫码绑定并匹配 UID'
|
||||
return '当前领取流程不可用'
|
||||
}
|
||||
|
||||
function resolveResultTitle(options: {
|
||||
isRedeemFailed: boolean
|
||||
isCompleted: boolean
|
||||
isDispatched: boolean
|
||||
isAffiliateDashFlow: boolean
|
||||
affiliateDash: ClaimAffiliateDashFlowInfo | null
|
||||
}) {
|
||||
@@ -298,9 +214,6 @@ function resolveResultTitle(options: {
|
||||
if (options.isCompleted) {
|
||||
return '兑换成功'
|
||||
}
|
||||
if (options.isDispatched) {
|
||||
return '兑换请求已提交'
|
||||
}
|
||||
if (options.isAffiliateDashFlow && options.affiliateDash?.orderStatus === 'delivered') {
|
||||
return '发货已完成'
|
||||
}
|
||||
@@ -309,8 +222,6 @@ function resolveResultTitle(options: {
|
||||
|
||||
function resolveResultDescription(options: {
|
||||
detail: ClaimDetailData | null
|
||||
flow: ClaimKuaishouCloudFlowInfo | null
|
||||
feifei: ClaimKuaishouFeifeiFlowInfo | null
|
||||
affiliateDash: ClaimAffiliateDashFlowInfo | null
|
||||
task: ClaimDetailData['task'] | null
|
||||
isRedeemFailed: boolean
|
||||
@@ -319,8 +230,6 @@ function resolveResultDescription(options: {
|
||||
if (options.isRedeemFailed) {
|
||||
const message = String(
|
||||
options.task?.lastError ||
|
||||
options.flow?.dispatch.errorMessage ||
|
||||
options.feifei?.rechargeResultMessage ||
|
||||
options.affiliateDash?.failureReason ||
|
||||
options.detail?.result?.resultMessage ||
|
||||
'',
|
||||
@@ -338,13 +247,3 @@ function resolveResultDescription(options: {
|
||||
|
||||
return '你的兑换请求已经提交。后续结果会由系统保存在后台任务界面。'
|
||||
}
|
||||
|
||||
function isDateExpired(value: string | null) {
|
||||
const normalized = String(value || '').trim()
|
||||
if (!normalized) {
|
||||
return false
|
||||
}
|
||||
|
||||
const expiresTime = Date.parse(normalized)
|
||||
return Number.isFinite(expiresTime) && expiresTime <= Date.now()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user