From 0056f2bb11b18a6516a2124fb70c442cb880d1ec Mon Sep 17 00:00:00 2001 From: ah--desktop Date: Thu, 15 Jan 2026 00:02:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E6=A6=82=E8=A7=88=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD=E5=8F=8A?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E7=8A=B6=E6=80=81=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ecom/controller/ShopController.java | 15 +- .../dto/orderstatus/CreateOrderStatusDTO.java | 6 + .../dto/orderstatus/UpdateOrderStatusDTO.java | 6 + .../dto/overview/ShopOverviewQueryDTO.java | 34 + .../modules/ecom/model/po/OrderStatusPO.java | 6 + .../modules/ecom/model/vo/OrderStatusVO.java | 6 + .../model/vo/ShopOverviewStatisticsVO.java | 205 +++++ .../ShopOverviewStatisticsService.java | 19 + .../impl/CompanyOverviewServiceImpl.java | 4 +- .../service/impl/OrderStatusServiceImpl.java | 3 + .../ShopOverviewStatisticsServiceImpl.java | 527 ++++++++++++ .../ecom/service/impl/ShopServiceImpl.java | 5 +- .../xyquan/ecomdmbbackend/sql/ec_design.sql | 2 + .../ecommerce/order-status/types/types.dto.ts | 4 + .../ecommerce/order-status/types/types.vo.ts | 2 + .../web-antd/src/api/ecommerce/shop/apis.ts | 14 +- .../src/api/ecommerce/shop/types/types.dto.ts | 8 + .../src/api/ecommerce/shop/types/types.vo.ts | 86 ++ .../components/OrderStatusFormModal.vue | 15 + .../views/ecommerce/shop/overview/index.vue | 807 ++++++++++++++++++ .../web-antd/test/ai_studio_code (16).html | 284 ++++++ 21 files changed, 2052 insertions(+), 6 deletions(-) create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/overview/ShopOverviewQueryDTO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/vo/ShopOverviewStatisticsVO.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/ShopOverviewStatisticsService.java create mode 100644 ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/ShopOverviewStatisticsServiceImpl.java create mode 100644 ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue create mode 100644 ecom-dmb-frontend/apps/web-antd/test/ai_studio_code (16).html diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/controller/ShopController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/controller/ShopController.java index 520e9e67..65ac4905 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/controller/ShopController.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/controller/ShopController.java @@ -16,10 +16,13 @@ import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopFilterDTO; import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopProductPageFilterDTO; import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.ShopStatisticsQueryDTO; import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.shop.UpdateShopDTO; +import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.overview.ShopOverviewQueryDTO; import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ProductVO; import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopOverviewVO; +import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopOverviewStatisticsVO; import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopVO; import top.xyquan.ecomdmbbackend.modules.ecom.service.ShopService; +import top.xyquan.ecomdmbbackend.modules.ecom.service.ShopOverviewStatisticsService; import top.xyquan.ecomdmbbackend.modules.media.model.vo.MediaImageVO; import top.xyquan.ecomdmbbackend.utils.FileUploadUtils; @@ -32,9 +35,11 @@ import top.xyquan.ecomdmbbackend.utils.FileUploadUtils; public class ShopController { private final ShopService shopService; + private final ShopOverviewStatisticsService shopOverviewStatisticsService; - public ShopController(ShopService shopService) { + public ShopController(ShopService shopService, ShopOverviewStatisticsService shopOverviewStatisticsService) { this.shopService = shopService; + this.shopOverviewStatisticsService = shopOverviewStatisticsService; } @Operation(summary = "创建店铺", description = "创建新的店铺") @@ -102,4 +107,12 @@ public class ShopController { PageResultVO result = shopService.getShopProductPage(pageQueryDTO); return ApiResponse.success(result); } + + @Operation(summary = "获取店铺概览统计数据", description = "获取指定店铺的概览统计数据,包括销售额、单量、推广费、利润、ROI等,以及多商品数据横向对比") + @PostMapping("/overview-statistics") + @RequireRole(description = "查询店铺概览统计", allowUser = true) + public ApiResponse getShopOverviewStatistics(@Valid @RequestBody ShopOverviewQueryDTO queryDTO) { + ShopOverviewStatisticsVO overviewVO = shopOverviewStatisticsService.getShopOverviewStatistics(queryDTO); + return ApiResponse.success(overviewVO); + } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/orderstatus/CreateOrderStatusDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/orderstatus/CreateOrderStatusDTO.java index c5a70e3f..a6f83dcd 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/orderstatus/CreateOrderStatusDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/orderstatus/CreateOrderStatusDTO.java @@ -37,5 +37,11 @@ public class CreateOrderStatusDTO { @Schema(description = "是否自动参与统计", example = "1", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "是否自动参与统计不能为空") private Integer autoStatistics; + + /** + * 是否为退款状态 0否 1是 + */ + @Schema(description = "是否为退款状态", example = "0") + private Integer isRefund; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/orderstatus/UpdateOrderStatusDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/orderstatus/UpdateOrderStatusDTO.java index 8d62fd0c..df9a8eb1 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/orderstatus/UpdateOrderStatusDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/orderstatus/UpdateOrderStatusDTO.java @@ -37,5 +37,11 @@ public class UpdateOrderStatusDTO { @Schema(description = "是否自动参与统计", example = "1", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "是否自动参与统计不能为空") private Integer autoStatistics; + + /** + * 是否为退款状态 0否 1是 + */ + @Schema(description = "是否为退款状态", example = "0") + private Integer isRefund; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/overview/ShopOverviewQueryDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/overview/ShopOverviewQueryDTO.java new file mode 100644 index 00000000..c44476cd --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/dto/overview/ShopOverviewQueryDTO.java @@ -0,0 +1,34 @@ +package top.xyquan.ecomdmbbackend.modules.ecom.model.dto.overview; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.Data; + +import java.time.LocalDate; +import java.util.List; + +/** + * 单店铺概览查询DTO + */ +@Data +@Schema(description = "单店铺概览查询DTO") +public class ShopOverviewQueryDTO { + + /** + * 店铺ID + */ + @Schema(description = "店铺ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "店铺ID不能为空") + private Long shopId; + + /** + * 日期范围数组(第一个是开始日期,第二个是结束日期,只有一个日期则返回当天数据) + */ + @Schema(description = "日期范围数组", example = "[\"2024-01-01\", \"2024-01-31\"]", requiredMode = Schema.RequiredMode.REQUIRED) + @NotEmpty(message = "日期范围不能为空") + @Size(min = 1, max = 2, message = "日期范围数组必须包含1-2个日期") + private List dateRange; +} + diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/po/OrderStatusPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/po/OrderStatusPO.java index ffd1e98f..d1c9b443 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/po/OrderStatusPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/po/OrderStatusPO.java @@ -50,6 +50,12 @@ public class OrderStatusPO { @TableField("auto_statistics") private Integer autoStatistics; + /** + * 是否为退款状态 0否 1是 + */ + @TableField("is_refund") + private Integer isRefund; + /** * 创建时间 */ diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/vo/OrderStatusVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/vo/OrderStatusVO.java index ada20d9a..be5eb903 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/vo/OrderStatusVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/vo/OrderStatusVO.java @@ -48,6 +48,12 @@ public class OrderStatusVO { @Schema(description = "是否自动参与统计", example = "1") private Integer autoStatistics; + /** + * 是否为退款状态 0否 1是 + */ + @Schema(description = "是否为退款状态", example = "0") + private Integer isRefund; + /** * 创建时间 */ diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/vo/ShopOverviewStatisticsVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/vo/ShopOverviewStatisticsVO.java new file mode 100644 index 00000000..7b7a3ba3 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/model/vo/ShopOverviewStatisticsVO.java @@ -0,0 +1,205 @@ +package top.xyquan.ecomdmbbackend.modules.ecom.model.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.List; + +/** + * 单店铺概览统计VO + */ +@Data +@Schema(description = "单店铺概览统计VO") +public class ShopOverviewStatisticsVO { + + /** + * 店铺总销售额 + */ + @Schema(description = "店铺总销售额", example = "100000.00") + private BigDecimal totalSalesAmount; + + /** + * 较上月同期增长百分比 + */ + @Schema(description = "较上月同期增长百分比", example = "15.50") + private BigDecimal monthOverMonthGrowth; + + /** + * 店铺总单量 + */ + @Schema(description = "店铺总单量", example = "1000") + private Integer totalOrderCount; + + /** + * 总推广费支出 + */ + @Schema(description = "总推广费支出", example = "5000.00") + private BigDecimal totalPromotionFee; + + /** + * 平均费比(推广费/销售额) + */ + @Schema(description = "平均费比", example = "0.05") + private BigDecimal averageFeeRatio; + + /** + * 店铺总净利(税后) + */ + @Schema(description = "店铺总净利(税后)", example = "80000.00") + private BigDecimal totalNetProfitAfterTax; + + /** + * 扣除总税额 + */ + @Schema(description = "扣除总税额", example = "6000.00") + private BigDecimal totalTaxAmount; + + /** + * 店铺总销量目标(目标订单数) + */ + @Schema(description = "店铺总销量目标(目标订单数)", example = "1200") + private Integer totalTargetOrderCount; + + /** + * 店铺总销售额目标 + */ + @Schema(description = "店铺总销售额目标", example = "120000.00") + private BigDecimal totalTargetAmount; + + /** + * 销量目标达成率 + */ + @Schema(description = "销量目标达成率", example = "83.33") + private BigDecimal orderCountAchievementRate; + + /** + * 销售额目标达成率 + */ + @Schema(description = "销售额目标达成率", example = "83.33") + private BigDecimal salesAmountAchievementRate; + + /** + * 汇总ROI + */ + @Schema(description = "汇总ROI", example = "1.5") + private BigDecimal totalROI; + + /** + * 总税后盈亏 + */ + @Schema(description = "总税后盈亏", example = "80000.00") + private BigDecimal totalProfitAfterTax; + + /** + * 销售额趋势分析 + */ + @Schema(description = "销售额趋势分析") + private TrendData salesAmountTrend; + + /** + * 单量趋势分析 + */ + @Schema(description = "单量趋势分析") + private TrendData orderCountTrend; + + /** + * 多商品数据横向对比 + */ + @Schema(description = "多商品数据横向对比") + private List productComparisons; + + /** + * 商品对比数据 + */ + @Data + @Schema(description = "商品对比数据") + public static class ProductComparison { + @Schema(description = "商品ID", example = "1") + private Long productId; + + @Schema(description = "商品名称", example = "iPhone 15 Pro") + private String productName; + + @Schema(description = "商品编码", example = "IPHONE15PRO") + private String productCode; + + @Schema(description = "销售额", example = "50000.00") + private BigDecimal salesAmount; + + @Schema(description = "单量", example = "500") + private Integer orderCount; + + @Schema(description = "客单价", example = "100.00") + private BigDecimal averageOrderValue; + + @Schema(description = "成本运费", example = "5000.00") + private BigDecimal shippingCost; + + @Schema(description = "退款金额", example = "1000.00") + private BigDecimal refundAmount; + + @Schema(description = "推广费", example = "5000.00") + private BigDecimal totalPromotionFee; + + @Schema(description = "刷单费用", example = "2000.00") + private BigDecimal brushFee; + + @Schema(description = "费比", example = "0.10") + private BigDecimal feeRatio; + + @Schema(description = "税前盈亏", example = "35000.00") + private BigDecimal totalProfitBeforeTax; + + @Schema(description = "销售额4%税额", example = "2000.00") + private BigDecimal salesTaxAmount; + + @Schema(description = "税后盈亏", example = "30000.00") + private BigDecimal profitAfterTax; + + @Schema(description = "ROI", example = "1.5") + private BigDecimal roi; + } + + /** + * 趋势数据 + */ + @Data + @Schema(description = "趋势数据") + public static class TrendData { + /** + * 时间范围的总值 + */ + @Schema(description = "时间范围的总值") + private BigDecimal total; + + /** + * 每日数据列表 + */ + @Schema(description = "每日数据列表") + private List dailyDataList; + } + + /** + * 趋势数据项 + */ + @Data + @Schema(description = "趋势数据项") + public static class TrendDataItem { + /** + * 日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Schema(description = "日期", example = "2024-01-01") + private LocalDate date; + + /** + * 对应的值 + */ + @Schema(description = "对应的值") + private BigDecimal value; + } +} + diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/ShopOverviewStatisticsService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/ShopOverviewStatisticsService.java new file mode 100644 index 00000000..74556e68 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/ShopOverviewStatisticsService.java @@ -0,0 +1,19 @@ +package top.xyquan.ecomdmbbackend.modules.ecom.service; + +import top.xyquan.ecomdmbbackend.modules.ecom.model.dto.overview.ShopOverviewQueryDTO; +import top.xyquan.ecomdmbbackend.modules.ecom.model.vo.ShopOverviewStatisticsVO; + +/** + * 单店铺概览统计服务接口 + */ +public interface ShopOverviewStatisticsService { + + /** + * 获取单店铺概览统计数据 + * + * @param queryDTO 查询DTO + * @return 单店铺概览统计VO + */ + ShopOverviewStatisticsVO getShopOverviewStatistics(ShopOverviewQueryDTO queryDTO); +} + diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/CompanyOverviewServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/CompanyOverviewServiceImpl.java index 322d7fed..3ce281a0 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/CompanyOverviewServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/CompanyOverviewServiceImpl.java @@ -624,13 +624,13 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { } /** - * 获取退款状态ID + * 获取退款状态ID(通过 is_refund 字段查询) */ private Long getRefundStatusId() { Long companyId = currentUserContext.getCurrentCompanyId(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(OrderStatusPO::getCompanyId, companyId) - .eq(OrderStatusPO::getStatusName, "已退款") + .eq(OrderStatusPO::getIsRefund, 1) .last("LIMIT 1"); OrderStatusPO status = orderStatusService.getOne(wrapper); return status != null ? status.getId() : null; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/OrderStatusServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/OrderStatusServiceImpl.java index 4517a0e2..51deab26 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/OrderStatusServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/OrderStatusServiceImpl.java @@ -61,6 +61,9 @@ public class OrderStatusServiceImpl extends ServiceImpl orderWrapper = new LambdaQueryWrapper<>(); + orderWrapper.eq(OrderPO::getCompanyId, companyId) + .eq(OrderPO::getShopId, queryDTO.getShopId()) + .ge(OrderPO::getOrderTime, startDateTime) + .le(OrderPO::getOrderTime, endDateTime); + List orders = orderMapper.selectList(orderWrapper); + + // 查询推广费数据(该店铺) + LambdaQueryWrapper promotionWrapper = new LambdaQueryWrapper<>(); + promotionWrapper.eq(PromotionFeePO::getCompanyId, companyId) + .eq(PromotionFeePO::getShopId, queryDTO.getShopId()) + .ge(PromotionFeePO::getFeeDate, startDate) + .le(PromotionFeePO::getFeeDate, endDate); + List promotionFees = promotionFeeMapper.selectList(promotionWrapper); + + // 查询刷单费数据(该店铺) + LambdaQueryWrapper brushWrapper = new LambdaQueryWrapper<>(); + brushWrapper.eq(BrushOrderPO::getCompanyId, companyId) + .eq(BrushOrderPO::getShopId, queryDTO.getShopId()) + .ge(BrushOrderPO::getBrushTime, startDateTime) + .le(BrushOrderPO::getBrushTime, endDateTime); + List brushOrders = brushOrderMapper.selectList(brushWrapper); + + // 获取退款状态ID + Long refundStatusId = getRefundStatusId(); + + // 计算上月同期数据(用于增长百分比) + LocalDate lastMonthStartDate = startDate.minusMonths(1); + LocalDate lastMonthEndDate = endDate.minusMonths(1); + LocalDateTime lastMonthStartDateTime = lastMonthStartDate.atStartOfDay(); + LocalDateTime lastMonthEndDateTime = lastMonthEndDate.atTime(23, 59, 59); + + LambdaQueryWrapper lastMonthOrderWrapper = new LambdaQueryWrapper<>(); + lastMonthOrderWrapper.eq(OrderPO::getCompanyId, companyId) + .eq(OrderPO::getShopId, queryDTO.getShopId()) + .ge(OrderPO::getOrderTime, lastMonthStartDateTime) + .le(OrderPO::getOrderTime, lastMonthEndDateTime); + List lastMonthOrders = orderMapper.selectList(lastMonthOrderWrapper); + + // 构建返回对象 + ShopOverviewStatisticsVO overviewVO = new ShopOverviewStatisticsVO(); + + // 1. 计算店铺总销售额 + BigDecimal totalSalesAmount = orders.stream() + .map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + overviewVO.setTotalSalesAmount(totalSalesAmount); + + // 2. 计算较上月同期增长百分比 + BigDecimal lastMonthSalesAmount = lastMonthOrders.stream() + .map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal monthOverMonthGrowth = BigDecimal.ZERO; + if (lastMonthSalesAmount.compareTo(BigDecimal.ZERO) > 0) { + monthOverMonthGrowth = totalSalesAmount.subtract(lastMonthSalesAmount) + .divide(lastMonthSalesAmount, 4, RoundingMode.HALF_UP) + .multiply(new BigDecimal("100")); + } else if (totalSalesAmount.compareTo(BigDecimal.ZERO) > 0) { + monthOverMonthGrowth = new BigDecimal("100"); + } + overviewVO.setMonthOverMonthGrowth(monthOverMonthGrowth); + + // 3. 计算店铺总单量 + int totalOrderCount = orders.size(); + overviewVO.setTotalOrderCount(totalOrderCount); + + // 4. 计算总推广费支出 + BigDecimal totalPromotionFee = promotionFees.stream() + .map(fee -> fee.getFeeAmount() != null ? fee.getFeeAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + overviewVO.setTotalPromotionFee(totalPromotionFee); + + // 5. 计算平均费比 + BigDecimal averageFeeRatio = BigDecimal.ZERO; + if (totalSalesAmount.compareTo(BigDecimal.ZERO) > 0) { + averageFeeRatio = totalPromotionFee.divide(totalSalesAmount, 4, RoundingMode.HALF_UP); + } + overviewVO.setAverageFeeRatio(averageFeeRatio); + + // 6. 计算店铺总净利(税后)和总税额 + BigDecimal totalProfitBeforeTax = calculateTotalProfit(orders); + BigDecimal totalSalesTaxAmount = totalSalesAmount.multiply(SALES_TAX_RATE); + BigDecimal totalNetProfitAfterTax = totalProfitBeforeTax.subtract(totalSalesTaxAmount); + overviewVO.setTotalNetProfitAfterTax(totalNetProfitAfterTax); + overviewVO.setTotalTaxAmount(totalSalesTaxAmount); + + // 7. 计算目标维度的数据 + calculateTargetData(overviewVO, companyId, queryDTO.getShopId(), startDate, endDate, totalSalesAmount, totalOrderCount); + + // 8. 汇总ROI和总税后盈亏 + BigDecimal totalROI = calculateTotalROI(orders, promotionFees, brushOrders); + overviewVO.setTotalROI(totalROI); + overviewVO.setTotalProfitAfterTax(totalNetProfitAfterTax); + + // 9. 计算趋势分析数据 + ShopOverviewStatisticsVO.TrendData salesAmountTrend = calculateSalesAmountTrend(orders, startDate, endDate); + ShopOverviewStatisticsVO.TrendData orderCountTrend = calculateOrderCountTrend(orders, startDate, endDate); + overviewVO.setSalesAmountTrend(salesAmountTrend); + overviewVO.setOrderCountTrend(orderCountTrend); + + // 10. 多商品数据横向对比 + List productComparisons = calculateProductComparisons( + orders, promotionFees, brushOrders, refundStatusId); + overviewVO.setProductComparisons(productComparisons); + + return overviewVO; + } + + /** + * 计算总利润(税前) + */ + private BigDecimal calculateTotalProfit(List orders) { + return orders.stream() + .map(order -> { + BigDecimal receivedAmount = order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO; + BigDecimal productCost = order.getProductCost() != null ? order.getProductCost() : BigDecimal.ZERO; + BigDecimal shippingCost = order.getShippingCost() != null ? order.getShippingCost() : BigDecimal.ZERO; + BigDecimal otherCost = order.getOtherCost() != null ? order.getOtherCost() : BigDecimal.ZERO; + Integer quantity = order.getQuantity() != null ? order.getQuantity() : 1; + BigDecimal totalCost = productCost.add(shippingCost).add(otherCost).multiply(new BigDecimal(quantity)); + return receivedAmount.subtract(totalCost); + }) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } + + /** + * 计算目标维度的数据 + */ + private void calculateTargetData(ShopOverviewStatisticsVO overviewVO, Long companyId, Long shopId, + LocalDate startDate, LocalDate endDate, + BigDecimal totalSalesAmount, Integer totalOrderCount) { + // 生成日期范围内所有月份的第一天列表 + List targetMonths = new ArrayList<>(); + LocalDate currentMonth = startDate.withDayOfMonth(1); + LocalDate endMonth = endDate.withDayOfMonth(1); + while (!currentMonth.isAfter(endMonth)) { + targetMonths.add(currentMonth); + currentMonth = currentMonth.plusMonths(1); + } + + // 查询该店铺在这些月份的目标数据 + LambdaQueryWrapper targetWrapper = new LambdaQueryWrapper<>(); + targetWrapper.eq(ShopMonthlyTargetPO::getCompanyId, companyId) + .eq(ShopMonthlyTargetPO::getShopId, shopId) + .in(ShopMonthlyTargetPO::getTargetMonth, targetMonths); + List targets = shopMonthlyTargetMapper.selectList(targetWrapper); + + // 汇总目标数据 + BigDecimal totalTargetAmount = targets.stream() + .map(target -> target.getTargetAmount() != null ? target.getTargetAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + Integer totalTargetOrderCount = targets.stream() + .mapToInt(target -> target.getTargetOrderCount() != null ? target.getTargetOrderCount() : 0) + .sum(); + + overviewVO.setTotalTargetAmount(totalTargetAmount); + overviewVO.setTotalTargetOrderCount(totalTargetOrderCount); + + // 计算达成率 + BigDecimal salesAmountAchievementRate = BigDecimal.ZERO; + if (totalTargetAmount.compareTo(BigDecimal.ZERO) > 0) { + salesAmountAchievementRate = totalSalesAmount.divide(totalTargetAmount, 4, RoundingMode.HALF_UP) + .multiply(new BigDecimal("100")); + } else if (totalSalesAmount.compareTo(BigDecimal.ZERO) > 0) { + salesAmountAchievementRate = new BigDecimal("100"); + } + overviewVO.setSalesAmountAchievementRate(salesAmountAchievementRate); + + BigDecimal orderCountAchievementRate = BigDecimal.ZERO; + if (totalTargetOrderCount > 0) { + orderCountAchievementRate = new BigDecimal(totalOrderCount) + .divide(new BigDecimal(totalTargetOrderCount), 4, RoundingMode.HALF_UP) + .multiply(new BigDecimal("100")); + } else if (totalOrderCount > 0) { + orderCountAchievementRate = new BigDecimal("100"); + } + overviewVO.setOrderCountAchievementRate(orderCountAchievementRate); + } + + /** + * 计算汇总ROI + */ + private BigDecimal calculateTotalROI(List orders, List promotionFees, + List brushOrders) { + BigDecimal totalProfit = calculateTotalProfit(orders); + BigDecimal totalPromotionFee = promotionFees.stream() + .map(fee -> fee.getFeeAmount() != null ? fee.getFeeAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal totalBrushFee = brushOrders.stream() + .map(brush -> brush.getBrushAmount() != null ? brush.getBrushAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal totalCost = totalPromotionFee.add(totalBrushFee); + return calculateROI(totalProfit, totalCost); + } + + /** + * 计算ROI + */ + private BigDecimal calculateROI(BigDecimal profit, BigDecimal totalCost) { + if (totalCost.compareTo(BigDecimal.ZERO) <= 0) { + return BigDecimal.ZERO; + } + return profit.divide(totalCost, 4, RoundingMode.HALF_UP); + } + + /** + * 计算多商品数据横向对比 + */ + private List calculateProductComparisons( + List orders, List promotionFees, + List brushOrders, Long refundStatusId) { + List comparisons = new ArrayList<>(); + + // 按商品分组订单数据 + Map> ordersByProduct = orders.stream() + .collect(Collectors.groupingBy(OrderPO::getProductId)); + + // 按商品分组刷单费数据(如果有商品ID) + Map> brushOrdersByProduct = brushOrders.stream() + .filter(brush -> brush.getProductId() != null) + .collect(Collectors.groupingBy(BrushOrderPO::getProductId)); + + // 推广费无法按商品分组(推广费只有店铺级别),所以每个商品使用相同的推广费比例 + BigDecimal totalPromotionFee = promotionFees.stream() + .map(fee -> fee.getFeeAmount() != null ? fee.getFeeAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal totalSalesAmount = orders.stream() + .map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + for (Map.Entry> entry : ordersByProduct.entrySet()) { + Long productId = entry.getKey(); + List productOrders = entry.getValue(); + + // 获取商品信息 + ProductPO product = productService.getById(productId); + if (product == null) { + continue; + } + + // 计算各项指标 + BigDecimal salesAmount = productOrders.stream() + .map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + int orderCount = productOrders.size(); + + BigDecimal refundAmount = productOrders.stream() + .filter(order -> refundStatusId != null && refundStatusId.equals(order.getStatusId())) + .map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal brushFee = brushOrdersByProduct.getOrDefault(productId, new ArrayList<>()).stream() + .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 ratio = salesAmount.divide(totalSalesAmount, 4, RoundingMode.HALF_UP); + productPromotionFee = totalPromotionFee.multiply(ratio); + } + + // 计算成本运费(单独计算运费成本) + BigDecimal shippingCost = productOrders.stream() + .map(order -> { + BigDecimal cost = order.getShippingCost() != null ? order.getShippingCost() : BigDecimal.ZERO; + Integer quantity = order.getQuantity() != null ? order.getQuantity() : 1; + return cost.multiply(new BigDecimal(quantity)); + }) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal totalCost = calculateProductTotalCost(productOrders); + BigDecimal profitBeforeTax = salesAmount.subtract(totalCost).subtract(refundAmount); + + // 销售额4%税额 + BigDecimal salesTaxAmount = salesAmount.multiply(SALES_TAX_RATE); + + // 税后盈亏(扣除销售额4%税额) + BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTaxAmount); + + BigDecimal totalCostForROI = productPromotionFee.add(brushFee); + BigDecimal roi = calculateROI(profitBeforeTax, totalCostForROI); + + BigDecimal feeRatio = BigDecimal.ZERO; + if (salesAmount.compareTo(BigDecimal.ZERO) > 0) { + feeRatio = productPromotionFee.divide(salesAmount, 4, RoundingMode.HALF_UP); + } + + BigDecimal averageOrderValue = BigDecimal.ZERO; + if (orderCount > 0) { + averageOrderValue = salesAmount.divide(new BigDecimal(orderCount), 2, RoundingMode.HALF_UP); + } + + ShopOverviewStatisticsVO.ProductComparison comparison = new ShopOverviewStatisticsVO.ProductComparison(); + comparison.setProductId(productId); + comparison.setProductName(product.getName()); + comparison.setProductCode(product.getProductCode()); + comparison.setSalesAmount(salesAmount); + comparison.setOrderCount(orderCount); + comparison.setAverageOrderValue(averageOrderValue); + comparison.setShippingCost(shippingCost); + comparison.setRefundAmount(refundAmount); + comparison.setTotalPromotionFee(productPromotionFee); + comparison.setBrushFee(brushFee); + comparison.setFeeRatio(feeRatio); + comparison.setTotalProfitBeforeTax(profitBeforeTax); + comparison.setSalesTaxAmount(salesTaxAmount); + comparison.setProfitAfterTax(profitAfterTax); + comparison.setRoi(roi); + comparisons.add(comparison); + } + + // 按销售额降序排序 + comparisons.sort(Comparator.comparing(ShopOverviewStatisticsVO.ProductComparison::getSalesAmount).reversed()); + return comparisons; + } + + /** + * 计算商品总成本(订单成本) + */ + private BigDecimal calculateProductTotalCost(List orders) { + return orders.stream() + .map(order -> { + BigDecimal productCost = order.getProductCost() != null ? order.getProductCost() : BigDecimal.ZERO; + BigDecimal shippingCost = order.getShippingCost() != null ? order.getShippingCost() : BigDecimal.ZERO; + BigDecimal otherCost = order.getOtherCost() != null ? order.getOtherCost() : BigDecimal.ZERO; + Integer quantity = order.getQuantity() != null ? order.getQuantity() : 1; + return productCost.add(shippingCost).add(otherCost).multiply(new BigDecimal(quantity)); + }) + .reduce(BigDecimal.ZERO, BigDecimal::add); + } + + /** + * 计算销售额趋势分析 + */ + private ShopOverviewStatisticsVO.TrendData calculateSalesAmountTrend(List orders, LocalDate startDate, LocalDate endDate) { + ShopOverviewStatisticsVO.TrendData trendData = new ShopOverviewStatisticsVO.TrendData(); + + // 按日期分组订单数据 + Map> ordersByDate = orders.stream() + .collect(Collectors.groupingBy(order -> order.getOrderTime().toLocalDate())); + + // 计算总销售额 + BigDecimal total = orders.stream() + .map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + trendData.setTotal(total); + + // 生成日期范围内的所有日期列表 + List dateList = new ArrayList<>(); + LocalDate currentDate = startDate; + while (!currentDate.isAfter(endDate)) { + dateList.add(currentDate); + currentDate = currentDate.plusDays(1); + } + + // 计算每日销售额 + List dailyDataList = dateList.stream() + .map(date -> { + ShopOverviewStatisticsVO.TrendDataItem item = new ShopOverviewStatisticsVO.TrendDataItem(); + item.setDate(date); + List dayOrders = ordersByDate.getOrDefault(date, new ArrayList<>()); + BigDecimal dayAmount = dayOrders.stream() + .map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + item.setValue(dayAmount); + return item; + }) + .sorted(Comparator.comparing(ShopOverviewStatisticsVO.TrendDataItem::getDate)) + .collect(Collectors.toList()); + trendData.setDailyDataList(dailyDataList); + + return trendData; + } + + /** + * 计算单量趋势分析 + */ + private ShopOverviewStatisticsVO.TrendData calculateOrderCountTrend(List orders, LocalDate startDate, LocalDate endDate) { + ShopOverviewStatisticsVO.TrendData trendData = new ShopOverviewStatisticsVO.TrendData(); + + // 按日期分组订单数据 + Map> ordersByDate = orders.stream() + .collect(Collectors.groupingBy(order -> order.getOrderTime().toLocalDate())); + + // 计算总单量 + int totalCount = orders.size(); + trendData.setTotal(new BigDecimal(totalCount)); + + // 生成日期范围内的所有日期列表 + List dateList = new ArrayList<>(); + LocalDate currentDate = startDate; + while (!currentDate.isAfter(endDate)) { + dateList.add(currentDate); + currentDate = currentDate.plusDays(1); + } + + // 计算每日单量 + List dailyDataList = dateList.stream() + .map(date -> { + ShopOverviewStatisticsVO.TrendDataItem item = new ShopOverviewStatisticsVO.TrendDataItem(); + item.setDate(date); + List dayOrders = ordersByDate.getOrDefault(date, new ArrayList<>()); + int dayCount = dayOrders.size(); + item.setValue(new BigDecimal(dayCount)); + return item; + }) + .sorted(Comparator.comparing(ShopOverviewStatisticsVO.TrendDataItem::getDate)) + .collect(Collectors.toList()); + trendData.setDailyDataList(dailyDataList); + + return trendData; + } + + /** + * 获取退款状态ID(通过 is_refund 字段查询) + */ + private Long getRefundStatusId() { + Long companyId = currentUserContext.getCurrentCompanyId(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(OrderStatusPO::getCompanyId, companyId) + .eq(OrderStatusPO::getIsRefund, 1) + .last("LIMIT 1"); + OrderStatusPO status = orderStatusService.getOne(wrapper); + return status != null ? status.getId() : null; + } +} + diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/ShopServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/ShopServiceImpl.java index 146df53d..99c4ff06 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/ShopServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/service/impl/ShopServiceImpl.java @@ -251,13 +251,14 @@ public class ShopServiceImpl extends ServiceImpl implements } /** - * 获取退款状态ID(根据状态名称"已退款"查找) + * 获取退款状态ID(根据 is_refund 字段查找) */ private Long getRefundStatusId() { Long companyId = currentUserContext.getCurrentCompanyId(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(OrderStatusPO::getCompanyId, companyId) - .eq(OrderStatusPO::getStatusName, "已退款"); + .eq(OrderStatusPO::getIsRefund, 1) + .last("LIMIT 1"); OrderStatusPO status = orderStatusService.getOne(wrapper); return status != null ? status.getId() : null; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/sql/ec_design.sql b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/sql/ec_design.sql index 9ced084f..e778e8c5 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/sql/ec_design.sql +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/sql/ec_design.sql @@ -80,6 +80,7 @@ CREATE TABLE `ec_order_status` ( `description` VARCHAR(200) DEFAULT NULL COMMENT '状态描述', `sort_order` INT NOT NULL DEFAULT 0 COMMENT '排序', `auto_statistics` TINYINT NOT NULL DEFAULT 1 COMMENT '是否自动参与统计 0不参与 1参与', + `is_refund` TINYINT NOT NULL DEFAULT 0 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 DEFAULT NULL COMMENT '创建人ID', @@ -89,6 +90,7 @@ CREATE TABLE `ec_order_status` ( UNIQUE KEY `uk_company_status_name` (`company_id`, `status_name`), KEY `idx_sort_order` (`sort_order`), KEY `idx_auto_statistics` (`auto_statistics`), + KEY `idx_is_refund` (`is_refund`), KEY `fk_ec_order_status_creator` (`create_by`), KEY `fk_ec_order_status_updater` (`update_by`), CONSTRAINT `fk_ec_order_status_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status/types/types.dto.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status/types/types.dto.ts index a348b428..35df3e22 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status/types/types.dto.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status/types/types.dto.ts @@ -13,6 +13,8 @@ export namespace OrderStatusDTO { sortOrder?: number; /** 自动统计 0不参与 1参与 */ autoStatistics: number; + /** 是否为退款状态 0否 1是 */ + isRefund?: number; } /** 更新订单状态参数 */ @@ -25,5 +27,7 @@ export namespace OrderStatusDTO { sortOrder?: number; /** 自动统计 0不参与 1参与 */ autoStatistics: number; + /** 是否为退款状态 0否 1是 */ + isRefund?: number; } } diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status/types/types.vo.ts index 9d707304..e539b9fe 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status/types/types.vo.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status/types/types.vo.ts @@ -17,6 +17,8 @@ export namespace OrderStatusVO { sortOrder?: number; /** 自动统计 0不参与 1参与 */ autoStatistics: number; + /** 是否为退款状态 0否 1是 */ + isRefund?: number; /** 创建时间 */ createTime: string; /** 更新时间 */ diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/apis.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/apis.ts index b4d8a92b..51b55939 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/apis.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/apis.ts @@ -1,7 +1,7 @@ import type { ShopDTO, ShopVO } from './types'; -import type { PageQueryDTO, PageResultVO } from '#/types/common'; import type { ProductVO } from '#/api/ecommerce/product/types'; +import type { PageQueryDTO, PageResultVO } from '#/types/common'; import { requestClient } from '#/api/request'; @@ -68,3 +68,15 @@ export async function getShopProductPageApi( params, ); } + +/** + * 获取店铺概览统计数据 + */ +export async function getShopOverviewStatisticsApi( + params: ShopDTO.OverviewQuery, +) { + return requestClient.post( + '/ec/shop/overview-statistics', + params, + ); +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.dto.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.dto.ts index f47df6de..764cef53 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.dto.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.dto.ts @@ -46,4 +46,12 @@ export namespace ShopDTO { /** 店铺ID */ shopId: number; } + + /** 店铺概览查询参数 */ + export interface OverviewQuery { + /** 店铺ID */ + shopId: number; + /** 日期范围数组(第一个是开始日期,第二个是结束日期,只有一个日期则返回当天数据) */ + dateRange: string[]; + } } diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts index 3fa1fb46..a6e383a0 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts @@ -104,4 +104,90 @@ export namespace ShopVO { /** 费比统计 */ feeRatio: DailyStatistics; } + + /** 店铺概览统计信息 */ + export interface OverviewStatistics { + /** 店铺总销售额 */ + totalSalesAmount: number; + /** 较上月同期增长百分比 */ + monthOverMonthGrowth?: number; + /** 店铺总单量 */ + totalOrderCount: number; + /** 总推广费支出 */ + totalPromotionFee: number; + /** 平均费比(推广费/销售额) */ + averageFeeRatio?: number; + /** 店铺总净利(税后) */ + totalNetProfitAfterTax: number; + /** 扣除总税额 */ + totalTaxAmount?: number; + /** 店铺总销量目标(目标订单数) */ + totalTargetOrderCount?: number; + /** 店铺总销售额目标 */ + totalTargetAmount?: number; + /** 销量目标达成率 */ + orderCountAchievementRate?: number; + /** 销售额目标达成率 */ + salesAmountAchievementRate?: number; + /** 汇总ROI */ + totalROI?: number; + /** 总税后盈亏 */ + totalProfitAfterTax?: number; + /** 销售额趋势分析 */ + salesAmountTrend?: TrendData; + /** 单量趋势分析 */ + orderCountTrend?: TrendData; + /** 多商品数据横向对比 */ + productComparisons?: ProductComparison[]; + } + + /** 商品对比数据 */ + export interface ProductComparison { + /** 商品ID */ + productId: number; + /** 商品名称 */ + productName: string; + /** 商品编码 */ + productCode?: string; + /** 销售额 */ + salesAmount: number; + /** 单量 */ + orderCount?: number; + /** 客单价 */ + averageOrderValue?: number; + /** 成本运费 */ + shippingCost?: number; + /** 退款金额 */ + refundAmount?: number; + /** 推广费 */ + totalPromotionFee?: number; + /** 刷单费用 */ + brushFee?: number; + /** 费比 */ + feeRatio?: number; + /** 税前盈亏 */ + totalProfitBeforeTax?: number; + /** 销售额4%税额 */ + salesTaxAmount?: number; + /** 税后盈亏 */ + profitAfterTax?: number; + /** ROI */ + roi?: number; + } + + /** 趋势数据 */ + export interface TrendData { + /** 时间范围的总值 */ + total: number; + /** 每日数据列表 */ + dailyDataList: TrendDataItem[]; + } + + /** 趋势数据项 */ + export interface TrendDataItem { + /** 日期 */ + date: string; + /** 对应的值 */ + value: number; + } } diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/config/order-status-config/components/OrderStatusFormModal.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/config/order-status-config/components/OrderStatusFormModal.vue index 1e15cdc2..5eafe5d3 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/config/order-status-config/components/OrderStatusFormModal.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/config/order-status-config/components/OrderStatusFormModal.vue @@ -43,6 +43,7 @@ const formData = ref>({ description: '', autoStatistics: 1, sortOrder: 0, + isRefund: 0, }); // 表单验证规则 @@ -68,12 +69,14 @@ function open(edit: boolean, record?: OrderStatusVO.Info) { description: record.description || '', autoStatistics: record.autoStatistics, sortOrder: record.sortOrder || 0, + isRefund: record.isRefund || 0, } : { statusName: '', description: '', autoStatistics: 1, sortOrder: 0, + isRefund: 0, }; } @@ -97,6 +100,7 @@ async function handleSubmit() { description: formData.value.description, autoStatistics: formData.value.autoStatistics!, sortOrder: formData.value.sortOrder, + isRefund: formData.value.isRefund, }; await updateOrderStatusApi(currentRecord.value.id, updateData); message.success('更新订单状态成功'); @@ -107,6 +111,7 @@ async function handleSubmit() { description: formData.value.description, autoStatistics: formData.value.autoStatistics!, sortOrder: formData.value.sortOrder, + isRefund: formData.value.isRefund, }; await createOrderStatusApi(createData); message.success('创建订单状态成功'); @@ -186,6 +191,16 @@ defineExpose({ /> + + + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue new file mode 100644 index 00000000..45e96fb5 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue @@ -0,0 +1,807 @@ + + + + + diff --git a/ecom-dmb-frontend/apps/web-antd/test/ai_studio_code (16).html b/ecom-dmb-frontend/apps/web-antd/test/ai_studio_code (16).html new file mode 100644 index 00000000..bbc5651e --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/test/ai_studio_code (16).html @@ -0,0 +1,284 @@ + + + + + + 店铺经营概览 - 极简毛玻璃版 + + + + + + + +
+ + +
+
+

店铺经营概览

+

数据更新于:今日 20:45:12

+
+ + +
+
+ + + + +
+
+
+ 自定义日期 + +
+
+
+ + +
+ +
+
+ 店铺销售总额 + 增长率 +12.4% +
+
¥1,284,000
+
+ 销售额目标达成 + 96.5% +
+
+ + +
+
订单总量与达成
+
8,412 单
+
+
+ 目标: 10,000 单 + 达成率: 84.1% +
+
+
+
+
+
+ + +
+
投资回报率 (ROI)
+
4.21
+
+
+ 平均费比 + 23.7% +
+
+
+ + +
+
店铺总净利润 (税后)
+
¥124,500
+
+ 已扣除 4% 税额 + -¥51,360 +
+
+
+ + +
+ +
+

销售额与单量趋势分析

+
+
+ + +
+

财务损益全维度 (P&L)

+
+
推广费总支出-¥305,000
+
客单价 (AOV)¥152.80
+
总税后盈亏 (Profit)¥175,860
+ +
+
销售额 4% 税额¥51,360
+
较上月同期增长+14.2%
+
+ +
+
+

Final Net Profit

+

税后最终净利

+
+
¥124,500
+
+
+
+
+ + +
+
+
+

核心商品多维度损益对比表

+

横向对比各商品规模、成本及 ROI 效率

+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
商品详情商品规模 (Scale)费用成本 (Costs)单品损益 (Profitability)
销售额单量客单价成本运费退款金额推广费刷单费用费比 %单品 ROI税前盈亏4%税额税后净利
+
智能降噪耳机 G200
+
编码: ITEM-99201
+
¥428,0001,240¥345.1¥42,400¥12,400¥65,000¥4,50015.1%6.58¥102,500¥17,120¥85,380
+
复古数码相机 RX-X
+
编码: ITEM-00821
+
¥215,000890¥241.5¥28,000¥32,000¥82,000¥8,50038.1%2.62¥12,400¥8,600¥3,800
+
+
+
+ + + + \ No newline at end of file