fix(fulfillment): 封堵重复载体并完善统一SKU映射
This commit is contained in:
@@ -6,6 +6,10 @@ import { INACTIVE_CARRIER_TASK_STATUSES, type FulfillmentChannel } from './chann
|
||||
import { applyIntakeChannelDecision } from './intake-channel-decision-service.js'
|
||||
import type { ResolvedFulfillmentItem } from './product-resolution-service.js'
|
||||
import { canonicalizeInternalSku, resolveInternalSkuKey } from './internal-sku-resolver.js'
|
||||
import {
|
||||
findConflictingCarrier,
|
||||
loadActiveCarrierEvidenceForItem,
|
||||
} from './carrier-evidence-service.js'
|
||||
|
||||
function parseObject(value: unknown): Record<string, unknown> {
|
||||
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
||||
@@ -77,6 +81,18 @@ export async function ensureCarrierForOrderItem(input: {
|
||||
channel: FulfillmentChannel
|
||||
}): Promise<EnsureCarrierResult> {
|
||||
const { order, item, channel } = input
|
||||
const existingCarrier = findConflictingCarrier(
|
||||
await loadActiveCarrierEvidenceForItem(Number(item.id)),
|
||||
channel,
|
||||
)
|
||||
if (existingCarrier) {
|
||||
return {
|
||||
ready: false,
|
||||
created: false,
|
||||
reason: 'existing_carrier_conflict',
|
||||
message: `订单项已有其它真实载体:${existingCarrier}`,
|
||||
}
|
||||
}
|
||||
|
||||
if (channel === 'manual') {
|
||||
const config = await query<{ id: number; canonical_product_id: number | null }>(
|
||||
|
||||
Reference in New Issue
Block a user