mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 23:49:19 +08:00
feat: 移除 BI Overview 旧趋势字段,统一使用 dealTrend
This commit is contained in:
@@ -302,7 +302,7 @@ CREATE TABLE ec_order_stat_daily_product (
|
||||
|
||||
- `specSummaries`:按规格行的销售额/成本/推广费分摊
|
||||
- `specSalesTop10`:规格销量排行
|
||||
- `salesAmountTrend` / `orderCountTrend`:可按商品日表;规格明细走本表
|
||||
- 日趋势:现用 `dealTrend`(`WorkbenchTrendPointVO`);旧 `salesAmountTrend` / `orderCountTrend` 已弃用删除;规格明细走本表
|
||||
|
||||
```sql
|
||||
CREATE TABLE ec_order_stat_daily_spec (
|
||||
@@ -628,7 +628,7 @@ RefreshWorker 循环:
|
||||
| 单店 `selectList` ×2(当前+上月) | `sumShopMetrics(company, [shopId], range)` ×2 |
|
||||
| `calculateProductOverview(orders)` 逐单按 product 分组 | `sumProductMetricsByProduct` 过滤 `shop_id` |
|
||||
| `calculateCategoryOverview(orders)` | `sumProductMetricsByCategory` 过滤 `shop_id` |
|
||||
| 销售额/订单量趋势 `buildTrendData(orders)` | `sumShopMetricsByDay` 单店 |
|
||||
| 销售额/订单量趋势(现 `dealTrend`) | `sumShopMetricsByDay` 单店 |
|
||||
| `productSalesTop10` 逐单排序 | `sumProductMetricsByProduct` + ORDER BY sales LIMIT 10 |
|
||||
|
||||
**不再加载** `List<OrderPO> orders`;规格/商品名称仍批量查 `ec_product` / `ec_category` 主数据(行数 = SKU 数,非订单数)。
|
||||
|
||||
-20
@@ -1,13 +1,11 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.bi.categoryoverview.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchCostSliceVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchKpiItemVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchTrendPointVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -53,11 +51,6 @@ public class CategoryOverviewVO {
|
||||
|
||||
private List<ProductSalesRankItem> productSalesTop10;
|
||||
|
||||
/** @deprecated 使用 dealTrend */
|
||||
private TrendData salesAmountTrend;
|
||||
/** @deprecated 使用 dealTrend */
|
||||
private TrendData orderCountTrend;
|
||||
|
||||
private ProductOverview productOverview;
|
||||
|
||||
@Data
|
||||
@@ -101,17 +94,4 @@ public class CategoryOverviewVO {
|
||||
private BigDecimal profitAfterTax;
|
||||
private BigDecimal roi;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class TrendData {
|
||||
private BigDecimal total;
|
||||
private List<TrendDataItem> dailyDataList;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class TrendDataItem {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate date;
|
||||
private BigDecimal value;
|
||||
}
|
||||
}
|
||||
|
||||
-31
@@ -121,7 +121,6 @@ public class BiCategoryOverviewServiceImpl implements BiCategoryOverviewService
|
||||
fillProductSalesTop10(vo);
|
||||
fillLegacyFlatFields(vo, curT, prevT);
|
||||
fillTargets(vo, companyId, cur.shopIds(), start, end, curT.totalSales(), curT.orderCount());
|
||||
fillLegacyTrends(vo, dealTrend);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -249,36 +248,6 @@ public class BiCategoryOverviewServiceImpl implements BiCategoryOverviewService
|
||||
vo.setMonthOverMonthGrowth(BiFinanceKpiAssembler.pctChange(cur.totalSales(), prev.totalSales()));
|
||||
}
|
||||
|
||||
private void fillLegacyTrends(CategoryOverviewVO vo, List<WorkbenchTrendPointVO> dealTrend) {
|
||||
CategoryOverviewVO.TrendData sales = new CategoryOverviewVO.TrendData();
|
||||
CategoryOverviewVO.TrendData orders = new CategoryOverviewVO.TrendData();
|
||||
List<CategoryOverviewVO.TrendDataItem> salesItems = new ArrayList<>();
|
||||
List<CategoryOverviewVO.TrendDataItem> orderItems = new ArrayList<>();
|
||||
BigDecimal salesTotal = BigDecimal.ZERO;
|
||||
BigDecimal orderTotal = BigDecimal.ZERO;
|
||||
if (dealTrend != null) {
|
||||
for (WorkbenchTrendPointVO p : dealTrend) {
|
||||
CategoryOverviewVO.TrendDataItem s = new CategoryOverviewVO.TrendDataItem();
|
||||
s.setDate(LocalDate.parse(p.getDate()));
|
||||
s.setValue(BiFinanceKpiAssembler.nz(p.getSalesYuan()));
|
||||
salesItems.add(s);
|
||||
salesTotal = salesTotal.add(s.getValue());
|
||||
|
||||
CategoryOverviewVO.TrendDataItem o = new CategoryOverviewVO.TrendDataItem();
|
||||
o.setDate(s.getDate());
|
||||
o.setValue(BigDecimal.valueOf(p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0));
|
||||
orderItems.add(o);
|
||||
orderTotal = orderTotal.add(o.getValue());
|
||||
}
|
||||
}
|
||||
sales.setDailyDataList(salesItems);
|
||||
sales.setTotal(salesTotal);
|
||||
orders.setDailyDataList(orderItems);
|
||||
orders.setTotal(orderTotal);
|
||||
vo.setSalesAmountTrend(sales);
|
||||
vo.setOrderCountTrend(orders);
|
||||
}
|
||||
|
||||
private void fillTargets(CategoryOverviewVO vo, Long companyId, List<Long> shopIds,
|
||||
LocalDate startDate, LocalDate endDate,
|
||||
BigDecimal sales, int orderCount) {
|
||||
|
||||
-31
@@ -1,10 +1,8 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.bi.overview.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -58,16 +56,6 @@ public class CompanyOverviewVO {
|
||||
*/
|
||||
private List<ShopEfficiencyQuadrant> shopEfficiencyQuadrants;
|
||||
|
||||
/**
|
||||
* 销售额趋势分析
|
||||
*/
|
||||
private TrendData salesAmountTrend;
|
||||
|
||||
/**
|
||||
* 单量趋势分析
|
||||
*/
|
||||
private TrendData orderCountTrend;
|
||||
|
||||
/**
|
||||
* 多店铺数据横向汇总(包含合计行和店铺列表)
|
||||
*/
|
||||
@@ -156,25 +144,6 @@ public class CompanyOverviewVO {
|
||||
*/
|
||||
private BigDecimal salesAmountAchievementRate;
|
||||
|
||||
/**
|
||||
* 趋势数据
|
||||
*/
|
||||
@Data
|
||||
public static class TrendData {
|
||||
private BigDecimal total;
|
||||
private List<TrendDataItem> dailyDataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 趋势数据项
|
||||
*/
|
||||
@Data
|
||||
public static class TrendDataItem {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate date;
|
||||
private BigDecimal value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺销售占比
|
||||
*/
|
||||
|
||||
+29
-30
@@ -11,6 +11,7 @@ import top.xyquan.ecomdmbbackend.modules.bi.shopoverview.service.BiShopOverviewS
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.overview.model.dto.CategoryExportDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.overview.model.vo.CompanyOverviewVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.overview.service.CategoryExportExcelService;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchTrendPointVO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
@@ -18,7 +19,7 @@ import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -145,9 +146,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
try (Workbook workbook = new XSSFWorkbook()) {
|
||||
Sheet sheet = workbook.createSheet("品类汇总");
|
||||
writeCategoryMultidimensionalSheet(sheet, shopTitle, dateRangeLabel, rows, totalRow, taxRate, "品类名称");
|
||||
if (vo.getSalesAmountTrend() != null
|
||||
&& vo.getSalesAmountTrend().getDailyDataList() != null
|
||||
&& !vo.getSalesAmountTrend().getDailyDataList().isEmpty()) {
|
||||
if (vo.getDealTrend() != null && !vo.getDealTrend().isEmpty()) {
|
||||
Sheet trendSheet = workbook.createSheet("销量趋势");
|
||||
writeShopSalesTrendSheet(trendSheet, shopTitle, dateRangeLabel, vo);
|
||||
}
|
||||
@@ -160,7 +159,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
}
|
||||
}
|
||||
|
||||
/** 与店铺概览销量趋势同源({@link ShopOverviewStatisticsVO} 日销售额、日单量)。 */
|
||||
/** 与店铺概览销量趋势同源:从 {@link ShopOverviewStatisticsVO#getDealTrend()} 取日销售额/单量。 */
|
||||
private void writeShopSalesTrendSheet(
|
||||
Sheet sheet, String shopContextTitle, String dateRangeLabel, ShopOverviewStatisticsVO vo) {
|
||||
Workbook wb = sheet.getWorkbook();
|
||||
@@ -181,32 +180,32 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
cell.setCellStyle(headerStyle);
|
||||
}
|
||||
|
||||
List<ShopOverviewStatisticsVO.TrendDataItem> dailySales = vo.getSalesAmountTrend().getDailyDataList();
|
||||
List<ShopOverviewStatisticsVO.TrendDataItem> dailyOrders = vo.getOrderCountTrend() != null
|
||||
? vo.getOrderCountTrend().getDailyDataList()
|
||||
: null;
|
||||
List<WorkbenchTrendPointVO> dealTrend = vo.getDealTrend();
|
||||
if (dealTrend == null || dealTrend.isEmpty()) {
|
||||
sheet.setColumnWidth(0, 3200);
|
||||
sheet.setColumnWidth(1, 3200);
|
||||
sheet.setColumnWidth(2, 3200);
|
||||
return;
|
||||
}
|
||||
|
||||
Map<LocalDate, BigDecimal> salesMap = dailySales.stream()
|
||||
.collect(Collectors.toMap(
|
||||
ShopOverviewStatisticsVO.TrendDataItem::getDate,
|
||||
ShopOverviewStatisticsVO.TrendDataItem::getValue,
|
||||
(a, b) -> a));
|
||||
Map<LocalDate, BigDecimal> ordersMap = dailyOrders != null
|
||||
? dailyOrders.stream()
|
||||
.collect(Collectors.toMap(
|
||||
ShopOverviewStatisticsVO.TrendDataItem::getDate,
|
||||
ShopOverviewStatisticsVO.TrendDataItem::getValue,
|
||||
(a, b) -> a))
|
||||
: Collections.emptyMap();
|
||||
|
||||
LocalDate startDate = dailySales.stream()
|
||||
.map(ShopOverviewStatisticsVO.TrendDataItem::getDate)
|
||||
.min(LocalDate::compareTo)
|
||||
.orElse(null);
|
||||
LocalDate endDate = dailySales.stream()
|
||||
.map(ShopOverviewStatisticsVO.TrendDataItem::getDate)
|
||||
.max(LocalDate::compareTo)
|
||||
.orElse(null);
|
||||
Map<LocalDate, BigDecimal> salesMap = new HashMap<>();
|
||||
Map<LocalDate, BigDecimal> ordersMap = new HashMap<>();
|
||||
LocalDate startDate = null;
|
||||
LocalDate endDate = null;
|
||||
for (WorkbenchTrendPointVO p : dealTrend) {
|
||||
if (p == null || p.getDate() == null || p.getDate().isBlank()) {
|
||||
continue;
|
||||
}
|
||||
LocalDate d = LocalDate.parse(p.getDate());
|
||||
salesMap.put(d, p.getSalesYuan() != null ? p.getSalesYuan() : BigDecimal.ZERO);
|
||||
ordersMap.put(d, BigDecimal.valueOf(p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0));
|
||||
if (startDate == null || d.isBefore(startDate)) {
|
||||
startDate = d;
|
||||
}
|
||||
if (endDate == null || d.isAfter(endDate)) {
|
||||
endDate = d;
|
||||
}
|
||||
}
|
||||
|
||||
int rowIdx = 2;
|
||||
if (startDate != null && endDate != null) {
|
||||
|
||||
-20
@@ -1,13 +1,11 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.bi.platformoverview.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchCostSliceVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchKpiItemVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchTrendPointVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -53,11 +51,6 @@ public class PlatformOverviewVO {
|
||||
|
||||
private List<ProductSalesRankItem> productSalesTop10;
|
||||
|
||||
/** @deprecated 使用 dealTrend;保留以免旧客户端空指针 */
|
||||
private TrendData salesAmountTrend;
|
||||
/** @deprecated 使用 dealTrend */
|
||||
private TrendData orderCountTrend;
|
||||
|
||||
private ProductOverview productOverview;
|
||||
|
||||
private CategoryOverview categoryOverview;
|
||||
@@ -135,17 +128,4 @@ public class PlatformOverviewVO {
|
||||
private BigDecimal profitAfterTax;
|
||||
private BigDecimal roi;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class TrendData {
|
||||
private BigDecimal total;
|
||||
private List<TrendDataItem> dailyDataList;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class TrendDataItem {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate date;
|
||||
private BigDecimal value;
|
||||
}
|
||||
}
|
||||
|
||||
-32
@@ -123,7 +123,6 @@ public class BiPlatformOverviewServiceImpl implements BiPlatformOverviewService
|
||||
fillProductSalesTop10(vo);
|
||||
fillLegacyFlatFields(vo, curT, prevT);
|
||||
fillTargets(vo, companyId, shopIds, start, end, curT.totalSales(), curT.orderCount());
|
||||
fillLegacyTrends(vo, dealTrend);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -217,7 +216,6 @@ public class BiPlatformOverviewServiceImpl implements BiPlatformOverviewService
|
||||
co.setCategories(List.of());
|
||||
vo.setCategoryOverview(co);
|
||||
fillLegacyFlatFields(vo, empty, empty);
|
||||
fillLegacyTrends(vo, vo.getDealTrend());
|
||||
}
|
||||
|
||||
private void fillLegacyFlatFields(PlatformOverviewVO vo,
|
||||
@@ -241,36 +239,6 @@ public class BiPlatformOverviewServiceImpl implements BiPlatformOverviewService
|
||||
vo.setMonthOverMonthGrowth(BiFinanceKpiAssembler.pctChange(cur.totalSales(), prev.totalSales()));
|
||||
}
|
||||
|
||||
private void fillLegacyTrends(PlatformOverviewVO vo, List<WorkbenchTrendPointVO> dealTrend) {
|
||||
PlatformOverviewVO.TrendData sales = new PlatformOverviewVO.TrendData();
|
||||
PlatformOverviewVO.TrendData orders = new PlatformOverviewVO.TrendData();
|
||||
List<PlatformOverviewVO.TrendDataItem> salesItems = new ArrayList<>();
|
||||
List<PlatformOverviewVO.TrendDataItem> orderItems = new ArrayList<>();
|
||||
BigDecimal salesTotal = BigDecimal.ZERO;
|
||||
BigDecimal orderTotal = BigDecimal.ZERO;
|
||||
if (dealTrend != null) {
|
||||
for (WorkbenchTrendPointVO p : dealTrend) {
|
||||
PlatformOverviewVO.TrendDataItem s = new PlatformOverviewVO.TrendDataItem();
|
||||
s.setDate(LocalDate.parse(p.getDate()));
|
||||
s.setValue(BiFinanceKpiAssembler.nz(p.getSalesYuan()));
|
||||
salesItems.add(s);
|
||||
salesTotal = salesTotal.add(s.getValue());
|
||||
|
||||
PlatformOverviewVO.TrendDataItem o = new PlatformOverviewVO.TrendDataItem();
|
||||
o.setDate(s.getDate());
|
||||
o.setValue(BigDecimal.valueOf(p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0));
|
||||
orderItems.add(o);
|
||||
orderTotal = orderTotal.add(o.getValue());
|
||||
}
|
||||
}
|
||||
sales.setDailyDataList(salesItems);
|
||||
sales.setTotal(salesTotal);
|
||||
orders.setDailyDataList(orderItems);
|
||||
orders.setTotal(orderTotal);
|
||||
vo.setSalesAmountTrend(sales);
|
||||
vo.setOrderCountTrend(orders);
|
||||
}
|
||||
|
||||
private void fillTargets(PlatformOverviewVO vo, Long companyId, List<Long> shopIds,
|
||||
LocalDate startDate, LocalDate endDate,
|
||||
BigDecimal sales, int orderCount) {
|
||||
|
||||
-20
@@ -1,13 +1,11 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.bi.productoverview.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchCostSliceVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchKpiItemVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchTrendPointVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -47,26 +45,8 @@ public class ProductOverviewVO {
|
||||
|
||||
private List<SpecSalesRankItem> specSalesTop10;
|
||||
|
||||
/** @deprecated 使用 dealTrend;保留以免旧客户端空指针 */
|
||||
private TrendData salesAmountTrend;
|
||||
/** @deprecated 使用 dealTrend */
|
||||
private TrendData orderCountTrend;
|
||||
|
||||
private SpecSummary specSummaries;
|
||||
|
||||
@Data
|
||||
public static class TrendData {
|
||||
private BigDecimal total;
|
||||
private List<TrendDataItem> dailyDataList;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class TrendDataItem {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate date;
|
||||
private BigDecimal value;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SpecSummary {
|
||||
private List<SpecSummaryItem> list;
|
||||
|
||||
-31
@@ -132,7 +132,6 @@ public class BiProductOverviewServiceImpl implements BiProductOverviewService {
|
||||
vo.setSpecSalesTop10(buildSpecTop10(specSummaries));
|
||||
fillLegacyFlatFields(vo, curT, prevT);
|
||||
fillTargets(vo, companyId, cur.shopIds(), start, end, curT.totalSales(), curT.orderCount());
|
||||
fillLegacyTrends(vo, dealTrend);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -204,36 +203,6 @@ public class BiProductOverviewServiceImpl implements BiProductOverviewService {
|
||||
vo.setMonthOverMonthGrowth(BiFinanceKpiAssembler.pctChange(cur.totalSales(), prev.totalSales()));
|
||||
}
|
||||
|
||||
private void fillLegacyTrends(ProductOverviewVO vo, List<WorkbenchTrendPointVO> dealTrend) {
|
||||
ProductOverviewVO.TrendData sales = new ProductOverviewVO.TrendData();
|
||||
ProductOverviewVO.TrendData orders = new ProductOverviewVO.TrendData();
|
||||
List<ProductOverviewVO.TrendDataItem> salesItems = new ArrayList<>();
|
||||
List<ProductOverviewVO.TrendDataItem> orderItems = new ArrayList<>();
|
||||
BigDecimal salesTotal = BigDecimal.ZERO;
|
||||
BigDecimal orderTotal = BigDecimal.ZERO;
|
||||
if (dealTrend != null) {
|
||||
for (WorkbenchTrendPointVO p : dealTrend) {
|
||||
ProductOverviewVO.TrendDataItem s = new ProductOverviewVO.TrendDataItem();
|
||||
s.setDate(LocalDate.parse(p.getDate()));
|
||||
s.setValue(BiFinanceKpiAssembler.nz(p.getSalesYuan()));
|
||||
salesItems.add(s);
|
||||
salesTotal = salesTotal.add(s.getValue());
|
||||
|
||||
ProductOverviewVO.TrendDataItem o = new ProductOverviewVO.TrendDataItem();
|
||||
o.setDate(s.getDate());
|
||||
o.setValue(BigDecimal.valueOf(p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0));
|
||||
orderItems.add(o);
|
||||
orderTotal = orderTotal.add(o.getValue());
|
||||
}
|
||||
}
|
||||
sales.setDailyDataList(salesItems);
|
||||
sales.setTotal(salesTotal);
|
||||
orders.setDailyDataList(orderItems);
|
||||
orders.setTotal(orderTotal);
|
||||
vo.setSalesAmountTrend(sales);
|
||||
vo.setOrderCountTrend(orders);
|
||||
}
|
||||
|
||||
private void fillTargets(ProductOverviewVO vo, Long companyId, List<Long> shopIds,
|
||||
LocalDate start, LocalDate end, BigDecimal sales, int orderCount) {
|
||||
if (shopIds == null || shopIds.isEmpty()) {
|
||||
|
||||
-40
@@ -1,13 +1,11 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.bi.shopoverview.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchCostSliceVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchKpiItemVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchTrendPointVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -52,11 +50,6 @@ public class ShopOverviewStatisticsVO {
|
||||
|
||||
private List<ProductSalesRankItem> productSalesTop10;
|
||||
|
||||
/** @deprecated 使用 dealTrend */
|
||||
private TrendData salesAmountTrend;
|
||||
/** @deprecated 使用 dealTrend */
|
||||
private TrendData orderCountTrend;
|
||||
|
||||
private ProductOverview productOverview;
|
||||
private CategoryOverview categoryOverview;
|
||||
|
||||
@@ -207,38 +200,5 @@ public class ShopOverviewStatisticsVO {
|
||||
|
||||
private BigDecimal roi;
|
||||
}
|
||||
|
||||
/**
|
||||
* 趋势数据
|
||||
*/
|
||||
@Data
|
||||
public static class TrendData {
|
||||
/**
|
||||
* 时间范围的总值
|
||||
*/
|
||||
private BigDecimal total;
|
||||
|
||||
/**
|
||||
* 每日数据列表
|
||||
*/
|
||||
private List<TrendDataItem> dailyDataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 趋势数据项
|
||||
*/
|
||||
@Data
|
||||
public static class TrendDataItem {
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 对应的值
|
||||
*/
|
||||
private BigDecimal value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+30
-20
@@ -12,6 +12,7 @@ import top.xyquan.ecomdmbbackend.modules.bi.shopoverview.model.vo.ShopOverviewSt
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.shopoverview.service.BiShopOverviewService;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.overview.service.CategoryExportExcelService;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.shopoverview.service.BiShopExportService;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchTrendPointVO;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
@@ -19,9 +20,9 @@ import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class BiShopExportServiceImpl implements BiShopExportService {
|
||||
@@ -81,9 +82,8 @@ public class BiShopExportServiceImpl implements BiShopExportService {
|
||||
}
|
||||
|
||||
if (("trend".equals(exportType) || "all".equals(exportType) || "summary".equals(exportType))
|
||||
&& vo.getSalesAmountTrend() != null
|
||||
&& vo.getSalesAmountTrend().getDailyDataList() != null
|
||||
&& !vo.getSalesAmountTrend().getDailyDataList().isEmpty()) {
|
||||
&& vo.getDealTrend() != null
|
||||
&& !vo.getDealTrend().isEmpty()) {
|
||||
Sheet trendSheet = workbook.createSheet("销量趋势");
|
||||
createTrendSheetFromVO(trendSheet, dateRangeLabel, vo);
|
||||
}
|
||||
@@ -194,6 +194,7 @@ public class BiShopExportServiceImpl implements BiShopExportService {
|
||||
setCell(row, 18, profitAfterTax.doubleValue(), style);
|
||||
}
|
||||
|
||||
/** 从 dealTrend 写日销售额/单量;date 为 String,需 LocalDate.parse。 */
|
||||
private void createTrendSheetFromVO(Sheet sheet, String dateRangeLabel, ShopOverviewStatisticsVO vo) {
|
||||
CellStyle headerStyle = createHeaderStyle(sheet.getWorkbook());
|
||||
CellStyle dataStyle = createDataStyle(sheet.getWorkbook());
|
||||
@@ -212,23 +213,32 @@ public class BiShopExportServiceImpl implements BiShopExportService {
|
||||
cell.setCellStyle(headerStyle);
|
||||
}
|
||||
|
||||
List<ShopOverviewStatisticsVO.TrendDataItem> dailySales = vo.getSalesAmountTrend().getDailyDataList();
|
||||
List<ShopOverviewStatisticsVO.TrendDataItem> dailyOrders = vo.getOrderCountTrend() != null
|
||||
? vo.getOrderCountTrend().getDailyDataList() : null;
|
||||
List<WorkbenchTrendPointVO> dealTrend = vo.getDealTrend();
|
||||
if (dealTrend == null || dealTrend.isEmpty()) {
|
||||
sheet.setColumnWidth(0, 3200);
|
||||
sheet.setColumnWidth(1, 3200);
|
||||
sheet.setColumnWidth(2, 3200);
|
||||
return;
|
||||
}
|
||||
|
||||
Map<LocalDate, BigDecimal> salesMap = dailySales.stream()
|
||||
.collect(Collectors.toMap(ShopOverviewStatisticsVO.TrendDataItem::getDate,
|
||||
ShopOverviewStatisticsVO.TrendDataItem::getValue, (a, b) -> a));
|
||||
Map<LocalDate, BigDecimal> ordersMap = dailyOrders != null
|
||||
? dailyOrders.stream().collect(Collectors.toMap(
|
||||
ShopOverviewStatisticsVO.TrendDataItem::getDate,
|
||||
ShopOverviewStatisticsVO.TrendDataItem::getValue, (a, b) -> a))
|
||||
: Collections.emptyMap();
|
||||
|
||||
LocalDate startDate = vo.getSalesAmountTrend().getDailyDataList().stream()
|
||||
.map(ShopOverviewStatisticsVO.TrendDataItem::getDate).min(LocalDate::compareTo).orElse(null);
|
||||
LocalDate endDate = vo.getSalesAmountTrend().getDailyDataList().stream()
|
||||
.map(ShopOverviewStatisticsVO.TrendDataItem::getDate).max(LocalDate::compareTo).orElse(null);
|
||||
Map<LocalDate, BigDecimal> salesMap = new HashMap<>();
|
||||
Map<LocalDate, BigDecimal> ordersMap = new HashMap<>();
|
||||
LocalDate startDate = null;
|
||||
LocalDate endDate = null;
|
||||
for (WorkbenchTrendPointVO p : dealTrend) {
|
||||
if (p == null || p.getDate() == null || p.getDate().isBlank()) {
|
||||
continue;
|
||||
}
|
||||
LocalDate d = LocalDate.parse(p.getDate());
|
||||
salesMap.put(d, p.getSalesYuan() != null ? p.getSalesYuan() : BigDecimal.ZERO);
|
||||
ordersMap.put(d, BigDecimal.valueOf(p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0));
|
||||
if (startDate == null || d.isBefore(startDate)) {
|
||||
startDate = d;
|
||||
}
|
||||
if (endDate == null || d.isAfter(endDate)) {
|
||||
endDate = d;
|
||||
}
|
||||
}
|
||||
|
||||
int rowIdx = 2;
|
||||
if (startDate != null && endDate != null) {
|
||||
|
||||
-47
@@ -129,7 +129,6 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
|
||||
fillProductSalesTop10(vo);
|
||||
fillLegacyFlatFields(vo, curT, prevT);
|
||||
fillTargets(vo, companyId, shop.getId(), startDate, endDate, curT.totalSales(), curT.orderCount());
|
||||
fillLegacyTrends(vo, dealTrend);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -195,36 +194,6 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
|
||||
vo.setMonthOverMonthGrowth(BiFinanceKpiAssembler.pctChange(cur.totalSales(), prev.totalSales()));
|
||||
}
|
||||
|
||||
private void fillLegacyTrends(ShopOverviewStatisticsVO vo, List<WorkbenchTrendPointVO> dealTrend) {
|
||||
ShopOverviewStatisticsVO.TrendData sales = new ShopOverviewStatisticsVO.TrendData();
|
||||
ShopOverviewStatisticsVO.TrendData orders = new ShopOverviewStatisticsVO.TrendData();
|
||||
List<ShopOverviewStatisticsVO.TrendDataItem> salesItems = new ArrayList<>();
|
||||
List<ShopOverviewStatisticsVO.TrendDataItem> orderItems = new ArrayList<>();
|
||||
BigDecimal salesTotal = BigDecimal.ZERO;
|
||||
BigDecimal orderTotal = BigDecimal.ZERO;
|
||||
if (dealTrend != null) {
|
||||
for (WorkbenchTrendPointVO p : dealTrend) {
|
||||
ShopOverviewStatisticsVO.TrendDataItem s = new ShopOverviewStatisticsVO.TrendDataItem();
|
||||
s.setDate(LocalDate.parse(p.getDate()));
|
||||
s.setValue(BiFinanceKpiAssembler.nz(p.getSalesYuan()));
|
||||
salesItems.add(s);
|
||||
salesTotal = salesTotal.add(s.getValue());
|
||||
|
||||
ShopOverviewStatisticsVO.TrendDataItem o = new ShopOverviewStatisticsVO.TrendDataItem();
|
||||
o.setDate(s.getDate());
|
||||
o.setValue(BigDecimal.valueOf(p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0));
|
||||
orderItems.add(o);
|
||||
orderTotal = orderTotal.add(o.getValue());
|
||||
}
|
||||
}
|
||||
sales.setDailyDataList(salesItems);
|
||||
sales.setTotal(salesTotal);
|
||||
orders.setDailyDataList(orderItems);
|
||||
orders.setTotal(orderTotal);
|
||||
vo.setSalesAmountTrend(sales);
|
||||
vo.setOrderCountTrend(orders);
|
||||
}
|
||||
|
||||
private List<WorkbenchCostSliceVO> buildProductSalesShare(
|
||||
ShopOverviewStatisticsVO.ProductOverview overview, BigDecimal salesTotal) {
|
||||
if (overview == null || overview.getProducts() == null || overview.getProducts().isEmpty()) {
|
||||
@@ -439,22 +408,6 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/** 税额 = 净销售额 × 税率 */
|
||||
private static BigDecimal salesTaxOnNet(BigDecimal sales, BigDecimal taxRate) {
|
||||
BigDecimal base = nz(sales);
|
||||
if (base.compareTo(BigDecimal.ZERO) < 0) {
|
||||
base = BigDecimal.ZERO;
|
||||
}
|
||||
return base.multiply(taxRate != null ? taxRate : DEFAULT_TAX_RATE).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
private static BigDecimal roi(BigDecimal netSales, BigDecimal promo) {
|
||||
if (promo == null || promo.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return nz(netSales).divide(promo, 2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
private static BigDecimal nz(BigDecimal v) {
|
||||
return v != null ? v : BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
-20
@@ -1,12 +1,10 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.bi.skuoverview.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchKpiItemVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.bi.workbench.model.vo.WorkbenchTrendPointVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -44,22 +42,4 @@ public class SkuOverviewVO {
|
||||
private BigDecimal refundAmount;
|
||||
private BigDecimal averageOrderValue;
|
||||
private BigDecimal totalProfitBeforeTax;
|
||||
|
||||
/** @deprecated 使用 dealTrend */
|
||||
private TrendData salesAmountTrend;
|
||||
/** @deprecated 使用 dealTrend */
|
||||
private TrendData orderCountTrend;
|
||||
|
||||
@Data
|
||||
public static class TrendData {
|
||||
private BigDecimal total;
|
||||
private List<TrendDataItem> dailyDataList;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class TrendDataItem {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate date;
|
||||
private BigDecimal value;
|
||||
}
|
||||
}
|
||||
|
||||
-32
@@ -25,7 +25,6 @@ import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -122,7 +121,6 @@ public class BiSkuOverviewServiceImpl implements BiSkuOverviewService {
|
||||
vo.setYoyCompareDateStart(yoy[0].toString());
|
||||
vo.setYoyCompareDateEnd(yoy[1].toString());
|
||||
fillLegacyFlatFields(vo, curT, prevT);
|
||||
fillLegacyTrends(vo, dealTrend);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -267,36 +265,6 @@ public class BiSkuOverviewServiceImpl implements BiSkuOverviewService {
|
||||
vo.setMonthOverMonthGrowth(BiFinanceKpiAssembler.pctChange(cur.totalSales(), prev.totalSales()));
|
||||
}
|
||||
|
||||
private void fillLegacyTrends(SkuOverviewVO vo, List<WorkbenchTrendPointVO> dealTrend) {
|
||||
SkuOverviewVO.TrendData sales = new SkuOverviewVO.TrendData();
|
||||
SkuOverviewVO.TrendData orders = new SkuOverviewVO.TrendData();
|
||||
List<SkuOverviewVO.TrendDataItem> salesItems = new ArrayList<>();
|
||||
List<SkuOverviewVO.TrendDataItem> orderItems = new ArrayList<>();
|
||||
BigDecimal salesTotal = BigDecimal.ZERO;
|
||||
BigDecimal orderTotal = BigDecimal.ZERO;
|
||||
if (dealTrend != null) {
|
||||
for (WorkbenchTrendPointVO p : dealTrend) {
|
||||
SkuOverviewVO.TrendDataItem s = new SkuOverviewVO.TrendDataItem();
|
||||
s.setDate(LocalDate.parse(p.getDate()));
|
||||
s.setValue(BiFinanceKpiAssembler.nz(p.getSalesYuan()));
|
||||
salesItems.add(s);
|
||||
salesTotal = salesTotal.add(s.getValue());
|
||||
|
||||
SkuOverviewVO.TrendDataItem o = new SkuOverviewVO.TrendDataItem();
|
||||
o.setDate(s.getDate());
|
||||
o.setValue(BigDecimal.valueOf(p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0));
|
||||
orderItems.add(o);
|
||||
orderTotal = orderTotal.add(o.getValue());
|
||||
}
|
||||
}
|
||||
sales.setDailyDataList(salesItems);
|
||||
sales.setTotal(salesTotal);
|
||||
orders.setDailyDataList(orderItems);
|
||||
orders.setTotal(orderTotal);
|
||||
vo.setSalesAmountTrend(sales);
|
||||
vo.setOrderCountTrend(orders);
|
||||
}
|
||||
|
||||
private record PeriodBundle(List<Long> shopIds,
|
||||
BiFinanceKpiAssembler.Totals totals,
|
||||
List<OverviewAggRows.DailyRow> dailyRows) {
|
||||
|
||||
+3
-4
@@ -83,7 +83,6 @@ public class ProductSpecServiceImpl implements ProductSpecService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<ProductSpecVO> replaceSpecs(Long productId, ReplaceProductSpecsDTO dto) {
|
||||
ProductPO product = requireProduct(productId);
|
||||
Long companyId = product.getCompanyId();
|
||||
Long userId = currentUserContext.getCurrentUserId();
|
||||
List<ReplaceProductSpecsDTO.SpecItem> items =
|
||||
dto.getSpecs() == null ? List.of() : dto.getSpecs();
|
||||
@@ -368,7 +367,7 @@ public class ProductSpecServiceImpl implements ProductSpecService {
|
||||
if (valueIds.isEmpty()) {
|
||||
throw new BusinessException("请至少选择一个规格值");
|
||||
}
|
||||
List<ProductSpecValuePO> values = valueMapper.selectBatchIds(valueIds);
|
||||
List<ProductSpecValuePO> values = valueMapper.selectByIds(valueIds);
|
||||
if (values.size() != valueIds.size()) {
|
||||
throw new BusinessException("存在无效的规格值");
|
||||
}
|
||||
@@ -383,7 +382,7 @@ public class ProductSpecServiceImpl implements ProductSpecService {
|
||||
throw new BusinessException("同一规格维只能选择一个规格值");
|
||||
}
|
||||
}
|
||||
Map<Long, ProductSpecPO> specById = specMapper.selectBatchIds(specIds).stream()
|
||||
Map<Long, ProductSpecPO> specById = specMapper.selectByIds(specIds).stream()
|
||||
.collect(Collectors.toMap(ProductSpecPO::getId, s -> s, (a, b) -> a));
|
||||
return new ResolvedSpecValues(values, specById);
|
||||
}
|
||||
@@ -432,7 +431,7 @@ public class ProductSpecServiceImpl implements ProductSpecService {
|
||||
return Map.of();
|
||||
}
|
||||
Set<Long> valueIds = rels.stream().map(ProductSkuSpecValuePO::getSpecValueId).collect(Collectors.toSet());
|
||||
Map<Long, ProductSpecValuePO> valueMap = valueMapper.selectBatchIds(valueIds).stream()
|
||||
Map<Long, ProductSpecValuePO> valueMap = valueMapper.selectByIds(valueIds).stream()
|
||||
.collect(Collectors.toMap(ProductSpecValuePO::getId, v -> v, (a, b) -> a));
|
||||
Map<Long, List<ProductSpecValueVO>> result = new HashMap<>();
|
||||
for (ProductSkuSpecValuePO rel : rels) {
|
||||
|
||||
@@ -16,8 +16,6 @@ export namespace CompanyOverviewVO {
|
||||
totalTaxAmount?: number;
|
||||
shopSalesRatios?: ShopSalesRatio[];
|
||||
shopEfficiencyQuadrants?: ShopEfficiencyQuadrant[];
|
||||
salesAmountTrend?: TrendData;
|
||||
orderCountTrend?: TrendData;
|
||||
shopSummary?: ShopOverview;
|
||||
categorySummary?: CategoryOverview;
|
||||
platformSummary?: PlatformOverview;
|
||||
@@ -29,17 +27,6 @@ export namespace CompanyOverviewVO {
|
||||
salesAmountAchievementRate?: number;
|
||||
}
|
||||
|
||||
export interface TrendData {
|
||||
total?: number;
|
||||
dailyDataList?: TrendDataItem[];
|
||||
}
|
||||
|
||||
export interface TrendDataItem {
|
||||
/** yyyy-MM-dd */
|
||||
date?: string;
|
||||
value?: number;
|
||||
}
|
||||
|
||||
export interface ShopSalesRatio {
|
||||
shopId?: number;
|
||||
shopName?: string;
|
||||
|
||||
@@ -68,18 +68,6 @@ export namespace CategoryOverviewVO {
|
||||
products: ProductSummary[];
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface TrendDataItem {
|
||||
date: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface TrendData {
|
||||
total: number;
|
||||
dailyDataList: TrendDataItem[];
|
||||
}
|
||||
|
||||
export interface Overview {
|
||||
categoryId: number;
|
||||
categoryName: string;
|
||||
@@ -109,10 +97,6 @@ export namespace CategoryOverviewVO {
|
||||
totalProfitBeforeTax?: number;
|
||||
|
||||
productSalesTop10?: ProductSalesRankItem[];
|
||||
/** @deprecated */
|
||||
salesAmountTrend?: TrendData;
|
||||
/** @deprecated */
|
||||
orderCountTrend?: TrendData;
|
||||
productOverview?: ProductOverview;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,18 +96,6 @@ export namespace PlatformOverviewVO {
|
||||
categories: CategorySummary[];
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface TrendDataItem {
|
||||
date: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface TrendData {
|
||||
total: number;
|
||||
dailyDataList: TrendDataItem[];
|
||||
}
|
||||
|
||||
export interface Overview {
|
||||
platformCode: string;
|
||||
platformName: string;
|
||||
@@ -137,10 +125,6 @@ export namespace PlatformOverviewVO {
|
||||
totalProfitBeforeTax?: number;
|
||||
|
||||
productSalesTop10?: ProductSalesRankItem[];
|
||||
/** @deprecated */
|
||||
salesAmountTrend?: TrendData;
|
||||
/** @deprecated */
|
||||
orderCountTrend?: TrendData;
|
||||
productOverview?: ProductOverview;
|
||||
categoryOverview?: CategoryOverview;
|
||||
}
|
||||
|
||||
@@ -30,18 +30,6 @@ export namespace ProductOverviewVO {
|
||||
pct?: number;
|
||||
}
|
||||
|
||||
/** @deprecated 旧趋势结构,优先用 dealTrend */
|
||||
export interface TrendDataItem {
|
||||
date: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface TrendData {
|
||||
total: number;
|
||||
dailyDataList: TrendDataItem[];
|
||||
}
|
||||
|
||||
export interface SkuSalesRankItem {
|
||||
skuId?: number;
|
||||
skuName?: string;
|
||||
@@ -118,10 +106,6 @@ export namespace ProductOverviewVO {
|
||||
totalROI?: number;
|
||||
|
||||
specSalesTop10?: SkuSalesRankItem[];
|
||||
/** @deprecated */
|
||||
salesAmountTrend?: TrendData;
|
||||
/** @deprecated */
|
||||
orderCountTrend?: TrendData;
|
||||
specSummaries?: SkuSummary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,10 +201,6 @@ export namespace ShopVO {
|
||||
totalProfitBeforeTax?: number;
|
||||
/** 各商品按单量排序的销量 Top10 */
|
||||
productSalesTop10?: ProductSalesRankItem[];
|
||||
/** @deprecated 使用 dealTrend */
|
||||
salesAmountTrend?: TrendData;
|
||||
/** @deprecated 使用 dealTrend */
|
||||
orderCountTrend?: TrendData;
|
||||
/** 多商品数据横向汇总(含合计行) */
|
||||
productOverview?: ProductOverview;
|
||||
/** 品类多维度数据汇总(含合计行) */
|
||||
@@ -310,22 +306,6 @@ export namespace ShopVO {
|
||||
roi?: number;
|
||||
}
|
||||
|
||||
/** 趋势数据 */
|
||||
export interface TrendData {
|
||||
/** 时间范围的总值 */
|
||||
total: number;
|
||||
/** 每日数据列表 */
|
||||
dailyDataList: TrendDataItem[];
|
||||
}
|
||||
|
||||
/** 趋势数据项 */
|
||||
export interface TrendDataItem {
|
||||
/** 日期 */
|
||||
date: string;
|
||||
/** 对应的值 */
|
||||
value: number;
|
||||
}
|
||||
|
||||
/** 商品概览(含合计行和商品列表) */
|
||||
export interface ProductOverview {
|
||||
/** 合计行 */
|
||||
|
||||
@@ -24,18 +24,6 @@ export namespace SkuOverviewVO {
|
||||
refundYuan?: number;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface TrendDataItem {
|
||||
date: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface TrendData {
|
||||
total: number;
|
||||
dailyDataList: TrendDataItem[];
|
||||
}
|
||||
|
||||
export interface Overview {
|
||||
skuId: number;
|
||||
skuName?: string;
|
||||
@@ -61,10 +49,5 @@ export namespace SkuOverviewVO {
|
||||
refundAmount?: number;
|
||||
averageOrderValue?: number;
|
||||
totalProfitBeforeTax?: number;
|
||||
|
||||
/** @deprecated */
|
||||
salesAmountTrend?: TrendData;
|
||||
/** @deprecated */
|
||||
orderCountTrend?: TrendData;
|
||||
}
|
||||
}
|
||||
|
||||
+705
-248
File diff suppressed because it is too large
Load Diff
-176
@@ -1,176 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
|
||||
interface Props {
|
||||
data: {
|
||||
salesAmountTrend?: {
|
||||
dailyDataList: { date: string; value: number }[];
|
||||
};
|
||||
orderCountTrend?: {
|
||||
dailyDataList: { date: string; value: number }[];
|
||||
};
|
||||
} | null;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const trendChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderTrendChart } = useEcharts(trendChartRef);
|
||||
|
||||
const renderChart = () => {
|
||||
if (!trendChartRef.value || !props.data) return;
|
||||
|
||||
const salesTrend = props.data.salesAmountTrend;
|
||||
const orderTrend = props.data.orderCountTrend;
|
||||
|
||||
if (!salesTrend || !orderTrend) return;
|
||||
|
||||
const dates = salesTrend.dailyDataList.map((item) =>
|
||||
dayjs(item.date).format('MM-DD'),
|
||||
);
|
||||
const salesData = salesTrend.dailyDataList.map((item) => item.value);
|
||||
const orderData = orderTrend.dailyDataList.map((item) => item.value);
|
||||
|
||||
const isDark = document.documentElement.classList.contains('dark');
|
||||
renderTrendChart({
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '3%',
|
||||
bottom: '3%',
|
||||
top: '5%',
|
||||
containLabel: true,
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
|
||||
textStyle: {
|
||||
color: isDark ? 'hsl(0deg 0% 95%)' : '#000',
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: dates,
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: isDark ? 'hsl(240deg 3.7% 22%)' : '#e2e8f0',
|
||||
},
|
||||
},
|
||||
},
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
name: '销售额',
|
||||
nameTextStyle: {
|
||||
color: isDark ? 'hsl(240deg 5% 64.9%)' : undefined,
|
||||
},
|
||||
axisLabel: {
|
||||
color: isDark ? 'hsl(240deg 5% 64.9%)' : undefined,
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
color: isDark ? 'hsl(240deg 3.7% 22%)' : undefined,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'value',
|
||||
name: '单量',
|
||||
position: 'right',
|
||||
nameTextStyle: {
|
||||
color: isDark ? 'hsl(240deg 5% 64.9%)' : undefined,
|
||||
},
|
||||
axisLabel: {
|
||||
color: isDark ? 'hsl(240deg 5% 64.9%)' : undefined,
|
||||
},
|
||||
splitLine: { show: false },
|
||||
},
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: '销售额',
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
lineStyle: { width: 3, color: '#3b82f6' },
|
||||
areaStyle: {
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{ offset: 0, color: 'rgba(59, 130, 246, 0.4)' },
|
||||
{ offset: 1, color: 'rgba(59, 130, 246, 0)' },
|
||||
],
|
||||
},
|
||||
},
|
||||
data: salesData,
|
||||
},
|
||||
{
|
||||
name: '日单量',
|
||||
type: 'line',
|
||||
yAxisIndex: 1,
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
lineStyle: { width: 3, color: '#10b981' },
|
||||
areaStyle: {
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{ offset: 0, color: 'rgba(16, 185, 129, 0.2)' },
|
||||
{ offset: 1, color: 'rgba(16, 185, 129, 0)' },
|
||||
],
|
||||
},
|
||||
},
|
||||
data: orderData,
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.data,
|
||||
() => {
|
||||
if (props.data) {
|
||||
setTimeout(() => renderChart(), 100);
|
||||
}
|
||||
},
|
||||
{ deep: true, immediate: true },
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
const darkObserver = new MutationObserver(() => {
|
||||
if (props.data) renderChart();
|
||||
});
|
||||
darkObserver.observe(document.documentElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ['class'],
|
||||
});
|
||||
onUnmounted(() => darkObserver.disconnect());
|
||||
});
|
||||
|
||||
defineExpose({ renderChart });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="rounded-[20px] border border-slate-200/80 dark:border-[hsl(240deg_3.7%_22%)] bg-white/85 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-8 shadow-[0_4px_20px_rgba(0,0,0,0.02)] dark:shadow-none backdrop-blur-[12px] xl:col-span-2">
|
||||
<h3 class="mb-6 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
销售额与单量趋势分析
|
||||
</h3>
|
||||
<div class="h-[380px] w-full">
|
||||
<EchartsUI ref="trendChartRef" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user