mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 02:29:19 +08:00
feat: 优化工作台计算
This commit is contained in:
+4
@@ -58,6 +58,7 @@ public class BiOrderStatQueryService {
|
|||||||
OverviewAggRows.DailyRow r = new OverviewAggRows.DailyRow();
|
OverviewAggRows.DailyRow r = new OverviewAggRows.DailyRow();
|
||||||
r.setStatDate(d);
|
r.setStatDate(d);
|
||||||
r.setSalesAmount(BigDecimal.ZERO);
|
r.setSalesAmount(BigDecimal.ZERO);
|
||||||
|
r.setDealAmount(BigDecimal.ZERO);
|
||||||
r.setRefundAmount(BigDecimal.ZERO);
|
r.setRefundAmount(BigDecimal.ZERO);
|
||||||
r.setProductCost(BigDecimal.ZERO);
|
r.setProductCost(BigDecimal.ZERO);
|
||||||
r.setFreightCost(BigDecimal.ZERO);
|
r.setFreightCost(BigDecimal.ZERO);
|
||||||
@@ -66,6 +67,7 @@ public class BiOrderStatQueryService {
|
|||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
row.setSalesAmount(nz(row.getSalesAmount()).add(nz(doc.getSalesAmount())));
|
row.setSalesAmount(nz(row.getSalesAmount()).add(nz(doc.getSalesAmount())));
|
||||||
|
row.setDealAmount(nz(row.getDealAmount()).add(nz(doc.getDealAmount())));
|
||||||
row.setRefundAmount(nz(row.getRefundAmount()).add(nz(doc.getRefundAmount())));
|
row.setRefundAmount(nz(row.getRefundAmount()).add(nz(doc.getRefundAmount())));
|
||||||
row.setProductCost(nz(row.getProductCost()).add(nz(doc.getProductCost())));
|
row.setProductCost(nz(row.getProductCost()).add(nz(doc.getProductCost())));
|
||||||
row.setFreightCost(nz(row.getFreightCost()).add(nz(doc.getFreightCost())));
|
row.setFreightCost(nz(row.getFreightCost()).add(nz(doc.getFreightCost())));
|
||||||
@@ -181,6 +183,7 @@ public class BiOrderStatQueryService {
|
|||||||
OverviewAggRows.DailyRow r = new OverviewAggRows.DailyRow();
|
OverviewAggRows.DailyRow r = new OverviewAggRows.DailyRow();
|
||||||
r.setStatDate(d);
|
r.setStatDate(d);
|
||||||
r.setSalesAmount(BigDecimal.ZERO);
|
r.setSalesAmount(BigDecimal.ZERO);
|
||||||
|
r.setDealAmount(BigDecimal.ZERO);
|
||||||
r.setRefundAmount(BigDecimal.ZERO);
|
r.setRefundAmount(BigDecimal.ZERO);
|
||||||
r.setProductCost(BigDecimal.ZERO);
|
r.setProductCost(BigDecimal.ZERO);
|
||||||
r.setFreightCost(BigDecimal.ZERO);
|
r.setFreightCost(BigDecimal.ZERO);
|
||||||
@@ -189,6 +192,7 @@ public class BiOrderStatQueryService {
|
|||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
row.setSalesAmount(nz(row.getSalesAmount()).add(nz(doc.getSalesAmount())));
|
row.setSalesAmount(nz(row.getSalesAmount()).add(nz(doc.getSalesAmount())));
|
||||||
|
row.setDealAmount(nz(row.getDealAmount()).add(nz(doc.getDealAmount())));
|
||||||
row.setRefundAmount(nz(row.getRefundAmount()).add(nz(doc.getRefundAmount())));
|
row.setRefundAmount(nz(row.getRefundAmount()).add(nz(doc.getRefundAmount())));
|
||||||
row.setProductCost(nz(row.getProductCost()).add(nz(doc.getProductCost())));
|
row.setProductCost(nz(row.getProductCost()).add(nz(doc.getProductCost())));
|
||||||
row.setFreightCost(nz(row.getFreightCost()).add(nz(doc.getFreightCost())));
|
row.setFreightCost(nz(row.getFreightCost()).add(nz(doc.getFreightCost())));
|
||||||
|
|||||||
+1
@@ -35,6 +35,7 @@ public final class OverviewAggRows {
|
|||||||
public static class DailyRow {
|
public static class DailyRow {
|
||||||
private LocalDate statDate;
|
private LocalDate statDate;
|
||||||
private BigDecimal salesAmount;
|
private BigDecimal salesAmount;
|
||||||
|
private BigDecimal dealAmount;
|
||||||
private BigDecimal refundAmount;
|
private BigDecimal refundAmount;
|
||||||
private BigDecimal productCost;
|
private BigDecimal productCost;
|
||||||
private BigDecimal freightCost;
|
private BigDecimal freightCost;
|
||||||
|
|||||||
+16
-18
@@ -47,23 +47,21 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
this.categoryService = categoryService;
|
this.categoryService = categoryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal salesTaxOnNetSales(BigDecimal salesAmount, BigDecimal refundAmount) {
|
private BigDecimal salesTaxOnSales(BigDecimal salesAmount) {
|
||||||
BigDecimal sales = salesAmount != null ? salesAmount : BigDecimal.ZERO;
|
BigDecimal sales = salesAmount != null ? salesAmount : BigDecimal.ZERO;
|
||||||
BigDecimal refund = refundAmount != null ? refundAmount : BigDecimal.ZERO;
|
if (sales.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
BigDecimal base = sales.subtract(refund);
|
sales = BigDecimal.ZERO;
|
||||||
if (base.compareTo(BigDecimal.ZERO) < 0) {
|
|
||||||
base = BigDecimal.ZERO;
|
|
||||||
}
|
}
|
||||||
BigDecimal rate = taxRate != null ? taxRate : DEFAULT_TAX_RATE;
|
BigDecimal rate = taxRate != null ? taxRate : DEFAULT_TAX_RATE;
|
||||||
return base.multiply(rate).setScale(2, RoundingMode.HALF_UP);
|
return sales.multiply(rate).setScale(2, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 计算ROI:(销售额 - 退款金额)/ 推广费用 */
|
/** 计算ROI:实际销售额 / 推广费用 */
|
||||||
private BigDecimal calculateSalesROI(BigDecimal netSales, BigDecimal promotionFee) {
|
private BigDecimal calculateSalesROI(BigDecimal salesAmount, BigDecimal promotionFee) {
|
||||||
if (promotionFee == null || promotionFee.compareTo(BigDecimal.ZERO) <= 0) {
|
if (promotionFee == null || promotionFee.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
return netSales.divide(promotionFee, 4, RoundingMode.HALF_UP);
|
return salesAmount.divide(promotionFee, 4, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 计算店铺汇总的合计行 */
|
/** 计算店铺汇总的合计行 */
|
||||||
@@ -102,7 +100,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
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)
|
||||||
.subtract(totalPromoFee).subtract(totalBrushFee);
|
.subtract(totalPromoFee).subtract(totalBrushFee);
|
||||||
BigDecimal salesTax = salesTaxOnNetSales(totalSales, totalRefund);
|
BigDecimal salesTax = salesTaxOnSales(totalSales);
|
||||||
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)
|
||||||
@@ -177,7 +175,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
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)
|
||||||
.subtract(totalPromoFee).subtract(totalBrushFee);
|
.subtract(totalPromoFee).subtract(totalBrushFee);
|
||||||
BigDecimal salesTax = salesTaxOnNetSales(totalSales, totalRefund);
|
BigDecimal salesTax = salesTaxOnSales(totalSales);
|
||||||
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)
|
||||||
@@ -245,7 +243,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
|
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
|
||||||
BigDecimal profitBeforeTax = totalSalesAmount.subtract(totalCost).subtract(totalRefundAmount)
|
BigDecimal profitBeforeTax = totalSalesAmount.subtract(totalCost).subtract(totalRefundAmount)
|
||||||
.subtract(totalPromotionFee).subtract(totalBrushFee);
|
.subtract(totalPromotionFee).subtract(totalBrushFee);
|
||||||
BigDecimal salesTax = salesTaxOnNetSales(totalSalesAmount, totalRefundAmount);
|
BigDecimal salesTax = salesTaxOnSales(totalSalesAmount);
|
||||||
BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax);
|
BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax);
|
||||||
BigDecimal roi = totalPromotionFee.compareTo(BigDecimal.ZERO) > 0
|
BigDecimal roi = totalPromotionFee.compareTo(BigDecimal.ZERO) > 0
|
||||||
? totalSalesAmount.subtract(totalRefundAmount).divide(totalPromotionFee, 4, RoundingMode.HALF_UP)
|
? totalSalesAmount.subtract(totalRefundAmount).divide(totalPromotionFee, 4, RoundingMode.HALF_UP)
|
||||||
@@ -539,9 +537,9 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
s.setGrossProfit(m.grossProfit().setScale(2, RoundingMode.HALF_UP));
|
s.setGrossProfit(m.grossProfit().setScale(2, RoundingMode.HALF_UP));
|
||||||
BigDecimal pbt = m.grossProfit().subtract(promo).subtract(brush);
|
BigDecimal pbt = m.grossProfit().subtract(promo).subtract(brush);
|
||||||
s.setTotalProfitBeforeTax(pbt);
|
s.setTotalProfitBeforeTax(pbt);
|
||||||
s.setSalesTaxAmount(salesTaxOnNetSales(m.sales, m.refund));
|
s.setSalesTaxAmount(salesTaxOnSales(m.sales));
|
||||||
s.setProfitAfterTax(pbt.subtract(s.getSalesTaxAmount()).setScale(2, RoundingMode.HALF_UP));
|
s.setProfitAfterTax(pbt.subtract(s.getSalesTaxAmount()).setScale(2, RoundingMode.HALF_UP));
|
||||||
s.setRoi(calculateSalesROI(m.sales.subtract(m.refund), promo));
|
s.setRoi(calculateSalesROI(m.sales, promo));
|
||||||
s.setTargetAmount(targetAmt);
|
s.setTargetAmount(targetAmt);
|
||||||
s.setTargetOrderCount(targetOrders);
|
s.setTargetOrderCount(targetOrders);
|
||||||
s.setSalesAmountAchievementRate(achievementRate(m.sales, targetAmt));
|
s.setSalesAmountAchievementRate(achievementRate(m.sales, targetAmt));
|
||||||
@@ -566,9 +564,9 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
s.setGrossProfit(m.grossProfit().setScale(2, RoundingMode.HALF_UP));
|
s.setGrossProfit(m.grossProfit().setScale(2, RoundingMode.HALF_UP));
|
||||||
BigDecimal pbt = m.grossProfit().subtract(promo).subtract(brush);
|
BigDecimal pbt = m.grossProfit().subtract(promo).subtract(brush);
|
||||||
s.setTotalProfitBeforeTax(pbt);
|
s.setTotalProfitBeforeTax(pbt);
|
||||||
s.setSalesTaxAmount(salesTaxOnNetSales(m.sales, m.refund));
|
s.setSalesTaxAmount(salesTaxOnSales(m.sales));
|
||||||
s.setProfitAfterTax(pbt.subtract(s.getSalesTaxAmount()).setScale(2, RoundingMode.HALF_UP));
|
s.setProfitAfterTax(pbt.subtract(s.getSalesTaxAmount()).setScale(2, RoundingMode.HALF_UP));
|
||||||
s.setRoi(calculateSalesROI(m.sales.subtract(m.refund), promo));
|
s.setRoi(calculateSalesROI(m.sales, promo));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillPlatformLikeMetrics(CompanyOverviewVO.PlatformSummary s, AggMetrics m,
|
private void fillPlatformLikeMetrics(CompanyOverviewVO.PlatformSummary s, AggMetrics m,
|
||||||
@@ -589,9 +587,9 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
s.setGrossProfit(m.grossProfit().setScale(2, RoundingMode.HALF_UP));
|
s.setGrossProfit(m.grossProfit().setScale(2, RoundingMode.HALF_UP));
|
||||||
BigDecimal pbt = m.grossProfit().subtract(promo).subtract(brush);
|
BigDecimal pbt = m.grossProfit().subtract(promo).subtract(brush);
|
||||||
s.setTotalProfitBeforeTax(pbt);
|
s.setTotalProfitBeforeTax(pbt);
|
||||||
s.setSalesTaxAmount(salesTaxOnNetSales(m.sales, m.refund));
|
s.setSalesTaxAmount(salesTaxOnSales(m.sales));
|
||||||
s.setProfitAfterTax(pbt.subtract(s.getSalesTaxAmount()).setScale(2, RoundingMode.HALF_UP));
|
s.setProfitAfterTax(pbt.subtract(s.getSalesTaxAmount()).setScale(2, RoundingMode.HALF_UP));
|
||||||
s.setRoi(calculateSalesROI(m.sales.subtract(m.refund), promo));
|
s.setRoi(calculateSalesROI(m.sales, promo));
|
||||||
s.setTargetAmount(targetAmt);
|
s.setTargetAmount(targetAmt);
|
||||||
s.setTargetOrderCount(targetOrders);
|
s.setTargetOrderCount(targetOrders);
|
||||||
s.setSalesAmountAchievementRate(achievementRate(m.sales, targetAmt));
|
s.setSalesAmountAchievementRate(achievementRate(m.sales, targetAmt));
|
||||||
|
|||||||
+5
-2
@@ -12,19 +12,22 @@ import java.math.BigDecimal;
|
|||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Schema(description = "工作台-GM/利润趋势点(元,两位小数)")
|
@Schema(description = "工作台-经营趋势点(元,两位小数)")
|
||||||
public class WorkbenchTrendPointVO {
|
public class WorkbenchTrendPointVO {
|
||||||
|
|
||||||
@Schema(description = "横轴日期,如 M/d")
|
@Schema(description = "横轴日期,如 M/d")
|
||||||
private String date;
|
private String date;
|
||||||
|
|
||||||
|
@Schema(description = "成交金额(元,两位小数):全部订单状态商家实收合计")
|
||||||
|
private BigDecimal dealYuan;
|
||||||
|
|
||||||
@Schema(description = "实际销售额(元,两位小数),与计入销售额的订单状态配置一致")
|
@Schema(description = "实际销售额(元,两位小数),与计入销售额的订单状态配置一致")
|
||||||
private BigDecimal salesYuan;
|
private BigDecimal salesYuan;
|
||||||
|
|
||||||
@Schema(description = "日毛利润(元,两位小数)= 销售额−成本−退款,与 KPI「毛利润」按日拆解口径一致")
|
@Schema(description = "日毛利润(元,两位小数)= 销售额−成本−退款,与 KPI「毛利润」按日拆解口径一致")
|
||||||
private BigDecimal profitYuan;
|
private BigDecimal profitYuan;
|
||||||
|
|
||||||
@Schema(description = "日净利润(元,两位小数)= 毛利润−按日销售额占比分摊的推广费、刷单费−按日净销售额占比分摊的税额,与 KPI「净利润」及多维分析分摊口径一致")
|
@Schema(description = "日净利润(元,两位小数)= 毛利润−按日销售额占比分摊的推广费、刷单费、税额,与 KPI「净利润」及多维分析分摊口径一致")
|
||||||
private BigDecimal netProfitYuan;
|
private BigDecimal netProfitYuan;
|
||||||
|
|
||||||
@Schema(description = "退款(元,两位小数)")
|
@Schema(description = "退款(元,两位小数)")
|
||||||
|
|||||||
+34
-66
@@ -57,7 +57,7 @@ import java.util.stream.Collectors;
|
|||||||
* <li>「实际销售额、成本、退款、多维行、趋势」等与 {@link OrderStatusStatSets} 一致:仅统计配置为「计入销售额」的订单状态,
|
* <li>「实际销售额、成本、退款、多维行、趋势」等与 {@link OrderStatusStatSets} 一致:仅统计配置为「计入销售额」的订单状态,
|
||||||
* 金额字段由 {@code stat} 解析商家实收、成本、退款等。</li>
|
* 金额字段由 {@code stat} 解析商家实收、成本、退款等。</li>
|
||||||
* <li>「成交金额」为同店铺、同时间范围内<strong>全部订单状态</strong>的商家实收合计(由汇总表 KPI 提供)。</li>
|
* <li>「成交金额」为同店铺、同时间范围内<strong>全部订单状态</strong>的商家实收合计(由汇总表 KPI 提供)。</li>
|
||||||
* <li>推广费、刷单费为区间汇总;多维行与趋势中的「净利润」按销售额 / 净销售额占比将区间推广、刷单、税额<strong>分摊</strong>到各维度或各日,
|
* <li>推广费、刷单费为区间汇总;多维行与趋势中的「净利润」按销售额占比将区间推广、刷单、税额<strong>分摊</strong>到各维度或各日,
|
||||||
* 与 {@link #totalsFromOrderRows} 得到的区间总毛利润、总税额自洽。</li>
|
* 与 {@link #totalsFromOrderRows} 得到的区间总毛利润、总税额自洽。</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
@@ -367,7 +367,7 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
BigDecimal cost = pc.add(fc).add(oc);
|
BigDecimal cost = pc.add(fc).add(oc);
|
||||||
BigDecimal gross = sales.subtract(cost).subtract(refund);
|
BigDecimal gross = sales.subtract(cost).subtract(refund);
|
||||||
BigDecimal pbt = gross.subtract(promotion).subtract(brush);
|
BigDecimal pbt = gross.subtract(promotion).subtract(brush);
|
||||||
BigDecimal tax = salesTaxOnNetSales(sales, refund, taxRate);
|
BigDecimal tax = salesTaxOnSales(sales, taxRate);
|
||||||
BigDecimal aov = orderCount > 0
|
BigDecimal aov = orderCount > 0
|
||||||
? sales.divide(BigDecimal.valueOf(orderCount), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
? sales.divide(BigDecimal.valueOf(orderCount), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
||||||
BigDecimal dealAov = dealOrderCount > 0
|
BigDecimal dealAov = dealOrderCount > 0
|
||||||
@@ -390,26 +390,24 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
BigDecimal salesTotal = periodTotals.totalSales();
|
BigDecimal salesTotal = periodTotals.totalSales();
|
||||||
BigDecimal netSum = BigDecimal.ZERO;
|
|
||||||
for (LocalDate d = range.startDate(); !d.isAfter(range.endDate()); d = d.plusDays(1)) {
|
|
||||||
netSum = netSum.add(dayNetSales(byDay.get(d)));
|
|
||||||
}
|
|
||||||
List<WorkbenchTrendPointVO> list = new ArrayList<>();
|
List<WorkbenchTrendPointVO> list = new ArrayList<>();
|
||||||
for (LocalDate d = range.startDate(); !d.isAfter(range.endDate()); d = d.plusDays(1)) {
|
for (LocalDate d = range.startDate(); !d.isAfter(range.endDate()); d = d.plusDays(1)) {
|
||||||
OverviewAggRows.DailyRow row = byDay.get(d);
|
OverviewAggRows.DailyRow row = byDay.get(d);
|
||||||
BigDecimal sales = row != null ? nz(row.getSalesAmount()) : BigDecimal.ZERO;
|
BigDecimal sales = row != null ? nz(row.getSalesAmount()) : BigDecimal.ZERO;
|
||||||
|
BigDecimal deal = row != null ? nz(row.getDealAmount()) : BigDecimal.ZERO;
|
||||||
BigDecimal refund = row != null ? nz(row.getRefundAmount()) : BigDecimal.ZERO;
|
BigDecimal refund = row != null ? nz(row.getRefundAmount()) : BigDecimal.ZERO;
|
||||||
BigDecimal cost = row != null
|
BigDecimal cost = row != null
|
||||||
? nz(row.getProductCost()).add(nz(row.getFreightCost())).add(nz(row.getOtherCost())) : BigDecimal.ZERO;
|
? nz(row.getProductCost()).add(nz(row.getFreightCost())).add(nz(row.getOtherCost())) : BigDecimal.ZERO;
|
||||||
BigDecimal gross = sales.subtract(cost).subtract(refund);
|
BigDecimal gross = sales.subtract(cost).subtract(refund);
|
||||||
BigDecimal promoB = allocShare(sales, salesTotal, periodTotals.promotion());
|
BigDecimal promoB = allocShare(sales, salesTotal, periodTotals.promotion());
|
||||||
BigDecimal brushB = allocShare(sales, salesTotal, periodTotals.brush());
|
BigDecimal brushB = allocShare(sales, salesTotal, periodTotals.brush());
|
||||||
BigDecimal taxB = allocShare(dayNetSales(row), netSum.max(BigDecimal.ONE), periodTotals.tax());
|
BigDecimal taxB = allocShare(sales, salesTotal.max(BigDecimal.ONE), periodTotals.tax());
|
||||||
if (netSum.compareTo(BigDecimal.ZERO) <= 0) {
|
if (salesTotal.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
taxB = BigDecimal.ZERO;
|
taxB = BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
list.add(WorkbenchTrendPointVO.builder()
|
list.add(WorkbenchTrendPointVO.builder()
|
||||||
.date(d.format(TREND_DATE_FMT))
|
.date(d.format(TREND_DATE_FMT))
|
||||||
|
.dealYuan(yuan2(deal))
|
||||||
.salesYuan(yuan2(sales))
|
.salesYuan(yuan2(sales))
|
||||||
.profitYuan(yuan2(gross))
|
.profitYuan(yuan2(gross))
|
||||||
.netProfitYuan(yuan2(gross.subtract(promoB).subtract(brushB).subtract(taxB)))
|
.netProfitYuan(yuan2(gross.subtract(promoB).subtract(brushB).subtract(taxB)))
|
||||||
@@ -427,13 +425,6 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
.stream().collect(Collectors.toMap(CategoryPO::getId, CategoryPO::getName, (a, b) -> a));
|
.stream().collect(Collectors.toMap(CategoryPO::getId, CategoryPO::getName, (a, b) -> a));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BigDecimal dayNetSales(OverviewAggRows.DailyRow row) {
|
|
||||||
if (row == null) {
|
|
||||||
return BigDecimal.ZERO;
|
|
||||||
}
|
|
||||||
return nz(row.getSalesAmount()).subtract(nz(row.getRefundAmount())).max(BigDecimal.ZERO);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LocalDate minDate(LocalDate... dates) {
|
private static LocalDate minDate(LocalDate... dates) {
|
||||||
LocalDate min = dates[0];
|
LocalDate min = dates[0];
|
||||||
for (LocalDate d : dates) {
|
for (LocalDate d : dates) {
|
||||||
@@ -584,7 +575,7 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 将「字符串 key → 聚合桶」转为多维表格行:每行毛利润 = 销售−成本−退款;
|
* 将「字符串 key → 聚合桶」转为多维表格行:每行毛利润 = 销售−成本−退款;
|
||||||
* 推广费、刷单费按该行销售额占 {@code salesTotalCompany} 比例分摊;税额按该行净销售额占全部分桶净销售额之和比例分摊;
|
* 推广费、刷单费、税额均按该行销售额占 {@code salesTotalCompany} 比例分摊;
|
||||||
* 净利润 = 毛利润 − 分摊推广 − 分摊刷单 − 分摊税。
|
* 净利润 = 毛利润 − 分摊推广 − 分摊刷单 − 分摊税。
|
||||||
*/
|
*/
|
||||||
private List<WorkbenchDimRowVO> buildDimRows(Map<String, Agg> aggs,
|
private List<WorkbenchDimRowVO> buildDimRows(Map<String, Agg> aggs,
|
||||||
@@ -593,10 +584,6 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
BigDecimal promoTotal,
|
BigDecimal promoTotal,
|
||||||
BigDecimal brushTotal,
|
BigDecimal brushTotal,
|
||||||
BigDecimal taxTotal) {
|
BigDecimal taxTotal) {
|
||||||
BigDecimal netSum = aggs.values().stream()
|
|
||||||
.map(Agg::netSalesBase)
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
List<WorkbenchDimRowVO> rows = new ArrayList<>();
|
List<WorkbenchDimRowVO> rows = new ArrayList<>();
|
||||||
for (Map.Entry<String, Agg> e : aggs.entrySet()) {
|
for (Map.Entry<String, Agg> e : aggs.entrySet()) {
|
||||||
Agg a = e.getValue();
|
Agg a = e.getValue();
|
||||||
@@ -606,8 +593,8 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
BigDecimal gross = a.sales.subtract(a.cost).subtract(a.refund);
|
BigDecimal gross = a.sales.subtract(a.cost).subtract(a.refund);
|
||||||
BigDecimal promoB = allocShare(a.sales, salesTotalCompany, promoTotal);
|
BigDecimal promoB = allocShare(a.sales, salesTotalCompany, promoTotal);
|
||||||
BigDecimal brushB = allocShare(a.sales, salesTotalCompany, brushTotal);
|
BigDecimal brushB = allocShare(a.sales, salesTotalCompany, brushTotal);
|
||||||
BigDecimal taxB = allocShare(a.netSalesBase(), netSum.max(BigDecimal.ONE), taxTotal);
|
BigDecimal taxB = allocShare(a.sales, salesTotalCompany.max(BigDecimal.ONE), taxTotal);
|
||||||
if (netSum.compareTo(BigDecimal.ZERO) <= 0) {
|
if (salesTotalCompany.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
taxB = BigDecimal.ZERO;
|
taxB = BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
BigDecimal net = gross.subtract(promoB).subtract(brushB).subtract(taxB);
|
BigDecimal net = gross.subtract(promoB).subtract(brushB).subtract(taxB);
|
||||||
@@ -695,17 +682,16 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
private List<WorkbenchKpiItemVO> buildKpis(Totals cur, Totals prev, Totals yoy, DateRange range, BigDecimal taxRate) {
|
private List<WorkbenchKpiItemVO> buildKpis(Totals cur, Totals prev, Totals yoy, DateRange range, BigDecimal taxRate) {
|
||||||
int days = (int) (range.endDate().toEpochDay() - range.startDate().toEpochDay() + 1);
|
int days = (int) (range.endDate().toEpochDay() - range.startDate().toEpochDay() + 1);
|
||||||
|
|
||||||
BigDecimal netRecv = cur.netSales();
|
|
||||||
BigDecimal grossMarginPct = safePct(cur.grossOrder(), cur.totalSales());
|
BigDecimal grossMarginPct = safePct(cur.grossOrder(), cur.totalSales());
|
||||||
BigDecimal netMarginPct = safePct(cur.netProfit(), cur.totalSales());
|
BigDecimal netMarginPct = safePct(cur.netProfit(), cur.totalSales());
|
||||||
BigDecimal refundRate = safePct(cur.totalRefund(), cur.totalSales());
|
BigDecimal refundRate = safePct(cur.totalRefund(), cur.totalSales());
|
||||||
BigDecimal costRate = safePct(cur.totalCost(), cur.totalSales());
|
BigDecimal costRate = safePct(cur.totalCost(), cur.totalSales());
|
||||||
BigDecimal roi = cur.promotion().compareTo(BigDecimal.ZERO) > 0
|
BigDecimal roi = cur.promotion().compareTo(BigDecimal.ZERO) > 0
|
||||||
? netRecv.divide(cur.promotion(), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
? cur.totalSales().divide(cur.promotion(), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
||||||
BigDecimal yoyRoi = yoy.promotion().compareTo(BigDecimal.ZERO) > 0
|
BigDecimal yoyRoi = yoy.promotion().compareTo(BigDecimal.ZERO) > 0
|
||||||
? yoy.netSales().divide(yoy.promotion(), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
? yoy.totalSales().divide(yoy.promotion(), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
||||||
BigDecimal prevRoi = prev.promotion().compareTo(BigDecimal.ZERO) > 0
|
BigDecimal prevRoi = prev.promotion().compareTo(BigDecimal.ZERO) > 0
|
||||||
? prev.netSales().divide(prev.promotion(), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
? prev.totalSales().divide(prev.promotion(), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
||||||
|
|
||||||
BigDecimal avgDailySalesOrders = days > 0
|
BigDecimal avgDailySalesOrders = days > 0
|
||||||
? BigDecimal.valueOf(cur.orderCount()).divide(BigDecimal.valueOf(days), 1, RoundingMode.HALF_UP)
|
? BigDecimal.valueOf(cur.orderCount()).divide(BigDecimal.valueOf(days), 1, RoundingMode.HALF_UP)
|
||||||
@@ -713,54 +699,48 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
BigDecimal avgDailyDealOrders = days > 0
|
BigDecimal avgDailyDealOrders = days > 0
|
||||||
? BigDecimal.valueOf(cur.dealOrderCount()).divide(BigDecimal.valueOf(days), 1, RoundingMode.HALF_UP)
|
? BigDecimal.valueOf(cur.dealOrderCount()).divide(BigDecimal.valueOf(days), 1, RoundingMode.HALF_UP)
|
||||||
: BigDecimal.ZERO;
|
: BigDecimal.ZERO;
|
||||||
BigDecimal dealSalesGap = cur.totalDealAmount().subtract(cur.totalSales());
|
|
||||||
|
|
||||||
List<WorkbenchKpiItemVO> list = new ArrayList<>();
|
List<WorkbenchKpiItemVO> list = new ArrayList<>();
|
||||||
|
|
||||||
// —— 成交口径(全状态)——
|
// —— 成交口径(全状态)——
|
||||||
list.add(kpi("成交金额", formatYuanComma(cur.totalDealAmount()), "元", cur.totalDealAmount(), prev.totalDealAmount(), yoy.totalDealAmount(),
|
list.add(kpi("成交金额", formatYuanComma(cur.totalDealAmount()), "元", cur.totalDealAmount(), prev.totalDealAmount(), yoy.totalDealAmount(),
|
||||||
"全状态商家实收", cur.totalDealAmount(), true));
|
"全状态实收", cur.totalDealAmount(), true));
|
||||||
list.add(kpiCount("成交单量", cur.dealOrderCount(), prev.dealOrderCount(), yoy.dealOrderCount(), "单",
|
list.add(kpiCount("成交单量", cur.dealOrderCount(), prev.dealOrderCount(), yoy.dealOrderCount(), "单",
|
||||||
"日均约 " + avgDailyDealOrders.stripTrailingZeros().toPlainString() + " 单"));
|
"日均 " + avgDailyDealOrders.stripTrailingZeros().toPlainString() + " 单"));
|
||||||
list.add(kpiCount("成交销量", cur.dealQuantitySum(), prev.dealQuantitySum(), yoy.dealQuantitySum(), "件", "全状态件数合计"));
|
list.add(kpiCount("成交销量", cur.dealQuantitySum(), prev.dealQuantitySum(), yoy.dealQuantitySum(), "件", "全状态件数"));
|
||||||
list.add(kpi("成交客单价", formatYuanComma(cur.dealAverageOrderValue()), "元",
|
list.add(kpi("成交客单价", formatYuanComma(cur.dealAverageOrderValue()), "元",
|
||||||
cur.dealAverageOrderValue(), prev.dealAverageOrderValue(), yoy.dealAverageOrderValue(),
|
cur.dealAverageOrderValue(), prev.dealAverageOrderValue(), yoy.dealAverageOrderValue(),
|
||||||
"成交金额÷成交单量", cur.dealAverageOrderValue(), false));
|
"成交金额/成交单量", cur.dealAverageOrderValue(), false));
|
||||||
list.add(kpi("成交件单价", formatYuanComma(cur.dealPiecePrice()), "元",
|
list.add(kpi("成交件单价", formatYuanComma(cur.dealPiecePrice()), "元",
|
||||||
cur.dealPiecePrice(), prev.dealPiecePrice(), yoy.dealPiecePrice(),
|
cur.dealPiecePrice(), prev.dealPiecePrice(), yoy.dealPiecePrice(),
|
||||||
"成交金额÷成交销量", cur.dealPiecePrice(), false));
|
"成交金额/成交销量", cur.dealPiecePrice(), false));
|
||||||
|
|
||||||
// —— 实际销售口径(计入销售额状态)——
|
// —— 实际销售口径(计入销售额状态)——
|
||||||
list.add(kpi("实际销售额", formatYuanComma(cur.totalSales()), "元", cur.totalSales(), prev.totalSales(), yoy.totalSales(),
|
list.add(kpi("实际销售额", formatYuanComma(cur.totalSales()), "元", cur.totalSales(), prev.totalSales(), yoy.totalSales(),
|
||||||
"计入销售额的订单状态", cur.totalSales(), true));
|
"计入销售状态", cur.totalSales(), true));
|
||||||
list.add(kpiCount("销售单量", cur.orderCount(), prev.orderCount(), yoy.orderCount(), "单",
|
list.add(kpiCount("销售单量", cur.orderCount(), prev.orderCount(), yoy.orderCount(), "单",
|
||||||
"日均约 " + avgDailySalesOrders.stripTrailingZeros().toPlainString() + " 单"));
|
"日均 " + avgDailySalesOrders.stripTrailingZeros().toPlainString() + " 单"));
|
||||||
list.add(kpiCount("实际销量", cur.salesQuantitySum(), prev.salesQuantitySum(), yoy.salesQuantitySum(), "件",
|
list.add(kpiCount("实际销量", cur.salesQuantitySum(), prev.salesQuantitySum(), yoy.salesQuantitySum(), "件",
|
||||||
"计入销售额状态件数"));
|
"计入销售件数"));
|
||||||
list.add(kpi("客单价", formatYuanComma(cur.averageOrderValue()), "元",
|
list.add(kpi("客单价", formatYuanComma(cur.averageOrderValue()), "元",
|
||||||
cur.averageOrderValue(), prev.averageOrderValue(), yoy.averageOrderValue(),
|
cur.averageOrderValue(), prev.averageOrderValue(), yoy.averageOrderValue(),
|
||||||
"销售额÷销售单量", cur.averageOrderValue(), false));
|
"销售额/销售单量", cur.averageOrderValue(), false));
|
||||||
list.add(kpi("销售件单价", formatYuanComma(cur.salesPiecePrice()), "元",
|
list.add(kpi("销售件单价", formatYuanComma(cur.salesPiecePrice()), "元",
|
||||||
cur.salesPiecePrice(), prev.salesPiecePrice(), yoy.salesPiecePrice(),
|
cur.salesPiecePrice(), prev.salesPiecePrice(), yoy.salesPiecePrice(),
|
||||||
"销售额÷实际销量", cur.salesPiecePrice(), false));
|
"销售额/实际销量", cur.salesPiecePrice(), false));
|
||||||
|
|
||||||
// —— 净收与退款 ——
|
// —— 净收与退款 ——
|
||||||
list.add(kpi("净销售额", formatYuanComma(netRecv), "元", netRecv, prev.netSales(), yoy.netSales(),
|
|
||||||
"实际销售额−退款", netRecv, true));
|
|
||||||
list.add(kpi("退款额", formatYuanComma(cur.totalRefund()), "元", cur.totalRefund(), prev.totalRefund(), yoy.totalRefund(),
|
list.add(kpi("退款额", formatYuanComma(cur.totalRefund()), "元", cur.totalRefund(), prev.totalRefund(), yoy.totalRefund(),
|
||||||
"计入退款状态口径", cur.totalRefund(), true));
|
"计入退款状态", cur.totalRefund(), true));
|
||||||
list.add(kpi("退款率", refundRate.setScale(2, RoundingMode.HALF_UP).toPlainString(), "%",
|
list.add(kpi("退款率", refundRate.setScale(2, RoundingMode.HALF_UP).toPlainString(), "%",
|
||||||
refundRate, safePct(prev.totalRefund(), prev.totalSales()), safePct(yoy.totalRefund(), yoy.totalSales()),
|
refundRate, safePct(prev.totalRefund(), prev.totalSales()), safePct(yoy.totalRefund(), yoy.totalSales()),
|
||||||
"退款÷实际销售额", null, null));
|
"退款/实际销售额", null, null));
|
||||||
list.add(kpi("成交与销售差额", formatYuanComma(dealSalesGap), "元", dealSalesGap,
|
|
||||||
prev.totalDealAmount().subtract(prev.totalSales()), yoy.totalDealAmount().subtract(yoy.totalSales()),
|
|
||||||
"成交金额−实际销售额", dealSalesGap, true));
|
|
||||||
|
|
||||||
// —— 成本 ——
|
// —— 成本 ——
|
||||||
list.add(kpi("订单成本", formatYuanComma(cur.totalCost()), "元", cur.totalCost(), prev.totalCost(), yoy.totalCost(),
|
list.add(kpi("订单成本", formatYuanComma(cur.totalCost()), "元", cur.totalCost(), prev.totalCost(), yoy.totalCost(),
|
||||||
"成本率 " + costRate.stripTrailingZeros().toPlainString() + "%", cur.totalCost(), true));
|
"成本率 " + costRate.stripTrailingZeros().toPlainString() + "%", cur.totalCost(), true));
|
||||||
list.add(kpi("商品成本", formatYuanComma(cur.productCost()), "元", cur.productCost(), prev.productCost(), yoy.productCost(),
|
list.add(kpi("商品成本", formatYuanComma(cur.productCost()), "元", cur.productCost(), prev.productCost(), yoy.productCost(),
|
||||||
"按状态配置计入", cur.productCost(), true));
|
null, cur.productCost(), true));
|
||||||
list.add(kpi("运费成本", formatYuanComma(cur.freightCost()), "元", cur.freightCost(), prev.freightCost(), yoy.freightCost(),
|
list.add(kpi("运费成本", formatYuanComma(cur.freightCost()), "元", cur.freightCost(), prev.freightCost(), yoy.freightCost(),
|
||||||
null, cur.freightCost(), true));
|
null, cur.freightCost(), true));
|
||||||
list.add(kpi("其他成本", formatYuanComma(cur.otherCost()), "元", cur.otherCost(), prev.otherCost(), yoy.otherCost(),
|
list.add(kpi("其他成本", formatYuanComma(cur.otherCost()), "元", cur.otherCost(), prev.otherCost(), yoy.otherCost(),
|
||||||
@@ -770,11 +750,11 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
list.add(kpi("毛利润", formatYuanComma(cur.grossOrder()), "元", cur.grossOrder(), prev.grossOrder(), yoy.grossOrder(),
|
list.add(kpi("毛利润", formatYuanComma(cur.grossOrder()), "元", cur.grossOrder(), prev.grossOrder(), yoy.grossOrder(),
|
||||||
"毛利率 " + grossMarginPct.stripTrailingZeros().toPlainString() + "%", cur.grossOrder(), true));
|
"毛利率 " + grossMarginPct.stripTrailingZeros().toPlainString() + "%", cur.grossOrder(), true));
|
||||||
list.add(kpi("推广费", formatYuanComma(cur.promotion()), "元", cur.promotion(), prev.promotion(), yoy.promotion(),
|
list.add(kpi("推广费", formatYuanComma(cur.promotion()), "元", cur.promotion(), prev.promotion(), yoy.promotion(),
|
||||||
"区间推广费合计", cur.promotion(), true));
|
null, cur.promotion(), true));
|
||||||
list.add(kpi("刷单费", formatYuanComma(cur.brush()), "元", cur.brush(), prev.brush(), yoy.brush(),
|
list.add(kpi("刷单费", formatYuanComma(cur.brush()), "元", cur.brush(), prev.brush(), yoy.brush(),
|
||||||
"区间刷单费合计", cur.brush(), true));
|
null, cur.brush(), true));
|
||||||
list.add(kpi("税额", formatYuanComma(cur.tax()), "元", cur.tax(), prev.tax(), yoy.tax(),
|
list.add(kpi("税额", formatYuanComma(cur.tax()), "元", cur.tax(), prev.tax(), yoy.tax(),
|
||||||
"税率 " + taxRate.multiply(new BigDecimal("100")).stripTrailingZeros().toPlainString() + "%(净销售额口径)",
|
"税率 " + taxRate.multiply(new BigDecimal("100")).stripTrailingZeros().toPlainString() + "%",
|
||||||
cur.tax(), true));
|
cur.tax(), true));
|
||||||
list.add(kpi("净利润", formatYuanComma(cur.netProfit()), "元", cur.netProfit(), prev.netProfit(), yoy.netProfit(),
|
list.add(kpi("净利润", formatYuanComma(cur.netProfit()), "元", cur.netProfit(), prev.netProfit(), yoy.netProfit(),
|
||||||
"净利率 " + netMarginPct.stripTrailingZeros().toPlainString() + "%",
|
"净利率 " + netMarginPct.stripTrailingZeros().toPlainString() + "%",
|
||||||
@@ -782,7 +762,7 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
|
|
||||||
// —— 运营效率 ——
|
// —— 运营效率 ——
|
||||||
list.add(kpi("广告ROI", roi.stripTrailingZeros().toPlainString(), ":1", roi, prevRoi, yoyRoi,
|
list.add(kpi("广告ROI", roi.stripTrailingZeros().toPlainString(), ":1", roi, prevRoi, yoyRoi,
|
||||||
"净销售额÷推广费", null, null));
|
"实际销售额/推广费", null, null));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -837,17 +817,15 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 与单店概览一致:订单流水中「销售额−成本」的合计,再扣推广、刷单得税前;再扣税得净利。
|
* 税额 = 实际销售额 * 税率(实际销售额已按状态剔除退款单,不再二次扣退款)。
|
||||||
*/
|
*/
|
||||||
private BigDecimal salesTaxOnNetSales(BigDecimal salesAmount, BigDecimal refundAmount, BigDecimal rate) {
|
private BigDecimal salesTaxOnSales(BigDecimal salesAmount, BigDecimal rate) {
|
||||||
BigDecimal sales = salesAmount != null ? salesAmount : BigDecimal.ZERO;
|
BigDecimal sales = salesAmount != null ? salesAmount : BigDecimal.ZERO;
|
||||||
BigDecimal ref = refundAmount != null ? refundAmount : BigDecimal.ZERO;
|
if (sales.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
BigDecimal base = sales.subtract(ref);
|
sales = BigDecimal.ZERO;
|
||||||
if (base.compareTo(BigDecimal.ZERO) < 0) {
|
|
||||||
base = BigDecimal.ZERO;
|
|
||||||
}
|
}
|
||||||
BigDecimal r = rate != null ? rate : DEFAULT_TAX_RATE;
|
BigDecimal r = rate != null ? rate : DEFAULT_TAX_RATE;
|
||||||
return base.multiply(r).setScale(2, RoundingMode.HALF_UP);
|
return sales.multiply(r).setScale(2, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 解析前端传入的 1 个或 2 个日期为闭区间 [start, end] */
|
/** 解析前端传入的 1 个或 2 个日期为闭区间 [start, end] */
|
||||||
@@ -960,10 +938,6 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
BigDecimal dealAverageOrderValue,
|
BigDecimal dealAverageOrderValue,
|
||||||
BigDecimal salesPiecePrice,
|
BigDecimal salesPiecePrice,
|
||||||
BigDecimal dealPiecePrice) {
|
BigDecimal dealPiecePrice) {
|
||||||
|
|
||||||
BigDecimal netSales() {
|
|
||||||
return totalSales.subtract(totalRefund);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 多维或按日聚合用的累加桶:累计销售额、退款、成本 */
|
/** 多维或按日聚合用的累加桶:累计销售额、退款、成本 */
|
||||||
@@ -978,11 +952,5 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
refund = refund.add(nz(row.getRefundAmount()));
|
refund = refund.add(nz(row.getRefundAmount()));
|
||||||
cost = cost.add(nz(row.getProductCost())).add(nz(row.getFreightCost())).add(nz(row.getOtherCost()));
|
cost = cost.add(nz(row.getProductCost())).add(nz(row.getFreightCost())).add(nz(row.getOtherCost()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 桶内净销售额 max(0, 销售−退款),用于税额分摊 */
|
|
||||||
BigDecimal netSalesBase() {
|
|
||||||
BigDecimal b = sales.subtract(refund);
|
|
||||||
return b.max(BigDecimal.ZERO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ export namespace WorkbenchVO {
|
|||||||
|
|
||||||
export interface TrendPoint {
|
export interface TrendPoint {
|
||||||
date: string;
|
date: string;
|
||||||
|
/** 日成交金额(元):全部订单状态商家实收 */
|
||||||
|
dealYuan?: number;
|
||||||
/** 日实际销售额(元),与 KPI「实际销售额」同口径 */
|
/** 日实际销售额(元),与 KPI「实际销售额」同口径 */
|
||||||
salesYuan?: number;
|
salesYuan?: number;
|
||||||
/** 日毛利润(元)= 销售额−成本−退款 */
|
/** 日毛利润(元)= 销售额−成本−退款 */
|
||||||
|
|||||||
@@ -1,66 +1,46 @@
|
|||||||
/**
|
/**
|
||||||
* 全店 / 店铺 / 商品概览表格列说明(与后端汇总口径一致,供表头 Tooltip 使用)
|
* 全店 / 店铺 / 商品概览表格列说明(表头问号)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const overviewTableHints = {
|
export const overviewTableHints = {
|
||||||
targetOrderCount:
|
targetOrderCount: '区间内各店铺月度目标单量之和。',
|
||||||
'所选日期范围内,涉及月份的「店铺月度目标单量」之和(来自各店铺月度目标配置)。',
|
orderCountAchievementRate: '实际单量 / 目标单量 * 100%。',
|
||||||
orderCountAchievementRate: '实际单量 ÷ 目标单量 × 100%。',
|
targetAmount: '区间内各店铺月度目标销售额之和。',
|
||||||
targetAmount:
|
salesAmountAchievementRate: '实际销售额 / 目标额 * 100%。',
|
||||||
'所选日期范围内,涉及月份的「店铺月度目标销售额」之和(来自各店铺月度目标配置)。',
|
salesAmount: '计入销售额状态的商家实收合计。',
|
||||||
salesAmountAchievementRate: '实际销售额 ÷ 目标额 × 100%。',
|
dealAmount: '全部订单状态的商家实收合计。',
|
||||||
salesAmount:
|
grossProfit: '实际销售额 − 订单成本 − 退款额。',
|
||||||
'统计口径下,计入销售额的订单实收金额合计(与后端订单状态统计一致)。',
|
|
||||||
dealAmount:
|
|
||||||
'成交金额 = 所选时间范围内全部订单状态的商家实收金额合计(不按订单状态过滤)。',
|
|
||||||
grossProfit:
|
|
||||||
'毛利 = 实际销售额 − 订单成本 − 退款金额(未扣推广费、刷单费与税额)。',
|
|
||||||
/** 与 salesAmount 同口径,表头文案为「销售额」时使用 */
|
/** 与 salesAmount 同口径,表头文案为「销售额」时使用 */
|
||||||
salesAmountShort:
|
salesAmountShort: '计入销售额状态的商家实收合计。',
|
||||||
'统计口径下,计入销售额的订单实收金额合计(与后端订单状态统计一致)。',
|
orderCount: '计入销售额状态的订单笔数。',
|
||||||
orderCount: '统计口径下,计入销量的有效订单笔数。',
|
orderCountSku: '该 SKU 计入统计的订单笔数;括号内为件数。',
|
||||||
orderCountSku:
|
|
||||||
'该 SKU 下计入统计的订单笔数;括号内「件」为销售件数合计。',
|
|
||||||
/** @deprecated 使用 orderCountSku */
|
/** @deprecated 使用 orderCountSku */
|
||||||
orderCountSpec:
|
orderCountSpec: '该 SKU 计入统计的订单笔数;括号内为件数。',
|
||||||
'该 SKU 下计入统计的订单笔数;括号内「件」为销售件数合计。',
|
averageOrderValue: '销售额 / 单量。',
|
||||||
averageOrderValue: '销售额 ÷ 单量。',
|
productCost: '商品成本合计。',
|
||||||
productCost: '订单维度「商品成本」字段汇总。',
|
shippingCost: '运费成本合计。',
|
||||||
shippingCost: '订单维度「运费成本」字段汇总。',
|
otherCost: '其他成本合计。',
|
||||||
otherCost: '订单维度「其他成本」字段汇总。',
|
orderCost: '商品成本 + 运费 + 其他成本。',
|
||||||
orderCost:
|
refundAmount: '计入退款状态的商家实收合计。',
|
||||||
'订单成本 = 商品成本 + 运费 + 其他成本(订单维度汇总,不含推广费、刷单费)。',
|
totalPromotionFee: '推广费合计。',
|
||||||
refundAmount: '统计口径下,计入退款的实收金额合计。',
|
promotionFeeSku: '店铺推广费 *(该 SKU 订单数 / 区间总订单数)。',
|
||||||
totalPromotionFee: '该维度下推广费金额合计(来自推广费单据)。',
|
|
||||||
promotionFeeSku:
|
|
||||||
'该 SKU 推广费 = 店铺推广费总额 ×(该 SKU 订单数 ÷ 所选时间范围内订单总数),由后端按比例分摊。',
|
|
||||||
/** @deprecated 使用 promotionFeeSku */
|
/** @deprecated 使用 promotionFeeSku */
|
||||||
promotionFeeSpec:
|
promotionFeeSpec: '店铺推广费 *(该 SKU 订单数 / 区间总订单数)。',
|
||||||
'该 SKU 推广费 = 店铺推广费总额 ×(该 SKU 订单数 ÷ 所选时间范围内订单总数),由后端按比例分摊。',
|
brushFee: '刷单费合计。',
|
||||||
brushFee: '该维度下刷单费用合计(来自刷单记录)。',
|
feeRatioShopRow: '推广费 / 实际销售额;合计行含刷单费。',
|
||||||
feeRatioShopRow:
|
feeRatioShopCategoryRow: '推广费 / 实际销售额;合计行含刷单费。',
|
||||||
'费比 = 推广费 ÷ 实际销售额。(「合计」行:推广费与刷单费之和 ÷ 实际销售额)',
|
feeRatioCategoryRow: '推广费 / 实际销售额;合计行含刷单费。',
|
||||||
feeRatioShopCategoryRow:
|
feeRatioPlatform: '(推广费 + 刷单费)/ 实际销售额。',
|
||||||
'费比(各行)= 推广费 ÷ 实际销售额;「合计」行 =(推广费 + 刷单费)÷ 实际销售额。为单店内该品类汇总。',
|
feeRatioSku: '推广费 / 销售额(百分数 0–100)。',
|
||||||
feeRatioCategoryRow:
|
|
||||||
'费比 = 推广费 ÷ 实际销售额。全店品类行的推广费、刷单费按店铺在该品类销售额占比分摊;「合计」行费比 =(推广费 + 刷单费)÷ 实际销售额。',
|
|
||||||
feeRatioPlatform:
|
|
||||||
'费比 =(推广费 + 刷单费用)÷ 实际销售额。数据行与「合计」行口径一致。',
|
|
||||||
feeRatioSku:
|
|
||||||
'费比(%)= 推广费 ÷ 销售额;接口字段已为百分数数值(0–100),与店铺商品表费比展示方式不同。',
|
|
||||||
/** @deprecated 使用 feeRatioSku */
|
/** @deprecated 使用 feeRatioSku */
|
||||||
feeRatioSpec:
|
feeRatioSpec: '推广费 / 销售额(百分数 0–100)。',
|
||||||
'费比(%)= 推广费 ÷ 销售额;接口字段已为百分数数值(0–100),与店铺商品表费比展示方式不同。',
|
totalProfitBeforeTax: '毛利 − 推广费 − 刷单费。',
|
||||||
totalProfitBeforeTax:
|
profitBeforeTaxSku: '销售额 − 订单成本 − 退款额 − 推广费。',
|
||||||
'税前净利 = 毛利 − 推广费 − 刷单费用。',
|
|
||||||
profitBeforeTaxSku:
|
|
||||||
'税前净利 = 销售额 − 订单成本 − 退款金额 − 推广费(SKU 维度不含刷单费)。',
|
|
||||||
/** @deprecated 使用 profitBeforeTaxSku */
|
/** @deprecated 使用 profitBeforeTaxSku */
|
||||||
profitBeforeTaxSpec:
|
profitBeforeTaxSpec: '销售额 − 订单成本 − 退款额 − 推广费。',
|
||||||
'税前净利 = 销售额 − 订单成本 − 退款金额 − 推广费(SKU 维度不含刷单费)。',
|
roi: '实际销售额 / 推广费。',
|
||||||
roi: 'ROI =(实际销售额 − 退款金额)÷ 推广费;推广费为 0 时后端记为 0。',
|
profitAfterTax: '税前净利 − 税额。',
|
||||||
profitAfterTax: '税后净利 = 税前净利 − 税额。',
|
profitAfterTaxNet: '税前净利 − 税额。',
|
||||||
profitAfterTaxNet: '税后净利 = 税前净利 − 税额(与「税后盈亏」同口径,表头名称不同)。',
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/** @deprecated 使用 overviewTableHints */
|
/** @deprecated 使用 overviewTableHints */
|
||||||
@@ -68,5 +48,5 @@ export const storeOverviewHints = overviewTableHints;
|
|||||||
|
|
||||||
export function salesTaxColumnHint(taxRate: number): string {
|
export function salesTaxColumnHint(taxRate: number): string {
|
||||||
const pct = (taxRate * 100).toFixed(0);
|
const pct = (taxRate * 100).toFixed(0);
|
||||||
return `税额 = (销售额 - 退款金额) × ${pct}%(与当前页面所选税率一致,由后端按该税率计算)。`;
|
return `实际销售额 * ${pct}%。`;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-14
@@ -233,15 +233,15 @@ const emptyShellClass =
|
|||||||
overlay-class-name="workbench-kpi-card-popover"
|
overlay-class-name="workbench-kpi-card-popover"
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="w-[min(18rem,80vw)] space-y-1 py-0.5">
|
<div class="w-[min(20rem,80vw)] space-y-1 py-0.5">
|
||||||
<p class="mb-1.5 px-1 text-[11px] text-slate-400">
|
<p class="mb-2 px-1 text-xs text-slate-400">
|
||||||
点击切换优先显示
|
点击切换优先显示
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
v-for="m in row.members"
|
v-for="m in row.members"
|
||||||
:key="m.label"
|
:key="m.label"
|
||||||
type="button"
|
type="button"
|
||||||
class="flex w-full items-center justify-between gap-3 rounded-lg px-2 py-1.5 text-left transition-colors hover:bg-blue-50 dark:hover:bg-[hsl(240deg_3.7%_18%)]"
|
class="flex w-full items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-blue-50 dark:hover:bg-[hsl(240deg_3.7%_18%)]"
|
||||||
:class="
|
:class="
|
||||||
m.isPrimary
|
m.isPrimary
|
||||||
? 'bg-blue-50/80 dark:bg-[hsl(240deg_3.7%_16%)]'
|
? 'bg-blue-50/80 dark:bg-[hsl(240deg_3.7%_16%)]'
|
||||||
@@ -251,19 +251,19 @@ const emptyShellClass =
|
|||||||
>
|
>
|
||||||
<span class="min-w-0 flex-1">
|
<span class="min-w-0 flex-1">
|
||||||
<span
|
<span
|
||||||
class="block truncate text-xs font-semibold text-slate-700 dark:text-[hsl(0deg_0%_90%)]"
|
class="block truncate text-sm font-semibold text-slate-700 dark:text-[hsl(0deg_0%_90%)]"
|
||||||
>
|
>
|
||||||
{{ m.label }}
|
{{ m.label }}
|
||||||
<span
|
<span
|
||||||
v-if="m.isPrimary"
|
v-if="m.isPrimary"
|
||||||
class="ml-1 text-[10px] font-medium text-blue-500"
|
class="ml-1 text-xs font-medium text-blue-500"
|
||||||
>
|
>
|
||||||
当前
|
当前
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="m.kpi"
|
v-if="m.kpi"
|
||||||
class="mt-0.5 block text-[11px] tabular-nums text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
class="mt-0.5 block text-sm tabular-nums text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||||
>
|
>
|
||||||
{{ compactValue(m.kpi) }}
|
{{ compactValue(m.kpi) }}
|
||||||
<span
|
<span
|
||||||
@@ -287,22 +287,20 @@ const emptyShellClass =
|
|||||||
:title="getFinanceKpiHint(row.primaryLabel, taxRate ?? 0.04)"
|
:title="getFinanceKpiHint(row.primaryLabel, taxRate ?? 0.04)"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="block truncate text-[13px] font-medium leading-snug text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
class="block truncate text-[16px] font-semibold leading-snug text-slate-800 dark:text-[hsl(0deg_0%_90%)]"
|
||||||
>
|
>
|
||||||
{{ row.card.title }}
|
{{ row.primaryLabel }}
|
||||||
</span>
|
</span>
|
||||||
</OverviewColumnHint>
|
</OverviewColumnHint>
|
||||||
<p
|
|
||||||
class="mt-0.5 truncate text-[11px] font-semibold text-slate-800 dark:text-[hsl(0deg_0%_90%)]"
|
|
||||||
>
|
|
||||||
{{ row.primaryLabel }}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="grid size-9 shrink-0 place-items-center rounded-[10px]"
|
class="grid size-9 shrink-0 place-items-center rounded-[10px]"
|
||||||
:class="toneIconClass(row.card.tone)"
|
:class="toneIconClass(row.card.tone)"
|
||||||
>
|
>
|
||||||
<component :is="row.card.icon" class="size-4" />
|
<component
|
||||||
|
:is="kpiMetaByLabel(row.primaryLabel).icon"
|
||||||
|
class="size-4"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
+38
-5
@@ -27,6 +27,7 @@ const hasData = computed(
|
|||||||
props.trend.length > 0 &&
|
props.trend.length > 0 &&
|
||||||
props.trend.some(
|
props.trend.some(
|
||||||
(d) =>
|
(d) =>
|
||||||
|
Number(d.dealYuan ?? 0) !== 0 ||
|
||||||
Number(d.salesYuan ?? 0) !== 0 ||
|
Number(d.salesYuan ?? 0) !== 0 ||
|
||||||
Number(d.profitYuan ?? 0) !== 0 ||
|
Number(d.profitYuan ?? 0) !== 0 ||
|
||||||
Number(d.netProfitYuan ?? 0) !== 0,
|
Number(d.netProfitYuan ?? 0) !== 0,
|
||||||
@@ -34,17 +35,19 @@ const hasData = computed(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const periodSummary = computed(() => {
|
const periodSummary = computed(() => {
|
||||||
|
let deal = 0;
|
||||||
let sales = 0;
|
let sales = 0;
|
||||||
let gross = 0;
|
let gross = 0;
|
||||||
let net = 0;
|
let net = 0;
|
||||||
for (const d of props.trend) {
|
for (const d of props.trend) {
|
||||||
|
deal += Number(d.dealYuan ?? 0);
|
||||||
sales += Number(d.salesYuan ?? 0);
|
sales += Number(d.salesYuan ?? 0);
|
||||||
gross += Number(d.profitYuan ?? 0);
|
gross += Number(d.profitYuan ?? 0);
|
||||||
net += Number(d.netProfitYuan ?? 0);
|
net += Number(d.netProfitYuan ?? 0);
|
||||||
}
|
}
|
||||||
const netMarginPct =
|
const netMarginPct =
|
||||||
sales > 0 ? Number(((net / sales) * 100).toFixed(1)) : null;
|
sales > 0 ? Number(((net / sales) * 100).toFixed(1)) : null;
|
||||||
return { sales, gross, net, netMarginPct };
|
return { deal, sales, gross, net, netMarginPct };
|
||||||
});
|
});
|
||||||
|
|
||||||
function pctOfSales(part: number, sales: number): string {
|
function pctOfSales(part: number, sales: number): string {
|
||||||
@@ -74,6 +77,7 @@ function drawFinanceTrend() {
|
|||||||
const split = isDark ? 'hsl(240deg 3.7% 22%)' : '#f1f5f9';
|
const split = isDark ? 'hsl(240deg 3.7% 22%)' : '#f1f5f9';
|
||||||
const dates = props.trend.map((d) => d.date);
|
const dates = props.trend.map((d) => d.date);
|
||||||
|
|
||||||
|
const dealWan = props.trend.map((d) => yuanToWanNum(Number(d.dealYuan ?? 0)));
|
||||||
const salesWan = props.trend.map((d) => yuanToWanNum(Number(d.salesYuan ?? 0)));
|
const salesWan = props.trend.map((d) => yuanToWanNum(Number(d.salesYuan ?? 0)));
|
||||||
const grossWan = props.trend.map((d) => yuanToWanNum(Number(d.profitYuan ?? 0)));
|
const grossWan = props.trend.map((d) => yuanToWanNum(Number(d.profitYuan ?? 0)));
|
||||||
const netWan = props.trend.map((d) => yuanToWanNum(Number(d.netProfitYuan ?? 0)));
|
const netWan = props.trend.map((d) => yuanToWanNum(Number(d.netProfitYuan ?? 0)));
|
||||||
@@ -99,6 +103,7 @@ function drawFinanceTrend() {
|
|||||||
const idx = Number((params[0] as { dataIndex?: number })?.dataIndex ?? 0);
|
const idx = Number((params[0] as { dataIndex?: number })?.dataIndex ?? 0);
|
||||||
const row = props.trend[idx];
|
const row = props.trend[idx];
|
||||||
if (!row) return '';
|
if (!row) return '';
|
||||||
|
const deal = Number(row.dealYuan ?? 0);
|
||||||
const sales = Number(row.salesYuan ?? 0);
|
const sales = Number(row.salesYuan ?? 0);
|
||||||
const gross = Number(row.profitYuan ?? 0);
|
const gross = Number(row.profitYuan ?? 0);
|
||||||
const net = Number(row.netProfitYuan ?? 0);
|
const net = Number(row.netProfitYuan ?? 0);
|
||||||
@@ -108,6 +113,7 @@ function drawFinanceTrend() {
|
|||||||
);
|
);
|
||||||
const lines: string[] = [
|
const lines: string[] = [
|
||||||
`<div style="font-weight:800;margin-bottom:6px">${title}</div>`,
|
`<div style="font-weight:800;margin-bottom:6px">${title}</div>`,
|
||||||
|
`<span style="color:${isDark ? '#fbbf24' : '#d97706'}">●</span> 成交金额:${formatWanWithYuanDetail(deal)}`,
|
||||||
`<span style="color:${isDark ? '#60a5fa' : '#1d4ed8'}">●</span> 实际销售额:${formatWanWithYuanDetail(sales)}`,
|
`<span style="color:${isDark ? '#60a5fa' : '#1d4ed8'}">●</span> 实际销售额:${formatWanWithYuanDetail(sales)}`,
|
||||||
`<span style="color:${isDark ? '#34d399' : '#059669'}">●</span> 毛利:${formatWanWithYuanDetail(gross)} <span style="opacity:0.75">(毛利率 ${pctOfSales(gross, sales)})</span>`,
|
`<span style="color:${isDark ? '#34d399' : '#059669'}">●</span> 毛利:${formatWanWithYuanDetail(gross)} <span style="opacity:0.75">(毛利率 ${pctOfSales(gross, sales)})</span>`,
|
||||||
`<span style="color:${isDark ? '#c4b5fd' : '#6d28d9'}">●</span> 净利:${formatWanWithYuanDetail(net)} <span style="opacity:0.75">(净利率 ${pctOfSales(net, sales)})</span>`,
|
`<span style="color:${isDark ? '#c4b5fd' : '#6d28d9'}">●</span> 净利:${formatWanWithYuanDetail(net)} <span style="opacity:0.75">(净利率 ${pctOfSales(net, sales)})</span>`,
|
||||||
@@ -126,6 +132,7 @@ function drawFinanceTrend() {
|
|||||||
itemHeight: 8,
|
itemHeight: 8,
|
||||||
textStyle: { color: axisLabel, fontWeight: 700, fontSize: 11 },
|
textStyle: { color: axisLabel, fontWeight: 700, fontSize: 11 },
|
||||||
data: [
|
data: [
|
||||||
|
'成交金额',
|
||||||
'实际销售额',
|
'实际销售额',
|
||||||
'毛利',
|
'毛利',
|
||||||
'净利',
|
'净利',
|
||||||
@@ -192,10 +199,31 @@ function drawFinanceTrend() {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
series: [
|
series: [
|
||||||
|
{
|
||||||
|
name: '成交金额',
|
||||||
|
type: 'bar',
|
||||||
|
barMaxWidth: 22,
|
||||||
|
barGap: '12%',
|
||||||
|
itemStyle: {
|
||||||
|
borderRadius: [6, 6, 0, 0],
|
||||||
|
color: barGradient(
|
||||||
|
isDark,
|
||||||
|
isDark ? 'rgba(251, 191, 36, 0.85)' : 'rgba(217, 119, 6, 0.88)',
|
||||||
|
isDark ? 'rgba(217, 119, 6, 0.35)' : 'rgba(253, 230, 138, 0.55)',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
emphasis: {
|
||||||
|
itemStyle: {
|
||||||
|
color: isDark ? '#fcd34d' : '#d97706',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: dealWan,
|
||||||
|
z: 1,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: '实际销售额',
|
name: '实际销售额',
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
barMaxWidth: 28,
|
barMaxWidth: 22,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
borderRadius: [6, 6, 0, 0],
|
borderRadius: [6, 6, 0, 0],
|
||||||
color: barGradient(
|
color: barGradient(
|
||||||
@@ -266,9 +294,9 @@ function drawFinanceTrend() {
|
|||||||
lineStyle: {
|
lineStyle: {
|
||||||
width: 2,
|
width: 2,
|
||||||
type: 'dotted',
|
type: 'dotted',
|
||||||
color: isDark ? '#fbbf24' : '#d97706',
|
color: isDark ? '#94a3b8' : '#64748b',
|
||||||
},
|
},
|
||||||
itemStyle: { color: isDark ? '#fbbf24' : '#d97706' },
|
itemStyle: { color: isDark ? '#94a3b8' : '#64748b' },
|
||||||
data: netMarginPct,
|
data: netMarginPct,
|
||||||
z: 5,
|
z: 5,
|
||||||
},
|
},
|
||||||
@@ -346,13 +374,18 @@ defineExpose({ redraw });
|
|||||||
经营趋势
|
经营趋势
|
||||||
</h3>
|
</h3>
|
||||||
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||||
柱状为实际销售额,折线为毛利/净利;右轴为日净利率
|
柱状为成交金额 / 实际销售额,折线为毛利 / 净利;右轴为日净利率
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="hasData"
|
v-if="hasData"
|
||||||
class="flex flex-wrap gap-2 text-xs font-medium"
|
class="flex flex-wrap gap-2 text-xs font-medium"
|
||||||
>
|
>
|
||||||
|
<span
|
||||||
|
class="rounded-lg bg-amber-50 px-2.5 py-1 text-amber-700 dark:bg-amber-950/50 dark:text-amber-300"
|
||||||
|
>
|
||||||
|
区间成交 {{ formatWanWithYuanDetail(periodSummary.deal) }}
|
||||||
|
</span>
|
||||||
<span
|
<span
|
||||||
class="rounded-lg bg-blue-50 px-2.5 py-1 text-blue-600 dark:bg-blue-950/50 dark:text-blue-300"
|
class="rounded-lg bg-blue-50 px-2.5 py-1 text-blue-600 dark:bg-blue-950/50 dark:text-blue-300"
|
||||||
>
|
>
|
||||||
|
|||||||
+14
-26
@@ -1,25 +1,19 @@
|
|||||||
import { overviewTableHints, salesTaxColumnHint } from '#/utils/overview-table-hints';
|
import { overviewTableHints, salesTaxColumnHint } from '#/utils/overview-table-hints';
|
||||||
|
|
||||||
/** 工作台经营 KPI 计算说明(与汇总表、后端 WorkbenchServiceImpl 口径一致) */
|
/** 工作台经营 KPI 问号说明 */
|
||||||
const FINANCE_KPI_HINTS: Record<string, string> = {
|
const FINANCE_KPI_HINTS: Record<string, string> = {
|
||||||
成交金额: overviewTableHints.dealAmount,
|
成交金额: overviewTableHints.dealAmount,
|
||||||
成交单量:
|
成交单量: '全部订单状态的订单笔数。',
|
||||||
'所选时间范围内,全部订单状态的订单笔数合计(不按是否计入销售额过滤)。环比/同比为笔数变化率。',
|
成交销量: '全部订单状态的销售件数。',
|
||||||
成交销量:
|
成交客单价: '成交金额 / 成交单量。',
|
||||||
'所选时间范围内,全部订单状态的销售件数合计(订单行件数汇总)。',
|
成交件单价: '成交金额 / 成交销量。',
|
||||||
成交客单价: '成交金额 ÷ 成交单量;成交单量为 0 时为 0。',
|
|
||||||
成交件单价: '成交金额 ÷ 成交销量;成交销量为 0 时为 0。',
|
|
||||||
实际销售额: overviewTableHints.salesAmount,
|
实际销售额: overviewTableHints.salesAmount,
|
||||||
销售单量:
|
销售单量: '计入销售额状态的订单笔数。',
|
||||||
'统计口径下,计入销售额的有效订单笔数(与下方汇总表「单量」列一致)。环比/同比为笔数变化率。',
|
实际销量: '计入销售额状态的销售件数。',
|
||||||
实际销量: '计入销售额的订单状态件数合计。',
|
客单价: '实际销售额 / 销售单量。',
|
||||||
客单价: '实际销售额 ÷ 销售单量;销售单量为 0 时为 0。',
|
销售件单价: '实际销售额 / 实际销量。',
|
||||||
销售件单价: '实际销售额 ÷ 实际销量;实际销量为 0 时为 0。',
|
|
||||||
净销售额: '实际销售额 − 退款额(与广告 ROI 分子、税额计税基数同口径)。',
|
|
||||||
退款额: overviewTableHints.refundAmount,
|
退款额: overviewTableHints.refundAmount,
|
||||||
退款率: '退款额 ÷ 实际销售额 × 100%;实际销售额为 0 时为 0。',
|
退款率: '退款额 / 实际销售额 * 100%。',
|
||||||
'成交与销售差额':
|
|
||||||
'成交金额 − 实际销售额,反映未计入销售口径的订单实收差额。',
|
|
||||||
订单成本: overviewTableHints.orderCost,
|
订单成本: overviewTableHints.orderCost,
|
||||||
商品成本: overviewTableHints.productCost,
|
商品成本: overviewTableHints.productCost,
|
||||||
运费成本: overviewTableHints.shippingCost,
|
运费成本: overviewTableHints.shippingCost,
|
||||||
@@ -27,20 +21,14 @@ const FINANCE_KPI_HINTS: Record<string, string> = {
|
|||||||
毛利润: overviewTableHints.grossProfit,
|
毛利润: overviewTableHints.grossProfit,
|
||||||
推广费: overviewTableHints.totalPromotionFee,
|
推广费: overviewTableHints.totalPromotionFee,
|
||||||
刷单费: overviewTableHints.brushFee,
|
刷单费: overviewTableHints.brushFee,
|
||||||
净利润:
|
净利润: '毛利润 − 推广费 − 刷单费 − 税额。',
|
||||||
'净利润 = 毛利润 − 推广费 − 刷单费 − 税额(与汇总表损益链路一致)。卡片副文案中的净利率 = 净利润 ÷ 实际销售额。',
|
|
||||||
广告ROI: overviewTableHints.roi,
|
广告ROI: overviewTableHints.roi,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/** KPI 标题旁问号 Tooltip;税额随页面税率变化。 */
|
||||||
* 获取 KPI 标题旁问号 Tooltip 文案;税额随页面税率变化。
|
|
||||||
*/
|
|
||||||
export function getFinanceKpiHint(label: string, taxRate = 0.04): string {
|
export function getFinanceKpiHint(label: string, taxRate = 0.04): string {
|
||||||
if (label === '税额') {
|
if (label === '税额') {
|
||||||
return `${salesTaxColumnHint(taxRate)} 工作台按净销售额计税基数汇总。`;
|
return salesTaxColumnHint(taxRate);
|
||||||
}
|
}
|
||||||
return (
|
return FINANCE_KPI_HINTS[label] ?? '暂无说明。';
|
||||||
FINANCE_KPI_HINTS[label] ??
|
|
||||||
'该指标说明暂未配置,请以汇总表同名列或系统配置口径为准。'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -47,7 +47,6 @@ const IconTruck = createIconifyIcon('lucide:truck');
|
|||||||
const IconMegaphone = createIconifyIcon('lucide:megaphone');
|
const IconMegaphone = createIconifyIcon('lucide:megaphone');
|
||||||
const IconBrush = createIconifyIcon('lucide:brush');
|
const IconBrush = createIconifyIcon('lucide:brush');
|
||||||
const IconTax = createIconifyIcon('lucide:landmark');
|
const IconTax = createIconifyIcon('lucide:landmark');
|
||||||
const IconScale = createIconifyIcon('lucide:scale');
|
|
||||||
const IconReceipt = createIconifyIcon('lucide:receipt');
|
const IconReceipt = createIconifyIcon('lucide:receipt');
|
||||||
const IconDefault = createIconifyIcon('lucide:bar-chart-3');
|
const IconDefault = createIconifyIcon('lucide:bar-chart-3');
|
||||||
|
|
||||||
@@ -69,10 +68,8 @@ export const FINANCE_KPI_METRIC_META: Record<string, FinanceKpiMetricMeta> = {
|
|||||||
实际销量: { label: '实际销量', upIsGood: true, icon: IconPackage },
|
实际销量: { label: '实际销量', upIsGood: true, icon: IconPackage },
|
||||||
客单价: { label: '客单价', upIsGood: true, icon: IconAov },
|
客单价: { label: '客单价', upIsGood: true, icon: IconAov },
|
||||||
销售件单价: { label: '销售件单价', upIsGood: true, icon: IconReceipt },
|
销售件单价: { label: '销售件单价', upIsGood: true, icon: IconReceipt },
|
||||||
净销售额: { label: '净销售额', upIsGood: true, icon: IconNet },
|
|
||||||
退款额: { label: '退款额', upIsGood: false, icon: IconRefund },
|
退款额: { label: '退款额', upIsGood: false, icon: IconRefund },
|
||||||
退款率: { label: '退款率', upIsGood: false, icon: IconPercent },
|
退款率: { label: '退款率', upIsGood: false, icon: IconPercent },
|
||||||
'成交与销售差额': { label: '成交与销售差额', upIsGood: true, icon: IconScale },
|
|
||||||
订单成本: { label: '订单成本', upIsGood: false, icon: IconCost },
|
订单成本: { label: '订单成本', upIsGood: false, icon: IconCost },
|
||||||
商品成本: { label: '商品成本', upIsGood: false, icon: IconPackage },
|
商品成本: { label: '商品成本', upIsGood: false, icon: IconPackage },
|
||||||
运费成本: { label: '运费成本', upIsGood: false, icon: IconTruck },
|
运费成本: { label: '运费成本', upIsGood: false, icon: IconTruck },
|
||||||
@@ -103,7 +100,7 @@ export const FINANCE_KPI_CARDS: FinanceKpiCardDef[] = [
|
|||||||
{
|
{
|
||||||
id: 'revenue',
|
id: 'revenue',
|
||||||
title: '销售额',
|
title: '销售额',
|
||||||
metrics: ['实际销售额', '成交金额', '净销售额', '成交与销售差额'],
|
metrics: ['实际销售额', '成交金额'],
|
||||||
defaultPrimary: '实际销售额',
|
defaultPrimary: '实际销售额',
|
||||||
icon: IconSales,
|
icon: IconSales,
|
||||||
tone: 'blue',
|
tone: 'blue',
|
||||||
|
|||||||
Reference in New Issue
Block a user