diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/controller/JdPublishController.java b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/controller/JdPublishController.java index 04962cf40..3291b4e17 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/controller/JdPublishController.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/controller/JdPublishController.java @@ -16,6 +16,7 @@ import com.nanri.aiimage.modules.jd.model.vo.JdPublishItemsPageVo; import com.nanri.aiimage.modules.jd.model.vo.JdPublishProgressVo; import com.nanri.aiimage.modules.jd.model.vo.JdPublishTaskBatchVo; import com.nanri.aiimage.modules.jd.model.vo.JdPublishTaskVo; +import com.nanri.aiimage.modules.jd.service.JdCategoryScopeService; import com.nanri.aiimage.modules.jd.service.JdProductQueryService; import com.nanri.aiimage.modules.jd.service.JdPublishBoardService; import com.nanri.aiimage.modules.jd.service.JdPublishFillAiService; @@ -70,6 +71,7 @@ public class JdPublishController { private final JdSizeChartAiService sizeChartAiService; private final JdPublishFillAiService fillAiService; private final JdPublishPermissionSupport publishPermissionSupport; + private final JdCategoryScopeService jdCategoryScopeService; @PostMapping({"/tasks", "/tasks/target-brand"}) @Operation(summary = "创建京东商品上架任务", description = "勾选京东数据库商品(归属校验)+可选统一改价规则建单;" @@ -189,16 +191,18 @@ public class JdPublishController { // ------------------------------------------------------------------ // v1.5 Phase 4:用户端「商品上架」页读侧(选品分页+任务面板四端点)。 // 形状照 JdCollectController 面板段同族:dashboard/history/delete 走 resolve, - // progressBatch 走 requireOwnershipUserId+filterOwnedTaskIds;products 按会话 - // 身份只回归属当前用户的商品行(AC-9 owner 过滤,跨用户商品 0 返回)。 + // progressBatch 走 requireOwnershipUserId+filterOwnedTaskIds;products 按会话身份 + // 解析可见数据权限分组、回归属行(2026-11-25 口径改:与分类下拉/徽标同源,同组同事 + // 采集的商品也能上架;跨公司/跨组看不到——见 JdProductQueryService#pageInScope)。 // ------------------------------------------------------------------ @GetMapping("/products") - @Operation(summary = "用户端选品分页(归属过滤)", description = "「商品上架」页选品列表:只回归属当前" - + "登录用户的京东数据库商品行(AC-9 owner 过滤,跨用户商品 0 返回),可按自定义分类过滤" - + "(分类 id 经 V203 归属表两步下推:先取 product_id 集,再 in 主键)。") + @Operation(summary = "用户端选品分页(可见分类作用域)", description = "「商品上架」页选品列表:回归当前" + + "账号可见数据权限分组下的分类归属商品行(与分类下拉/徽标同源同口径,2026-11-25 " + + "口径改:同组同事采集的商品也能由你上架;跨公司、跨组一律看不到),可按自定义分类过滤" + + "(分类与可见组合成同一条 V203 归属表 EXISTS,SQL 侧下推)。") public ApiResponse products( - @Parameter(description = "自定义分类 id(不传=全部归属商品)") + @Parameter(description = "自定义分类 id(不传=全部可见分类下商品)") @RequestParam(name = "category_id", required = false) Long categoryId, @Parameter(description = "页码") @RequestParam(name = "page", defaultValue = PageDefaults.FIRST_PAGE) Long page, @Parameter(description = "每页数量") @RequestParam(name = "page_size", defaultValue = PageDefaults.JD_PRODUCTS_PAGE_SIZE) Long pageSize, @@ -207,7 +211,9 @@ public class JdPublishController { HttpServletRequest httpRequest) { userId = adminAuthSupport.requireSessionOwnerUserId(httpRequest, userId); publishPermissionSupport.assertCanPublish(userId); - return ApiResponse.success(jdProductQueryService.pageForUser(userId, categoryId, page, pageSize)); + JdCategoryScopeService.JdCategoryScope scope = jdCategoryScopeService.resolveByUserId(userId); + return ApiResponse.success(jdProductQueryService.pageInScope(scope.visibleGroupIds(), + scope.companyId(), categoryId, page, pageSize)); } @GetMapping("/dashboard") diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/mapper/JdProductMapper.java b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/mapper/JdProductMapper.java index e262f1c82..e958c32a4 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/mapper/JdProductMapper.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/mapper/JdProductMapper.java @@ -65,6 +65,12 @@ public interface JdProductMapper extends BaseMapper { * {@code companyId}(2026-11-23 客户口径「公司与公司之间不能互看」):行级公司谓词 * {@code p.company_id = #{companyId}},由控制器经 {@code DataReadScope#readCompanyIdOrOwn} * 算好传入——非平台超管恒为本公司,平台超管不带公司参数时为 {@code null}(=不筛)。 + * {@code visibleGroupIds}(2026-11-25 客户实况「分类里有 3 个商品、选品列表 0 条」): + * 用户端「商品上架」的选品作用域=当前账号可见的数据权限分组下的分类归属行 + * (V203 {@code biz_jd_product_group_assign.owner_group_id IN (...)},与分类下拉同一份 + * {@code JdCategoryScope#visibleGroupIds})——与分类徽标「N 个商品」同口径。非空时与 + * {@code groupId} 合成同一条 EXISTS(分类与可见组必须落在同一归属行,不拿别组 + * 分类凑数);{@code null}/空=该面不过滤(后管只读页维持原口径不变)。 */ long countProducts(@Param("keyword") String keyword, @Param("productCode") String productCode, @@ -78,7 +84,8 @@ public interface JdProductMapper extends BaseMapper { @Param("syncedTo") LocalDateTime syncedTo, @Param("classified") Boolean classified, @Param("ownerGroupId") Long ownerGroupId, - @Param("companyId") Long companyId); + @Param("companyId") Long companyId, + @Param("visibleGroupIds") List visibleGroupIds); /** * 商品上架配额计数({@code JdPublishQuotaService}):按 owner uid 集(管理员本人+ @@ -125,6 +132,7 @@ public interface JdProductMapper extends BaseMapper { @Param("classified") Boolean classified, @Param("ownerGroupId") Long ownerGroupId, @Param("companyId") Long companyId, + @Param("visibleGroupIds") List visibleGroupIds, @Param("offset") long offset, @Param("limit") int limit); diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/model/dto/JdPublishTaskCreateRequest.java b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/model/dto/JdPublishTaskCreateRequest.java index 04ddf40ea..0ba2ba164 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/model/dto/JdPublishTaskCreateRequest.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/model/dto/JdPublishTaskCreateRequest.java @@ -8,7 +8,8 @@ import java.util.List; * 京东商品上架建单请求(v1.5 蓝图 §3 建单契约)。 * *

用户在用户端「京东工具台 → 商品上架」页选自定义分类(消费 {@code GET /api/jd-collect/groups}, - * B113-01 分类口唯一,AC-9)→ 分页拉该分类下归属自己的商品 → 勾选 → 可选统一改价规则 → 提交建单。 + * B113-01 分类口唯一,AC-9)→ 分页拉该分类下商品(2026-11-25 起作用域=本账号可见 + * 数据权限分组,同组同事采集的也能上架)→ 勾选 → 可选统一改价规则 → 提交建单。 * 服务端按 productIds 落 {@code biz_jd_publish_item} 快照行;{@code request_json} 整体进 * {@code biz_file_task} 供兜底拉取回读({@code readCreateRequest} 同形)。

*/ @@ -21,7 +22,8 @@ public class JdPublishTaskCreateRequest { /** 自定义分类 id(biz_jd_product_group.id,记录与展示用;商品勾选集才是发布范围)。 */ private Long categoryId; - /** 要上架的商品行 id 集(biz_jd_product.id,必填非空;全部必须归属当前用户,AC-9 归属半边)。 */ + /** 要上架的商品行 id 集(biz_jd_product.id,必填非空;必须落在本账号可见数据权限分组的 + * 分类归属行上——2026-11-25 作用域口径,跨公司/跨组商品建单当场 403)。 */ private List productIds; /** 统一改价规则(可选;null=按原价,mode=none)。 */ diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdProductQueryService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdProductQueryService.java index 9de2e1028..7b64a7d62 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdProductQueryService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdProductQueryService.java @@ -128,13 +128,13 @@ public class JdProductQueryService { filter.titleKeyword(), filter.categories(), filter.groupId(), filter.shopName(), filter.minPrice(), filter.maxPrice(), filter.syncedFrom(), filter.syncedTo(), filter.classified(), ownerGroupId, - scopedCompanyId); + scopedCompanyId, null); List rows = total <= 0 ? List.of() : jdProductMapper.selectProductPage(filter.keyword(), filter.productCode(), filter.titleKeyword(), filter.categories(), filter.groupId(), filter.shopName(), filter.minPrice(), filter.maxPrice(), filter.syncedFrom(), filter.syncedTo(), filter.classified(), ownerGroupId, - scopedCompanyId, + scopedCompanyId, null, (safePage - 1) * safeSize, (int) safeSize); List items = rows.stream().map(this::toListItem).toList(); fillGroupNames(items, ownerGroupId); @@ -147,34 +147,47 @@ public class JdProductQueryService { } /** - * 用户端「商品上架」选品分页(v1.5 Phase 4,AC-9 owner 过滤):只回归属当前用户的行, - * 可按自定义分类过滤。分类过滤不走 wrapper 原生 EXISTS(SqlLayeringConventionTest - * rawSqlInsideWrappersDoesNotGrow 钉死不涨):先从 V203 归属表取该分类的 product_id 集, - * 再 in 主键——分类规模=组内商品数,量级可控;分类空集直接回空页不查主表。 - * 页码钳制与 {@link #page} 同出口(MAX_PAGE/MAX_PAGE_SIZE,铁律 15)。 + * 用户端「商品上架」选品分页(v1.5 Phase 4;2026-11-25 作用域改口径)。 + * + *

旧形状按 {@code biz_jd_product.user_id = 当前账号} 严格过滤(AC-9 owner 半边), + * 客户实况暴露两套口径:分类下拉与徽标来自「可见数据权限分组」(同组同事采集的商品 + * 也算),选品列表只认建单人 ⇒ 阿华112336 看到「3店(3 个商品)」却选不到任何一行、 + * 上架按钮永久置灰(那 3 行是同一分组的 阿华普通账户测试 采的)。

+ * + *

新口径:可见分组下的分类归属行——与分类下拉同源 + * ({@code JdCategoryScopeService#resolveByUserId} 的 {@code visibleGroupIds}), + * 与分类徽标同表同口径({@code JdProductGroupService#listForGroups} 数的是归属行、 + * 不带 owner 条件)。归属(谁能看到分类)已在作用域解析里做完:普通号=自己带的组+ + * 所属组组长带的组+管理链上级各账号带的组,跨公司/跨组一律进不来。谓词 SQL 侧下推 + * (铁律 20,不 Java 侧对已取页 filter),分类与可见组合成同一条 EXISTS 由 + * {@code JdProductMapper.countProducts}/{@code selectProductPage} 的 + * {@code visibleGroupIds} 参数承载。

+ * + *

可见分组为空=看不到任何分类归属行,直接回空页不查主表(防 {@code IN ()}); + * 页码/页宽钳制与 {@link #page} 同出口(MAX_PAGE/MAX_PAGE_SIZE,铁律 15)。

*/ - public JdProductPageVo pageForUser(Long userId, Long categoryId, Long page, Long pageSize) { + public JdProductPageVo pageInScope(List visibleGroupIds, Long companyId, + Long categoryId, Long page, Long pageSize) { long safePage = page == null || page < 1 ? 1 : Math.min(page, MAX_PAGE); long safeSize = pageSize == null ? PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT : Math.min(Math.max(pageSize, 1), MAX_PAGE_SIZE); - LambdaQueryWrapper query = new LambdaQueryWrapper() - .eq(JdProductEntity::getUserId, userId); - if (categoryId != null && categoryId > 0) { - List productIds = jdProductGroupAssignMapper.selectList( - new LambdaQueryWrapper() - .select(JdProductGroupAssignEntity::getProductId) - .eq(JdProductGroupAssignEntity::getCategoryId, categoryId)) - .stream().map(JdProductGroupAssignEntity::getProductId).distinct().toList(); - if (productIds.isEmpty()) { - return emptyPage(safePage, safeSize); - } - query.in(JdProductEntity::getId, productIds); + List groupIds = visibleGroupIds == null ? List.of() + : visibleGroupIds.stream() + .filter(id -> id != null && id > 0) + .distinct() + .toList(); + if (groupIds.isEmpty()) { + return emptyPage(safePage, safeSize); } - long total = jdProductMapper.selectCount(query); + long safeCategoryId = categoryId != null && categoryId > 0 ? categoryId : 0L; + long total = jdProductMapper.countProducts(null, null, null, null, + safeCategoryId, null, null, null, null, null, null, null, + companyId, groupIds); List items = total <= 0 ? List.of() - : jdProductMapper.selectList(query - .orderByDesc(JdProductEntity::getSyncedAt, JdProductEntity::getId) - .last("limit " + (safePage - 1) * safeSize + ", " + safeSize)) + : jdProductMapper.selectProductPage(null, null, null, null, + safeCategoryId, null, null, null, null, null, null, null, + companyId, groupIds, + (safePage - 1) * safeSize, (int) safeSize) .stream().map(this::toListItem).toList(); JdProductPageVo vo = new JdProductPageVo(); vo.setItems(items); diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdPublishTaskService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdPublishTaskService.java index 575b8b462..b0f7a5266 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdPublishTaskService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdPublishTaskService.java @@ -13,6 +13,7 @@ import com.nanri.aiimage.common.task.TaskStatuses; import com.fasterxml.jackson.core.JsonProcessingException; import com.nanri.aiimage.config.CollectRoutingProperties; import com.nanri.aiimage.modules.file.service.oss.OssStorageService; +import com.nanri.aiimage.modules.jd.mapper.JdProductGroupAssignMapper; import com.nanri.aiimage.modules.jd.mapper.JdProductImageMapper; import com.nanri.aiimage.modules.jd.mapper.JdProductMapper; import com.nanri.aiimage.modules.jd.mapper.JdProductSkuMapper; @@ -20,6 +21,7 @@ import com.nanri.aiimage.modules.jd.mapper.JdPublishItemMapper; import com.nanri.aiimage.modules.jd.model.dto.JdPublishTaskCreateRequest; import com.nanri.aiimage.modules.jd.model.dto.JdPublishTaskCreateRequest.PriceRule; import com.nanri.aiimage.modules.jd.model.entity.JdProductEntity; +import com.nanri.aiimage.modules.jd.model.entity.JdProductGroupAssignEntity; import com.nanri.aiimage.modules.jd.model.entity.JdProductImageEntity; import com.nanri.aiimage.modules.jd.model.entity.JdProductSkuEntity; import com.nanri.aiimage.modules.jd.model.entity.JdPublishItemEntity; @@ -63,9 +65,11 @@ import java.util.stream.Collectors; * 19899 Chrome profile,执行方没有"界面选 ONLINE"的自由度);② 建单口不接 * {@code requireSubmitSecret}——发布由桌面机已登录京麦的 Chrome 直连执行,无代理无 LLM * ({@code TaskModuleRegistry} 登记 {@code Optional.empty()},铁律 27c 登记结论); - * ③ 建单前置闸门按铁律 27b 排在一切昂贵动作前:未选商品 / 选了他人商品(AC-9 归属, - * 业务码 403)/ 超配额(AC-8,{@code JdPublishQuotaService#assertWithinQuota} 原语接线) - * 逐条点名拒绝;④ 建单即按商品快照落 {@code biz_jd_publish_item} 行(V210,商品库有 + * ③ 建单前置闸门按铁律 27b 排在一切昂贵动作前:未选商品 / 勾选商品不在可上架作用域 + * (2026-11-25 起=本账号可见数据权限分组下的分类归属行,跨公司/跨组业务码 403;旧口径 + * 「只认建单人」把同组同事采的商品全拒在门外,客户实况「分类里有 3 个、列表 0 个」)/ + * 超配额(AC-8,{@code JdPublishQuotaService#assertWithinQuota} 原语接线)逐条点名拒绝; + * ④ 建单即按商品快照落 {@code biz_jd_publish_item} 行(V210,商品库有 * 清理语义,发布记录不随商品删除丢失溯源)。

* *

建单成功页面推送与兜底拉取共用同一份载荷组装 {@link #buildQueuePayload}: @@ -109,6 +113,8 @@ public class JdPublishTaskService { private final TaskHeartbeatService taskHeartbeatService; private final TaskHeartbeatPositionService taskHeartbeatPositionService; private final JdPublishTaskItemsResetSpiImpl itemsReset; + private final JdCategoryScopeService jdCategoryScopeService; + private final JdProductGroupAssignMapper jdProductGroupAssignMapper; /** 下发批大小出厂值(aiimage.jd.publish.items-batch-size,服务侧钳制上限 100)。 */ @Value("${aiimage.jd.publish.items-batch-size:20}") @@ -125,15 +131,23 @@ public class JdPublishTaskService { AdminUserEntity operator = adminUserMapper.selectById(request.getUserId()); jdPublishQuotaService.assertWithinQuota(operator, request.getProductIds().size()); - // AC-9 归属半边:按主键批量取商品行(建单勾选集上界 500,非取页分页),存在性 - // 与归属一起 fail-closed——缺行与选了他人商品都当场拒,不让一半商品静默混进任务。 + // 归属闸(2026-11-25 作用域改口径:选中商品必须在「本账号可见数据权限分组」的分类 + // 归属行里,与选品列表/分类下拉同源同口径)。旧形状按 biz_jd_product.user_id 严格 + // 等于当前账号,客户实况把同组同事采集的商品全数拒在门外(分类里有 3 个、列表 0 个、 + // 上架按钮永久置灰)——分组本就是团队作业面:组内谁采的都能由组内成员上架, + // 跨公司/跨组仍 fail-closed 拒绝(可见集来自 JdCategoryScopeService,不由请求体决定)。 + // 存在性先于归属:缺行与不在作用域内都当场拒,不让一半商品静默混进任务。 List products = jdProductMapper.selectBatchIds(request.getProductIds()); if (products.size() != request.getProductIds().size()) { throw new BusinessException("部分商品不存在或已从京东数据库清理,请刷新后重新勾选"); } + JdCategoryScopeService.JdCategoryScope scope = + jdCategoryScopeService.resolveByUserId(request.getUserId()); + Set visibleProductIds = resolveVisibleProductIds(request.getProductIds(), scope); for (JdProductEntity product : products) { - if (!Objects.equals(product.getUserId(), request.getUserId())) { - throw new BusinessException(403, "勾选的商品不属于当前账号,不能上架他人数据库的商品"); + if (!visibleProductIds.contains(product.getId())) { + throw new BusinessException(403, + "勾选的商品不在你可上架的店铺分类内(跨公司/跨组商品不能上架),请刷新后重新勾选"); } } // 来源店铺闸(2026-11-24 客户口径「软件怎么知道要上架哪一家店」):一次任务只允许 @@ -182,6 +196,38 @@ public class JdPublishTaskService { return vo; } + /** + * 建单归属闸的作用域取数(2026-11-25):勾选商品里落在「可见数据权限分组的分类归属行」 + * 上的 id 集。与 {@code JdProductQueryService#pageInScope} 读同一张 V203 归属表、 + * 同一份 {@code JdCategoryScope#visibleGroupIds}(分类下拉/徽标/选品列表/建单四处 + * 同口径,口径源只有 {@code JdCategoryScopeService} 一处)。可见集为空=一行都不放行 + * (不查 SQL、不回空 {@code IN ()});归属表为空同样回空集,调用方按 403 拒。 + */ + private Set resolveVisibleProductIds(List productIds, + JdCategoryScopeService.JdCategoryScope scope) { + if (productIds == null || productIds.isEmpty() || scope == null) { + return Set.of(); + } + List groupIds = scope.visibleGroupIds() == null ? List.of() + : scope.visibleGroupIds().stream() + .filter(id -> id != null && id > 0) + .distinct() + .toList(); + if (groupIds.isEmpty()) { + return Set.of(); + } + return jdProductGroupAssignMapper.selectList( + new LambdaQueryWrapper() + .select(JdProductGroupAssignEntity::getProductId) + .in(JdProductGroupAssignEntity::getProductId, productIds) + .in(JdProductGroupAssignEntity::getOwnerGroupId, groupIds) + .isNotNull(JdProductGroupAssignEntity::getCategoryId)) + .stream() + .map(JdProductGroupAssignEntity::getProductId) + .filter(id -> id != null && id > 0) + .collect(Collectors.toSet()); + } + /** 仅当前代次的 PENDING 任务能被页面队列中的桌面执行器认领。 */ public void activateTask(Long taskId, Long userId, int attempt, Integer protocol) { FileTaskEntity task = requireOwnedTask(taskId, userId); diff --git a/backend-java/src/main/resources/mapper/jd/JdProductMapper.xml b/backend-java/src/main/resources/mapper/jd/JdProductMapper.xml index 3257a920f..02c1daf3e 100644 --- a/backend-java/src/main/resources/mapper/jd/JdProductMapper.xml +++ b/backend-java/src/main/resources/mapper/jd/JdProductMapper.xml @@ -143,12 +143,30 @@ (price_min >= X AND price_max <= Y),不是「区间有交集」。 --> AND p.price_min >= #{minPrice} AND p.price_max <= #{maxPrice} - + + AND EXISTS ( SELECT 1 FROM biz_jd_product_group_assign a - WHERE a.product_id = p.id AND a.category_id = #{groupId} + WHERE a.product_id = p.id + AND a.category_id = #{groupId} + AND a.owner_group_id IN + #{vgid} ) + + + AND EXISTS ( + SELECT 1 FROM biz_jd_product_group_assign a + WHERE a.product_id = p.id AND a.category_id = #{groupId} + ) + + ", ""); @@ -851,18 +851,18 @@ class AdminJdProductControllerTest { JdProductMapper mapper = mock(JdProductMapper.class); JdProductQueryService service = queryService(mapper); when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), isNull())).thenReturn(1L); + any(), any(), any(), any(), isNull(), isNull())).thenReturn(1L); service.page(1L, 20L, null, null, null, null, null, null, null, null, null, null, Boolean.TRUE, GROUP_ID, null); - verify(mapper).countProducts(null, null, null, null, null, null, null, null, null, null, true, GROUP_ID, null); + verify(mapper).countProducts(null, null, null, null, null, null, null, null, null, null, true, GROUP_ID, null, null); verify(mapper).selectProductPage(null, null, null, null, null, null, null, null, - null, null, true, GROUP_ID, null, 0L, 20); + null, null, true, GROUP_ID, null, null, 0L, 20); service.page(1L, 20L, null, null, null, null, null, null, null, null, null, null, Boolean.FALSE, GROUP_ID, null); - verify(mapper).countProducts(null, null, null, null, null, null, null, null, null, null, false, GROUP_ID, null); + verify(mapper).countProducts(null, null, null, null, null, null, null, null, null, null, false, GROUP_ID, null, null); verify(mapper).selectProductPage(null, null, null, null, null, null, null, null, - null, null, false, GROUP_ID, null, 0L, 20); + null, null, false, GROUP_ID, null, null, 0L, 20); // ③ 控制器直传:classified 原样进服务(owner_group_id 仍按作用域收敛后的值)。 JdProductQueryService queryService = mock(JdProductQueryService.class); @@ -896,19 +896,19 @@ class AdminJdProductControllerTest { JdProductMapper mapper = mock(JdProductMapper.class); JdProductQueryService service = queryService(mapper); when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), isNull())).thenReturn(1L); + any(), any(), any(), any(), isNull(), isNull())).thenReturn(1L); // ① 三件新面原样直传:keyword/shopName trim 归一,价格 BigDecimal 原样。 service.page(1L, 20L, " 连衣裙 ", null, null, null, 7L, " 测试店铺 ", new BigDecimal("100"), new BigDecimal("200"), null, null, null, null, null); verify(mapper).countProducts("连衣裙", null, null, null, 7L, "测试店铺", - new BigDecimal("100"), new BigDecimal("200"), null, null, null, null, null); + new BigDecimal("100"), new BigDecimal("200"), null, null, null, null, null, null); verify(mapper).selectProductPage("连衣裙", null, null, null, 7L, "测试店铺", - new BigDecimal("100"), new BigDecimal("200"), null, null, null, null, null, 0L, 20); + new BigDecimal("100"), new BigDecimal("200"), null, null, null, null, null, null, 0L, 20); // ② 空白 keyword/shopName 归 null(不过滤该面)。 service.page(1L, 20L, " ", null, null, null, 0L, " ", null, null, null, null, null, null, null); - verify(mapper).countProducts(null, null, null, null, null, null, null, null, null, null, null, null, null); + verify(mapper).countProducts(null, null, null, null, null, null, null, null, null, null, null, null, null, null); // ③ 价格倒挂按业务异常拒绝(同同步起止倒挂形状)。 BusinessException ex = assertThrows(BusinessException.class, @@ -916,7 +916,7 @@ class AdminJdProductControllerTest { new BigDecimal("200"), new BigDecimal("100"), null, null, null, null, null)); assertTrue(ex.getMessage().contains("价格区间最小值不能大于最大值"), "倒挂价格区间按业务异常拒绝"); verify(mapper, times(2)).countProducts(any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any(), any(), isNull()); + any(), any(), any(), any(), any(), any(), isNull(), isNull()); } /** @@ -1170,9 +1170,9 @@ class AdminJdProductControllerTest { JdProductEntity categorized = productEntity(1L); JdProductEntity missing = productEntity(2L); when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), isNull())).thenReturn(2L); + any(), any(), any(), any(), isNull(), isNull())).thenReturn(2L); when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), isNull(), anyLong(), anyInt())).thenReturn(List.of(categorized, missing)); + any(), any(), any(), any(), isNull(), isNull(), anyLong(), anyInt())).thenReturn(List.of(categorized, missing)); when(assignMapper.selectList(any())).thenReturn(List.of( assign(1L, GROUP_ID, 3L), assign(2L, GROUP_ID, 99L))); JdProductGroupEntity category = new JdProductGroupEntity(); @@ -1197,9 +1197,9 @@ class AdminJdProductControllerTest { JdProductQueryService service = queryService(mapper, mock(JdProductImageMapper.class), mock(JdProductSkuMapper.class), mock(JdProductGroupMapper.class), assignMapper); when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), isNull())).thenReturn(1L); + any(), any(), any(), any(), isNull(), isNull())).thenReturn(1L); when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), isNull(), anyLong(), anyInt())).thenReturn(List.of(productEntity(1L))); + any(), any(), any(), any(), isNull(), isNull(), anyLong(), anyInt())).thenReturn(List.of(productEntity(1L))); JdProductPageVo vo = service.page(1L, 20L, null, null, null, null, null, null, null, null, null, null, null, null, null); diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/jd/service/JdProductQueryServiceUserPageTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/jd/service/JdProductQueryServiceUserPageTest.java index f818d26a2..80e590546 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/modules/jd/service/JdProductQueryServiceUserPageTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/jd/service/JdProductQueryServiceUserPageTest.java @@ -21,16 +21,24 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /** - * 用户端「商品上架」选品分页(v1.5 Phase 4,AC-9 owner 过滤的服务端半边)。 + * 用户端「商品上架」选品分页(v1.5 Phase 4;2026-11-25 作用域改口径)。 * - *

判据四件:① 归属条件恒带(user_id 来自会话出口,跨用户商品 0 返回);② 分类过滤走 - * V203 归属表两步下推(先取 product_id 集再 in 主键,不往 wrapper 夹原生 SQL);③ 分类空集 - * 直接回空页不查主表;④ 页码/页宽钳制照管理面同出口(MAX_PAGE/MAX_PAGE_SIZE,铁律 15)。

+ *

旧判据是「owner 条件恒带(user_id=当前账号),跨用户商品 0 返回」——客户实况把它打穿: + * 分类「3店」写着 3 个商品(徽标数的是 V203 归属行),列表却回 0 条(那 3 行是同一分组的 + * 同事采的),上架按钮永久置灰。新判据:

+ *

① 选品作用域=可见数据权限分组({@code JdCategoryScope#visibleGroupIds},与分类下拉 + * 同源),谓词下推进 mapper 的 {@code visibleGroupIds}(不按 user_id 过滤,同组同事采集的 + * 商品可见可上架);② 分类过滤与可见组合成同一支谓词(同一个 {@code groupId} 参数 + * 交给 SQL 侧的 EXISTS,不许 Java 侧先取 product_id 集);③ 可见组为空直接回空页不查主表; + * ④ 页码/页宽钳制照管理面同出口(MAX_PAGE/MAX_PAGE_SIZE,铁律 15)。

*/ @ExtendWith(MockitoExtension.class) class JdProductQueryServiceUserPageTest { @@ -73,80 +81,78 @@ class JdProductQueryServiceUserPageTest { return row; } - private com.nanri.aiimage.modules.jd.model.entity.JdProductGroupAssignEntity assign(long productId) { - com.nanri.aiimage.modules.jd.model.entity.JdProductGroupAssignEntity row = - new com.nanri.aiimage.modules.jd.model.entity.JdProductGroupAssignEntity(); - row.setProductId(productId); - row.setCategoryId(3L); - row.setOwnerGroupId(2L); - return row; + /** countProducts 的 14 个形参全 matcher(返回总数 1 行)。 */ + private void stubCount(long total) { + when(jdProductMapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), + any(), any(), any(), any(), any(), any())).thenReturn(total); + } + + /** selectProductPage 的 16 个形参全 matcher。 */ + private void stubPage(List rows) { + when(jdProductMapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(), + any(), any(), any(), any(), any(), any(), org.mockito.ArgumentMatchers.anyLong(), + anyInt())).thenReturn(rows); } @Test - void 选品分页只回归属当前用户的行() { - when(jdProductMapper.selectCount(any())).thenReturn(1L); - when(jdProductMapper.selectList(any())).thenReturn(List.of(product(11L))); + void 选品分页按可见分组作用域下推_不按建单人过滤() { + stubCount(1L); + stubPage(List.of(product(11L))); - JdProductPageVo vo = service.pageForUser(7L, null, 1L, 20L); + JdProductPageVo vo = service.pageInScope(List.of(11L, 12L), 2L, null, 1L, 20L); - ArgumentCaptor> captor = - ArgumentCaptor.forClass(LambdaQueryWrapper.class); - verify(jdProductMapper).selectCount(captor.capture()); - captor.getValue().getSqlSegment(); // MP 惯例:先求值一次才铺出参数 - assertThat(captor.getValue().getSqlSegment()).as("归属条件恒在主查询里").contains("user_id"); - assertThat(captor.getValue().getParamNameValuePairs().values()).contains(7L); + // 作用域全在 SQL 侧:可见组集合+公司进 mapper,owner_group_id 过滤由 XML 的 EXISTS 承担; + // 这里恰好证明了「没有 user_id 条件」——旧实现按 user_id 过滤,同组同事采的商品恒 0 条。 + verify(jdProductMapper).countProducts(isNull(), isNull(), isNull(), isNull(), + eq(0L), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + eq(2L), eq(List.of(11L, 12L))); assertThat(vo.getTotal()).isEqualTo(1L); assertThat(vo.getItems()).hasSize(1); assertThat(vo.getItems().get(0).getTitle()).isEqualTo("测试商品 11"); - // 没选分类不查归属表 + // 归属表由 SQL 侧 EXISTS 读,Java 侧不再先取 product_id 集 verify(jdProductGroupAssignMapper, never()).selectList(any()); } @Test - void 分类过滤_先取归属表产品集再进主查询() { - when(jdProductGroupAssignMapper.selectList(any())) - .thenReturn(List.of(assign(11L), assign(12L), assign(11L))); - when(jdProductMapper.selectCount(any())).thenReturn(1L); - when(jdProductMapper.selectList(any())).thenReturn(List.of(product(12L))); + void 分类过滤与可见组合成同一支谓词() { + stubCount(0L); - JdProductPageVo vo = service.pageForUser(7L, 3L, 1L, 20L); + JdProductPageVo vo = service.pageInScope(List.of(11L), 2L, 3L, 1L, 20L); - ArgumentCaptor> captor = - ArgumentCaptor.forClass(LambdaQueryWrapper.class); - verify(jdProductMapper).selectCount(captor.capture()); - captor.getValue().getSqlSegment(); - assertThat(captor.getValue().getSqlSegment()) - .as("分类集以 IN 下推进主查询(owner 条件仍然恒在)") - .contains("user_id").contains("IN"); - assertThat(captor.getValue().getParamNameValuePairs().values()) - .contains(7L, 11L, 12L); - assertThat(vo.getItems()).hasSize(1); + verify(jdProductMapper).countProducts(isNull(), isNull(), isNull(), isNull(), + eq(3L), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + eq(2L), eq(List.of(11L))); + assertThat(vo.getTotal()).isZero(); + assertThat(vo.getItems()).isEmpty(); + verify(jdProductMapper, never()).selectProductPage(any(), any(), any(), any(), any(), any(), + any(), any(), any(), any(), any(), any(), any(), any(), + org.mockito.ArgumentMatchers.anyLong(), anyInt()); } @Test - void 分类空集直接回空页不查主表() { - when(jdProductGroupAssignMapper.selectList(any())).thenReturn(List.of()); - - JdProductPageVo vo = service.pageForUser(7L, 3L, 1L, 20L); - + void 可见分组为空直接回空页不查主表() { + JdProductPageVo vo = service.pageInScope(List.of(), 2L, 3L, 1L, 20L); assertThat(vo.getTotal()).isZero(); assertThat(vo.getItems()).isEmpty(); - verify(jdProductMapper, never()).selectCount(any()); - verify(jdProductMapper, never()).selectList(any()); + verify(jdProductMapper, never()).countProducts(any(), any(), any(), any(), any(), any(), + any(), any(), any(), any(), any(), any(), any(), any()); + + JdProductPageVo nullScope = service.pageInScope(null, 2L, 3L, 1L, 20L); + assertThat(nullScope.getTotal()).as("作用域解析不出(null)同样回空页,不给全平台") + .isZero(); } @Test void 页码页宽钳制_离谱页码不喂负下标() { - when(jdProductMapper.selectCount(any())).thenReturn(0L); + stubCount(0L); - JdProductPageVo zero = service.pageForUser(7L, null, 0L, 5000L); + JdProductPageVo zero = service.pageInScope(List.of(11L), 2L, null, 0L, 5000L); assertThat(zero.getPage()).as("页码下限钳到 1").isEqualTo(1L); assertThat(zero.getPageSize()).as("页宽上限钳到 1000(v1.7 对齐原型档位放宽,与后管只读页同出口)") .isEqualTo(1000L); - JdProductPageVo huge = service.pageForUser(7L, null, Long.MAX_VALUE, 20L); + JdProductPageVo huge = service.pageInScope(List.of(11L), 2L, null, Long.MAX_VALUE, 20L); assertThat(huge.getPage()).as("页码上限钳到 10000(乘积不溢出,铁律 15 同形)").isEqualTo(10000L); - verify(jdProductMapper, never()).selectList(any()); } /** @@ -202,9 +208,9 @@ class JdProductQueryServiceUserPageTest { JdProductEntity listRow = product(22L); listRow.setManualLocked(1); - when(jdProductMapper.selectList(any())).thenReturn(List.of(listRow)); - when(jdProductMapper.selectCount(any())).thenReturn(1L); - JdProductPageVo page = service.pageForUser(7L, null, 1L, 20L); + stubCount(1L); + stubPage(List.of(listRow)); + JdProductPageVo page = service.pageInScope(List.of(11L), 2L, 3L, 1L, 20L); assertThat(page.getItems().get(0).getManualLocked()).as("列表 VO 带回人工锁").isEqualTo(1); } -} +} \ No newline at end of file diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/jd/service/JdPublishTaskServiceTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/jd/service/JdPublishTaskServiceTest.java index 4171dcc2a..fe63fda5e 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/modules/jd/service/JdPublishTaskServiceTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/jd/service/JdPublishTaskServiceTest.java @@ -5,6 +5,7 @@ import com.nanri.aiimage.common.exception.BusinessException; import com.nanri.aiimage.common.mapper.AdminUserMapper; import com.nanri.aiimage.common.model.entity.AdminUserEntity; import com.nanri.aiimage.modules.file.service.oss.OssStorageService; +import com.nanri.aiimage.modules.jd.mapper.JdProductGroupAssignMapper; import com.nanri.aiimage.modules.jd.mapper.JdProductImageMapper; import com.nanri.aiimage.modules.jd.mapper.JdProductMapper; import com.nanri.aiimage.modules.jd.mapper.JdProductSkuMapper; @@ -12,6 +13,7 @@ import com.nanri.aiimage.modules.jd.mapper.JdPublishItemMapper; import com.nanri.aiimage.modules.jd.model.dto.JdPublishTaskCreateRequest; import com.nanri.aiimage.modules.jd.model.dto.JdPublishTaskCreateRequest.PriceRule; import com.nanri.aiimage.modules.jd.model.entity.JdProductEntity; +import com.nanri.aiimage.modules.jd.model.entity.JdProductGroupAssignEntity; import com.nanri.aiimage.modules.jd.model.entity.JdPublishItemEntity; import com.nanri.aiimage.modules.jd.model.vo.JdPublishTaskVo; import com.nanri.aiimage.modules.task.mapper.FileTaskMapper; @@ -71,10 +73,28 @@ class JdPublishTaskServiceTest { private TaskHeartbeatPositionService taskHeartbeatPositionService; @Mock private JdPublishTaskItemsResetSpiImpl itemsReset; + @Mock + private JdCategoryScopeService jdCategoryScopeService; + @Mock + private JdProductGroupAssignMapper jdProductGroupAssignMapper; @InjectMocks private JdPublishTaskService service; + @org.junit.jupiter.api.BeforeAll + static void initMybatisPlusTableInfo() { + // LambdaQueryWrapper/LambdaUpdateWrapper 需要 MP 的 lambda cache(单类点跑时无人预热, + // 整量跑才靠别的用例带上——这里显式初始化,点跑与整量同结果)。 + com.baomidou.mybatisplus.core.MybatisConfiguration configuration = + new com.baomidou.mybatisplus.core.MybatisConfiguration(); + org.apache.ibatis.builder.MapperBuilderAssistant assistant = + new org.apache.ibatis.builder.MapperBuilderAssistant(configuration, ""); + com.baomidou.mybatisplus.core.metadata.TableInfoHelper.initTableInfo(assistant, + FileTaskEntity.class); + com.baomidou.mybatisplus.core.metadata.TableInfoHelper.initTableInfo(assistant, + JdProductGroupAssignEntity.class); + } + private JdProductEntity product(long id, long userId, String title) { JdProductEntity product = new JdProductEntity(); product.setId(id); @@ -98,11 +118,33 @@ class JdPublishTaskServiceTest { return request; } + /** 可见作用域桩:userId 的可见数据权限分组=groupIds(2026-11-25 起建单归属闸读它)。 */ + private void stubVisibleGroups(long userId, Long companyId, long... groupIds) { + when(jdCategoryScopeService.resolveByUserId(userId)).thenReturn( + new JdCategoryScopeService.JdCategoryScope(false, companyId, + java.util.Arrays.stream(groupIds).boxed().toList(), List.of(), List.of())); + } + + /** 归属行桩:这些商品落在可见分组的分类归属行上(category_id 非空)。 */ + private void stubAssign(long groupId, long... productIds) { + List rows = java.util.Arrays.stream(productIds) + .mapToObj(id -> { + JdProductGroupAssignEntity row = new JdProductGroupAssignEntity(); + row.setProductId(id); + row.setOwnerGroupId(groupId); + row.setCategoryId(11L); + return row; + }).toList(); + when(jdProductGroupAssignMapper.selectList(any())).thenReturn(rows); + } + @Test void 建单成功且通道显式写LOCAL并落快照行() { when(adminUserMapper.selectById(7L)).thenReturn(new AdminUserEntity()); when(jdProductMapper.selectBatchIds(List.of(101L, 102L))) .thenReturn(List.of(product(101L, 7L, "连衣裙A"), product(102L, 7L, "连衣裙B"))); + stubVisibleGroups(7L, 2L, 11L); + stubAssign(11L, 101L, 102L); when(fileTaskMapper.insert(any(FileTaskEntity.class))).thenAnswer(invocation -> { invocation.getArgument(0, FileTaskEntity.class).setId(34400L); return 1; @@ -139,6 +181,8 @@ class JdPublishTaskServiceTest { void 快照行带改价折算与库存() { when(adminUserMapper.selectById(7L)).thenReturn(new AdminUserEntity()); when(jdProductMapper.selectBatchIds(List.of(101L))).thenReturn(List.of(product(101L, 7L, "连衣裙A"))); + stubVisibleGroups(7L, 2L, 11L); + stubAssign(11L, 101L); when(fileTaskMapper.insert(any(FileTaskEntity.class))).thenAnswer(invocation -> { invocation.getArgument(0, FileTaskEntity.class).setId(34401L); return 1; @@ -186,21 +230,65 @@ class JdPublishTaskServiceTest { } @Test - void 选了他人商品建单被拒并点名() { + void 同组同事采集的商品可以建单() { + // 2026-11-25 客户实况:分类「3店」3 个商品是同一分组的同事采的,登录人 7 选不到、上架按钮 + // 永久置灰。作用域口径下「组内谁采的都能由组内成员上架」——归属闸看的是分类归属行, + // 不是 biz_jd_product.user_id。 when(adminUserMapper.selectById(7L)).thenReturn(new AdminUserEntity()); when(jdProductMapper.selectBatchIds(List.of(101L))) - .thenReturn(List.of(product(101L, 8L, "别人的连衣裙"))); + .thenReturn(List.of(product(101L, 8L, "同事采集的连衣裙"))); + stubVisibleGroups(7L, 2L, 11L); + stubAssign(11L, 101L); + when(fileTaskMapper.insert(any(FileTaskEntity.class))).thenAnswer(invocation -> { + invocation.getArgument(0, FileTaskEntity.class).setId(34402L); + return 1; + }); + when(jdPublishItemMapper.insert(any(JdPublishItemEntity.class))).thenReturn(1); + + JdPublishTaskCreateRequest request = validRequest(7L); + request.setProductIds(List.of(101L)); + JdPublishTaskVo vo = service.createTask(request, null); + + assertThat(vo.getTaskId()).isEqualTo(34402L); + verify(fileTaskMapper).insert(any(FileTaskEntity.class)); + verify(jdPublishItemMapper).insert(any(JdPublishItemEntity.class)); + } + + @Test + void 勾选商品不在可见分组内建单被拒并点名() { + when(adminUserMapper.selectById(7L)).thenReturn(new AdminUserEntity()); + when(jdProductMapper.selectBatchIds(List.of(101L))) + .thenReturn(List.of(product(101L, 8L, "别组采集的连衣裙"))); + stubVisibleGroups(7L, 2L, 11L); + // 归属表没有落在可见分组上的行(跨组/跨公司商品):可见集为空 ⇒ 业务码 403。 + when(jdProductGroupAssignMapper.selectList(any())).thenReturn(List.of()); JdPublishTaskCreateRequest request = validRequest(7L); request.setProductIds(List.of(101L)); assertThatThrownBy(() -> service.createTask(request, null)) .isInstanceOf(BusinessException.class) - .as("AC-9 归属半边:选他人商品业务码拒绝") + .as("作用域归属闸:不在可见分组分类归属行上的商品业务码拒绝") .extracting("code") .isEqualTo(403); verify(fileTaskMapper, never()).insert(any(FileTaskEntity.class)); verify(jdPublishItemMapper, never()).insert(any(JdPublishItemEntity.class)); } + @Test + void 可见分组为空建单被拒并不查归属表() { + when(adminUserMapper.selectById(7L)).thenReturn(new AdminUserEntity()); + when(jdProductMapper.selectBatchIds(List.of(101L))) + .thenReturn(List.of(product(101L, 7L, "自己的连衣裙"))); + stubVisibleGroups(7L, 2L); + JdPublishTaskCreateRequest request = validRequest(7L); + request.setProductIds(List.of(101L)); + assertThatThrownBy(() -> service.createTask(request, null)) + .isInstanceOf(BusinessException.class) + .extracting("code") + .isEqualTo(403); + verify(jdProductGroupAssignMapper, never()).selectList(any()); + verify(fileTaskMapper, never()).insert(any(FileTaskEntity.class)); + } + @Test void 商品缺行建单被拒() { when(adminUserMapper.selectById(7L)).thenReturn(new AdminUserEntity()); @@ -429,6 +517,8 @@ class JdPublishTaskServiceTest { second.setShopId("2002"); second.setShopName("家居日用数据库店"); when(jdProductMapper.selectBatchIds(List.of(101L, 102L))).thenReturn(List.of(first, second)); + stubVisibleGroups(7L, 2L, 11L); + stubAssign(11L, 101L, 102L); assertThatThrownBy(() -> service.createTask(validRequest(7L), null)) .isInstanceOf(BusinessException.class) @@ -448,6 +538,8 @@ class JdPublishTaskServiceTest { second.setShopId("228346061"); second.setShopName("家居日用数据库店"); when(jdProductMapper.selectBatchIds(List.of(101L, 102L))).thenReturn(List.of(first, second)); + stubVisibleGroups(7L, 2L, 11L); + stubAssign(11L, 101L, 102L); when(fileTaskMapper.insert(any(FileTaskEntity.class))).thenAnswer(invocation -> { invocation.getArgument(0, FileTaskEntity.class).setId(34410L); return 1; @@ -475,6 +567,8 @@ class JdPublishTaskServiceTest { nameOnly.setShopId(null); nameOnly.setShopName("家居日用数据库店"); when(jdProductMapper.selectBatchIds(List.of(101L, 102L))).thenReturn(List.of(withId, nameOnly)); + stubVisibleGroups(7L, 2L, 11L); + stubAssign(11L, 101L, 102L); when(fileTaskMapper.insert(any(FileTaskEntity.class))).thenAnswer(invocation -> { invocation.getArgument(0, FileTaskEntity.class).setId(34411L); return 1; diff --git a/frontend-vue/src/pages/jd/JdPublishTab.vue b/frontend-vue/src/pages/jd/JdPublishTab.vue index 9ad09ef7d..95e3fa145 100644 --- a/frontend-vue/src/pages/jd/JdPublishTab.vue +++ b/frontend-vue/src/pages/jd/JdPublishTab.vue @@ -40,8 +40,9 @@ import BrandApiSecretSettingsButton from '@/pages/brand/components/BrandApiSecre * * 六条边界(照 v1.4/v1.5 已落地的采集契约与外观专利任务面板骨架,不另造流程): * 1. 分类选项唯一来源=jdCollect.groups 既有出口(B113-01,AC-9 源码绊线钉死:本页不得自拼 - * 分类 URL);分组下的商品列表走 jdPublish.products(AC-9 owner 过滤:服务端只回归属 - * 当前登录用户的行),页内翻页、勾选跨页累计; + * 分类 URL);分组下的商品列表走 jdPublish.products(2026-11-25 起作用域=本账号可见 + * 数据权限分组下的分类归属行,与分类下拉/徽标同源——同组同事采集的商品也能上架, + * 跨公司/跨组看不到),页内翻页、勾选跨页累计; * 2. 改价规则三档(none/percent/fixed,蓝图 §3 死契约),与勾选集一起进建单体;服务端按 * 同一规则折算 SKU 价(铁律 27a 改价同源); * 3. 网页原样转交建单响应的 queuePayload;认领只由客户端与后端完成,投递失败仍可由客户端拉取; @@ -93,7 +94,7 @@ const GROUPS_EMPTY_HINT_TEXT = '本分组暂无分类——请联系管理员在后台「京东数据库 → 店铺分类」创建分类并归入你的分组后再上架。' const groupsEmpty = computed(() => !groupsLoading.value && groupOptions.value.length === 0) -// ---- 选品分页(owner 过滤在服务端;勾选跨页累计在本地 Map,翻页不清空)---- +// ---- 选品分页(作用域过滤在服务端:可见分组的分类归属行;勾选跨页累计在本地 Map,翻页不清空)---- const PRODUCT_PAGE_SIZE = 12 const products = ref([]) const productTotal = ref(0) @@ -712,7 +713,7 @@ async function startPublish() { ? { mode: 'none' as const } : { mode: priceMode.value, value: priceValue.value as number } // 勾选集即建单 productIds;selectedGroupId 即建单体 categoryId - // (服务端按 owner 校验,选了他人商品当场拒,AC-9)。 + // (服务端按可见分类作用域校验:跨公司/跨组商品当场拒,同组同事采集的可上架)。 const categoryId = selectedGroupId.value const productIds = selectedProductIds.value const brand = targetBrandName.value @@ -784,7 +785,7 @@ onUnmounted(() => { ← 返回京东工具台 商品上架 - 把京东数据库里你自己的商品批量上架到京麦店铺:选分类、勾商品、可选统一改价,本机已登录京麦的客户端逐个发布。 + 把京东数据库里的商品批量上架到京麦店铺:选分类、勾商品、可选统一改价,本机已登录京麦的客户端逐个发布。 @@ -828,7 +829,7 @@ onUnmounted(() => { :label="`${group.name}(${group.productCount ?? 0} 个商品)`" :value="group.id" />

{{ GROUPS_EMPTY_HINT_TEXT }}

-

分类由管理员在后台「京东数据库」维护;列表只显示归属你账号的商品。

+

分类由管理员在后台「京东数据库」维护;列表显示你可见分类下的商品(同组同事采集的也能上架)。

@@ -844,7 +845,7 @@ onUnmounted(() => { @click="clearSelection">清空勾选
- {{ selectedGroupId ? '该分类下暂无归属你账号的商品' : '请先选择分类' }} + {{ selectedGroupId ? '该分类下暂无商品' : '请先选择分类' }}