feifei 优化 订单编号
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
|
|
||||||
import { resolveKuaishouFeifeiClaimUrl } from './index.js'
|
import {
|
||||||
|
buildFeifeiPlatformOrderNo,
|
||||||
|
resolveKuaishouFeifeiClaimUrl,
|
||||||
|
} from './index.js'
|
||||||
|
import type { TaskRow } from '../../../types/repository/rows.js'
|
||||||
|
|
||||||
test('resolveKuaishouFeifeiClaimUrl prefers feifei h5 url over local claim url', () => {
|
test('resolveKuaishouFeifeiClaimUrl prefers feifei h5 url over local claim url', () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
@@ -41,3 +45,66 @@ test('resolveKuaishouFeifeiClaimUrl prefers internal short link', () => {
|
|||||||
'https://ks.khhao.com/s/AbCd1234',
|
'https://ks.khhao.com/s/AbCd1234',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('buildFeifeiPlatformOrderNo prefers source order number', () => {
|
||||||
|
assert.equal(
|
||||||
|
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',
|
||||||
|
})),
|
||||||
|
'DT600a8bd23b8',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
function createTask(patch: Partial<TaskRow> = {}): TaskRow {
|
||||||
|
return {
|
||||||
|
id: 123,
|
||||||
|
order_id: 456,
|
||||||
|
order_item_id: 789,
|
||||||
|
unit_index: 0,
|
||||||
|
platform_order_id: '',
|
||||||
|
profile_id: 0,
|
||||||
|
task_no: '',
|
||||||
|
executor_key: 'kuaishou_feifei',
|
||||||
|
task_status: 'pending',
|
||||||
|
delivery_status: 'pending',
|
||||||
|
result_code: '',
|
||||||
|
result_message: '',
|
||||||
|
automation_mode: 'auto',
|
||||||
|
requires_claim: true,
|
||||||
|
user_action_status: 'not_required',
|
||||||
|
attempt_count: 0,
|
||||||
|
runtime_session_id: '',
|
||||||
|
login_type: '',
|
||||||
|
nickname: '',
|
||||||
|
role_name: '',
|
||||||
|
role_id: '',
|
||||||
|
area: '',
|
||||||
|
partition_name: '',
|
||||||
|
claim_token: '',
|
||||||
|
primary_claim_token: '',
|
||||||
|
primary_claim_token_id: null,
|
||||||
|
primary_claim_token_status: '',
|
||||||
|
artifacts_json: '{}',
|
||||||
|
context_json: '{}',
|
||||||
|
screenshot_path: '',
|
||||||
|
last_error: '',
|
||||||
|
retry_count: 0,
|
||||||
|
created_at: '2026-07-08T00:00:00.000Z',
|
||||||
|
updated_at: '2026-07-08T00:00:00.000Z',
|
||||||
|
claimed_at: null,
|
||||||
|
role_confirmed_at: null,
|
||||||
|
redeemed_at: null,
|
||||||
|
...patch,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -343,7 +343,12 @@ function isLocalClaimUrl(value: unknown) {
|
|||||||
return !/^https?:\/\//i.test(url) || url.includes('/#/claim/')
|
return !/^https?:\/\//i.test(url) || url.includes('/#/claim/')
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildFeifeiPlatformOrderNo(task: TaskRow) {
|
export function buildFeifeiPlatformOrderNo(task: TaskRow) {
|
||||||
|
const platformOrderId = String(task.platform_order_id || '').trim()
|
||||||
|
if (platformOrderId && platformOrderId.length <= 64) {
|
||||||
|
return platformOrderId
|
||||||
|
}
|
||||||
|
|
||||||
const taskNo = String(task.task_no || '').trim()
|
const taskNo = String(task.task_no || '').trim()
|
||||||
if (taskNo && taskNo.length <= 64) {
|
if (taskNo && taskNo.length <= 64) {
|
||||||
return taskNo
|
return taskNo
|
||||||
|
|||||||
Reference in New Issue
Block a user