feat(ecom): 产品概况增加总成本字段及按自动统计状态过滤订单

- CompanyOverviewVO 新增 totalCost 字段(商品成本+运费+其他成本)
- ProductOverviewServiceImpl 查询订单时仅统计 autoStatistics=1 的订单状态
- 同步前端 types.vo.ts 及各组件展示总成本
- SQL 迁移文件整理至 sql/migration/ 目录
This commit is contained in:
小蟑螂
2026-05-05 12:06:09 +08:00
parent 17bbae66a1
commit 44662a4790
14 changed files with 116 additions and 51 deletions
@@ -285,6 +285,9 @@ public class CompanyOverviewVO {
@Schema(description = "其他成本", example = "1000.00") @Schema(description = "其他成本", example = "1000.00")
private BigDecimal otherCost; private BigDecimal otherCost;
@Schema(description = "总成本(商品成本+运费+其他成本)", example = "5000.00")
private BigDecimal totalCost;
@Schema(description = "退款金额", example = "1000.00") @Schema(description = "退款金额", example = "1000.00")
private BigDecimal refundAmount; private BigDecimal refundAmount;
@@ -344,6 +347,8 @@ public class CompanyOverviewVO {
@Schema(description = "其他成本", example = "1000.00") @Schema(description = "其他成本", example = "1000.00")
private BigDecimal otherCost; private BigDecimal otherCost;
@Schema(description = "总成本(商品成本+运费+其他成本)", example = "5000.00")
private BigDecimal totalCost;
@Schema(description = "退款金额", example = "1000.00") @Schema(description = "退款金额", example = "1000.00")
private BigDecimal refundAmount; private BigDecimal refundAmount;
@@ -360,11 +365,9 @@ public class CompanyOverviewVO {
@Schema(description = "税前盈亏", example = "35000.00") @Schema(description = "税前盈亏", example = "35000.00")
private BigDecimal totalProfitBeforeTax; private BigDecimal totalProfitBeforeTax;
@Schema(description = "销售额4%税额", example = "2000.00") @Schema(description = "销售额4%税额", example = "2000.00")
private BigDecimal salesTaxAmount; private BigDecimal salesTaxAmount;
@Schema(description = "税后盈亏", example = "30000.00") @Schema(description = "税后盈亏", example = "30000.00")
private BigDecimal profitAfterTax; private BigDecimal profitAfterTax;
@@ -414,6 +417,9 @@ public class CompanyOverviewVO {
@Schema(description = "其他成本", example = "3200.00") @Schema(description = "其他成本", example = "3200.00")
private BigDecimal otherCost; private BigDecimal otherCost;
@Schema(description = "总成本(商品成本+运费+其他成本)", example = "167700.00")
private BigDecimal totalCost;
@Schema(description = "退款金额", example = "12600.00") @Schema(description = "退款金额", example = "12600.00")
private BigDecimal refundAmount; private BigDecimal refundAmount;
@@ -231,6 +231,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
data.setProductCost(productCost); data.setProductCost(productCost);
data.setShippingCost(shippingCost); data.setShippingCost(shippingCost);
data.setOtherCost(otherCost); data.setOtherCost(otherCost);
data.setTotalCost(totalCost);
data.setRefundAmount(refundAmount); data.setRefundAmount(refundAmount);
data.setTotalPromotionFee(totalPromotionFee); data.setTotalPromotionFee(totalPromotionFee);
data.setBrushFee(totalBrushFee); data.setBrushFee(totalBrushFee);
@@ -272,18 +273,18 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
CellStyle headerStyle = createHeaderStyle(sheet.getWorkbook()); CellStyle headerStyle = createHeaderStyle(sheet.getWorkbook());
CellStyle dataStyle = createDataStyle(sheet.getWorkbook()); CellStyle dataStyle = createDataStyle(sheet.getWorkbook());
String taxLabel = taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP).toPlainString() + "%税额";
String[] headers = {
"品类名称", "销售额", "单量", "客单价",
"商品成本", "运费", "其他成本", "总成本", "退款金额", "推广费", "刷单费用",
"费比", "税前盈亏", taxLabel, "税后盈亏", "ROI"
};
Row titleRow = sheet.createRow(0); Row titleRow = sheet.createRow(0);
Cell titleCell = titleRow.createCell(0); Cell titleCell = titleRow.createCell(0);
titleCell.setCellValue("品类明细 | " + dateRangeLabel); titleCell.setCellValue("品类明细 | " + dateRangeLabel);
titleCell.setCellStyle(titleStyle); titleCell.setCellStyle(titleStyle);
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 13)); sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headers.length - 1));
String taxLabel = taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP).toPlainString() + "%税额";
String[] headers = {
"品类名称", "销售额", "单量", "客单价",
"商品成本", "运费", "其他成本", "退款金额", "推广费", "刷单费用",
"费比", "税前盈亏", taxLabel, "税后盈亏", "ROI"
};
Row headerRow = sheet.createRow(1); Row headerRow = sheet.createRow(1);
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
@@ -302,14 +303,15 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
setCell(row, 4, objToDouble(data.getProductCost()), dataStyle); setCell(row, 4, objToDouble(data.getProductCost()), dataStyle);
setCell(row, 5, objToDouble(data.getShippingCost()), dataStyle); setCell(row, 5, objToDouble(data.getShippingCost()), dataStyle);
setCell(row, 6, objToDouble(data.getOtherCost()), dataStyle); setCell(row, 6, objToDouble(data.getOtherCost()), dataStyle);
setCell(row, 7, objToDouble(data.getRefundAmount()), dataStyle); setCell(row, 7, objToDouble(data.getTotalCost()), dataStyle);
setCell(row, 8, objToDouble(data.getTotalPromotionFee()), dataStyle); setCell(row, 8, objToDouble(data.getRefundAmount()), dataStyle);
setCell(row, 9, objToDouble(data.getBrushFee()), dataStyle); setCell(row, 9, objToDouble(data.getTotalPromotionFee()), dataStyle);
setCell(row, 10, objToDouble(data.getFeeRatio()), dataStyle); setCell(row, 10, objToDouble(data.getBrushFee()), dataStyle);
setCell(row, 11, objToDouble(data.getTotalProfitBeforeTax()), dataStyle); setCell(row, 11, objToDouble(data.getFeeRatio()), dataStyle);
setCell(row, 12, objToDouble(data.getSalesTaxAmount()), dataStyle); setCell(row, 12, objToDouble(data.getTotalProfitBeforeTax()), dataStyle);
setCell(row, 13, objToDouble(data.getProfitAfterTax()), dataStyle); setCell(row, 13, objToDouble(data.getSalesTaxAmount()), dataStyle);
setCell(row, 14, objToDouble(data.getRoi()), dataStyle); setCell(row, 14, objToDouble(data.getProfitAfterTax()), dataStyle);
setCell(row, 15, objToDouble(data.getRoi()), dataStyle);
} }
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
@@ -616,6 +616,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
comparison.setProductCost(productCost); comparison.setProductCost(productCost);
comparison.setShippingCost(shippingCost); comparison.setShippingCost(shippingCost);
comparison.setOtherCost(otherCost); comparison.setOtherCost(otherCost);
comparison.setTotalCost(productCost.add(shippingCost).add(otherCost));
comparison.setRefundAmount(refundAmount); comparison.setRefundAmount(refundAmount);
comparison.setTotalPromotionFee(totalPromotionFee); comparison.setTotalPromotionFee(totalPromotionFee);
comparison.setBrushFee(brushFee); comparison.setBrushFee(brushFee);
@@ -702,6 +703,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setProductCost(totalProductCost); total.setProductCost(totalProductCost);
total.setShippingCost(totalShippingCost); total.setShippingCost(totalShippingCost);
total.setOtherCost(totalOtherCost); total.setOtherCost(totalOtherCost);
total.setTotalCost(totalCost);
total.setRefundAmount(totalRefund); total.setRefundAmount(totalRefund);
total.setTotalPromotionFee(totalPromoFee); total.setTotalPromotionFee(totalPromoFee);
total.setBrushFee(totalBrushFee); total.setBrushFee(totalBrushFee);
@@ -991,6 +993,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
comparison.setProductCost(productCost); comparison.setProductCost(productCost);
comparison.setShippingCost(shippingCost); comparison.setShippingCost(shippingCost);
comparison.setOtherCost(otherCost); comparison.setOtherCost(otherCost);
comparison.setTotalCost(totalCost);
comparison.setRefundAmount(refundAmount); comparison.setRefundAmount(refundAmount);
comparison.setTotalPromotionFee(totalPromotionFee); comparison.setTotalPromotionFee(totalPromotionFee);
comparison.setBrushFee(totalBrushFee); comparison.setBrushFee(totalBrushFee);
@@ -1061,6 +1064,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setProductCost(totalProductCost); total.setProductCost(totalProductCost);
total.setShippingCost(totalShippingCost); total.setShippingCost(totalShippingCost);
total.setOtherCost(totalOtherCost); total.setOtherCost(totalOtherCost);
total.setTotalCost(totalCost);
total.setRefundAmount(totalRefund); total.setRefundAmount(totalRefund);
total.setTotalPromotionFee(totalPromoFee); total.setTotalPromotionFee(totalPromoFee);
total.setBrushFee(totalBrushFee); total.setBrushFee(totalBrushFee);
@@ -1279,6 +1283,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
platformSummary.setProductCost(totalProductCost); platformSummary.setProductCost(totalProductCost);
platformSummary.setShippingCost(totalShippingCost); platformSummary.setShippingCost(totalShippingCost);
platformSummary.setOtherCost(totalOtherCost); platformSummary.setOtherCost(totalOtherCost);
platformSummary.setTotalCost(totalCost);
platformSummary.setRefundAmount(totalRefundAmount); platformSummary.setRefundAmount(totalRefundAmount);
platformSummary.setTotalPromotionFee(totalPromotionFee); platformSummary.setTotalPromotionFee(totalPromotionFee);
platformSummary.setBrushFee(totalBrushFee); platformSummary.setBrushFee(totalBrushFee);
@@ -1377,6 +1382,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setProductCost(totalProductCost); total.setProductCost(totalProductCost);
total.setShippingCost(totalShippingCost); total.setShippingCost(totalShippingCost);
total.setOtherCost(totalOtherCost); total.setOtherCost(totalOtherCost);
total.setTotalCost(totalCost);
total.setRefundAmount(totalRefundAmount); total.setRefundAmount(totalRefundAmount);
total.setTotalPromotionFee(totalPromotionFee); total.setTotalPromotionFee(totalPromotionFee);
total.setBrushFee(totalBrushFee); total.setBrushFee(totalBrushFee);
@@ -1507,6 +1513,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
summary.setProductCost(totalProductCost); summary.setProductCost(totalProductCost);
summary.setShippingCost(totalShippingCost); summary.setShippingCost(totalShippingCost);
summary.setOtherCost(totalOtherCost); summary.setOtherCost(totalOtherCost);
summary.setTotalCost(totalCost);
summary.setRefundAmount(totalRefundAmount); summary.setRefundAmount(totalRefundAmount);
summary.setTotalPromotionFee(totalPromotionFee); summary.setTotalPromotionFee(totalPromotionFee);
summary.setBrushFee(totalBrushFee); summary.setBrushFee(totalBrushFee);
@@ -235,18 +235,18 @@ public class ExportServiceImpl implements ExportService {
Cell titleCell = titleRow.createCell(0); Cell titleCell = titleRow.createCell(0);
titleCell.setCellValue("店铺明细 | " + dateRangeLabel); titleCell.setCellValue("店铺明细 | " + dateRangeLabel);
titleCell.setCellStyle(createTitleStyle(sheet.getWorkbook())); titleCell.setCellStyle(createTitleStyle(sheet.getWorkbook()));
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 17));
CellStyle headerStyle = createHeaderStyle(sheet.getWorkbook());
CellStyle dataStyle = createDataStyle(sheet.getWorkbook());
// 列顺序与 Dashboard 表格一致
String taxLabel = (taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP)).toPlainString() + "%税额"; String taxLabel = (taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP)).toPlainString() + "%税额";
String[] headers = { String[] headers = {
"店铺名称", "目标单量", "单量达成率(%)", "目标额", "销售达成率(%)", "店铺名称", "目标单量", "单量达成率(%)", "目标额", "销售达成率(%)",
"实际销售额", "单量", "客单价", "实际销售额", "单量", "客单价",
"商品成本", "运费", "其他成本", "退款金额", "推广费", "刷单费用", "费比", "商品成本", "运费", "其他成本", "总成本", "退款金额", "推广费", "刷单费用", "费比",
"税前盈亏", taxLabel, "ROI", "税后盈亏" "税前盈亏", taxLabel, "ROI", "税后盈亏"
}; };
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headers.length - 1));
CellStyle headerStyle = createHeaderStyle(sheet.getWorkbook());
CellStyle dataStyle = createDataStyle(sheet.getWorkbook());
// 列顺序与 Dashboard 表格一致
Row headerRow = sheet.createRow(1); Row headerRow = sheet.createRow(1);
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
@@ -269,14 +269,15 @@ public class ExportServiceImpl implements ExportService {
setCell(row, 8, objToDouble(data.get("productCost")), dataStyle); setCell(row, 8, objToDouble(data.get("productCost")), dataStyle);
setCell(row, 9, objToDouble(data.get("shippingCost")), dataStyle); setCell(row, 9, objToDouble(data.get("shippingCost")), dataStyle);
setCell(row, 10, objToDouble(data.get("otherCost")), dataStyle); setCell(row, 10, objToDouble(data.get("otherCost")), dataStyle);
setCell(row, 11, objToDouble(data.get("refundAmount")), dataStyle); setCell(row, 11, objToDouble(data.get("totalCost")), dataStyle);
setCell(row, 12, objToDouble(data.get("totalPromotionFee")), dataStyle); setCell(row, 12, objToDouble(data.get("refundAmount")), dataStyle);
setCell(row, 13, objToDouble(data.get("brushFee")), dataStyle); setCell(row, 13, objToDouble(data.get("totalPromotionFee")), dataStyle);
setCell(row, 14, objToDouble(data.get("feeRatio")), dataStyle); setCell(row, 14, objToDouble(data.get("brushFee")), dataStyle);
setCell(row, 15, objToDouble(data.get("totalProfitBeforeTax")), dataStyle); setCell(row, 15, objToDouble(data.get("feeRatio")), dataStyle);
setCell(row, 16, objToDouble(data.get("salesTaxAmount")), dataStyle); setCell(row, 16, objToDouble(data.get("totalProfitBeforeTax")), dataStyle);
setCell(row, 17, objToDouble(data.get("roi")), dataStyle); setCell(row, 17, objToDouble(data.get("salesTaxAmount")), dataStyle);
setCell(row, 18, objToDouble(data.get("profitAfterTax")), dataStyle); setCell(row, 18, objToDouble(data.get("roi")), dataStyle);
setCell(row, 19, objToDouble(data.get("profitAfterTax")), dataStyle);
} }
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
@@ -478,6 +479,7 @@ public class ExportServiceImpl implements ExportService {
data.put("productCost", productCostTotal); data.put("productCost", productCostTotal);
data.put("shippingCost", shippingCost); data.put("shippingCost", shippingCost);
data.put("otherCost", otherCostTotal); data.put("otherCost", otherCostTotal);
data.put("totalCost", totalCost);
data.put("totalProfitBeforeTax", profitBeforeTax); // 对齐 ShopComparison data.put("totalProfitBeforeTax", profitBeforeTax); // 对齐 ShopComparison
data.put("salesTaxAmount", tax); // 对齐 ShopComparison data.put("salesTaxAmount", tax); // 对齐 ShopComparison
data.put("profitAfterTax", profitAfterTax); data.put("profitAfterTax", profitAfterTax);
@@ -768,6 +770,7 @@ public class ExportServiceImpl implements ExportService {
data.put("productCost", totalProductCost); data.put("productCost", totalProductCost);
data.put("shippingCost", totalShippingCost); data.put("shippingCost", totalShippingCost);
data.put("otherCost", totalOtherCost); data.put("otherCost", totalOtherCost);
data.put("totalCost", totalCost);
data.put("refundAmount", totalRefundAmount); data.put("refundAmount", totalRefundAmount);
data.put("totalPromotionFee", totalPromotionFee); data.put("totalPromotionFee", totalPromotionFee);
data.put("brushFee", totalBrushFee); data.put("brushFee", totalBrushFee);
@@ -807,15 +810,14 @@ public class ExportServiceImpl implements ExportService {
Cell titleCell = titleRow.createCell(0); Cell titleCell = titleRow.createCell(0);
titleCell.setCellValue("平台维度汇总 | " + dateRangeLabel); titleCell.setCellValue("平台维度汇总 | " + dateRangeLabel);
titleCell.setCellStyle(titleStyle); titleCell.setCellStyle(titleStyle);
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 17));
String taxLabel = taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP).toPlainString() + "%税额"; String taxLabel = taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP).toPlainString() + "%税额";
String[] headers = { String[] headers = {
"平台名称", "目标单量", "单量达成率(%)", "目标额", "销售达成率(%)", "平台名称", "目标单量", "单量达成率(%)", "目标额", "销售达成率(%)",
"实际销售额", "单量", "客单价", "实际销售额", "单量", "客单价",
"商品成本", "运费", "其他成本", "退款金额", "推广费", "刷单费用", "费比", "商品成本", "运费", "其他成本", "总成本", "退款金额", "推广费", "刷单费用", "费比",
"税前盈亏", taxLabel, "ROI", "税后盈亏" "税前盈亏", taxLabel, "ROI", "税后盈亏"
}; };
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headers.length - 1));
Row headerRow = sheet.createRow(1); Row headerRow = sheet.createRow(1);
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
@@ -838,14 +840,15 @@ public class ExportServiceImpl implements ExportService {
setCell(row, 8, objToDouble(data.get("productCost")), dataStyle); setCell(row, 8, objToDouble(data.get("productCost")), dataStyle);
setCell(row, 9, objToDouble(data.get("shippingCost")), dataStyle); setCell(row, 9, objToDouble(data.get("shippingCost")), dataStyle);
setCell(row, 10, objToDouble(data.get("otherCost")), dataStyle); setCell(row, 10, objToDouble(data.get("otherCost")), dataStyle);
setCell(row, 11, objToDouble(data.get("refundAmount")), dataStyle); setCell(row, 11, objToDouble(data.get("totalCost")), dataStyle);
setCell(row, 12, objToDouble(data.get("totalPromotionFee")), dataStyle); setCell(row, 12, objToDouble(data.get("refundAmount")), dataStyle);
setCell(row, 13, objToDouble(data.get("brushFee")), dataStyle); setCell(row, 13, objToDouble(data.get("totalPromotionFee")), dataStyle);
setCell(row, 14, objToPct(data.get("feeRatio")), dataStyle); setCell(row, 14, objToDouble(data.get("brushFee")), dataStyle);
setCell(row, 15, objToDouble(data.get("totalProfitBeforeTax")), dataStyle); setCell(row, 15, objToPct(data.get("feeRatio")), dataStyle);
setCell(row, 16, objToDouble(data.get("salesTaxAmount")), dataStyle); setCell(row, 16, objToDouble(data.get("totalProfitBeforeTax")), dataStyle);
setCell(row, 17, objToDouble(data.get("roi")), dataStyle); setCell(row, 17, objToDouble(data.get("salesTaxAmount")), dataStyle);
setCell(row, 18, objToDouble(data.get("profitAfterTax")), dataStyle); setCell(row, 18, objToDouble(data.get("roi")), dataStyle);
setCell(row, 19, objToDouble(data.get("profitAfterTax")), dataStyle);
} }
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
@@ -563,7 +563,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
: BigDecimal.ZERO; : BigDecimal.ZERO;
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost); BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
BigDecimal profitBeforeTax = totalSales.subtract(totalCost).subtract(totalRefund); BigDecimal profitBeforeTax = totalSales.subtract(totalCost).subtract(totalRefund);
BigDecimal salesTax = totalSales.multiply(new BigDecimal("0.04")); BigDecimal salesTax = totalSales.multiply(taxRate);
BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax); BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax);
BigDecimal roi = totalPromoFee.compareTo(BigDecimal.ZERO) > 0 BigDecimal roi = totalPromoFee.compareTo(BigDecimal.ZERO) > 0
? totalSales.subtract(totalRefund).divide(totalPromoFee, 4, RoundingMode.HALF_UP) ? totalSales.subtract(totalRefund).divide(totalPromoFee, 4, RoundingMode.HALF_UP)
@@ -894,7 +894,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
: BigDecimal.ZERO; : BigDecimal.ZERO;
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost); BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
BigDecimal profitBeforeTax = totalSales.subtract(totalCost).subtract(totalRefund); BigDecimal profitBeforeTax = totalSales.subtract(totalCost).subtract(totalRefund);
BigDecimal salesTax = totalSales.multiply(new BigDecimal("0.04")); BigDecimal salesTax = totalSales.multiply(taxRate);
BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax); BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax);
BigDecimal roi = totalPromoFee.compareTo(BigDecimal.ZERO) > 0 BigDecimal roi = totalPromoFee.compareTo(BigDecimal.ZERO) > 0
? totalSales.subtract(totalRefund).divide(totalPromoFee, 4, RoundingMode.HALF_UP) ? totalSales.subtract(totalRefund).divide(totalPromoFee, 4, RoundingMode.HALF_UP)
@@ -83,6 +83,8 @@ public class ProductOverviewServiceImpl implements ProductOverviewService {
? queryDTO.getTaxRate() ? queryDTO.getTaxRate()
: new BigDecimal("0.04"); : new BigDecimal("0.04");
List<Long> autoStatisticsStatusIds = getAutoStatisticsStatusIds(companyId);
// 查询订单数据 // 查询订单数据
LambdaQueryWrapper<OrderPO> orderWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderPO> orderWrapper = new LambdaQueryWrapper<>();
orderWrapper.eq(OrderPO::getCompanyId, companyId) orderWrapper.eq(OrderPO::getCompanyId, companyId)
@@ -90,6 +92,11 @@ public class ProductOverviewServiceImpl implements ProductOverviewService {
queryDTO.getProductId()) queryDTO.getProductId())
.ge(OrderPO::getOrderTime, startDateTime) .ge(OrderPO::getOrderTime, startDateTime)
.le(OrderPO::getOrderTime, endDateTime); .le(OrderPO::getOrderTime, endDateTime);
if (!autoStatisticsStatusIds.isEmpty()) {
orderWrapper.in(OrderPO::getStatusId, autoStatisticsStatusIds);
} else {
orderWrapper.isNull(OrderPO::getId);
}
List<OrderPO> orders = orderMapper.selectList(orderWrapper); List<OrderPO> orders = orderMapper.selectList(orderWrapper);
// 收集店铺ID列表 // 收集店铺ID列表
@@ -126,6 +133,11 @@ public class ProductOverviewServiceImpl implements ProductOverviewService {
queryDTO.getProductId()) queryDTO.getProductId())
.ge(OrderPO::getOrderTime, lastStartTime) .ge(OrderPO::getOrderTime, lastStartTime)
.le(OrderPO::getOrderTime, lastEndTime); .le(OrderPO::getOrderTime, lastEndTime);
if (!autoStatisticsStatusIds.isEmpty()) {
lastPeriodWrapper.in(OrderPO::getStatusId, autoStatisticsStatusIds);
} else {
lastPeriodWrapper.isNull(OrderPO::getId);
}
List<OrderPO> lastPeriodOrders = orderMapper.selectList(lastPeriodWrapper); List<OrderPO> lastPeriodOrders = orderMapper.selectList(lastPeriodWrapper);
// ========== 构建返回对象 ========== // ========== 构建返回对象 ==========
@@ -602,6 +614,19 @@ public class ProductOverviewServiceImpl implements ProductOverviewService {
return summary; return summary;
} }
/**
* 获取参与统计的订单状态ID列表
*/
private List<Long> getAutoStatisticsStatusIds(Long companyId) {
LambdaQueryWrapper<OrderStatusPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(OrderStatusPO::getCompanyId, companyId)
.eq(OrderStatusPO::getAutoStatistics, 1)
.select(OrderStatusPO::getId);
return orderStatusMapper.selectList(wrapper).stream()
.map(OrderStatusPO::getId)
.collect(Collectors.toList());
}
/** /**
* 获取退款状态ID集合 * 获取退款状态ID集合
*/ */
@@ -117,6 +117,8 @@ export namespace CompanyOverviewVO {
shippingCost?: number; shippingCost?: number;
/** 其他成本 */ /** 其他成本 */
otherCost?: number; otherCost?: number;
/** 总成本(商品成本+运费+其他成本) */
totalCost?: number;
/** 退款金额 */ /** 退款金额 */
refundAmount?: number; refundAmount?: number;
/** 推广费 */ /** 推广费 */
@@ -153,6 +155,8 @@ export namespace CompanyOverviewVO {
shippingCost?: number; shippingCost?: number;
/** 其他成本 */ /** 其他成本 */
otherCost?: number; otherCost?: number;
/** 总成本(商品成本+运费+其他成本) */
totalCost?: number;
/** 退款金额 */ /** 退款金额 */
refundAmount?: number; refundAmount?: number;
/** 推广费 */ /** 推广费 */
@@ -197,6 +201,8 @@ export namespace CompanyOverviewVO {
shippingCost?: number; shippingCost?: number;
/** 其他成本 */ /** 其他成本 */
otherCost?: number; otherCost?: number;
/** 总成本(商品成本+运费+其他成本) */
totalCost?: number;
/** 退款金额 */ /** 退款金额 */
refundAmount?: number; refundAmount?: number;
/** 推广费 */ /** 推广费 */
@@ -131,7 +131,7 @@ const formatPercentPlain = (value: number | undefined) => {
经营规模维度 经营规模维度
</th> </th>
<th <th
colspan="7" 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-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] p-3 text-center text-orange-700 dark:text-orange-400" 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-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] p-3 text-center text-orange-700 dark:text-orange-400"
> >
成本费用维度 成本费用维度
@@ -152,6 +152,7 @@ const formatPercentPlain = (value: number | undefined) => {
<th class="border-b border-l px-6 py-4">商品成本</th> <th class="border-b border-l px-6 py-4">商品成本</th>
<th class="border-b px-6 py-4">运费</th> <th class="border-b px-6 py-4">运费</th>
<th class="border-b px-6 py-4">其他成本</th> <th class="border-b px-6 py-4">其他成本</th>
<th class="border-b px-6 py-4 font-bold text-orange-800 dark:text-orange-300">总成本</th>
<th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400"> <th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400">
退款金额 退款金额
</th> </th>
@@ -214,6 +215,9 @@ const formatPercentPlain = (value: number | undefined) => {
<td class="p-6">{{ cat.productCost ? formatAmount(cat.productCost) : '-' }}</td> <td class="p-6">{{ cat.productCost ? formatAmount(cat.productCost) : '-' }}</td>
<td class="p-6">{{ cat.shippingCost ? formatAmount(cat.shippingCost) : '-' }}</td> <td class="p-6">{{ cat.shippingCost ? formatAmount(cat.shippingCost) : '-' }}</td>
<td class="p-6">{{ cat.otherCost ? formatAmount(cat.otherCost) : '-' }}</td> <td class="p-6">{{ cat.otherCost ? formatAmount(cat.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
{{ cat.totalCost != null ? formatAmount(cat.totalCost) : '-' }}
</td>
<td class="p-6 font-bold text-rose-600 dark:text-rose-400"> <td class="p-6 font-bold text-rose-600 dark:text-rose-400">
{{ cat.refundAmount ? formatAmount(cat.refundAmount) : '-' }} {{ cat.refundAmount ? formatAmount(cat.refundAmount) : '-' }}
</td> </td>
@@ -238,7 +242,7 @@ const formatPercentPlain = (value: number | undefined) => {
</td> </td>
</tr> </tr>
<tr v-if="!categoryComparisons?.categories?.length"> <tr v-if="!categoryComparisons?.categories?.length">
<td :colspan="categoryExportMode ? 16 : 15" class="p-8 text-center text-gray-400"> <td :colspan="categoryExportMode ? 18 : 17" class="p-8 text-center text-gray-400">
暂无数据 暂无数据
</td> </td>
</tr> </tr>
@@ -255,6 +259,7 @@ const formatPercentPlain = (value: number | undefined) => {
<td class="p-6">{{ categoryComparisons?.total?.productCost ? formatAmount(categoryComparisons?.total?.productCost) : '-' }}</td> <td class="p-6">{{ categoryComparisons?.total?.productCost ? formatAmount(categoryComparisons?.total?.productCost) : '-' }}</td>
<td class="p-6">{{ categoryComparisons?.total?.shippingCost ? formatAmount(categoryComparisons?.total?.shippingCost) : '-' }}</td> <td class="p-6">{{ categoryComparisons?.total?.shippingCost ? formatAmount(categoryComparisons?.total?.shippingCost) : '-' }}</td>
<td class="p-6">{{ categoryComparisons?.total?.otherCost ? formatAmount(categoryComparisons?.total?.otherCost) : '-' }}</td> <td class="p-6">{{ categoryComparisons?.total?.otherCost ? formatAmount(categoryComparisons?.total?.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ categoryComparisons?.total?.totalCost != null ? formatAmount(categoryComparisons?.total?.totalCost) : '-' }}</td>
<td class="p-6 text-rose-600 dark:text-rose-400">{{ categoryComparisons?.total?.refundAmount ? formatAmount(categoryComparisons?.total?.refundAmount) : '-' }}</td> <td class="p-6 text-rose-600 dark:text-rose-400">{{ categoryComparisons?.total?.refundAmount ? formatAmount(categoryComparisons?.total?.refundAmount) : '-' }}</td>
<td class="p-6">{{ categoryComparisons?.total?.totalPromotionFee ? formatAmount(categoryComparisons?.total?.totalPromotionFee) : '-' }}</td> <td class="p-6">{{ categoryComparisons?.total?.totalPromotionFee ? formatAmount(categoryComparisons?.total?.totalPromotionFee) : '-' }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ categoryComparisons?.total?.brushFee ? formatAmount(categoryComparisons?.total?.brushFee) : '-' }}</td> <td class="p-6 text-orange-600 dark:text-orange-400">{{ categoryComparisons?.total?.brushFee ? formatAmount(categoryComparisons?.total?.brushFee) : '-' }}</td>
@@ -58,6 +58,7 @@ const platformData = computed(() => {
productCost: p.productCost ?? 0, productCost: p.productCost ?? 0,
shippingCost: p.shippingCost ?? 0, shippingCost: p.shippingCost ?? 0,
otherCost: p.otherCost ?? 0, otherCost: p.otherCost ?? 0,
totalCost: p.totalCost ?? 0,
refundAmount: p.refundAmount ?? 0, refundAmount: p.refundAmount ?? 0,
totalPromotionFee: p.totalPromotionFee ?? 0, totalPromotionFee: p.totalPromotionFee ?? 0,
brushFee: p.brushFee ?? 0, brushFee: p.brushFee ?? 0,
@@ -191,7 +192,7 @@ const sortedData = computed(() => {
</th> </th>
<!-- 成本 --> <!-- 成本 -->
<th <th
colspan="7" 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-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] text-orange-700 dark:text-orange-400" 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-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] text-orange-700 dark:text-orange-400"
> >
成本费用维度 成本费用维度
@@ -218,6 +219,7 @@ const sortedData = computed(() => {
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">商品成本</th> <th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">商品成本</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">运费</th> <th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">运费</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">其他成本</th> <th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">其他成本</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold text-orange-800 dark:text-orange-300">总成本</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold text-rose-600 dark:text-rose-400">退款金额</th> <th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold text-rose-600 dark:text-rose-400">退款金额</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">推广费</th> <th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">推广费</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 text-orange-600 dark:text-orange-400">刷单费用</th> <th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 text-orange-600 dark:text-orange-400">刷单费用</th>
@@ -275,6 +277,7 @@ const sortedData = computed(() => {
<td class="p-6">{{ formatAmount(p.productCost) }}</td> <td class="p-6">{{ formatAmount(p.productCost) }}</td>
<td class="p-6">{{ formatAmount(p.shippingCost) }}</td> <td class="p-6">{{ formatAmount(p.shippingCost) }}</td>
<td class="p-6">{{ formatAmount(p.otherCost) }}</td> <td class="p-6">{{ formatAmount(p.otherCost) }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ formatAmount(p.totalCost) }}</td>
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">{{ formatAmount(p.refundAmount) }}</td> <td class="p-6 font-bold text-rose-600 dark:text-rose-400">{{ formatAmount(p.refundAmount) }}</td>
<td class="p-6">{{ formatAmount(p.totalPromotionFee) }}</td> <td class="p-6">{{ formatAmount(p.totalPromotionFee) }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ formatAmount(p.brushFee) }}</td> <td class="p-6 text-orange-600 dark:text-orange-400">{{ formatAmount(p.brushFee) }}</td>
@@ -310,6 +313,7 @@ const sortedData = computed(() => {
<td class="p-6">{{ totalData.productCost ? formatAmount(totalData.productCost) : '-' }}</td> <td class="p-6">{{ totalData.productCost ? formatAmount(totalData.productCost) : '-' }}</td>
<td class="p-6">{{ totalData.shippingCost ? formatAmount(totalData.shippingCost) : '-' }}</td> <td class="p-6">{{ totalData.shippingCost ? formatAmount(totalData.shippingCost) : '-' }}</td>
<td class="p-6">{{ totalData.otherCost ? formatAmount(totalData.otherCost) : '-' }}</td> <td class="p-6">{{ totalData.otherCost ? formatAmount(totalData.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ totalData.totalCost != null ? formatAmount(totalData.totalCost) : '-' }}</td>
<td class="p-6 text-rose-600 dark:text-rose-400">{{ totalData.refundAmount ? formatAmount(totalData.refundAmount) : '-' }}</td> <td class="p-6 text-rose-600 dark:text-rose-400">{{ totalData.refundAmount ? formatAmount(totalData.refundAmount) : '-' }}</td>
<td class="p-6">{{ totalData.totalPromotionFee ? formatAmount(totalData.totalPromotionFee) : '-' }}</td> <td class="p-6">{{ totalData.totalPromotionFee ? formatAmount(totalData.totalPromotionFee) : '-' }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ totalData.brushFee ? formatAmount(totalData.brushFee) : '-' }}</td> <td class="p-6 text-orange-600 dark:text-orange-400">{{ totalData.brushFee ? formatAmount(totalData.brushFee) : '-' }}</td>
@@ -335,7 +339,7 @@ const sortedData = computed(() => {
</tfoot> </tfoot>
<tfoot v-else class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]"> <tfoot v-else class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
<tr class="text-center text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"> <tr class="text-center text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
<td :colspan="platformExportMode ? 20 : 19" class="p-6">暂无数据</td> <td :colspan="platformExportMode ? 22 : 21" class="p-6">暂无数据</td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
@@ -142,7 +142,7 @@ const formatPercentPlain = (value: number | undefined) => {
经营规模维度 经营规模维度
</th> </th>
<th <th
colspan="7" 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-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] p-3 text-center text-orange-700 dark:text-orange-400" 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-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] p-3 text-center text-orange-700 dark:text-orange-400"
> >
成本费用维度 成本费用维度
@@ -170,6 +170,7 @@ const formatPercentPlain = (value: number | undefined) => {
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">商品成本</th> <th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">商品成本</th>
<th class="border-b px-6 py-4">运费</th> <th class="border-b px-6 py-4">运费</th>
<th class="border-b px-6 py-4">其他成本</th> <th class="border-b px-6 py-4">其他成本</th>
<th class="border-b px-6 py-4 font-bold text-orange-800 dark:text-orange-300">总成本</th>
<th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400"> <th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400">
退款金额 退款金额
</th> </th>
@@ -280,6 +281,11 @@ const formatPercentPlain = (value: number | undefined) => {
shop.otherCost ? formatAmount(shop.otherCost) : '-' shop.otherCost ? formatAmount(shop.otherCost) : '-'
}} }}
</td> </td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
{{
shop.totalCost != null ? formatAmount(shop.totalCost) : '-'
}}
</td>
<td class="p-6 font-bold text-rose-600 dark:text-rose-400"> <td class="p-6 font-bold text-rose-600 dark:text-rose-400">
{{ {{
shop.refundAmount ? formatAmount(shop.refundAmount) : '-' shop.refundAmount ? formatAmount(shop.refundAmount) : '-'
@@ -329,7 +335,7 @@ const formatPercentPlain = (value: number | undefined) => {
</td> </td>
</tr> </tr>
<tr v-if="!shopComparisons?.shops?.length"> <tr v-if="!shopComparisons?.shops?.length">
<td colspan="17" class="p-8 text-center text-gray-400"> <td :colspan="shopExportMode ? 22 : 21" class="p-8 text-center text-gray-400">
暂无数据 暂无数据
</td> </td>
</tr> </tr>
@@ -351,6 +357,7 @@ const formatPercentPlain = (value: number | undefined) => {
<td class="p-6">{{ shopComparisons?.total?.productCost ? formatAmount(shopComparisons?.total?.productCost) : '-' }}</td> <td class="p-6">{{ shopComparisons?.total?.productCost ? formatAmount(shopComparisons?.total?.productCost) : '-' }}</td>
<td class="p-6">{{ shopComparisons?.total?.shippingCost ? formatAmount(shopComparisons?.total?.shippingCost) : '-' }}</td> <td class="p-6">{{ shopComparisons?.total?.shippingCost ? formatAmount(shopComparisons?.total?.shippingCost) : '-' }}</td>
<td class="p-6">{{ shopComparisons?.total?.otherCost ? formatAmount(shopComparisons?.total?.otherCost) : '-' }}</td> <td class="p-6">{{ shopComparisons?.total?.otherCost ? formatAmount(shopComparisons?.total?.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ shopComparisons?.total?.totalCost != null ? formatAmount(shopComparisons?.total?.totalCost) : '-' }}</td>
<td class="p-6 text-rose-600 dark:text-rose-400">{{ shopComparisons?.total?.refundAmount ? formatAmount(shopComparisons?.total?.refundAmount) : '-' }}</td> <td class="p-6 text-rose-600 dark:text-rose-400">{{ shopComparisons?.total?.refundAmount ? formatAmount(shopComparisons?.total?.refundAmount) : '-' }}</td>
<td class="p-6">{{ shopComparisons?.total?.totalPromotionFee ? formatAmount(shopComparisons?.total?.totalPromotionFee) : '-' }}</td> <td class="p-6">{{ shopComparisons?.total?.totalPromotionFee ? formatAmount(shopComparisons?.total?.totalPromotionFee) : '-' }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ shopComparisons?.total?.brushFee ? formatAmount(shopComparisons?.total?.brushFee) : '-' }}</td> <td class="p-6 text-orange-600 dark:text-orange-400">{{ shopComparisons?.total?.brushFee ? formatAmount(shopComparisons?.total?.brushFee) : '-' }}</td>