fix(jd): 京东数据库价格列恢复显示+时间三列后移(2026-11-16 客户三问)

This commit is contained in:
2026-11-16 00:38:14 +08:00
parent ee3ff6fe8c
commit 46a334004a
4 changed files with 67 additions and 24 deletions
@@ -19,7 +19,11 @@ export interface JdProductItem {
title: string
brand: string
categoryPath: string
/** 价格区间下限(京麦 priceDetailVO.minJdPrice):后端 BigDecimal 序列化成 JSON number,
* decimalText 数值/字符串都收——2026-11-16 实录:text() 把 number 丢成空串=生产库
* 273/273 行 price_min 全有值而列表价格全显示「-」(用户报「价格没采集到」的真因)。 */
priceMin: string
/** 价格区间上限(京麦 priceDetailVO.maxJdPrice),解析口径同 priceMin。 */
priceMax: string
stockTotal: number | null
/** 上架中/已下架/审核中/草稿。 */
@@ -59,10 +63,13 @@ function numberOrNull(value: unknown): number | null {
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : null
}
/** 价格区间展示:min/max 都空为 -,只空一侧给单值。 */
/** 价格区间展示:min/max 都空为 -,只空一侧给单值。输入数值/字符串都收
* (后端 BigDecimal 序列化成 JSON number;列表行解析层之外,mount 测试 mock
* 绕过解析层时 number 会原样进这里——对 number 直接 .trim() 抛 TypeError
* 炸整页渲染,2026-11-16 实录),统一 decimalText 归一后再拼。 */
export function jdPriceRange(item: Pick<JdProductItem, 'priceMin' | 'priceMax'>): string {
const min = (item.priceMin || '').trim()
const max = (item.priceMax || '').trim()
const min = decimalText(item.priceMin).trim()
const max = decimalText(item.priceMax).trim()
if (min && max) return min === max ? min : `${min} ~ ${max}`
return min || max || ''
}
@@ -85,8 +92,11 @@ export function toJdProductItem(raw: unknown): JdProductItem | null {
title: text(record.title),
brand: text(record.brand),
categoryPath: text(record.categoryPath ?? record.category_path),
priceMin: text(record.priceMin ?? record.price_min),
priceMax: text(record.priceMax ?? record.price_max),
// 价格必须走 decimalText(数值/字符串都收):后端 BigDecimal 序列化成 JSON number,
// text() 对非字符串一律回空串=采集到的价格在解析层被丢掉(2026-11-16 生产库 273 行
// price_min 全有值、列表全「-」实录)。与详情 SKU 价(decimalText)同一出口。
priceMin: decimalText(record.priceMin ?? record.price_min),
priceMax: decimalText(record.priceMax ?? record.price_max),
stockTotal: numberOrNull(record.stockTotal ?? record.stock_total),
saleStatus: text(record.saleStatus ?? record.sale_status),
listTab: text(record.listTab ?? record.list_tab),