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:
小蟑螂
2026-05-08 02:10:21 +08:00
co-authored by Claude Opus 4.7
parent 499881514e
commit 7761667904
14 changed files with 217 additions and 217 deletions
@@ -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;
@@ -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;
@@ -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);
@@ -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);
@@ -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);
@@ -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);