feat: 经营概览四张汇总表透出成交量与净销量

This commit is contained in:
2026-09-02 22:43:06 +08:00
parent acf8e06c86
commit 76df7701b2
18 changed files with 260 additions and 37 deletions
@@ -0,0 +1,12 @@
---
description: 每完成一个完整功能后给出一行 commit message
alwaysApply: true
---
# 功能完成后的提交消息
每完成一个**完整、可独立提交**的功能(或一组相关改动收尾)后,主动给出**一行**中文 conventional commit message,供用户直接复制提交。
- 格式:`feat:` / `fix:` / `refactor:` / `sql:` 等前缀 + 简洁说明(侧重 why)
- 不要主动执行 `git commit`,除非用户明确要求提交
- 若同一会话连续完成多个独立功能,每个功能收尾时各给一行,不要攒到最后一起写
@@ -232,6 +232,12 @@ public class CompanyOverviewVO {
/** 成交单量 */
private Integer dealOrderCount;
/** 成交量(件数) */
private Integer dealQuantitySum;
/** 净销量(件数)= 成交量 − 退款件数 */
private Integer salesQuantitySum;
/** 净销售客单价 = 净销售额 / 净销售单量 */
private BigDecimal salesAverageOrderValue;
@@ -284,6 +290,12 @@ public class CompanyOverviewVO {
/** 成交单量 */
private Integer dealOrderCount;
/** 成交量(件数) */
private Integer dealQuantitySum;
/** 净销量(件数)= 成交量 − 退款件数 */
private Integer salesQuantitySum;
/** 净销售客单价 = 净销售额 / 净销售单量 */
private BigDecimal salesAverageOrderValue;
@@ -344,6 +356,12 @@ public class CompanyOverviewVO {
/** 成交单量 */
private Integer dealOrderCount;
/** 成交量(件数) */
private Integer dealQuantitySum;
/** 净销量(件数)= 成交量 − 退款件数 */
private Integer salesQuantitySum;
/** 净销售客单价 = 净销售额 / 净销售单量 */
private BigDecimal salesAverageOrderValue;
@@ -235,6 +235,8 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
s.setDealAmount(c.getDealAmount());
s.setSalesOrderCount(c.getSalesOrderCount());
s.setDealOrderCount(c.getDealOrderCount());
s.setDealQuantitySum(c.getDealQuantitySum());
s.setSalesQuantitySum(c.getSalesQuantitySum());
s.setSalesAverageOrderValue(c.getSalesAverageOrderValue());
s.setDealAverageOrderValue(c.getDealAverageOrderValue());
s.setProductCost(c.getProductCost());
@@ -259,6 +261,8 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
BigDecimal totalDealAmount = BigDecimal.ZERO;
int totalSalesOrders = 0;
int totalDealOrders = 0;
int totalDealQuantity = 0;
int totalSalesQuantity = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
BigDecimal totalShippingCost = BigDecimal.ZERO;
BigDecimal totalOtherCost = BigDecimal.ZERO;
@@ -271,6 +275,8 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
totalDealAmount = totalDealAmount.add(c.getDealAmount() != null ? c.getDealAmount() : BigDecimal.ZERO);
totalSalesOrders += c.getSalesOrderCount() != null ? c.getSalesOrderCount() : 0;
totalDealOrders += c.getDealOrderCount() != null ? c.getDealOrderCount() : 0;
totalDealQuantity += c.getDealQuantitySum() != null ? c.getDealQuantitySum() : 0;
totalSalesQuantity += c.getSalesQuantitySum() != null ? c.getSalesQuantitySum() : 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);
@@ -304,6 +310,8 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
total.setDealAmount(totalDealAmount);
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setDealQuantitySum(totalDealQuantity);
total.setSalesQuantitySum(totalSalesQuantity);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setProductCost(totalProductCost);
@@ -341,7 +349,8 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
String taxHeader = taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP).toPlainString()
+ "%税额";
String[] headers = {
dimensionColumnHeader, "成交金额", "净销售额", "成交单量", "净销售单量", "成交客单价", "净销售客单价",
dimensionColumnHeader, "成交金额", "净销售额", "成交单量", "净销售单量", "成交量", "净销量",
"成交客单价", "净销售客单价",
"商品成本", "运费", "其他成本", "订单成本", "退款金额", taxHeader, "推广费", "刷单费",
"税前盈亏", "费比 %", "ROI", "税后盈亏"
};
@@ -384,24 +393,30 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
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);
Cell dealQty = row.createCell(5);
dealQty.setCellStyle(style);
dealQty.setCellValue(d.getDealQuantitySum() != null ? d.getDealQuantitySum() : 0);
Cell salesQty = row.createCell(6);
salesQty.setCellStyle(style);
salesQty.setCellValue(d.getSalesQuantitySum() != null ? d.getSalesQuantitySum() : 0);
setCell(row, 7, bd2Money(d.getDealAverageOrderValue()), style);
setCell(row, 8, bd2Money(d.getSalesAverageOrderValue()), style);
setCell(row, 9, bd2Money(d.getProductCost()), style);
setCell(row, 10, bd2Money(d.getShippingCost()), style);
setCell(row, 11, bd2Money(d.getOtherCost()), style);
setCell(row, 12, 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, 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);
setCell(row, 13, bd2Money(d.getRefundAmount()), style);
setCell(row, 14, bd2Money(salesTax), style);
setCell(row, 15, bd2Money(d.getTotalPromotionFee()), style);
setCell(row, 16, bd2Money(d.getBrushFee()), style);
setCell(row, 17, bd2Money(d.getTotalProfitBeforeTax()), style);
setCell(row, 18, bd2FeeRatioPercent(d.getFeeRatio()), style);
setCell(row, 19, bd2Roi(d.getRoi()), style);
setCell(row, 20, bd2Money(profitAfterTax), style);
}
private static double bd2Money(BigDecimal v) {
@@ -69,6 +69,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
BigDecimal totalSales = BigDecimal.ZERO;
int totalSalesOrders = 0;
int totalDealOrders = 0;
int totalDealQuantity = 0;
int totalSalesQuantity = 0;
BigDecimal totalTargetAmount = BigDecimal.ZERO;
int totalTargetOrders = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
@@ -86,6 +88,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
totalGrossProfit = totalGrossProfit.add(s.getGrossProfit() != null ? s.getGrossProfit() : BigDecimal.ZERO);
totalSalesOrders += s.getSalesOrderCount() != null ? s.getSalesOrderCount() : 0;
totalDealOrders += s.getDealOrderCount() != null ? s.getDealOrderCount() : 0;
totalDealQuantity += s.getDealQuantitySum() != null ? s.getDealQuantitySum() : 0;
totalSalesQuantity += s.getSalesQuantitySum() != null ? s.getSalesQuantitySum() : 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);
@@ -129,6 +133,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setGrossProfit(totalGrossProfit.setScale(2, RoundingMode.HALF_UP));
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setDealQuantitySum(totalDealQuantity);
total.setSalesQuantitySum(totalSalesQuantity);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setTargetAmount(totalTargetAmount);
@@ -155,6 +161,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
BigDecimal totalSales = BigDecimal.ZERO;
int totalSalesOrders = 0;
int totalDealOrders = 0;
int totalDealQuantity = 0;
int totalSalesQuantity = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
BigDecimal totalShippingCost = BigDecimal.ZERO;
BigDecimal totalOtherCost = BigDecimal.ZERO;
@@ -170,6 +178,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
totalGrossProfit = totalGrossProfit.add(c.getGrossProfit() != null ? c.getGrossProfit() : BigDecimal.ZERO);
totalSalesOrders += c.getSalesOrderCount() != null ? c.getSalesOrderCount() : 0;
totalDealOrders += c.getDealOrderCount() != null ? c.getDealOrderCount() : 0;
totalDealQuantity += c.getDealQuantitySum() != null ? c.getDealQuantitySum() : 0;
totalSalesQuantity += c.getSalesQuantitySum() != null ? c.getSalesQuantitySum() : 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);
@@ -204,6 +214,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setGrossProfit(totalGrossProfit.setScale(2, RoundingMode.HALF_UP));
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setDealQuantitySum(totalDealQuantity);
total.setSalesQuantitySum(totalSalesQuantity);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setProductCost(totalProductCost);
@@ -226,6 +238,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
BigDecimal totalSalesAmount = BigDecimal.ZERO;
int totalSalesOrders = 0;
int totalDealOrders = 0;
int totalDealQuantity = 0;
int totalSalesQuantity = 0;
BigDecimal totalTargetAmount = BigDecimal.ZERO;
int totalTargetOrderCount = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
@@ -243,6 +257,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
totalGrossProfit = totalGrossProfit.add(p.getGrossProfit() != null ? p.getGrossProfit() : BigDecimal.ZERO);
totalSalesOrders += p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0;
totalDealOrders += p.getDealOrderCount() != null ? p.getDealOrderCount() : 0;
totalDealQuantity += p.getDealQuantitySum() != null ? p.getDealQuantitySum() : 0;
totalSalesQuantity += p.getSalesQuantitySum() != null ? p.getSalesQuantitySum() : 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);
@@ -286,6 +302,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setGrossProfit(totalGrossProfit.setScale(2, RoundingMode.HALF_UP));
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setDealQuantitySum(totalDealQuantity);
total.setSalesQuantitySum(totalSalesQuantity);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setTargetAmount(totalTargetAmount);
@@ -547,6 +565,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
s.setDealAmount(m.dealAmount);
s.setSalesOrderCount(m.salesOrderCount);
s.setDealOrderCount(m.dealOrderCount);
s.setDealQuantitySum(m.dealQuantitySum);
s.setSalesQuantitySum(m.salesQuantitySum);
s.setSalesAverageOrderValue(aov(m.sales, m.salesOrderCount));
s.setDealAverageOrderValue(aov(m.dealAmount, m.dealOrderCount));
s.setProductCost(m.productCost);
@@ -576,6 +596,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
s.setDealAmount(m.dealAmount);
s.setSalesOrderCount(m.salesOrderCount);
s.setDealOrderCount(m.dealOrderCount);
s.setDealQuantitySum(m.dealQuantitySum);
s.setSalesQuantitySum(m.salesQuantitySum);
s.setSalesAverageOrderValue(aov(m.sales, m.salesOrderCount));
s.setDealAverageOrderValue(aov(m.dealAmount, m.dealOrderCount));
s.setProductCost(m.productCost);
@@ -601,6 +623,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
s.setDealAmount(m.dealAmount);
s.setSalesOrderCount(m.salesOrderCount);
s.setDealOrderCount(m.dealOrderCount);
s.setDealQuantitySum(m.dealQuantitySum);
s.setSalesQuantitySum(m.salesQuantitySum);
s.setSalesAverageOrderValue(aov(m.sales, m.salesOrderCount));
s.setDealAverageOrderValue(aov(m.dealAmount, m.dealOrderCount));
s.setProductCost(m.productCost);
@@ -759,6 +783,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
BigDecimal dealAmount = BigDecimal.ZERO;
int salesOrderCount;
int dealOrderCount;
int dealQuantitySum;
int salesQuantitySum;
BigDecimal refund = BigDecimal.ZERO;
BigDecimal productCost = BigDecimal.ZERO;
BigDecimal freightCost = BigDecimal.ZERO;
@@ -780,6 +806,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
a.dealAmount = nz(row.getDealAmount());
a.salesOrderCount = row.getOrderCount() != null ? row.getOrderCount().intValue() : 0;
a.dealOrderCount = row.getDealOrderCount() != null ? row.getDealOrderCount().intValue() : 0;
a.dealQuantitySum = row.getDealQuantitySum() != null ? row.getDealQuantitySum().intValue() : 0;
a.salesQuantitySum = row.getSalesQuantitySum() != null ? row.getSalesQuantitySum().intValue() : 0;
a.refund = nz(row.getRefundAmount());
a.productCost = nz(row.getProductCost());
a.freightCost = nz(row.getFreightCost());
@@ -793,6 +821,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
a.dealAmount = dealAmount.add(o.dealAmount);
a.salesOrderCount = salesOrderCount + o.salesOrderCount;
a.dealOrderCount = dealOrderCount + o.dealOrderCount;
a.dealQuantitySum = dealQuantitySum + o.dealQuantitySum;
a.salesQuantitySum = salesQuantitySum + o.salesQuantitySum;
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", "税后净利"
};
@@ -173,27 +173,29 @@ public class ExportServiceImpl implements ExportService {
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);
setCell(row, 9, objToDouble(data.get("dealQuantitySum")), style);
setCell(row, 10, objToDouble(data.get("salesQuantitySum")), style);
setCell(row, 11, objToDouble(data.get("dealAvgOrderValue")), style);
setCell(row, 12, objToDouble(data.get("salesAvgOrderValue")), style);
setCell(row, 13, objToDouble(data.get("productCost")), style);
setCell(row, 14, objToDouble(data.get("shippingCost")), style);
setCell(row, 15, objToDouble(data.get("otherCost")), style);
setCell(row, 16, 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, 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);
setCell(row, 17, objToDouble(data.get("refundAmount")), style);
setCell(row, 18, salesTax.doubleValue(), style);
setCell(row, 19, objToDouble(data.get("totalPromotionFee")), style);
setCell(row, 20, objToDouble(data.get("brushFee")), style);
setCell(row, 21, objToDouble(data.get("grossProfit")), style);
setCell(row, 22, objToDouble(data.get("totalProfitBeforeTax")), style);
setCell(row, 23, objToDouble(data.get("feeRatio")), style);
setCell(row, 24, objToDouble(data.get("roi")), style);
setCell(row, 25, profitAfterTax.doubleValue(), style);
}
private static BigDecimal mapToBigDecimal(Object val) {
@@ -223,6 +225,8 @@ public class ExportServiceImpl implements ExportService {
data.put("salesAmount", s.getSalesAmount());
data.put("dealOrderCount", s.getDealOrderCount());
data.put("salesOrderCount", s.getSalesOrderCount());
data.put("dealQuantitySum", s.getDealQuantitySum());
data.put("salesQuantitySum", s.getSalesQuantitySum());
data.put("dealAvgOrderValue", s.getDealAverageOrderValue());
data.put("salesAvgOrderValue", s.getSalesAverageOrderValue());
data.put("productCost", s.getProductCost());
@@ -257,6 +261,8 @@ public class ExportServiceImpl implements ExportService {
BigDecimal totalDealAmount = BigDecimal.ZERO;
int totalSalesOrders = 0;
int totalDealOrders = 0;
int totalDealQuantity = 0;
int totalSalesQuantity = 0;
BigDecimal totalTargetAmount = BigDecimal.ZERO;
int totalTargetOrders = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
@@ -271,6 +277,8 @@ public class ExportServiceImpl implements ExportService {
totalDealAmount = totalDealAmount.add(s.getDealAmount() != null ? s.getDealAmount() : BigDecimal.ZERO);
totalSalesOrders += s.getSalesOrderCount() != null ? s.getSalesOrderCount() : 0;
totalDealOrders += s.getDealOrderCount() != null ? s.getDealOrderCount() : 0;
totalDealQuantity += s.getDealQuantitySum() != null ? s.getDealQuantitySum() : 0;
totalSalesQuantity += s.getSalesQuantitySum() != null ? s.getSalesQuantitySum() : 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);
@@ -313,6 +321,8 @@ public class ExportServiceImpl implements ExportService {
total.setDealAmount(totalDealAmount);
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setDealQuantitySum(totalDealQuantity);
total.setSalesQuantitySum(totalSalesQuantity);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setTargetAmount(totalTargetAmount);
@@ -345,6 +355,8 @@ public class ExportServiceImpl implements ExportService {
data.put("salesAmount", s.getSalesAmount());
data.put("dealOrderCount", s.getDealOrderCount());
data.put("salesOrderCount", s.getSalesOrderCount());
data.put("dealQuantitySum", s.getDealQuantitySum());
data.put("salesQuantitySum", s.getSalesQuantitySum());
data.put("dealAvgOrderValue", s.getDealAverageOrderValue());
data.put("salesAvgOrderValue", s.getSalesAverageOrderValue());
data.put("productCost", s.getProductCost());
@@ -369,6 +381,8 @@ public class ExportServiceImpl implements ExportService {
BigDecimal totalDealAmount = BigDecimal.ZERO;
int totalSalesOrders = 0;
int totalDealOrders = 0;
int totalDealQuantity = 0;
int totalSalesQuantity = 0;
BigDecimal totalTargetAmount = BigDecimal.ZERO;
int totalTargetOrders = 0;
BigDecimal totalProductCost = BigDecimal.ZERO;
@@ -383,6 +397,8 @@ public class ExportServiceImpl implements ExportService {
totalDealAmount = totalDealAmount.add(s.getDealAmount() != null ? s.getDealAmount() : BigDecimal.ZERO);
totalSalesOrders += s.getSalesOrderCount() != null ? s.getSalesOrderCount() : 0;
totalDealOrders += s.getDealOrderCount() != null ? s.getDealOrderCount() : 0;
totalDealQuantity += s.getDealQuantitySum() != null ? s.getDealQuantitySum() : 0;
totalSalesQuantity += s.getSalesQuantitySum() != null ? s.getSalesQuantitySum() : 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);
@@ -425,6 +441,8 @@ public class ExportServiceImpl implements ExportService {
total.setDealAmount(totalDealAmount);
total.setSalesOrderCount(totalSalesOrders);
total.setDealOrderCount(totalDealOrders);
total.setDealQuantitySum(totalDealQuantity);
total.setSalesQuantitySum(totalSalesQuantity);
total.setSalesAverageOrderValue(salesAvgOrderValue);
total.setDealAverageOrderValue(dealAvgOrderValue);
total.setTargetAmount(totalTargetAmount);
@@ -178,6 +178,12 @@ public class ShopOverviewStatisticsVO {
/** 成交单量 */
private Integer dealOrderCount;
/** 成交量(件数) */
private Integer dealQuantitySum;
/** 净销量(件数)= 成交量 − 退款件数 */
private Integer salesQuantitySum;
/** 净销售客单价 */
private BigDecimal salesAverageOrderValue;
@@ -228,6 +234,12 @@ public class ShopOverviewStatisticsVO {
/** 成交单量 */
private Integer dealOrderCount;
/** 成交量(件数) */
private Integer dealQuantitySum;
/** 净销量(件数)= 成交量 − 退款件数 */
private Integer salesQuantitySum;
/** 净销售客单价 */
private BigDecimal salesAverageOrderValue;
@@ -330,6 +330,8 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
s.setDealAmount(c.getDealAmount());
s.setSalesOrderCount(c.getSalesOrderCount());
s.setDealOrderCount(c.getDealOrderCount());
s.setDealQuantitySum(c.getDealQuantitySum());
s.setSalesQuantitySum(c.getSalesQuantitySum());
s.setSalesAverageOrderValue(c.getSalesAverageOrderValue());
s.setDealAverageOrderValue(c.getDealAverageOrderValue());
s.setProductCost(c.getProductCost());
@@ -64,4 +64,9 @@ public interface CategoryService extends IService<CategoryPO> {
/** 按公司 + 名称精确查找(公司内名称唯一)。 */
CategoryPO getByCompanyIdAndName(Long companyId, String name);
/**
* 自身及全部下级类目 ID(含 categoryId);类目不存在或不属于公司时返回空列表。
*/
List<Long> listSelfAndDescendantIds(Long companyId, Long categoryId);
}
@@ -231,6 +231,37 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, CategoryPO>
.last("LIMIT 1"));
}
@Override
public List<Long> listSelfAndDescendantIds(Long companyId, Long categoryId) {
if (companyId == null || categoryId == null) {
return List.of();
}
CategoryPO root = this.getById(categoryId);
if (root == null || !companyId.equals(root.getCompanyId())) {
return List.of();
}
List<CategoryPO> all = this.list(new LambdaQueryWrapper<CategoryPO>()
.eq(CategoryPO::getCompanyId, companyId)
.select(CategoryPO::getId, CategoryPO::getParentId));
Map<Long, List<Long>> childrenByParent = all.stream()
.filter(c -> c.getParentId() != null)
.collect(Collectors.groupingBy(
CategoryPO::getParentId,
Collectors.mapping(CategoryPO::getId, Collectors.toList())));
List<Long> result = new ArrayList<>();
collectSelfAndDescendants(categoryId, childrenByParent, result);
return result;
}
/** 深度优先收集自身及下级 ID */
private void collectSelfAndDescendants(
Long id, Map<Long, List<Long>> childrenByParent, List<Long> out) {
out.add(id);
for (Long childId : childrenByParent.getOrDefault(id, List.of())) {
collectSelfAndDescendants(childId, childrenByParent, out);
}
}
/**
* 检查 targetId 是否是 ancestorId 的后代
*/
@@ -13,7 +13,7 @@ public class ProductFilterDTO {
private String name;
/**
* 类目ID(精准查询)
* 类目 ID(含自身及全部下级)
*/
private Long categoryId;
@@ -616,9 +616,15 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductPO> im
wrapper.eq(ProductPO::getProductCode, filter.getProductCode());
}
// 类目ID(精准查询)
// 类目:选中节点及其全部下级
if (filter.getCategoryId() != null) {
wrapper.eq(ProductPO::getCategoryId, filter.getCategoryId());
List<Long> categoryIds = categoryService.listSelfAndDescendantIds(
companyId, filter.getCategoryId());
if (categoryIds.isEmpty()) {
return PageResultVO.create(
List.of(), 0L, pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
}
wrapper.in(ProductPO::getCategoryId, categoryIds);
}
// 处理规格相关的过滤条件
@@ -100,6 +100,10 @@ export namespace CompanyOverviewVO {
salesOrderCount?: number;
/** 成交单量 */
dealOrderCount?: number;
/** 成交量(件数) */
dealQuantitySum?: number;
/** 净销量(件数) */
salesQuantitySum?: number;
/** 净销售客单价 */
salesAverageOrderValue?: number;
/** 成交客单价 */
@@ -129,6 +133,8 @@ export namespace CompanyOverviewVO {
dealAmount?: number;
salesOrderCount?: number;
dealOrderCount?: number;
dealQuantitySum?: number;
salesQuantitySum?: number;
salesAverageOrderValue?: number;
dealAverageOrderValue?: number;
productCost?: number;
@@ -158,6 +164,8 @@ export namespace CompanyOverviewVO {
dealAmount?: number;
salesOrderCount?: number;
dealOrderCount?: number;
dealQuantitySum?: number;
salesQuantitySum?: number;
salesAverageOrderValue?: number;
dealAverageOrderValue?: number;
productCost?: number;
@@ -99,6 +99,8 @@ export namespace ProductDTO {
skuCode?: string;
/** SKU 名称(模糊查询) */
skuName?: string;
/** 类目 ID(含自身及全部下级) */
categoryId?: number;
/** 关键字(模糊查询商品名称、商品编码、SKU 名称、SKU 编码) */
keywords?: string;
}
@@ -14,6 +14,8 @@ export const overviewTableHints = {
salesAmountShort: '成交金额 − 退款额(不含已取消、未知订单)。',
salesOrderCount: '净销售单量 = 成交单量 − 退款单量。',
dealOrderCount: '计入成交状态的订单笔数(不含已取消、未知)。',
dealQuantitySum: '计入成交状态的商品件数合计(不含已取消、未知)。',
salesQuantitySum: '净销量 = 成交量 − 退款件数。',
salesAverageOrderValue: '净销售额 / 净销售单量。',
dealAverageOrderValue: '成交金额 / 成交单量。',
/** @deprecated 使用 salesOrderCount */
@@ -148,7 +148,7 @@ const cellRoi = (v: number | null | undefined) =>
{{ props.firstColumnLabel }}
</th>
<th
colspan="6"
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%)] dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50%)] p-3 text-center"
>
经营规模维度
@@ -181,6 +181,12 @@ const cellRoi = (v: number | null | undefined) =>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.salesOrderCount">净销售单量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.dealQuantitySum">成交量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.salesQuantitySum">净销量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.dealAverageOrderValue">成交客单价</OverviewColumnHint>
</th>
@@ -281,6 +287,8 @@ const cellRoi = (v: number | null | undefined) =>
<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">{{ formatIntCell(cat.dealQuantitySum) }}</td>
<td class="p-6 font-medium">{{ formatIntCell(cat.salesQuantitySum) }}</td>
<td class="p-6 font-medium"><AnimatedMoneyCell :value="cat.dealAverageOrderValue" /></td>
<td class="p-6 font-medium">
<AnimatedMoneyCell :value="cat.salesAverageOrderValue" />
@@ -332,6 +340,8 @@ const cellRoi = (v: number | null | undefined) =>
<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">{{ formatIntCell(categorySummary?.total?.dealQuantitySum) }}</td>
<td class="p-6">{{ formatIntCell(categorySummary?.total?.salesQuantitySum) }}</td>
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.dealAverageOrderValue" /></td>
<td class="p-6">
<AnimatedMoneyCell :value="categorySummary?.total?.salesAverageOrderValue" />
@@ -73,6 +73,8 @@ const platformData = computed(() => {
dealAmount: p.dealAmount ?? 0,
salesOrderCount: p.salesOrderCount ?? 0,
dealOrderCount: p.dealOrderCount ?? 0,
dealQuantitySum: p.dealQuantitySum ?? 0,
salesQuantitySum: p.salesQuantitySum ?? 0,
salesAverageOrderValue: p.salesAverageOrderValue ?? 0,
dealAverageOrderValue: p.dealAverageOrderValue ?? 0,
productCost: p.productCost ?? 0,
@@ -206,7 +208,7 @@ const sortedData = computed(() => {
</th>
<!-- 规模 -->
<th
colspan="6"
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%)] p-3 text-center bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50%)]"
>
经营规模维度
@@ -261,6 +263,12 @@ const sortedData = computed(() => {
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
<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.dealQuantitySum">成交量</OverviewColumnHint>
</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.salesQuantitySum">净销量</OverviewColumnHint>
</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.dealAverageOrderValue">成交客单价</OverviewColumnHint>
</th>
@@ -359,6 +367,8 @@ const sortedData = computed(() => {
<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">{{ formatIntCell(p.dealQuantitySum) }}</td>
<td class="p-6 font-medium">{{ formatIntCell(p.salesQuantitySum) }}</td>
<td class="p-6 font-medium"><AnimatedMoneyCell :value="p.dealAverageOrderValue" /></td>
<td class="p-6 font-medium"><AnimatedMoneyCell :value="p.salesAverageOrderValue" /></td>
<!-- 成本 -->
@@ -405,6 +415,8 @@ const sortedData = computed(() => {
<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">{{ formatIntCell(totalData.dealQuantitySum) }}</td>
<td class="p-6">{{ formatIntCell(totalData.salesQuantitySum) }}</td>
<td class="p-6">
<AnimatedMoneyCell :value="totalData.dealAverageOrderValue" />
</td>
@@ -152,7 +152,7 @@ const cellRoi = (v: number | null | undefined) =>
目标达成维度
</th>
<th
colspan="6"
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%)] dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50%)] p-3 text-center"
>
经营规模维度
@@ -205,6 +205,12 @@ const cellRoi = (v: number | null | undefined) =>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.salesOrderCount">净销售单量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.dealQuantitySum">成交量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.salesQuantitySum">净销量</OverviewColumnHint>
</th>
<th class="border-b px-6 py-4">
<OverviewColumnHint :title="storeOverviewHints.dealAverageOrderValue">成交客单价</OverviewColumnHint>
</th>
@@ -329,6 +335,12 @@ const cellRoi = (v: number | null | undefined) =>
<td class="p-6 font-medium">
{{ formatIntCell(shop.salesOrderCount) }}
</td>
<td class="p-6 font-medium">
{{ formatIntCell(shop.dealQuantitySum) }}
</td>
<td class="p-6 font-medium">
{{ formatIntCell(shop.salesQuantitySum) }}
</td>
<td class="p-6 font-medium">
<AnimatedMoneyCell :value="shop.dealAverageOrderValue" />
</td>
@@ -418,6 +430,8 @@ const cellRoi = (v: number | null | undefined) =>
<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">{{ formatIntCell(shopSummary?.total?.dealQuantitySum) }}</td>
<td class="p-6">{{ formatIntCell(shopSummary?.total?.salesQuantitySum) }}</td>
<td class="p-6">
<AnimatedMoneyCell :value="shopSummary?.total?.dealAverageOrderValue" />
</td>
@@ -24,6 +24,7 @@ import {
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getProductPageApi } from '#/api/ec/product';
import { getCategoryTreeApi } from '#/api/ec/product/category';
import { PermissionGate } from '#/components/permission';
import { usePermission } from '#/composables/use-permission';
@@ -69,6 +70,7 @@ const searchForm = ref({
productCode: '',
skuCode: '',
skuName: '',
categoryId: undefined as number | undefined,
});
/** 提取 SKU 编码列表 */
@@ -199,6 +201,9 @@ const gridOptions: VxeGridProps<ProductVO.Info> = {
skuName:
String(searchParams.skuName ?? searchForm.value.skuName ?? '').trim() ||
undefined,
categoryId:
(searchParams.categoryId as number | undefined) ??
searchForm.value.categoryId,
};
const params: PageQueryDTO<ProductDTO.Filters> = {
page: page.currentPage,
@@ -281,6 +286,27 @@ const formOptions = computed(() => ({
fieldName: 'skuCode',
label: 'SKU 编码',
},
{
component: 'ApiTreeSelect',
componentProps: {
placeholder: '请选择类目(含下级)',
allowClear: true,
showSearch: true,
treeDefaultExpandAll: true,
treeNodeFilterProp: 'label',
api: getCategoryTreeApi,
labelField: 'name',
valueField: 'id',
childrenField: 'children',
class: 'w-full',
onChange: (val: number | undefined) => {
searchForm.value.categoryId = val;
gridReloadRef.value?.();
},
},
fieldName: 'categoryId',
label: '商品类目',
},
],
showDefaultActions: true,
collapsed: true,