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

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
@@ -64,43 +64,56 @@ test('resolveKuaishouFeifeiH5UrlWithUid appends uid query', () => {
test('buildFeifeiPlatformOrderNo prefers source order number', () => {
assert.equal(
buildFeifeiPlatformOrderNo(createTask({
platform_order_id: 'KS202607080001',
task_no: 'DT600a8bd23b8',
})),
buildFeifeiPlatformOrderNo(
createTask({
platform_order_id: 'KS202607080001',
task_no: 'DT600a8bd23b8',
}),
),
'KS202607080001',
)
})
test('buildFeifeiPlatformOrderNo falls back to task number', () => {
assert.equal(
buildFeifeiPlatformOrderNo(createTask({
platform_order_id: '',
task_no: 'DT600a8bd23b8',
})),
buildFeifeiPlatformOrderNo(
createTask({
platform_order_id: '',
task_no: 'DT600a8bd23b8',
}),
),
'DT600a8bd23b8',
)
})
test('resolveKuaishouFeifeiPlatformAmount converts order fen amount to yuan', () => {
assert.equal(resolveKuaishouFeifeiPlatformAmount({
totalAmountFen: 3800,
quantity: 1,
}), 38)
assert.equal(
resolveKuaishouFeifeiPlatformAmount({
totalAmountFen: 3800,
quantity: 1,
}),
38,
)
})
test('resolveKuaishouFeifeiPlatformAmount splits amount by item quantity', () => {
assert.equal(resolveKuaishouFeifeiPlatformAmount({
totalAmountFen: 7600,
quantity: 2,
}), 38)
assert.equal(
resolveKuaishouFeifeiPlatformAmount({
totalAmountFen: 7600,
quantity: 2,
}),
38,
)
})
test('resolveKuaishouFeifeiPlatformAmount skips empty amount', () => {
assert.equal(resolveKuaishouFeifeiPlatformAmount({
totalAmountFen: 0,
quantity: 1,
}), 0)
assert.equal(
resolveKuaishouFeifeiPlatformAmount({
totalAmountFen: 0,
quantity: 1,
}),
0,
)
})
function createTask(patch: Partial<TaskRow> = {}): TaskRow {
@@ -173,19 +173,25 @@ export async function syncKuaishouFeifeiTaskStatus(task: TaskRow) {
resultMessage = consumeResult.failed[0]?.errorMessage || '电子凭证核销失败,请人工处理'
lastError = resultMessage
nextFlow.consumeStatus = 'failed'
logIntegration('[kuaishou-feifei]', '飞飞履约完成,但行业电子凭证核销失败', {
taskId: task.id,
platformOrderNo: nextFlow.platformOrderNo,
orderNo: nextFlow.orderNo,
voucherCount: consumeResult.vouchers.length,
failedCount: consumeResult.failed.length,
errorMessage: resultMessage,
}, { level: 'warn' })
logIntegration(
'[kuaishou-feifei]',
'飞飞履约完成,但行业电子凭证核销失败',
{
taskId: task.id,
platformOrderNo: nextFlow.platformOrderNo,
orderNo: nextFlow.orderNo,
voucherCount: consumeResult.vouchers.length,
failedCount: consumeResult.failed.length,
errorMessage: resultMessage,
},
{ level: 'warn' },
)
}
} else if ([40, 50, 60].includes(order.rechargeStatus)) {
nextTaskStatus = order.rechargeStatus === 60 ? TASK_STATUS.CLOSED : TASK_STATUS.MANUAL_REVIEW
resultCode = `kuaishou_feifei_status_${order.rechargeStatus}`
resultMessage = order.rechargeResultMessage || order.rechargeStatusLabel || 'kuaishou-feifei 履约异常'
resultMessage =
order.rechargeResultMessage || order.rechargeStatusLabel || 'kuaishou-feifei 履约异常'
lastError = resultMessage
}
@@ -229,10 +235,9 @@ export type KuaishouFeifeiFlow = {
}
export function normalizeKuaishouFeifeiFlow(value: unknown): KuaishouFeifeiFlow {
const source = value && typeof value === 'object' && !Array.isArray(value)
? value as JsonObject
: {}
const h5 = source.h5 && typeof source.h5 === 'object' ? source.h5 as JsonObject : {}
const source =
value && typeof value === 'object' && !Array.isArray(value) ? (value as JsonObject) : {}
const h5 = source.h5 && typeof source.h5 === 'object' ? (source.h5 as JsonObject) : {}
return {
flowType: 'kuaishou_feifei',
@@ -263,10 +268,7 @@ export function resolveKuaishouFeifeiClaimUrl(value: unknown) {
}
/** 在已有 expectedUid 时返回拼好 uid 的 H5 链接。 */
export function resolveKuaishouFeifeiH5UrlWithUid(
value: unknown,
expectedUid?: unknown,
) {
export function resolveKuaishouFeifeiH5UrlWithUid(value: unknown, expectedUid?: unknown) {
const directUrl = resolveKuaishouFeifeiClaimUrl(value)
if (!directUrl) {
return ''
@@ -319,9 +321,7 @@ function mergeKuaishouFeifeiOrder(
}
}
function resolveKuaishouFeifeiDirectClaimUrl(
flow: KuaishouFeifeiFlow,
) {
function resolveKuaishouFeifeiDirectClaimUrl(flow: KuaishouFeifeiFlow) {
const h5ClaimUrl = flow.h5.rechargeUrl || flow.h5.entryUrl
if (h5ClaimUrl) {
return h5ClaimUrl
@@ -335,7 +335,9 @@ function resolveKuaishouFeifeiDirectClaimUrl(
return isLocalClaimUrl(flow.claimUrl) ? '' : flow.claimUrl
}
function resolveKuaishouFeifeiOrderClaimUrl(order: Awaited<ReturnType<typeof createKuaishouFeifeiOrder>>) {
function resolveKuaishouFeifeiOrderClaimUrl(
order: Awaited<ReturnType<typeof createKuaishouFeifeiOrder>>,
) {
return String(order.h5.rechargeUrl || order.h5.entryUrl || '').trim()
}