All checks were successful
Build and Deploy Front / deploy (push) Successful in 3m58s
支持声明式报价模板(壹号/万国/3PE)、左列渠道识别、对比步预填新建渠道并写入草稿买价;按票挂号费并入操作费 handling。 Co-authored-by: Cursor <cursoragent@cursor.com>
74 lines
2.7 KiB
TypeScript
74 lines
2.7 KiB
TypeScript
import XLSX from 'xlsx'
|
|
import { parseSheetMatrixWithTemplate } from '../src/views/channel/pricingWorkbench/channelQuoteLocalParse'
|
|
import { BUILTIN_QUOTE_TEMPLATES } from '../src/views/channel/pricingWorkbench/channelQuoteTemplateSeeds'
|
|
|
|
const files = [
|
|
{
|
|
path: 'd:/wechatremake/xwechat_files/wxid_1ebse7qb7gde12_c306/msg/file/2026-11/壹号小包价格2026.11.07大VIP最低对外底价.xlsx',
|
|
templateKey: 'yihao-xiaobao',
|
|
sheet: 'TK扫一枪 预上网渠道',
|
|
expectModels: 3,
|
|
expectNames: ['690普货BT', '690特货ABT', '690纯电BT'],
|
|
},
|
|
{
|
|
path: 'd:/wechatremake/xwechat_files/wxid_1ebse7qb7gde12_c306/msg/file/2026-11/万国优联递球村报价表2026.11.10(1).xlsx',
|
|
templateKey: 'wanguo-youlian',
|
|
sheet: '万国快线-普货',
|
|
expectModels: 1,
|
|
expectNames: ['万国快线-普货'],
|
|
},
|
|
{
|
|
path: 'd:/wechatremake/xwechat_files/wxid_1ebse7qb7gde12_c306/msg/file/2026-11/3PE Express&ePost报价表2026-05-08(5).xlsx',
|
|
templateKey: '3pe-express',
|
|
sheet: '3SZ01-3PE Express--优先',
|
|
expectModelsMin: 1,
|
|
expectCode: '3SZ01',
|
|
},
|
|
] as const
|
|
|
|
let failed = 0
|
|
for (const case_ of files) {
|
|
const tpl = BUILTIN_QUOTE_TEMPLATES.find((t) => t.templateKey === case_.templateKey)
|
|
const wb = XLSX.readFile(case_.path, { cellDates: true })
|
|
const ws = wb.Sheets[case_.sheet]
|
|
const matrix = XLSX.utils.sheet_to_json(ws, { header: 1, defval: '', raw: false }) as any[][]
|
|
const parsed = parseSheetMatrixWithTemplate(case_.sheet, matrix, tpl)
|
|
const names = parsed.channelQuotes.map((q) => q.channelNameHint || q.channelCodeHint || '')
|
|
const okCount =
|
|
'expectModels' in case_ && case_.expectModels != null
|
|
? parsed.channelQuotes.length === case_.expectModels
|
|
: parsed.channelQuotes.length >= (('expectModelsMin' in case_ && case_.expectModelsMin) || 1)
|
|
const okNames =
|
|
'expectNames' in case_ && case_.expectNames
|
|
? case_.expectNames.every((n) => names.some((x) => String(x).includes(n)))
|
|
: true
|
|
const okCode =
|
|
'expectCode' in case_ && case_.expectCode
|
|
? parsed.channelQuotes.some(
|
|
(q) =>
|
|
String(q.channelCodeHint || '').includes(case_.expectCode) ||
|
|
String(q.channelNameHint || '').includes(case_.expectCode),
|
|
)
|
|
: true
|
|
const pass = parsed.isPriceSheet && okCount && okNames && okCode
|
|
console.log(
|
|
pass ? 'PASS' : 'FAIL',
|
|
case_.templateKey,
|
|
'|',
|
|
case_.sheet,
|
|
'| models=',
|
|
parsed.channelQuotes.length,
|
|
'|',
|
|
names.join(' ; '),
|
|
'|',
|
|
parsed.strategy,
|
|
parsed.skipReason || '',
|
|
)
|
|
if (!pass) {
|
|
failed += 1
|
|
console.log(JSON.stringify(parsed.channelQuotes.slice(0, 4), null, 2))
|
|
}
|
|
}
|
|
|
|
process.exit(failed ? 1 : 0)
|