mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
refactor: 统一字段命名从 *Comparisons 改为 *Summary
后端: - CompanyOverviewVO: shopComparisons -> shopSummary, categoryComparisons -> categorySummary - ShopOverviewStatisticsVO: ProductComparison/CategoryComparison -> ProductSummary/CategorySummary - CompanyOverviewServiceImpl/ShopOverviewStatisticsServiceImpl: 方法和变量重命名 - CategoryExportExcelServiceImpl, ShopExportServiceImpl: 类型引用更新 前端: - store-overview/types/types.vo.ts: 接口重命名 ShopSummary/CategorySummary - shop/types/types.vo.ts: 接口重命名 ProductSummary/CategorySummary - 组件 props 从 shopComparisons/categoryComparisons 改为 shopSummary/categorySummary - 修复 ShopComparisonTable 导出类型引用 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+8
-8
@@ -85,13 +85,13 @@ public class CompanyOverviewVO {
|
||||
* 多店铺数据横向汇总(包含合计行和店铺列表)
|
||||
*/
|
||||
@Schema(description = "多店铺数据横向汇总")
|
||||
private ShopOverview shopComparisons;
|
||||
private ShopOverview shopSummary;
|
||||
|
||||
/**
|
||||
* 多品类数据横向汇总(包含合计行和品类列表)
|
||||
*/
|
||||
@Schema(description = "多品类数据横向汇总")
|
||||
private CategoryOverview categoryComparisons;
|
||||
private CategoryOverview categorySummary;
|
||||
|
||||
/**
|
||||
* 平台维度概览(包含合计行和平台列表)
|
||||
@@ -113,10 +113,10 @@ public class CompanyOverviewVO {
|
||||
@Schema(description = "多店铺概览")
|
||||
public static class ShopOverview {
|
||||
@Schema(description = "合计行")
|
||||
private ShopComparison total;
|
||||
private ShopSummary total;
|
||||
|
||||
@Schema(description = "各店铺汇总列表")
|
||||
private List<ShopComparison> shops;
|
||||
private List<ShopSummary> shops;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,10 +126,10 @@ public class CompanyOverviewVO {
|
||||
@Schema(description = "多品类概览")
|
||||
public static class CategoryOverview {
|
||||
@Schema(description = "合计行")
|
||||
private CategoryComparison total;
|
||||
private CategorySummary total;
|
||||
|
||||
@Schema(description = "各品类汇总列表")
|
||||
private List<CategoryComparison> categories;
|
||||
private List<CategorySummary> categories;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,7 +245,7 @@ public class CompanyOverviewVO {
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "店铺汇总数据")
|
||||
public static class ShopComparison {
|
||||
public static class ShopSummary {
|
||||
@Schema(description = "店铺ID", example = "1")
|
||||
private Long shopId;
|
||||
|
||||
@@ -318,7 +318,7 @@ public class CompanyOverviewVO {
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "品类汇总数据")
|
||||
public static class CategoryComparison {
|
||||
public static class CategorySummary {
|
||||
@Schema(description = "品类ID(未分配为null)", example = "1")
|
||||
private Long categoryId;
|
||||
|
||||
|
||||
+6
-6
@@ -176,9 +176,9 @@ public class ShopOverviewStatisticsVO {
|
||||
@Schema(description = "商品概览")
|
||||
public static class ProductOverview {
|
||||
@Schema(description = "合计行")
|
||||
private ProductComparison total;
|
||||
private ProductSummary total;
|
||||
@Schema(description = "各商品汇总列表")
|
||||
private List<ProductComparison> products;
|
||||
private List<ProductSummary> products;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,9 +188,9 @@ public class ShopOverviewStatisticsVO {
|
||||
@Schema(description = "品类概览")
|
||||
public static class CategoryOverview {
|
||||
@Schema(description = "合计行")
|
||||
private CategoryComparison total;
|
||||
private CategorySummary total;
|
||||
@Schema(description = "各品类汇总列表")
|
||||
private List<CategoryComparison> categories;
|
||||
private List<CategorySummary> categories;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +198,7 @@ public class ShopOverviewStatisticsVO {
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "商品汇总数据")
|
||||
public static class ProductComparison {
|
||||
public static class ProductSummary {
|
||||
@Schema(description = "商品ID", example = "1")
|
||||
private Long productId;
|
||||
|
||||
@@ -259,7 +259,7 @@ public class ShopOverviewStatisticsVO {
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "品类汇总数据")
|
||||
public static class CategoryComparison {
|
||||
public static class CategorySummary {
|
||||
@Schema(description = "品类ID", example = "1")
|
||||
private Long categoryId;
|
||||
|
||||
|
||||
+5
-5
@@ -154,7 +154,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
Map<Long, String> categoryNameMap = allCategories.stream()
|
||||
.collect(Collectors.toMap(CategoryPO::getId, CategoryPO::getName));
|
||||
|
||||
List<CompanyOverviewVO.CategoryComparison> categoryDataList = new ArrayList<>();
|
||||
List<CompanyOverviewVO.CategorySummary> categoryDataList = new ArrayList<>();
|
||||
for (Map.Entry<Long, List<OrderPO>> entry : ordersByCategory.entrySet()) {
|
||||
Long categoryId = entry.getKey();
|
||||
List<OrderPO> categoryOrders = entry.getValue();
|
||||
@@ -213,7 +213,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
? "未分配品类"
|
||||
: categoryNameMap.getOrDefault(categoryId, "Unknown");
|
||||
|
||||
CompanyOverviewVO.CategoryComparison data = new CompanyOverviewVO.CategoryComparison();
|
||||
CompanyOverviewVO.CategorySummary data = new CompanyOverviewVO.CategorySummary();
|
||||
data.setCategoryId(categoryId == -1L ? null : categoryId);
|
||||
data.setCategoryName(categoryName);
|
||||
data.setSalesAmount(salesAmount);
|
||||
@@ -241,7 +241,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
categoryDataList.sort(Comparator.comparing(CompanyOverviewVO.CategoryComparison::getSalesAmount).reversed());
|
||||
categoryDataList.sort(Comparator.comparing(CompanyOverviewVO.CategorySummary::getSalesAmount).reversed());
|
||||
|
||||
String dateRangeLabel = startDate.format(DATE_FMT) + " 至 " + endDate.format(DATE_FMT);
|
||||
|
||||
@@ -258,7 +258,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
}
|
||||
|
||||
private void createCategoryDetailSheet(Sheet sheet, String dateRangeLabel,
|
||||
List<CompanyOverviewVO.CategoryComparison> dataList,
|
||||
List<CompanyOverviewVO.CategorySummary> dataList,
|
||||
BigDecimal taxRate) {
|
||||
CellStyle titleStyle = createTitleStyle(sheet.getWorkbook());
|
||||
CellStyle headerStyle = createHeaderStyle(sheet.getWorkbook());
|
||||
@@ -285,7 +285,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
}
|
||||
|
||||
int rowIdx = 2;
|
||||
for (CompanyOverviewVO.CategoryComparison data : dataList) {
|
||||
for (CompanyOverviewVO.CategorySummary data : dataList) {
|
||||
Row row = sheet.createRow(rowIdx++);
|
||||
setCell(row, 0, data.getCategoryName(), dataStyle);
|
||||
setCell(row, 1, objToDouble(data.getSalesAmount()), dataStyle);
|
||||
|
||||
+63
-63
@@ -232,14 +232,14 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
overviewVO.setShopEfficiencyQuadrants(shopEfficiencyQuadrants);
|
||||
|
||||
// 9. 多店铺数据横向汇总
|
||||
CompanyOverviewVO.ShopOverview shopOverview = calculateShopComparisons(
|
||||
CompanyOverviewVO.ShopOverview shopOverview = calculateShopSummary(
|
||||
shops, orders, promotionFees, brushOrders, stat, companyId, startDate, endDate);
|
||||
overviewVO.setShopComparisons(shopOverview);
|
||||
overviewVO.setShopSummary(shopOverview);
|
||||
|
||||
// 10. 多品类数据横向汇总
|
||||
CompanyOverviewVO.CategoryOverview categoryOverview = calculateCategoryComparisons(
|
||||
CompanyOverviewVO.CategoryOverview categoryOverview = calculateCategorySummary(
|
||||
orders, promotionFees, brushOrders, stat, companyId, startDate, endDate);
|
||||
overviewVO.setCategoryComparisons(categoryOverview);
|
||||
overviewVO.setCategorySummary(categoryOverview);
|
||||
|
||||
// 11. 平台维度汇总
|
||||
CompanyOverviewVO.PlatformOverview platformOverview = calculatePlatformSummary(
|
||||
@@ -470,10 +470,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
/**
|
||||
* 计算多店铺数据横向汇总
|
||||
*/
|
||||
private CompanyOverviewVO.ShopOverview calculateShopComparisons(
|
||||
private CompanyOverviewVO.ShopOverview calculateShopSummary(
|
||||
List<ShopPO> shops, List<OrderPO> orders, List<PromotionFeePO> promotionFees,
|
||||
List<BrushOrderPO> brushOrders, OrderStatusStatSets stat, Long companyId, LocalDate startDate, LocalDate endDate) {
|
||||
List<CompanyOverviewVO.ShopComparison> comparisons = new ArrayList<>();
|
||||
List<CompanyOverviewVO.ShopSummary> summaries = new ArrayList<>();
|
||||
|
||||
// 按店铺分组数据
|
||||
Map<Long, List<OrderPO>> ordersByShop = orders.stream()
|
||||
@@ -590,49 +590,49 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
orderCountAchievementRate = new BigDecimal("100");
|
||||
}
|
||||
|
||||
CompanyOverviewVO.ShopComparison comparison = new CompanyOverviewVO.ShopComparison();
|
||||
comparison.setShopId(shop.getId());
|
||||
comparison.setShopName(shop.getName());
|
||||
comparison.setPlatform(shop.getPlatformId() != null ? getPlatformNameById(shop.getPlatformId()) : null);
|
||||
comparison.setTargetOrderCount(targetOrderCount);
|
||||
comparison.setOrderCountAchievementRate(orderCountAchievementRate);
|
||||
comparison.setTargetAmount(targetAmount);
|
||||
comparison.setSalesAmountAchievementRate(salesAmountAchievementRate);
|
||||
comparison.setSalesAmount(salesAmount);
|
||||
comparison.setOrderCount(orderCount);
|
||||
comparison.setAverageOrderValue(averageOrderValue);
|
||||
comparison.setProductCost(productCost);
|
||||
comparison.setShippingCost(shippingCost);
|
||||
comparison.setOtherCost(otherCost);
|
||||
comparison.setTotalCost(productCost.add(shippingCost).add(otherCost));
|
||||
comparison.setRefundAmount(refundAmount);
|
||||
comparison.setTotalPromotionFee(totalPromotionFee);
|
||||
comparison.setBrushFee(brushFee);
|
||||
comparison.setFeeRatio(feeRatio);
|
||||
comparison.setTotalProfitBeforeTax(profitBeforeTax);
|
||||
comparison.setSalesTaxAmount(salesTaxAmount);
|
||||
comparison.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
|
||||
comparison.setRoi(roi);
|
||||
comparisons.add(comparison);
|
||||
CompanyOverviewVO.ShopSummary summary = new CompanyOverviewVO.ShopSummary();
|
||||
summary.setShopId(shop.getId());
|
||||
summary.setShopName(shop.getName());
|
||||
summary.setPlatform(shop.getPlatformId() != null ? getPlatformNameById(shop.getPlatformId()) : null);
|
||||
summary.setTargetOrderCount(targetOrderCount);
|
||||
summary.setOrderCountAchievementRate(orderCountAchievementRate);
|
||||
summary.setTargetAmount(targetAmount);
|
||||
summary.setSalesAmountAchievementRate(salesAmountAchievementRate);
|
||||
summary.setSalesAmount(salesAmount);
|
||||
summary.setOrderCount(orderCount);
|
||||
summary.setAverageOrderValue(averageOrderValue);
|
||||
summary.setProductCost(productCost);
|
||||
summary.setShippingCost(shippingCost);
|
||||
summary.setOtherCost(otherCost);
|
||||
summary.setTotalCost(productCost.add(shippingCost).add(otherCost));
|
||||
summary.setRefundAmount(refundAmount);
|
||||
summary.setTotalPromotionFee(totalPromotionFee);
|
||||
summary.setBrushFee(brushFee);
|
||||
summary.setFeeRatio(feeRatio);
|
||||
summary.setTotalProfitBeforeTax(profitBeforeTax);
|
||||
summary.setSalesTaxAmount(salesTaxAmount);
|
||||
summary.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
|
||||
summary.setRoi(roi);
|
||||
summaries.add(summary);
|
||||
}
|
||||
|
||||
// 按销售额降序排序
|
||||
comparisons.sort(Comparator.comparing(CompanyOverviewVO.ShopComparison::getSalesAmount).reversed());
|
||||
summaries.sort(Comparator.comparing(CompanyOverviewVO.ShopSummary::getSalesAmount).reversed());
|
||||
|
||||
// 计算合计行
|
||||
CompanyOverviewVO.ShopComparison total = computeShopTotal(comparisons);
|
||||
CompanyOverviewVO.ShopSummary total = computeShopTotal(summaries);
|
||||
|
||||
// 封装为 ShopOverview
|
||||
CompanyOverviewVO.ShopOverview overview = new CompanyOverviewVO.ShopOverview();
|
||||
overview.setTotal(total);
|
||||
overview.setShops(comparisons);
|
||||
overview.setShops(summaries);
|
||||
return overview;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算店铺汇总的合计行
|
||||
*/
|
||||
private CompanyOverviewVO.ShopComparison computeShopTotal(List<CompanyOverviewVO.ShopComparison> shops) {
|
||||
private CompanyOverviewVO.ShopSummary computeShopTotal(List<CompanyOverviewVO.ShopSummary> shops) {
|
||||
BigDecimal totalSales = BigDecimal.ZERO;
|
||||
int totalOrders = 0;
|
||||
BigDecimal totalTargetAmount = BigDecimal.ZERO;
|
||||
@@ -644,7 +644,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
BigDecimal totalPromoFee = BigDecimal.ZERO;
|
||||
BigDecimal totalBrushFee = BigDecimal.ZERO;
|
||||
|
||||
for (CompanyOverviewVO.ShopComparison s : shops) {
|
||||
for (CompanyOverviewVO.ShopSummary s : shops) {
|
||||
totalSales = totalSales.add(s.getSalesAmount() != null ? s.getSalesAmount() : BigDecimal.ZERO);
|
||||
totalOrders += s.getOrderCount() != null ? s.getOrderCount() : 0;
|
||||
totalTargetAmount = totalTargetAmount.add(s.getTargetAmount() != null ? s.getTargetAmount() : BigDecimal.ZERO);
|
||||
@@ -679,7 +679,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
.multiply(new BigDecimal("100"))
|
||||
: totalOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
|
||||
CompanyOverviewVO.ShopComparison total = new CompanyOverviewVO.ShopComparison();
|
||||
CompanyOverviewVO.ShopSummary total = new CompanyOverviewVO.ShopSummary();
|
||||
total.setShopId(0L);
|
||||
total.setShopName("合计");
|
||||
total.setSalesAmount(totalSales);
|
||||
@@ -776,7 +776,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
/**
|
||||
* Calculate category comparison data
|
||||
*/
|
||||
private CompanyOverviewVO.CategoryOverview calculateCategoryComparisons(
|
||||
private CompanyOverviewVO.CategoryOverview calculateCategorySummary(
|
||||
List<OrderPO> orders, List<PromotionFeePO> promotionFees,
|
||||
List<BrushOrderPO> brushOrders, OrderStatusStatSets stat, Long companyId,
|
||||
LocalDate startDate, LocalDate endDate) {
|
||||
@@ -828,7 +828,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
brush -> brush.getBrushAmount() != null ? brush.getBrushAmount() : BigDecimal.ZERO,
|
||||
BigDecimal::add)));
|
||||
|
||||
List<CompanyOverviewVO.CategoryComparison> comparisons = new ArrayList<>();
|
||||
List<CompanyOverviewVO.CategorySummary> summaries = new ArrayList<>();
|
||||
for (Map.Entry<Long, List<OrderPO>> entry : ordersByCategory.entrySet()) {
|
||||
Long categoryId = entry.getKey();
|
||||
List<OrderPO> categoryOrders = entry.getValue();
|
||||
@@ -902,43 +902,43 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
|
||||
String categoryName = categoryId == -1L ? "其他品类" : categoryNameMap.getOrDefault(categoryId, "Unknown");
|
||||
|
||||
CompanyOverviewVO.CategoryComparison comparison = new CompanyOverviewVO.CategoryComparison();
|
||||
comparison.setCategoryId(categoryId == -1L ? null : categoryId);
|
||||
comparison.setCategoryName(categoryName);
|
||||
comparison.setSalesAmount(salesAmount);
|
||||
comparison.setOrderCount(orderCount);
|
||||
comparison.setAverageOrderValue(averageOrderValue);
|
||||
comparison.setProductCost(productCost);
|
||||
comparison.setShippingCost(shippingCost);
|
||||
comparison.setOtherCost(otherCost);
|
||||
comparison.setTotalCost(totalCost);
|
||||
comparison.setRefundAmount(refundAmount);
|
||||
comparison.setTotalPromotionFee(totalPromotionFee);
|
||||
comparison.setBrushFee(totalBrushFee);
|
||||
comparison.setFeeRatio(feeRatio);
|
||||
comparison.setTotalProfitBeforeTax(profitBeforeTax);
|
||||
comparison.setSalesTaxAmount(salesTaxAmount);
|
||||
comparison.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
|
||||
comparison.setRoi(roi);
|
||||
comparisons.add(comparison);
|
||||
CompanyOverviewVO.CategorySummary summary = new CompanyOverviewVO.CategorySummary();
|
||||
summary.setCategoryId(categoryId == -1L ? null : categoryId);
|
||||
summary.setCategoryName(categoryName);
|
||||
summary.setSalesAmount(salesAmount);
|
||||
summary.setOrderCount(orderCount);
|
||||
summary.setAverageOrderValue(averageOrderValue);
|
||||
summary.setProductCost(productCost);
|
||||
summary.setShippingCost(shippingCost);
|
||||
summary.setOtherCost(otherCost);
|
||||
summary.setTotalCost(totalCost);
|
||||
summary.setRefundAmount(refundAmount);
|
||||
summary.setTotalPromotionFee(totalPromotionFee);
|
||||
summary.setBrushFee(totalBrushFee);
|
||||
summary.setFeeRatio(feeRatio);
|
||||
summary.setTotalProfitBeforeTax(profitBeforeTax);
|
||||
summary.setSalesTaxAmount(salesTaxAmount);
|
||||
summary.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
|
||||
summary.setRoi(roi);
|
||||
summaries.add(summary);
|
||||
}
|
||||
|
||||
comparisons.sort(Comparator.comparing(CompanyOverviewVO.CategoryComparison::getSalesAmount).reversed());
|
||||
summaries.sort(Comparator.comparing(CompanyOverviewVO.CategorySummary::getSalesAmount).reversed());
|
||||
|
||||
// 计算合计行
|
||||
CompanyOverviewVO.CategoryComparison total = computeCategoryTotal(comparisons);
|
||||
CompanyOverviewVO.CategorySummary total = computeCategoryTotal(summaries);
|
||||
|
||||
// 封装为 CategoryOverview
|
||||
CompanyOverviewVO.CategoryOverview overview = new CompanyOverviewVO.CategoryOverview();
|
||||
overview.setTotal(total);
|
||||
overview.setCategories(comparisons);
|
||||
overview.setCategories(summaries);
|
||||
return overview;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算品类汇总的合计行
|
||||
*/
|
||||
private CompanyOverviewVO.CategoryComparison computeCategoryTotal(List<CompanyOverviewVO.CategoryComparison> categories) {
|
||||
private CompanyOverviewVO.CategorySummary computeCategoryTotal(List<CompanyOverviewVO.CategorySummary> categories) {
|
||||
BigDecimal totalSales = BigDecimal.ZERO;
|
||||
int totalOrders = 0;
|
||||
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||
@@ -948,7 +948,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
BigDecimal totalPromoFee = BigDecimal.ZERO;
|
||||
BigDecimal totalBrushFee = BigDecimal.ZERO;
|
||||
|
||||
for (CompanyOverviewVO.CategoryComparison c : categories) {
|
||||
for (CompanyOverviewVO.CategorySummary c : categories) {
|
||||
totalSales = totalSales.add(c.getSalesAmount() != null ? c.getSalesAmount() : BigDecimal.ZERO);
|
||||
totalOrders += c.getOrderCount() != null ? c.getOrderCount() : 0;
|
||||
totalProductCost = totalProductCost.add(c.getProductCost() != null ? c.getProductCost() : BigDecimal.ZERO);
|
||||
@@ -974,7 +974,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
? totalPromoFee.add(totalBrushFee).divide(totalSales, 4, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
|
||||
CompanyOverviewVO.CategoryComparison total = new CompanyOverviewVO.CategoryComparison();
|
||||
CompanyOverviewVO.CategorySummary total = new CompanyOverviewVO.CategorySummary();
|
||||
total.setCategoryId(0L);
|
||||
total.setCategoryName("合计");
|
||||
total.setSalesAmount(totalSales);
|
||||
|
||||
+57
-57
@@ -248,12 +248,12 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
overviewVO.setOrderCountTrend(orderCountTrend);
|
||||
|
||||
// 10. 多商品数据横向汇总
|
||||
ShopOverviewStatisticsVO.ProductOverview productOverview = calculateProductComparisons(
|
||||
ShopOverviewStatisticsVO.ProductOverview productOverview = calculateProductSummary(
|
||||
orders, promotionFees, brushOrders, stat);
|
||||
overviewVO.setProductOverview(productOverview);
|
||||
|
||||
// 11. 品类多维度数据汇总
|
||||
ShopOverviewStatisticsVO.CategoryOverview categoryOverview = calculateCategoryComparisons(
|
||||
ShopOverviewStatisticsVO.CategoryOverview categoryOverview = calculateCategorySummary(
|
||||
orders, promotionFees, brushOrders, stat);
|
||||
overviewVO.setCategoryOverview(categoryOverview);
|
||||
|
||||
@@ -273,7 +273,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
}
|
||||
List<ShopOverviewStatisticsVO.ProductSalesRankItem> top10 = po.getProducts().stream()
|
||||
.sorted(Comparator.comparing(
|
||||
(ShopOverviewStatisticsVO.ProductComparison p) ->
|
||||
(ShopOverviewStatisticsVO.ProductSummary p) ->
|
||||
p.getOrderCount() != null ? p.getOrderCount() : 0,
|
||||
Comparator.reverseOrder()))
|
||||
.limit(10)
|
||||
@@ -414,10 +414,10 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
/**
|
||||
* 计算多商品数据横向汇总
|
||||
*/
|
||||
private ShopOverviewStatisticsVO.ProductOverview calculateProductComparisons(
|
||||
private ShopOverviewStatisticsVO.ProductOverview calculateProductSummary(
|
||||
List<OrderPO> orders, List<PromotionFeePO> promotionFees,
|
||||
List<BrushOrderPO> brushOrders, OrderStatusStatSets stat) {
|
||||
List<ShopOverviewStatisticsVO.ProductComparison> comparisons = new ArrayList<>();
|
||||
List<ShopOverviewStatisticsVO.ProductSummary> summaries = new ArrayList<>();
|
||||
|
||||
Map<Long, Long> specToProduct = orderSpecIdToProductIdMap(orders);
|
||||
Map<Long, List<OrderPO>> ordersByProduct = orders.stream()
|
||||
@@ -530,45 +530,45 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
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.setProductCost(productCost);
|
||||
comparison.setShippingCost(shippingCost);
|
||||
comparison.setOtherCost(otherCost);
|
||||
comparison.setTotalCost(productCost.add(shippingCost).add(otherCost));
|
||||
comparison.setRefundAmount(refundAmount);
|
||||
comparison.setTotalPromotionFee(productPromotionFee);
|
||||
comparison.setBrushFee(brushFee);
|
||||
comparison.setFeeRatio(feeRatio);
|
||||
comparison.setTotalProfitBeforeTax(profitBeforeTax);
|
||||
comparison.setSalesTaxAmount(salesTaxAmount);
|
||||
comparison.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
|
||||
comparison.setRoi(roi);
|
||||
comparisons.add(comparison);
|
||||
ShopOverviewStatisticsVO.ProductSummary summary = new ShopOverviewStatisticsVO.ProductSummary();
|
||||
summary.setProductId(productId);
|
||||
summary.setProductName(product.getName());
|
||||
summary.setProductCode(product.getProductCode());
|
||||
summary.setSalesAmount(salesAmount);
|
||||
summary.setOrderCount(orderCount);
|
||||
summary.setAverageOrderValue(averageOrderValue);
|
||||
summary.setProductCost(productCost);
|
||||
summary.setShippingCost(shippingCost);
|
||||
summary.setOtherCost(otherCost);
|
||||
summary.setTotalCost(productCost.add(shippingCost).add(otherCost));
|
||||
summary.setRefundAmount(refundAmount);
|
||||
summary.setTotalPromotionFee(productPromotionFee);
|
||||
summary.setBrushFee(brushFee);
|
||||
summary.setFeeRatio(feeRatio);
|
||||
summary.setTotalProfitBeforeTax(profitBeforeTax);
|
||||
summary.setSalesTaxAmount(salesTaxAmount);
|
||||
summary.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
|
||||
summary.setRoi(roi);
|
||||
summaries.add(summary);
|
||||
}
|
||||
|
||||
// 按销售额降序排序
|
||||
comparisons.sort(Comparator.comparing(ShopOverviewStatisticsVO.ProductComparison::getSalesAmount).reversed());
|
||||
summaries.sort(Comparator.comparing(ShopOverviewStatisticsVO.ProductSummary::getSalesAmount).reversed());
|
||||
|
||||
// 计算合计行
|
||||
ShopOverviewStatisticsVO.ProductComparison total = computeProductTotal(comparisons);
|
||||
ShopOverviewStatisticsVO.ProductSummary total = computeProductTotal(summaries);
|
||||
|
||||
// 封装为 ProductOverview
|
||||
ShopOverviewStatisticsVO.ProductOverview overview = new ShopOverviewStatisticsVO.ProductOverview();
|
||||
overview.setTotal(total);
|
||||
overview.setProducts(comparisons);
|
||||
overview.setProducts(summaries);
|
||||
return overview;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算商品汇总的合计行
|
||||
*/
|
||||
private ShopOverviewStatisticsVO.ProductComparison computeProductTotal(List<ShopOverviewStatisticsVO.ProductComparison> products) {
|
||||
private ShopOverviewStatisticsVO.ProductSummary computeProductTotal(List<ShopOverviewStatisticsVO.ProductSummary> products) {
|
||||
BigDecimal totalSales = BigDecimal.ZERO;
|
||||
int totalOrders = 0;
|
||||
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||
@@ -578,7 +578,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
BigDecimal totalPromoFee = BigDecimal.ZERO;
|
||||
BigDecimal totalBrushFee = BigDecimal.ZERO;
|
||||
|
||||
for (ShopOverviewStatisticsVO.ProductComparison p : products) {
|
||||
for (ShopOverviewStatisticsVO.ProductSummary p : products) {
|
||||
totalSales = totalSales.add(p.getSalesAmount() != null ? p.getSalesAmount() : BigDecimal.ZERO);
|
||||
totalOrders += p.getOrderCount() != null ? p.getOrderCount() : 0;
|
||||
totalProductCost = totalProductCost.add(p.getProductCost() != null ? p.getProductCost() : BigDecimal.ZERO);
|
||||
@@ -604,7 +604,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
? totalPromoFee.add(totalBrushFee).divide(totalSales, 4, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
|
||||
ShopOverviewStatisticsVO.ProductComparison total = new ShopOverviewStatisticsVO.ProductComparison();
|
||||
ShopOverviewStatisticsVO.ProductSummary total = new ShopOverviewStatisticsVO.ProductSummary();
|
||||
total.setProductId(0L);
|
||||
total.setProductName("合计");
|
||||
total.setSalesAmount(totalSales);
|
||||
@@ -719,7 +719,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
/**
|
||||
* 计算品类多维度数据汇总
|
||||
*/
|
||||
private ShopOverviewStatisticsVO.CategoryOverview calculateCategoryComparisons(
|
||||
private ShopOverviewStatisticsVO.CategoryOverview calculateCategorySummary(
|
||||
List<OrderPO> orders, List<PromotionFeePO> promotionFees,
|
||||
List<BrushOrderPO> brushOrders, OrderStatusStatSets stat) {
|
||||
|
||||
@@ -783,7 +783,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
// 按品类聚合
|
||||
List<ShopOverviewStatisticsVO.CategoryComparison> results = new ArrayList<>();
|
||||
List<ShopOverviewStatisticsVO.CategorySummary> results = new ArrayList<>();
|
||||
for (Map.Entry<Long, List<OrderPO>> entry : ordersByCategory.entrySet()) {
|
||||
Long categoryId = entry.getKey();
|
||||
List<OrderPO> catOrders = entry.getValue();
|
||||
@@ -849,31 +849,31 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
? salesAmount.divide(new BigDecimal(orderCount), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
|
||||
ShopOverviewStatisticsVO.CategoryComparison cc = new ShopOverviewStatisticsVO.CategoryComparison();
|
||||
cc.setCategoryId(categoryId);
|
||||
cc.setCategoryName(categoryId == 0L ? "未分类" : categoryMap.get(categoryId).getName());
|
||||
cc.setSalesAmount(salesAmount);
|
||||
cc.setOrderCount(orderCount);
|
||||
cc.setAverageOrderValue(averageOrderValue);
|
||||
cc.setProductCost(productCost);
|
||||
cc.setShippingCost(shippingCost);
|
||||
cc.setOtherCost(otherCost);
|
||||
cc.setTotalCost(totalCost);
|
||||
cc.setRefundAmount(refundAmount);
|
||||
cc.setTotalPromotionFee(catPromotionFee);
|
||||
cc.setBrushFee(catBrushFee);
|
||||
cc.setFeeRatio(feeRatio);
|
||||
cc.setTotalProfitBeforeTax(profitBeforeTax);
|
||||
cc.setSalesTaxAmount(salesTaxAmount);
|
||||
cc.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
|
||||
cc.setRoi(roi);
|
||||
results.add(cc);
|
||||
ShopOverviewStatisticsVO.CategorySummary summary = new ShopOverviewStatisticsVO.CategorySummary();
|
||||
summary.setCategoryId(categoryId);
|
||||
summary.setCategoryName(categoryId == 0L ? "未分类" : categoryMap.get(categoryId).getName());
|
||||
summary.setSalesAmount(salesAmount);
|
||||
summary.setOrderCount(orderCount);
|
||||
summary.setAverageOrderValue(averageOrderValue);
|
||||
summary.setProductCost(productCost);
|
||||
summary.setShippingCost(shippingCost);
|
||||
summary.setOtherCost(otherCost);
|
||||
summary.setTotalCost(totalCost);
|
||||
summary.setRefundAmount(refundAmount);
|
||||
summary.setTotalPromotionFee(catPromotionFee);
|
||||
summary.setBrushFee(catBrushFee);
|
||||
summary.setFeeRatio(feeRatio);
|
||||
summary.setTotalProfitBeforeTax(profitBeforeTax);
|
||||
summary.setSalesTaxAmount(salesTaxAmount);
|
||||
summary.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
|
||||
summary.setRoi(roi);
|
||||
results.add(summary);
|
||||
}
|
||||
|
||||
results.sort(Comparator.comparing(ShopOverviewStatisticsVO.CategoryComparison::getSalesAmount).reversed());
|
||||
results.sort(Comparator.comparing(ShopOverviewStatisticsVO.CategorySummary::getSalesAmount).reversed());
|
||||
|
||||
// 计算合计行
|
||||
ShopOverviewStatisticsVO.CategoryComparison total = computeCategoryTotalForShop(results);
|
||||
ShopOverviewStatisticsVO.CategorySummary total = computeCategoryTotalForShop(results);
|
||||
|
||||
// 封装为 CategoryOverview
|
||||
ShopOverviewStatisticsVO.CategoryOverview overview = new ShopOverviewStatisticsVO.CategoryOverview();
|
||||
@@ -885,7 +885,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
/**
|
||||
* 计算店铺视角品类汇总的合计行
|
||||
*/
|
||||
private ShopOverviewStatisticsVO.CategoryComparison computeCategoryTotalForShop(List<ShopOverviewStatisticsVO.CategoryComparison> categories) {
|
||||
private ShopOverviewStatisticsVO.CategorySummary computeCategoryTotalForShop(List<ShopOverviewStatisticsVO.CategorySummary> categories) {
|
||||
BigDecimal totalSales = BigDecimal.ZERO;
|
||||
int totalOrders = 0;
|
||||
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||
@@ -895,7 +895,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
BigDecimal totalPromoFee = BigDecimal.ZERO;
|
||||
BigDecimal totalBrushFee = BigDecimal.ZERO;
|
||||
|
||||
for (ShopOverviewStatisticsVO.CategoryComparison c : categories) {
|
||||
for (ShopOverviewStatisticsVO.CategorySummary c : categories) {
|
||||
totalSales = totalSales.add(c.getSalesAmount() != null ? c.getSalesAmount() : BigDecimal.ZERO);
|
||||
totalOrders += c.getOrderCount() != null ? c.getOrderCount() : 0;
|
||||
totalProductCost = totalProductCost.add(c.getProductCost() != null ? c.getProductCost() : BigDecimal.ZERO);
|
||||
@@ -921,7 +921,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
|
||||
? totalPromoFee.add(totalBrushFee).divide(totalSales, 4, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
|
||||
ShopOverviewStatisticsVO.CategoryComparison total = new ShopOverviewStatisticsVO.CategoryComparison();
|
||||
ShopOverviewStatisticsVO.CategorySummary total = new ShopOverviewStatisticsVO.CategorySummary();
|
||||
total.setCategoryId(0L);
|
||||
total.setCategoryName("合计");
|
||||
total.setSalesAmount(totalSales);
|
||||
|
||||
+2
-2
@@ -190,7 +190,7 @@ public class ShopExportServiceImpl implements ShopExportService {
|
||||
}
|
||||
|
||||
private void createProductDetailSheetFromVO(Sheet sheet, String dateRangeLabel,
|
||||
List<ShopOverviewStatisticsVO.ProductComparison> products,
|
||||
List<ShopOverviewStatisticsVO.ProductSummary> products,
|
||||
BigDecimal taxRate) {
|
||||
Row titleRow = sheet.createRow(0);
|
||||
Cell titleCell = titleRow.createCell(0);
|
||||
@@ -216,7 +216,7 @@ public class ShopExportServiceImpl implements ShopExportService {
|
||||
}
|
||||
|
||||
int rowIdx = 2;
|
||||
for (ShopOverviewStatisticsVO.ProductComparison p : products) {
|
||||
for (ShopOverviewStatisticsVO.ProductSummary p : products) {
|
||||
Row row = sheet.createRow(rowIdx++);
|
||||
setCell(row, 0, p.getProductName() + (p.getProductCode() != null ? "\n编码: " + p.getProductCode() : ""), dataStyle);
|
||||
setCell(row, 1, nvl(p.getSalesAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
|
||||
|
||||
@@ -113,7 +113,7 @@ export namespace ShopVO {
|
||||
}
|
||||
|
||||
/** 商品汇总数据 */
|
||||
export interface ProductComparison {
|
||||
export interface ProductSummary {
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 商品名称 */
|
||||
@@ -153,7 +153,7 @@ export namespace ShopVO {
|
||||
}
|
||||
|
||||
/** 品类汇总数据 */
|
||||
export interface CategoryComparison {
|
||||
export interface CategorySummary {
|
||||
/** 品类ID */
|
||||
categoryId: number;
|
||||
/** 品类名称 */
|
||||
@@ -209,17 +209,17 @@ export namespace ShopVO {
|
||||
/** 商品概览(含合计行和商品列表) */
|
||||
export interface ProductOverview {
|
||||
/** 合计行 */
|
||||
total: ProductComparison;
|
||||
total: ProductSummary;
|
||||
/** 各商品汇总列表 */
|
||||
products: ProductComparison[];
|
||||
products: ProductSummary[];
|
||||
}
|
||||
|
||||
/** 品类概览(含合计行和品类列表) */
|
||||
export interface CategoryOverview {
|
||||
/** 合计行 */
|
||||
total: CategoryComparison;
|
||||
total: CategorySummary;
|
||||
/** 各品类汇总列表 */
|
||||
categories: CategoryComparison[];
|
||||
categories: CategorySummary[];
|
||||
}
|
||||
|
||||
// ========== 店铺详情看板 ==========
|
||||
|
||||
@@ -28,9 +28,9 @@ export namespace CompanyOverviewVO {
|
||||
/** 单量趋势分析 */
|
||||
orderCountTrend?: TrendData;
|
||||
/** 多店铺数据横向汇总 */
|
||||
shopComparisons?: ShopOverview;
|
||||
shopSummary?: ShopOverview;
|
||||
/** 多品类数据横向汇总 */
|
||||
categoryComparisons?: CategoryOverview;
|
||||
categorySummary?: CategoryOverview;
|
||||
/** 平台维度概览(包含合计行和平台列表) */
|
||||
platformSummary?: PlatformOverview;
|
||||
/** 汇总ROI */
|
||||
@@ -90,7 +90,7 @@ export namespace CompanyOverviewVO {
|
||||
}
|
||||
|
||||
/** 店铺汇总数据(16维度) */
|
||||
export interface ShopComparison {
|
||||
export interface ShopSummary {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 店铺名称 */
|
||||
@@ -138,7 +138,7 @@ export namespace CompanyOverviewVO {
|
||||
}
|
||||
|
||||
/** 品类汇总数据 */
|
||||
export interface CategoryComparison {
|
||||
export interface CategorySummary {
|
||||
/** 品类ID(未分配为null) */
|
||||
categoryId?: number;
|
||||
/** 品类名称(未分配为"未分配品类") */
|
||||
@@ -232,16 +232,16 @@ export namespace CompanyOverviewVO {
|
||||
/** 多店铺概览 */
|
||||
export interface ShopOverview {
|
||||
/** 合计行 */
|
||||
total: ShopComparison;
|
||||
total: ShopSummary;
|
||||
/** 各店铺汇总列表 */
|
||||
shops: ShopComparison[];
|
||||
shops: ShopSummary[];
|
||||
}
|
||||
|
||||
/** 多品类概览 */
|
||||
export interface CategoryOverview {
|
||||
/** 合计行 */
|
||||
total: CategoryComparison;
|
||||
total: CategorySummary;
|
||||
/** 各品类汇总列表 */
|
||||
categories: CategoryComparison[];
|
||||
categories: CategorySummary[];
|
||||
}
|
||||
}
|
||||
|
||||
+22
-22
@@ -15,7 +15,7 @@ import {
|
||||
defineOptions({ name: 'CategoryComparisonTable' });
|
||||
|
||||
interface Props {
|
||||
categoryComparisons?: CompanyOverviewVO.CategoryOverview;
|
||||
categorySummary?: CompanyOverviewVO.CategoryOverview;
|
||||
taxRate: number;
|
||||
categoryExportMode?: boolean;
|
||||
selectedExportCategoryIds?: number[];
|
||||
@@ -35,7 +35,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const allCategoriesSelected = computed(() => {
|
||||
const total = props.categoryComparisons?.categories?.length || 0;
|
||||
const total = props.categorySummary?.categories?.length || 0;
|
||||
return total > 0 && props.selectedExportCategoryIds.length === total;
|
||||
});
|
||||
|
||||
@@ -122,7 +122,7 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
'update:selectedExportCategoryIds',
|
||||
allCategoriesSelected
|
||||
? []
|
||||
: (categoryComparisons?.categories ?? []).map((c) => c.categoryId!)
|
||||
: (categorySummary?.categories ?? []).map((c) => c.categoryId!)
|
||||
)
|
||||
"
|
||||
/>
|
||||
@@ -210,7 +210,7 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
||||
<tr
|
||||
v-for="cat in (categoryComparisons?.categories || [])"
|
||||
v-for="cat in (categorySummary?.categories || [])"
|
||||
:key="cat.categoryId ?? 'uncategorized'"
|
||||
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
||||
>
|
||||
@@ -274,39 +274,39 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
{{ cellMoney(cat.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!categoryComparisons?.categories?.length">
|
||||
<tr v-if="!categorySummary?.categories?.length">
|
||||
<td :colspan="categoryExportMode ? 18 : 17" class="p-8 text-center text-gray-400">
|
||||
暂无数据
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<!-- 合计行 -->
|
||||
<tfoot v-if="categoryComparisons?.total" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
<tfoot v-if="categorySummary?.total" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td class="p-6 text-base">合计</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(categoryComparisons?.total?.orderCount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(categorySummary?.total?.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(categoryComparisons?.total?.averageOrderValue) }}
|
||||
{{ cellMoney(categorySummary?.total?.averageOrderValue) }}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(categoryComparisons?.total?.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(categoryComparisons?.total?.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(categoryComparisons?.total?.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categoryComparisons?.total?.feeRatio !== undefined ? formatFeeRatioPercent(categoryComparisons?.total?.feeRatio) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(categorySummary?.total?.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(categorySummary?.total?.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(categorySummary?.total?.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categorySummary?.total?.feeRatio !== undefined ? formatFeeRatioPercent(categorySummary?.total?.feeRatio) : '-' }}</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(categoryComparisons?.total?.salesTaxAmount) }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ cellRoi(categoryComparisons?.total?.roi) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(categorySummary?.total?.salesTaxAmount) }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ cellRoi(categorySummary?.total?.roi) }}</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(categoryComparisons?.total?.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-700 dark:text-emerald-300'"
|
||||
>{{ cellMoney(categoryComparisons?.total?.profitAfterTax) }}</td>
|
||||
:class="(categorySummary?.total?.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-700 dark:text-emerald-300'"
|
||||
>{{ cellMoney(categorySummary?.total?.profitAfterTax) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
+4
-4
@@ -16,10 +16,10 @@ interface Props {
|
||||
platformSummary?: CompanyOverviewVO.PlatformOverview;
|
||||
platformExportMode: boolean;
|
||||
selectedExportPlatformIds: number[];
|
||||
shopComparisons?: CompanyOverviewVO.ShopOverview;
|
||||
shopSummary?: CompanyOverviewVO.ShopOverview;
|
||||
shopExportMode: boolean;
|
||||
selectedExportShopIds: number[];
|
||||
categoryComparisons?: CompanyOverviewVO.CategoryOverview;
|
||||
categorySummary?: CompanyOverviewVO.CategoryOverview;
|
||||
categoryExportMode: boolean;
|
||||
selectedExportCategoryIds: number[];
|
||||
}
|
||||
@@ -83,7 +83,7 @@ const modeOptions = [
|
||||
|
||||
<ShopComparisonTable
|
||||
v-if="activeMode === 'shop'"
|
||||
:shop-comparisons="props.shopComparisons"
|
||||
:shop-summary="props.shopSummary"
|
||||
:tax-rate="props.taxRate"
|
||||
:shop-export-mode="props.shopExportMode"
|
||||
:selected-export-shop-ids="props.selectedExportShopIds"
|
||||
@@ -97,7 +97,7 @@ const modeOptions = [
|
||||
|
||||
<CategoryComparisonTable
|
||||
v-if="activeMode === 'category'"
|
||||
:category-comparisons="props.categoryComparisons"
|
||||
:category-summary="props.categorySummary"
|
||||
:tax-rate="props.taxRate"
|
||||
:category-export-mode="props.categoryExportMode"
|
||||
:selected-export-category-ids="props.selectedExportCategoryIds"
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ defineOptions({ name: 'ShopCharts' });
|
||||
|
||||
interface Props {
|
||||
shopSalesRatios?: CompanyOverviewVO.ShopSalesRatio[];
|
||||
shopComparisons?: CompanyOverviewVO.ShopOverview;
|
||||
shopSummary?: CompanyOverviewVO.ShopOverview;
|
||||
salesAmountTrend?: CompanyOverviewVO.TrendData;
|
||||
orderCountTrend?: CompanyOverviewVO.TrendData;
|
||||
}
|
||||
|
||||
+28
-28
@@ -15,7 +15,7 @@ import {
|
||||
defineOptions({ name: 'ShopComparisonTable' });
|
||||
|
||||
interface Props {
|
||||
shopComparisons?: CompanyOverviewVO.ShopOverview;
|
||||
shopSummary?: CompanyOverviewVO.ShopOverview;
|
||||
taxRate: number;
|
||||
shopExportMode: boolean;
|
||||
selectedExportShopIds: number[];
|
||||
@@ -32,7 +32,7 @@ const props = defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const allShopsSelected = computed(() => {
|
||||
const total = props.shopComparisons?.shops?.length || 0;
|
||||
const total = props.shopSummary?.shops?.length || 0;
|
||||
return total > 0 && props.selectedExportShopIds.length === total;
|
||||
});
|
||||
const someShopsSelected = computed(() => {
|
||||
@@ -122,7 +122,7 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
if ((e.target as HTMLInputElement).checked) {
|
||||
emit(
|
||||
'update:selectedExportShopIds',
|
||||
shopComparisons?.shops?.map((s) => s.shopId) || [],
|
||||
shopSummary?.shops?.map((s) => s.shopId) || [],
|
||||
);
|
||||
} else {
|
||||
emit('update:selectedExportShopIds', []);
|
||||
@@ -247,7 +247,7 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
||||
<tr
|
||||
v-for="shop in (shopComparisons?.shops || [])"
|
||||
v-for="shop in (shopSummary?.shops || [])"
|
||||
:key="shop.shopId"
|
||||
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
||||
>
|
||||
@@ -355,56 +355,56 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
{{ cellMoney(shop.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!shopComparisons?.shops?.length">
|
||||
<tr v-if="!shopSummary?.shops?.length">
|
||||
<td :colspan="shopExportMode ? 22 : 21" class="p-8 text-center text-gray-400">
|
||||
暂无数据
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<!-- 合计行 -->
|
||||
<tfoot v-if="shopComparisons?.total" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
<tfoot v-if="shopSummary?.total" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td class="p-6 text-base" :class="shopExportMode ? 'border-l-0' : ''">合计</td>
|
||||
<!-- 目标 -->
|
||||
<td class="p-6">{{ formatIntCell(shopComparisons?.total?.targetOrderCount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(shopSummary?.total?.targetOrderCount) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
shopComparisons?.total?.orderCountAchievementRate !== undefined
|
||||
? formatPercentPlain(shopComparisons?.total?.orderCountAchievementRate)
|
||||
shopSummary?.total?.orderCountAchievementRate !== undefined
|
||||
? formatPercentPlain(shopSummary?.total?.orderCountAchievementRate)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.targetAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.targetAmount) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
shopComparisons?.total?.salesAmountAchievementRate !== undefined
|
||||
? formatPercentPlain(shopComparisons?.total?.salesAmountAchievementRate)
|
||||
shopSummary?.total?.salesAmountAchievementRate !== undefined
|
||||
? formatPercentPlain(shopSummary?.total?.salesAmountAchievementRate)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(shopComparisons?.total?.orderCount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(shopSummary?.total?.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shopComparisons?.total?.averageOrderValue) }}
|
||||
{{ cellMoney(shopSummary?.total?.averageOrderValue) }}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(shopComparisons?.total?.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(shopComparisons?.total?.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(shopComparisons?.total?.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopComparisons?.total?.feeRatio !== undefined ? formatFeeRatioPercent(shopComparisons?.total?.feeRatio) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(shopSummary?.total?.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(shopSummary?.total?.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(shopSummary?.total?.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopSummary?.total?.feeRatio !== undefined ? formatFeeRatioPercent(shopSummary?.total?.feeRatio) : '-' }}</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(shopComparisons?.total?.salesTaxAmount) }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ cellRoi(shopComparisons?.total?.roi) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(shopSummary?.total?.salesTaxAmount) }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ cellRoi(shopSummary?.total?.roi) }}</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(shopComparisons?.total?.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-700 dark:text-emerald-300'"
|
||||
>{{ cellMoney(shopComparisons?.total?.profitAfterTax) }}</td>
|
||||
:class="(shopSummary?.total?.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-700 dark:text-emerald-300'"
|
||||
>{{ cellMoney(shopSummary?.total?.profitAfterTax) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
@@ -325,9 +325,9 @@ const handleExportCompanyOverview = async () => {
|
||||
exportLoading.value = true;
|
||||
const [startDate, endDate] = dateRange.value;
|
||||
|
||||
let dataToExport: CompanyOverviewVO.ShopComparison[] = [];
|
||||
if (overviewData.value?.shopComparisons) {
|
||||
const shops = overviewData.value.shopComparisons.shops;
|
||||
let dataToExport: CompanyOverviewVO.ShopSummary[] = [];
|
||||
if (overviewData.value?.shopSummary) {
|
||||
const shops = overviewData.value.shopSummary.shops;
|
||||
dataToExport =
|
||||
selectedExportShopIds.value.length > 0
|
||||
? shops.filter((s) =>
|
||||
@@ -554,7 +554,7 @@ const navigateToShopOverview = (shopId: number) => {
|
||||
<ShopCharts
|
||||
ref="shopChartsRef"
|
||||
:shop-sales-ratios="overviewData?.shopSalesRatios"
|
||||
:shop-comparisons="overviewData?.shopComparisons"
|
||||
:shop-summary="overviewData?.shopSummary"
|
||||
:sales-amount-trend="overviewData?.salesAmountTrend"
|
||||
:order-count-trend="overviewData?.orderCountTrend"
|
||||
/>
|
||||
@@ -565,10 +565,10 @@ const navigateToShopOverview = (shopId: number) => {
|
||||
:platform-summary="overviewData?.platformSummary"
|
||||
:platform-export-mode="platformExportMode"
|
||||
:selected-export-platform-ids="selectedExportPlatformIds"
|
||||
:shop-comparisons="overviewData?.shopComparisons"
|
||||
:shop-summary="overviewData?.shopSummary"
|
||||
:shop-export-mode="shopExportMode"
|
||||
:selected-export-shop-ids="selectedExportShopIds"
|
||||
:category-comparisons="overviewData?.categoryComparisons"
|
||||
:category-summary="overviewData?.categorySummary"
|
||||
:category-export-mode="categoryExportMode"
|
||||
:selected-export-category-ids="selectedExportCategoryIds"
|
||||
@update:selected-export-platform-ids="(ids) => (selectedExportPlatformIds = ids)"
|
||||
|
||||
@@ -252,7 +252,7 @@ const handleCategorySelectAllChange = (event: Event) => {
|
||||
const target = event.target as HTMLInputElement | null;
|
||||
if (!target) return;
|
||||
selectedExportCategoryIds.value = target.checked
|
||||
? (overviewData.value?.categoryOverview?.categories?.map((c: ShopVO.CategoryComparison) => c.categoryId) ?? [])
|
||||
? (overviewData.value?.categoryOverview?.categories?.map((c: ShopVO.CategorySummary) => c.categoryId) ?? [])
|
||||
: [];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user