1
This commit is contained in:
@@ -150,7 +150,7 @@ public AjaxResult getStatistics(OrderRows orderRows, Date beginTime, Date endTim
|
|||||||
List<OrderRows> filteredList = orderRowsService.selectOrderRowsListWithFilter(orderRows, beginTime, endTime, excludeUnionIds);
|
List<OrderRows> filteredList = orderRowsService.selectOrderRowsListWithFilter(orderRows, beginTime, endTime, excludeUnionIds);
|
||||||
|
|
||||||
// 定义分组
|
// 定义分组
|
||||||
Map<String, Object> groups = new HashMap<>();
|
Map<String, List<String>> groups = new HashMap<>();
|
||||||
groups.put("cancel", Arrays.asList("3"));
|
groups.put("cancel", Arrays.asList("3"));
|
||||||
groups.put("invalid", Arrays.asList("2","4","5","6","7","8","9","10","11","14","19","20","21","22","23","29","30","31","32","33","34"));
|
groups.put("invalid", Arrays.asList("2","4","5","6","7","8","9","10","11","14","19","20","21","22","23","29","30","31","32","33","34"));
|
||||||
groups.put("pending", Arrays.asList("15"));
|
groups.put("pending", Arrays.asList("15"));
|
||||||
@@ -182,26 +182,60 @@ public AjaxResult getStatistics(OrderRows orderRows, Date beginTime, Date endTim
|
|||||||
// 按分组统计
|
// 按分组统计
|
||||||
for (OrderRows row : filteredList) {
|
for (OrderRows row : filteredList) {
|
||||||
totalOrders++;
|
totalOrders++;
|
||||||
if (row.getEstimateFee() != null) {
|
|
||||||
totalCommission += row.getEstimateFee();
|
|
||||||
}
|
|
||||||
if (row.getActualFee() != null) {
|
|
||||||
totalActualFee += row.getActualFee();
|
|
||||||
}
|
|
||||||
if (row.getSkuNum() != null) {
|
if (row.getSkuNum() != null) {
|
||||||
totalSkuNum += row.getSkuNum();
|
totalSkuNum += row.getSkuNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算佣金金额(对于违规和取消订单使用特殊计算)
|
||||||
|
String validCode = row.getValidCode() != null ? String.valueOf(row.getValidCode()) : null;
|
||||||
|
boolean isCancel = "3".equals(validCode); // 取消订单
|
||||||
|
boolean isIllegal = "25".equals(validCode) || "26".equals(validCode)
|
||||||
|
|| "27".equals(validCode) || "28".equals(validCode); // 违规订单
|
||||||
|
|
||||||
|
double commissionAmount = 0.0;
|
||||||
|
double actualFeeAmount = 0.0;
|
||||||
|
|
||||||
|
// 违规订单:始终使用 estimateCosPrice * commissionRate / 100 计算
|
||||||
|
if (isIllegal) {
|
||||||
|
if (row.getEstimateCosPrice() != null && row.getCommissionRate() != null) {
|
||||||
|
commissionAmount = row.getEstimateCosPrice() * row.getCommissionRate() * 0.01;
|
||||||
|
actualFeeAmount = commissionAmount; // 违规订单的实际费用等于计算的佣金
|
||||||
|
} else if (row.getEstimateFee() != null) {
|
||||||
|
commissionAmount = row.getEstimateFee();
|
||||||
|
actualFeeAmount = commissionAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 取消订单:如果actualFee为空或0,则使用公式计算
|
||||||
|
else if (isCancel) {
|
||||||
|
if (row.getActualFee() != null && row.getActualFee() > 0) {
|
||||||
|
actualFeeAmount = row.getActualFee();
|
||||||
|
commissionAmount = row.getEstimateFee() != null ? row.getEstimateFee() : 0;
|
||||||
|
} else if (row.getEstimateCosPrice() != null && row.getCommissionRate() != null) {
|
||||||
|
commissionAmount = row.getEstimateCosPrice() * row.getCommissionRate() * 0.01;
|
||||||
|
actualFeeAmount = commissionAmount;
|
||||||
|
} else {
|
||||||
|
commissionAmount = row.getEstimateFee() != null ? row.getEstimateFee() : 0;
|
||||||
|
actualFeeAmount = row.getActualFee() != null ? row.getActualFee() : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 其他订单:使用原有的字段值
|
||||||
|
else {
|
||||||
|
commissionAmount = row.getEstimateFee() != null ? row.getEstimateFee() : 0;
|
||||||
|
actualFeeAmount = row.getActualFee() != null ? row.getActualFee() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
totalCommission += commissionAmount;
|
||||||
|
totalActualFee += actualFeeAmount;
|
||||||
|
|
||||||
// 按validCode分组统计
|
// 按validCode分组统计
|
||||||
if (row.getValidCode() != null) {
|
if (validCode != null) {
|
||||||
String validCode = String.valueOf(row.getValidCode());
|
for (Map.Entry<String, List<String>> group : groups.entrySet()) {
|
||||||
for (Map.Entry<String, Object> group : groups.entrySet()) {
|
List<String> codes = group.getValue();
|
||||||
List<String> codes = (List<String>) group.getValue();
|
|
||||||
if (codes.contains(validCode)) {
|
if (codes.contains(validCode)) {
|
||||||
Map<String, Object> stat = groupStats.get(group.getKey());
|
Map<String, Object> stat = groupStats.get(group.getKey());
|
||||||
stat.put("count", (Integer) stat.get("count") + 1);
|
stat.put("count", (Integer) stat.get("count") + 1);
|
||||||
stat.put("commission", (Double) stat.get("commission") + (row.getEstimateFee() != null ? row.getEstimateFee() : 0));
|
stat.put("commission", (Double) stat.get("commission") + commissionAmount);
|
||||||
stat.put("actualFee", (Double) stat.get("actualFee") + (row.getActualFee() != null ? row.getActualFee() : 0));
|
stat.put("actualFee", (Double) stat.get("actualFee") + actualFeeAmount);
|
||||||
if (row.getSkuNum() != null) {
|
if (row.getSkuNum() != null) {
|
||||||
stat.put("skuNum", (Long) stat.get("skuNum") + row.getSkuNum());
|
stat.put("skuNum", (Long) stat.get("skuNum") + row.getSkuNum());
|
||||||
}
|
}
|
||||||
@@ -209,13 +243,7 @@ public AjaxResult getStatistics(OrderRows orderRows, Date beginTime, Date endTim
|
|||||||
// 统计违规订单
|
// 统计违规订单
|
||||||
if ("illegal".equals(group.getKey())) {
|
if ("illegal".equals(group.getKey())) {
|
||||||
violationOrders++;
|
violationOrders++;
|
||||||
// 违规订单佣金计算方式:实际价格 * 佣金比例
|
violationCommission += commissionAmount;
|
||||||
if (row.getActualCosPrice() != null && row.getCommissionRate() != null) {
|
|
||||||
violationCommission += row.getActualCosPrice() * row.getCommissionRate() * 0.01;
|
|
||||||
} else if (row.getEstimateFee() != null) {
|
|
||||||
// 如果无法计算,使用预估佣金
|
|
||||||
violationCommission += row.getEstimateFee();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user