mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:19:19 +08:00
feat(ecom): 推广费表增加商品维度,移除冗余字段和平台外键
- ec_promotion_fee 新增 product_id 字段(可空,关联 ec_product) - 移除冗余字段:fee_name / base_amount / fee_rate / click_count / impression_count / conversion_count - 移除 ec_promotion_fee.platform_id 外键(店铺已关联平台,此处冗余) - 后端 PO/DTO/VO 层字段更新,DTO 新增 productId 过滤条件 - ShopOverviewStatisticsServiceImpl 推广费计算改为有 product_id 直接归属,无则按销售额比例分配 - 前端类型定义和推广费表单同步更新
This commit is contained in:
@@ -292,16 +292,11 @@ CREATE TABLE `ec_promotion_fee` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '推广费记录ID',
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||
`shop_id` bigint UNSIGNED NOT NULL COMMENT '店铺ID',
|
||||
`product_id` bigint UNSIGNED NULL DEFAULT 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 '推广费名称',
|
||||
`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 '基础金额(用于按比例计算)',
|
||||
`fee_rate` decimal(5, 4) NULL DEFAULT NULL COMMENT '费率(用于按比例计算)',
|
||||
`click_count` int NULL DEFAULT NULL COMMENT '点击次数',
|
||||
`impression_count` int NULL DEFAULT NULL COMMENT '展示次数',
|
||||
`conversion_count` int NULL DEFAULT NULL COMMENT '转化次数',
|
||||
`fee_date` date NOT NULL COMMENT '推广费发生日期',
|
||||
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
@@ -311,6 +306,7 @@ CREATE TABLE `ec_promotion_fee` (
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_company_id`(`company_id` ASC) USING BTREE,
|
||||
INDEX `idx_shop_id`(`shop_id` ASC) USING BTREE,
|
||||
INDEX `idx_product_id`(`product_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_id`(`platform_id` ASC) USING BTREE,
|
||||
@@ -319,6 +315,7 @@ CREATE TABLE `ec_promotion_fee` (
|
||||
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_product` FOREIGN KEY (`product_id`) REFERENCES `ec_product` (`id`) ON DELETE SET NULL 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
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
-- ================================================
|
||||
-- ec_promotion_fee 表结构迁移
|
||||
-- 1. 新增 product_id 字段及外键(可空,关联 ec_product)
|
||||
-- 2. 移除冗余字段:fee_name / base_amount / fee_rate / click_count / impression_count / conversion_count
|
||||
-- ================================================
|
||||
|
||||
-- Step1: 新增 product_id 字段(在 platform_id 之后)
|
||||
ALTER TABLE ec_promotion_fee
|
||||
ADD COLUMN `product_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '商品ID(可选)' AFTER `platform_id`;
|
||||
|
||||
-- Step2: 新增外键约束
|
||||
ALTER TABLE ec_promotion_fee
|
||||
ADD CONSTRAINT `fk_ec_promotion_fee_product`
|
||||
FOREIGN KEY (`product_id`) REFERENCES `ec_product` (`id`)
|
||||
ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- Step3: 新增 product_id 索引(外键未自动建索引需手动建)
|
||||
ALTER TABLE ec_promotion_fee
|
||||
ADD INDEX `idx_product_id`(`product_id` ASC);
|
||||
|
||||
-- Step4: 移除冗余字段
|
||||
ALTER TABLE ec_promotion_fee DROP COLUMN `fee_name`;
|
||||
ALTER TABLE ec_promotion_fee DROP COLUMN `base_amount`;
|
||||
ALTER TABLE ec_promotion_fee DROP COLUMN `fee_rate`;
|
||||
ALTER TABLE ec_promotion_fee DROP COLUMN `click_count`;
|
||||
ALTER TABLE ec_promotion_fee DROP COLUMN `impression_count`;
|
||||
ALTER TABLE ec_promotion_fee DROP COLUMN `conversion_count`;
|
||||
+62
-17
@@ -34,9 +34,11 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -399,12 +401,29 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
.filter(brush -> brush.getProductId() != null)
|
||||
.collect(Collectors.groupingBy(BrushOrderPO::getProductId));
|
||||
|
||||
// 推广费无法按商品分组(推广费只有店铺级别),所以每个商品使用相同的推广费比例
|
||||
BigDecimal totalPromotionFee = promotionFees.stream()
|
||||
// 按商品ID分组推广费:有 product_id 的为直接归属,无 product_id 的进入比例池
|
||||
Map<Long, BigDecimal> directPromotionByProduct = promotionFees.stream()
|
||||
.filter(fee -> fee.getProductId() != null)
|
||||
.collect(Collectors.groupingBy(
|
||||
PromotionFeePO::getProductId,
|
||||
Collectors.reducing(
|
||||
BigDecimal.ZERO,
|
||||
fee -> fee.getFeeAmount() != null ? fee.getFeeAmount() : BigDecimal.ZERO,
|
||||
BigDecimal::add)));
|
||||
// 无商品归属的推广费(店铺级),按销售比例分配
|
||||
BigDecimal ratioPool = promotionFees.stream()
|
||||
.filter(fee -> fee.getProductId() == null)
|
||||
.map(fee -> fee.getFeeAmount() != null ? fee.getFeeAmount() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal totalSalesAmount = orders.stream()
|
||||
.map(stat::receivedForSales)
|
||||
|
||||
// 计算各商品销售额(仅用于比例分配)
|
||||
Map<Long, BigDecimal> salesByProduct = ordersByProduct.entrySet().stream()
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
e -> e.getValue().stream()
|
||||
.map(stat::receivedForSales)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add)));
|
||||
BigDecimal totalSalesAmount = salesByProduct.values().stream()
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
for (Map.Entry<Long, List<OrderPO>> entry : ordersByProduct.entrySet()) {
|
||||
@@ -437,11 +456,11 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
.map(brush -> brush.getBrushAmount() != null ? brush.getBrushAmount() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
// 推广费按销售额比例分配
|
||||
BigDecimal productPromotionFee = BigDecimal.ZERO;
|
||||
if (totalSalesAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 推广费:有商品级直接归属的用直接归属,其余用比例分配
|
||||
BigDecimal productPromotionFee = directPromotionByProduct.getOrDefault(productId, BigDecimal.ZERO);
|
||||
if (productPromotionFee.compareTo(BigDecimal.ZERO) == 0 && ratioPool.compareTo(BigDecimal.ZERO) > 0 && totalSalesAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BigDecimal ratio = salesAmount.divide(totalSalesAmount, 4, RoundingMode.HALF_UP);
|
||||
productPromotionFee = totalPromotionFee.multiply(ratio);
|
||||
productPromotionFee = ratioPool.multiply(ratio);
|
||||
}
|
||||
|
||||
// 计算商品成本
|
||||
@@ -705,12 +724,29 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
ordersByCategory.computeIfAbsent(categoryId, k -> new ArrayList<>()).add(order);
|
||||
}
|
||||
|
||||
// 推广费总额(按销售额比例分配)
|
||||
BigDecimal totalPromotionFee = promotionFees.stream()
|
||||
// 推广费:按商品ID聚合直接归属 + 无商品归属的进入比例池
|
||||
Map<Long, BigDecimal> directPromotionByProduct = promotionFees.stream()
|
||||
.filter(fee -> fee.getProductId() != null)
|
||||
.collect(Collectors.groupingBy(
|
||||
PromotionFeePO::getProductId,
|
||||
Collectors.reducing(
|
||||
BigDecimal.ZERO,
|
||||
fee -> fee.getFeeAmount() != null ? fee.getFeeAmount() : BigDecimal.ZERO,
|
||||
BigDecimal::add)));
|
||||
BigDecimal ratioPool = promotionFees.stream()
|
||||
.filter(fee -> fee.getProductId() == null)
|
||||
.map(fee -> fee.getFeeAmount() != null ? fee.getFeeAmount() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal totalSalesAmount = orders.stream()
|
||||
.map(stat::receivedForSales)
|
||||
|
||||
// 品类总销售额(用于比例分配)
|
||||
Map<Long, BigDecimal> salesByCategory = new HashMap<>();
|
||||
for (Map.Entry<Long, List<OrderPO>> e : ordersByCategory.entrySet()) {
|
||||
BigDecimal catSales = e.getValue().stream()
|
||||
.map(stat::receivedForSales)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
salesByCategory.put(e.getKey(), catSales);
|
||||
}
|
||||
BigDecimal totalSalesAmount = salesByCategory.values().stream()
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal totalBrushFeeAll = brushOrders.stream()
|
||||
.map(b -> b.getBrushAmount() != null ? b.getBrushAmount() : BigDecimal.ZERO)
|
||||
@@ -732,11 +768,20 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
.map(stat::receivedForRefund)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
// 推广费按销售额比例
|
||||
BigDecimal catPromotionFee = BigDecimal.ZERO;
|
||||
if (totalSalesAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
catPromotionFee = totalPromotionFee.multiply(
|
||||
salesAmount.divide(totalSalesAmount, 4, RoundingMode.HALF_UP));
|
||||
// 推广费:先汇总品类内各商品的直接归属推广费,再按品类销售额比例分配比例池
|
||||
Set<Long> catProductIds = new HashSet<>();
|
||||
for (OrderPO order : catOrders) {
|
||||
Long pid = specToProduct.get(order.getProductSpecId());
|
||||
if (pid != null) catProductIds.add(pid);
|
||||
}
|
||||
BigDecimal directCatPromotion = catProductIds.stream()
|
||||
.map(pid -> directPromotionByProduct.getOrDefault(pid, BigDecimal.ZERO))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// 分配比例池
|
||||
BigDecimal catPromotionFee = directCatPromotion;
|
||||
if (ratioPool.compareTo(BigDecimal.ZERO) > 0 && totalSalesAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BigDecimal ratio = salesAmount.divide(totalSalesAmount, 4, RoundingMode.HALF_UP);
|
||||
catPromotionFee = catPromotionFee.add(ratioPool.multiply(ratio));
|
||||
}
|
||||
|
||||
BigDecimal catBrushFee = BigDecimal.ZERO;
|
||||
|
||||
+6
-38
@@ -1,7 +1,6 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.promotion.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -29,19 +28,18 @@ public class CreatePromotionFeeDTO {
|
||||
@NotNull(message = "推广费类型ID不能为空")
|
||||
private Long feeTypeId;
|
||||
|
||||
/**
|
||||
* 推广费名称
|
||||
*/
|
||||
@Schema(description = "推广费名称", example = "直通车推广", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "推广费名称不能为空")
|
||||
private String feeName;
|
||||
|
||||
/**
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 商品ID(可选,关联到具体商品)
|
||||
*/
|
||||
@Schema(description = "商品ID(可选)", example = "1")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 推广活动名称
|
||||
*/
|
||||
@@ -55,36 +53,6 @@ public class CreatePromotionFeeDTO {
|
||||
@NotNull(message = "推广费金额不能为空")
|
||||
private BigDecimal feeAmount;
|
||||
|
||||
/**
|
||||
* 基础金额(用于按比例计算)
|
||||
*/
|
||||
@Schema(description = "基础金额", example = "10000.00")
|
||||
private BigDecimal baseAmount;
|
||||
|
||||
/**
|
||||
* 费率(用于按比例计算)
|
||||
*/
|
||||
@Schema(description = "费率", example = "0.05")
|
||||
private BigDecimal feeRate;
|
||||
|
||||
/**
|
||||
* 点击次数
|
||||
*/
|
||||
@Schema(description = "点击次数", example = "1000")
|
||||
private Integer clickCount;
|
||||
|
||||
/**
|
||||
* 展示次数
|
||||
*/
|
||||
@Schema(description = "展示次数", example = "10000")
|
||||
private Integer impressionCount;
|
||||
|
||||
/**
|
||||
* 转化次数
|
||||
*/
|
||||
@Schema(description = "转化次数", example = "50")
|
||||
private Integer conversionCount;
|
||||
|
||||
/**
|
||||
* 推广费发生日期
|
||||
*/
|
||||
|
||||
+6
@@ -30,6 +30,12 @@ public class PromotionFeeFilterDTO {
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 商品ID(可选)
|
||||
*/
|
||||
@Schema(description = "商品ID(可选)", example = "1")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 推广费发生日期开始
|
||||
*/
|
||||
|
||||
+6
-38
@@ -1,7 +1,6 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ecom.promotion.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -36,19 +35,18 @@ public class UpdatePromotionFeeDTO {
|
||||
@NotNull(message = "推广费类型ID不能为空")
|
||||
private Long feeTypeId;
|
||||
|
||||
/**
|
||||
* 推广费名称
|
||||
*/
|
||||
@Schema(description = "推广费名称", example = "直通车推广", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "推广费名称不能为空")
|
||||
private String feeName;
|
||||
|
||||
/**
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 商品ID(可选,关联到具体商品)
|
||||
*/
|
||||
@Schema(description = "商品ID(可选)", example = "1")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 推广活动名称
|
||||
*/
|
||||
@@ -62,36 +60,6 @@ public class UpdatePromotionFeeDTO {
|
||||
@NotNull(message = "推广费金额不能为空")
|
||||
private BigDecimal feeAmount;
|
||||
|
||||
/**
|
||||
* 基础金额(用于按比例计算)
|
||||
*/
|
||||
@Schema(description = "基础金额", example = "10000.00")
|
||||
private BigDecimal baseAmount;
|
||||
|
||||
/**
|
||||
* 费率(用于按比例计算)
|
||||
*/
|
||||
@Schema(description = "费率", example = "0.05")
|
||||
private BigDecimal feeRate;
|
||||
|
||||
/**
|
||||
* 点击次数
|
||||
*/
|
||||
@Schema(description = "点击次数", example = "1000")
|
||||
private Integer clickCount;
|
||||
|
||||
/**
|
||||
* 展示次数
|
||||
*/
|
||||
@Schema(description = "展示次数", example = "10000")
|
||||
private Integer impressionCount;
|
||||
|
||||
/**
|
||||
* 转化次数
|
||||
*/
|
||||
@Schema(description = "转化次数", example = "50")
|
||||
private Integer conversionCount;
|
||||
|
||||
/**
|
||||
* 推广费发生日期
|
||||
*/
|
||||
|
||||
+3
-33
@@ -47,10 +47,10 @@ public class PromotionFeePO {
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 推广费名称
|
||||
* 商品ID(可选)
|
||||
*/
|
||||
@TableField("fee_name")
|
||||
private String feeName;
|
||||
@TableField("product_id")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 推广活动名称
|
||||
@@ -64,36 +64,6 @@ public class PromotionFeePO {
|
||||
@TableField("fee_amount")
|
||||
private BigDecimal feeAmount;
|
||||
|
||||
/**
|
||||
* 基础金额(用于按比例计算)
|
||||
*/
|
||||
@TableField("base_amount")
|
||||
private BigDecimal baseAmount;
|
||||
|
||||
/**
|
||||
* 费率(用于按比例计算)
|
||||
*/
|
||||
@TableField("fee_rate")
|
||||
private BigDecimal feeRate;
|
||||
|
||||
/**
|
||||
* 点击次数
|
||||
*/
|
||||
@TableField("click_count")
|
||||
private Integer clickCount;
|
||||
|
||||
/**
|
||||
* 展示次数
|
||||
*/
|
||||
@TableField("impression_count")
|
||||
private Integer impressionCount;
|
||||
|
||||
/**
|
||||
* 转化次数
|
||||
*/
|
||||
@TableField("conversion_count")
|
||||
private Integer conversionCount;
|
||||
|
||||
/**
|
||||
* 推广费发生日期
|
||||
*/
|
||||
|
||||
+3
-39
@@ -63,16 +63,10 @@ public class PromotionFeeVO {
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 推广费名称
|
||||
* 商品ID(可选)
|
||||
*/
|
||||
@Schema(description = "推广费名称", example = "直通车推广")
|
||||
private String feeName;
|
||||
|
||||
/**
|
||||
* 平台(淘宝、京东、拼多多等)
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝")
|
||||
private String platform;
|
||||
@Schema(description = "商品ID(可选)", example = "1")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 推广活动名称
|
||||
@@ -86,36 +80,6 @@ public class PromotionFeeVO {
|
||||
@Schema(description = "推广费金额", example = "1000.00")
|
||||
private BigDecimal feeAmount;
|
||||
|
||||
/**
|
||||
* 基础金额(用于按比例计算)
|
||||
*/
|
||||
@Schema(description = "基础金额", example = "10000.00")
|
||||
private BigDecimal baseAmount;
|
||||
|
||||
/**
|
||||
* 费率(用于按比例计算)
|
||||
*/
|
||||
@Schema(description = "费率", example = "0.05")
|
||||
private BigDecimal feeRate;
|
||||
|
||||
/**
|
||||
* 点击次数
|
||||
*/
|
||||
@Schema(description = "点击次数", example = "1000")
|
||||
private Integer clickCount;
|
||||
|
||||
/**
|
||||
* 展示次数
|
||||
*/
|
||||
@Schema(description = "展示次数", example = "10000")
|
||||
private Integer impressionCount;
|
||||
|
||||
/**
|
||||
* 转化次数
|
||||
*/
|
||||
@Schema(description = "转化次数", example = "50")
|
||||
private Integer conversionCount;
|
||||
|
||||
/**
|
||||
* 推广费发生日期
|
||||
*/
|
||||
|
||||
+3
@@ -130,6 +130,9 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
if (filter.getPlatformId() != null) {
|
||||
wrapper.eq(PromotionFeePO::getPlatformId, filter.getPlatformId());
|
||||
}
|
||||
if (filter.getProductId() != null) {
|
||||
wrapper.eq(PromotionFeePO::getProductId, filter.getProductId());
|
||||
}
|
||||
if (filter.getFeeDateStart() != null) {
|
||||
wrapper.ge(PromotionFeePO::getFeeDate, filter.getFeeDateStart());
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ export namespace PromotionFeeDTO {
|
||||
feeTypeId?: number;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 商品ID(可选) */
|
||||
productId?: number;
|
||||
/** 推广费发生日期开始 */
|
||||
feeDateStart?: string;
|
||||
/** 推广费发生日期结束 */
|
||||
@@ -23,24 +25,14 @@ export namespace PromotionFeeDTO {
|
||||
shopId: number;
|
||||
/** 推广费类型ID */
|
||||
feeTypeId: number;
|
||||
/** 推广费名称 */
|
||||
feeName: string;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 商品ID(可选,关联到具体商品) */
|
||||
productId?: number;
|
||||
/** 推广活动名称 */
|
||||
campaignName?: string;
|
||||
/** 推广费金额 */
|
||||
feeAmount: number;
|
||||
/** 基础金额(用于按比例计算) */
|
||||
baseAmount?: number;
|
||||
/** 费率(用于按比例计算) */
|
||||
feeRate?: number;
|
||||
/** 点击次数 */
|
||||
clickCount?: number;
|
||||
/** 展示次数 */
|
||||
impressionCount?: number;
|
||||
/** 转化次数 */
|
||||
conversionCount?: number;
|
||||
/** 推广费发生日期 */
|
||||
feeDate: string;
|
||||
/** 备注 */
|
||||
@@ -55,27 +47,17 @@ export namespace PromotionFeeDTO {
|
||||
shopId: number;
|
||||
/** 推广费类型ID */
|
||||
feeTypeId: number;
|
||||
/** 推广费名称 */
|
||||
feeName: string;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 商品ID(可选,关联到具体商品) */
|
||||
productId?: number;
|
||||
/** 推广活动名称 */
|
||||
campaignName?: string;
|
||||
/** 推广费金额 */
|
||||
feeAmount: number;
|
||||
/** 基础金额(用于按比例计算) */
|
||||
baseAmount?: number;
|
||||
/** 费率(用于按比例计算) */
|
||||
feeRate?: number;
|
||||
/** 点击次数 */
|
||||
clickCount?: number;
|
||||
/** 展示次数 */
|
||||
impressionCount?: number;
|
||||
/** 转化次数 */
|
||||
conversionCount?: number;
|
||||
/** 推广费发生日期 */
|
||||
feeDate: string;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,26 +17,16 @@ export namespace PromotionFeeVO {
|
||||
feeTypeId: number;
|
||||
/** 推广费类型名称 */
|
||||
feeTypeName?: string;
|
||||
/** 推广费名称 */
|
||||
feeName: string;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 平台名称 */
|
||||
platformName?: string;
|
||||
/** 商品ID(可选) */
|
||||
productId?: number;
|
||||
/** 推广活动名称 */
|
||||
campaignName?: string;
|
||||
/** 推广费金额 */
|
||||
feeAmount: number;
|
||||
/** 基础金额(用于按比例计算) */
|
||||
baseAmount?: number;
|
||||
/** 费率(用于按比例计算) */
|
||||
feeRate?: number;
|
||||
/** 点击次数 */
|
||||
clickCount?: number;
|
||||
/** 展示次数 */
|
||||
impressionCount?: number;
|
||||
/** 转化次数 */
|
||||
conversionCount?: number;
|
||||
/** 推广费发生日期 */
|
||||
feeDate: string;
|
||||
/** 备注 */
|
||||
@@ -50,4 +40,4 @@ export namespace PromotionFeeVO {
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+49
-75
@@ -4,6 +4,7 @@ import type {
|
||||
PromotionFeeDTO,
|
||||
PromotionFeeVO,
|
||||
} from '#/api/ecommerce/promotion-fee/types';
|
||||
import type { ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import { nextTick, onMounted, ref, watch } from 'vue';
|
||||
@@ -27,6 +28,7 @@ import {
|
||||
} from '#/api/ecommerce/promotion-fee';
|
||||
import { getActivePromotionFeeTypeListApi } from '#/api/ecommerce/promotion-fee-type';
|
||||
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'PromotionFeeFormModal' });
|
||||
@@ -72,15 +74,10 @@ const isEdit = ref(false);
|
||||
const formData = ref<PromotionFeeDTO.Create>({
|
||||
shopId: undefined as any,
|
||||
feeTypeId: undefined as any,
|
||||
feeName: '',
|
||||
platformId: undefined,
|
||||
productId: undefined,
|
||||
campaignName: '',
|
||||
feeAmount: undefined as any,
|
||||
baseAmount: undefined,
|
||||
feeRate: undefined,
|
||||
clickCount: undefined,
|
||||
impressionCount: undefined,
|
||||
conversionCount: undefined,
|
||||
feeDate: undefined as any,
|
||||
remark: '',
|
||||
});
|
||||
@@ -90,7 +87,6 @@ const rules = {
|
||||
feeTypeId: [
|
||||
{ required: true, message: '请选择推广费类型', trigger: 'change' },
|
||||
],
|
||||
feeName: [{ required: true, message: '请输入推广费名称', trigger: 'blur' }],
|
||||
feeAmount: [{ required: true, message: '请输入推广费金额', trigger: 'blur' }],
|
||||
feeDate: [{ required: true, message: '请选择发生日期', trigger: 'change' }],
|
||||
} as any;
|
||||
@@ -107,6 +103,10 @@ const shopListLoading = ref(false);
|
||||
const feeTypeList = ref<PromotionFeeTypeVO.Info[]>([]);
|
||||
const feeTypeListLoading = ref(false);
|
||||
|
||||
// 商品列表
|
||||
const productList = ref<ProductVO.Info[]>([]);
|
||||
const productListLoading = ref(false);
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
async (newVal) => {
|
||||
@@ -119,15 +119,10 @@ watch(
|
||||
formData.value = {
|
||||
shopId: props.promotionFeeData.shopId,
|
||||
feeTypeId: props.promotionFeeData.feeTypeId,
|
||||
feeName: props.promotionFeeData.feeName,
|
||||
platformId: props.promotionFeeData.platformId,
|
||||
productId: props.promotionFeeData.productId,
|
||||
campaignName: props.promotionFeeData.campaignName || '',
|
||||
feeAmount: props.promotionFeeData.feeAmount,
|
||||
baseAmount: props.promotionFeeData.baseAmount,
|
||||
feeRate: props.promotionFeeData.feeRate,
|
||||
clickCount: props.promotionFeeData.clickCount,
|
||||
impressionCount: props.promotionFeeData.impressionCount,
|
||||
conversionCount: props.promotionFeeData.conversionCount,
|
||||
feeDate: props.promotionFeeData.feeDate
|
||||
? dayjs(props.promotionFeeData.feeDate)
|
||||
: undefined,
|
||||
@@ -186,19 +181,30 @@ const loadPlatformList = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const loadProductList = async () => {
|
||||
productListLoading.value = true;
|
||||
try {
|
||||
const response = await getProductPageApi({
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
filters: {},
|
||||
});
|
||||
productList.value = response.records;
|
||||
} catch (error) {
|
||||
console.error('加载商品列表失败:', error);
|
||||
} finally {
|
||||
productListLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const resetFormData = () => {
|
||||
formData.value = {
|
||||
shopId: undefined as any,
|
||||
feeTypeId: undefined as any,
|
||||
feeName: '',
|
||||
platformId: undefined,
|
||||
productId: undefined,
|
||||
campaignName: '',
|
||||
feeAmount: undefined as any,
|
||||
baseAmount: undefined,
|
||||
feeRate: undefined,
|
||||
clickCount: undefined,
|
||||
impressionCount: undefined,
|
||||
conversionCount: undefined,
|
||||
feeDate: undefined as any,
|
||||
remark: '',
|
||||
};
|
||||
@@ -237,6 +243,7 @@ onMounted(() => {
|
||||
loadShopList();
|
||||
loadFeeTypeList();
|
||||
loadPlatformList();
|
||||
loadProductList();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -281,13 +288,6 @@ onMounted(() => {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="推广费名称" name="feeName">
|
||||
<Input
|
||||
v-model:value="formData.feeName"
|
||||
placeholder="请输入推广费名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="平台" name="platformId">
|
||||
<Select
|
||||
v-model:value="formData.platformId"
|
||||
@@ -305,6 +305,28 @@ onMounted(() => {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="商品(可选)" name="productId">
|
||||
<Select
|
||||
v-model:value="formData.productId"
|
||||
placeholder="请选择商品(可选,不选则为店铺级推广费)"
|
||||
:loading="productListLoading"
|
||||
allow-clear
|
||||
show-search
|
||||
:filter-option="(input: string, option: any) =>
|
||||
option?.children?.props?.children?.props?.children?.props?.children?.props?.children?.props?.children
|
||||
?.toLowerCase?.().includes?.(input.toLowerCase()) ?? false
|
||||
"
|
||||
>
|
||||
<Select.Option
|
||||
v-for="product in productList"
|
||||
:key="product.id"
|
||||
:value="product.id"
|
||||
>
|
||||
{{ product.name }}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="推广活动名称" name="campaignName">
|
||||
<Input
|
||||
v-model:value="formData.campaignName"
|
||||
@@ -322,54 +344,6 @@ onMounted(() => {
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="基础金额" name="baseAmount">
|
||||
<InputNumber
|
||||
v-model:value="formData.baseAmount"
|
||||
placeholder="请输入基础金额(用于按比例计算)"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="费率" name="feeRate">
|
||||
<InputNumber
|
||||
v-model:value="formData.feeRate"
|
||||
placeholder="请输入费率(用于按比例计算)"
|
||||
:min="0"
|
||||
:max="1"
|
||||
:precision="4"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="点击次数" name="clickCount">
|
||||
<InputNumber
|
||||
v-model:value="formData.clickCount"
|
||||
placeholder="请输入点击次数"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="展示次数" name="impressionCount">
|
||||
<InputNumber
|
||||
v-model:value="formData.impressionCount"
|
||||
placeholder="请输入展示次数"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="转化次数" name="conversionCount">
|
||||
<InputNumber
|
||||
v-model:value="formData.conversionCount"
|
||||
placeholder="请输入转化次数"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="发生日期" name="feeDate">
|
||||
<DatePicker
|
||||
v-model:value="formData.feeDate"
|
||||
@@ -387,4 +361,4 @@ onMounted(() => {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -113,8 +113,8 @@ const gridOptions: VxeGridProps<any> = {
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
field: 'feeName',
|
||||
title: '推广费名称',
|
||||
field: 'productId',
|
||||
title: '商品ID',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ const editingData = ref<PromotionFeeVO.Info | undefined>();
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', title: '序号', width: 60 },
|
||||
{ field: 'feeName', title: '费用名称', width: 110 },
|
||||
{ field: 'productId', title: '商品ID', width: 90 },
|
||||
{ field: 'platformName', title: '平台', width: 90 },
|
||||
{ field: 'campaignName', title: '活动名称', minWidth: 140 },
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user