|
|
@@ -125,9 +125,9 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
String deptName = "";
|
|
|
String branchId = deptUtils.getDeptPid() + "";
|
|
|
//获取部门ids对应中文名
|
|
|
- if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
- deptId = AuthUtil.getDeptId();
|
|
|
- R<List<String>> res = sysClient.getDeptNames(AuthUtil.getDeptId());
|
|
|
+ if (ObjectUtils.isNotNull(deptUtils.getDeptPid()+"")) {
|
|
|
+ deptId = deptUtils.getDeptPid()+"";
|
|
|
+ R<List<String>> res = sysClient.getDeptNames(deptUtils.getDeptPid()+"");
|
|
|
if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
|
|
|
deptName = String.join(",", res.getData());
|
|
|
}
|
|
|
@@ -137,7 +137,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
}
|
|
|
List<Bills> count = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
.select(Bills::getId)
|
|
|
- .eq(Bills::getCreateDept, AuthUtil.getDeptId())
|
|
|
+ .eq(Bills::getCreateDept, deptUtils.getDeptPid()+"")
|
|
|
.eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(Bills::getIsDeleted, 0)
|
|
|
.eq(Bills::getMblno, bills.getMblno())
|
|
|
@@ -176,7 +176,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
bills.setCreateTime(new Date());
|
|
|
bills.setCreateUser(AuthUtil.getUserId());
|
|
|
bills.setCreateUserName(AuthUtil.getUserName());
|
|
|
- if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ if (ObjectUtils.isNotNull(deptUtils.getDeptPid()+"")) {
|
|
|
bills.setBranchId(branchId);
|
|
|
bills.setCreateDept(deptId);
|
|
|
bills.setCreateDeptName(deptName);
|
|
|
@@ -219,7 +219,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
, Bills::getFinalDestinationNamePrint, Bills::getCyId, Bills::getCyCode, Bills::getCyCnName, Bills::getCyEnName, Bills::getCyAddress
|
|
|
, Bills::getCyTel, Bills::getCyRemarks, Bills::getCyTrailerTime, Bills::getCyReturnTime, Bills::getCarrierId, Bills::getCarrierCnName
|
|
|
, Bills::getCarrierEnName, Bills::getCarrierArgreementNo, Bills::getBookingDate)
|
|
|
- .eq(Bills::getCreateDept, AuthUtil.getDeptId())
|
|
|
+ .eq(Bills::getCreateDept, deptUtils.getDeptPid()+"")
|
|
|
.eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(Bills::getIsDeleted, 0)
|
|
|
.eq(Bills::getMblno, bills.getMblno()));
|
|
|
@@ -1103,52 +1103,49 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
|
|
|
feeCenterList.addAll(feeCenters);
|
|
|
}
|
|
|
}
|
|
|
- List<FeeCenter> feeCenterListUsd = feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode())).collect(Collectors.toList());
|
|
|
- List<FeeCenter> feeCenterListCny = feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode())).collect(Collectors.toList());
|
|
|
- if (!feeCenterListUsd.isEmpty() && !feeCenterListCny.isEmpty()) {
|
|
|
- throw new RuntimeException("应收应付币种不一致");
|
|
|
- }
|
|
|
- List<FeeCenter> feeCenterListPS = feeCenterList.stream().filter(e -> e.getFeeCnName().equals("PS")).collect(Collectors.toList());
|
|
|
- List<FeeCenter> feeCenterListHY = feeCenterList.stream().filter(e -> e.getFeeCnName().equals("海运费")).collect(Collectors.toList());
|
|
|
- if (!feeCenterListPS.isEmpty() && !feeCenterListHY.isEmpty()) {
|
|
|
- BigDecimal amountHYD = feeCenterList.stream()
|
|
|
- .filter(e -> e.getFeeCnName().equals("海运费") && "USD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
- .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal amountHYC = feeCenterList.stream()
|
|
|
- .filter(e -> e.getFeeCnName().equals("海运费") && "USD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
- .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal amountPSD = feeCenterList.stream()
|
|
|
- .filter(e -> e.getFeeCnName().equals("PS") && "USD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
- .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal amountPSC = feeCenterList.stream()
|
|
|
- .filter(e -> e.getFeeCnName().equals("PS") && "USD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
- .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- if (("PP".equals(declare.getMpaymode()) && ("MM".equals(declare.getBillType()) || "DD".equals(declare.getBillType()))) ||
|
|
|
- ("CC".equals(declare.getMpaymode()) && "MH".equals(declare.getBillType()))) {
|
|
|
- BCorps bCorps = ibCorpsService.getById(declare.getCorpId());
|
|
|
- BigDecimal PSAmount = amountPSC.subtract(amountPSD);
|
|
|
- BigDecimal HYAmount = amountHYD.subtract(amountHYC);
|
|
|
- BigDecimal rate = new BigDecimal("0.00");
|
|
|
- if (PSAmount.compareTo(new BigDecimal("0.00")) > 0 && HYAmount.compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
- rate = PSAmount.divide(HYAmount, MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ String status = sysClient.getParamServiceNew("is.profit.margin");
|
|
|
+ if ("1".equals(status)) {
|
|
|
+ List<FeeCenter> feeCenterListPS = feeCenterList.stream().filter(e -> e.getFeeCnName().equals("PS")).collect(Collectors.toList());
|
|
|
+ List<FeeCenter> feeCenterListHY = feeCenterList.stream().filter(e -> e.getFeeCnName().equals("海运费")).collect(Collectors.toList());
|
|
|
+ if (!feeCenterListPS.isEmpty() && !feeCenterListHY.isEmpty()) {
|
|
|
+ BigDecimal amountHYD = feeCenterList.stream()
|
|
|
+ .filter(e -> e.getFeeCnName().equals("海运费") && "USD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal amountHYC = feeCenterList.stream()
|
|
|
+ .filter(e -> e.getFeeCnName().equals("海运费") && "USD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal amountPSD = feeCenterList.stream()
|
|
|
+ .filter(e -> e.getFeeCnName().equals("PS") && "USD".equals(e.getCurCode()) && "D".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal amountPSC = feeCenterList.stream()
|
|
|
+ .filter(e -> e.getFeeCnName().equals("PS") && "USD".equals(e.getCurCode()) && "C".equals(e.getDc()))
|
|
|
+ .map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ if (("PP".equals(declare.getMpaymode()) && ("MM".equals(declare.getBillType()) || "DD".equals(declare.getBillType()))) ||
|
|
|
+ ("CC".equals(declare.getMpaymode()) && "MH".equals(declare.getBillType()))) {
|
|
|
+ BCorps bCorps = ibCorpsService.getById(declare.getCorpId());
|
|
|
+ BigDecimal PSAmount = amountPSC.subtract(amountPSD);
|
|
|
+ BigDecimal HYAmount = amountHYD.subtract(amountHYC);
|
|
|
+ BigDecimal rate = new BigDecimal("0.00");
|
|
|
+ if (PSAmount.compareTo(new BigDecimal("0.00")) > 0 && HYAmount.compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
+ rate = PSAmount.divide(HYAmount, MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("海运费利润:" + HYAmount + ", PS利润:" + PSAmount);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(bCorps) && ObjectUtils.isNotNull(bCorps.getPsRate()) && new BigDecimal(bCorps.getPsRate()).compareTo(new BigDecimal("0.00")) == 0) {
|
|
|
+ throw new RuntimeException("往来单位PS规则为空或零,不能存在PS费用");
|
|
|
+ }
|
|
|
+ if (new BigDecimal(bCorps.getPsRate()).compareTo(rate) < 0) {
|
|
|
+ throw new RuntimeException("PS比例高,公司实际分成比例:" + rate + ".系统比例为:" + bCorps.getPsRate());
|
|
|
+ }
|
|
|
} else {
|
|
|
- throw new RuntimeException("海运费利润:" + HYAmount + ", PS利润:" + PSAmount);
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(bCorps) && ObjectUtils.isNotNull(bCorps.getPsRate()) && new BigDecimal(bCorps.getPsRate()).compareTo(new BigDecimal("0.00")) == 0) {
|
|
|
- throw new RuntimeException("往来单位PS规则为空或零,不能存在PS费用");
|
|
|
+ throw new RuntimeException("只有预付、直单和主单,或分单和到付才可以输入PS");
|
|
|
}
|
|
|
- if (new BigDecimal(bCorps.getPsRate()).compareTo(rate) < 0) {
|
|
|
- throw new RuntimeException("PS比例高,公司实际分成比例:" + rate + ".系统比例为:" + bCorps.getPsRate());
|
|
|
- }
|
|
|
- } else {
|
|
|
- throw new RuntimeException("只有预付、直单和主单,或分单和到付才可以输入PS");
|
|
|
+ } else if (feeCenterListPS.isEmpty() && !feeCenterListHY.isEmpty()) {
|
|
|
+ throw new RuntimeException("PS费与海运费需同时存在,当前缺少PS费用信息");
|
|
|
+ } else if (!feeCenterListPS.isEmpty()) {
|
|
|
+ throw new RuntimeException("PS费与海运费需同时存在,当前缺少海运费用信息");
|
|
|
}
|
|
|
- } else if (feeCenterListPS.isEmpty() && !feeCenterListHY.isEmpty()) {
|
|
|
- throw new RuntimeException("PS费与海运费需同时存在,当前缺少PS费用信息");
|
|
|
- } else if (!feeCenterListPS.isEmpty()) {
|
|
|
- throw new RuntimeException("PS费与海运费需同时存在,当前缺少海运费用信息");
|
|
|
}
|
|
|
-
|
|
|
// 没开启审批流直接走 通过流程
|
|
|
if (pathsActs == null || pathsActs.getIsEnable() == 2) {
|
|
|
throw new SecurityException("当前租户未查询到审批流配置");
|