mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 03:49:19 +08:00
refactor: 经营概览汇总表统一成交/净销售六列规模字段并同步前后端导出与对比
This commit is contained in:
+30
-6
@@ -226,9 +226,17 @@ public class CompanyOverviewVO {
|
||||
|
||||
private BigDecimal dealAmount;
|
||||
|
||||
private Integer orderCount;
|
||||
/** 净销售单量 = 成交单量 − 退款单量 */
|
||||
private Integer salesOrderCount;
|
||||
|
||||
private BigDecimal averageOrderValue;
|
||||
/** 成交单量 */
|
||||
private Integer dealOrderCount;
|
||||
|
||||
/** 净销售客单价 = 净销售额 / 净销售单量 */
|
||||
private BigDecimal salesAverageOrderValue;
|
||||
|
||||
/** 成交客单价 = 成交金额 / 成交单量 */
|
||||
private BigDecimal dealAverageOrderValue;
|
||||
|
||||
private BigDecimal productCost;
|
||||
|
||||
@@ -270,9 +278,17 @@ public class CompanyOverviewVO {
|
||||
|
||||
private BigDecimal dealAmount;
|
||||
|
||||
private Integer orderCount;
|
||||
/** 净销售单量 = 成交单量 − 退款单量 */
|
||||
private Integer salesOrderCount;
|
||||
|
||||
private BigDecimal averageOrderValue;
|
||||
/** 成交单量 */
|
||||
private Integer dealOrderCount;
|
||||
|
||||
/** 净销售客单价 = 净销售额 / 净销售单量 */
|
||||
private BigDecimal salesAverageOrderValue;
|
||||
|
||||
/** 成交客单价 = 成交金额 / 成交单量 */
|
||||
private BigDecimal dealAverageOrderValue;
|
||||
|
||||
private BigDecimal productCost;
|
||||
|
||||
@@ -322,9 +338,17 @@ public class CompanyOverviewVO {
|
||||
|
||||
private BigDecimal dealAmount;
|
||||
|
||||
private Integer orderCount;
|
||||
/** 净销售单量 = 成交单量 − 退款单量 */
|
||||
private Integer salesOrderCount;
|
||||
|
||||
private BigDecimal averageOrderValue;
|
||||
/** 成交单量 */
|
||||
private Integer dealOrderCount;
|
||||
|
||||
/** 净销售客单价 = 净销售额 / 净销售单量 */
|
||||
private BigDecimal salesAverageOrderValue;
|
||||
|
||||
/** 成交客单价 = 成交金额 / 成交单量 */
|
||||
private BigDecimal dealAverageOrderValue;
|
||||
|
||||
private BigDecimal productCost;
|
||||
|
||||
|
||||
+44
-26
@@ -232,8 +232,11 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
s.setCategoryId(c.getCategoryId() != null ? c.getCategoryId() : 0L);
|
||||
s.setCategoryName(c.getCategoryName());
|
||||
s.setSalesAmount(c.getSalesAmount());
|
||||
s.setOrderCount(c.getOrderCount());
|
||||
s.setAverageOrderValue(c.getAverageOrderValue());
|
||||
s.setDealAmount(c.getDealAmount());
|
||||
s.setSalesOrderCount(c.getSalesOrderCount());
|
||||
s.setDealOrderCount(c.getDealOrderCount());
|
||||
s.setSalesAverageOrderValue(c.getSalesAverageOrderValue());
|
||||
s.setDealAverageOrderValue(c.getDealAverageOrderValue());
|
||||
s.setProductCost(c.getProductCost());
|
||||
s.setShippingCost(c.getShippingCost());
|
||||
s.setOtherCost(c.getOtherCost());
|
||||
@@ -253,7 +256,9 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
private ShopOverviewStatisticsVO.CategorySummary aggregateCategoryTotals(
|
||||
List<ShopOverviewStatisticsVO.CategorySummary> categories, BigDecimal taxRate) {
|
||||
BigDecimal totalSales = BigDecimal.ZERO;
|
||||
int totalOrders = 0;
|
||||
BigDecimal totalDealAmount = BigDecimal.ZERO;
|
||||
int totalSalesOrders = 0;
|
||||
int totalDealOrders = 0;
|
||||
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||
BigDecimal totalShippingCost = BigDecimal.ZERO;
|
||||
BigDecimal totalOtherCost = BigDecimal.ZERO;
|
||||
@@ -263,7 +268,9 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
|
||||
for (ShopOverviewStatisticsVO.CategorySummary c : categories) {
|
||||
totalSales = totalSales.add(c.getSalesAmount() != null ? c.getSalesAmount() : BigDecimal.ZERO);
|
||||
totalOrders += c.getOrderCount() != null ? c.getOrderCount() : 0;
|
||||
totalDealAmount = totalDealAmount.add(c.getDealAmount() != null ? c.getDealAmount() : BigDecimal.ZERO);
|
||||
totalSalesOrders += c.getSalesOrderCount() != null ? c.getSalesOrderCount() : 0;
|
||||
totalDealOrders += c.getDealOrderCount() != null ? c.getDealOrderCount() : 0;
|
||||
totalProductCost = totalProductCost.add(c.getProductCost() != null ? c.getProductCost() : BigDecimal.ZERO);
|
||||
totalShippingCost = totalShippingCost.add(c.getShippingCost() != null ? c.getShippingCost() : BigDecimal.ZERO);
|
||||
totalOtherCost = totalOtherCost.add(c.getOtherCost() != null ? c.getOtherCost() : BigDecimal.ZERO);
|
||||
@@ -272,8 +279,11 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
totalBrushFee = totalBrushFee.add(c.getBrushFee() != null ? c.getBrushFee() : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
BigDecimal avgOrderValue = totalOrders > 0
|
||||
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
|
||||
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
|
||||
? totalSales.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal dealAvgOrderValue = totalDealOrders > 0
|
||||
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
|
||||
BigDecimal profitBeforeTax = totalSales.subtract(totalCost)
|
||||
@@ -291,8 +301,11 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
total.setCategoryId(0L);
|
||||
total.setCategoryName("合计");
|
||||
total.setSalesAmount(totalSales);
|
||||
total.setOrderCount(totalOrders);
|
||||
total.setAverageOrderValue(avgOrderValue);
|
||||
total.setDealAmount(totalDealAmount);
|
||||
total.setSalesOrderCount(totalSalesOrders);
|
||||
total.setDealOrderCount(totalDealOrders);
|
||||
total.setSalesAverageOrderValue(salesAvgOrderValue);
|
||||
total.setDealAverageOrderValue(dealAvgOrderValue);
|
||||
total.setProductCost(totalProductCost);
|
||||
total.setShippingCost(totalShippingCost);
|
||||
total.setOtherCost(totalOtherCost);
|
||||
@@ -328,7 +341,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
String taxHeader = taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP).toPlainString()
|
||||
+ "%税额";
|
||||
String[] headers = {
|
||||
dimensionColumnHeader, "净销售额", "单量", "客单价",
|
||||
dimensionColumnHeader, "成交金额", "净销售额", "成交单量", "净销售单量", "成交客单价", "净销售客单价",
|
||||
"商品成本", "运费", "其他成本", "订单成本", "退款金额", taxHeader, "推广费", "刷单费",
|
||||
"税前盈亏", "费比 %", "ROI", "税后盈亏"
|
||||
};
|
||||
@@ -363,27 +376,32 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
|
||||
private void fillCategoryDataRow(
|
||||
Row row, ShopOverviewStatisticsVO.CategorySummary d, CellStyle style, BigDecimal taxRate) {
|
||||
setCell(row, 0, d.getCategoryName() != null ? d.getCategoryName() : "", style);
|
||||
setCell(row, 1, bd2Money(d.getSalesAmount()), style);
|
||||
Cell oc = row.createCell(2);
|
||||
oc.setCellStyle(style);
|
||||
oc.setCellValue(d.getOrderCount() != null ? d.getOrderCount() : 0);
|
||||
setCell(row, 3, bd2Money(d.getAverageOrderValue()), style);
|
||||
setCell(row, 4, bd2Money(d.getProductCost()), style);
|
||||
setCell(row, 5, bd2Money(d.getShippingCost()), style);
|
||||
setCell(row, 6, bd2Money(d.getOtherCost()), style);
|
||||
setCell(row, 7, bd2Money(d.getOrderCost()), style);
|
||||
setCell(row, 1, bd2Money(d.getDealAmount()), style);
|
||||
setCell(row, 2, bd2Money(d.getSalesAmount()), style);
|
||||
Cell dealOc = row.createCell(3);
|
||||
dealOc.setCellStyle(style);
|
||||
dealOc.setCellValue(d.getDealOrderCount() != null ? d.getDealOrderCount() : 0);
|
||||
Cell salesOc = row.createCell(4);
|
||||
salesOc.setCellStyle(style);
|
||||
salesOc.setCellValue(d.getSalesOrderCount() != null ? d.getSalesOrderCount() : 0);
|
||||
setCell(row, 5, bd2Money(d.getDealAverageOrderValue()), style);
|
||||
setCell(row, 6, bd2Money(d.getSalesAverageOrderValue()), style);
|
||||
setCell(row, 7, bd2Money(d.getProductCost()), style);
|
||||
setCell(row, 8, bd2Money(d.getShippingCost()), style);
|
||||
setCell(row, 9, bd2Money(d.getOtherCost()), style);
|
||||
setCell(row, 10, bd2Money(d.getOrderCost()), style);
|
||||
BigDecimal salesTax = salesTaxOnNetForCategoryExport(d.getSalesAmount(), taxRate);
|
||||
BigDecimal profitAfterTax = (d.getTotalProfitBeforeTax() != null ? d.getTotalProfitBeforeTax() : BigDecimal.ZERO)
|
||||
.subtract(salesTax)
|
||||
.setScale(2, RoundingMode.HALF_UP);
|
||||
setCell(row, 8, bd2Money(d.getRefundAmount()), style);
|
||||
setCell(row, 9, bd2Money(salesTax), style);
|
||||
setCell(row, 10, bd2Money(d.getTotalPromotionFee()), style);
|
||||
setCell(row, 11, bd2Money(d.getBrushFee()), style);
|
||||
setCell(row, 12, bd2Money(d.getTotalProfitBeforeTax()), style);
|
||||
setCell(row, 13, bd2FeeRatioPercent(d.getFeeRatio()), style);
|
||||
setCell(row, 14, bd2Roi(d.getRoi()), style);
|
||||
setCell(row, 15, bd2Money(profitAfterTax), style);
|
||||
setCell(row, 11, bd2Money(d.getRefundAmount()), style);
|
||||
setCell(row, 12, bd2Money(salesTax), style);
|
||||
setCell(row, 13, bd2Money(d.getTotalPromotionFee()), style);
|
||||
setCell(row, 14, bd2Money(d.getBrushFee()), style);
|
||||
setCell(row, 15, bd2Money(d.getTotalProfitBeforeTax()), style);
|
||||
setCell(row, 16, bd2FeeRatioPercent(d.getFeeRatio()), style);
|
||||
setCell(row, 17, bd2Roi(d.getRoi()), style);
|
||||
setCell(row, 18, bd2Money(profitAfterTax), style);
|
||||
}
|
||||
|
||||
private static double bd2Money(BigDecimal v) {
|
||||
|
||||
+63
-33
@@ -67,7 +67,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
/** 计算店铺汇总的合计行 */
|
||||
private CompanyOverviewVO.ShopSummary computeShopTotal(List<CompanyOverviewVO.ShopSummary> shops) {
|
||||
BigDecimal totalSales = BigDecimal.ZERO;
|
||||
int totalOrders = 0;
|
||||
int totalSalesOrders = 0;
|
||||
int totalDealOrders = 0;
|
||||
BigDecimal totalTargetAmount = BigDecimal.ZERO;
|
||||
int totalTargetOrders = 0;
|
||||
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||
@@ -83,7 +84,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
totalSales = totalSales.add(s.getSalesAmount() != null ? s.getSalesAmount() : BigDecimal.ZERO);
|
||||
totalDealAmount = totalDealAmount.add(s.getDealAmount() != null ? s.getDealAmount() : BigDecimal.ZERO);
|
||||
totalGrossProfit = totalGrossProfit.add(s.getGrossProfit() != null ? s.getGrossProfit() : BigDecimal.ZERO);
|
||||
totalOrders += s.getOrderCount() != null ? s.getOrderCount() : 0;
|
||||
totalSalesOrders += s.getSalesOrderCount() != null ? s.getSalesOrderCount() : 0;
|
||||
totalDealOrders += s.getDealOrderCount() != null ? s.getDealOrderCount() : 0;
|
||||
totalTargetAmount = totalTargetAmount.add(s.getTargetAmount() != null ? s.getTargetAmount() : BigDecimal.ZERO);
|
||||
totalTargetOrders += s.getTargetOrderCount() != null ? s.getTargetOrderCount() : 0;
|
||||
totalProductCost = totalProductCost.add(s.getProductCost() != null ? s.getProductCost() : BigDecimal.ZERO);
|
||||
@@ -94,8 +96,11 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
totalBrushFee = totalBrushFee.add(s.getBrushFee() != null ? s.getBrushFee() : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
BigDecimal avgOrderValue = totalOrders > 0
|
||||
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
|
||||
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
|
||||
? totalSales.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal dealAvgOrderValue = totalDealOrders > 0
|
||||
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
|
||||
BigDecimal profitBeforeTax = totalSales.subtract(totalCost)
|
||||
@@ -112,9 +117,9 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
? totalSales.divide(totalTargetAmount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))
|
||||
: totalSales.compareTo(BigDecimal.ZERO) > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
BigDecimal orderAchievementRate = totalTargetOrders > 0
|
||||
? new BigDecimal(totalOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
|
||||
? new BigDecimal(totalSalesOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal("100"))
|
||||
: totalOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
: totalSalesOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
|
||||
CompanyOverviewVO.ShopSummary total = new CompanyOverviewVO.ShopSummary();
|
||||
total.setShopId(0L);
|
||||
@@ -122,8 +127,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
total.setSalesAmount(totalSales);
|
||||
total.setDealAmount(totalDealAmount);
|
||||
total.setGrossProfit(totalGrossProfit.setScale(2, RoundingMode.HALF_UP));
|
||||
total.setOrderCount(totalOrders);
|
||||
total.setAverageOrderValue(avgOrderValue);
|
||||
total.setSalesOrderCount(totalSalesOrders);
|
||||
total.setDealOrderCount(totalDealOrders);
|
||||
total.setSalesAverageOrderValue(salesAvgOrderValue);
|
||||
total.setDealAverageOrderValue(dealAvgOrderValue);
|
||||
total.setTargetAmount(totalTargetAmount);
|
||||
total.setTargetOrderCount(totalTargetOrders);
|
||||
total.setSalesAmountAchievementRate(salesAchievementRate);
|
||||
@@ -146,7 +153,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
/** 计算品类汇总的合计行 */
|
||||
private CompanyOverviewVO.CategorySummary computeCategoryTotal(List<CompanyOverviewVO.CategorySummary> categories) {
|
||||
BigDecimal totalSales = BigDecimal.ZERO;
|
||||
int totalOrders = 0;
|
||||
int totalSalesOrders = 0;
|
||||
int totalDealOrders = 0;
|
||||
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||
BigDecimal totalShippingCost = BigDecimal.ZERO;
|
||||
BigDecimal totalOtherCost = BigDecimal.ZERO;
|
||||
@@ -160,7 +168,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
totalSales = totalSales.add(c.getSalesAmount() != null ? c.getSalesAmount() : BigDecimal.ZERO);
|
||||
totalDealAmount = totalDealAmount.add(c.getDealAmount() != null ? c.getDealAmount() : BigDecimal.ZERO);
|
||||
totalGrossProfit = totalGrossProfit.add(c.getGrossProfit() != null ? c.getGrossProfit() : BigDecimal.ZERO);
|
||||
totalOrders += c.getOrderCount() != null ? c.getOrderCount() : 0;
|
||||
totalSalesOrders += c.getSalesOrderCount() != null ? c.getSalesOrderCount() : 0;
|
||||
totalDealOrders += c.getDealOrderCount() != null ? c.getDealOrderCount() : 0;
|
||||
totalProductCost = totalProductCost.add(c.getProductCost() != null ? c.getProductCost() : BigDecimal.ZERO);
|
||||
totalShippingCost = totalShippingCost.add(c.getShippingCost() != null ? c.getShippingCost() : BigDecimal.ZERO);
|
||||
totalOtherCost = totalOtherCost.add(c.getOtherCost() != null ? c.getOtherCost() : BigDecimal.ZERO);
|
||||
@@ -169,8 +178,11 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
totalBrushFee = totalBrushFee.add(c.getBrushFee() != null ? c.getBrushFee() : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
BigDecimal avgOrderValue = totalOrders > 0
|
||||
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
|
||||
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
|
||||
? totalSales.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal dealAvgOrderValue = totalDealOrders > 0
|
||||
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
|
||||
BigDecimal profitBeforeTax = totalSales.subtract(totalCost)
|
||||
@@ -190,8 +202,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
total.setSalesAmount(totalSales);
|
||||
total.setDealAmount(totalDealAmount);
|
||||
total.setGrossProfit(totalGrossProfit.setScale(2, RoundingMode.HALF_UP));
|
||||
total.setOrderCount(totalOrders);
|
||||
total.setAverageOrderValue(avgOrderValue);
|
||||
total.setSalesOrderCount(totalSalesOrders);
|
||||
total.setDealOrderCount(totalDealOrders);
|
||||
total.setSalesAverageOrderValue(salesAvgOrderValue);
|
||||
total.setDealAverageOrderValue(dealAvgOrderValue);
|
||||
total.setProductCost(totalProductCost);
|
||||
total.setShippingCost(totalShippingCost);
|
||||
total.setOtherCost(totalOtherCost);
|
||||
@@ -210,7 +224,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
/** 计算平台汇总的合计行 */
|
||||
private CompanyOverviewVO.PlatformSummary computePlatformTotal(List<CompanyOverviewVO.PlatformSummary> platforms) {
|
||||
BigDecimal totalSalesAmount = BigDecimal.ZERO;
|
||||
int totalOrderCount = 0;
|
||||
int totalSalesOrders = 0;
|
||||
int totalDealOrders = 0;
|
||||
BigDecimal totalTargetAmount = BigDecimal.ZERO;
|
||||
int totalTargetOrderCount = 0;
|
||||
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||
@@ -226,7 +241,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
totalSalesAmount = totalSalesAmount.add(p.getSalesAmount() != null ? p.getSalesAmount() : BigDecimal.ZERO);
|
||||
totalDealAmount = totalDealAmount.add(p.getDealAmount() != null ? p.getDealAmount() : BigDecimal.ZERO);
|
||||
totalGrossProfit = totalGrossProfit.add(p.getGrossProfit() != null ? p.getGrossProfit() : BigDecimal.ZERO);
|
||||
totalOrderCount += p.getOrderCount() != null ? p.getOrderCount() : 0;
|
||||
totalSalesOrders += p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0;
|
||||
totalDealOrders += p.getDealOrderCount() != null ? p.getDealOrderCount() : 0;
|
||||
totalTargetAmount = totalTargetAmount.add(p.getTargetAmount() != null ? p.getTargetAmount() : BigDecimal.ZERO);
|
||||
totalTargetOrderCount += p.getTargetOrderCount() != null ? p.getTargetOrderCount() : 0;
|
||||
totalProductCost = totalProductCost.add(p.getProductCost() != null ? p.getProductCost() : BigDecimal.ZERO);
|
||||
@@ -237,8 +253,11 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
totalBrushFee = totalBrushFee.add(p.getBrushFee() != null ? p.getBrushFee() : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
BigDecimal avgOrderValue = totalOrderCount > 0
|
||||
? totalSalesAmount.divide(new BigDecimal(totalOrderCount), 2, RoundingMode.HALF_UP)
|
||||
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
|
||||
? totalSalesAmount.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal dealAvgOrderValue = totalDealOrders > 0
|
||||
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
|
||||
BigDecimal profitBeforeTax = totalSalesAmount.subtract(totalCost)
|
||||
@@ -255,9 +274,9 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
? totalSalesAmount.divide(totalTargetAmount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))
|
||||
: totalSalesAmount.compareTo(BigDecimal.ZERO) > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
BigDecimal orderAchievementRate = totalTargetOrderCount > 0
|
||||
? new BigDecimal(totalOrderCount).divide(new BigDecimal(totalTargetOrderCount), 4, RoundingMode.HALF_UP)
|
||||
? new BigDecimal(totalSalesOrders).divide(new BigDecimal(totalTargetOrderCount), 4, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal("100"))
|
||||
: totalOrderCount > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
: totalSalesOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
|
||||
CompanyOverviewVO.PlatformSummary total = new CompanyOverviewVO.PlatformSummary();
|
||||
total.setPlatformCode(null);
|
||||
@@ -265,8 +284,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
total.setSalesAmount(totalSalesAmount);
|
||||
total.setDealAmount(totalDealAmount);
|
||||
total.setGrossProfit(totalGrossProfit.setScale(2, RoundingMode.HALF_UP));
|
||||
total.setOrderCount(totalOrderCount);
|
||||
total.setAverageOrderValue(avgOrderValue);
|
||||
total.setSalesOrderCount(totalSalesOrders);
|
||||
total.setDealOrderCount(totalDealOrders);
|
||||
total.setSalesAverageOrderValue(salesAvgOrderValue);
|
||||
total.setDealAverageOrderValue(dealAvgOrderValue);
|
||||
total.setTargetAmount(totalTargetAmount);
|
||||
total.setTargetOrderCount(totalTargetOrderCount);
|
||||
total.setSalesAmountAchievementRate(salesAchievementRate);
|
||||
@@ -524,8 +545,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
BigDecimal brush, BigDecimal targetAmt, int targetOrders) {
|
||||
s.setSalesAmount(m.sales);
|
||||
s.setDealAmount(m.dealAmount);
|
||||
s.setOrderCount(m.orderCount);
|
||||
s.setAverageOrderValue(aov(m.sales, m.orderCount));
|
||||
s.setSalesOrderCount(m.salesOrderCount);
|
||||
s.setDealOrderCount(m.dealOrderCount);
|
||||
s.setSalesAverageOrderValue(aov(m.sales, m.salesOrderCount));
|
||||
s.setDealAverageOrderValue(aov(m.dealAmount, m.dealOrderCount));
|
||||
s.setProductCost(m.productCost);
|
||||
s.setShippingCost(m.freightCost);
|
||||
s.setOtherCost(m.otherCost);
|
||||
@@ -543,7 +566,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
s.setTargetAmount(targetAmt);
|
||||
s.setTargetOrderCount(targetOrders);
|
||||
s.setSalesAmountAchievementRate(achievementRate(m.sales, targetAmt));
|
||||
s.setOrderCountAchievementRate(achievementRate(BigDecimal.valueOf(m.orderCount), BigDecimal.valueOf(targetOrders)));
|
||||
s.setOrderCountAchievementRate(achievementRate(BigDecimal.valueOf(m.salesOrderCount), BigDecimal.valueOf(targetOrders)));
|
||||
}
|
||||
|
||||
/** 品类/商品/平台汇总行:填充成交金额、毛利与净利字段 */
|
||||
@@ -551,8 +574,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
BigDecimal promo, BigDecimal brush) {
|
||||
s.setSalesAmount(m.sales);
|
||||
s.setDealAmount(m.dealAmount);
|
||||
s.setOrderCount(m.orderCount);
|
||||
s.setAverageOrderValue(aov(m.sales, m.orderCount));
|
||||
s.setSalesOrderCount(m.salesOrderCount);
|
||||
s.setDealOrderCount(m.dealOrderCount);
|
||||
s.setSalesAverageOrderValue(aov(m.sales, m.salesOrderCount));
|
||||
s.setDealAverageOrderValue(aov(m.dealAmount, m.dealOrderCount));
|
||||
s.setProductCost(m.productCost);
|
||||
s.setShippingCost(m.freightCost);
|
||||
s.setOtherCost(m.otherCost);
|
||||
@@ -574,8 +599,10 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
BigDecimal targetAmt, int targetOrders) {
|
||||
s.setSalesAmount(m.sales);
|
||||
s.setDealAmount(m.dealAmount);
|
||||
s.setOrderCount(m.orderCount);
|
||||
s.setAverageOrderValue(aov(m.sales, m.orderCount));
|
||||
s.setSalesOrderCount(m.salesOrderCount);
|
||||
s.setDealOrderCount(m.dealOrderCount);
|
||||
s.setSalesAverageOrderValue(aov(m.sales, m.salesOrderCount));
|
||||
s.setDealAverageOrderValue(aov(m.dealAmount, m.dealOrderCount));
|
||||
s.setProductCost(m.productCost);
|
||||
s.setShippingCost(m.freightCost);
|
||||
s.setOtherCost(m.otherCost);
|
||||
@@ -593,7 +620,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
s.setTargetAmount(targetAmt);
|
||||
s.setTargetOrderCount(targetOrders);
|
||||
s.setSalesAmountAchievementRate(achievementRate(m.sales, targetAmt));
|
||||
s.setOrderCountAchievementRate(achievementRate(BigDecimal.valueOf(m.orderCount), BigDecimal.valueOf(targetOrders)));
|
||||
s.setOrderCountAchievementRate(achievementRate(BigDecimal.valueOf(m.salesOrderCount), BigDecimal.valueOf(targetOrders)));
|
||||
}
|
||||
|
||||
private static void mergeAgg(Map<Long, AggMetrics> map, long key, OverviewAggRows.ShopProductRow row) {
|
||||
@@ -730,7 +757,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
BigDecimal sales = BigDecimal.ZERO;
|
||||
/** 成交金额(全订单状态商家实收合计) */
|
||||
BigDecimal dealAmount = BigDecimal.ZERO;
|
||||
int orderCount;
|
||||
int salesOrderCount;
|
||||
int dealOrderCount;
|
||||
BigDecimal refund = BigDecimal.ZERO;
|
||||
BigDecimal productCost = BigDecimal.ZERO;
|
||||
BigDecimal freightCost = BigDecimal.ZERO;
|
||||
@@ -750,7 +778,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
AggMetrics a = new AggMetrics();
|
||||
a.sales = nz(row.getSalesAmount());
|
||||
a.dealAmount = nz(row.getDealAmount());
|
||||
a.orderCount = row.getOrderCount() != null ? row.getOrderCount().intValue() : 0;
|
||||
a.salesOrderCount = row.getOrderCount() != null ? row.getOrderCount().intValue() : 0;
|
||||
a.dealOrderCount = row.getDealOrderCount() != null ? row.getDealOrderCount().intValue() : 0;
|
||||
a.refund = nz(row.getRefundAmount());
|
||||
a.productCost = nz(row.getProductCost());
|
||||
a.freightCost = nz(row.getFreightCost());
|
||||
@@ -762,7 +791,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
||||
AggMetrics a = new AggMetrics();
|
||||
a.sales = sales.add(o.sales);
|
||||
a.dealAmount = dealAmount.add(o.dealAmount);
|
||||
a.orderCount = orderCount + o.orderCount;
|
||||
a.salesOrderCount = salesOrderCount + o.salesOrderCount;
|
||||
a.dealOrderCount = dealOrderCount + o.dealOrderCount;
|
||||
a.refund = refund.add(o.refund);
|
||||
a.productCost = productCost.add(o.productCost);
|
||||
a.freightCost = freightCost.add(o.freightCost);
|
||||
|
||||
+66
-40
@@ -131,7 +131,7 @@ public class ExportServiceImpl implements ExportService {
|
||||
String taxLabel = (taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP)).toPlainString() + "%税额";
|
||||
String[] headers = {
|
||||
firstColumnHeader, "目标单量", "单量达成率(%)", "目标额", "销售达成率(%)",
|
||||
"净销售额", "成交金额", "单量", "客单价",
|
||||
"成交金额", "净销售额", "成交单量", "净销售单量", "成交客单价", "净销售客单价",
|
||||
"商品成本", "运费", "其他成本", "订单成本", "退款金额", taxLabel, "推广费", "刷单费",
|
||||
"毛利", "税前净利", "费比", "ROI", "税后净利"
|
||||
};
|
||||
@@ -169,29 +169,31 @@ public class ExportServiceImpl implements ExportService {
|
||||
setCell(row, 2, objToPct(data.get("orderCountAchievementRate")), style);
|
||||
setCell(row, 3, objToDouble(data.get("targetAmount")), style);
|
||||
setCell(row, 4, objToPct(data.get("salesAchievementRate")), style);
|
||||
setCell(row, 5, objToDouble(data.get("salesAmount")), style);
|
||||
setCell(row, 6, objToDouble(data.get("dealAmount")), style);
|
||||
setCell(row, 7, objToDouble(data.get("orderCount")), style);
|
||||
setCell(row, 8, objToDouble(data.get("avgOrderValue")), style);
|
||||
setCell(row, 9, objToDouble(data.get("productCost")), style);
|
||||
setCell(row, 10, objToDouble(data.get("shippingCost")), style);
|
||||
setCell(row, 11, objToDouble(data.get("otherCost")), style);
|
||||
setCell(row, 12, objToDouble(data.get("orderCost")), style);
|
||||
setCell(row, 5, objToDouble(data.get("dealAmount")), style);
|
||||
setCell(row, 6, objToDouble(data.get("salesAmount")), style);
|
||||
setCell(row, 7, objToDouble(data.get("dealOrderCount")), style);
|
||||
setCell(row, 8, objToDouble(data.get("salesOrderCount")), style);
|
||||
setCell(row, 9, objToDouble(data.get("dealAvgOrderValue")), style);
|
||||
setCell(row, 10, objToDouble(data.get("salesAvgOrderValue")), style);
|
||||
setCell(row, 11, objToDouble(data.get("productCost")), style);
|
||||
setCell(row, 12, objToDouble(data.get("shippingCost")), style);
|
||||
setCell(row, 13, objToDouble(data.get("otherCost")), style);
|
||||
setCell(row, 14, objToDouble(data.get("orderCost")), style);
|
||||
BigDecimal salesTax = salesTaxOnNetForExport(
|
||||
mapToBigDecimal(data.get("salesAmount")),
|
||||
taxRate);
|
||||
BigDecimal profitAfterTax = mapToBigDecimal(data.get("totalProfitBeforeTax"))
|
||||
.subtract(salesTax)
|
||||
.setScale(2, RoundingMode.HALF_UP);
|
||||
setCell(row, 13, objToDouble(data.get("refundAmount")), style);
|
||||
setCell(row, 14, salesTax.doubleValue(), style);
|
||||
setCell(row, 15, objToDouble(data.get("totalPromotionFee")), style);
|
||||
setCell(row, 16, objToDouble(data.get("brushFee")), style);
|
||||
setCell(row, 17, objToDouble(data.get("grossProfit")), style);
|
||||
setCell(row, 18, objToDouble(data.get("totalProfitBeforeTax")), style);
|
||||
setCell(row, 19, objToDouble(data.get("feeRatio")), style);
|
||||
setCell(row, 20, objToDouble(data.get("roi")), style);
|
||||
setCell(row, 21, profitAfterTax.doubleValue(), style);
|
||||
setCell(row, 15, objToDouble(data.get("refundAmount")), style);
|
||||
setCell(row, 16, salesTax.doubleValue(), style);
|
||||
setCell(row, 17, objToDouble(data.get("totalPromotionFee")), style);
|
||||
setCell(row, 18, objToDouble(data.get("brushFee")), style);
|
||||
setCell(row, 19, objToDouble(data.get("grossProfit")), style);
|
||||
setCell(row, 20, objToDouble(data.get("totalProfitBeforeTax")), style);
|
||||
setCell(row, 21, objToDouble(data.get("feeRatio")), style);
|
||||
setCell(row, 22, objToDouble(data.get("roi")), style);
|
||||
setCell(row, 23, profitAfterTax.doubleValue(), style);
|
||||
}
|
||||
|
||||
private static BigDecimal mapToBigDecimal(Object val) {
|
||||
@@ -217,10 +219,12 @@ public class ExportServiceImpl implements ExportService {
|
||||
data.put("orderCountAchievementRate", s.getOrderCountAchievementRate());
|
||||
data.put("targetAmount", s.getTargetAmount());
|
||||
data.put("salesAchievementRate", s.getSalesAmountAchievementRate());
|
||||
data.put("salesAmount", s.getSalesAmount());
|
||||
data.put("dealAmount", s.getDealAmount());
|
||||
data.put("orderCount", s.getOrderCount());
|
||||
data.put("avgOrderValue", s.getAverageOrderValue());
|
||||
data.put("salesAmount", s.getSalesAmount());
|
||||
data.put("dealOrderCount", s.getDealOrderCount());
|
||||
data.put("salesOrderCount", s.getSalesOrderCount());
|
||||
data.put("dealAvgOrderValue", s.getDealAverageOrderValue());
|
||||
data.put("salesAvgOrderValue", s.getSalesAverageOrderValue());
|
||||
data.put("productCost", s.getProductCost());
|
||||
data.put("shippingCost", s.getShippingCost());
|
||||
data.put("otherCost", s.getOtherCost());
|
||||
@@ -250,7 +254,9 @@ public class ExportServiceImpl implements ExportService {
|
||||
private CompanyOverviewVO.ShopSummary aggregateShopSummariesForExport(
|
||||
List<CompanyOverviewVO.ShopSummary> shops, BigDecimal taxRate) {
|
||||
BigDecimal totalSales = BigDecimal.ZERO;
|
||||
int totalOrders = 0;
|
||||
BigDecimal totalDealAmount = BigDecimal.ZERO;
|
||||
int totalSalesOrders = 0;
|
||||
int totalDealOrders = 0;
|
||||
BigDecimal totalTargetAmount = BigDecimal.ZERO;
|
||||
int totalTargetOrders = 0;
|
||||
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||
@@ -262,7 +268,9 @@ public class ExportServiceImpl implements ExportService {
|
||||
|
||||
for (CompanyOverviewVO.ShopSummary s : shops) {
|
||||
totalSales = totalSales.add(s.getSalesAmount() != null ? s.getSalesAmount() : BigDecimal.ZERO);
|
||||
totalOrders += s.getOrderCount() != null ? s.getOrderCount() : 0;
|
||||
totalDealAmount = totalDealAmount.add(s.getDealAmount() != null ? s.getDealAmount() : BigDecimal.ZERO);
|
||||
totalSalesOrders += s.getSalesOrderCount() != null ? s.getSalesOrderCount() : 0;
|
||||
totalDealOrders += s.getDealOrderCount() != null ? s.getDealOrderCount() : 0;
|
||||
totalTargetAmount = totalTargetAmount.add(s.getTargetAmount() != null ? s.getTargetAmount() : BigDecimal.ZERO);
|
||||
totalTargetOrders += s.getTargetOrderCount() != null ? s.getTargetOrderCount() : 0;
|
||||
totalProductCost = totalProductCost.add(s.getProductCost() != null ? s.getProductCost() : BigDecimal.ZERO);
|
||||
@@ -273,8 +281,11 @@ public class ExportServiceImpl implements ExportService {
|
||||
totalBrushFee = totalBrushFee.add(s.getBrushFee() != null ? s.getBrushFee() : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
BigDecimal avgOrderValue = totalOrders > 0
|
||||
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
|
||||
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
|
||||
? totalSales.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal dealAvgOrderValue = totalDealOrders > 0
|
||||
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
|
||||
BigDecimal profitBeforeTax = totalSales.subtract(totalCost)
|
||||
@@ -291,16 +302,19 @@ public class ExportServiceImpl implements ExportService {
|
||||
? totalSales.divide(totalTargetAmount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))
|
||||
: totalSales.compareTo(BigDecimal.ZERO) > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
BigDecimal orderAchievementRate = totalTargetOrders > 0
|
||||
? new BigDecimal(totalOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
|
||||
? new BigDecimal(totalSalesOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal("100"))
|
||||
: totalOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
: totalSalesOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
|
||||
CompanyOverviewVO.ShopSummary total = new CompanyOverviewVO.ShopSummary();
|
||||
total.setShopId(0L);
|
||||
total.setShopName("合计");
|
||||
total.setSalesAmount(totalSales);
|
||||
total.setOrderCount(totalOrders);
|
||||
total.setAverageOrderValue(avgOrderValue);
|
||||
total.setDealAmount(totalDealAmount);
|
||||
total.setSalesOrderCount(totalSalesOrders);
|
||||
total.setDealOrderCount(totalDealOrders);
|
||||
total.setSalesAverageOrderValue(salesAvgOrderValue);
|
||||
total.setDealAverageOrderValue(dealAvgOrderValue);
|
||||
total.setTargetAmount(totalTargetAmount);
|
||||
total.setTargetOrderCount(totalTargetOrders);
|
||||
total.setSalesAmountAchievementRate(salesAchievementRate);
|
||||
@@ -327,10 +341,12 @@ public class ExportServiceImpl implements ExportService {
|
||||
data.put("orderCountAchievementRate", s.getOrderCountAchievementRate());
|
||||
data.put("targetAmount", s.getTargetAmount());
|
||||
data.put("salesAchievementRate", s.getSalesAmountAchievementRate());
|
||||
data.put("salesAmount", s.getSalesAmount());
|
||||
data.put("dealAmount", s.getDealAmount());
|
||||
data.put("orderCount", s.getOrderCount());
|
||||
data.put("avgOrderValue", s.getAverageOrderValue());
|
||||
data.put("salesAmount", s.getSalesAmount());
|
||||
data.put("dealOrderCount", s.getDealOrderCount());
|
||||
data.put("salesOrderCount", s.getSalesOrderCount());
|
||||
data.put("dealAvgOrderValue", s.getDealAverageOrderValue());
|
||||
data.put("salesAvgOrderValue", s.getSalesAverageOrderValue());
|
||||
data.put("productCost", s.getProductCost());
|
||||
data.put("shippingCost", s.getShippingCost());
|
||||
data.put("otherCost", s.getOtherCost());
|
||||
@@ -350,7 +366,9 @@ public class ExportServiceImpl implements ExportService {
|
||||
private CompanyOverviewVO.PlatformSummary aggregatePlatformSummariesForExport(
|
||||
List<CompanyOverviewVO.PlatformSummary> platforms, BigDecimal taxRate) {
|
||||
BigDecimal totalSales = BigDecimal.ZERO;
|
||||
int totalOrders = 0;
|
||||
BigDecimal totalDealAmount = BigDecimal.ZERO;
|
||||
int totalSalesOrders = 0;
|
||||
int totalDealOrders = 0;
|
||||
BigDecimal totalTargetAmount = BigDecimal.ZERO;
|
||||
int totalTargetOrders = 0;
|
||||
BigDecimal totalProductCost = BigDecimal.ZERO;
|
||||
@@ -362,7 +380,9 @@ public class ExportServiceImpl implements ExportService {
|
||||
|
||||
for (CompanyOverviewVO.PlatformSummary s : platforms) {
|
||||
totalSales = totalSales.add(s.getSalesAmount() != null ? s.getSalesAmount() : BigDecimal.ZERO);
|
||||
totalOrders += s.getOrderCount() != null ? s.getOrderCount() : 0;
|
||||
totalDealAmount = totalDealAmount.add(s.getDealAmount() != null ? s.getDealAmount() : BigDecimal.ZERO);
|
||||
totalSalesOrders += s.getSalesOrderCount() != null ? s.getSalesOrderCount() : 0;
|
||||
totalDealOrders += s.getDealOrderCount() != null ? s.getDealOrderCount() : 0;
|
||||
totalTargetAmount = totalTargetAmount.add(s.getTargetAmount() != null ? s.getTargetAmount() : BigDecimal.ZERO);
|
||||
totalTargetOrders += s.getTargetOrderCount() != null ? s.getTargetOrderCount() : 0;
|
||||
totalProductCost = totalProductCost.add(s.getProductCost() != null ? s.getProductCost() : BigDecimal.ZERO);
|
||||
@@ -373,8 +393,11 @@ public class ExportServiceImpl implements ExportService {
|
||||
totalBrushFee = totalBrushFee.add(s.getBrushFee() != null ? s.getBrushFee() : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
BigDecimal avgOrderValue = totalOrders > 0
|
||||
? totalSales.divide(new BigDecimal(totalOrders), 2, RoundingMode.HALF_UP)
|
||||
BigDecimal salesAvgOrderValue = totalSalesOrders > 0
|
||||
? totalSales.divide(new BigDecimal(totalSalesOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal dealAvgOrderValue = totalDealOrders > 0
|
||||
? totalDealAmount.divide(new BigDecimal(totalDealOrders), 2, RoundingMode.HALF_UP)
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal totalCost = totalProductCost.add(totalShippingCost).add(totalOtherCost);
|
||||
BigDecimal profitBeforeTax = totalSales.subtract(totalCost)
|
||||
@@ -391,16 +414,19 @@ public class ExportServiceImpl implements ExportService {
|
||||
? totalSales.divide(totalTargetAmount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))
|
||||
: totalSales.compareTo(BigDecimal.ZERO) > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
BigDecimal orderAchievementRate = totalTargetOrders > 0
|
||||
? new BigDecimal(totalOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
|
||||
? new BigDecimal(totalSalesOrders).divide(new BigDecimal(totalTargetOrders), 4, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal("100"))
|
||||
: totalOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
: totalSalesOrders > 0 ? new BigDecimal("100") : BigDecimal.ZERO;
|
||||
|
||||
CompanyOverviewVO.PlatformSummary total = new CompanyOverviewVO.PlatformSummary();
|
||||
total.setPlatformCode(null);
|
||||
total.setPlatformName("合计");
|
||||
total.setSalesAmount(totalSales);
|
||||
total.setOrderCount(totalOrders);
|
||||
total.setAverageOrderValue(avgOrderValue);
|
||||
total.setDealAmount(totalDealAmount);
|
||||
total.setSalesOrderCount(totalSalesOrders);
|
||||
total.setDealOrderCount(totalDealOrders);
|
||||
total.setSalesAverageOrderValue(salesAvgOrderValue);
|
||||
total.setDealAverageOrderValue(dealAvgOrderValue);
|
||||
total.setTargetAmount(totalTargetAmount);
|
||||
total.setTargetOrderCount(totalTargetOrders);
|
||||
total.setSalesAmountAchievementRate(salesAchievementRate);
|
||||
|
||||
+2
-2
@@ -140,8 +140,8 @@ public class BiProductOverviewServiceImpl implements BiProductOverviewService {
|
||||
CompanyOverviewVO.CategorySummary productRow = findProductRow(tables.getProductTable(), product.getId());
|
||||
|
||||
BigDecimal sales = productRow != null ? nz(productRow.getSalesAmount()) : sumSales(thisProductDocs);
|
||||
int orderCount = productRow != null && productRow.getOrderCount() != null
|
||||
? productRow.getOrderCount()
|
||||
int orderCount = productRow != null && productRow.getSalesOrderCount() != null
|
||||
? productRow.getSalesOrderCount()
|
||||
: sumOrders(thisProductDocs);
|
||||
BigDecimal refund = productRow != null ? nz(productRow.getRefundAmount()) : sumRefund(thisProductDocs);
|
||||
BigDecimal promo = productRow != null ? nz(productRow.getTotalPromotionFee()) : BigDecimal.ZERO;
|
||||
|
||||
+24
-4
@@ -170,9 +170,19 @@ public class ShopOverviewStatisticsVO {
|
||||
|
||||
private BigDecimal salesAmount;
|
||||
|
||||
private Integer orderCount;
|
||||
private BigDecimal dealAmount;
|
||||
|
||||
private BigDecimal averageOrderValue;
|
||||
/** 净销售单量 */
|
||||
private Integer salesOrderCount;
|
||||
|
||||
/** 成交单量 */
|
||||
private Integer dealOrderCount;
|
||||
|
||||
/** 净销售客单价 */
|
||||
private BigDecimal salesAverageOrderValue;
|
||||
|
||||
/** 成交客单价 */
|
||||
private BigDecimal dealAverageOrderValue;
|
||||
|
||||
private BigDecimal productCost;
|
||||
|
||||
@@ -210,9 +220,19 @@ public class ShopOverviewStatisticsVO {
|
||||
|
||||
private BigDecimal salesAmount;
|
||||
|
||||
private Integer orderCount;
|
||||
private BigDecimal dealAmount;
|
||||
|
||||
private BigDecimal averageOrderValue;
|
||||
/** 净销售单量 */
|
||||
private Integer salesOrderCount;
|
||||
|
||||
/** 成交单量 */
|
||||
private Integer dealOrderCount;
|
||||
|
||||
/** 净销售客单价 */
|
||||
private BigDecimal salesAverageOrderValue;
|
||||
|
||||
/** 成交客单价 */
|
||||
private BigDecimal dealAverageOrderValue;
|
||||
|
||||
private BigDecimal productCost;
|
||||
|
||||
|
||||
+19
-16
@@ -121,7 +121,7 @@ public class BiShopExportServiceImpl implements BiShopExportService {
|
||||
String titlePrefix = (shopName != null && !shopName.isBlank() ? shopName : "店铺") + " - 按商品汇总";
|
||||
String taxLabel = (taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP)).toPlainString() + "%税额";
|
||||
String[] headers = {
|
||||
"商品", "销售额", "单量", "客单价",
|
||||
"商品", "成交金额", "净销售额", "成交单量", "净销售单量", "成交客单价", "净销售客单价",
|
||||
"商品成本", "运费", "其他成本", "订单成本", "退款金额", "推广费", "刷单费用",
|
||||
"费比 %", "单品 ROI", "税前盈亏", taxLabel, "税后净利"
|
||||
};
|
||||
@@ -167,28 +167,31 @@ public class BiShopExportServiceImpl implements BiShopExportService {
|
||||
? "\n编码: " + p.getProductCode()
|
||||
: "");
|
||||
setCell(row, 0, nameCol, style);
|
||||
setCell(row, 1, nvl(p.getSalesAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 2, (double) nvl(p.getOrderCount(), 0), style);
|
||||
setCell(row, 3, nvl(p.getAverageOrderValue(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 4, nvl(p.getProductCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 5, nvl(p.getShippingCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 6, nvl(p.getOtherCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 7, nvl(p.getOrderCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 8, nvl(p.getRefundAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 9, nvl(p.getTotalPromotionFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 10, nvl(p.getBrushFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 1, nvl(p.getDealAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 2, nvl(p.getSalesAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 3, (double) nvl(p.getDealOrderCount(), 0), style);
|
||||
setCell(row, 4, (double) nvl(p.getSalesOrderCount(), 0), style);
|
||||
setCell(row, 5, nvl(p.getDealAverageOrderValue(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 6, nvl(p.getSalesAverageOrderValue(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 7, nvl(p.getProductCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 8, nvl(p.getShippingCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 9, nvl(p.getOtherCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 10, nvl(p.getOrderCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 11, nvl(p.getRefundAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 12, nvl(p.getTotalPromotionFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 13, nvl(p.getBrushFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
BigDecimal fr = p.getFeeRatio();
|
||||
double feePct = fr == null ? 0.0
|
||||
: fr.multiply(new BigDecimal("100")).setScale(1, RoundingMode.HALF_UP).doubleValue();
|
||||
setCell(row, 11, feePct, style);
|
||||
setCell(row, 12, nvl(p.getRoi(), BigDecimal.ZERO).setScale(4, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 13, nvl(p.getTotalProfitBeforeTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 14, feePct, style);
|
||||
setCell(row, 15, nvl(p.getRoi(), BigDecimal.ZERO).setScale(4, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
setCell(row, 16, nvl(p.getTotalProfitBeforeTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), style);
|
||||
BigDecimal salesTax = salesTaxOnNetForShopExport(p.getSalesAmount(), taxRate);
|
||||
BigDecimal profitAfterTax = nvl(p.getTotalProfitBeforeTax(), BigDecimal.ZERO)
|
||||
.subtract(salesTax)
|
||||
.setScale(2, RoundingMode.HALF_UP);
|
||||
setCell(row, 14, salesTax.doubleValue(), style);
|
||||
setCell(row, 15, profitAfterTax.doubleValue(), style);
|
||||
setCell(row, 17, salesTax.doubleValue(), style);
|
||||
setCell(row, 18, profitAfterTax.doubleValue(), style);
|
||||
}
|
||||
|
||||
private void createTrendSheetFromVO(Sheet sheet, String dateRangeLabel, ShopOverviewStatisticsVO vo) {
|
||||
|
||||
+12
-6
@@ -281,8 +281,11 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
|
||||
private static void copyMetrics(ShopOverviewStatisticsVO.ProductSummary p,
|
||||
CompanyOverviewVO.CategorySummary c) {
|
||||
p.setSalesAmount(c.getSalesAmount());
|
||||
p.setOrderCount(c.getOrderCount());
|
||||
p.setAverageOrderValue(c.getAverageOrderValue());
|
||||
p.setDealAmount(c.getDealAmount());
|
||||
p.setSalesOrderCount(c.getSalesOrderCount());
|
||||
p.setDealOrderCount(c.getDealOrderCount());
|
||||
p.setSalesAverageOrderValue(c.getSalesAverageOrderValue());
|
||||
p.setDealAverageOrderValue(c.getDealAverageOrderValue());
|
||||
p.setProductCost(c.getProductCost());
|
||||
p.setShippingCost(c.getShippingCost());
|
||||
p.setOtherCost(c.getOtherCost());
|
||||
@@ -324,8 +327,11 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
|
||||
s.setCategoryId(c.getCategoryId());
|
||||
s.setCategoryName(c.getCategoryName());
|
||||
s.setSalesAmount(c.getSalesAmount());
|
||||
s.setOrderCount(c.getOrderCount());
|
||||
s.setAverageOrderValue(c.getAverageOrderValue());
|
||||
s.setDealAmount(c.getDealAmount());
|
||||
s.setSalesOrderCount(c.getSalesOrderCount());
|
||||
s.setDealOrderCount(c.getDealOrderCount());
|
||||
s.setSalesAverageOrderValue(c.getSalesAverageOrderValue());
|
||||
s.setDealAverageOrderValue(c.getDealAverageOrderValue());
|
||||
s.setProductCost(c.getProductCost());
|
||||
s.setShippingCost(c.getShippingCost());
|
||||
s.setOtherCost(c.getOtherCost());
|
||||
@@ -350,7 +356,7 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
|
||||
vo.setProductSalesTop10(po.getProducts().stream()
|
||||
.sorted(Comparator.comparing(
|
||||
(ShopOverviewStatisticsVO.ProductSummary p) ->
|
||||
p.getOrderCount() != null ? p.getOrderCount() : 0,
|
||||
p.getSalesOrderCount() != null ? p.getSalesOrderCount() : 0,
|
||||
Comparator.reverseOrder()))
|
||||
.limit(10)
|
||||
.map(p -> {
|
||||
@@ -359,7 +365,7 @@ public class BiShopOverviewServiceImpl implements BiShopOverviewService {
|
||||
item.setProductId(p.getProductId());
|
||||
item.setProductName(p.getProductName());
|
||||
item.setProductCode(p.getProductCode());
|
||||
item.setOrderCount(p.getOrderCount());
|
||||
item.setOrderCount(p.getSalesOrderCount());
|
||||
item.setSalesAmount(p.getSalesAmount());
|
||||
return item;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user