修复停产下架:仅京喜通知只监控京喜平台
This commit is contained in:
parent
24db7fde13
commit
ee659f6dfa
@ -132,6 +132,7 @@
|
||||
`简尚-分销部专用仓` 只排除利润中心为“分销部”的链接,其他部门继续通知。
|
||||
同一备注包含多个专用仓时逐个部门排除。
|
||||
- 停产/退市替换款只有部门专用仓库存时,链接维度按替换款专用仓所属部门覆盖处理结果,该部门链接显示“仅分销部替换”等部门级替换,其他部门仍显示下架。
|
||||
- 处理说明为“仅京喜下架/仅京喜替换”时,链接维度和未下架监控都只保留京喜平台链接与订单,其他平台不进入下架及乐捐判断;处理说明为“全渠道下架/全渠道替换”时才覆盖全部平台。
|
||||
- 全部批次成功后,在数据库事务中替换当天链接;失败时保留已有完整链接。
|
||||
- 最终有效写入为 0 时默认回滚;确有业务依据的正常零链接必须显式使用
|
||||
`--allow-zero-links`,避免异常空文件清空当天快照。
|
||||
|
||||
@ -8,6 +8,10 @@ import {
|
||||
shouldExcludeDedicatedWarehouseLink,
|
||||
type DiscontinuationLinkImportStats,
|
||||
} from '@/server/services/supply-chain-discontinuation-link-import'
|
||||
import {
|
||||
isJingxiOnlyHandling,
|
||||
isJingxiPlatform,
|
||||
} from '@/lib/supply-chain-discontinuation-link-filters'
|
||||
|
||||
loadEnvConfig(process.cwd())
|
||||
|
||||
@ -24,6 +28,7 @@ type NoticeRecord = {
|
||||
id: string
|
||||
barcode: string
|
||||
specialWarehouseNote: string
|
||||
handlingNote: string
|
||||
}
|
||||
|
||||
type OwnerRecord = {
|
||||
@ -177,7 +182,7 @@ async function main() {
|
||||
const statTime = new Date()
|
||||
try {
|
||||
const noticeRows = (await db.query<NoticeRecord>(
|
||||
`SELECT id, barcode, "specialWarehouseNote"
|
||||
`SELECT id, barcode, "specialWarehouseNote", "handlingNote"
|
||||
FROM "SupplyChainDiscontinuationNotice"
|
||||
WHERE "statDate" = $1::date`,
|
||||
[statDate],
|
||||
@ -208,6 +213,7 @@ async function main() {
|
||||
let skippedNotOnline = 0
|
||||
let skippedByDedicatedWarehouse = 0
|
||||
let skippedByCloudWarehouse = 0
|
||||
let skippedByJingxiScope = 0
|
||||
let writtenRows = 0
|
||||
|
||||
const insertBatch = async (rows: Array<Record<string, string>>) => {
|
||||
@ -221,6 +227,13 @@ async function main() {
|
||||
const itemId = code(row.product_id)
|
||||
const shopSkuCode = code(row.shop_sku_code)
|
||||
const owner = ownerByItemId.get(itemId)
|
||||
if (
|
||||
isJingxiOnlyHandling(notice.handlingNote)
|
||||
&& !isJingxiPlatform(row.platform)
|
||||
) {
|
||||
skippedByJingxiScope += 1
|
||||
return ''
|
||||
}
|
||||
if (shouldExcludeDedicatedWarehouseLink(
|
||||
notice.specialWarehouseNote,
|
||||
owner?.profitCenter,
|
||||
@ -339,6 +352,7 @@ async function main() {
|
||||
skippedNotOnline,
|
||||
skippedByDedicatedWarehouse,
|
||||
skippedByCloudWarehouse,
|
||||
skippedByJingxiScope,
|
||||
allowZeroLinks,
|
||||
} satisfies DiscontinuationLinkImportStats
|
||||
}, async (initialStats) => {
|
||||
@ -439,6 +453,7 @@ async function main() {
|
||||
skippedNotOnline,
|
||||
skippedByDedicatedWarehouse: storedStats.skippedByDedicatedWarehouse ?? 0,
|
||||
skippedByCloudWarehouse: storedStats.skippedByCloudWarehouse ?? 0,
|
||||
skippedByJingxiScope: storedStats.skippedByJingxiScope ?? 0,
|
||||
writtenRows: storedStats.writtenRows,
|
||||
storedRows: stored.rows[0]?.count ?? 0,
|
||||
allowZeroLinks,
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import {
|
||||
buildDiscontinuationLinkFilterWhere,
|
||||
isJingxiOnlyHandling,
|
||||
isJingxiPlatform,
|
||||
parseDiscontinuationFilterValues,
|
||||
} from './supply-chain-discontinuation-link-filters'
|
||||
|
||||
@ -49,4 +51,13 @@ describe('supply chain discontinuation link filters', () => {
|
||||
ownerName: { in: ['正露', '春蕾'], mode: 'insensitive' },
|
||||
})
|
||||
})
|
||||
|
||||
it('scopes Jingxi-only handling to Jingxi platform links', () => {
|
||||
expect(isJingxiOnlyHandling('仅京喜下架')).toBe(true)
|
||||
expect(isJingxiOnlyHandling('仅京喜替换')).toBe(true)
|
||||
expect(isJingxiOnlyHandling('全渠道下架')).toBe(false)
|
||||
expect(isJingxiPlatform('Jos')).toBe(true)
|
||||
expect(isJingxiPlatform('京喜')).toBe(true)
|
||||
expect(isJingxiPlatform('Pinduoduo')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@ -23,6 +23,15 @@ export type DiscontinuationLinkFilterInput = {
|
||||
owner?: readonly string[]
|
||||
}
|
||||
|
||||
export function isJingxiOnlyHandling(value: unknown) {
|
||||
return String(value ?? '').trim().startsWith('仅京喜')
|
||||
}
|
||||
|
||||
export function isJingxiPlatform(value: unknown) {
|
||||
const platform = String(value ?? '').trim().toLowerCase()
|
||||
return platform === 'jos' || platform === 'jingxi' || platform.includes('京喜')
|
||||
}
|
||||
|
||||
function filterValues(values: readonly string[] | undefined) {
|
||||
return Array.from(new Set(
|
||||
(values ?? []).map((value) => value.trim()).filter(Boolean),
|
||||
|
||||
@ -10,6 +10,7 @@ export type DiscontinuationLinkImportStats = {
|
||||
skippedNotOnline: number
|
||||
skippedByDedicatedWarehouse?: number
|
||||
skippedByCloudWarehouse?: number
|
||||
skippedByJingxiScope?: number
|
||||
allowZeroLinks: boolean
|
||||
}
|
||||
function normalizeProfitCenter(value: unknown) {
|
||||
|
||||
@ -6,6 +6,10 @@ import {
|
||||
isDiscontinuationOwnerNameMatch,
|
||||
type DiscontinuationDataScope,
|
||||
} from '@/lib/supply-chain-discontinuation-permissions'
|
||||
import {
|
||||
isJingxiOnlyHandling,
|
||||
isJingxiPlatform,
|
||||
} from '@/lib/supply-chain-discontinuation-link-filters'
|
||||
import { evaluateActivityRegistrationAppeal } from '@/lib/supply-chain-discontinuation-activity-appeal'
|
||||
import { isDiscontinuationAppealReason } from '@/lib/supply-chain-discontinuation-penalty'
|
||||
import { hasBusinessRole } from '@/lib/role-scope'
|
||||
@ -133,6 +137,7 @@ class SupplyChainDiscontinuationPenaltyService {
|
||||
deptHead: string
|
||||
profitCenter: string
|
||||
noticeDate: string
|
||||
handlingNote: string
|
||||
}>>(Prisma.sql`
|
||||
SELECT DISTINCT ON (link."shopId", link."itemId", link."shopSkuCode")
|
||||
notice.barcode,
|
||||
@ -144,7 +149,8 @@ class SupplyChainDiscontinuationPenaltyService {
|
||||
link."ownerName",
|
||||
link."deptHead",
|
||||
link."profitCenter",
|
||||
TO_CHAR(notice."statDate", 'YYYY-MM-DD') AS "noticeDate"
|
||||
TO_CHAR(notice."statDate", 'YYYY-MM-DD') AS "noticeDate",
|
||||
notice."handlingNote"
|
||||
FROM "SupplyChainDiscontinuationNoticeLink" link
|
||||
INNER JOIN "SupplyChainDiscontinuationNotice" notice
|
||||
ON notice.id = link."noticeId"
|
||||
@ -159,6 +165,12 @@ class SupplyChainDiscontinuationPenaltyService {
|
||||
`)
|
||||
|
||||
return rows.flatMap<DiscontinuationPenaltyLink>((row) => {
|
||||
if (
|
||||
isJingxiOnlyHandling(row.handlingNote)
|
||||
&& !isJingxiPlatform(row.platform)
|
||||
) {
|
||||
return []
|
||||
}
|
||||
const noticeAt = parseNoticeDateAtNine(row.noticeDate)
|
||||
if (!noticeAt) return []
|
||||
return [{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user