mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 17:09:20 +08:00
feat: 新增电商平台管理模块(ec_platform),店铺表platform改为外键
后端: - 新增 ec_platform 表 + 10条初始平台数据(淘宝/京东/拼多多/抖音等) - ec_shop 表 platform varchar → platform_id bigint 外键 - 新增 Platform 模块:PO/VO/DTO/Mapper/Service/Controller - 修复 ShopServiceImpl/CompanyOverviewServiceImpl/ExportServiceImpl 中 platform 字段引用 前端: - 新增平台管理页面(列表 + 表单弹窗) - 路由注册 /data/platform - 店铺管理:平台选择改为下拉,字段 platform 字符串 → platformId 外键 - 同步更新 ShopVO/ShopDTO 类型定义 数据库: - V20260422__add_ec_platform.sql 迁移文件
This commit is contained in:
@@ -0,0 +1,87 @@
|
|||||||
|
-- =============================================================================
|
||||||
|
-- 迁移 SQL:新增 ec_platform 表,增加 platform_id 外键,创建平台管理权限和菜单
|
||||||
|
-- 执行时间:2026-04-22
|
||||||
|
-- =============================================================================
|
||||||
|
|
||||||
|
-- =========================================
|
||||||
|
-- Part 1: ec_platform 表结构 + 初始化数据
|
||||||
|
-- =========================================
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `ec_platform`;
|
||||||
|
CREATE TABLE `ec_platform` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '平台ID',
|
||||||
|
`platform_name` varchar(50) NOT NULL COMMENT '平台名称',
|
||||||
|
`platform_code` varchar(20) NOT NULL COMMENT '平台代码',
|
||||||
|
`logo_url` varchar(500) NULL DEFAULT NULL COMMENT '平台Logo URL',
|
||||||
|
`sort_order` int NULL DEFAULT 0 COMMENT '排序',
|
||||||
|
`is_active` tinyint NOT NULL DEFAULT 1 COMMENT '是否启用 0禁用 1启用',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '创建人ID',
|
||||||
|
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人ID',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE INDEX `uk_platform_code` (`platform_code` ASC)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='电商-平台表';
|
||||||
|
|
||||||
|
INSERT INTO `ec_platform` (`platform_name`, `platform_code`, `sort_order`, `is_active`) VALUES
|
||||||
|
('淘宝', 'taobao', 1, 1),
|
||||||
|
('京东', 'jd', 2, 1),
|
||||||
|
('拼多多', 'pdd', 3, 1),
|
||||||
|
('抖音', 'douyin', 4, 1),
|
||||||
|
('快手', 'kuaishou', 5, 1),
|
||||||
|
('小红书', 'xiaohongshu', 6, 1),
|
||||||
|
('天猫', 'tmall', 7, 1),
|
||||||
|
('唯品会', 'vip', 8, 1),
|
||||||
|
('苏宁', 'suning', 9, 1),
|
||||||
|
('1688', '1688', 10, 1);
|
||||||
|
|
||||||
|
-- =========================================
|
||||||
|
-- Part 2: ec_shop 表增加 platform_id 字段
|
||||||
|
-- =========================================
|
||||||
|
|
||||||
|
SET @column_exists = (
|
||||||
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'ec_shop'
|
||||||
|
AND COLUMN_NAME = 'platform_id'
|
||||||
|
);
|
||||||
|
SET @sql = IF(@column_exists = 0,
|
||||||
|
'ALTER TABLE `ec_shop` ADD COLUMN `platform_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT ''平台ID'' AFTER `logo_image_id`,
|
||||||
|
ADD INDEX `idx_platform_id`(`platform_id` ASC),
|
||||||
|
ADD CONSTRAINT `fk_ec_shop_platform` FOREIGN KEY (`platform_id`) REFERENCES `ec_platform`(`id`) ON DELETE SET NULL ON UPDATE CASCADE',
|
||||||
|
'SELECT ''Column platform_id already exists, skipping'' '
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
-- =========================================
|
||||||
|
-- Part 3: 平台管理权限
|
||||||
|
-- =========================================
|
||||||
|
|
||||||
|
-- 3.1 插入平台管理模块(parent_id=102 为电商业务顶级模块)
|
||||||
|
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `code`, `type`, `sort_order`, `status`, `create_time`)
|
||||||
|
SELECT 133, 102, '平台管理', 'ecom:platform', 'module', 330, 1, NOW()
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE code = 'ecom:platform' AND parent_id = 102);
|
||||||
|
|
||||||
|
-- 3.2 插入平台查看和管理权限
|
||||||
|
INSERT INTO `sys_permission` (`parent_id`, `name`, `code`, `type`, `sort_order`, `status`, `create_time`)
|
||||||
|
SELECT 133, '平台查看', 'ecom:platform:read', 'api', 331, 1, NOW()
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE code = 'ecom:platform:read');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission` (`parent_id`, `name`, `code`, `type`, `sort_order`, `status`, `create_time`)
|
||||||
|
SELECT 133, '平台管理', 'ecom:platform:manage', 'api', 332, 1, NOW()
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_permission WHERE code = 'ecom:platform:manage');
|
||||||
|
|
||||||
|
-- =========================================
|
||||||
|
-- Part 4: 平台管理菜单
|
||||||
|
-- 说明:请根据 sys_menu 实际情况调整 parent_id(电商父菜单的ID)
|
||||||
|
-- 可以通过: SELECT id, name, parent_id FROM sys_menu WHERE name LIKE '%电商%' 来查找
|
||||||
|
-- =========================================
|
||||||
|
|
||||||
|
-- 查找电商父菜单的ID(请手动确认后再执行下面的 INSERT)
|
||||||
|
-- SELECT id, name, parent_id FROM sys_menu WHERE name LIKE '%电商%' OR name LIKE '%店铺%';
|
||||||
|
|
||||||
|
-- 示例: 如果电商菜单的 ID 是 28,则执行:
|
||||||
|
-- INSERT INTO `sys_menu` (`parent_id`, `name`, `title`, `path`, `component`, `icon`, `type`, `visible`, `status`, `order`, `create_time`)
|
||||||
|
-- VALUES (28, 'platform', '平台管理', '/ecommerce/platform', 'ecommerce/platform/index', 'appstore', 'menu', 1, 1, 330, NOW());
|
||||||
@@ -350,6 +350,47 @@ CREATE TABLE `ec_promotion_fee_type` (
|
|||||||
CONSTRAINT `fk_ec_promotion_fee_type_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
CONSTRAINT `fk_ec_promotion_fee_type_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 = '电商-推广费类型表' ;
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-推广费类型表' ;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- 平台表
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `ec_platform`;
|
||||||
|
CREATE TABLE `ec_platform` (
|
||||||
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT 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',
|
||||||
|
`sort_order` int NOT NULL DEFAULT 0 COMMENT '排序',
|
||||||
|
`is_active` tinyint NOT NULL DEFAULT 1 COMMENT '是否启用 0禁用 1启用',
|
||||||
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`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_sort_order`(`sort_order` ASC) USING BTREE,
|
||||||
|
INDEX `idx_is_active`(`is_active` 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_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 = '电商-平台表' ;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- 平台数据初始化
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `ec_platform` (`platform_name`, `platform_code`, `sort_order`, `is_active`) VALUES
|
||||||
|
('淘宝', 'taobao', 1, 1),
|
||||||
|
('京东', 'jd', 2, 1),
|
||||||
|
('拼多多', 'pdd', 3, 1),
|
||||||
|
('抖音', 'douyin', 4, 1),
|
||||||
|
('快手', 'kuaishou', 5, 1),
|
||||||
|
('小红书', 'xiaohongshu', 6, 1),
|
||||||
|
('天猫', 'tmall', 7, 1),
|
||||||
|
('唯品会', 'vip', 8, 1),
|
||||||
|
('苏宁', 'suning', 9, 1),
|
||||||
|
('1688', '1688', 10, 1);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- 店铺表
|
-- 店铺表
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
@@ -359,19 +400,21 @@ CREATE TABLE `ec_shop` (
|
|||||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '所属公司ID',
|
`company_id` bigint UNSIGNED NOT NULL COMMENT '所属公司ID',
|
||||||
`name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '店铺名称',
|
`name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '店铺名称',
|
||||||
`logo_image_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT 'logo图片ID',
|
`logo_image_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT 'logo图片ID',
|
||||||
`platform` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '平台(如淘宝、京东、拼多多)',
|
`platform_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '平台ID',
|
||||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '创建人ID',
|
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '创建人ID',
|
||||||
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人ID',
|
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人ID',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
INDEX `idx_company_id`(`company_id` ASC) USING BTREE,
|
INDEX `idx_company_id`(`company_id` ASC) USING BTREE,
|
||||||
|
INDEX `idx_platform_id`(`platform_id` ASC) USING BTREE,
|
||||||
INDEX `fk_ec_shop_logo_image`(`logo_image_id` ASC) USING BTREE,
|
INDEX `fk_ec_shop_logo_image`(`logo_image_id` ASC) USING BTREE,
|
||||||
INDEX `fk_ec_shop_creator`(`create_by` ASC) USING BTREE,
|
INDEX `fk_ec_shop_creator`(`create_by` ASC) USING BTREE,
|
||||||
INDEX `fk_ec_shop_updater`(`update_by` ASC) USING BTREE,
|
INDEX `fk_ec_shop_updater`(`update_by` ASC) USING BTREE,
|
||||||
CONSTRAINT `fk_ec_shop_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
CONSTRAINT `fk_ec_shop_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
CONSTRAINT `fk_ec_shop_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
CONSTRAINT `fk_ec_shop_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
CONSTRAINT `fk_ec_shop_logo_image` FOREIGN KEY (`logo_image_id`) REFERENCES `sys_file` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
CONSTRAINT `fk_ec_shop_logo_image` FOREIGN KEY (`logo_image_id`) REFERENCES `sys_file` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `fk_ec_shop_platform` FOREIGN KEY (`platform_id`) REFERENCES `ec_platform` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
CONSTRAINT `fk_ec_shop_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
CONSTRAINT `fk_ec_shop_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 = '电商-店铺表' ;
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-店铺表' ;
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -5,6 +5,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.mapper.BrushOrderMapper;
|
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.mapper.BrushOrderMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
|
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper;
|
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.dto.CompanyOverviewQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.dto.CompanyOverviewQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.model.po.BrushOrderPO;
|
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.model.po.BrushOrderPO;
|
||||||
@@ -52,6 +54,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
private final OrderStatusService orderStatusService;
|
private final OrderStatusService orderStatusService;
|
||||||
private final ProductMapper productMapper;
|
private final ProductMapper productMapper;
|
||||||
private final CategoryService categoryService;
|
private final CategoryService categoryService;
|
||||||
|
private final PlatformMapper platformMapper;
|
||||||
|
|
||||||
public CompanyOverviewServiceImpl(CurrentUserContext currentUserContext,
|
public CompanyOverviewServiceImpl(CurrentUserContext currentUserContext,
|
||||||
OrderMapper orderMapper,
|
OrderMapper orderMapper,
|
||||||
@@ -61,7 +64,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
ShopService shopService,
|
ShopService shopService,
|
||||||
OrderStatusService orderStatusService,
|
OrderStatusService orderStatusService,
|
||||||
ProductMapper productMapper,
|
ProductMapper productMapper,
|
||||||
CategoryService categoryService) {
|
CategoryService categoryService,
|
||||||
|
PlatformMapper platformMapper) {
|
||||||
this.currentUserContext = currentUserContext;
|
this.currentUserContext = currentUserContext;
|
||||||
this.orderMapper = orderMapper;
|
this.orderMapper = orderMapper;
|
||||||
this.promotionFeeMapper = promotionFeeMapper;
|
this.promotionFeeMapper = promotionFeeMapper;
|
||||||
@@ -71,6 +75,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
this.orderStatusService = orderStatusService;
|
this.orderStatusService = orderStatusService;
|
||||||
this.productMapper = productMapper;
|
this.productMapper = productMapper;
|
||||||
this.categoryService = categoryService;
|
this.categoryService = categoryService;
|
||||||
|
this.platformMapper = platformMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -582,7 +587,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
CompanyOverviewVO.ShopComparison comparison = new CompanyOverviewVO.ShopComparison();
|
CompanyOverviewVO.ShopComparison comparison = new CompanyOverviewVO.ShopComparison();
|
||||||
comparison.setShopId(shop.getId());
|
comparison.setShopId(shop.getId());
|
||||||
comparison.setShopName(shop.getName());
|
comparison.setShopName(shop.getName());
|
||||||
comparison.setPlatform(shop.getPlatform());
|
comparison.setPlatform(shop.getPlatformId() != null ? platformMapper.selectById(shop.getPlatformId()).getPlatformName() : null);
|
||||||
comparison.setTargetOrderCount(targetOrderCount);
|
comparison.setTargetOrderCount(targetOrderCount);
|
||||||
comparison.setOrderCountAchievementRate(orderCountAchievementRate);
|
comparison.setOrderCountAchievementRate(orderCountAchievementRate);
|
||||||
comparison.setTargetAmount(targetAmount);
|
comparison.setTargetAmount(targetAmount);
|
||||||
|
|||||||
+7
-2
@@ -8,6 +8,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.mapper.BrushOrderMapper;
|
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.mapper.BrushOrderMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
|
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.dto.ShopOverviewQueryDTO;
|
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.dto.ShopOverviewQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo.CompanyOverviewVO;
|
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo.CompanyOverviewVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo.ShopOverviewStatisticsVO;
|
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo.ShopOverviewStatisticsVO;
|
||||||
@@ -60,6 +62,7 @@ public class ExportServiceImpl implements ExportService {
|
|||||||
private final OrderStatusService orderStatusService;
|
private final OrderStatusService orderStatusService;
|
||||||
private final ShopOverviewStatisticsService shopOverviewStatisticsService;
|
private final ShopOverviewStatisticsService shopOverviewStatisticsService;
|
||||||
private final CategoryService categoryService;
|
private final CategoryService categoryService;
|
||||||
|
private final PlatformMapper platformMapper;
|
||||||
|
|
||||||
public ExportServiceImpl(CurrentUserContext currentUserContext,
|
public ExportServiceImpl(CurrentUserContext currentUserContext,
|
||||||
OrderMapper orderMapper,
|
OrderMapper orderMapper,
|
||||||
@@ -70,7 +73,8 @@ public class ExportServiceImpl implements ExportService {
|
|||||||
ProductService productService,
|
ProductService productService,
|
||||||
OrderStatusService orderStatusService,
|
OrderStatusService orderStatusService,
|
||||||
ShopOverviewStatisticsService shopOverviewStatisticsService,
|
ShopOverviewStatisticsService shopOverviewStatisticsService,
|
||||||
CategoryService categoryService) {
|
CategoryService categoryService,
|
||||||
|
PlatformMapper platformMapper) {
|
||||||
this.currentUserContext = currentUserContext;
|
this.currentUserContext = currentUserContext;
|
||||||
this.orderMapper = orderMapper;
|
this.orderMapper = orderMapper;
|
||||||
this.promotionFeeMapper = promotionFeeMapper;
|
this.promotionFeeMapper = promotionFeeMapper;
|
||||||
@@ -81,6 +85,7 @@ public class ExportServiceImpl implements ExportService {
|
|||||||
this.orderStatusService = orderStatusService;
|
this.orderStatusService = orderStatusService;
|
||||||
this.shopOverviewStatisticsService = shopOverviewStatisticsService;
|
this.shopOverviewStatisticsService = shopOverviewStatisticsService;
|
||||||
this.categoryService = categoryService;
|
this.categoryService = categoryService;
|
||||||
|
this.platformMapper = platformMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1151,7 +1156,7 @@ public class ExportServiceImpl implements ExportService {
|
|||||||
|
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
data.put("shopName", shop.getName());
|
data.put("shopName", shop.getName());
|
||||||
data.put("platform", shop.getPlatform());
|
data.put("platform", shop.getPlatformId() != null ? platformMapper.selectById(shop.getPlatformId()).getPlatformName() : null);
|
||||||
data.put("salesAmount", salesAmount);
|
data.put("salesAmount", salesAmount);
|
||||||
data.put("orderCount", orderCount);
|
data.put("orderCount", orderCount);
|
||||||
data.put("avgOrderValue", avgOrderValue);
|
data.put("avgOrderValue", avgOrderValue);
|
||||||
|
|||||||
+75
@@ -0,0 +1,75 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.ecom.platform.controller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.CreatePlatformDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.PlatformFilterDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.UpdatePlatformDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.vo.PlatformVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.service.PlatformService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台管理控制器
|
||||||
|
*/
|
||||||
|
@Tag(name = "电商-平台管理", description = "平台的增删改查接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ec/platform")
|
||||||
|
public class PlatformController {
|
||||||
|
|
||||||
|
private final PlatformService platformService;
|
||||||
|
|
||||||
|
public PlatformController(PlatformService platformService) {
|
||||||
|
this.platformService = platformService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "创建平台", description = "创建新的平台")
|
||||||
|
@PostMapping("/create")
|
||||||
|
@RequirePermission(value = "ecom:platform:manage", description = "创建平台", allowSuper = true)
|
||||||
|
public ApiResponse<PlatformVO> createPlatform(@Valid @RequestBody CreatePlatformDTO createPlatformDTO) {
|
||||||
|
PlatformVO platformVO = platformService.createPlatform(createPlatformDTO);
|
||||||
|
return ApiResponse.success(platformVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新平台", description = "更新现有平台信息")
|
||||||
|
@PutMapping("/update/{id}")
|
||||||
|
@RequirePermission(value = "ecom:platform:manage", description = "更新平台", allowSuper = true)
|
||||||
|
public ApiResponse<PlatformVO> updatePlatform(@Valid @RequestBody UpdatePlatformDTO updatePlatformDTO,
|
||||||
|
@Parameter(description = "平台ID") @PathVariable Long id) {
|
||||||
|
PlatformVO platformVO = platformService.updatePlatform(updatePlatformDTO, id);
|
||||||
|
return ApiResponse.success(platformVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除平台", description = "删除指定平台")
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
@RequirePermission(value = "ecom:platform:manage", description = "删除平台", allowSuper = true)
|
||||||
|
public ApiResponse<Void> deletePlatform(@Parameter(description = "平台ID") @PathVariable Long id) {
|
||||||
|
platformService.deletePlatform(id);
|
||||||
|
return ApiResponse.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "分页获取平台列表", description = "分页获取平台列表,支持条件过滤")
|
||||||
|
@PostMapping("/page")
|
||||||
|
@RequirePermission(value = "ecom:platform:read", description = "查询平台列表", allowSuper = true)
|
||||||
|
public ApiResponse<PageResultVO<PlatformVO>> getPlatformPage(
|
||||||
|
@Valid @RequestBody PageQueryDTO<PlatformFilterDTO> pageQueryDTO) {
|
||||||
|
PageResultVO<PlatformVO> result = platformService.getPlatformPage(pageQueryDTO);
|
||||||
|
return ApiResponse.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取所有启用的平台", description = "获取所有已启用的平台列表,供下拉选择")
|
||||||
|
@GetMapping("/active")
|
||||||
|
@RequirePermission(value = "ecom:platform:read", description = "查询平台列表", allowSuper = true)
|
||||||
|
public ApiResponse<List<PlatformVO>> getActivePlatforms() {
|
||||||
|
List<PlatformVO> result = platformService.getActivePlatforms();
|
||||||
|
return ApiResponse.success(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台Mapper接口
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface PlatformMapper extends BaseMapper<PlatformPO> {
|
||||||
|
}
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建平台DTO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "创建平台DTO")
|
||||||
|
public class CreatePlatformDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "平台名称", example = "淘宝", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotBlank(message = "平台名称不能为空")
|
||||||
|
private String platformName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台代码
|
||||||
|
*/
|
||||||
|
@Schema(description = "平台代码", example = "taobao", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotBlank(message = "平台代码不能为空")
|
||||||
|
private String platformCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logo URL
|
||||||
|
*/
|
||||||
|
@Schema(description = "Logo URL")
|
||||||
|
private String logoUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
@Schema(description = "排序", example = "1")
|
||||||
|
private Integer sortOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*/
|
||||||
|
@Schema(description = "是否启用 0禁用 1启用", example = "1")
|
||||||
|
private Integer isActive;
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台过滤DTO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "平台过滤DTO")
|
||||||
|
public class PlatformFilterDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "平台名称", example = "淘宝")
|
||||||
|
private String platformName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台代码
|
||||||
|
*/
|
||||||
|
@Schema(description = "平台代码", example = "taobao")
|
||||||
|
private String platformCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*/
|
||||||
|
@Schema(description = "是否启用 0禁用 1启用", example = "1")
|
||||||
|
private Integer isActive;
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新平台DTO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "更新平台DTO")
|
||||||
|
public class UpdatePlatformDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "平台名称", example = "淘宝", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotBlank(message = "平台名称不能为空")
|
||||||
|
private String platformName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台代码
|
||||||
|
*/
|
||||||
|
@Schema(description = "平台代码", example = "taobao", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotBlank(message = "平台代码不能为空")
|
||||||
|
private String platformCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logo URL
|
||||||
|
*/
|
||||||
|
@Schema(description = "Logo URL")
|
||||||
|
private String logoUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
@Schema(description = "排序", example = "1")
|
||||||
|
@NotNull(message = "排序不能为空")
|
||||||
|
private Integer sortOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*/
|
||||||
|
@Schema(description = "是否启用 0禁用 1启用", example = "1")
|
||||||
|
@NotNull(message = "是否启用不能为空")
|
||||||
|
private Integer isActive;
|
||||||
|
}
|
||||||
+76
@@ -0,0 +1,76 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电商-平台实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("ec_platform")
|
||||||
|
public class PlatformPO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台名称(如淘宝、京东、拼多多、抖音)
|
||||||
|
*/
|
||||||
|
@TableField("platform_name")
|
||||||
|
private String platformName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台代码(如 taobao、jd、pdd、douyin)
|
||||||
|
*/
|
||||||
|
@TableField("platform_code")
|
||||||
|
private String platformCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台Logo URL
|
||||||
|
*/
|
||||||
|
@TableField("logo_url")
|
||||||
|
private String logoUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
@TableField("sort_order")
|
||||||
|
private Integer sortOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用 0禁用 1启用
|
||||||
|
*/
|
||||||
|
@TableField("is_active")
|
||||||
|
private Integer isActive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人ID
|
||||||
|
*/
|
||||||
|
@TableField("create_by")
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人ID
|
||||||
|
*/
|
||||||
|
@TableField("update_by")
|
||||||
|
private Long updateBy;
|
||||||
|
}
|
||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.ecom.platform.model.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台VO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "平台VO")
|
||||||
|
public class PlatformVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台ID
|
||||||
|
*/
|
||||||
|
@Schema(description = "平台ID", example = "1")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "平台名称", example = "淘宝")
|
||||||
|
private String platformName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台代码
|
||||||
|
*/
|
||||||
|
@Schema(description = "平台代码", example = "taobao")
|
||||||
|
private String platformCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logo URL
|
||||||
|
*/
|
||||||
|
@Schema(description = "Logo URL", example = "https://example.com/taobao.png")
|
||||||
|
private String logoUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
@Schema(description = "排序", example = "1")
|
||||||
|
private Integer sortOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*/
|
||||||
|
@Schema(description = "是否启用 0禁用 1启用", example = "1")
|
||||||
|
private Integer isActive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.ecom.platform.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.CreatePlatformDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.PlatformFilterDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.UpdatePlatformDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.vo.PlatformVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台服务接口
|
||||||
|
*/
|
||||||
|
public interface PlatformService extends IService<PlatformPO> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建平台
|
||||||
|
*
|
||||||
|
* @param createPlatformDTO 创建平台DTO
|
||||||
|
* @return 平台VO
|
||||||
|
*/
|
||||||
|
PlatformVO createPlatform(CreatePlatformDTO createPlatformDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新平台
|
||||||
|
*
|
||||||
|
* @param updatePlatformDTO 更新平台DTO
|
||||||
|
* @param id 平台ID
|
||||||
|
* @return 平台VO
|
||||||
|
*/
|
||||||
|
PlatformVO updatePlatform(UpdatePlatformDTO updatePlatformDTO, Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除平台
|
||||||
|
*
|
||||||
|
* @param id 平台ID
|
||||||
|
*/
|
||||||
|
void deletePlatform(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页获取平台列表
|
||||||
|
*
|
||||||
|
* @param pageQueryDTO 分页查询DTO
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
PageResultVO<PlatformVO> getPlatformPage(PageQueryDTO<PlatformFilterDTO> pageQueryDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有启用的平台列表
|
||||||
|
*
|
||||||
|
* @return 平台列表
|
||||||
|
*/
|
||||||
|
List<PlatformVO> getActivePlatforms();
|
||||||
|
}
|
||||||
+212
@@ -0,0 +1,212 @@
|
|||||||
|
package top.xyquan.ecomdmbbackend.modules.ecom.platform.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.CreatePlatformDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.PlatformFilterDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.dto.UpdatePlatformDTO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.vo.PlatformVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.service.PlatformService;
|
||||||
|
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台服务实现类
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PlatformServiceImpl extends ServiceImpl<PlatformMapper, PlatformPO> implements PlatformService {
|
||||||
|
|
||||||
|
private final CurrentUserContext currentUserContext;
|
||||||
|
|
||||||
|
public PlatformServiceImpl(CurrentUserContext currentUserContext) {
|
||||||
|
this.currentUserContext = currentUserContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建平台
|
||||||
|
*
|
||||||
|
* @param createPlatformDTO 创建平台DTO
|
||||||
|
* @return 平台VO
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public PlatformVO createPlatform(CreatePlatformDTO createPlatformDTO) {
|
||||||
|
// 验证平台名称是否重复
|
||||||
|
LambdaQueryWrapper<PlatformPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(PlatformPO::getPlatformName, createPlatformDTO.getPlatformName());
|
||||||
|
if (this.count(wrapper) > 0) {
|
||||||
|
throw new BusinessException("平台名称已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证平台代码是否重复
|
||||||
|
wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(PlatformPO::getPlatformCode, createPlatformDTO.getPlatformCode());
|
||||||
|
if (this.count(wrapper) > 0) {
|
||||||
|
throw new BusinessException("平台代码已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建平台
|
||||||
|
PlatformPO platform = new PlatformPO();
|
||||||
|
BeanUtils.copyProperties(createPlatformDTO, platform);
|
||||||
|
|
||||||
|
// 设置默认值
|
||||||
|
if (platform.getSortOrder() == null) {
|
||||||
|
platform.setSortOrder(0);
|
||||||
|
}
|
||||||
|
if (platform.getIsActive() == null) {
|
||||||
|
platform.setIsActive(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置创建人ID
|
||||||
|
platform.setCreateBy(currentUserContext.getCurrentUserId());
|
||||||
|
|
||||||
|
// 保存平台
|
||||||
|
this.save(platform);
|
||||||
|
|
||||||
|
// 转换为VO并返回
|
||||||
|
return convertToVO(platform);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新平台
|
||||||
|
*
|
||||||
|
* @param updatePlatformDTO 更新平台DTO
|
||||||
|
* @param id 平台ID
|
||||||
|
* @return 平台VO
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public PlatformVO updatePlatform(UpdatePlatformDTO updatePlatformDTO, Long id) {
|
||||||
|
// 验证平台是否存在
|
||||||
|
PlatformPO existingPlatform = this.getById(id);
|
||||||
|
if (existingPlatform == null) {
|
||||||
|
throw new BusinessException("平台不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证平台名称是否重复(排除当前平台)
|
||||||
|
LambdaQueryWrapper<PlatformPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.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())
|
||||||
|
.ne(PlatformPO::getId, id);
|
||||||
|
if (this.count(wrapper) > 0) {
|
||||||
|
throw new BusinessException("平台代码已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新平台
|
||||||
|
PlatformPO platform = new PlatformPO();
|
||||||
|
BeanUtils.copyProperties(updatePlatformDTO, platform);
|
||||||
|
platform.setId(id);
|
||||||
|
|
||||||
|
// 设置更新人ID
|
||||||
|
platform.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||||
|
|
||||||
|
// 更新平台
|
||||||
|
this.updateById(platform);
|
||||||
|
|
||||||
|
// 转换为VO并返回
|
||||||
|
return convertToVO(platform);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除平台
|
||||||
|
*
|
||||||
|
* @param id 平台ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void deletePlatform(Long id) {
|
||||||
|
// 验证平台是否存在
|
||||||
|
PlatformPO existingPlatform = this.getById(id);
|
||||||
|
if (existingPlatform == null) {
|
||||||
|
throw new BusinessException("平台不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除平台
|
||||||
|
this.removeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页获取平台列表
|
||||||
|
*
|
||||||
|
* @param pageQueryDTO 分页查询DTO
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResultVO<PlatformVO> getPlatformPage(PageQueryDTO<PlatformFilterDTO> pageQueryDTO) {
|
||||||
|
PlatformFilterDTO filter = pageQueryDTO.getFilters() != null ? pageQueryDTO.getFilters() : new PlatformFilterDTO();
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
LambdaQueryWrapper<PlatformPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (filter.getPlatformName() != null && !filter.getPlatformName().isEmpty()) {
|
||||||
|
wrapper.like(PlatformPO::getPlatformName, filter.getPlatformName());
|
||||||
|
}
|
||||||
|
if (filter.getPlatformCode() != null && !filter.getPlatformCode().isEmpty()) {
|
||||||
|
wrapper.eq(PlatformPO::getPlatformCode, filter.getPlatformCode());
|
||||||
|
}
|
||||||
|
if (filter.getIsActive() != null) {
|
||||||
|
wrapper.eq(PlatformPO::getIsActive, filter.getIsActive());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按排序字段升序
|
||||||
|
wrapper.orderByAsc(PlatformPO::getSortOrder)
|
||||||
|
.orderByDesc(PlatformPO::getCreateTime);
|
||||||
|
|
||||||
|
// 分页查询
|
||||||
|
IPage<PlatformPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||||
|
IPage<PlatformPO> result = this.page(page, wrapper);
|
||||||
|
|
||||||
|
// 转换为VO
|
||||||
|
List<PlatformVO> voList = result.getRecords().stream()
|
||||||
|
.map(this::convertToVO)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
return PageResultVO.create(voList, result.getTotal(), (int) pageQueryDTO.getPage(), (int) pageQueryDTO.getPageSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有启用的平台列表
|
||||||
|
*
|
||||||
|
* @return 平台列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<PlatformVO> getActivePlatforms() {
|
||||||
|
LambdaQueryWrapper<PlatformPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(PlatformPO::getIsActive, 1)
|
||||||
|
.orderByAsc(PlatformPO::getSortOrder);
|
||||||
|
|
||||||
|
return this.list(wrapper).stream()
|
||||||
|
.map(this::convertToVO)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换为VO
|
||||||
|
*
|
||||||
|
* @param platform 平台实体
|
||||||
|
* @return 平台VO
|
||||||
|
*/
|
||||||
|
private PlatformVO convertToVO(PlatformPO platform) {
|
||||||
|
PlatformVO vo = new PlatformVO();
|
||||||
|
BeanUtils.copyProperties(platform, vo);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-3
@@ -25,8 +25,8 @@ public class CreateShopDTO {
|
|||||||
private Long logoImageId;
|
private Long logoImageId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台(如淘宝、京东、拼多多)
|
* 平台ID
|
||||||
*/
|
*/
|
||||||
@Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"})
|
@Schema(description = "平台ID", example = "1")
|
||||||
private String platform;
|
private Long platformId;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -17,8 +17,8 @@ public class ShopFilterDTO {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台
|
* 平台ID
|
||||||
*/
|
*/
|
||||||
@Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"})
|
@Schema(description = "平台ID", example = "1")
|
||||||
private String platform;
|
private Long platformId;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -25,8 +25,8 @@ public class UpdateShopDTO {
|
|||||||
private Long logoImageId;
|
private Long logoImageId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台(如淘宝、京东、拼多多)
|
* 平台ID
|
||||||
*/
|
*/
|
||||||
@Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"})
|
@Schema(description = "平台ID", example = "1")
|
||||||
private String platform;
|
private Long platformId;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -39,10 +39,10 @@ public class ShopPO {
|
|||||||
private Long logoImageId;
|
private Long logoImageId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台(如淘宝、京东、拼多多)
|
* 平台ID
|
||||||
*/
|
*/
|
||||||
@TableField("platform")
|
@TableField("platform_id")
|
||||||
private String platform;
|
private Long platformId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
|
|||||||
+9
-3
@@ -37,10 +37,16 @@ public class ShopVO {
|
|||||||
private String logo;
|
private String logo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台(如淘宝、京东、拼多多)
|
* 平台ID
|
||||||
*/
|
*/
|
||||||
@Schema(description = "平台", example = "淘宝")
|
@Schema(description = "平台ID", example = "1")
|
||||||
private String platform;
|
private Long platformId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "平台名称", example = "淘宝")
|
||||||
|
private String platformName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
|
|||||||
+15
-3
@@ -13,6 +13,8 @@ import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
|||||||
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
|
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.product.mapper.ProductMapper;
|
import top.xyquan.ecomdmbbackend.modules.ecom.product.mapper.ProductMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper;
|
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.shop.mapper.ShopMapper;
|
import top.xyquan.ecomdmbbackend.modules.ecom.shop.mapper.ShopMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.shop.mapper.ShopProductRelationMapper;
|
import top.xyquan.ecomdmbbackend.modules.ecom.shop.mapper.ShopProductRelationMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.CreateShopDTO;
|
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.CreateShopDTO;
|
||||||
@@ -68,12 +70,13 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
|||||||
private final ShopProductRelationMapper shopProductRelationMapper;
|
private final ShopProductRelationMapper shopProductRelationMapper;
|
||||||
private final ProductSpecService productSpecService;
|
private final ProductSpecService productSpecService;
|
||||||
private final OrderStatusService orderStatusService;
|
private final OrderStatusService orderStatusService;
|
||||||
|
private final PlatformMapper platformMapper;
|
||||||
|
|
||||||
public ShopServiceImpl(CurrentUserContext currentUserContext, SysFileMapper sysFileMapper, SysFileService sysFileService,
|
public ShopServiceImpl(CurrentUserContext currentUserContext, SysFileMapper sysFileMapper, SysFileService sysFileService,
|
||||||
OrderMapper orderMapper, PromotionFeeMapper promotionFeeMapper,
|
OrderMapper orderMapper, PromotionFeeMapper promotionFeeMapper,
|
||||||
ProductMapper productMapper,
|
ProductMapper productMapper,
|
||||||
ShopProductRelationMapper shopProductRelationMapper, ProductSpecService productSpecService,
|
ShopProductRelationMapper shopProductRelationMapper, ProductSpecService productSpecService,
|
||||||
OrderStatusService orderStatusService) {
|
OrderStatusService orderStatusService, PlatformMapper platformMapper) {
|
||||||
this.currentUserContext = currentUserContext;
|
this.currentUserContext = currentUserContext;
|
||||||
this.sysFileMapper = sysFileMapper;
|
this.sysFileMapper = sysFileMapper;
|
||||||
this.sysFileService = sysFileService;
|
this.sysFileService = sysFileService;
|
||||||
@@ -83,6 +86,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
|||||||
this.shopProductRelationMapper = shopProductRelationMapper;
|
this.shopProductRelationMapper = shopProductRelationMapper;
|
||||||
this.productSpecService = productSpecService;
|
this.productSpecService = productSpecService;
|
||||||
this.orderStatusService = orderStatusService;
|
this.orderStatusService = orderStatusService;
|
||||||
|
this.platformMapper = platformMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -207,8 +211,8 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
|||||||
if (filter.getName() != null && !filter.getName().trim().isEmpty()) {
|
if (filter.getName() != null && !filter.getName().trim().isEmpty()) {
|
||||||
wrapper.like(ShopPO::getName, filter.getName());
|
wrapper.like(ShopPO::getName, filter.getName());
|
||||||
}
|
}
|
||||||
if (filter.getPlatform() != null && !filter.getPlatform().trim().isEmpty()) {
|
if (filter.getPlatformId() != null) {
|
||||||
wrapper.eq(ShopPO::getPlatform, filter.getPlatform());
|
wrapper.eq(ShopPO::getPlatformId, filter.getPlatformId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,6 +270,14 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
|||||||
shopVO.setLogo(sysFileService.getFileAccessUrl(shop.getLogoImageId()));
|
shopVO.setLogo(sysFileService.getFileAccessUrl(shop.getLogoImageId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取平台名称
|
||||||
|
if (shop.getPlatformId() != null) {
|
||||||
|
PlatformPO platform = platformMapper.selectById(shop.getPlatformId());
|
||||||
|
if (platform != null) {
|
||||||
|
shopVO.setPlatformName(platform.getPlatformName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return shopVO;
|
return shopVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import type { PlatformDTO, PlatformVO } from './types';
|
||||||
|
|
||||||
|
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台管理API
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页获取平台列表
|
||||||
|
*/
|
||||||
|
export async function getPlatformPageApi(
|
||||||
|
params: PageQueryDTO<PlatformDTO.Filters>,
|
||||||
|
) {
|
||||||
|
return requestClient.post<PageResultVO<PlatformVO.Info>>(
|
||||||
|
'/ec/platform/page',
|
||||||
|
params,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建平台
|
||||||
|
*/
|
||||||
|
export async function createPlatformApi(data: PlatformDTO.Create) {
|
||||||
|
return requestClient.post<PlatformVO.Info>('/ec/platform/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新平台
|
||||||
|
*/
|
||||||
|
export async function updatePlatformApi(id: number, data: PlatformDTO.Update) {
|
||||||
|
return requestClient.put<PlatformVO.Info>(`/ec/platform/update/${id}`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除平台
|
||||||
|
*/
|
||||||
|
export async function deletePlatformApi(id: number) {
|
||||||
|
return requestClient.delete(`/ec/platform/delete/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有启用的平台列表
|
||||||
|
*/
|
||||||
|
export async function getActivePlatformsApi() {
|
||||||
|
return requestClient.get<PlatformVO.Info[]>('/ec/platform/active');
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './apis';
|
||||||
|
export * from './types';
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './types.dto';
|
||||||
|
export * from './types.vo';
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
export namespace PlatformDTO {
|
||||||
|
/**
|
||||||
|
* 创建平台
|
||||||
|
*/
|
||||||
|
export interface Create {
|
||||||
|
platformName: string;
|
||||||
|
platformCode: string;
|
||||||
|
logoUrl?: string;
|
||||||
|
sortOrder?: number;
|
||||||
|
isActive?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新平台
|
||||||
|
*/
|
||||||
|
export interface Update {
|
||||||
|
platformName: string;
|
||||||
|
platformCode: string;
|
||||||
|
logoUrl?: string;
|
||||||
|
sortOrder: number;
|
||||||
|
isActive: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤条件
|
||||||
|
*/
|
||||||
|
export interface Filters {
|
||||||
|
platformName?: string;
|
||||||
|
platformCode?: string;
|
||||||
|
isActive?: number;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
export namespace PlatformVO {
|
||||||
|
/**
|
||||||
|
* 平台信息
|
||||||
|
*/
|
||||||
|
export interface Info {
|
||||||
|
id: number;
|
||||||
|
platformName: string;
|
||||||
|
platformCode: string;
|
||||||
|
logoUrl?: string;
|
||||||
|
sortOrder: number;
|
||||||
|
isActive: number;
|
||||||
|
createTime: string;
|
||||||
|
updateTime: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,8 +9,8 @@ export namespace ShopDTO {
|
|||||||
name: string;
|
name: string;
|
||||||
/** logo图片ID */
|
/** logo图片ID */
|
||||||
logoImageId?: number;
|
logoImageId?: number;
|
||||||
/** 平台(如淘宝、京东、拼多多) */
|
/** 平台ID */
|
||||||
platform?: string;
|
platformId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 更新店铺参数 */
|
/** 更新店铺参数 */
|
||||||
@@ -19,16 +19,16 @@ export namespace ShopDTO {
|
|||||||
name: string;
|
name: string;
|
||||||
/** logo图片ID */
|
/** logo图片ID */
|
||||||
logoImageId?: number;
|
logoImageId?: number;
|
||||||
/** 平台(如淘宝、京东、拼多多) */
|
/** 平台ID */
|
||||||
platform?: string;
|
platformId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 店铺过滤条件 */
|
/** 店铺过滤条件 */
|
||||||
export interface Filters {
|
export interface Filters {
|
||||||
/** 店铺名称(模糊查询) */
|
/** 店铺名称(模糊查询) */
|
||||||
name?: string;
|
name?: string;
|
||||||
/** 平台 */
|
/** 平台ID */
|
||||||
platform?: string;
|
platformId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 店铺统计查询参数 */
|
/** 店铺统计查询参数 */
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ export namespace ShopVO {
|
|||||||
logo?: string;
|
logo?: string;
|
||||||
/** logo图片ID */
|
/** logo图片ID */
|
||||||
logoImageId?: number;
|
logoImageId?: number;
|
||||||
/** 平台(如淘宝、京东、拼多多) */
|
/** 平台ID */
|
||||||
platform?: string;
|
platformId?: number;
|
||||||
|
/** 平台名称 */
|
||||||
|
platformName?: string;
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
createTime: string;
|
createTime: string;
|
||||||
/** 更新时间 */
|
/** 更新时间 */
|
||||||
|
|||||||
@@ -19,6 +19,15 @@ const routes: RouteRecordRaw[] = [
|
|||||||
title: '数据导入',
|
title: '数据导入',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'PlatformManagement',
|
||||||
|
path: '/data/platform',
|
||||||
|
component: () => import('#/views/ecommerce/platform/list/index.vue'),
|
||||||
|
meta: {
|
||||||
|
icon: 'lucide:app-store',
|
||||||
|
title: '平台管理',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -181,7 +181,8 @@ const goImportTask = () => {
|
|||||||
--border-color: #e2e8f0;
|
--border-color: #e2e8f0;
|
||||||
--badge-bg: #eff6ff;
|
--badge-bg: #eff6ff;
|
||||||
--badge-border: #dbeafe;
|
--badge-border: #dbeafe;
|
||||||
height: 100vh;
|
min-height: 0;
|
||||||
|
flex: 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -513,7 +514,6 @@ html.dark .welcome-page {
|
|||||||
--border-color: hsl(240deg 3.7% 22%);
|
--border-color: hsl(240deg 3.7% 22%);
|
||||||
--badge-bg: hsl(217deg 91% 60% / 14%);
|
--badge-bg: hsl(217deg 91% 60% / 14%);
|
||||||
--badge-border: hsl(217deg 91% 60% / 28%);
|
--badge-border: hsl(217deg 91% 60% / 28%);
|
||||||
height: 100vh;
|
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
145deg,
|
145deg,
|
||||||
hsl(222.34deg 10.43% 12.27%) 0%,
|
hsl(222.34deg 10.43% 12.27%) 0%,
|
||||||
|
|||||||
+179
@@ -0,0 +1,179 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { PlatformDTO, PlatformVO } from '#/api/ecommerce/platform/types';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { Form, Input, message, Select, Switch } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { createPlatformApi, updatePlatformApi } from '#/api/ecommerce/platform';
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: 'success'): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
|
// 创建 vben modal
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
draggable: true,
|
||||||
|
class: 'w-[500px]',
|
||||||
|
onCancel() {
|
||||||
|
handleCancel();
|
||||||
|
},
|
||||||
|
onConfirm() {
|
||||||
|
handleSubmit();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 内部状态
|
||||||
|
const isEdit = ref(false);
|
||||||
|
const currentPlatformData = ref<PlatformVO.Info | null>(null);
|
||||||
|
const formRef = ref();
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
// 表单数据
|
||||||
|
const formData = ref({
|
||||||
|
platformName: '',
|
||||||
|
platformCode: '',
|
||||||
|
logoUrl: '',
|
||||||
|
sortOrder: 0,
|
||||||
|
isActive: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 模态框标题
|
||||||
|
const modalTitle = computed(() => (isEdit.value ? '编辑平台' : '添加平台'));
|
||||||
|
|
||||||
|
// 初始化表单数据
|
||||||
|
function initFormData() {
|
||||||
|
if (isEdit.value && currentPlatformData.value) {
|
||||||
|
formData.value = {
|
||||||
|
platformName: currentPlatformData.value.platformName || '',
|
||||||
|
platformCode: currentPlatformData.value.platformCode || '',
|
||||||
|
logoUrl: currentPlatformData.value.logoUrl || '',
|
||||||
|
sortOrder: currentPlatformData.value.sortOrder || 0,
|
||||||
|
isActive: currentPlatformData.value.isActive === 1,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
formData.value = {
|
||||||
|
platformName: '',
|
||||||
|
platformCode: '',
|
||||||
|
logoUrl: '',
|
||||||
|
sortOrder: 0,
|
||||||
|
isActive: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭模态框
|
||||||
|
function handleCancel() {
|
||||||
|
formRef.value?.resetFields();
|
||||||
|
modalApi.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理提交
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
await formRef.value?.validate();
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
const submitData: PlatformDTO.Create | PlatformDTO.Update = {
|
||||||
|
platformName: formData.value.platformName,
|
||||||
|
platformCode: formData.value.platformCode,
|
||||||
|
logoUrl: formData.value.logoUrl || undefined,
|
||||||
|
sortOrder: formData.value.sortOrder,
|
||||||
|
isActive: formData.value.isActive ? 1 : 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isEdit.value && currentPlatformData.value?.id) {
|
||||||
|
await updatePlatformApi(
|
||||||
|
currentPlatformData.value.id,
|
||||||
|
submitData as PlatformDTO.Update,
|
||||||
|
);
|
||||||
|
message.success('更新成功');
|
||||||
|
} else {
|
||||||
|
await createPlatformApi(submitData as PlatformDTO.Create);
|
||||||
|
message.success('创建成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
emit('success');
|
||||||
|
handleCancel();
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error?.errorFields) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
message.error(error?.message || '操作失败');
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 暴露给父组件的方法
|
||||||
|
function open(
|
||||||
|
editMode: boolean = false,
|
||||||
|
platformData?: PlatformVO.Info,
|
||||||
|
) {
|
||||||
|
isEdit.value = editMode;
|
||||||
|
currentPlatformData.value = platformData || null;
|
||||||
|
initFormData();
|
||||||
|
modalApi.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 暴露方法给父组件
|
||||||
|
defineExpose({
|
||||||
|
open,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="modalTitle">
|
||||||
|
<Form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
layout="vertical"
|
||||||
|
class="mx-4 my-4"
|
||||||
|
>
|
||||||
|
<Form.Item
|
||||||
|
label="平台名称"
|
||||||
|
name="platformName"
|
||||||
|
:rules="[{ required: true, message: '请输入平台名称' }]"
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
v-model:value="formData.platformName"
|
||||||
|
placeholder="如:淘宝、京东"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
label="平台代码"
|
||||||
|
name="platformCode"
|
||||||
|
:rules="[{ required: true, message: '请输入平台代码' }]"
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
v-model:value="formData.platformCode"
|
||||||
|
placeholder="如:taobao、jd"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="Logo URL" name="logoUrl">
|
||||||
|
<Input
|
||||||
|
v-model:value="formData.logoUrl"
|
||||||
|
placeholder="平台Logo图片地址(可选)"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="排序" name="sortOrder">
|
||||||
|
<Input
|
||||||
|
v-model:value="formData.sortOrder"
|
||||||
|
type="number"
|
||||||
|
placeholder="数值越小越靠前"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="启用状态" name="isActive">
|
||||||
|
<Switch v-model:checked="formData.isActive" />
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,294 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
import type { PlatformVO } from '#/api/ecommerce/platform/types';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { Page } from '@vben/common-ui';
|
||||||
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import { Avatar, Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
createPlatformApi,
|
||||||
|
deletePlatformApi,
|
||||||
|
getPlatformPageApi,
|
||||||
|
updatePlatformApi,
|
||||||
|
} from '#/api/ecommerce/platform';
|
||||||
|
|
||||||
|
import PlatformFormModal from './components/PlatformFormModal.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'PlatformManagement' });
|
||||||
|
|
||||||
|
// 创建图标组件
|
||||||
|
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||||
|
|
||||||
|
// 响应式数据
|
||||||
|
const loading = ref(false);
|
||||||
|
const platformFormModalRef = ref<InstanceType<typeof PlatformFormModal>>();
|
||||||
|
|
||||||
|
// 搜索表单
|
||||||
|
const searchForm = ref({
|
||||||
|
platformName: '',
|
||||||
|
platformCode: '',
|
||||||
|
isActive: undefined as number | undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 当前排序状态
|
||||||
|
const currentSort = ref<null | { field: string; order: 'asc' | 'desc' }>(null);
|
||||||
|
|
||||||
|
// VxeGrid 表格配置
|
||||||
|
const gridOptions: VxeGridProps<any> = {
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
type: 'seq' as const,
|
||||||
|
width: 80,
|
||||||
|
title: '序号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'platformName',
|
||||||
|
title: '平台名称',
|
||||||
|
minWidth: 140,
|
||||||
|
showOverflow: true,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'platformCode',
|
||||||
|
title: '平台代码',
|
||||||
|
minWidth: 120,
|
||||||
|
showOverflow: true,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'logoUrl',
|
||||||
|
title: 'Logo',
|
||||||
|
width: 100,
|
||||||
|
align: 'center',
|
||||||
|
slots: { default: 'logo' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sortOrder',
|
||||||
|
title: '排序',
|
||||||
|
width: 80,
|
||||||
|
align: 'center',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'isActive',
|
||||||
|
title: '状态',
|
||||||
|
width: 100,
|
||||||
|
align: 'center',
|
||||||
|
slots: { default: 'isActive' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
minWidth: 160,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'updateTime',
|
||||||
|
title: '更新时间',
|
||||||
|
minWidth: 160,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 150,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'action' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
height: 'auto',
|
||||||
|
border: true,
|
||||||
|
stripe: true,
|
||||||
|
highlightHoverRow: true,
|
||||||
|
showOverflow: true,
|
||||||
|
size: 'small',
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: true,
|
||||||
|
pageSize: 20,
|
||||||
|
pageSizes: [10, 20, 50, 100],
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page, form }) => {
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
const filters = {
|
||||||
|
platformName:
|
||||||
|
form?.platformName || searchForm.value.platformName || undefined,
|
||||||
|
platformCode:
|
||||||
|
form?.platformCode || searchForm.value.platformCode || undefined,
|
||||||
|
isActive: form?.isActive ?? searchForm.value.isActive,
|
||||||
|
};
|
||||||
|
const params: any = {
|
||||||
|
page: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
filters,
|
||||||
|
};
|
||||||
|
if (currentSort.value) {
|
||||||
|
params.sorts = [currentSort.value];
|
||||||
|
}
|
||||||
|
const data = await getPlatformPageApi(params);
|
||||||
|
return {
|
||||||
|
items: data.records || [],
|
||||||
|
total: data.total || 0,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取平台列表失败:', error);
|
||||||
|
message.error('获取平台列表失败');
|
||||||
|
return { items: [], total: 0 };
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// 搜索表单配置(FormSearch 组件)
|
||||||
|
const gridReloadRef = ref<(() => void) | null>(null);
|
||||||
|
const formOptions = computed(() => ({
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入平台名称(回车搜索)',
|
||||||
|
onPressEnter: () => gridReloadRef.value?.(),
|
||||||
|
},
|
||||||
|
fieldName: 'platformName',
|
||||||
|
label: '平台名称',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入平台代码(回车搜索)',
|
||||||
|
onPressEnter: () => gridReloadRef.value?.(),
|
||||||
|
},
|
||||||
|
fieldName: 'platformCode',
|
||||||
|
label: '平台代码',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择状态',
|
||||||
|
allowClear: true,
|
||||||
|
options: [
|
||||||
|
{ label: '启用', value: 1 },
|
||||||
|
{ label: '禁用', value: 0 },
|
||||||
|
],
|
||||||
|
onChange: (val: any) => {
|
||||||
|
searchForm.value.isActive = val;
|
||||||
|
gridReloadRef.value?.();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fieldName: 'isActive',
|
||||||
|
label: '状态',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
showDefaultActions: true,
|
||||||
|
collapsed: true,
|
||||||
|
collapsedRows: 1,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// 创建 VxeGrid 实例
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions,
|
||||||
|
formOptions: formOptions.value,
|
||||||
|
showSearchForm: true,
|
||||||
|
tableTitle: '平台管理',
|
||||||
|
});
|
||||||
|
gridReloadRef.value = () => gridApi.reload();
|
||||||
|
|
||||||
|
// 刷新表格
|
||||||
|
function refreshTable() {
|
||||||
|
gridApi.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开新增模态框
|
||||||
|
function handleAdd() {
|
||||||
|
platformFormModalRef.value?.open(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开编辑模态框
|
||||||
|
function handleEdit(row: PlatformVO.Info) {
|
||||||
|
platformFormModalRef.value?.open(true, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除平台
|
||||||
|
async function handleDelete(id: number) {
|
||||||
|
try {
|
||||||
|
await deletePlatformApi(id);
|
||||||
|
message.success('删除成功');
|
||||||
|
refreshTable();
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error?.message || '删除失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 排序变化
|
||||||
|
function handleSortChange({
|
||||||
|
field,
|
||||||
|
order,
|
||||||
|
}: {
|
||||||
|
field?: string;
|
||||||
|
order?: 'asc' | 'desc' | null;
|
||||||
|
}) {
|
||||||
|
currentSort.value = field
|
||||||
|
? { field, order: order || 'desc' }
|
||||||
|
: null;
|
||||||
|
gridReloadRef.value?.();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<!-- VxeGrid 表格 -->
|
||||||
|
<Grid :loading="loading" @sort-change="handleSortChange">
|
||||||
|
<!-- 工具栏 -->
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<Space>
|
||||||
|
<Button type="primary" @click="handleAdd">
|
||||||
|
<PlusIcon />
|
||||||
|
添加平台
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Logo 列 -->
|
||||||
|
<template #logo="{ row }">
|
||||||
|
<Avatar
|
||||||
|
v-if="row.logoUrl"
|
||||||
|
:src="row.logoUrl"
|
||||||
|
:size="36"
|
||||||
|
shape="square"
|
||||||
|
/>
|
||||||
|
<span v-else class="text-gray-400">-</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 状态列 -->
|
||||||
|
<template #isActive="{ row }">
|
||||||
|
<Tag :color="row.isActive === 1 ? 'success' : 'default'" type="outline">
|
||||||
|
{{ row.isActive === 1 ? '启用' : '禁用' }}
|
||||||
|
</Tag>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 操作列 -->
|
||||||
|
<template #action="{ row }">
|
||||||
|
<Space>
|
||||||
|
<Button type="link" size="small" @click="handleEdit(row)">
|
||||||
|
编辑
|
||||||
|
</Button>
|
||||||
|
<Popconfirm title="确定删除该平台?" @confirm="handleDelete(row.id)">
|
||||||
|
<Button type="link" danger size="small">删除</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 表单模态框 -->
|
||||||
|
<PlatformFormModal ref="platformFormModalRef" @success="refreshTable" />
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
+24
-12
@@ -9,6 +9,7 @@ import { createIconifyIcon } from '@vben/icons';
|
|||||||
import { Button, Form, Input, message, Select } from 'ant-design-vue';
|
import { Button, Form, Input, message, Select } from 'ant-design-vue';
|
||||||
|
|
||||||
import { createShopApi, updateShopApi } from '#/api/ecommerce/shop';
|
import { createShopApi, updateShopApi } from '#/api/ecommerce/shop';
|
||||||
|
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
|
||||||
import { uploadFileToOss } from '#/utils/oss-upload';
|
import { uploadFileToOss } from '#/utils/oss-upload';
|
||||||
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
@@ -46,17 +47,26 @@ const imageLoadError = ref(false); // 图片加载错误状态
|
|||||||
// 表单数据
|
// 表单数据
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
name: '',
|
name: '',
|
||||||
platform: '',
|
platformId: undefined as number | undefined,
|
||||||
logoImageId: undefined as number | undefined,
|
logoImageId: undefined as number | undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 平台选项
|
// 平台选项(动态加载)
|
||||||
const platformOptions = [
|
const platformOptions = ref<{ label: string; value: number }[]>([]);
|
||||||
{ label: '淘宝', value: '淘宝' },
|
|
||||||
{ label: '京东', value: '京东' },
|
|
||||||
{ label: '拼多多', value: '拼多多' },
|
// 加载平台列表
|
||||||
{ label: '天猫', value: '天猫' },
|
async function fetchPlatformOptions() {
|
||||||
];
|
try {
|
||||||
|
const data = await getActivePlatformsApi();
|
||||||
|
platformOptions.value = data.map((p: any) => ({
|
||||||
|
label: p.platformName,
|
||||||
|
value: p.id,
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取平台列表失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 模态框标题
|
// 模态框标题
|
||||||
const modalTitle = computed(() => (isEdit.value ? '编辑店铺' : '添加店铺'));
|
const modalTitle = computed(() => (isEdit.value ? '编辑店铺' : '添加店铺'));
|
||||||
@@ -75,7 +85,7 @@ function initFormData() {
|
|||||||
// 编辑模式
|
// 编辑模式
|
||||||
formData.value = {
|
formData.value = {
|
||||||
name: currentShopData.value.name || '',
|
name: currentShopData.value.name || '',
|
||||||
platform: currentShopData.value.platform || '',
|
platformId: currentShopData.value.platformId,
|
||||||
logoImageId: undefined,
|
logoImageId: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -85,7 +95,7 @@ function initFormData() {
|
|||||||
// 创建模式 - 如果有传入的shopData,则使用它来初始化表单
|
// 创建模式 - 如果有传入的shopData,则使用它来初始化表单
|
||||||
formData.value = {
|
formData.value = {
|
||||||
name: currentShopData.value?.name || '',
|
name: currentShopData.value?.name || '',
|
||||||
platform: currentShopData.value?.platform || '',
|
platformId: currentShopData.value?.platformId,
|
||||||
logoImageId: undefined,
|
logoImageId: undefined,
|
||||||
};
|
};
|
||||||
originalLogoUrl.value = currentShopData.value?.logo || '';
|
originalLogoUrl.value = currentShopData.value?.logo || '';
|
||||||
@@ -102,6 +112,8 @@ function resetForm() {
|
|||||||
newLogoFile.value = null;
|
newLogoFile.value = null;
|
||||||
originalLogoUrl.value = '';
|
originalLogoUrl.value = '';
|
||||||
imageLoadError.value = false;
|
imageLoadError.value = false;
|
||||||
|
// 加载平台选项
|
||||||
|
fetchPlatformOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理提交
|
// 处理提交
|
||||||
@@ -366,9 +378,9 @@ onUnmounted(() => {
|
|||||||
<Input v-model:value="formData.name" placeholder="请输入店铺名称" />
|
<Input v-model:value="formData.name" placeholder="请输入店铺名称" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item label="平台" name="platform">
|
<Form.Item label="平台" name="platformId">
|
||||||
<Select
|
<Select
|
||||||
v-model:value="formData.platform"
|
v-model:value="formData.platformId"
|
||||||
placeholder="请选择平台"
|
placeholder="请选择平台"
|
||||||
:options="platformOptions"
|
:options="platformOptions"
|
||||||
allow-clear
|
allow-clear
|
||||||
|
|||||||
@@ -30,18 +30,13 @@ const shopFormModalRef = ref();
|
|||||||
// 搜索表单
|
// 搜索表单
|
||||||
const searchForm = ref({
|
const searchForm = ref({
|
||||||
name: '',
|
name: '',
|
||||||
platform: undefined as string | undefined,
|
platformId: undefined as number | undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 表单数据(已移至ShopFormModal组件)
|
// 表单数据(已移至ShopFormModal组件)
|
||||||
|
|
||||||
// 平台选项
|
// 平台选项(动态加载)
|
||||||
const platformOptions = [
|
const platformOptions = ref<{ label: string; value: number }[]>([]);
|
||||||
{ label: '淘宝', value: '淘宝' },
|
|
||||||
{ label: '京东', value: '京东' },
|
|
||||||
{ label: '拼多多', value: '拼多多' },
|
|
||||||
{ label: '天猫', value: '天猫' },
|
|
||||||
];
|
|
||||||
|
|
||||||
// VbenVxeGrid 表格配置
|
// VbenVxeGrid 表格配置
|
||||||
const gridOptions: VxeGridProps<any> = {
|
const gridOptions: VxeGridProps<any> = {
|
||||||
@@ -65,10 +60,10 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
slots: { default: 'name' },
|
slots: { default: 'name' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'platform',
|
field: 'platformName',
|
||||||
title: '平台',
|
title: '平台',
|
||||||
minWidth: 'auto',
|
minWidth: 120,
|
||||||
showOverflow: 'tooltip' as const,
|
showOverflow: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
@@ -133,7 +128,7 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
filters: {
|
filters: {
|
||||||
name: searchForm.value.name || undefined,
|
name: searchForm.value.name || undefined,
|
||||||
platform: searchForm.value.platform,
|
platformId: searchForm.value.platformId,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const data = await getShopPageApi(params);
|
const data = await getShopPageApi(params);
|
||||||
@@ -175,9 +170,12 @@ const formOptions = computed(() => ({
|
|||||||
placeholder: '请选择平台',
|
placeholder: '请选择平台',
|
||||||
options: platformOptions,
|
options: platformOptions,
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
onChange: () => gridReloadRef.value?.(),
|
onChange: (val: any) => {
|
||||||
|
searchForm.value.platformId = val;
|
||||||
|
gridReloadRef.value?.();
|
||||||
},
|
},
|
||||||
fieldName: 'platform',
|
},
|
||||||
|
fieldName: 'platformId',
|
||||||
label: '平台',
|
label: '平台',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -195,6 +193,20 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
});
|
});
|
||||||
gridReloadRef.value = () => gridApi.reload();
|
gridReloadRef.value = () => gridApi.reload();
|
||||||
|
|
||||||
|
|
||||||
|
// 加载平台选项
|
||||||
|
async function fetchPlatformOptions() {
|
||||||
|
try {
|
||||||
|
const data = await getActivePlatformsApi();
|
||||||
|
platformOptions.value = data.map((p: any) => ({
|
||||||
|
label: p.platformName,
|
||||||
|
value: p.id,
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取平台列表失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 刷新表格数据
|
// 刷新表格数据
|
||||||
function refreshTable() {
|
function refreshTable() {
|
||||||
if (gridApi) {
|
if (gridApi) {
|
||||||
|
|||||||
Reference in New Issue
Block a user