重构订单履约发货流程
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
import { findLatestOrderByPlatformOrderId } from '../../repositories/order-repo.js'
|
||||
import { listKuaishouIndustryVouchersByOid } from '../../repositories/kuaishou-industry-voucher-repo.js'
|
||||
import { listTasksByOrderId } from '../../repositories/task-repo.js'
|
||||
import { buildClaimUrl } from '../claim/claim-service.js'
|
||||
import { ensureTaskClaimLink } from '../fulfillment/kuaishou-cloud/index.js'
|
||||
import {
|
||||
ensureKuaishouFeifeiClaimShortLink,
|
||||
resolveKuaishouFeifeiClaimUrl,
|
||||
} from '../fulfillment/kuaishou-feifei/index.js'
|
||||
import { resolveTaskDeliveryLink } from '../fulfillment/delivery-link-service.js'
|
||||
import { logIntegration } from '../../utils/logger.js'
|
||||
import {
|
||||
OPEN_91_MANUAL_FAILED_STATUS,
|
||||
@@ -107,28 +102,8 @@ export async function queryOpen91Order(payload: JsonObject = {}, { requestId = '
|
||||
const industryReadyTaskIds = new Set(industryVoucherState.readyTaskIds)
|
||||
|
||||
for (const task of tasks) {
|
||||
let claimUrl = ''
|
||||
let expireTime: unknown = task.primary_claim_expires_at || task.claim_expires_at || ''
|
||||
const primaryToken = String(task.primary_claim_token || task.claim_token || '').trim()
|
||||
|
||||
if (String(task.executor_key || '').trim() === 'kuaishou_feifei') {
|
||||
const context = parseJsonObject(task.context_json)
|
||||
claimUrl = await ensureKuaishouFeifeiClaimShortLink(task)
|
||||
if (!claimUrl) {
|
||||
claimUrl = resolveKuaishouFeifeiClaimUrl(context.kuaishouFeifei)
|
||||
}
|
||||
expireTime = ''
|
||||
} else if (primaryToken) {
|
||||
claimUrl = buildClaimUrl(primaryToken)
|
||||
} else if (String(task.executor_key || '').trim() === 'kuaishou_ct_assisted') {
|
||||
try {
|
||||
const ensured = await ensureTaskClaimLink(task)
|
||||
claimUrl = String(ensured.claimUrl || '').trim()
|
||||
expireTime = ensured.expiredAt || expireTime
|
||||
} catch {
|
||||
claimUrl = ''
|
||||
}
|
||||
}
|
||||
const deliveryLink = await resolveTaskDeliveryLink(task)
|
||||
const claimUrl = String(deliveryLink?.claimUrl || '').trim()
|
||||
|
||||
if (!claimUrl) {
|
||||
continue
|
||||
@@ -141,7 +116,7 @@ export async function queryOpen91Order(payload: JsonObject = {}, { requestId = '
|
||||
readyTaskIds.push(Number(task.id))
|
||||
cardItems.push(buildOpen91CardItem({
|
||||
claimUrl,
|
||||
expireTime,
|
||||
expireTime: deliveryLink?.expireTime || '',
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user