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