feat: 经营趋势增加单量统计

This commit is contained in:
2026-08-14 20:56:53 +08:00
parent e39d34700e
commit 070b555dde
6 changed files with 89 additions and 8 deletions
@@ -64,6 +64,7 @@ public class BiOrderStatQueryService {
r.setFreightCost(BigDecimal.ZERO);
r.setOtherCost(BigDecimal.ZERO);
r.setOrderCount(0L);
r.setDealOrderCount(0L);
return r;
});
row.setSalesAmount(nz(row.getSalesAmount()).add(nz(doc.getSalesAmount())));
@@ -73,6 +74,7 @@ public class BiOrderStatQueryService {
row.setFreightCost(nz(row.getFreightCost()).add(nz(doc.getFreightCost())));
row.setOtherCost(nz(row.getOtherCost()).add(nz(doc.getOtherCost())));
row.setOrderCount(nzLong(row.getOrderCount()) + nzInt(doc.getSalesOrderCount()));
row.setDealOrderCount(nzLong(row.getDealOrderCount()) + nzInt(doc.getDealOrderCount()));
}
return new ArrayList<>(byDay.values());
}
@@ -189,6 +191,7 @@ public class BiOrderStatQueryService {
r.setFreightCost(BigDecimal.ZERO);
r.setOtherCost(BigDecimal.ZERO);
r.setOrderCount(0L);
r.setDealOrderCount(0L);
return r;
});
row.setSalesAmount(nz(row.getSalesAmount()).add(nz(doc.getSalesAmount())));
@@ -198,6 +201,7 @@ public class BiOrderStatQueryService {
row.setFreightCost(nz(row.getFreightCost()).add(nz(doc.getFreightCost())));
row.setOtherCost(nz(row.getOtherCost()).add(nz(doc.getOtherCost())));
row.setOrderCount(nzLong(row.getOrderCount()) + nzInt(doc.getSalesOrderCount()));
row.setDealOrderCount(nzLong(row.getDealOrderCount()) + nzInt(doc.getDealOrderCount()));
}
return new ArrayList<>(byDay.values());
}
@@ -40,8 +40,10 @@ public final class OverviewAggRows {
private BigDecimal productCost;
private BigDecimal freightCost;
private BigDecimal otherCost;
/** 当日销售单量合计(店铺/商品日汇聚 salesOrderCount) */
/** 当日销售单量合计(店铺/商品日汇聚 salesOrderCount,与「实际销售额」同口径) */
private Long orderCount;
/** 当日成交单量合计(店铺/商品日汇聚 dealOrderCount) */
private Long dealOrderCount;
}
@Data
@@ -21,9 +21,15 @@ public class WorkbenchTrendPointVO {
@Schema(description = "成交金额(元,两位小数):全部订单状态商家实收合计")
private BigDecimal dealYuan;
@Schema(description = "成交单量:全部订单状态的订单笔数,与 KPI「成交单量」同口径")
private Integer dealOrderCount;
@Schema(description = "实际销售额(元,两位小数),与计入销售额的订单状态配置一致")
private BigDecimal salesYuan;
@Schema(description = "实际销售单量:计入销售额状态的订单笔数,与 KPI「销售单量」同口径")
private Integer salesOrderCount;
@Schema(description = "日毛利润(元,两位小数)= 销售额−成本−退款,与 KPI「毛利润」按日拆解口径一致")
private BigDecimal profitYuan;
@@ -395,6 +395,8 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
OverviewAggRows.DailyRow row = byDay.get(d);
BigDecimal sales = row != null ? nz(row.getSalesAmount()) : BigDecimal.ZERO;
BigDecimal deal = row != null ? nz(row.getDealAmount()) : BigDecimal.ZERO;
int salesOrders = row != null && row.getOrderCount() != null ? row.getOrderCount().intValue() : 0;
int dealOrders = row != null && row.getDealOrderCount() != null ? row.getDealOrderCount().intValue() : 0;
BigDecimal refund = row != null ? nz(row.getRefundAmount()) : BigDecimal.ZERO;
BigDecimal cost = row != null
? nz(row.getProductCost()).add(nz(row.getFreightCost())).add(nz(row.getOtherCost())) : BigDecimal.ZERO;
@@ -408,7 +410,9 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
list.add(WorkbenchTrendPointVO.builder()
.date(d.format(TREND_DATE_FMT))
.dealYuan(yuan2(deal))
.dealOrderCount(dealOrders)
.salesYuan(yuan2(sales))
.salesOrderCount(salesOrders)
.profitYuan(yuan2(gross))
.netProfitYuan(yuan2(gross.subtract(promoB).subtract(brushB).subtract(taxB)))
.refundYuan(yuan2(refund))