fix(supply-chain): 清空停产退市商品限价
(cherry picked from commit 42b374801df5926aba8f302af518a538e2baede1)
This commit is contained in:
parent
0509df6408
commit
1c1efebf27
@ -0,0 +1,38 @@
|
|||||||
|
import { resolveLimitPriceFields } from './supply-chain-limit-price-fields'
|
||||||
|
|
||||||
|
const ACTIVE_INPUT = {
|
||||||
|
productStatus: '销售',
|
||||||
|
ownerLimitPrice: 286.9,
|
||||||
|
costPrice: '128.50',
|
||||||
|
limitUpdatedAt: new Date('2026-04-21T20:54:00.000Z'),
|
||||||
|
limitInitiator: '玉衡',
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('resolveLimitPriceFields', () => {
|
||||||
|
it('calculates all limit price fields for an active product', () => {
|
||||||
|
const fields = resolveLimitPriceFields(ACTIVE_INPUT)
|
||||||
|
|
||||||
|
expect(fields.opsPriceLimit).toBe('286.90')
|
||||||
|
expect(fields.nonOwnerLimitPriceNew).toBe('301.25')
|
||||||
|
expect(fields.limitInitiator).toBe('玉衡')
|
||||||
|
})
|
||||||
|
|
||||||
|
it.each(['停产', ' 退市 '])('clears every limit field for %s products', (productStatus) => {
|
||||||
|
const fields = resolveLimitPriceFields({
|
||||||
|
...ACTIVE_INPUT,
|
||||||
|
productStatus,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(fields).toEqual({
|
||||||
|
opsPriceLimit: '',
|
||||||
|
nonOwnerLimitPriceNew: '',
|
||||||
|
jxLimitPrice: '',
|
||||||
|
alibabaPageLimitPrice: '',
|
||||||
|
distributorPrice89: '',
|
||||||
|
distributorPrice85: '',
|
||||||
|
distributorPrice80: '',
|
||||||
|
limitUpdatedAt: '',
|
||||||
|
limitInitiator: '',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -3,24 +3,37 @@
|
|||||||
* 负责人限价来自限价流程(货号维度);其余字段按固定公式从负责人限价 / 成本价推导。
|
* 负责人限价来自限价流程(货号维度);其余字段按固定公式从负责人限价 / 成本价推导。
|
||||||
* 供限价明细页查询(service)与导出(export service)共用。
|
* 供限价明细页查询(service)与导出(export service)共用。
|
||||||
*/
|
*/
|
||||||
|
const INACTIVE_PRODUCT_STATUSES = new Set(['停产', '退市'])
|
||||||
|
|
||||||
|
function emptyLimitPriceFields() {
|
||||||
|
return {
|
||||||
|
opsPriceLimit: '',
|
||||||
|
nonOwnerLimitPriceNew: '',
|
||||||
|
jxLimitPrice: '',
|
||||||
|
alibabaPageLimitPrice: '',
|
||||||
|
distributorPrice89: '',
|
||||||
|
distributorPrice85: '',
|
||||||
|
distributorPrice80: '',
|
||||||
|
limitUpdatedAt: '',
|
||||||
|
limitInitiator: '',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function resolveLimitPriceFields(input: {
|
export function resolveLimitPriceFields(input: {
|
||||||
|
productStatus: string
|
||||||
ownerLimitPrice: number | null
|
ownerLimitPrice: number | null
|
||||||
costPrice: string
|
costPrice: string
|
||||||
limitUpdatedAt: Date | null
|
limitUpdatedAt: Date | null
|
||||||
limitInitiator: string
|
limitInitiator: string
|
||||||
}) {
|
}) {
|
||||||
|
if (INACTIVE_PRODUCT_STATUSES.has(input.productStatus.trim())) {
|
||||||
|
return emptyLimitPriceFields()
|
||||||
|
}
|
||||||
const owner = input.ownerLimitPrice
|
const owner = input.ownerLimitPrice
|
||||||
const format = (value: number | null) => (value === null ? '' : value.toFixed(2))
|
const format = (value: number | null) => (value === null ? '' : value.toFixed(2))
|
||||||
if (owner === null) {
|
if (owner === null) {
|
||||||
return {
|
return {
|
||||||
opsPriceLimit: '',
|
...emptyLimitPriceFields(),
|
||||||
nonOwnerLimitPriceNew: '',
|
|
||||||
jxLimitPrice: '',
|
|
||||||
alibabaPageLimitPrice: '',
|
|
||||||
distributorPrice89: '',
|
|
||||||
distributorPrice85: '',
|
|
||||||
distributorPrice80: '',
|
|
||||||
limitUpdatedAt: '',
|
|
||||||
limitInitiator: input.limitInitiator,
|
limitInitiator: input.limitInitiator,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -218,10 +218,19 @@ export class SupplyChainProductArchiveExportService {
|
|||||||
currentStorageType: row.storageType,
|
currentStorageType: row.storageType,
|
||||||
config,
|
config,
|
||||||
})
|
})
|
||||||
|
const styleLimit = styleLimitByCode.get(String(record.sku ?? '').trim())
|
||||||
|
const limitFields = resolveLimitPriceFields({
|
||||||
|
productStatus: row.productStatus,
|
||||||
|
ownerLimitPrice: styleLimit?.ownerLimitPrice ?? null,
|
||||||
|
costPrice: String(row.costPrice ?? ''),
|
||||||
|
limitUpdatedAt: styleLimit?.approvedAt ?? null,
|
||||||
|
limitInitiator: styleLimit?.initiator ?? '',
|
||||||
|
})
|
||||||
if (!ownerEmploymentIndex) {
|
if (!ownerEmploymentIndex) {
|
||||||
return {
|
return {
|
||||||
...row,
|
...row,
|
||||||
...warehouseFields,
|
...warehouseFields,
|
||||||
|
...limitFields,
|
||||||
} satisfies SupplyChainProductArchiveRow
|
} satisfies SupplyChainProductArchiveRow
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@ -230,12 +239,7 @@ export class SupplyChainProductArchiveExportService {
|
|||||||
...warehouseFields,
|
...warehouseFields,
|
||||||
opsHead: resolveOwnerTakeover(record.opsHead ?? '', ownerEmploymentIndex).display || row.opsHead,
|
opsHead: resolveOwnerTakeover(record.opsHead ?? '', ownerEmploymentIndex).display || row.opsHead,
|
||||||
designer: resolveDesignerView(record.designer ?? '', ownerEmploymentIndex).display || row.designer,
|
designer: resolveDesignerView(record.designer ?? '', ownerEmploymentIndex).display || row.designer,
|
||||||
...resolveLimitPriceFields({
|
...limitFields,
|
||||||
ownerLimitPrice: styleLimitByCode.get(String(record.sku ?? '').trim())?.ownerLimitPrice ?? null,
|
|
||||||
costPrice: String(row.costPrice ?? ''),
|
|
||||||
limitUpdatedAt: styleLimitByCode.get(String(record.sku ?? '').trim())?.approvedAt ?? null,
|
|
||||||
limitInitiator: styleLimitByCode.get(String(record.sku ?? '').trim())?.initiator ?? '',
|
|
||||||
}),
|
|
||||||
} satisfies SupplyChainProductArchiveRow
|
} satisfies SupplyChainProductArchiveRow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,6 +145,7 @@ export class SupplyChainProductArchiveService {
|
|||||||
// 限价派生字段(限价明细页 / 导出共用):负责人限价 + 非负责人 / 京喜 / 阿里 / 分销商折扣
|
// 限价派生字段(限价明细页 / 导出共用):负责人限价 + 非负责人 / 京喜 / 阿里 / 分销商折扣
|
||||||
const styleLimit = styleLimitByCode.get(String(record.sku ?? '').trim())
|
const styleLimit = styleLimitByCode.get(String(record.sku ?? '').trim())
|
||||||
const limitFields = resolveLimitPriceFields({
|
const limitFields = resolveLimitPriceFields({
|
||||||
|
productStatus: row.productStatus,
|
||||||
ownerLimitPrice: styleLimit?.ownerLimitPrice ?? null,
|
ownerLimitPrice: styleLimit?.ownerLimitPrice ?? null,
|
||||||
costPrice: String(row.costPrice ?? ''),
|
costPrice: String(row.costPrice ?? ''),
|
||||||
limitUpdatedAt: styleLimit?.approvedAt ?? null,
|
limitUpdatedAt: styleLimit?.approvedAt ?? null,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user