优化feifei商品名映射

This commit is contained in:
yml2213
2026-07-07 15:12:48 +08:00
parent 6af2fe2e23
commit 177f72dd2c
11 changed files with 235 additions and 144 deletions
@@ -3,6 +3,8 @@ import { kuaishouFeifeiRequest } from './http-client.js'
type JsonObject = Record<string, any>
export type KuaishouFeifeiProductListResult = ReturnType<typeof mapKuaishouFeifeiProductList>
export async function listKuaishouFeifeiProducts(input: {
page?: number
perPage?: number
@@ -0,0 +1,22 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { resolveKuaishouFeifeiProductByName } from './product-rule-service.js'
test('resolveKuaishouFeifeiProductByName matches generated name-code mapping by normalized name', () => {
const match = resolveKuaishouFeifeiProductByName('【自动发货】套装-Alan Walker', {
rules: [
{
productName: '套装-Alan Walker',
normalizedProductName: '套装 alan walker',
productCode: '10000013',
skuName: '套装-Alan Walker',
},
],
})
assert.equal(match?.productCode, '10000013')
assert.equal(match?.matchMode, 'kuaishou_feifei_name')
assert.equal(match?.skuName, '套装-Alan Walker')
assert.equal(match?.normalizedProductName, '套装 alan walker')
})
@@ -3,7 +3,7 @@ import { getKuaishouFeifeiConfig } from './config.js'
import type { KuaishouFeifeiProductRule } from '../../../types/runtime-config.js'
export type KuaishouFeifeiProductMatch = {
matchMode: 'kuaishou_feifei_rule'
matchMode: 'kuaishou_feifei_name'
productName: string
normalizedProductName: string
productCode: string
@@ -37,7 +37,7 @@ export function resolveKuaishouFeifeiProductByName(
}
return {
matchMode: 'kuaishou_feifei_rule',
matchMode: 'kuaishou_feifei_name',
productName: String(matched.productName || productName || '').trim(),
normalizedProductName,
productCode,