mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 06:29:20 +08:00
refactor: 推广记录 platform 字段改为外键关联 ec_platform 表,平台下拉动态加载
This commit is contained in:
@@ -292,8 +292,8 @@ CREATE TABLE `ec_promotion_fee` (
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||
`shop_id` bigint UNSIGNED NOT NULL COMMENT '店铺ID',
|
||||
`fee_type_id` bigint UNSIGNED NOT NULL COMMENT '推广费类型ID',
|
||||
`platform_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '平台ID',
|
||||
`fee_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '推广费名称',
|
||||
`platform` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '平台(淘宝、京东、拼多多等)',
|
||||
`campaign_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '推广活动名称',
|
||||
`fee_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '推广费金额',
|
||||
`base_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '基础金额(用于按比例计算)',
|
||||
@@ -312,12 +312,13 @@ CREATE TABLE `ec_promotion_fee` (
|
||||
INDEX `idx_shop_id`(`shop_id` ASC) USING BTREE,
|
||||
INDEX `idx_fee_type_id`(`fee_type_id` ASC) USING BTREE,
|
||||
INDEX `idx_fee_date`(`fee_date` ASC) USING BTREE,
|
||||
INDEX `idx_platform`(`platform` ASC) USING BTREE,
|
||||
INDEX `idx_platform_id`(`platform_id` ASC) USING BTREE,
|
||||
INDEX `fk_ec_promotion_fee_creator`(`create_by` ASC) USING BTREE,
|
||||
INDEX `fk_ec_promotion_fee_updater`(`update_by` ASC) USING BTREE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_shop` FOREIGN KEY (`shop_id`) REFERENCES `ec_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_platform` FOREIGN KEY (`platform_id`) REFERENCES `ec_platform` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_type` FOREIGN KEY (`fee_type_id`) REFERENCES `ec_promotion_fee_type` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_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 = '电商-推广费记录表' ;
|
||||
|
||||
+4
-4
@@ -37,10 +37,10 @@ public class CreatePromotionFeeDTO {
|
||||
private String feeName;
|
||||
|
||||
/**
|
||||
* 平台(淘宝、京东、拼多多等)
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝")
|
||||
private String platform;
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 推广活动名称
|
||||
@@ -97,4 +97,4 @@ public class CreatePromotionFeeDTO {
|
||||
*/
|
||||
@Schema(description = "备注", example = "双十一期间推广费用")
|
||||
private String remark;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -25,10 +25,10 @@ public class PromotionFeeFilterDTO {
|
||||
private Long feeTypeId;
|
||||
|
||||
/**
|
||||
* 平台
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝")
|
||||
private String platform;
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 推广费发生日期开始
|
||||
@@ -41,4 +41,4 @@ public class PromotionFeeFilterDTO {
|
||||
*/
|
||||
@Schema(description = "推广费发生日期结束", example = "2024-01-31")
|
||||
private LocalDate feeDateEnd;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -44,10 +44,10 @@ public class UpdatePromotionFeeDTO {
|
||||
private String feeName;
|
||||
|
||||
/**
|
||||
* 平台(淘宝、京东、拼多多等)
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝")
|
||||
private String platform;
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 推广活动名称
|
||||
@@ -104,4 +104,4 @@ public class UpdatePromotionFeeDTO {
|
||||
*/
|
||||
@Schema(description = "备注", example = "双十一期间推广费用")
|
||||
private String remark;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -40,18 +40,18 @@ public class PromotionFeePO {
|
||||
@TableField("fee_type_id")
|
||||
private Long feeTypeId;
|
||||
|
||||
/**
|
||||
* 平台ID
|
||||
*/
|
||||
@TableField("platform_id")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 推广费名称
|
||||
*/
|
||||
@TableField("fee_name")
|
||||
private String feeName;
|
||||
|
||||
/**
|
||||
* 平台(淘宝、京东、拼多多等)
|
||||
*/
|
||||
@TableField("platform")
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 推广活动名称
|
||||
*/
|
||||
|
||||
+12
@@ -50,6 +50,18 @@ public class PromotionFeeVO {
|
||||
@Schema(description = "推广费类型名称", example = "直通车")
|
||||
private String feeTypeName;
|
||||
|
||||
/**
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 平台名称
|
||||
*/
|
||||
@Schema(description = "平台名称", example = "淘宝")
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 推广费名称
|
||||
*/
|
||||
|
||||
+18
-14
@@ -17,8 +17,9 @@ import top.xyquan.ecomdmbbackend.modules.ecom.promotion.model.dto.UpdatePromotio
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.model.po.PromotionFeePO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.model.vo.PromotionFeeVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.service.PromotionFeeService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.shop.service.ShopService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.service.PromotionFeeTypeService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.service.PlatformService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.shop.service.ShopService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.util.List;
|
||||
@@ -35,6 +36,7 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
private final CurrentUserContext currentUserContext;
|
||||
private final ShopService shopService;
|
||||
private final PromotionFeeTypeService promotionFeeTypeService;
|
||||
private final PlatformService platformService;
|
||||
|
||||
/**
|
||||
* 创建推广费记录
|
||||
@@ -49,7 +51,7 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
po.setCompanyId(currentUserContext.getCurrentCompanyId());
|
||||
po.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
po.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
|
||||
promotionFeeMapper.insert(po);
|
||||
return po.getId();
|
||||
}
|
||||
@@ -110,17 +112,13 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<PromotionFeeVO> getPromotionFeePage(PageQueryDTO<PromotionFeeFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 创建分页对象
|
||||
Page<PromotionFeePO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<PromotionFeePO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PromotionFeePO::getCompanyId, companyId);
|
||||
|
||||
// 添加过滤条件
|
||||
PromotionFeeFilterDTO filter = pageQueryDTO.getFilters();
|
||||
if (filter != null) {
|
||||
if (filter.getShopId() != null) {
|
||||
@@ -129,8 +127,8 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
if (filter.getFeeTypeId() != null) {
|
||||
wrapper.eq(PromotionFeePO::getFeeTypeId, filter.getFeeTypeId());
|
||||
}
|
||||
if (filter.getPlatform() != null && !filter.getPlatform().trim().isEmpty()) {
|
||||
wrapper.like(PromotionFeePO::getPlatform, filter.getPlatform());
|
||||
if (filter.getPlatformId() != null) {
|
||||
wrapper.eq(PromotionFeePO::getPlatformId, filter.getPlatformId());
|
||||
}
|
||||
if (filter.getFeeDateStart() != null) {
|
||||
wrapper.ge(PromotionFeePO::getFeeDate, filter.getFeeDateStart());
|
||||
@@ -140,19 +138,15 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
}
|
||||
}
|
||||
|
||||
// 排序
|
||||
wrapper.orderByDesc(PromotionFeePO::getFeeDate)
|
||||
.orderByDesc(PromotionFeePO::getCreateTime);
|
||||
|
||||
// 执行分页查询
|
||||
IPage<PromotionFeePO> pageResult = promotionFeeMapper.selectPage(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<PromotionFeeVO> voList = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建分页结果
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
@@ -182,10 +176,20 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
vo.setFeeTypeName(feeTypeVO.getTypeName());
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// 查询失败不影响主流程
|
||||
}
|
||||
}
|
||||
|
||||
// 填充平台名称
|
||||
if (po.getPlatformId() != null) {
|
||||
try {
|
||||
var platform = platformService.getById(po.getPlatformId());
|
||||
if (platform != null) {
|
||||
vo.setPlatformName(platform.getPlatformName());
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user