From 51c5e38b5816f3741616b56371e3e239a8494666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=9F=91=E8=9E=82?= Date: Thu, 23 Apr 2026 12:12:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(ecom-dmb):=20ec=5Fplatform=20=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20company=5Fid=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ec_platform 表增加 company_id 字段,关联 org_company - PlatformPO/VO/DTO 增加 companyId 字段 - PlatformServiceImpl 所有查询增加 companyId 过滤 - CompanyOverviewServiceImpl/ExportServiceImpl/ShopServiceImpl 平台查询增加 companyId 限制 - 数据库已更新,所有平台绑定到公司ID=3(秦华科技有限公司) --- ecom-dmb-backend/sql/ec_design.sql | 6 +- .../migration/add_company_id_to_platform.sql | 39 ++++++ .../impl/CompanyOverviewServiceImpl.java | 18 ++- .../service/impl/ExportServiceImpl.java | 18 ++- .../platform/model/dto/CreatePlatformDTO.java | 6 + .../platform/model/dto/PlatformFilterDTO.java | 6 + .../platform/model/dto/UpdatePlatformDTO.java | 6 + .../ecom/platform/model/po/PlatformPO.java | 6 + .../ecom/platform/model/vo/PlatformVO.java | 6 + .../service/impl/PlatformServiceImpl.java | 117 +++++++----------- .../shop/service/impl/ShopServiceImpl.java | 6 +- 11 files changed, 154 insertions(+), 80 deletions(-) create mode 100644 ecom-dmb-backend/sql/migration/add_company_id_to_platform.sql diff --git a/ecom-dmb-backend/sql/ec_design.sql b/ecom-dmb-backend/sql/ec_design.sql index 12d378a9..c8b8cd23 100644 --- a/ecom-dmb-backend/sql/ec_design.sql +++ b/ecom-dmb-backend/sql/ec_design.sql @@ -356,6 +356,7 @@ CREATE TABLE `ec_promotion_fee_type` ( DROP TABLE IF EXISTS `ec_platform`; CREATE TABLE `ec_platform` ( `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '平台ID', + `company_id` bigint UNSIGNED NOT NULL COMMENT '所属公司ID', `platform_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '平台名称(如淘宝、京东、拼多多、抖音)', `platform_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '平台代码(如 taobao、jd、pdd、douyin)', `logo_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '平台Logo URL', @@ -366,12 +367,13 @@ CREATE TABLE `ec_platform` ( `create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '创建人ID', `update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人ID', PRIMARY KEY (`id`) USING BTREE, - UNIQUE INDEX `uk_platform_name`(`platform_name` ASC) USING BTREE, - UNIQUE INDEX `uk_platform_code`(`platform_code` ASC) USING BTREE, + INDEX `idx_company_id`(`company_id` ASC) USING BTREE, INDEX `idx_sort_order`(`sort_order` ASC) USING BTREE, INDEX `idx_is_active`(`is_active` ASC) USING BTREE, + INDEX `fk_ec_platform_company`(`company_id` ASC) USING BTREE, INDEX `fk_ec_platform_creator`(`create_by` ASC) USING BTREE, INDEX `fk_ec_platform_updater`(`update_by` ASC) USING BTREE, + CONSTRAINT `fk_ec_platform_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_ec_platform_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fk_ec_platform_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-平台表' ; diff --git a/ecom-dmb-backend/sql/migration/add_company_id_to_platform.sql b/ecom-dmb-backend/sql/migration/add_company_id_to_platform.sql new file mode 100644 index 00000000..92658eb7 --- /dev/null +++ b/ecom-dmb-backend/sql/migration/add_company_id_to_platform.sql @@ -0,0 +1,39 @@ +-- ============================================================ +-- ec_platform 表添加 company_id 字段 +-- 执行前请先备份数据库! +-- ============================================================ + +-- 1. 添加 company_id 字段(NOT NULL 需要先设置默认值,再改回来) +ALTER TABLE ec_platform + ADD COLUMN company_id bigint UNSIGNED NOT NULL DEFAULT 1 COMMENT '所属公司ID' AFTER id; + +-- 2. 添加外键约束 +ALTER TABLE ec_platform + ADD CONSTRAINT fk_ec_platform_company + FOREIGN KEY (company_id) REFERENCES org_company(id) + ON DELETE CASCADE ON UPDATE CASCADE; + +-- 3. 添加索引 +ALTER TABLE ec_platform ADD INDEX idx_company_id(company_id); + +-- 4. 查看现有公司(确认要绑定到哪个公司) +-- SELECT id, company_name FROM org_company; + +-- 5. 如果只有一个公司,直接更新所有平台绑定到该公司 +-- (替换下面的 1 为实际的公司ID) +-- UPDATE ec_platform SET company_id = 1; + +-- 6. 如果需要创建新公司并绑定,参考以下SQL: +/* +-- 创建测试公司(如果需要) +INSERT INTO org_company (company_name, contact_name, contact_phone, address, is_active, create_by) +SELECT '默认公司', '管理员', '13800138000', '地址待填', 1, 1 +WHERE NOT EXISTS (SELECT 1 FROM org_company LIMIT 1); + +-- 获取公司ID并更新平台 +SET @company_id = (SELECT id FROM org_company LIMIT 1); +UPDATE ec_platform SET company_id = @company_id; +*/ + +-- 7. 确认更新结果 +-- SELECT id, company_id, platform_name FROM ec_platform; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/CompanyOverviewServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/CompanyOverviewServiceImpl.java index 45b7cb5b..a0dea639 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/CompanyOverviewServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/CompanyOverviewServiceImpl.java @@ -592,7 +592,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { CompanyOverviewVO.ShopComparison comparison = new CompanyOverviewVO.ShopComparison(); comparison.setShopId(shop.getId()); comparison.setShopName(shop.getName()); - comparison.setPlatform(shop.getPlatformId() != null ? platformMapper.selectById(shop.getPlatformId()).getPlatformName() : null); + comparison.setPlatform(shop.getPlatformId() != null ? getPlatformNameById(shop.getPlatformId()) : null); comparison.setTargetOrderCount(targetOrderCount); comparison.setOrderCountAchievementRate(orderCountAchievementRate); comparison.setTargetAmount(targetAmount); @@ -913,8 +913,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { List platformSummaries = new ArrayList<>(); - // 获取所有平台 - List allPlatforms = platformMapper.selectList(null); + // 获取当前公司的所有平台 + LambdaQueryWrapper platformWrapper = new LambdaQueryWrapper<>(); + platformWrapper.eq(PlatformPO::getCompanyId, companyId); + List allPlatforms = platformMapper.selectList(platformWrapper); Map platformMap = allPlatforms.stream() .collect(Collectors.toMap(PlatformPO::getId, p -> p)); @@ -1108,5 +1110,15 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { platformSummaries.sort(Comparator.comparing(CompanyOverviewVO.PlatformSummary::getSalesAmount).reversed()); return platformSummaries; } + + private String getPlatformNameById(Long platformId) { + if (platformId == null) return null; + Long companyId = currentUserContext.getCurrentCompanyId(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(PlatformPO::getId, platformId) + .eq(PlatformPO::getCompanyId, companyId); + PlatformPO platform = platformMapper.selectOne(wrapper); + return platform != null ? platform.getPlatformName() : null; + } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ExportServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ExportServiceImpl.java index a46ef328..a9d030cf 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ExportServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ExportServiceImpl.java @@ -1157,7 +1157,7 @@ public class ExportServiceImpl implements ExportService { Map data = new HashMap<>(); data.put("shopName", shop.getName()); - data.put("platform", shop.getPlatformId() != null ? platformMapper.selectById(shop.getPlatformId()).getPlatformName() : null); + data.put("platform", shop.getPlatformId() != null ? getPlatformNameById(shop.getPlatformId()) : null); data.put("salesAmount", salesAmount); data.put("orderCount", orderCount); data.put("avgOrderValue", avgOrderValue); @@ -1315,8 +1315,10 @@ public class ExportServiceImpl implements ExportService { .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } - // 获取所有平台信息 - List allPlatforms = platformMapper.selectList(null); + // 获取当前公司的所有平台信息 + LambdaQueryWrapper platformWrapper = new LambdaQueryWrapper<>(); + platformWrapper.eq(PlatformPO::getCompanyId, companyId); + List allPlatforms = platformMapper.selectList(platformWrapper); Map platformMap = allPlatforms.stream() .collect(Collectors.toMap(PlatformPO::getId, p -> p)); @@ -1570,4 +1572,14 @@ public class ExportServiceImpl implements ExportService { sheet.setColumnWidth(i, 3200); } } + + private String getPlatformNameById(Long platformId) { + if (platformId == null) return null; + Long companyId = currentUserContext.getCurrentCompanyId(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(PlatformPO::getId, platformId) + .eq(PlatformPO::getCompanyId, companyId); + PlatformPO platform = platformMapper.selectOne(wrapper); + return platform != null ? platform.getPlatformName() : null; + } } \ No newline at end of file diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/CreatePlatformDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/CreatePlatformDTO.java index 6c62396f..2d089b11 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/CreatePlatformDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/CreatePlatformDTO.java @@ -42,4 +42,10 @@ public class CreatePlatformDTO { */ @Schema(description = "是否启用 0禁用 1启用", example = "1") private Integer isActive; + + /** + * 所属公司ID + */ + @Schema(description = "所属公司ID", example = "1") + private Long companyId; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/PlatformFilterDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/PlatformFilterDTO.java index b6d8e1cd..5321d8d7 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/PlatformFilterDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/PlatformFilterDTO.java @@ -27,4 +27,10 @@ public class PlatformFilterDTO { */ @Schema(description = "是否启用 0禁用 1启用", example = "1") private Integer isActive; + + /** + * 所属公司ID + */ + @Schema(description = "所属公司ID", example = "1") + private Long companyId; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/UpdatePlatformDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/UpdatePlatformDTO.java index b1a22ffb..38c7d4c9 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/UpdatePlatformDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/dto/UpdatePlatformDTO.java @@ -45,4 +45,10 @@ public class UpdatePlatformDTO { @Schema(description = "是否启用 0禁用 1启用", example = "1") @NotNull(message = "是否启用不能为空") private Integer isActive; + + /** + * 所属公司ID + */ + @Schema(description = "所属公司ID", example = "1") + private Long companyId; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/po/PlatformPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/po/PlatformPO.java index 935f9120..2d6caa19 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/po/PlatformPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/po/PlatformPO.java @@ -20,6 +20,12 @@ public class PlatformPO { @TableId(value = "id", type = IdType.AUTO) private Long id; + /** + * 所属公司ID + */ + @TableField("company_id") + private Long companyId; + /** * 平台名称(如淘宝、京东、拼多多、抖音) */ diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/vo/PlatformVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/vo/PlatformVO.java index 0af4f221..46efe006 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/vo/PlatformVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/model/vo/PlatformVO.java @@ -18,6 +18,12 @@ public class PlatformVO { @Schema(description = "平台ID", example = "1") private Long id; + /** + * 所属公司ID + */ + @Schema(description = "所属公司ID", example = "1") + private Long companyId; + /** * 平台名称 */ diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/service/impl/PlatformServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/service/impl/PlatformServiceImpl.java index 7516fa33..1e36ce8e 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/service/impl/PlatformServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/platform/service/impl/PlatformServiceImpl.java @@ -34,25 +34,23 @@ public class PlatformServiceImpl extends ServiceImpl this.currentUserContext = currentUserContext; } - /** - * 创建平台 - * - * @param createPlatformDTO 创建平台DTO - * @return 平台VO - */ @Override @Transactional public PlatformVO createPlatform(CreatePlatformDTO createPlatformDTO) { - // 验证平台名称是否重复 + Long companyId = currentUserContext.getCurrentCompanyId(); + + // 验证平台名称是否重复(同一公司下) LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(PlatformPO::getPlatformName, createPlatformDTO.getPlatformName()); + wrapper.eq(PlatformPO::getCompanyId, companyId) + .eq(PlatformPO::getPlatformName, createPlatformDTO.getPlatformName()); if (this.count(wrapper) > 0) { throw new BusinessException("平台名称已存在"); } - // 验证平台代码是否重复 + // 验证平台代码是否重复(同一公司下) wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(PlatformPO::getPlatformCode, createPlatformDTO.getPlatformCode()); + wrapper.eq(PlatformPO::getCompanyId, companyId) + .eq(PlatformPO::getPlatformCode, createPlatformDTO.getPlatformCode()); if (this.count(wrapper) > 0) { throw new BusinessException("平台代码已存在"); } @@ -60,6 +58,7 @@ public class PlatformServiceImpl extends ServiceImpl // 创建平台 PlatformPO platform = new PlatformPO(); BeanUtils.copyProperties(createPlatformDTO, platform); + platform.setCompanyId(companyId); // 设置默认值 if (platform.getSortOrder() == null) { @@ -79,33 +78,30 @@ public class PlatformServiceImpl extends ServiceImpl return convertToVO(platform); } - /** - * 更新平台 - * - * @param updatePlatformDTO 更新平台DTO - * @param id 平台ID - * @return 平台VO - */ @Override @Transactional public PlatformVO updatePlatform(UpdatePlatformDTO updatePlatformDTO, Long id) { + Long companyId = currentUserContext.getCurrentCompanyId(); + // 验证平台是否存在 PlatformPO existingPlatform = this.getById(id); if (existingPlatform == null) { throw new BusinessException("平台不存在"); } - // 验证平台名称是否重复(排除当前平台) + // 验证平台名称是否重复(排除当前平台,同一公司下) LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(PlatformPO::getPlatformName, updatePlatformDTO.getPlatformName()) + wrapper.eq(PlatformPO::getCompanyId, companyId) + .eq(PlatformPO::getPlatformName, updatePlatformDTO.getPlatformName()) .ne(PlatformPO::getId, id); if (this.count(wrapper) > 0) { throw new BusinessException("平台名称已存在"); } - // 验证平台代码是否重复(排除当前平台) + // 验证平台代码是否重复(排除当前平台,同一公司下) wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(PlatformPO::getPlatformCode, updatePlatformDTO.getPlatformCode()) + wrapper.eq(PlatformPO::getCompanyId, companyId) + .eq(PlatformPO::getPlatformCode, updatePlatformDTO.getPlatformCode()) .ne(PlatformPO::getId, id); if (this.count(wrapper) > 0) { throw new BusinessException("平台代码已存在"); @@ -115,6 +111,7 @@ public class PlatformServiceImpl extends ServiceImpl PlatformPO platform = new PlatformPO(); BeanUtils.copyProperties(updatePlatformDTO, platform); platform.setId(id); + platform.setCompanyId(companyId); // 设置更新人ID platform.setUpdateBy(currentUserContext.getCurrentUserId()); @@ -126,11 +123,6 @@ public class PlatformServiceImpl extends ServiceImpl return convertToVO(platform); } - /** - * 删除平台 - * - * @param id 平台ID - */ @Override @Transactional public void deletePlatform(Long id) { @@ -144,18 +136,14 @@ public class PlatformServiceImpl extends ServiceImpl this.removeById(id); } - /** - * 分页获取平台列表 - * - * @param pageQueryDTO 分页查询DTO - * @return 分页结果 - */ @Override public PageResultVO getPlatformPage(PageQueryDTO pageQueryDTO) { + Long companyId = currentUserContext.getCurrentCompanyId(); PlatformFilterDTO filter = pageQueryDTO.getFilters() != null ? pageQueryDTO.getFilters() : new PlatformFilterDTO(); // 构建查询条件 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(PlatformPO::getCompanyId, companyId); if (filter.getPlatformName() != null && !filter.getPlatformName().isEmpty()) { wrapper.like(PlatformPO::getPlatformName, filter.getPlatformName()); } @@ -182,15 +170,12 @@ public class PlatformServiceImpl extends ServiceImpl return PageResultVO.create(voList, result.getTotal(), (int) pageQueryDTO.getPage(), (int) pageQueryDTO.getPageSize()); } - /** - * 获取所有启用的平台列表 - * - * @return 平台列表 - */ @Override public List getActivePlatforms() { + Long companyId = currentUserContext.getCurrentCompanyId(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(PlatformPO::getIsActive, 1) + wrapper.eq(PlatformPO::getCompanyId, companyId) + .eq(PlatformPO::getIsActive, 1) .orderByAsc(PlatformPO::getSortOrder); return this.list(wrapper).stream() @@ -198,51 +183,35 @@ public class PlatformServiceImpl extends ServiceImpl .collect(Collectors.toList()); } - /** - * 转换为VO - * - * @param platform 平台实体 - * @return 平台VO - */ - private PlatformVO convertToVO(PlatformPO platform) { - PlatformVO vo = new PlatformVO(); - BeanUtils.copyProperties(platform, vo); - return vo; - } - - /** - * 为新公司初始化平台数据(确保全局平台数据存在) - * 如果平台表为空,则插入初始平台数据 - * - * @param companyId 公司ID(预留参数,用于未来公司级平台配置扩展) - * @param creatorId 创建人ID - */ @Override public void initPlatformsForCompany(Long companyId, Long creatorId) { - // 检查是否已经有平台数据 - if (this.count() > 0) { + // 检查该公司是否已有平台数据 + LambdaQueryWrapper checkWrapper = new LambdaQueryWrapper<>(); + checkWrapper.eq(PlatformPO::getCompanyId, companyId); + if (this.count(checkWrapper) > 0) { return; // 已有平台数据,无需初始化 } - // 插入初始平台数据 + // 插入初始平台数据(绑定到公司) List initialPlatforms = List.of( - createPlatform("淘宝", "taobao", 1, creatorId), - createPlatform("京东", "jd", 2, creatorId), - createPlatform("拼多多", "pdd", 3, creatorId), - createPlatform("抖音", "douyin", 4, creatorId), - createPlatform("快手", "kuaishou", 5, creatorId), - createPlatform("小红书", "xiaohongshu", 6, creatorId), - createPlatform("天猫", "tmall", 7, creatorId), - createPlatform("唯品会", "vip", 8, creatorId), - createPlatform("苏宁", "suning", 9, creatorId), - createPlatform("1688", "1688", 10, creatorId) + createPlatform(companyId, "淘宝", "taobao", 1, creatorId), + createPlatform(companyId, "京东", "jd", 2, creatorId), + createPlatform(companyId, "拼多多", "pdd", 3, creatorId), + createPlatform(companyId, "抖音", "douyin", 4, creatorId), + createPlatform(companyId, "快手", "kuaishou", 5, creatorId), + createPlatform(companyId, "小红书", "xiaohongshu", 6, creatorId), + createPlatform(companyId, "天猫", "tmall", 7, creatorId), + createPlatform(companyId, "唯品会", "vip", 8, creatorId), + createPlatform(companyId, "苏宁", "suning", 9, creatorId), + createPlatform(companyId, "1688", "1688", 10, creatorId) ); this.saveBatch(initialPlatforms); } - private PlatformPO createPlatform(String name, String code, int sortOrder, Long creatorId) { + private PlatformPO createPlatform(Long companyId, String name, String code, int sortOrder, Long creatorId) { PlatformPO platform = new PlatformPO(); + platform.setCompanyId(companyId); platform.setPlatformName(name); platform.setPlatformCode(code); platform.setSortOrder(sortOrder); @@ -251,4 +220,10 @@ public class PlatformServiceImpl extends ServiceImpl platform.setUpdateBy(creatorId); return platform; } + + private PlatformVO convertToVO(PlatformPO platform) { + PlatformVO vo = new PlatformVO(); + BeanUtils.copyProperties(platform, vo); + return vo; + } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java index 775fa0d8..6aebb9cc 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java @@ -272,7 +272,11 @@ public class ShopServiceImpl extends ServiceImpl implements // 获取平台名称 if (shop.getPlatformId() != null) { - PlatformPO platform = platformMapper.selectById(shop.getPlatformId()); + Long companyId = currentUserContext.getCurrentCompanyId(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(PlatformPO::getId, shop.getPlatformId()) + .eq(PlatformPO::getCompanyId, companyId); + PlatformPO platform = platformMapper.selectOne(wrapper); if (platform != null) { shopVO.setPlatformName(platform.getPlatformName()); }