refactor: 经营概览汇总表统一成交/净销售六列规模字段并同步前后端导出与对比

This commit is contained in:
2026-08-26 10:38:56 +08:00
parent a329ebdba5
commit 216536815c
19 changed files with 504 additions and 247 deletions
@@ -226,9 +226,17 @@ public class CompanyOverviewVO {
private BigDecimal dealAmount;
private Integer orderCount;
/** 净销售单量 = 成交单量 − 退款单量 */
private Integer salesOrderCount;
private BigDecimal averageOrderValue;
/** 成交单量 */
private Integer dealOrderCount;
/** 净销售客单价 = 净销售额 / 净销售单量 */
private BigDecimal salesAverageOrderValue;
/** 成交客单价 = 成交金额 / 成交单量 */
private BigDecimal dealAverageOrderValue;
private BigDecimal productCost;
@@ -270,9 +278,17 @@ public class CompanyOverviewVO {
private BigDecimal dealAmount;
private Integer orderCount;
/** 净销售单量 = 成交单量 − 退款单量 */
private Integer salesOrderCount;
private BigDecimal averageOrderValue;
/** 成交单量 */
private Integer dealOrderCount;
/** 净销售客单价 = 净销售额 / 净销售单量 */
private BigDecimal salesAverageOrderValue;
/** 成交客单价 = 成交金额 / 成交单量 */
private BigDecimal dealAverageOrderValue;
private BigDecimal productCost;
@@ -322,9 +338,17 @@ public class CompanyOverviewVO {
private BigDecimal dealAmount;
private Integer orderCount;
/** 净销售单量 = 成交单量 − 退款单量 */
private Integer salesOrderCount;
private BigDecimal averageOrderValue;
/** 成交单量 */
private Integer dealOrderCount;
/** 净销售客单价 = 净销售额 / 净销售单量 */
private BigDecimal salesAverageOrderValue;
/** 成交客单价 = 成交金额 / 成交单量 */
private BigDecimal dealAverageOrderValue;
private BigDecimal productCost;
@@ -232,8 +232,11 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
s.setCategoryId(c.getCategoryId() != null ? c.getCategoryId() : 0L);
s.setCategoryName(c.getCategoryName());
s.setSalesAmount(c.getSalesAmount());
s.setOrderCount(c.getOrderCount());
s.setAverageOrderValue(c.getAverageOrderValue());
s.setDealAmount(c.getDealAmount());
s.setSalesOrderCount(c.getSalesOrderCount());
s.setDealOrderCount(c.getDealOrderCount());
s.setSalesAverageOrderValue(c.getSalesAverageOrderValue());
s.setDealAverageOrderValue(c.getDealAverageOrderValue());
s.setProductCost(c.getProductCost());
s.setShippingCost(c.getShippingCost());
s.setOtherCost(c.getOtherCost());
@@ -253,7 +256,9 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
private ShopOverviewStatisticsVO.CategorySummary aggregateCategoryTotals(
List<ShopOverviewStatisticsVO.CategorySummary> categories, BigDecimal taxRate) {
BigDecimal totalSales = BigDecimal.ZERO;
int totalOrders = 0;
BigDecimal totalDealAmount = BigDecimal.ZERO;
int totalSalesOrders = 0;
int totalDealOrders = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
BigDecimal totalShippingCost = BigDecimal.ZERO;
BigDecimal totalOtherCost = BigDecimal.ZERO;
@@ -263,7 +268,9 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
for (ShopOverviewStatisticsVO.CategorySummary c : categories) {
totalSales = totalSales.add(c.getSalesAmount() != null ? c.getSalesAmount() : BigDecimal.ZERO);
totalOrders += c.getOrderCount() != null ? c.getOrderCount() : 0;
totalDealAmount = totalDealAmount.add(c.getDealAmount() != null ? c.getDealAmount() : BigDecimal.ZERO);
totalSalesOrders += c.getSalesOrderCount() != null ? c.getSalesOrderCount() : 0;
totalDealOrders += c.getDealOrderCount() != null ? c.getDealOrderCount() : 0;
totalProductCost = totalProductCost.add(c.getProductCost() != null ? c.getProductCost() : BigDecimal.ZERO);
totalShippingCost = totalShippingCost.add(c.getShippingCost() != null ? c.getShippingCost() : BigDecimal.ZERO);
totalOtherCost = totalOtherCost.add(c.getOtherCost() != null ? c.getOtherCost() : BigDecimal.ZERO);
@@ -272,8 +279,11 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
totalBrushFee = totalBrushFee.add(c.getBrushFee() != null ? c.getBrushFee() : BigDecimal.ZERO);
}
BigDecimal avgOrderValue = totalOrders > 0
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
? totalSales.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal dealAvgOrderValue = totalDealOrders > 0
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
BigDecimal profitBeforeTax = totalSales.subtract(totalCost)
@@ -291,8 +301,11 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
total.setCategoryId(0L);
total.setCategoryName("合计");
total.setSalesAmount(totalSales);
total.setOrderCount(totalOrders);
total.setAverageOrderValue(avgOrderValue);
total.setDealAmount(totalDealAmount);
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setProductCost(totalProductCost);
total.setShippingCost(totalShippingCost);
total.setOtherCost(totalOtherCost);
@@ -328,7 +341,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
String taxHeader = taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP).toPlainString()
+ "%税额";
String[] headers = {
dimensionColumnHeader, "净销售额", "单量", "客单价",
dimensionColumnHeader, "成交金额", "净销售额", "成交单量", "净销售单量", "成交客单价", "净销售客单价",
"商品成本", "运费", "其他成本", "订单成本", "退款金额", taxHeader, "推广费", "刷单费",
"税前盈亏", "费比 %", "ROI", "税后盈亏"
};
@@ -363,27 +376,32 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
private void fillCategoryDataRow(
Row row, ShopOverviewStatisticsVO.CategorySummary d, CellStyle style, BigDecimal taxRate) {
setCell(row, 0, d.getCategoryName() != null ? d.getCategoryName() : "", style);
setCell(row, 1, bd2Money(d.getSalesAmount()), style);
Cell oc = row.createCell(2);
oc.setCellStyle(style);
oc.setCellValue(d.getOrderCount() != null ? d.getOrderCount() : 0);
setCell(row, 3, bd2Money(d.getAverageOrderValue()), style);
setCell(row, 4, bd2Money(d.getProductCost()), style);
setCell(row, 5, bd2Money(d.getShippingCost()), style);
setCell(row, 6, bd2Money(d.getOtherCost()), style);
setCell(row, 7, bd2Money(d.getOrderCost()), style);
setCell(row, 1, bd2Money(d.getDealAmount()), style);
setCell(row, 2, bd2Money(d.getSalesAmount()), style);
Cell dealOc = row.createCell(3);
dealOc.setCellStyle(style);
dealOc.setCellValue(d.getDealOrderCount() != null ? d.getDealOrderCount() : 0);
Cell salesOc = row.createCell(4);
salesOc.setCellStyle(style);
salesOc.setCellValue(d.getSalesOrderCount() != null ? d.getSalesOrderCount() : 0);
setCell(row, 5, bd2Money(d.getDealAverageOrderValue()), style);
setCell(row, 6, bd2Money(d.getSalesAverageOrderValue()), style);
setCell(row, 7, bd2Money(d.getProductCost()), style);
setCell(row, 8, bd2Money(d.getShippingCost()), style);
setCell(row, 9, bd2Money(d.getOtherCost()), style);
setCell(row, 10, bd2Money(d.getOrderCost()), style);
BigDecimal salesTax = salesTaxOnNetForCategoryExport(d.getSalesAmount(), taxRate);
BigDecimal profitAfterTax = (d.getTotalProfitBeforeTax() != null ? d.getTotalProfitBeforeTax() : BigDecimal.ZERO)
.subtract(salesTax)
.setScale(2, RoundingMode.HALF_UP);
setCell(row, 8, bd2Money(d.getRefundAmount()), style);
setCell(row, 9, bd2Money(salesTax), style);
setCell(row, 10, bd2Money(d.getTotalPromotionFee()), style);
setCell(row, 11, bd2Money(d.getBrushFee()), style);
setCell(row, 12, bd2Money(d.getTotalProfitBeforeTax()), style);
setCell(row, 13, bd2FeeRatioPercent(d.getFeeRatio()), style);
setCell(row, 14, bd2Roi(d.getRoi()), style);
setCell(row, 15, bd2Money(profitAfterTax), style);
setCell(row, 11, bd2Money(d.getRefundAmount()), style);
setCell(row, 12, bd2Money(salesTax), style);
setCell(row, 13, bd2Money(d.getTotalPromotionFee()), style);
setCell(row, 14, bd2Money(d.getBrushFee()), style);
setCell(row, 15, bd2Money(d.getTotalProfitBeforeTax()), style);
setCell(row, 16, bd2FeeRatioPercent(d.getFeeRatio()), style);
setCell(row, 17, bd2Roi(d.getRoi()), style);
setCell(row, 18, bd2Money(profitAfterTax), style);
}
private static double bd2Money(BigDecimal v) {
@@ -67,7 +67,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
/** 计算店铺汇总的合计行 */
private CompanyOverviewVO.ShopSummary computeShopTotal(List<CompanyOverviewVO.ShopSummary> shops) {
BigDecimal totalSales = BigDecimal.ZERO;
int totalOrders = 0;
int totalSalesOrders = 0;
int totalDealOrders = 0;
BigDecimal totalTargetAmount = BigDecimal.ZERO;
int totalTargetOrders = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
@@ -83,7 +84,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
totalSales = totalSales.add(s.getSalesAmount() != null ? s.getSalesAmount() : BigDecimal.ZERO);
totalDealAmount = totalDealAmount.add(s.getDealAmount() != null ? s.getDealAmount() : BigDecimal.ZERO);
totalGrossProfit = totalGrossProfit.add(s.getGrossProfit() != null ? s.getGrossProfit() : BigDecimal.ZERO);
totalOrders += s.getOrderCount() != null ? s.getOrderCount() : 0;
totalSalesOrders += s.getSalesOrderCount() != null ? s.getSalesOrderCount() : 0;
totalDealOrders += s.getDealOrderCount() != null ? s.getDealOrderCount() : 0;
totalTargetAmount = totalTargetAmount.add(s.getTargetAmount() != null ? s.getTargetAmount() : BigDecimal.ZERO);
totalTargetOrders += s.getTargetOrderCount() != null ? s.getTargetOrderCount() : 0;
totalProductCost = totalProductCost.add(s.getProductCost() != null ? s.getProductCost() : BigDecimal.ZERO);
@@ -94,8 +96,11 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
totalBrushFee = totalBrushFee.add(s.getBrushFee() != null ? s.getBrushFee() : BigDecimal.ZERO);
}
BigDecimal avgOrderValue = totalOrders > 0
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
? totalSales.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal dealAvgOrderValue = totalDealOrders > 0
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
BigDecimal profitBeforeTax = totalSales.subtract(totalCost)
@@ -112,9 +117,9 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
? totalSales.divide(totalTargetAmount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))
: totalSales.compareTo(BigDecimal.ZERO) > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
BigDecimal orderAchievementRate = totalTargetOrders > 0
? new BigDecimal(totalOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
? new BigDecimal(totalSalesOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
.multiply(new BigDecimal("100"))
: totalOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
: totalSalesOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
CompanyOverviewVO.ShopSummary total = new CompanyOverviewVO.ShopSummary();
total.setShopId(0L);
@@ -122,8 +127,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setSalesAmount(totalSales);
total.setDealAmount(totalDealAmount);
total.setGrossProfit(totalGrossProfit.setScale(2, RoundingMode.HALF_UP));
total.setOrderCount(totalOrders);
total.setAverageOrderValue(avgOrderValue);
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setTargetAmount(totalTargetAmount);
total.setTargetOrderCount(totalTargetOrders);
total.setSalesAmountAchievementRate(salesAchievementRate);
@@ -146,7 +153,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
/** 计算品类汇总的合计行 */
private CompanyOverviewVO.CategorySummary computeCategoryTotal(List<CompanyOverviewVO.CategorySummary> categories) {
BigDecimal totalSales = BigDecimal.ZERO;
int totalOrders = 0;
int totalSalesOrders = 0;
int totalDealOrders = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
BigDecimal totalShippingCost = BigDecimal.ZERO;
BigDecimal totalOtherCost = BigDecimal.ZERO;
@@ -160,7 +168,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
totalSales = totalSales.add(c.getSalesAmount() != null ? c.getSalesAmount() : BigDecimal.ZERO);
totalDealAmount = totalDealAmount.add(c.getDealAmount() != null ? c.getDealAmount() : BigDecimal.ZERO);
totalGrossProfit = totalGrossProfit.add(c.getGrossProfit() != null ? c.getGrossProfit() : BigDecimal.ZERO);
totalOrders += c.getOrderCount() != null ? c.getOrderCount() : 0;
totalSalesOrders += c.getSalesOrderCount() != null ? c.getSalesOrderCount() : 0;
totalDealOrders += c.getDealOrderCount() != null ? c.getDealOrderCount() : 0;
totalProductCost = totalProductCost.add(c.getProductCost() != null ? c.getProductCost() : BigDecimal.ZERO);
totalShippingCost = totalShippingCost.add(c.getShippingCost() != null ? c.getShippingCost() : BigDecimal.ZERO);
totalOtherCost = totalOtherCost.add(c.getOtherCost() != null ? c.getOtherCost() : BigDecimal.ZERO);
@@ -169,8 +178,11 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
totalBrushFee = totalBrushFee.add(c.getBrushFee() != null ? c.getBrushFee() : BigDecimal.ZERO);
}
BigDecimal avgOrderValue = totalOrders > 0
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
? totalSales.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal dealAvgOrderValue = totalDealOrders > 0
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
BigDecimal profitBeforeTax = totalSales.subtract(totalCost)
@@ -190,8 +202,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setSalesAmount(totalSales);
total.setDealAmount(totalDealAmount);
total.setGrossProfit(totalGrossProfit.setScale(2, RoundingMode.HALF_UP));
total.setOrderCount(totalOrders);
total.setAverageOrderValue(avgOrderValue);
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setProductCost(totalProductCost);
total.setShippingCost(totalShippingCost);
total.setOtherCost(totalOtherCost);
@@ -210,7 +224,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
/** 计算平台汇总的合计行 */
private CompanyOverviewVO.PlatformSummary computePlatformTotal(List<CompanyOverviewVO.PlatformSummary> platforms) {
BigDecimal totalSalesAmount = BigDecimal.ZERO;
int totalOrderCount = 0;
int totalSalesOrders = 0;
int totalDealOrders = 0;
BigDecimal totalTargetAmount = BigDecimal.ZERO;
int totalTargetOrderCount = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
@@ -226,7 +241,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
totalSalesAmount = totalSalesAmount.add(p.getSalesAmount() != null ? p.getSalesAmount() : BigDecimal.ZERO);
totalDealAmount = totalDealAmount.add(p.getDealAmount() != null ? p.getDealAmount() : BigDecimal.ZERO);
totalGrossProfit = totalGrossProfit.add(p.getGrossProfit() != null ? p.getGrossProfit() : BigDecimal.ZERO);
totalOrderCount += p.getOrderCount() != null ? p.getOrderCount() : 0;
totalSalesOrders += p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0;
totalDealOrders += p.getDealOrderCount() != null ? p.getDealOrderCount() : 0;
totalTargetAmount = totalTargetAmount.add(p.getTargetAmount() != null ? p.getTargetAmount() : BigDecimal.ZERO);
totalTargetOrderCount += p.getTargetOrderCount() != null ? p.getTargetOrderCount() : 0;
totalProductCost = totalProductCost.add(p.getProductCost() != null ? p.getProductCost() : BigDecimal.ZERO);
@@ -237,8 +253,11 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
totalBrushFee = totalBrushFee.add(p.getBrushFee() != null ? p.getBrushFee() : BigDecimal.ZERO);
}
BigDecimal avgOrderValue = totalOrderCount > 0
? totalSalesAmount.divide(new BigDecimal(totalOrderCount), 2, RoundingMode.HALF_UP)
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
? totalSalesAmount.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal dealAvgOrderValue = totalDealOrders > 0
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
BigDecimal profitBeforeTax = totalSalesAmount.subtract(totalCost)
@@ -255,9 +274,9 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
? totalSalesAmount.divide(totalTargetAmount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))
: totalSalesAmount.compareTo(BigDecimal.ZERO) > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
BigDecimal orderAchievementRate = totalTargetOrderCount > 0
? new BigDecimal(totalOrderCount).divide(new BigDecimal(totalTargetOrderCount), 4, RoundingMode.HALF_UP)
? new BigDecimal(totalSalesOrders).divide(new BigDecimal(totalTargetOrderCount), 4, RoundingMode.HALF_UP)
.multiply(new BigDecimal("100"))
: totalOrderCount > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
: totalSalesOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
CompanyOverviewVO.PlatformSummary total = new CompanyOverviewVO.PlatformSummary();
total.setPlatformCode(null);
@@ -265,8 +284,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setSalesAmount(totalSalesAmount);
total.setDealAmount(totalDealAmount);
total.setGrossProfit(totalGrossProfit.setScale(2, RoundingMode.HALF_UP));
total.setOrderCount(totalOrderCount);
total.setAverageOrderValue(avgOrderValue);
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setTargetAmount(totalTargetAmount);
total.setTargetOrderCount(totalTargetOrderCount);
total.setSalesAmountAchievementRate(salesAchievementRate);
@@ -524,8 +545,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
BigDecimal brush, BigDecimal targetAmt, int targetOrders) {
s.setSalesAmount(m.sales);
s.setDealAmount(m.dealAmount);
s.setOrderCount(m.orderCount);
s.setAverageOrderValue(aov(m.sales, m.orderCount));
s.setSalesOrderCount(m.salesOrderCount);
s.setDealOrderCount(m.dealOrderCount);
s.setSalesAverageOrderValue(aov(m.sales, m.salesOrderCount));
s.setDealAverageOrderValue(aov(m.dealAmount, m.dealOrderCount));
s.setProductCost(m.productCost);
s.setShippingCost(m.freightCost);
s.setOtherCost(m.otherCost);
@@ -543,7 +566,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
s.setTargetAmount(targetAmt);
s.setTargetOrderCount(targetOrders);
s.setSalesAmountAchievementRate(achievementRate(m.sales, targetAmt));
s.setOrderCountAchievementRate(achievementRate(BigDecimal.valueOf(m.orderCount), BigDecimal.valueOf(targetOrders)));
s.setOrderCountAchievementRate(achievementRate(BigDecimal.valueOf(m.salesOrderCount), BigDecimal.valueOf(targetOrders)));
}
/** 品类/商品/平台汇总行:填充成交金额、毛利与净利字段 */
@@ -551,8 +574,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
BigDecimal promo, BigDecimal brush) {
s.setSalesAmount(m.sales);
s.setDealAmount(m.dealAmount);
s.setOrderCount(m.orderCount);
s.setAverageOrderValue(aov(m.sales, m.orderCount));
s.setSalesOrderCount(m.salesOrderCount);
s.setDealOrderCount(m.dealOrderCount);
s.setSalesAverageOrderValue(aov(m.sales, m.salesOrderCount));
s.setDealAverageOrderValue(aov(m.dealAmount, m.dealOrderCount));
s.setProductCost(m.productCost);
s.setShippingCost(m.freightCost);
s.setOtherCost(m.otherCost);
@@ -574,8 +599,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
BigDecimal targetAmt, int targetOrders) {
s.setSalesAmount(m.sales);
s.setDealAmount(m.dealAmount);
s.setOrderCount(m.orderCount);
s.setAverageOrderValue(aov(m.sales, m.orderCount));
s.setSalesOrderCount(m.salesOrderCount);
s.setDealOrderCount(m.dealOrderCount);
s.setSalesAverageOrderValue(aov(m.sales, m.salesOrderCount));
s.setDealAverageOrderValue(aov(m.dealAmount, m.dealOrderCount));
s.setProductCost(m.productCost);
s.setShippingCost(m.freightCost);
s.setOtherCost(m.otherCost);
@@ -593,7 +620,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
s.setTargetAmount(targetAmt);
s.setTargetOrderCount(targetOrders);
s.setSalesAmountAchievementRate(achievementRate(m.sales, targetAmt));
s.setOrderCountAchievementRate(achievementRate(BigDecimal.valueOf(m.orderCount), BigDecimal.valueOf(targetOrders)));
s.setOrderCountAchievementRate(achievementRate(BigDecimal.valueOf(m.salesOrderCount), BigDecimal.valueOf(targetOrders)));
}
private static void mergeAgg(Map<Long, AggMetrics> map, long key, OverviewAggRows.ShopProductRow row) {
@@ -730,7 +757,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
BigDecimal sales = BigDecimal.ZERO;
/** 成交金额(全订单状态商家实收合计) */
BigDecimal dealAmount = BigDecimal.ZERO;
int orderCount;
int salesOrderCount;
int dealOrderCount;
BigDecimal refund = BigDecimal.ZERO;
BigDecimal productCost = BigDecimal.ZERO;
BigDecimal freightCost = BigDecimal.ZERO;
@@ -750,7 +778,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
AggMetrics a = new AggMetrics();
a.sales = nz(row.getSalesAmount());
a.dealAmount = nz(row.getDealAmount());
a.orderCount = row.getOrderCount() != null ? row.getOrderCount().intValue() : 0;
a.salesOrderCount = row.getOrderCount() != null ? row.getOrderCount().intValue() : 0;
a.dealOrderCount = row.getDealOrderCount() != null ? row.getDealOrderCount().intValue() : 0;
a.refund = nz(row.getRefundAmount());
a.productCost = nz(row.getProductCost());
a.freightCost = nz(row.getFreightCost());
@@ -762,7 +791,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
AggMetrics a = new AggMetrics();
a.sales = sales.add(o.sales);
a.dealAmount = dealAmount.add(o.dealAmount);
a.orderCount = orderCount + o.orderCount;
a.salesOrderCount = salesOrderCount + o.salesOrderCount;
a.dealOrderCount = dealOrderCount + o.dealOrderCount;
a.refund = refund.add(o.refund);
a.productCost = productCost.add(o.productCost);
a.freightCost = freightCost.add(o.freightCost);
@@ -131,7 +131,7 @@ public class ExportServiceImpl implements ExportService {
String taxLabel = (taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP)).toPlainString() + "%税额";
String[] headers = {
firstColumnHeader, "目标单量", "单量达成率(%)", "目标额", "销售达成率(%)",
"净销售额", "成交金额", "单量", "客单价",
"成交金额", "净销售额", "成交单量", "净销售单量", "成交客单价", "净销售客单价",
"商品成本", "运费", "其他成本", "订单成本", "退款金额", taxLabel, "推广费", "刷单费",
"毛利", "税前净利", "费比", "ROI", "税后净利"
};
@@ -169,29 +169,31 @@ public class ExportServiceImpl implements ExportService {
setCell(row, 2, objToPct(data.get("orderCountAchievementRate")), style);
setCell(row, 3, objToDouble(data.get("targetAmount")), style);
setCell(row, 4, objToPct(data.get("salesAchievementRate")), style);
setCell(row, 5, objToDouble(data.get("salesAmount")), style);
setCell(row, 6, objToDouble(data.get("dealAmount")), style);
setCell(row, 7, objToDouble(data.get("orderCount")), style);
setCell(row, 8, objToDouble(data.get("avgOrderValue")), style);
setCell(row, 9, objToDouble(data.get("productCost")), style);
setCell(row, 10, objToDouble(data.get("shippingCost")), style);
setCell(row, 11, objToDouble(data.get("otherCost")), style);
setCell(row, 12, objToDouble(data.get("orderCost")), style);
setCell(row, 5, objToDouble(data.get("dealAmount")), style);
setCell(row, 6, objToDouble(data.get("salesAmount")), style);
setCell(row, 7, objToDouble(data.get("dealOrderCount")), style);
setCell(row, 8, objToDouble(data.get("salesOrderCount")), style);
setCell(row, 9, objToDouble(data.get("dealAvgOrderValue")), style);
setCell(row, 10, objToDouble(data.get("salesAvgOrderValue")), style);
setCell(row, 11, objToDouble(data.get("productCost")), style);
setCell(row, 12, objToDouble(data.get("shippingCost")), style);
setCell(row, 13, objToDouble(data.get("otherCost")), style);
setCell(row, 14, objToDouble(data.get("orderCost")), style);
BigDecimal salesTax = salesTaxOnNetForExport(
mapToBigDecimal(data.get("salesAmount")),
taxRate);
BigDecimal profitAfterTax = mapToBigDecimal(data.get("totalProfitBeforeTax"))
.subtract(salesTax)
.setScale(2, RoundingMode.HALF_UP);
setCell(row, 13, objToDouble(data.get("refundAmount")), style);
setCell(row, 14, salesTax.doubleValue(), style);
setCell(row, 15, objToDouble(data.get("totalPromotionFee")), style);
setCell(row, 16, objToDouble(data.get("brushFee")), style);
setCell(row, 17, objToDouble(data.get("grossProfit")), style);
setCell(row, 18, objToDouble(data.get("totalProfitBeforeTax")), style);
setCell(row, 19, objToDouble(data.get("feeRatio")), style);
setCell(row, 20, objToDouble(data.get("roi")), style);
setCell(row, 21, profitAfterTax.doubleValue(), style);
setCell(row, 15, objToDouble(data.get("refundAmount")), style);
setCell(row, 16, salesTax.doubleValue(), style);
setCell(row, 17, objToDouble(data.get("totalPromotionFee")), style);
setCell(row, 18, objToDouble(data.get("brushFee")), style);
setCell(row, 19, objToDouble(data.get("grossProfit")), style);
setCell(row, 20, objToDouble(data.get("totalProfitBeforeTax")), style);
setCell(row, 21, objToDouble(data.get("feeRatio")), style);
setCell(row, 22, objToDouble(data.get("roi")), style);
setCell(row, 23, profitAfterTax.doubleValue(), style);
}
private static BigDecimal mapToBigDecimal(Object val) {
@@ -217,10 +219,12 @@ public class ExportServiceImpl implements ExportService {
data.put("orderCountAchievementRate", s.getOrderCountAchievementRate());
data.put("targetAmount", s.getTargetAmount());
data.put("salesAchievementRate", s.getSalesAmountAchievementRate());
data.put("salesAmount", s.getSalesAmount());
data.put("dealAmount", s.getDealAmount());
data.put("orderCount", s.getOrderCount());
data.put("avgOrderValue", s.getAverageOrderValue());
data.put("salesAmount", s.getSalesAmount());
data.put("dealOrderCount", s.getDealOrderCount());
data.put("salesOrderCount", s.getSalesOrderCount());
data.put("dealAvgOrderValue", s.getDealAverageOrderValue());
data.put("salesAvgOrderValue", s.getSalesAverageOrderValue());
data.put("productCost", s.getProductCost());
data.put("shippingCost", s.getShippingCost());
data.put("otherCost", s.getOtherCost());
@@ -250,7 +254,9 @@ public class ExportServiceImpl implements ExportService {
private CompanyOverviewVO.ShopSummary aggregateShopSummariesForExport(
List<CompanyOverviewVO.ShopSummary> shops, BigDecimal taxRate) {
BigDecimal totalSales = BigDecimal.ZERO;
int totalOrders = 0;
BigDecimal totalDealAmount = BigDecimal.ZERO;
int totalSalesOrders = 0;
int totalDealOrders = 0;
BigDecimal totalTargetAmount = BigDecimal.ZERO;
int totalTargetOrders = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
@@ -262,7 +268,9 @@ public class ExportServiceImpl implements ExportService {
for (CompanyOverviewVO.ShopSummary s : shops) {
totalSales = totalSales.add(s.getSalesAmount() != null ? s.getSalesAmount() : BigDecimal.ZERO);
totalOrders += s.getOrderCount() != null ? s.getOrderCount() : 0;
totalDealAmount = totalDealAmount.add(s.getDealAmount() != null ? s.getDealAmount() : BigDecimal.ZERO);
totalSalesOrders += s.getSalesOrderCount() != null ? s.getSalesOrderCount() : 0;
totalDealOrders += s.getDealOrderCount() != null ? s.getDealOrderCount() : 0;
totalTargetAmount = totalTargetAmount.add(s.getTargetAmount() != null ? s.getTargetAmount() : BigDecimal.ZERO);
totalTargetOrders += s.getTargetOrderCount() != null ? s.getTargetOrderCount() : 0;
totalProductCost = totalProductCost.add(s.getProductCost() != null ? s.getProductCost() : BigDecimal.ZERO);
@@ -273,8 +281,11 @@ public class ExportServiceImpl implements ExportService {
totalBrushFee = totalBrushFee.add(s.getBrushFee() != null ? s.getBrushFee() : BigDecimal.ZERO);
}
BigDecimal avgOrderValue = totalOrders > 0
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
? totalSales.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal dealAvgOrderValue = totalDealOrders > 0
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
BigDecimal profitBeforeTax = totalSales.subtract(totalCost)
@@ -291,16 +302,19 @@ public class ExportServiceImpl implements ExportService {
? totalSales.divide(totalTargetAmount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))
: totalSales.compareTo(BigDecimal.ZERO) > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
BigDecimal orderAchievementRate = totalTargetOrders > 0
? new BigDecimal(totalOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
? new BigDecimal(totalSalesOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
.multiply(new BigDecimal("100"))
: totalOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
: totalSalesOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
CompanyOverviewVO.ShopSummary total = new CompanyOverviewVO.ShopSummary();
total.setShopId(0L);
total.setShopName("合计");
total.setSalesAmount(totalSales);
total.setOrderCount(totalOrders);
total.setAverageOrderValue(avgOrderValue);
total.setDealAmount(totalDealAmount);
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setTargetAmount(totalTargetAmount);
total.setTargetOrderCount(totalTargetOrders);
total.setSalesAmountAchievementRate(salesAchievementRate);
@@ -327,10 +341,12 @@ public class ExportServiceImpl implements ExportService {
data.put("orderCountAchievementRate", s.getOrderCountAchievementRate());
data.put("targetAmount", s.getTargetAmount());
data.put("salesAchievementRate", s.getSalesAmountAchievementRate());
data.put("salesAmount", s.getSalesAmount());
data.put("dealAmount", s.getDealAmount());
data.put("orderCount", s.getOrderCount());
data.put("avgOrderValue", s.getAverageOrderValue());
data.put("salesAmount", s.getSalesAmount());
data.put("dealOrderCount", s.getDealOrderCount());
data.put("salesOrderCount", s.getSalesOrderCount());
data.put("dealAvgOrderValue", s.getDealAverageOrderValue());
data.put("salesAvgOrderValue", s.getSalesAverageOrderValue());
data.put("productCost", s.getProductCost());
data.put("shippingCost", s.getShippingCost());
data.put("otherCost", s.getOtherCost());
@@ -350,7 +366,9 @@ public class ExportServiceImpl implements ExportService {
private CompanyOverviewVO.PlatformSummary aggregatePlatformSummariesForExport(
List<CompanyOverviewVO.PlatformSummary> platforms, BigDecimal taxRate) {
BigDecimal totalSales = BigDecimal.ZERO;
int totalOrders = 0;
BigDecimal totalDealAmount = BigDecimal.ZERO;
int totalSalesOrders = 0;
int totalDealOrders = 0;
BigDecimal totalTargetAmount = BigDecimal.ZERO;
int totalTargetOrders = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
@@ -362,7 +380,9 @@ public class ExportServiceImpl implements ExportService {
for (CompanyOverviewVO.PlatformSummary s : platforms) {
totalSales = totalSales.add(s.getSalesAmount() != null ? s.getSalesAmount() : BigDecimal.ZERO);
totalOrders += s.getOrderCount() != null ? s.getOrderCount() : 0;
totalDealAmount = totalDealAmount.add(s.getDealAmount() != null ? s.getDealAmount() : BigDecimal.ZERO);
totalSalesOrders += s.getSalesOrderCount() != null ? s.getSalesOrderCount() : 0;
totalDealOrders += s.getDealOrderCount() != null ? s.getDealOrderCount() : 0;
totalTargetAmount = totalTargetAmount.add(s.getTargetAmount() != null ? s.getTargetAmount() : BigDecimal.ZERO);
totalTargetOrders += s.getTargetOrderCount() != null ? s.getTargetOrderCount() : 0;
totalProductCost = totalProductCost.add(s.getProductCost() != null ? s.getProductCost() : BigDecimal.ZERO);
@@ -373,8 +393,11 @@ public class ExportServiceImpl implements ExportService {
totalBrushFee = totalBrushFee.add(s.getBrushFee() != null ? s.getBrushFee() : BigDecimal.ZERO);
}
BigDecimal avgOrderValue = totalOrders > 0
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
? totalSales.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal dealAvgOrderValue = totalDealOrders > 0
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO;
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
BigDecimal profitBeforeTax = totalSales.subtract(totalCost)
@@ -391,16 +414,19 @@ public class ExportServiceImpl implements ExportService {
? totalSales.divide(totalTargetAmount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))
: totalSales.compareTo(BigDecimal.ZERO) > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
BigDecimal orderAchievementRate = totalTargetOrders > 0
? new BigDecimal(totalOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
? new BigDecimal(totalSalesOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
.multiply(new BigDecimal("100"))
: totalOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
: totalSalesOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
CompanyOverviewVO.PlatformSummary total = new CompanyOverviewVO.PlatformSummary();
total.setPlatformCode(null);
total.setPlatformName("合计");
total.setSalesAmount(totalSales);
total.setOrderCount(totalOrders);
total.setAverageOrderValue(avgOrderValue);
total.setDealAmount(totalDealAmount);
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setTargetAmount(totalTargetAmount);
total.setTargetOrderCount(totalTargetOrders);
total.setSalesAmountAchievementRate(salesAchievementRate);
@@ -140,8 +140,8 @@ public class BiProductOverviewServiceImpl implements BiProductOverviewService {
CompanyOverviewVO.CategorySummary productRow = findProductRow(tables.getProductTable(), product.getId());
BigDecimal sales = productRow != null ? nz(productRow.getSalesAmount()) : sumSales(thisProductDocs);
int orderCount = productRow != null && productRow.getOrderCount() != null
? productRow.getOrderCount()
int orderCount = productRow != null && productRow.getSalesOrderCount() != null
? productRow.getSalesOrderCount()
: sumOrders(thisProductDocs);
BigDecimal refund = productRow != null ? nz(productRow.getRefundAmount()) : sumRefund(thisProductDocs);
BigDecimal promo = productRow != null ? nz(productRow.getTotalPromotionFee()) : BigDecimal.ZERO;
@@ -170,9 +170,19 @@ public class ShopOverviewStatisticsVO {
private BigDecimal salesAmount;
private Integer orderCount;
private BigDecimal dealAmount;
private BigDecimal averageOrderValue;
/** 净销售单量 */
private Integer salesOrderCount;
/** 成交单量 */
private Integer dealOrderCount;
/** 净销售客单价 */
private BigDecimal salesAverageOrderValue;
/** 成交客单价 */
private BigDecimal dealAverageOrderValue;
private BigDecimal productCost;
@@ -210,9 +220,19 @@ public class ShopOverviewStatisticsVO {
private BigDecimal salesAmount;
private Integer orderCount;
private BigDecimal dealAmount;
private BigDecimal averageOrderValue;
/** 净销售单量 */
private Integer salesOrderCount;
/** 成交单量 */
private Integer dealOrderCount;
/** 净销售客单价 */
private BigDecimal salesAverageOrderValue;
/** 成交客单价 */
private BigDecimal dealAverageOrderValue;
private BigDecimal productCost;
@@ -121,7 +121,7 @@ public class BiShopExportServiceImpl implements BiShopExportService {
String titlePrefix = (shopName != null && !shopName.isBlank() ? shopName : "店铺") + " - 按商品汇总";
String taxLabel = (taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP)).toPlainString() + "%税额";
String[] headers = {
"商品", "销售额", "单量", "客单价",
"商品", "成交金额", "净销售额", "成交单量", "净销售单量", "成交客单价", "净销售客单价",
"商品成本", "运费", "其他成本", "订单成本", "退款金额", "推广费", "刷单费用",
"费比 %", "单品 ROI", "税前盈亏", taxLabel, "税后净利"
};
@@ -167,28 +167,31 @@ public class BiShopExportServiceImpl implements BiShopExportService {
? "\n编码: " + p.getProductCode()
: "");
setCell(row, 0, nameCol, style);
setCell(row, 1, nvl(p.getSalesAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 2, (double) nvl(p.getOrderCount(), 0), style);
setCell(row, 3, nvl(p.getAverageOrderValue(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 4, nvl(p.getProductCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 5, nvl(p.getShippingCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 6, nvl(p.getOtherCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 7, nvl(p.getOrderCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 8, nvl(p.getRefundAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 9, nvl(p.getTotalPromotionFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 10, nvl(p.getBrushFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 1, nvl(p.getDealAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 2, nvl(p.getSalesAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 3, (double) nvl(p.getDealOrderCount(), 0), style);
setCell(row, 4, (double) nvl(p.getSalesOrderCount(), 0), style);
setCell(row, 5, nvl(p.getDealAverageOrderValue(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 6, nvl(p.getSalesAverageOrderValue(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 7, nvl(p.getProductCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 8, nvl(p.getShippingCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 9, nvl(p.getOtherCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 10, nvl(p.getOrderCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 11, nvl(p.getRefundAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 12, nvl(p.getTotalPromotionFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 13, nvl(p.getBrushFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
BigDecimal fr = p.getFeeRatio();
double feePct = fr == null ? 0.0
: fr.multiply(new BigDecimal("100")).setScale(1, RoundingMode.HALF_UP).doubleValue();
setCell(row, 11, feePct, style);
setCell(row, 12, nvl(p.getRoi(), BigDecimal.ZERO).setScale(4, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 13, nvl(p.getTotalProfitBeforeTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 14, feePct, style);
setCell(row, 15, nvl(p.getRoi(), BigDecimal.ZERO).setScale(4, RoundingMode.HALF_UP).doubleValue(), style);
setCell(row, 16, nvl(p.getTotalProfitBeforeTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
BigDecimal salesTax = salesTaxOnNetForShopExport(p.getSalesAmount(), taxRate);
BigDecimal profitAfterTax = nvl(p.getTotalProfitBeforeTax(), BigDecimal.ZERO)
.subtract(salesTax)
.setScale(2, RoundingMode.HALF_UP);
setCell(row, 14, salesTax.doubleValue(), style);
setCell(row, 15, profitAfterTax.doubleValue(), style);
setCell(row, 17, salesTax.doubleValue(), style);
setCell(row, 18, profitAfterTax.doubleValue(), style);
}
private void createTrendSheetFromVO(Sheet sheet, String dateRangeLabel, ShopOverviewStatisticsVO vo) {
@@ -281,8 +281,11 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
private static void copyMetrics(ShopOverviewStatisticsVO.ProductSummary p,
CompanyOverviewVO.CategorySummary c) {
p.setSalesAmount(c.getSalesAmount());
p.setOrderCount(c.getOrderCount());
p.setAverageOrderValue(c.getAverageOrderValue());
p.setDealAmount(c.getDealAmount());
p.setSalesOrderCount(c.getSalesOrderCount());
p.setDealOrderCount(c.getDealOrderCount());
p.setSalesAverageOrderValue(c.getSalesAverageOrderValue());
p.setDealAverageOrderValue(c.getDealAverageOrderValue());
p.setProductCost(c.getProductCost());
p.setShippingCost(c.getShippingCost());
p.setOtherCost(c.getOtherCost());
@@ -324,8 +327,11 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
s.setCategoryId(c.getCategoryId());
s.setCategoryName(c.getCategoryName());
s.setSalesAmount(c.getSalesAmount());
s.setOrderCount(c.getOrderCount());
s.setAverageOrderValue(c.getAverageOrderValue());
s.setDealAmount(c.getDealAmount());
s.setSalesOrderCount(c.getSalesOrderCount());
s.setDealOrderCount(c.getDealOrderCount());
s.setSalesAverageOrderValue(c.getSalesAverageOrderValue());
s.setDealAverageOrderValue(c.getDealAverageOrderValue());
s.setProductCost(c.getProductCost());
s.setShippingCost(c.getShippingCost());
s.setOtherCost(c.getOtherCost());
@@ -350,7 +356,7 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
vo.setProductSalesTop10(po.getProducts().stream()
.sorted(Comparator.comparing(
(ShopOverviewStatisticsVO.ProductSummary p) ->
p.getOrderCount() != null ? p.getOrderCount() : 0,
p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0,
Comparator.reverseOrder()))
.limit(10)
.map(p -> {
@@ -359,7 +365,7 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
item.setProductId(p.getProductId());
item.setProductName(p.getProductName());
item.setProductCode(p.getProductCode());
item.setOrderCount(p.getOrderCount());
item.setOrderCount(p.getSalesOrderCount());
item.setSalesAmount(p.getSalesAmount());
return item;
})
@@ -92,11 +92,18 @@ export namespace CompanyOverviewVO {
orderCountAchievementRate?: number;
targetAmount?: number;
salesAmountAchievementRate?: number;
/** 净销售额 = 成交 − 退款 */
salesAmount?: number;
/** 成交金额(全订单状态商家实收合计) */
/** 成交金额 */
dealAmount?: number;
orderCount?: number;
averageOrderValue?: number;
/** 净销售单量 */
salesOrderCount?: number;
/** 成交单量 */
dealOrderCount?: number;
/** 净销售客单价 */
salesAverageOrderValue?: number;
/** 成交客单价 */
dealAverageOrderValue?: number;
productCost?: number;
shippingCost?: number;
otherCost?: number;
@@ -120,8 +127,10 @@ export namespace CompanyOverviewVO {
categoryName?: string;
salesAmount?: number;
dealAmount?: number;
orderCount?: number;
averageOrderValue?: number;
salesOrderCount?: number;
dealOrderCount?: number;
salesAverageOrderValue?: number;
dealAverageOrderValue?: number;
productCost?: number;
shippingCost?: number;
otherCost?: number;
@@ -147,8 +156,10 @@ export namespace CompanyOverviewVO {
salesAmountAchievementRate?: number;
salesAmount?: number;
dealAmount?: number;
orderCount?: number;
averageOrderValue?: number;
salesOrderCount?: number;
dealOrderCount?: number;
salesAverageOrderValue?: number;
dealAverageOrderValue?: number;
productCost?: number;
shippingCost?: number;
otherCost?: number;
@@ -176,10 +176,16 @@ export namespace ShopVO {
productCode?: string;
/** 销售额 */
salesAmount: number;
/** 单量 */
orderCount?: number;
/** 客单价 */
averageOrderValue?: number;
/** 成交金额 */
dealAmount?: number;
/** 净销售单量 */
salesOrderCount?: number;
/** 成交单量 */
dealOrderCount?: number;
/** 净销售客单价 */
salesAverageOrderValue?: number;
/** 成交客单价 */
dealAverageOrderValue?: number;
/** 商品成本 */
productCost?: number;
/** 运费 */
@@ -214,10 +220,16 @@ export namespace ShopVO {
categoryName: string;
/** 销售额 */
salesAmount: number;
/** 单量 */
orderCount?: number;
/** 客单价 */
averageOrderValue?: number;
/** 成交金额 */
dealAmount?: number;
/** 净销售单量 */
salesOrderCount?: number;
/** 成交单量 */
dealOrderCount?: number;
/** 净销售客单价 */
salesAverageOrderValue?: number;
/** 成交客单价 */
dealAverageOrderValue?: number;
/** 商品成本 */
productCost?: number;
/** 运费 */
@@ -4,7 +4,7 @@
export const overviewTableHints = {
targetOrderCount: '区间内各店铺月度目标单量之和。',
orderCountAchievementRate: '实际单量 / 目标单量 * 100%。',
orderCountAchievementRate: '净销售单量 / 目标单量 * 100%。',
targetAmount: '区间内各店铺月度目标销售额之和。',
salesAmountAchievementRate: '净销售额 / 目标额 * 100%。',
salesAmount: '成交金额 − 退款额(不含已取消、未知订单)。',
@@ -12,10 +12,16 @@ export const overviewTableHints = {
grossProfit: '净销售额 − 订单成本。',
/** 与 salesAmount 同口径,表头文案为「销售额」时使用 */
salesAmountShort: '成交金额 − 退款额(不含已取消、未知订单)。',
salesOrderCount: '净销售单量 = 成交单量 − 退款单量。',
dealOrderCount: '计入成交状态的订单笔数(不含已取消、未知)。',
salesAverageOrderValue: '净销售额 / 净销售单量。',
dealAverageOrderValue: '成交金额 / 成交单量。',
/** @deprecated 使用 salesOrderCount */
orderCount: '净销售单量 = 成交单量 − 退款单量。',
orderCountSku: '该 SKU 净销售单量;括号内为净销量件数。',
/** @deprecated 使用 orderCountSku */
orderCountSpec: '该 SKU 净销售单量;括号内为净销量件数。',
/** @deprecated 使用 salesAverageOrderValue */
averageOrderValue: '净销售额 / 净销售单量。',
productCost: '商品成本合计。',
shippingCost: '运费成本合计。',
@@ -102,14 +102,6 @@ function buildCompareMetrics(
const z = (r: CompanyOverviewVO.ShopSummary | undefined, fn: (x: CompanyOverviewVO.ShopSummary) => unknown) =>
num(r ? fn(r) : undefined);
return [
{
key: 'salesAmount',
label: '净销售额',
hint: overviewTableHints.salesAmount,
format: 'money',
valueA: z(a, (r) => r.salesAmount),
valueB: z(b, (r) => r.salesAmount),
},
{
key: 'dealAmount',
label: '成交金额',
@@ -119,20 +111,44 @@ function buildCompareMetrics(
valueB: z(b, (r) => r.dealAmount),
},
{
key: 'orderCount',
label: '单量',
hint: overviewTableHints.orderCount,
format: 'int',
valueA: z(a, (r) => r.orderCount),
valueB: z(b, (r) => r.orderCount),
key: 'salesAmount',
label: '净销售额',
hint: overviewTableHints.salesAmount,
format: 'money',
valueA: z(a, (r) => r.salesAmount),
valueB: z(b, (r) => r.salesAmount),
},
{
key: 'averageOrderValue',
label: '客单价',
hint: overviewTableHints.averageOrderValue,
key: 'dealOrderCount',
label: '成交单量',
hint: overviewTableHints.dealOrderCount,
format: 'int',
valueA: z(a, (r) => r.dealOrderCount),
valueB: z(b, (r) => r.dealOrderCount),
},
{
key: 'salesOrderCount',
label: '净销售单量',
hint: overviewTableHints.salesOrderCount,
format: 'int',
valueA: z(a, (r) => r.salesOrderCount),
valueB: z(b, (r) => r.salesOrderCount),
},
{
key: 'dealAverageOrderValue',
label: '成交客单价',
hint: overviewTableHints.dealAverageOrderValue,
format: 'money',
valueA: z(a, (r) => r.averageOrderValue),
valueB: z(b, (r) => r.averageOrderValue),
valueA: z(a, (r) => r.dealAverageOrderValue),
valueB: z(b, (r) => r.dealAverageOrderValue),
},
{
key: 'salesAverageOrderValue',
label: '净销售客单价',
hint: overviewTableHints.salesAverageOrderValue,
format: 'money',
valueA: z(a, (r) => r.salesAverageOrderValue),
valueB: z(b, (r) => r.salesAverageOrderValue),
},
{
key: 'productCost',
@@ -145,7 +145,7 @@ const cellRoi = (v: number | null | undefined) =>
{{ props.firstColumnLabel }}
</th>
<th
colspan="4"
colspan="6"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50%)] p-3 text-center"
>
经营规模维度
@@ -164,19 +164,25 @@ const cellRoi = (v: number | null | undefined) =>
</th>
</tr>
<tr class="bg-slate-50 dark:bg-[hsl(240deg_3.7%_15.9%)] text-sm">
<th class="border-b border-l px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<th class="border-b border-l px-6 py-4 font-black text-amber-700 dark:text-amber-400">
<OverviewColumnHint :title="storeOverviewHints.dealAmount">成交金额</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<OverviewColumnHint :title="storeOverviewHints.salesAmount">
净销售额
</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 font-black text-amber-700 dark:text-amber-400">
<OverviewColumnHint :title="storeOverviewHints.dealAmount">成交金额</OverviewColumnHint>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.dealOrderCount">成交单量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.orderCount">单量</OverviewColumnHint>
<OverviewColumnHint :title="storeOverviewHints.salesOrderCount">净销售单量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.averageOrderValue">客单价</OverviewColumnHint>
<OverviewColumnHint :title="storeOverviewHints.dealAverageOrderValue">成交客单价</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.salesAverageOrderValue">净销售客单价</OverviewColumnHint>
</th>
<th class="border-b border-l px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.productCost">商品成本</OverviewColumnHint>
@@ -268,11 +274,13 @@ const cellRoi = (v: number | null | undefined) =>
{{ cat.categoryName }}
</span>
</td>
<td class="p-6 font-black"><AnimatedMoneyCell :value="cat.salesAmount" /></td>
<td class="p-6 font-black text-amber-700 dark:text-amber-400"><AnimatedMoneyCell :value="cat.dealAmount" /></td>
<td class="p-6 font-medium">{{ formatIntCell(cat.orderCount) }}</td>
<td class="p-6 font-black"><AnimatedMoneyCell :value="cat.salesAmount" /></td>
<td class="p-6 font-medium">{{ formatIntCell(cat.dealOrderCount) }}</td>
<td class="p-6 font-medium">{{ formatIntCell(cat.salesOrderCount) }}</td>
<td class="p-6 font-medium"><AnimatedMoneyCell :value="cat.dealAverageOrderValue" /></td>
<td class="p-6 font-medium">
<AnimatedMoneyCell :value="cat.averageOrderValue" />
<AnimatedMoneyCell :value="cat.salesAverageOrderValue" />
</td>
<td class="p-6"><AnimatedMoneyCell :value="cat.productCost" /></td>
<td class="p-6"><AnimatedMoneyCell :value="cat.shippingCost" /></td>
@@ -317,11 +325,13 @@ const cellRoi = (v: number | null | undefined) =>
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<td class="sticky-col bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] p-6 text-base">合计</td>
<!-- 规模 -->
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.salesAmount" /></td>
<td class="p-6 text-amber-700 dark:text-amber-400"><AnimatedMoneyCell :value="categorySummary?.total?.dealAmount" /></td>
<td class="p-6">{{ formatIntCell(categorySummary?.total?.orderCount) }}</td>
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.salesAmount" /></td>
<td class="p-6">{{ formatIntCell(categorySummary?.total?.dealOrderCount) }}</td>
<td class="p-6">{{ formatIntCell(categorySummary?.total?.salesOrderCount) }}</td>
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.dealAverageOrderValue" /></td>
<td class="p-6">
<AnimatedMoneyCell :value="categorySummary?.total?.averageOrderValue" />
<AnimatedMoneyCell :value="categorySummary?.total?.salesAverageOrderValue" />
</td>
<!-- 成本 -->
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.productCost" /></td>
@@ -70,8 +70,10 @@ const platformData = computed(() => {
salesAmountAchievementRate: p.salesAmountAchievementRate ?? 0,
salesAmount: p.salesAmount ?? 0,
dealAmount: p.dealAmount ?? 0,
orderCount: p.orderCount ?? 0,
averageOrderValue: p.averageOrderValue ?? 0,
salesOrderCount: p.salesOrderCount ?? 0,
dealOrderCount: p.dealOrderCount ?? 0,
salesAverageOrderValue: p.salesAverageOrderValue ?? 0,
dealAverageOrderValue: p.dealAverageOrderValue ?? 0,
productCost: p.productCost ?? 0,
shippingCost: p.shippingCost ?? 0,
otherCost: p.otherCost ?? 0,
@@ -201,7 +203,7 @@ const sortedData = computed(() => {
</th>
<!-- 规模 -->
<th
colspan="4"
colspan="6"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] p-3 text-center bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50%)]"
>
经营规模维度
@@ -242,19 +244,25 @@ const sortedData = computed(() => {
</OverviewColumnHint>
</th>
<!-- 规模子列 -->
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-amber-700 dark:text-amber-400">
<OverviewColumnHint :title="storeOverviewHints.dealAmount">成交金额</OverviewColumnHint>
</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<OverviewColumnHint :title="storeOverviewHints.salesAmount">
净销售额
</OverviewColumnHint>
</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-amber-700 dark:text-amber-400">
<OverviewColumnHint :title="storeOverviewHints.dealAmount">成交金额</OverviewColumnHint>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.dealOrderCount">成交单量</OverviewColumnHint>
</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.orderCount">单量</OverviewColumnHint>
<OverviewColumnHint :title="storeOverviewHints.salesOrderCount">净销售单量</OverviewColumnHint>
</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.averageOrderValue">客单价</OverviewColumnHint>
<OverviewColumnHint :title="storeOverviewHints.dealAverageOrderValue">成交客单价</OverviewColumnHint>
</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.salesAverageOrderValue">净销售客单价</OverviewColumnHint>
</th>
<!-- 成本子列 -->
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">
@@ -344,10 +352,12 @@ const sortedData = computed(() => {
<td class="p-6 font-medium"><AnimatedMoneyCell :value="p.targetAmount" /></td>
<td class="p-6 font-black text-blue-600 dark:text-blue-400">{{ formatPercentPlain(p.salesAmountAchievementRate) }}</td>
<!-- 规模 -->
<td class="p-6 font-black"><AnimatedMoneyCell :value="p.salesAmount" /></td>
<td class="p-6 font-black text-amber-700 dark:text-amber-400"><AnimatedMoneyCell :value="p.dealAmount" /></td>
<td class="p-6 font-medium">{{ p.orderCount.toLocaleString('zh-CN') }}</td>
<td class="p-6 font-medium"><AnimatedMoneyCell :value="p.averageOrderValue" /></td>
<td class="p-6 font-black"><AnimatedMoneyCell :value="p.salesAmount" /></td>
<td class="p-6 font-medium">{{ formatIntCell(p.dealOrderCount) }}</td>
<td class="p-6 font-medium">{{ formatIntCell(p.salesOrderCount) }}</td>
<td class="p-6 font-medium"><AnimatedMoneyCell :value="p.dealAverageOrderValue" /></td>
<td class="p-6 font-medium"><AnimatedMoneyCell :value="p.salesAverageOrderValue" /></td>
<!-- 成本 -->
<td class="p-6"><AnimatedMoneyCell :value="p.productCost" /></td>
<td class="p-6"><AnimatedMoneyCell :value="p.shippingCost" /></td>
@@ -388,11 +398,15 @@ const sortedData = computed(() => {
{{ totalData.salesAmountAchievementRate !== undefined ? formatPercentPlain(totalData.salesAmountAchievementRate) : '-' }}
</td>
<!-- 规模 -->
<td class="p-6"><AnimatedMoneyCell :value="totalData.salesAmount" /></td>
<td class="p-6 text-amber-700 dark:text-amber-400"><AnimatedMoneyCell :value="totalData.dealAmount" /></td>
<td class="p-6">{{ formatIntCell(totalData.orderCount) }}</td>
<td class="p-6"><AnimatedMoneyCell :value="totalData.salesAmount" /></td>
<td class="p-6">{{ formatIntCell(totalData.dealOrderCount) }}</td>
<td class="p-6">{{ formatIntCell(totalData.salesOrderCount) }}</td>
<td class="p-6">
<AnimatedMoneyCell :value="totalData.averageOrderValue" />
<AnimatedMoneyCell :value="totalData.dealAverageOrderValue" />
</td>
<td class="p-6">
<AnimatedMoneyCell :value="totalData.salesAverageOrderValue" />
</td>
<!-- 成本 -->
<td class="p-6"><AnimatedMoneyCell :value="totalData.productCost" /></td>
@@ -149,7 +149,7 @@ const cellRoi = (v: number | null | undefined) =>
目标达成维度
</th>
<th
colspan="4"
colspan="6"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50%)] p-3 text-center"
>
经营规模维度
@@ -187,20 +187,26 @@ const cellRoi = (v: number | null | undefined) =>
销售达成率
</OverviewColumnHint>
</th>
<!-- 规模 -->
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<!-- 规模:成交在前,净销售在后 -->
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-amber-700 dark:text-amber-400">
<OverviewColumnHint :title="storeOverviewHints.dealAmount">成交金额</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<OverviewColumnHint :title="storeOverviewHints.salesAmount">
净销售额
</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 font-black text-amber-700 dark:text-amber-400">
<OverviewColumnHint :title="storeOverviewHints.dealAmount">成交金额</OverviewColumnHint>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.dealOrderCount">成交单量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.orderCount">单量</OverviewColumnHint>
<OverviewColumnHint :title="storeOverviewHints.salesOrderCount">净销售单量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.averageOrderValue">客单价</OverviewColumnHint>
<OverviewColumnHint :title="storeOverviewHints.dealAverageOrderValue">成交客单价</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.salesAverageOrderValue">净销售客单价</OverviewColumnHint>
</th>
<!-- 成本 -->
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">
@@ -308,17 +314,23 @@ const cellRoi = (v: number | null | undefined) =>
}}
</td>
<!-- 规模 -->
<td class="p-6 font-black">
<AnimatedMoneyCell :value="shop.salesAmount" />
</td>
<td class="p-6 font-black text-amber-700 dark:text-amber-400">
<AnimatedMoneyCell :value="shop.dealAmount" />
</td>
<td class="p-6 font-medium">
{{ formatIntCell(shop.orderCount) }}
<td class="p-6 font-black">
<AnimatedMoneyCell :value="shop.salesAmount" />
</td>
<td class="p-6 font-medium">
<AnimatedMoneyCell :value="shop.averageOrderValue" />
{{ formatIntCell(shop.dealOrderCount) }}
</td>
<td class="p-6 font-medium">
{{ formatIntCell(shop.salesOrderCount) }}
</td>
<td class="p-6 font-medium">
<AnimatedMoneyCell :value="shop.dealAverageOrderValue" />
</td>
<td class="p-6 font-medium">
<AnimatedMoneyCell :value="shop.salesAverageOrderValue" />
</td>
<!-- 成本 -->
<td class="p-6">
@@ -399,11 +411,15 @@ const cellRoi = (v: number | null | undefined) =>
}}
</td>
<!-- 规模 -->
<td class="p-6"><AnimatedMoneyCell :value="shopSummary?.total?.salesAmount" /></td>
<td class="p-6 text-amber-700 dark:text-amber-400"><AnimatedMoneyCell :value="shopSummary?.total?.dealAmount" /></td>
<td class="p-6">{{ formatIntCell(shopSummary?.total?.orderCount) }}</td>
<td class="p-6"><AnimatedMoneyCell :value="shopSummary?.total?.salesAmount" /></td>
<td class="p-6">{{ formatIntCell(shopSummary?.total?.dealOrderCount) }}</td>
<td class="p-6">{{ formatIntCell(shopSummary?.total?.salesOrderCount) }}</td>
<td class="p-6">
<AnimatedMoneyCell :value="shopSummary?.total?.averageOrderValue" />
<AnimatedMoneyCell :value="shopSummary?.total?.dealAverageOrderValue" />
</td>
<td class="p-6">
<AnimatedMoneyCell :value="shopSummary?.total?.salesAverageOrderValue" />
</td>
<!-- 成本 -->
<td class="p-6"><AnimatedMoneyCell :value="shopSummary?.total?.productCost" /></td>
@@ -7,9 +7,9 @@ const FINANCE_KPI_HINTS: Record<string, string> = {
成交销量: '计入成交状态的销售件数(不含已取消、未知)。',
成交客单价: '成交金额 / 成交单量。',
净销售额: overviewTableHints.salesAmount,
净销售单量: overviewTableHints.orderCount,
净销售单量: overviewTableHints.salesOrderCount,
净销售客单价: overviewTableHints.salesAverageOrderValue,
净销量: '成交销量 − 退款件数。',
净销售客单价: '净销售额 / 净销售单量。',
退款额: overviewTableHints.refundAmount,
退款率: '退款额 / 净销售额 * 100%。',
订单成本: overviewTableHints.orderCost,
@@ -36,9 +36,12 @@ function aggregateShopTotal(
const sum = (k: keyof CompanyOverviewVO.ShopSummary) =>
shops.reduce((a, x) => a + (Number(x[k]) || 0), 0);
const salesAmount = sum('salesAmount');
const orderCount = sum('orderCount') || 1;
const dealAmount = sum('dealAmount');
const salesOrderCount = sum('salesOrderCount');
const dealOrderCount = sum('dealOrderCount');
const totalPromotionFee = sum('totalPromotionFee');
const averageOrderValue = salesAmount / orderCount;
const salesAverageOrderValue = salesOrderCount ? salesAmount / salesOrderCount : 0;
const dealAverageOrderValue = dealOrderCount ? dealAmount / dealOrderCount : 0;
const feeRatio = salesAmount ? totalPromotionFee / salesAmount : 0;
return {
shopId: 0,
@@ -48,9 +51,11 @@ function aggregateShopTotal(
targetAmount: sum('targetAmount'),
salesAmountAchievementRate: sum('salesAmountAchievementRate'),
salesAmount,
dealAmount: sum('dealAmount'),
orderCount: sum('orderCount'),
averageOrderValue,
dealAmount,
salesOrderCount,
dealOrderCount,
salesAverageOrderValue,
dealAverageOrderValue,
productCost: sum('productCost'),
shippingCost: sum('shippingCost'),
otherCost: sum('otherCost'),
@@ -107,16 +112,21 @@ function aggregateCategoryTotal(
const sum = (k: keyof CompanyOverviewVO.CategorySummary) =>
rows.reduce((a, x) => a + (Number(x[k]) || 0), 0);
const salesAmount = sum('salesAmount');
const orderCount = sum('orderCount') || 1;
const dealAmount = sum('dealAmount');
const salesOrderCount = sum('salesOrderCount');
const dealOrderCount = sum('dealOrderCount');
const totalPromotionFee = sum('totalPromotionFee');
const averageOrderValue = salesAmount / orderCount;
const salesAverageOrderValue = salesOrderCount ? salesAmount / salesOrderCount : 0;
const dealAverageOrderValue = dealOrderCount ? dealAmount / dealOrderCount : 0;
const feeRatio = salesAmount ? totalPromotionFee / salesAmount : 0;
return {
categoryName: '合计',
salesAmount,
dealAmount: sum('dealAmount'),
orderCount: sum('orderCount'),
averageOrderValue,
dealAmount,
salesOrderCount,
dealOrderCount,
salesAverageOrderValue,
dealAverageOrderValue,
productCost: sum('productCost'),
shippingCost: sum('shippingCost'),
otherCost: sum('otherCost'),
@@ -171,9 +181,12 @@ function aggregatePlatformTotal(
const sum = (k: keyof CompanyOverviewVO.PlatformSummary) =>
rows.reduce((a, x) => a + (Number(x[k]) || 0), 0);
const salesAmount = sum('salesAmount');
const orderCount = sum('orderCount') || 1;
const dealAmount = sum('dealAmount');
const salesOrderCount = sum('salesOrderCount');
const dealOrderCount = sum('dealOrderCount');
const totalPromotionFee = sum('totalPromotionFee');
const averageOrderValue = salesAmount / orderCount;
const salesAverageOrderValue = salesOrderCount ? salesAmount / salesOrderCount : 0;
const dealAverageOrderValue = dealOrderCount ? dealAmount / dealOrderCount : 0;
const feeRatio = salesAmount ? totalPromotionFee / salesAmount : 0;
return {
platformCode: '',
@@ -183,9 +196,11 @@ function aggregatePlatformTotal(
targetAmount: sum('targetAmount'),
salesAmountAchievementRate: sum('salesAmountAchievementRate'),
salesAmount,
dealAmount: sum('dealAmount'),
orderCount: sum('orderCount'),
averageOrderValue,
dealAmount,
salesOrderCount,
dealOrderCount,
salesAverageOrderValue,
dealAverageOrderValue,
productCost: sum('productCost'),
shippingCost: sum('shippingCost'),
otherCost: sum('otherCost'),
@@ -117,7 +117,7 @@ const cellMoneyApi = (v: number | null | undefined) =>
>
品类名称
</th>
<th colspan="3" class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50)] p-3 text-center">
<th colspan="6" class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50)] p-3 text-center">
经营规模维度
</th>
<th colspan="8" class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] bg-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50)] p-3 text-center italic text-orange-700 dark:text-orange-400">
@@ -128,16 +128,25 @@ const cellMoneyApi = (v: number | null | undefined) =>
</th>
</tr>
<tr class="bg-slate-50/80 dark:bg-[hsl(240deg_3.7%_15.9%/80)] text-sm">
<th class="border-b border-l dark:border-l-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-slate-900 dark:bg-[hsl(240deg_3.7%_22%/50%)] dark:text-[hsl(0deg_0%_95%)]">
<th class="border-b border-l dark:border-l-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-amber-700 dark:bg-[hsl(240deg_3.7%_22%/50%)] dark:text-amber-400">
<OverviewColumnHint :title="overviewTableHints.dealAmount">成交金额</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 font-black text-slate-900 dark:bg-[hsl(240deg_3.7%_22%/50%)] dark:text-[hsl(0deg_0%_95%)]">
<OverviewColumnHint :title="overviewTableHints.salesAmount">
净销售额
</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 dark:bg-[hsl(240deg_3.7%_22%/50%)]">
<OverviewColumnHint :title="overviewTableHints.orderCount">单量</OverviewColumnHint>
<OverviewColumnHint :title="overviewTableHints.dealOrderCount">成交单量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 dark:bg-[hsl(240deg_3.7%_22%/50%)]">
<OverviewColumnHint :title="overviewTableHints.averageOrderValue">客单价</OverviewColumnHint>
<OverviewColumnHint :title="overviewTableHints.salesOrderCount">净销售单量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 dark:bg-[hsl(240deg_3.7%_22%/50%)]">
<OverviewColumnHint :title="overviewTableHints.dealAverageOrderValue">成交客单价</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 dark:bg-[hsl(240deg_3.7%_22%/50%)]">
<OverviewColumnHint :title="overviewTableHints.salesAverageOrderValue">净销售客单价</OverviewColumnHint>
</th>
<th class="border-b border-l dark:border-l-[hsl(240deg_3.7%_22%)] px-6 py-4 dark:bg-[hsl(24deg_9.8%_15%/50%)]">
<OverviewColumnHint :title="overviewTableHints.productCost">商品成本</OverviewColumnHint>
@@ -206,9 +215,12 @@ const cellMoneyApi = (v: number | null | undefined) =>
{{ cat.categoryName || '未分类' }}
</span>
</td>
<td class="p-6 font-black text-amber-700 dark:text-amber-400">{{ cellMoneyApi(cat.dealAmount) }}</td>
<td class="p-6 font-black">{{ formatCurrencyZhFromApi(cat.salesAmount) }}</td>
<td class="p-6">{{ formatIntCell(cat.orderCount) }}</td>
<td class="p-6">{{ cellMoneyApi(cat.averageOrderValue) }}</td>
<td class="p-6">{{ formatIntCell(cat.dealOrderCount) }}</td>
<td class="p-6">{{ formatIntCell(cat.salesOrderCount) }}</td>
<td class="p-6">{{ cellMoneyApi(cat.dealAverageOrderValue) }}</td>
<td class="p-6">{{ cellMoneyApi(cat.salesAverageOrderValue) }}</td>
<td class="border-l dark:border-l-[hsl(240deg_3.7%_22%)] p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoneyApi(cat.productCost) }}</td>
<td class="p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoneyApi(cat.shippingCost) }}</td>
<td class="p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoneyApi(cat.otherCost) }}</td>
@@ -232,7 +244,7 @@ const cellMoneyApi = (v: number | null | undefined) =>
</td>
</tr>
<tr v-if="!props.data?.categoryOverview?.categories?.length">
<td :colspan="props.categoryExportMode ? 18 : 17" class="p-8 text-center text-gray-400">
<td :colspan="props.categoryExportMode ? 21 : 20" class="p-8 text-center text-gray-400">
暂无数据
</td>
</tr>
@@ -241,9 +253,12 @@ const cellMoneyApi = (v: number | null | undefined) =>
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<td v-if="props.categoryExportMode" class="sticky-col border-r border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] p-6 text-center" style="left: 40px; position: sticky; z-index: 10;"></td>
<td class="sticky-col border-r-2 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4 text-base font-black" style="left: 0; position: sticky; z-index: 10;">合计</td>
<td class="p-6 text-amber-700 dark:text-amber-400">{{ cellMoneyApi(props.data.categoryOverview.total.dealAmount) }}</td>
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.salesAmount) }}</td>
<td class="p-6">{{ formatIntCell(props.data.categoryOverview.total.orderCount) }}</td>
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.averageOrderValue) }}</td>
<td class="p-6">{{ formatIntCell(props.data.categoryOverview.total.dealOrderCount) }}</td>
<td class="p-6">{{ formatIntCell(props.data.categoryOverview.total.salesOrderCount) }}</td>
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.dealAverageOrderValue) }}</td>
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.salesAverageOrderValue) }}</td>
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.productCost) }}</td>
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.shippingCost) }}</td>
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.otherCost) }}</td>
@@ -133,7 +133,7 @@ function goToProductOverview(productId: number) {
商品
</th>
<th
colspan="3"
colspan="6"
class="border-b border-l border-slate-200 dark:border-b dark:border-l dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50)] px-3 py-3 text-center"
>
商品规模 (Scale)
@@ -152,16 +152,25 @@ function goToProductOverview(productId: number) {
</th>
</tr>
<tr class="bg-slate-50/80 dark:bg-[hsl(240deg_3.7%_15.9%/80)] text-sm">
<th class="border-b px-6 py-4 dark:bg-[hsl(240deg_3.7%_15.9%/80%)]">
<th class="border-b px-6 py-4 font-black text-amber-700 dark:bg-[hsl(240deg_3.7%_15.9%/80%)] dark:text-amber-400">
<OverviewColumnHint :title="overviewTableHints.dealAmount">成交金额</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 font-black dark:bg-[hsl(240deg_3.7%_15.9%/80%)]">
<OverviewColumnHint :title="overviewTableHints.salesAmountShort">
净销售额
</OverviewColumnHint>
</th>
<th class="border-b border-l dark:border-l dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">
<OverviewColumnHint :title="overviewTableHints.orderCount">单量</OverviewColumnHint>
<th class="border-b px-6 py-4 dark:bg-[hsl(240deg_3.7%_15.9%/80%)]">
<OverviewColumnHint :title="overviewTableHints.dealOrderCount">成交单量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="overviewTableHints.averageOrderValue">客单价</OverviewColumnHint>
<th class="border-b px-6 py-4 dark:bg-[hsl(240deg_3.7%_15.9%/80%)]">
<OverviewColumnHint :title="overviewTableHints.salesOrderCount">净销售单量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 dark:bg-[hsl(240deg_3.7%_15.9%/80%)]">
<OverviewColumnHint :title="overviewTableHints.dealAverageOrderValue">成交客单价</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4 dark:bg-[hsl(240deg_3.7%_15.9%/80%)]">
<OverviewColumnHint :title="overviewTableHints.salesAverageOrderValue">净销售客单价</OverviewColumnHint>
</th>
<th class="border-b border-l dark:border-l dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">
<OverviewColumnHint :title="overviewTableHints.productCost">商品成本</OverviewColumnHint>
@@ -228,9 +237,12 @@ function goToProductOverview(productId: number) {
编码: {{ product.productCode }}
</div>
</td>
<td class="px-6 py-4 font-black text-amber-700 dark:text-amber-400">{{ cellMoneyApi(product.dealAmount) }}</td>
<td class="px-6 py-4 font-black">{{ formatCurrencyZhFromApi(product.salesAmount) }}</td>
<td class="px-6 py-4 font-medium">{{ formatIntCell(product.orderCount) }}</td>
<td class="px-6 py-4">{{ cellMoneyApi(product.averageOrderValue) }}</td>
<td class="px-6 py-4 font-medium">{{ formatIntCell(product.dealOrderCount) }}</td>
<td class="px-6 py-4 font-medium">{{ formatIntCell(product.salesOrderCount) }}</td>
<td class="px-6 py-4">{{ cellMoneyApi(product.dealAverageOrderValue) }}</td>
<td class="px-6 py-4">{{ cellMoneyApi(product.salesAverageOrderValue) }}</td>
<td class="px-6 py-4">{{ cellMoneyApi(product.productCost) }}</td>
<td class="px-6 py-4">{{ cellMoneyApi(product.shippingCost) }}</td>
<td class="px-6 py-4">{{ cellMoneyApi(product.otherCost) }}</td>
@@ -264,7 +276,7 @@ function goToProductOverview(productId: number) {
</td>
</tr>
<tr v-if="!data?.productOverview?.products?.length">
<td colspan="16" class="p-8 text-center text-gray-400">
<td colspan="19" class="p-8 text-center text-gray-400">
暂无数据
</td>
</tr>
@@ -272,9 +284,12 @@ function goToProductOverview(productId: number) {
<tfoot v-if="data?.productOverview?.total">
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<td class="sticky-col sticky bottom-0 border-r-2 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4 text-base font-black" style="left: 0; z-index: 30;">合计</td>
<td class="sticky bottom-0 bg-slate-100 text-amber-700 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-amber-400 px-6 py-4">{{ cellMoneyApi(data.productOverview.total.dealAmount) }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.salesAmount) }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ formatIntCell(data.productOverview.total.orderCount) }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.averageOrderValue) }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ formatIntCell(data.productOverview.total.dealOrderCount) }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ formatIntCell(data.productOverview.total.salesOrderCount) }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.dealAverageOrderValue) }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.salesAverageOrderValue) }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.productCost) }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.shippingCost) }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.otherCost) }}</td>