feat(京东上架): 选分类=整分类上架+多店勾选不再整单拒(2026-11-26 晚客户口径)
客户口径「商品信息不要显示,选分类上架就行」「去掉一次只能发一家店的约束」: - 后端 JdPublishTaskService:resolveSingleShop→resolveSourceShops(多店不整单判死); applyTargetShop 四档——没带目标店且多店仍拒(老页面/老客户端 fail-closed), 带目标店时异店或多店一律 NEW;多店任务级来源店不钉死(明细行各带来源店快照) - 用户端:商品勾选列表/分页器下线,选中分类自动分页拉全整分类商品纳入上架集 (终止按累计行数对撞 total,不按本页满不满判);multi 档带 target=与 cross 同档 (协议≥4+琥珀人工确认),未检测=先点检测;建单目标店透传 - 台账:catch-silence blocks 338→339(loadProducts 拉取失败有红色出口,非静默) - 判据:JdPublishTaskServiceTest 多店两支(新增不钉来源/老口径仍拒)+ jd-publish-shop 纯函数+jd-publish-tab/mount 对齐
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
* 是哪一个店铺?」;2026-11-26 客户口径「要跨店」后判据从「必须同店」改成「同店与跨店都行」)。
|
||||
*
|
||||
* 三份身份,各有唯一出处,三层同一标记:
|
||||
* 1. **来源店铺**=所勾商品行的 `shopName/shopId`(京东数据库快照)。服务端建单时按它做
|
||||
* 「一单只能发到一家店」校验(`JdPublishTaskService.resolveSingleShop`),并把它钉进
|
||||
* 任务载荷与明细下发(`JdPublishItemsPageVo.shopId/shopName`);
|
||||
* 1. **来源店铺**=上架集商品行(2026-11-26 晚起=所选分类全部商品行)的 `shopName/shopId`
|
||||
* (京东数据库快照)。服务端建单时按它归一
|
||||
* 发布模式(`JdPublishTaskService.resolveSourceShops`:单店可克隆、异店/多店整单走新增;
|
||||
* 2026-11-26 晚客户口径「去掉一次只能发一家店的约束」后多店不再整单拒绝),
|
||||
* 单店时钉进任务载荷、多店时只有明细行各带来源店(`JdPublishItemsPageVo.shopId/shopName`);
|
||||
* 2. **京麦当前登录店铺**=桥 `get_jd_shop_info` 现拉(客户端起有头浏览器读京麦首屏),
|
||||
* 不是页面缓存、也不是上次「同步分类」的残留;跨店时它就是**目标店**(服务端据此算
|
||||
* `publishMode=NEW`,客户端走京麦「新增商品」路径);
|
||||
@@ -47,8 +49,12 @@ export type JdShopGuard =
|
||||
| { state: 'match'; expected: JdShopRef; actual: JdShopRef }
|
||||
/** 京麦登录的不是来源店 ⇒ 跨店上架(目标店=京麦当前登录店,走新增商品路径) */
|
||||
| { state: 'cross'; expected: JdShopRef; target: JdShopRef; message: string }
|
||||
/** 勾选的商品来自多家店 ⇒ 服务端也会拒(按店分开勾) */
|
||||
| { state: 'multi'; shops: JdShopRef[]; message: string }
|
||||
/**
|
||||
* 勾选的商品来自多家店(2026-11-26 晚客户口径「去掉一次只能发一家店的约束」):
|
||||
* 已检测京麦 ⇒ 整单按跨店新增放行(目标店=京麦登录店,服务端 publishMode=NEW,
|
||||
* 与 cross 档同样要协议 ≥4 与人工确认);未检测 ⇒ 拦(建单没有目标店,服务端也会拒)。
|
||||
*/
|
||||
| { state: 'multi'; shops: JdShopRef[]; target: JdShopRef | null; message: string }
|
||||
|
||||
function text(value: unknown): string {
|
||||
return String(value ?? '').trim()
|
||||
@@ -108,10 +114,19 @@ export function crossShopMessage(source: JdShopRef | null | undefined, target: J
|
||||
+ '否则该商品会按「目标店没有授权类目」逐行失败。')
|
||||
}
|
||||
|
||||
/** 跨店勾选整句(与服务端建单拒绝文案同口径:按店分开勾)。 */
|
||||
export function multiShopMessage(shops: ReadonlyArray<JdShopRef>): string {
|
||||
/** 多店已检测京麦:整单跨店新增的说明句(与服务端 NEW 档口径一致)。 */
|
||||
export function multiShopCrossMessage(shops: ReadonlyArray<JdShopRef>, target: JdShopRef): string {
|
||||
const labels = shops.map((shop) => shopLabel(shop)).join('、')
|
||||
return `本次勾选的商品来自多个店铺(${labels}),一次上架只能发到一家店,请按店铺分开勾选。`
|
||||
return (`本次勾选的商品来自多个店铺(${labels}),将全部在京麦当前登录的「${shopLabel(target)}」`
|
||||
+ '以「新增商品」方式新建上架(与各来源店的商品各自独立,需京东审核通过后才上架);'
|
||||
+ '目标店须已授权各商品的类目,否则按「目标店没有授权类目」逐行失败。')
|
||||
}
|
||||
|
||||
/** 多店还没检测京麦:先检测的指引句(不带目标店建单服务端也会拒)。 */
|
||||
export function multiShopDetectMessage(shops: ReadonlyArray<JdShopRef>): string {
|
||||
const labels = shops.map((shop) => shopLabel(shop)).join('、')
|
||||
return (`本次勾选的商品来自多个店铺(${labels}):多店商品只能整单在京麦当前登录店铺`
|
||||
+ '以新增商品方式上架,请先点「检测京麦店铺」确认登录店后再建单。')
|
||||
}
|
||||
|
||||
/** true/false=能比;null=两边都缺可比字段(只认同一维度:id 对 id、名对名)。 */
|
||||
@@ -127,10 +142,17 @@ export function evaluateShopGuard(
|
||||
detected: JdShopRef | null | undefined,
|
||||
): JdShopGuard {
|
||||
const refs = sourceShopRefs(products)
|
||||
if (refs.length > 1) return { state: 'multi', shops: refs, message: multiShopMessage(refs) }
|
||||
const actual = normalizeShopRef(detected)
|
||||
if (refs.length > 1) {
|
||||
return {
|
||||
state: 'multi',
|
||||
shops: refs,
|
||||
target: actual,
|
||||
message: actual ? multiShopCrossMessage(refs, actual) : multiShopDetectMessage(refs),
|
||||
}
|
||||
}
|
||||
const expected = refs[0]
|
||||
if (!expected) return { state: 'unknown' }
|
||||
const actual = normalizeShopRef(detected)
|
||||
if (!actual) return { state: 'undetected', expected }
|
||||
const same = sameShop(expected, actual)
|
||||
// 比不了(一边只有店名、另一边只有 id)不判不匹配:宁可留给客户端强拦截,也不误拦真实任务。
|
||||
@@ -140,16 +162,20 @@ export function evaluateShopGuard(
|
||||
}
|
||||
|
||||
/**
|
||||
* UI 唯一处断:多店必拦;跨店档默认拦(本机不支持跨店=协议 < 4),
|
||||
* ``crossAllowed`` 为真时放行(客户端会走新增商品路径)。
|
||||
* UI 唯一处断:跨店与「多店已检测」档默认拦(本机不支持跨店=协议 < 4),
|
||||
* ``crossAllowed`` 为真时放行(客户端会走新增商品路径);
|
||||
* 多店还没检测京麦必拦(建单没有目标店,服务端也会拒)。
|
||||
*/
|
||||
export function shopGuardBlocks(guard: JdShopGuard, crossAllowed = false): boolean {
|
||||
if (guard.state === 'cross') return !crossAllowed
|
||||
return guard.state === 'multi'
|
||||
if (guard.state === 'multi') return !guard.target || !crossAllowed
|
||||
return false
|
||||
}
|
||||
|
||||
/** 拦截文案(空串=可建单):跨店档在协议不够时给升级提示,见 ``CROSS_UPGRADE_NOTICE``。 */
|
||||
/** 拦截文案(空串=可建单):协议不够时给升级提示,见 ``CROSS_UPGRADE_NOTICE``。 */
|
||||
export function shopGuardMessage(guard: JdShopGuard, crossAllowed = false): string {
|
||||
if (guard.state === 'cross') return crossAllowed ? '' : CROSS_UPGRADE_NOTICE
|
||||
return guard.state === 'multi' ? guard.message : ''
|
||||
if (guard.state !== 'multi') return ''
|
||||
if (!guard.target) return guard.message
|
||||
return crossAllowed ? '' : CROSS_UPGRADE_NOTICE
|
||||
}
|
||||
Reference in New Issue
Block a user