Commit c6db0645 by 张立顺

fix: support real order scene and merchant brand ids

1 parent 4f2c20f4
...@@ -8,7 +8,31 @@ export const BOUTIQUE_CUSTOMER_TAGS = [ ...@@ -8,7 +8,31 @@ export const BOUTIQUE_CUSTOMER_TAGS = [
const CUSTOMER_TAG_ORDER = BOUTIQUE_CUSTOMER_TAGS.map(item => item.value) const CUSTOMER_TAG_ORDER = BOUTIQUE_CUSTOMER_TAGS.map(item => item.value)
const BOUTIQUE_DELIVERY_SCENE_FRAGMENTS = ['1.1', '1.2', '1.3'] const BOUTIQUE_DELIVERY_SCENE_FRAGMENTS = ['1.1', '1.2', '1.3']
const FIVE_BOUNDARY_BRANDS = ['问界', '享界', '智界', '尚界', '尊界'] const BOUTIQUE_DELIVERY_SCENE_CODES = new Set([
'100101',
'100102',
'100103'
])
const FIVE_BOUNDARY_BRANDS = [
'鸿蒙智行',
'问界',
'享界',
'智界',
'尚界',
'尊界'
]
const FIVE_BOUNDARY_BRAND_IDS = new Set([
'3454',
'3503',
'3458',
'3574',
'3502',
'2695',
'2741',
'2698',
'2797',
'2740'
])
function toTagValues(value) { function toTagValues(value) {
if (Array.isArray(value)) return value if (Array.isArray(value)) return value
...@@ -52,23 +76,75 @@ function getBrandName(brand) { ...@@ -52,23 +76,75 @@ function getBrandName(brand) {
) )
} }
function includesSceneFragment(context, fragments) { function includesSceneFragment(context, fragments, sceneCodes = new Set()) {
const sceneText = [ const sceneValues = [
context?.baseSceneName, context?.baseSceneName,
context?.baseSceneCode, context?.baseSceneCode,
context?.sceneName, context?.sceneName,
context?.sceneCode context?.sceneCode
] ].filter(value => value !== undefined && value !== null && value !== '')
.filter(Boolean) if (sceneValues.some(value => sceneCodes.has(String(value).trim()))) {
.join(' ') return true
}
const sceneText = sceneValues.join(' ')
return fragments.some(fragment => sceneText.includes(fragment)) return fragments.some(fragment => sceneText.includes(fragment))
} }
function hasFiveBoundaryBrand(merchantBrands) { function getBrandNodeId(brand) {
return (Array.isArray(merchantBrands) ? merchantBrands : []).some(brand => { if (!brand || typeof brand !== 'object') return ''
const brandName = getBrandName(brand) if (Number(brand.brandId) > 0) return String(brand.brandId)
return FIVE_BOUNDARY_BRANDS.some(name => brandName.includes(name)) if (Number(brand.id) > 0) return String(brand.id)
return ''
}
function getOperatingBrandNodes(merchantBrands) {
const nodes = []
;(Array.isArray(merchantBrands) ? merchantBrands : []).forEach(brand => {
if (!brand || typeof brand !== 'object') {
if (typeof brand === 'string' && brand.trim()) nodes.push(brand)
return
}
if (Array.isArray(brand.childs) && brand.childs.length) {
brand.childs.forEach(child => {
if (child) nodes.push(child)
}) })
return
}
nodes.push(brand)
})
return nodes
}
function getMerchantBrandNames(merchantBrands) {
const names = []
function visit(brand) {
if (!brand) return
const name = getBrandName(brand)
if (name) names.push(name)
if (typeof brand === 'object' && Array.isArray(brand.childs)) {
brand.childs.forEach(visit)
}
}
;(Array.isArray(merchantBrands) ? merchantBrands : []).forEach(visit)
return names
}
function hasMerchantBrandContext(merchantBrands) {
return (
getOperatingBrandNodes(merchantBrands).some(
brand => getBrandNodeId(brand) || getBrandName(brand)
) || getMerchantBrandNames(merchantBrands).length > 0
)
}
function hasFiveBoundaryBrand(merchantBrands) {
const hasBoundaryId = getOperatingBrandNodes(merchantBrands).some(brand =>
FIVE_BOUNDARY_BRAND_IDS.has(getBrandNodeId(brand))
)
if (hasBoundaryId) return true
return getMerchantBrandNames(merchantBrands).some(brandName =>
FIVE_BOUNDARY_BRANDS.some(name => brandName.includes(name))
)
} }
export function getBoutiqueCustomerTagOptions(merchantBrands = []) { export function getBoutiqueCustomerTagOptions(merchantBrands = []) {
...@@ -85,7 +161,14 @@ export function isBoutiqueCustomerTagsVisible(salesType) { ...@@ -85,7 +161,14 @@ export function isBoutiqueCustomerTagsVisible(salesType) {
} }
export function isBoutiqueActualDeliveryDateVisible(context = {}) { export function isBoutiqueActualDeliveryDateVisible(context = {}) {
if (!includesSceneFragment(context, BOUTIQUE_DELIVERY_SCENE_FRAGMENTS)) { if (
!includesSceneFragment(
context,
BOUTIQUE_DELIVERY_SCENE_FRAGMENTS,
BOUTIQUE_DELIVERY_SCENE_CODES
) ||
!hasMerchantBrandContext(context.merchantBrands)
) {
return false return false
} }
const salesType = Number(context.salesType) const salesType = Number(context.salesType)
......
...@@ -103,6 +103,127 @@ describe('customerDailyFields.helpers', () => { ...@@ -103,6 +103,127 @@ describe('customerDailyFields.helpers', () => {
) )
}) })
it('IT-WO-DAILY-012: real scene codes use nested development and production merchant brand ids', () => {
const cases = [
{
name: 'development five-realm child rejects sales source',
context: {
salesType: 0,
baseSceneCode: 100101,
merchantBrands: [
{
id: 2978,
name: '鸿蒙智行',
childs: [{ id: '3454', name: 'AITO 问界' }]
}
]
},
expected: false
},
{
name: 'development five-realm child accepts delivery source',
context: {
salesType: 3,
baseSceneCode: '100101',
merchantBrands: [
{
id: 2978,
name: '鸿蒙智行',
childs: [{ id: 3454, name: 'AITO 问界' }]
}
]
},
expected: true
},
{
name: 'production five-realm child rejects sales source',
context: {
salesType: 0,
baseSceneCode: 100102,
merchantBrands: [
{
id: 2978,
name: '鸿蒙智行',
childs: [{ id: 2695 }]
}
]
},
expected: false
},
{
name: 'production five-realm child accepts delivery source',
context: {
salesType: 3,
baseSceneCode: 100102,
merchantBrands: [
{
id: 2978,
name: '鸿蒙智行',
childs: [{ id: 2695 }]
}
]
},
expected: true
},
{
name: 'other-brand child accepts sales source',
context: {
salesType: 0,
baseSceneCode: 100103,
merchantBrands: [
{
id: 2179,
name: '比亚迪',
childs: [{ id: 2180, name: '比亚迪' }]
}
]
},
expected: true
},
{
name: 'mixed brands use five-realm branch',
context: {
salesType: 0,
baseSceneCode: 100101,
merchantBrands: [
{
name: '经营品牌',
childs: [{ id: 2695 }, { id: 2180 }]
}
]
},
expected: false
},
{
name: 'nested brand name remains a compatibility fallback',
context: {
salesType: 0,
baseSceneCode: 100101,
merchantBrands: [
{
name: '经营品牌',
childs: [{ name: 'AITO 问界' }]
}
]
},
expected: false
},
{
name: 'missing merchant brands fails closed',
context: {
salesType: 3,
baseSceneCode: 100101,
merchantBrands: []
},
expected: false
}
]
for (const { name, context, expected } of cases) {
assert.equal(isBoutiqueActualDeliveryDateVisible(context), expected, name)
}
})
it('IT-WO-DAILY-005: reconciliation clears hidden and unavailable values', () => { it('IT-WO-DAILY-005: reconciliation clears hidden and unavailable values', () => {
const natural = reconcileBoutiqueCustomerDailyFields( const natural = reconcileBoutiqueCustomerDailyFields(
{ {
......
...@@ -193,6 +193,7 @@ describe('submitPayload.helpers', () => { ...@@ -193,6 +193,7 @@ describe('submitPayload.helpers', () => {
const { submitObj } = prepareSubmitPayload( const { submitObj } = prepareSubmitPayload(
{ {
...baseOrder, ...baseOrder,
baseSceneCode: 100104,
baseSceneName: '1.4 非适用场景', baseSceneName: '1.4 非适用场景',
customer: { customer: {
...baseOrder.customer, ...baseOrder.customer,
...@@ -206,4 +207,33 @@ describe('submitPayload.helpers', () => { ...@@ -206,4 +207,33 @@ describe('submitPayload.helpers', () => {
) )
assert.equal(submitObj.customer.actualDeliveryDate, '') assert.equal(submitObj.customer.actualDeliveryDate, '')
}) })
it('IT-WO-SUB-018: numeric scene and production merchant brand tree retain eligible date', () => {
const { submitObj } = prepareSubmitPayload(
{
...baseOrder,
baseSceneCode: 100101,
baseSceneName: '',
customer: {
...baseOrder.customer,
salesType: 3,
actualDeliveryDate: '2026-08-04'
}
},
{
merchantBrands: [
{
id: 2978,
name: '鸿蒙智行',
childs: [{ id: 2695 }]
}
]
}
)
assert.equal(
submitObj.customer.actualDeliveryDate,
'2026-08-04 00:00:00'
)
})
}) })
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!