优化任务状态投影和部署文档

This commit is contained in:
yml
2026-05-28 11:12:40 +08:00
parent 9709643583
commit ccc350cfea
15 changed files with 759 additions and 55 deletions
@@ -160,6 +160,105 @@ export function mapKuaishouCloudFulfillmentContext(
}
}
export function mapKuaishouCloudTaskStateProjection(
task: TaskLike | null | undefined,
options: KuaishouCloudFulfillmentMapOptions = {},
): JsonRecord | null {
if (!task || String(task.executor_key || '').trim() !== 'kuaishou_ct_assisted') {
return null
}
const hasProjection = [
task.kuaishou_ticket_status,
task.kuaishou_ticket_code_masked,
task.kuaishou_bind_url,
task.kuaishou_vn_phone,
task.kuaishou_role_name,
task.kuaishou_role_id,
task.kuaishou_dispatch_status,
task.kuaishou_consume_status,
task.kuaishou_source_key,
].some((value) => String(value || '').trim())
if (!hasProjection) {
return null
}
const sourceKey = String(task.kuaishou_source_key || '').trim()
const roleName = String(task.kuaishou_role_name || '').trim()
const roleId = String(task.kuaishou_role_id || '').trim()
return {
flowType: 'kuaishou_cloud_fulfillment',
configId: '',
internalSkuCode: '',
internalSkuName: '',
ticket: {
code: String(task.kuaishou_ticket_code_masked || '').trim(),
capturedAt: null,
status: String(task.kuaishou_ticket_status || 'pending').trim() || 'pending',
verifiedAt: null,
goodsTitle: '',
leftCount: 0,
},
binding: {
prepareStatus: task.kuaishou_bind_url ? 'ready' : 'pending',
cloudSourceKeys: sourceKey ? [sourceKey] : [],
cloudSourceLabels: sourceKey ? [resolveCloudSourceLabel(sourceKey, options.cloudSourceLabelMap)] : [],
resolvedSourceKey: sourceKey,
resolvedSourceLabel: sourceKey ? resolveCloudSourceLabel(sourceKey, options.cloudSourceLabelMap) : '',
skuId: 0,
skuName: '',
vnKey: '',
vnId: 0,
vnPhone: String(task.kuaishou_vn_phone || '').trim(),
bindUrl: String(task.kuaishou_bind_url || '').trim(),
bindPreparedAt: null,
bindExpiresAt: null,
bindProbeAt: null,
bindProbeStatus: '',
bindProbeMessage: '',
},
role: {
status: roleName || roleId ? 'ready' : 'pending',
name: roleName,
rid: roleId,
refreshedAt: null,
errorMessage: '',
rawInfo: null,
},
purchase: {
autoBuyEnabled: true,
minAssetReserve: 0,
usedKnapsack: false,
purchaseTriggered: false,
assetBefore: 0,
assetAfter: 0,
purchaseAt: null,
},
dispatch: {
status: String(task.kuaishou_dispatch_status || 'pending').trim() || 'pending',
dispatchAt: null,
sendType: 0,
note: '',
},
returnNumber: {
status: 'pending',
returnedAt: null,
autoReturnEnabled: false,
},
consume: {
status: String(task.kuaishou_consume_status || 'pending').trim() || 'pending',
shopId: '',
shopName: '',
autoConsumeEnabled: false,
consumedAt: null,
errorMessage: '',
},
notes: '',
}
}
function resolveCloudSourceLabel(sourceKey: string, labelMap: CloudSourceLabelMap | undefined) {
const key = String(sourceKey || '').trim()
if (!key) return ''