优化履约账号优先级配置

This commit is contained in:
yml2213
2026-05-26 12:44:01 +08:00
parent 2ff320c6ac
commit 6e85002724
26 changed files with 161 additions and 181 deletions
@@ -75,7 +75,7 @@ export async function prepareAdminTaskKuaishouCloudFulfillment(
const taskContext = parseTaskContext(task)
const flow = normalizeKuaishouCloudFlow(taskContext.kuaishouCloudFulfillment)
const cloudContext = resolvePersistedCloudtentaclesContext()
const cloudContext = resolvePersistedCloudtentaclesContext(flow.binding.cloudSourceKeys)
const [knapsack, skuList] = await Promise.all([
getCloudtentaclesKnapsack(cloudContext),
listCloudtentaclesSku(cloudContext),
@@ -164,6 +164,7 @@ export async function prepareAdminTaskKuaishouCloudFulfillment(
...flowWithResolvedBinding,
binding: {
...flowWithResolvedBinding.binding,
resolvedSourceKey: cloudContext.resolvedSourceKey,
vnKey: preparedBinding.vnKey,
prepareStatus: 'ready',
vnId,
@@ -250,7 +251,10 @@ export async function dispatchAdminTaskKuaishouCloudFulfillment(
const taskContext = parseTaskContext(task)
const flow = normalizeKuaishouCloudFlow(taskContext.kuaishouCloudFulfillment)
const cloudContext = resolvePersistedCloudtentaclesContext()
const cloudContext = resolvePersistedCloudtentaclesContext([
flow.binding.resolvedSourceKey,
...flow.binding.cloudSourceKeys,
])
if (!flow.binding.skuId || !flow.binding.vnId || !flow.binding.vnPhone) {
throw createHttpError('当前任务还没有准备好绑定资源,请先准备绑定资源', {
@@ -364,7 +368,10 @@ export async function refreshAdminTaskKuaishouCloudRoleInfo(
})
}
const cloudContext = resolvePersistedCloudtentaclesContext()
const cloudContext = resolvePersistedCloudtentaclesContext([
flow.binding.resolvedSourceKey,
...flow.binding.cloudSourceKeys,
])
const bindInfoResult = await getCloudtentaclesBindInfo({
...cloudContext,
key: flow.binding.vnKey,
@@ -441,7 +448,10 @@ export async function returnNumberAdminTaskKuaishouCloudFulfillment(
const taskContext = parseTaskContext(task)
const flow = normalizeKuaishouCloudFlow(taskContext.kuaishouCloudFulfillment)
const cloudContext = resolvePersistedCloudtentaclesContext()
const cloudContext = resolvePersistedCloudtentaclesContext([
flow.binding.resolvedSourceKey,
...flow.binding.cloudSourceKeys,
])
if (!flow.binding.vnId || !flow.binding.vnKey) {
throw createHttpError('当前任务缺少可退还的虚拟号信息', {
@@ -1,7 +1,7 @@
import { createHttpError } from '../../../utils/http.js'
import type { HttpErrorLike } from '../../../utils/http.js'
import {
resolvePersistedCloudtentaclesContext as resolveFulfillmentPersistedCloudtentaclesContext,
resolvePersistedCloudtentaclesContextBySourceKeys,
} from '../../fulfillment/kuaishou-cloud/cloudtentacles-context.js'
export {
@@ -23,6 +23,7 @@ export type CloudtentaclesContext = {
token: string
deviceId: string
deviceType: number
resolvedSourceKey: string
}
export type CloudSkuLikeItem = {
@@ -62,9 +63,9 @@ export type PreparedKuaishouCloudBindResource = {
bindUrl: string
}
export function resolvePersistedCloudtentaclesContext(): CloudtentaclesContext {
export function resolvePersistedCloudtentaclesContext(sourceKeys: unknown[]): CloudtentaclesContext {
try {
return resolveFulfillmentPersistedCloudtentaclesContext()
return resolvePersistedCloudtentaclesContextBySourceKeys(sourceKeys)
} catch (error) {
if (isMissingCloudtentaclesTokenError(error)) {
throw createHttpError('当前 cloudtentacles 没有可用 token,请先到平台配置完成登录校验', {