|
|
@@ -1,5 +1,6 @@
|
|
|
package org.springblade.los.business.sea.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
@@ -8,6 +9,7 @@ import org.springblade.los.Util.IDeptUtils;
|
|
|
import org.springblade.los.Util.MagicValues;
|
|
|
import org.springblade.los.basic.corps.entity.BCorps;
|
|
|
import org.springblade.los.basic.corps.service.IBCorpsService;
|
|
|
+import org.springblade.los.business.sea.service.IBillsService;
|
|
|
import org.springblade.los.business.sea.service.IDataProcessingService;
|
|
|
import org.springblade.los.check.entity.LosAuditPathsLevels;
|
|
|
import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
@@ -15,12 +17,13 @@ import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import org.springblade.los.business.sea.entity.*;
|
|
|
+import org.springblade.los.business.sea.service.*;
|
|
|
+
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -36,6 +39,8 @@ public class DataProcessingImplService implements IDataProcessingService {
|
|
|
|
|
|
private final IDeptUtils deptUtils;
|
|
|
|
|
|
+ private final IBillsService billsService;
|
|
|
+
|
|
|
private final IBCorpsService bCorpsService;
|
|
|
|
|
|
|
|
|
@@ -103,11 +108,27 @@ public class DataProcessingImplService implements IDataProcessingService {
|
|
|
|
|
|
if("SE,SI".contains(businessType)){
|
|
|
return profitStatus_HY(id, businessType, fcList);
|
|
|
- }else if("SEA".equals(businessType) || "SEI".equals(businessType)){
|
|
|
- return profitStatus_HY(id, businessType, fcList);
|
|
|
+ // }else if("SEA".equals(businessType) || "SEI".equals(businessType)){
|
|
|
+ // return profitStatus_HY(id, businessType, fcList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String,Object> profitStatus_HY(Long id, String businessType, List<FeeCenter> feeCenterList) {
|
|
|
+ Map<String, Object> R = new HashMap<>();
|
|
|
+
|
|
|
+ Bills bill = billsService.getOne(new LambdaQueryWrapper<Bills>()
|
|
|
+ .select(Bills::getId, Bills::getQuotationMethod, Bills::getCorpId, Bills::getCarrierId,
|
|
|
+ Bills::getHpaymode, Bills::getMpaymode, Bills::getBillType, Bills::getHblno)
|
|
|
+ .eq(Bills::getId, id)
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0));
|
|
|
+
|
|
|
+ if (ObjectUtils.isNull(bill)) {
|
|
|
+ throw new RuntimeException("请核的业务 id 不存在");
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
// 费用名称
|
|
|
// 1722822288795000833 O/F 海运费 145
|
|
|
// 1722823384343011329 P/S P/S 220
|
|
|
@@ -123,6 +144,13 @@ public class DataProcessingImplService implements IDataProcessingService {
|
|
|
// 12247 W0661 W0661
|
|
|
// 12431 W0675 W0675
|
|
|
// 12731 W0689 W0689
|
|
|
+ // 'F':aAuditItem.RefNo2:='正常';
|
|
|
+ // 'M':aAuditItem.RefNo2:='为负';
|
|
|
+ // 'H':aAuditItem.RefNo2:='过高';
|
|
|
+ // 'L':aAuditItem.RefNo2:='过低';
|
|
|
+ // 'U':aAuditItem.RefNo2:='不成比例';
|
|
|
+ // 'D':aAuditItem.RefNo2:='不成比例且过低';
|
|
|
+
|
|
|
String specPScorpIds = ",1425,1561,3415,5110,6363,10120,11794,12247,12431,12731,";
|
|
|
|
|
|
BigDecimal usdOFProfit = new BigDecimal(BigInteger.ZERO);
|
|
|
@@ -141,7 +169,7 @@ public class DataProcessingImplService implements IDataProcessingService {
|
|
|
// 高收退费客户 Id
|
|
|
Long hpsCorpId = 0L;
|
|
|
|
|
|
- for (FeeCenter fee : fcList) {
|
|
|
+ for (FeeCenter fee : feeCenterList) {
|
|
|
if (specPSCorpId == 0 && ObjectUtils.isNotNull(fee.getCorpId())) {
|
|
|
if (specPScorpIds.indexOf("," + fee.getCorpId().toString() + ",") >= 0) {
|
|
|
specPSCorpId = fee.getCorpId();
|
|
|
@@ -189,13 +217,13 @@ public class DataProcessingImplService implements IDataProcessingService {
|
|
|
}
|
|
|
|
|
|
// 提取客户 PsRate
|
|
|
- BCorps bCorps11 = bCorpsService.getById(item.getCorpId());
|
|
|
+ BCorps bCorps11 = bCorpsService.getById(bill.getCorpId());
|
|
|
BigDecimal PsRate = new BigDecimal(BigInteger.ZERO);
|
|
|
Integer corpIsDC = 0;
|
|
|
if (ObjectUtils.isNotNull(bCorps11)) {
|
|
|
- if("外部报价".equals(item.getQuotationMethod())){
|
|
|
+ if ("外部报价".equals(bill.getQuotationMethod())) {
|
|
|
PsRate = new BigDecimal(bCorps11.getPsRateExternal());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
PsRate = new BigDecimal(bCorps11.getPsRate());
|
|
|
}
|
|
|
if (ObjectUtils.isNotNull(bCorps11.getCorpTypeName()) && bCorps11.getCorpTypeName().contains("国内直接客户")) {
|
|
|
@@ -216,7 +244,7 @@ public class DataProcessingImplService implements IDataProcessingService {
|
|
|
BCorps bCorps13 = bCorpsService.getById(hpsCorpId);
|
|
|
if (ObjectUtils.isNotNull(bCorps13)) {
|
|
|
Long ownerCorpId = ObjectUtils.isNotNull(bCorps13.getCorpId()) ? bCorps13.getCorpId() : 0L;
|
|
|
- if (ownerCorpId.equals(item.getCorpId()) || ownerCorpId.equals(item.getCarrierId()) || hpsCorpId.equals(item.getCorpId())) {
|
|
|
+ if (ownerCorpId.equals(bill.getCorpId()) || ownerCorpId.equals(bill.getCarrierId()) || hpsCorpId.equals(bill.getCorpId())) {
|
|
|
isPS = ObjectUtils.isNotNull(bCorps13.getIsPs()) && bCorps13.getIsPs() == 1;
|
|
|
}
|
|
|
}
|
|
|
@@ -240,12 +268,12 @@ public class DataProcessingImplService implements IDataProcessingService {
|
|
|
ps_remarks += " PS不能出现 RMB 费用\r\n";
|
|
|
}
|
|
|
|
|
|
- if ("CC".equals(item.getMpaymode()) && psProfit.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ if ("CC".equals(bill.getMpaymode()) && psProfit.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
ps_remarks += " 主单付费方式为CC 不能出现PS\r\n";
|
|
|
}
|
|
|
|
|
|
- if (("PP".equals(item.getMpaymode()) && (MagicValues.DD.equals(item.getBillType()) || MagicValues.MM.equals(item.getBillType())))
|
|
|
- || ("CC".equals(item.getMpaymode()) && ObjectUtils.isNotNull(item.getHblno()))) {
|
|
|
+ if (("PP".equals(bill.getMpaymode()) && (MagicValues.DD.equals(bill.getBillType()) || MagicValues.MM.equals(bill.getBillType())))
|
|
|
+ || ("CC".equals(bill.getMpaymode()) && ObjectUtils.isNotNull(bill.getHblno()))) {
|
|
|
if (specPScorpIds.contains("," + specPSCorpId.toString() + ",")) {
|
|
|
if (usdOFProfit.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
BigDecimal tt1 = usdOFProfit.add(ofInAmtProfit).add(HPSProfit).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
@@ -291,12 +319,13 @@ public class DataProcessingImplService implements IDataProcessingService {
|
|
|
|
|
|
ps_remarks = ps_remarks.trim();
|
|
|
ps_ps = ps_ps.trim();
|
|
|
- item.setProfitStatus("");
|
|
|
- item.setProfitRemarks(ps_remarks.trim());
|
|
|
- item.setProfitSpec(ps_ps.trim() + "\r\n" + ps_spec.trim());
|
|
|
- item.setText(ps_text);
|
|
|
- item.setCorpIsDC(corpIsDC);
|
|
|
- item.setIfDCCorp(corpIsDC == 1 ? "DC" : "");
|
|
|
+
|
|
|
+ R.put("profitStatus", "");
|
|
|
+ R.put("profitRemarks", ps_remarks.trim());
|
|
|
+ R.put("profitSpec", ps_ps.trim() + "\r\n" + ps_spec.trim());
|
|
|
+ R.put("text", ps_text);
|
|
|
+ R.put("corpIsDC", corpIsDC);
|
|
|
+ R.put("ifDCCorp", corpIsDC == 1 ? "DC" : "");
|
|
|
|
|
|
// FOverFeeLimit:=Trim(GetSysConst('SEA_ISSUEBILL_OVERFEE_LIMIT', '100000'));
|
|
|
// 判断是否国内直客
|
|
|
@@ -310,107 +339,102 @@ public class DataProcessingImplService implements IDataProcessingService {
|
|
|
BigDecimal sumLocCr = new BigDecimal(BigInteger.ZERO);
|
|
|
|
|
|
BigDecimal sumOFPS = new BigDecimal(BigInteger.ZERO);
|
|
|
- if (item.equals(bills)) {
|
|
|
- // 当前单据,计算 ProfitStatus
|
|
|
- for (FeeCenter fee : allFeeCenter) {
|
|
|
- if (MagicValues.C.equals(fee.getDc()) && "P/S".equals(fee.getFeeCode())) {
|
|
|
- // if("USD".equals(fee.getCurCode())){
|
|
|
- sumOFPS = sumOFPS.add(fee.getAmountLoc()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
+ // 当前单据,计算 ProfitStatus
|
|
|
+ for (FeeCenter fee : feeCenterList) {
|
|
|
+ if (MagicValues.C.equals(fee.getDc()) && "P/S".equals(fee.getFeeCode())) {
|
|
|
+ // if("USD".equals(fee.getCurCode())){
|
|
|
+ sumOFPS = sumOFPS.add(fee.getAmountLoc()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
|
|
|
- if (MagicValues.D.equals(fee.getDc())) {
|
|
|
- if ("USD".equals(fee.getCurCode())) {
|
|
|
- sumUSDDr = sumUSDDr.add(fee.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- } else {
|
|
|
- sumCNYDr = sumCNYDr.add(fee.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
- sumLocDr = sumLocDr.add(fee.getAmountLoc()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ if (MagicValues.D.equals(fee.getDc())) {
|
|
|
+ if ("USD".equals(fee.getCurCode())) {
|
|
|
+ sumUSDDr = sumUSDDr.add(fee.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ } else {
|
|
|
+ sumCNYDr = sumCNYDr.add(fee.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
+ sumLocDr = sumLocDr.add(fee.getAmountLoc()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
|
|
|
- if (MagicValues.C.equals(fee.getDc())) {
|
|
|
- if ("USD".equals(fee.getCurCode())) {
|
|
|
- sumUSDCr = sumUSDCr.add(fee.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- } else {
|
|
|
- sumCNYCr = sumCNYCr.add(fee.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
- sumLocCr = sumLocCr.add(fee.getAmountLoc()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ if (MagicValues.C.equals(fee.getDc())) {
|
|
|
+ if ("USD".equals(fee.getCurCode())) {
|
|
|
+ sumUSDCr = sumUSDCr.add(fee.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ } else {
|
|
|
+ sumCNYCr = sumCNYCr.add(fee.getAmount()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
+ sumLocCr = sumLocCr.add(fee.getAmountLoc()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- BigDecimal sumProfitUSD = sumUSDDr.subtract(sumUSDCr).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal sumProfitCNY = sumCNYDr.subtract(sumCNYCr).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- BigDecimal sumProfitLoc = sumLocDr.subtract(sumLocCr).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
-
|
|
|
- BigDecimal profitRate = new BigDecimal(BigInteger.ZERO);
|
|
|
- if (sumLocDr.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
- profitRate = sumProfitLoc.divide(sumLocDr, 4, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
+ BigDecimal sumProfitUSD = sumUSDDr.subtract(sumUSDCr).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal sumProfitCNY = sumCNYDr.subtract(sumCNYCr).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal sumProfitLoc = sumLocDr.subtract(sumLocCr).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
- String profitStatus = "F";
|
|
|
- if (!ps_ps.isEmpty()) {
|
|
|
- profitStatus = "U";
|
|
|
- }
|
|
|
- if (sumProfitLoc.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
- profitStatus = "Z";
|
|
|
- } else if (sumProfitLoc.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
- profitStatus = "M";
|
|
|
- } else if (sumLocDr.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- if (profitRate.compareTo(new BigDecimal("0.4")) >= 0) {
|
|
|
- profitStatus = "H";
|
|
|
- } else if (profitRate.compareTo(new BigDecimal("0.02")) < 0) {
|
|
|
- profitStatus = "U".equals(profitStatus) ? "D" : "L";
|
|
|
- }
|
|
|
- }
|
|
|
+ BigDecimal profitRate = new BigDecimal(BigInteger.ZERO);
|
|
|
+ if (sumLocDr.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+ profitRate = sumProfitLoc.divide(sumLocDr, 4, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
|
|
|
- item.setProfitStatus(profitStatus);
|
|
|
- switch (profitStatus) {
|
|
|
- case "Z":
|
|
|
- item.setProfitStatusText("利润为零");
|
|
|
- item.setProfitStatusEnText("Profit was zero!");
|
|
|
- break;
|
|
|
- case "D":
|
|
|
- item.setProfitStatusText("利润不成比例且过低");
|
|
|
- item.setProfitStatusEnText("Profit was unfair and low!");
|
|
|
- break;
|
|
|
- case "H":
|
|
|
- item.setProfitStatusText("利润过高");
|
|
|
- item.setProfitStatusEnText("Profit was high!");
|
|
|
- break;
|
|
|
- case "L":
|
|
|
- item.setProfitStatusText("利润过低");
|
|
|
- item.setProfitStatusEnText("Profit was low!");
|
|
|
- break;
|
|
|
- case "F":
|
|
|
- item.setProfitStatusText("利润正常");
|
|
|
- item.setProfitStatusEnText("");
|
|
|
- break;
|
|
|
- case "M":
|
|
|
- item.setProfitStatusText("利润为负");
|
|
|
- item.setProfitStatusEnText("Profit was minus!");
|
|
|
- break;
|
|
|
- case "U":
|
|
|
- item.setProfitStatusText("不成比例");
|
|
|
- item.setProfitStatusEnText("P/S was unfair!");
|
|
|
- break;
|
|
|
- default:
|
|
|
- item.setProfitStatusText("");
|
|
|
- item.setProfitStatusEnText("");
|
|
|
+ String profitStatus = "F";
|
|
|
+ if (!ps_ps.isEmpty()) {
|
|
|
+ profitStatus = "U";
|
|
|
+ }
|
|
|
+ if (sumProfitLoc.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ profitStatus = "Z";
|
|
|
+ } else if (sumProfitLoc.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ profitStatus = "M";
|
|
|
+ } else if (sumLocDr.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (profitRate.compareTo(new BigDecimal("0.4")) >= 0) {
|
|
|
+ profitStatus = "H";
|
|
|
+ } else if (profitRate.compareTo(new BigDecimal("0.02")) < 0) {
|
|
|
+ profitStatus = "U".equals(profitStatus) ? "D" : "L";
|
|
|
}
|
|
|
}
|
|
|
-// 'F':aAuditItem.RefNo2:='正常';
|
|
|
-// 'M':aAuditItem.RefNo2:='为负';
|
|
|
-// 'H':aAuditItem.RefNo2:='过高';
|
|
|
-// 'L':aAuditItem.RefNo2:='过低';
|
|
|
-// 'U':aAuditItem.RefNo2:='不成比例';
|
|
|
-// 'D':aAuditItem.RefNo2:='不成比例且过低';
|
|
|
-*/
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
- public Map<String,Object> profitStatus_HY(Long id, String businessType, List<FeeCenter> feeCenterList) {
|
|
|
+ R.put("profitStatus", profitStatus);
|
|
|
+ switch (profitStatus) {
|
|
|
+ case "Z":
|
|
|
+ R.put("profitStatusText", "为零");
|
|
|
+ R.put("profitStatusCnText", "利润为零");
|
|
|
+ R.put("profitStatusEnText", "Profit was zero!");
|
|
|
+ break;
|
|
|
+ case "D":
|
|
|
+ R.put("profitStatusText", "不成比例且过低");
|
|
|
+ R.put("profitStatusCnText", "利润不成比例且过低");
|
|
|
+ R.put("profitStatusEnText", "Profit was unfair and low!");
|
|
|
+ break;
|
|
|
+ case "H":
|
|
|
+ R.put("profitStatusText", "过高");
|
|
|
+ R.put("profitStatusCnText", "利润过高");
|
|
|
+ R.put("profitStatusEnText", "Profit was high!");
|
|
|
+ break;
|
|
|
+ case "L":
|
|
|
+ R.put("profitStatusText", "过低");
|
|
|
+ R.put("profitStatusCnText", "利润过低");
|
|
|
+ R.put("profitStatusEnText", "Profit was low!");
|
|
|
+ break;
|
|
|
+ case "F":
|
|
|
+ R.put("profitStatusText", "正常");
|
|
|
+ R.put("profitStatusCnText", "利润正常");
|
|
|
+ R.put("profitStatusEnText", "");
|
|
|
+ break;
|
|
|
+ case "M":
|
|
|
+ R.put("profitStatusText", "为负");
|
|
|
+ R.put("profitStatusCnText", "利润为负");
|
|
|
+ R.put("profitStatusEnText", "Profit was minus!");
|
|
|
+ break;
|
|
|
+ case "U":
|
|
|
+ R.put("profitStatusText", "不成比例");
|
|
|
+ R.put("profitStatusCnText", "不成比例");
|
|
|
+ R.put("profitStatusEnText", "P/S was unfair!");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ R.put("profitStatusText", "");
|
|
|
+ R.put("profitStatusCnText", "");
|
|
|
+ R.put("profitStatusEnText", "");
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
+ return R;
|
|
|
}
|
|
|
|
|
|
}
|