feat: 店铺概览导出支持自定义税率,商品明细表增加商品成本/运费/其他成本列

exportShopOverview: 将 taxRate 传入 queryDTO 并传给 ShopOverviewStatisticsService
createProductDetailSheetFromVO: 表头拆为商品成本/运费/其他成本三列,税额表头动态化
前端导出请求加 taxRate 参数
This commit is contained in:
小蟑螂
2026-04-15 22:59:03 +08:00
parent 0caa8e8e95
commit 65626e5072
2 changed files with 20 additions and 13 deletions
@@ -169,6 +169,8 @@ public class ExportServiceImpl implements ExportService {
ShopOverviewQueryDTO queryDTO = new ShopOverviewQueryDTO();
queryDTO.setShopId(dto.getShopId());
queryDTO.setDateRange(dto.getDateRange());
BigDecimal taxRate = dto.getTaxRate() != null ? dto.getTaxRate() : DEFAULT_TAX_RATE;
queryDTO.setTaxRate(taxRate);
ShopOverviewStatisticsVO vo = shopOverviewStatisticsService.getShopOverviewStatistics(queryDTO);
@@ -186,7 +188,7 @@ public class ExportServiceImpl implements ExportService {
if (("product".equals(exportType) || "all".equals(exportType))
&& vo.getProductComparisons() != null && !vo.getProductComparisons().isEmpty()) {
Sheet productSheet = workbook.createSheet("商品明细");
createProductDetailSheetFromVO(productSheet, dateRangeLabel, vo.getProductComparisons());
createProductDetailSheetFromVO(productSheet, dateRangeLabel, vo.getProductComparisons(), taxRate);
}
if (("trend".equals(exportType) || "all".equals(exportType))
@@ -655,7 +657,8 @@ public class ExportServiceImpl implements ExportService {
* 列顺序与页面「核心商品多维度损益对比表」完全一致
*/
private void createProductDetailSheetFromVO(Sheet sheet, String dateRangeLabel,
List<ShopOverviewStatisticsVO.ProductComparison> products) {
List<ShopOverviewStatisticsVO.ProductComparison> products,
BigDecimal taxRate) {
Row titleRow = sheet.createRow(0);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellValue("核心商品多维度损益对比表 | " + dateRangeLabel);
@@ -666,10 +669,11 @@ public class ExportServiceImpl implements ExportService {
CellStyle dataStyle = createDataStyle(sheet.getWorkbook());
// 表头与页面顺序完全一致(分三组:规模/成本/损益)
String taxLabel = (taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP)).toPlainString() + "%税额";
String[] headers = {
"商品详情", "销售额", "单量", "客单价",
"成本运费", "退款金额", "推广费", "刷单费用",
"费比(%)", "单品ROI", "税前盈亏", "4%税额", "税后净利"
"商品成本", "运费", "其他成本", "退款金额", "推广费", "刷单费用",
"费比(%)", "单品ROI", "税前盈亏", taxLabel, "税后净利"
};
Row headerRow = sheet.createRow(1);
@@ -687,15 +691,17 @@ public class ExportServiceImpl implements ExportService {
setCell(row, 1, nvl(p.getSalesAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 2, (double) nvl(p.getOrderCount(), 0), dataStyle);
setCell(row, 3, nvl(p.getAverageOrderValue(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 4, nvl(p.getShippingCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 5, nvl(p.getRefundAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 6, nvl(p.getTotalPromotionFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 7, nvl(p.getBrushFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 8, nvl(p.getFeeRatio(), BigDecimal.ZERO).setScale(4, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 9, nvl(p.getRoi(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 10, nvl(p.getTotalProfitBeforeTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 11, nvl(p.getSalesTaxAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 12, nvl(p.getProfitAfterTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 4, nvl(p.getProductCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 5, nvl(p.getShippingCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 6, nvl(p.getOtherCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 7, nvl(p.getRefundAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 8, nvl(p.getTotalPromotionFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 9, nvl(p.getBrushFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 10, nvl(p.getFeeRatio(), BigDecimal.ZERO).setScale(4, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 11, nvl(p.getRoi(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 12, nvl(p.getTotalProfitBeforeTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 13, nvl(p.getSalesTaxAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
setCell(row, 14, nvl(p.getProfitAfterTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle);
}
sheet.setColumnWidth(0, 5000);
@@ -284,6 +284,7 @@ const handleExportShopOverview = async () => {
startDate.format('YYYY-MM-DD'),
endDate.format('YYYY-MM-DD'),
],
taxRate: taxRate.value,
},
filename,
);