diff --git a/ecom-dmb-backend/sql/V20260430__add_shop_details_menu.sql b/ecom-dmb-backend/sql/V20260430__add_shop_details_menu.sql new file mode 100644 index 00000000..39c9eea4 --- /dev/null +++ b/ecom-dmb-backend/sql/V20260430__add_shop_details_menu.sql @@ -0,0 +1,12 @@ +-- ================================================ +-- 店铺详情菜单 SQL(需在数据库执行) +-- 父菜单:电商/店铺管理(请先查询确认父菜单ID) +-- ================================================ +-- +-- 步骤1:查询父菜单ID(电商/店铺管理) +-- SELECT id, name, title, parent_id FROM sys_menu WHERE name LIKE '%店铺%'; +-- +-- 假设父菜单 ID 为 XX,则执行以下 INSERT(将 XX 替换为实际父菜单ID) +-- +-- INSERT INTO `sys_menu` (`parent_id`, `name`, `title`, `path`, `component`, `icon`, `type`, `visible`, `status`, `order`, `create_time`) +-- VALUES (XX, 'shop-details', '店铺详情', '/ecom/shop/details/:id', 'ecommerce/shop/details/index', 'file-text', 'menu', 1, 1, 200, NOW()); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/controller/ShopController.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/controller/ShopController.java index c03fc2d7..1c799e68 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/controller/ShopController.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/controller/ShopController.java @@ -12,12 +12,14 @@ 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.shop.model.dto.CreateShopDTO; +import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopDetailQueryDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopFilterDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopProductPageFilterDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopStatisticsQueryDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.UpdateShopDTO; import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.dto.ShopOverviewQueryDTO; import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductVO; +import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopDashboardVO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopOverviewVO; import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo.ShopOverviewStatisticsVO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopVO; @@ -115,4 +117,12 @@ public class ShopController { ShopOverviewStatisticsVO overviewVO = shopOverviewStatisticsService.getShopOverviewStatistics(queryDTO); return ApiResponse.success("获取店铺概览统计成功", overviewVO); } + + @Operation(summary = "获取店铺详情页看板数据", description = "获取店铺详情页的月度目标、推广费、刷单费、店铺订单等看板数据") + @PostMapping("/details") + @RequirePermission(value = "ecom:shop:read", description = "查询店铺详情", allowSuper = true) + public ApiResponse getShopDetails(@Valid @RequestBody ShopDetailQueryDTO queryDTO) { + ShopDashboardVO dashboard = shopService.getShopDashboard(queryDTO); + return ApiResponse.success("获取店铺详情看板数据成功", dashboard); + } } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/model/vo/ShopDashboardVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/model/vo/ShopDashboardVO.java new file mode 100644 index 00000000..5a7fe607 --- /dev/null +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/model/vo/ShopDashboardVO.java @@ -0,0 +1,133 @@ +package top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * 店铺详情页看板VO + */ +@Data +@Schema(description = "店铺详情页看板VO") +public class ShopDashboardVO { + + /** + * 店铺基本信息 + */ + @Schema(description = "店铺基本信息") + private ShopInfo shopInfo; + + /** + * 月度目标看板数据 + */ + @Schema(description = "月度目标看板数据") + private MonthlyTargetKpi monthlyTarget; + + /** + * 推广费看板数据 + */ + @Schema(description = "推广费看板数据") + private PromotionFeeKpi promotionFee; + + /** + * 刷单费看板数据 + */ + @Schema(description = "刷单费看板数据") + private BrushOrderKpi brushOrder; + + /** + * 店铺订单看板数据 + */ + @Schema(description = "店铺订单看板数据") + private ShopOrderKpi shopOrder; + + /** + * 店铺基本信息 + */ + @Data + @Schema(description = "店铺基本信息") + public static class ShopInfo { + @Schema(description = "店铺ID") + private Long id; + @Schema(description = "店铺名称") + private String name; + @Schema(description = "logo URL") + private String logo; + @Schema(description = "平台名称") + private String platformName; + } + + + /** + * 月度目标KPI + */ + @Data + @Schema(description = "月度目标KPI") + public static class MonthlyTargetKpi { + /** 年度目标总额 */ + @Schema(description = "年度目标总额") + private java.math.BigDecimal totalTargetAmount; + /** 目标单量合计 */ + @Schema(description = "目标单量合计") + private Integer totalOrderCount; + /** 本月目标销售额 */ + @Schema(description = "本月目标销售额") + private java.math.BigDecimal thisMonthTargetAmount; + /** 本月目标单量 */ + @Schema(description = "本月目标单量") + private Integer thisMonthTargetOrderCount; + /** 当前达成率 */ + @Schema(description = "当前达成率(百分比)") + private java.math.BigDecimal achievementRate; + } + + /** + * 推广费KPI + */ + @Data + @Schema(description = "推广费KPI") + public static class PromotionFeeKpi { + /** 累计推广费 */ + @Schema(description = "累计推广费") + private java.math.BigDecimal totalFeeAmount; + /** 本月推广费 */ + @Schema(description = "本月推广费") + private java.math.BigDecimal thisMonthFee; + /** 日均推广费 */ + @Schema(description = "日均推广费") + private java.math.BigDecimal avgDailyFee; + } + + /** + * 刷单费KPI + */ + @Data + @Schema(description = "刷单费KPI") + public static class BrushOrderKpi { + /** 累计刷单费 */ + @Schema(description = "累计刷单费") + private java.math.BigDecimal totalBrushAmount; + /** 本月刷单次数 */ + @Schema(description = "本月刷单次数") + private Integer thisMonthCount; + /** 平均刷单金额 */ + @Schema(description = "平均刷单金额") + private java.math.BigDecimal avgAmount; + } + + /** + * 店铺订单KPI + */ + @Data + @Schema(description = "店铺订单KPI") + public static class ShopOrderKpi { + /** 累计实收金额 */ + @Schema(description = "累计实收金额") + private java.math.BigDecimal totalReceivedAmount; + /** 累计佣金 */ + @Schema(description = "累计佣金") + private java.math.BigDecimal totalCommission; + /** 累计订单数 */ + @Schema(description = "累计订单数") + private Integer totalOrderCount; + } +} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/ShopService.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/ShopService.java index 41d277f8..49753d35 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/ShopService.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/ShopService.java @@ -5,12 +5,14 @@ import org.springframework.web.multipart.MultipartFile; import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO; import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.CreateShopDTO; +import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopDetailQueryDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopFilterDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopProductPageFilterDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopStatisticsQueryDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.UpdateShopDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.po.ShopPO; import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductVO; +import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopDashboardVO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopOverviewVO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopVO; import top.xyquan.ecomdmbbackend.modules.sys.file.model.vo.SysFileUploadVO; @@ -75,4 +77,12 @@ public interface ShopService extends IService { * @return 分页结果 */ PageResultVO getShopProductPage(PageQueryDTO pageQueryDTO); + + /** + * 获取店铺详情页看板数据 + * + * @param queryDTO 查询DTO + * @return 看板VO + */ + ShopDashboardVO getShopDashboard(ShopDetailQueryDTO queryDTO); } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java index cbfd864a..110847ef 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java @@ -10,6 +10,8 @@ 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.brushorder.mapper.BrushOrderMapper; +import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.model.po.BrushOrderPO; import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper; import top.xyquan.ecomdmbbackend.modules.ecom.product.mapper.ProductMapper; import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper; @@ -17,7 +19,11 @@ 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.ShopProductRelationMapper; +import top.xyquan.ecomdmbbackend.modules.ecom.shop.monthlytarget.mapper.ShopMonthlyTargetMapper; +import top.xyquan.ecomdmbbackend.modules.ecom.shop.monthlytarget.model.po.ShopMonthlyTargetPO; +import top.xyquan.ecomdmbbackend.modules.ecom.shop.monthlytarget.model.vo.ShopMonthlyTargetVO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.CreateShopDTO; +import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopDetailQueryDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopFilterDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopProductPageFilterDTO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopStatisticsQueryDTO; @@ -32,6 +38,7 @@ import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.po.ShopPO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.po.ShopProductRelationPO; import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductSpecVO; import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductVO; +import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopDashboardVO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopOverviewVO; import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopVO; import top.xyquan.ecomdmbbackend.modules.ecom.product.service.ProductSpecService; @@ -71,12 +78,15 @@ public class ShopServiceImpl extends ServiceImpl implements private final ProductSpecService productSpecService; private final OrderStatusService orderStatusService; private final PlatformMapper platformMapper; + private final BrushOrderMapper brushOrderMapper; + private final ShopMonthlyTargetMapper shopMonthlyTargetMapper; public ShopServiceImpl(CurrentUserContext currentUserContext, SysFileMapper sysFileMapper, SysFileService sysFileService, OrderMapper orderMapper, PromotionFeeMapper promotionFeeMapper, ProductMapper productMapper, ShopProductRelationMapper shopProductRelationMapper, ProductSpecService productSpecService, - OrderStatusService orderStatusService, PlatformMapper platformMapper) { + OrderStatusService orderStatusService, PlatformMapper platformMapper, + BrushOrderMapper brushOrderMapper, ShopMonthlyTargetMapper shopMonthlyTargetMapper) { this.currentUserContext = currentUserContext; this.sysFileMapper = sysFileMapper; this.sysFileService = sysFileService; @@ -87,6 +97,8 @@ public class ShopServiceImpl extends ServiceImpl implements this.productSpecService = productSpecService; this.orderStatusService = orderStatusService; this.platformMapper = platformMapper; + this.brushOrderMapper = brushOrderMapper; + this.shopMonthlyTargetMapper = shopMonthlyTargetMapper; } /** @@ -733,4 +745,185 @@ public class ShopServiceImpl extends ServiceImpl implements BeanUtils.copyProperties(productSpec, productSpecVO); return productSpecVO; } + + @Override + public ShopDashboardVO getShopDashboard(ShopDetailQueryDTO queryDTO) { + Long companyId = currentUserContext.getCurrentCompanyId(); + Long shopId = queryDTO.getShopId(); + + // 验证店铺 + ShopPO shop = this.getById(shopId); + if (shop == null || !shop.getCompanyId().equals(companyId)) { + throw new BusinessException("店铺不存在"); + } + + // 日期范围(默认当月) + LocalDate startDate = queryDTO.getStartDate() != null ? queryDTO.getStartDate() : LocalDate.now().withDayOfMonth(1); + LocalDate endDate = queryDTO.getEndDate() != null ? queryDTO.getEndDate() : LocalDate.now(); + LocalDateTime startDateTime = startDate.atStartOfDay(); + LocalDateTime endDateTime = endDate.atTime(23, 59, 59); + + ShopDashboardVO dashboard = new ShopDashboardVO(); + + // 设置店铺基本信息 + ShopDashboardVO.ShopInfo shopInfo = new ShopDashboardVO.ShopInfo(); + shopInfo.setId(shop.getId()); + shopInfo.setName(shop.getName()); + shopInfo.setLogo(null); // logoImageId 冗余字段,前端按需使用 + // 查询平台名称 + if (shop.getPlatformId() != null) { + LambdaQueryWrapper platformWrapper = new LambdaQueryWrapper<>(); + platformWrapper.eq(PlatformPO::getId, shop.getPlatformId()) + .eq(PlatformPO::getCompanyId, companyId); + PlatformPO platform = platformMapper.selectOne(platformWrapper); + if (platform != null) { + shopInfo.setPlatformName(platform.getPlatformName()); + } + } + dashboard.setShopInfo(shopInfo); + + // 1. 月度目标 + dashboard.setMonthlyTarget(buildMonthlyTargetKpi(companyId, shopId, shop, startDate, endDate)); + + // 2. 推广费 + dashboard.setPromotionFee(buildPromotionFeeKpi(companyId, shopId, shop, startDate, endDate)); + + // 3. 刷单费 + dashboard.setBrushOrder(buildBrushOrderKpi(companyId, shopId, shop, startDate, endDate)); + + // 4. 店铺订单 + dashboard.setShopOrder(buildShopOrderKpi(companyId, shopId, shop, startDateTime, endDateTime)); + + return dashboard; + } + + private ShopDashboardVO.MonthlyTargetKpi buildMonthlyTargetKpi(Long companyId, Long shopId, ShopPO shop, LocalDate startDate, LocalDate endDate) { + ShopDashboardVO.MonthlyTargetKpi kpi = new ShopDashboardVO.MonthlyTargetKpi(); + + // 查询所有目标记录(不限日期,取所有) + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ShopMonthlyTargetPO::getCompanyId, companyId) + .eq(ShopMonthlyTargetPO::getShopId, shopId) + .orderByDesc(ShopMonthlyTargetPO::getTargetMonth); + List allTargets = shopMonthlyTargetMapper.selectList(wrapper); + + // 年度总额 & 目标单量合计 + BigDecimal totalTargetAmount = allTargets.stream() + .map(ShopMonthlyTargetPO::getTargetAmount) + .reduce(BigDecimal.ZERO, BigDecimal::add); + int totalOrderCount = allTargets.stream() + .mapToInt(t -> t.getTargetOrderCount() != null ? t.getTargetOrderCount() : 0) + .sum(); + + // 本月目标 + String thisMonth = startDate.withDayOfMonth(1).toString().substring(0, 7); + ShopMonthlyTargetPO thisMonthTarget = allTargets.stream() + .filter(t -> t.getTargetMonth() != null && t.getTargetMonth().toString().startsWith(thisMonth)) + .findFirst().orElse(null); + + kpi.setTotalTargetAmount(totalTargetAmount); + kpi.setTotalOrderCount(totalOrderCount); + kpi.setThisMonthTargetAmount(thisMonthTarget != null ? thisMonthTarget.getTargetAmount() : BigDecimal.ZERO); + kpi.setThisMonthTargetOrderCount(thisMonthTarget != null ? thisMonthTarget.getTargetOrderCount() : 0); + + // 达成率 = 实际销售额 / 目标销售额(简化:查时间段内订单实收 / 目标) + LambdaQueryWrapper orderWrapper = new LambdaQueryWrapper<>(); + orderWrapper.eq(OrderPO::getCompanyId, companyId) + .eq(OrderPO::getShopId, shopId) + .ge(OrderPO::getOrderTime, startDate.atStartOfDay()) + .le(OrderPO::getOrderTime, endDate.atTime(23, 59, 59)); + List periodOrders = orderMapper.selectList(orderWrapper); + BigDecimal actualSales = periodOrders.stream() + .map(o -> o.getReceivedAmount() != null ? o.getReceivedAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal achievementRate = BigDecimal.ZERO; + if (thisMonthTarget != null && thisMonthTarget.getTargetAmount() != null + && thisMonthTarget.getTargetAmount().compareTo(BigDecimal.ZERO) > 0) { + achievementRate = actualSales.divide(thisMonthTarget.getTargetAmount(), 4, RoundingMode.HALF_UP) + .multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP); + } + kpi.setAchievementRate(achievementRate); + + + return kpi; + } + + private ShopDashboardVO.PromotionFeeKpi buildPromotionFeeKpi(Long companyId, Long shopId, ShopPO shop, LocalDate startDate, LocalDate endDate) { + ShopDashboardVO.PromotionFeeKpi kpi = new ShopDashboardVO.PromotionFeeKpi(); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(PromotionFeePO::getCompanyId, companyId) + .eq(PromotionFeePO::getShopId, shopId) + .ge(PromotionFeePO::getFeeDate, startDate) + .le(PromotionFeePO::getFeeDate, endDate) + .orderByDesc(PromotionFeePO::getFeeDate); + List allFees = promotionFeeMapper.selectList(wrapper); + + BigDecimal totalFeeAmount = allFees.stream() + .map(f -> f.getFeeAmount() != null ? f.getFeeAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 本月推广费 + String thisMonthStr = startDate.withDayOfMonth(1).toString().substring(0, 7); + BigDecimal thisMonthFee = allFees.stream() + .filter(f -> f.getFeeDate() != null && f.getFeeDate().toString().startsWith(thisMonthStr)) + .map(f -> f.getFeeAmount() != null ? f.getFeeAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 日均 + long days = java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1; + BigDecimal avgDailyFee = days > 0 ? totalFeeAmount.divide(BigDecimal.valueOf(days), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO; + + kpi.setTotalFeeAmount(totalFeeAmount); + kpi.setThisMonthFee(thisMonthFee); + kpi.setAvgDailyFee(avgDailyFee); + return kpi; + } + + private ShopDashboardVO.BrushOrderKpi buildBrushOrderKpi(Long companyId, Long shopId, ShopPO shop, LocalDate startDate, LocalDate endDate) { + ShopDashboardVO.BrushOrderKpi kpi = new ShopDashboardVO.BrushOrderKpi(); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(BrushOrderPO::getCompanyId, companyId) + .eq(BrushOrderPO::getShopId, shopId) + .ge(BrushOrderPO::getBrushTime, startDate.atStartOfDay()) + .le(BrushOrderPO::getBrushTime, endDate.atTime(23, 59, 59)) + .orderByDesc(BrushOrderPO::getBrushTime); + List allBrush = brushOrderMapper.selectList(wrapper); + + BigDecimal totalBrushAmount = allBrush.stream() + .map(b -> b.getBrushAmount() != null ? b.getBrushAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + long thisMonthCount = allBrush.stream() + .filter(b -> b.getBrushTime() != null && b.getBrushTime().toLocalDate().getMonth().equals(startDate.getMonth())) + .count(); + long brushCount = allBrush.size(); + BigDecimal avgAmount = brushCount > 0 ? totalBrushAmount.divide(BigDecimal.valueOf(brushCount), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO; + + kpi.setTotalBrushAmount(totalBrushAmount); + kpi.setThisMonthCount((int) thisMonthCount); + kpi.setAvgAmount(avgAmount); + return kpi; + } + + private ShopDashboardVO.ShopOrderKpi buildShopOrderKpi(Long companyId, Long shopId, ShopPO shop, LocalDateTime startDateTime, LocalDateTime endDateTime) { + ShopDashboardVO.ShopOrderKpi kpi = new ShopDashboardVO.ShopOrderKpi(); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(OrderPO::getCompanyId, companyId) + .eq(OrderPO::getShopId, shopId) + .ge(OrderPO::getOrderTime, startDateTime) + .le(OrderPO::getOrderTime, endDateTime) + .orderByDesc(OrderPO::getOrderTime); + List allOrders = orderMapper.selectList(wrapper); + + BigDecimal totalReceived = allOrders.stream() + .map(o -> o.getReceivedAmount() != null ? o.getReceivedAmount() : BigDecimal.ZERO) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + kpi.setTotalReceivedAmount(totalReceived); + kpi.setTotalCommission(BigDecimal.ZERO); // 订单表暂无佣金字段 + kpi.setTotalOrderCount(allOrders.size()); + return kpi; + } } 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 0a793162..e399b610 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 @@ -106,3 +106,10 @@ export async function exportCompanyOverviewApi(params: { responseType: 'blob', }); } + +/** + * 获取店铺详情看板数据 + */ +export async function getShopDetailsApi(params: ShopDTO.DetailQuery) { + return requestClient.post('/ec/shop/details', 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 7ad321b9..83007b40 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 @@ -56,4 +56,14 @@ export namespace ShopDTO { /** 税率(默认0.04,即4%) */ taxRate?: number; } + + /** 店铺详情看板查询参数 */ + export interface DetailQuery { + /** 店铺ID */ + shopId: number; + /** 开始日期(不传默认为当月1号) */ + startDate?: string; + /** 结束日期(不传默认为今天) */ + endDate?: 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 4f69d356..c4c65077 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 @@ -260,4 +260,72 @@ export namespace ShopVO { /** 各品类汇总列表 */ categories: CategoryComparison[]; } + + // ========== 店铺详情看板 ========== + + /** 店铺基本信息 */ + export interface ShopInfo { + id: number; + name: string; + logo?: string; + platformName?: string; + } + + /** 月度目标KPI */ + export interface MonthlyTargetKpi { + /** 年度目标总额 */ + totalTargetAmount: number; + /** 目标单量合计 */ + totalOrderCount: number; + /** 本月目标销售额 */ + thisMonthTargetAmount: number; + /** 本月目标单量 */ + thisMonthTargetOrderCount: number; + /** 当前达成率(百分比) */ + achievementRate: number; + } + + /** 推广费KPI */ + export interface PromotionFeeKpi { + /** 累计推广费 */ + totalFeeAmount: number; + /** 本月推广费 */ + thisMonthFee: number; + /** 日均推广费 */ + avgDailyFee: number; + } + + /** 刷单费KPI */ + export interface BrushOrderKpi { + /** 累计刷单费 */ + totalBrushAmount: number; + /** 本月刷单次数 */ + thisMonthCount: number; + /** 平均刷单金额 */ + avgAmount: number; + } + + /** 店铺订单KPI */ + export interface ShopOrderKpi { + /** 累计实收金额 */ + totalReceivedAmount: number; + /** 累计佣金 */ + totalCommission: number; + /** 累计订单数 */ + totalOrderCount: number; + } + + /** 店铺详情看板数据 */ + export interface Dashboard { + /** 店铺基本信息 */ + shopInfo: ShopInfo; + /** 月度目标看板数据 */ + monthlyTarget: MonthlyTargetKpi; + /** 推广费看板数据 */ + promotionFee: PromotionFeeKpi; + /** 刷单费看板数据 */ + brushOrder: BrushOrderKpi; + /** 店铺订单看板数据 */ + shopOrder: ShopOrderKpi; + } } diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/BrushOrderCard.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/BrushOrderCard.vue new file mode 100644 index 00000000..41a55cdd --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/BrushOrderCard.vue @@ -0,0 +1,174 @@ + + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ChartCard.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ChartCard.vue deleted file mode 100644 index cea05b13..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ChartCard.vue +++ /dev/null @@ -1,170 +0,0 @@ - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/MonthlyTargetCard.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/MonthlyTargetCard.vue new file mode 100644 index 00000000..b446e550 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/MonthlyTargetCard.vue @@ -0,0 +1,179 @@ + + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ProductsTab.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ProductsTab.vue deleted file mode 100644 index 99962154..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ProductsTab.vue +++ /dev/null @@ -1,214 +0,0 @@ - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/PromotionFeeCard.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/PromotionFeeCard.vue new file mode 100644 index 00000000..0a00a728 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/PromotionFeeCard.vue @@ -0,0 +1,182 @@ + + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ShopOrderCard.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ShopOrderCard.vue new file mode 100644 index 00000000..5e2947d0 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ShopOrderCard.vue @@ -0,0 +1,167 @@ + + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ShopStatistics.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ShopStatistics.vue deleted file mode 100644 index 6a0c992b..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/components/ShopStatistics.vue +++ /dev/null @@ -1,164 +0,0 @@ - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/index.vue index f00fef4a..b8d058db 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/index.vue @@ -1,41 +1,79 @@ diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/tabs/OverviewTab.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/tabs/OverviewTab.vue deleted file mode 100644 index b9b4d0f4..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/tabs/OverviewTab.vue +++ /dev/null @@ -1,178 +0,0 @@ - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/tabs/ProductsTab.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/tabs/ProductsTab.vue deleted file mode 100644 index 99962154..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/details/tabs/ProductsTab.vue +++ /dev/null @@ -1,214 +0,0 @@ - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/index.vue index 0f06496a..bf631fc0 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/list/index.vue @@ -288,6 +288,9 @@ function handleViewOverview(record: ShopVO.Info) { +