统一前后端代码格式化配置

This commit is contained in:
yml2213
2026-08-16 17:27:12 +08:00
parent 8705f6a6a1
commit 5c7c3e14e3
278 changed files with 6386 additions and 5500 deletions
@@ -52,10 +52,13 @@ export async function prepareAffiliateDashTask(task: TaskRow) {
}
if (!flow.sku) {
throw createHttpError('affiliate-dash 商品 sku 缺失,请配置 91 商品 → affiliate_dash sku 映射', {
statusCode: 409,
errorCode: 'affiliate_dash_sku_missing',
})
throw createHttpError(
'affiliate-dash 商品 sku 缺失,请配置 91 商品 → affiliate_dash sku 映射',
{
statusCode: 409,
errorCode: 'affiliate_dash_sku_missing',
},
)
}
const siblingTasks = await listTasksByOrderId(task.order_id)
@@ -97,13 +100,18 @@ export async function prepareAffiliateDashTask(task: TaskRow) {
)
}
if (!consumeResult.ok) {
logIntegration('[affiliate-dash]', '建单成功但电子凭证核销失败,delivered 回调将兜底重试', {
taskId: task.id,
orderNo: order.orderNo,
voucherCount: consumeResult.vouchers.length,
failedCount: consumeResult.failed.length,
errorMessage: consumeResult.failed[0]?.errorMessage || '',
}, { level: 'warn' })
logIntegration(
'[affiliate-dash]',
'建单成功但电子凭证核销失败,delivered 回调将兜底重试',
{
taskId: task.id,
orderNo: order.orderNo,
voucherCount: consumeResult.vouchers.length,
failedCount: consumeResult.failed.length,
errorMessage: consumeResult.failed[0]?.errorMessage || '',
},
{ level: 'warn' },
)
}
} else {
nextFlow.consumeStatus = 'not_required'
@@ -231,11 +239,16 @@ export async function syncAffiliateDashTaskStatus(
resultMessage = consumeResult.failed[0]?.errorMessage || '电子凭证核销失败,请人工处理'
lastError = resultMessage
nextFlow.consumeStatus = 'failed'
logIntegration('[affiliate-dash]', 'affiliate-dash 履约完成但核销失败', {
taskId: task.id,
orderNo: flow.orderNo,
errorMessage: resultMessage,
}, { level: 'warn' })
logIntegration(
'[affiliate-dash]',
'affiliate-dash 履约完成但核销失败',
{
taskId: task.id,
orderNo: flow.orderNo,
errorMessage: resultMessage,
},
{ level: 'warn' },
)
}
break
}
@@ -256,7 +269,12 @@ export async function syncAffiliateDashTaskStatus(
}
const isAlreadyTerminal = (
[TASK_STATUS.REDEEMED, TASK_STATUS.MANUAL_REVIEW, TASK_STATUS.CLOSED, TASK_STATUS.FAILED] as string[]
[
TASK_STATUS.REDEEMED,
TASK_STATUS.MANUAL_REVIEW,
TASK_STATUS.CLOSED,
TASK_STATUS.FAILED,
] as string[]
).includes(task.task_status)
// 终态保护:已收敛成功的任务,非 delivered 状态不允许降级(如轮询时平台详情短暂返回
// delivering/paid 会把 REDEEMED 打回 REDEEMING,导致结果页闪烁/倒退)。
@@ -316,9 +334,8 @@ export type AffiliateDashFlow = {
}
export function normalizeAffiliateDashFlow(value: unknown): AffiliateDashFlow {
const source = value && typeof value === 'object' && !Array.isArray(value)
? value as JsonObject
: {}
const source =
value && typeof value === 'object' && !Array.isArray(value) ? (value as JsonObject) : {}
return {
flowType: 'affiliate_dash',
@@ -397,10 +414,15 @@ async function preflightAffiliateDashWallet(sku: string) {
if ((error as { errorCode?: string })?.errorCode === 'affiliate_dash_wallet_not_enough') {
throw error
}
logIntegration('[affiliate-dash]', '余额预检失败(忽略,继续下单)', {
sku,
error: error instanceof Error ? error.message : String(error),
}, { level: 'warn' })
logIntegration(
'[affiliate-dash]',
'余额预检失败(忽略,继续下单)',
{
sku,
error: error instanceof Error ? error.message : String(error),
},
{ level: 'warn' },
)
}
}