demand: TMS系统财务销账优化
committer: heyu
This commit is contained in:
parent
1b5f7b5730
commit
9173fc069b
@ -1134,15 +1134,17 @@ public class EmisWriteoffApplyServiceImpl extends EmisBaseService implements IEm
|
|||||||
String applyManName = StringUtils.hasText(apply.getApplyManName()) ? apply.getApplyManName()
|
String applyManName = StringUtils.hasText(apply.getApplyManName()) ? apply.getApplyManName()
|
||||||
: apply.getApplyManCode();
|
: apply.getApplyManCode();
|
||||||
|
|
||||||
// 获取操作人姓名
|
// 获取操作人姓名 - 通过当前登录账号获取
|
||||||
String operatorName = "";
|
String operatorName = "";
|
||||||
if ("centerPass".equals(actionType) || "centerReject".equals(actionType)) {
|
try {
|
||||||
operatorName = StringUtils.hasText(apply.getCenterConfirmManName()) ? apply.getCenterConfirmManName()
|
SysUser currentUser = getCurrentUser();
|
||||||
: apply.getCenterConfirmManCode();
|
if (currentUser != null) {
|
||||||
} else if ("headquartersReject".equals(actionType)) {
|
operatorName = StringUtils.hasText(currentUser.getEmpName()) ? currentUser.getEmpName()
|
||||||
operatorName = StringUtils.hasText(apply.getHeadquartersConfirmManName())
|
: currentUser.getEmpCode();
|
||||||
? apply.getHeadquartersConfirmManName()
|
}
|
||||||
: apply.getHeadquartersConfirmManCode();
|
} catch (Exception e) {
|
||||||
|
log.warn("获取当前登录用户信息失败,使用默认操作人", e);
|
||||||
|
operatorName = "系统";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建通知内容
|
// 构建通知内容
|
||||||
@ -1214,57 +1216,56 @@ public class EmisWriteoffApplyServiceImpl extends EmisBaseService implements IEm
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算该运单的总申请金额
|
|
||||||
BigDecimal totalApplyMoney = waybillDetails.stream()
|
|
||||||
.map(detail -> detail.getApplyMoney() != null ? detail.getApplyMoney() : BigDecimal.ZERO)
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
// 计算该运单的总已收金额
|
|
||||||
BigDecimal totalReceivedMoney = waybillDetails.stream()
|
|
||||||
.map(detail -> detail.getEmisSettleSubBill() != null
|
|
||||||
&& detail.getEmisSettleSubBill().getRecedMoney() != null
|
|
||||||
? detail.getEmisSettleSubBill().getRecedMoney()
|
|
||||||
: BigDecimal.ZERO)
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
||||||
|
|
||||||
// 获取运单运费
|
// 获取运单运费
|
||||||
BigDecimal waybillFreight = firstDetail.getEmisWaybill().getFreight() != null
|
BigDecimal waybillFreight = firstDetail.getEmisWaybill().getFreight() != null
|
||||||
? firstDetail.getEmisWaybill().getFreight()
|
? firstDetail.getEmisWaybill().getFreight()
|
||||||
: BigDecimal.ZERO;
|
: BigDecimal.ZERO;
|
||||||
|
|
||||||
// 更新运单付款状态
|
// 对每个运单明细单独计算并更新付款状态
|
||||||
EmisWaybill updateWaybill = new EmisWaybill();
|
for (EmisWriteoffApplyDetail detail : waybillDetails) {
|
||||||
updateWaybill.setBillCode(billCode);
|
// 计算该明细的申请金额
|
||||||
|
BigDecimal applyMoney = detail.getApplyMoney() != null ? detail.getApplyMoney()
|
||||||
|
: BigDecimal.ZERO;
|
||||||
|
|
||||||
if (isPass) {
|
// 计算该明细的已收金额
|
||||||
// 审核通过:申请金额 + 已收金额 与运单金额比较
|
BigDecimal receivedMoney = detail.getEmisSettleSubBill() != null
|
||||||
BigDecimal totalAmount = totalApplyMoney.add(totalReceivedMoney);
|
&& detail.getEmisSettleSubBill().getRecedMoney() != null
|
||||||
if (totalAmount.compareTo(BigDecimal.ZERO) == 0) {
|
? detail.getEmisSettleSubBill().getRecedMoney()
|
||||||
updateWaybill.setPaymentStatus("0"); // 未付款
|
: BigDecimal.ZERO;
|
||||||
} else if (totalAmount.compareTo(waybillFreight) >= 0) {
|
|
||||||
updateWaybill.setPaymentStatus("1"); // 已付款
|
// 更新运单付款状态
|
||||||
|
EmisWaybill updateWaybill = new EmisWaybill();
|
||||||
|
updateWaybill.setBillCode(billCode);
|
||||||
|
|
||||||
|
if (isPass) {
|
||||||
|
// 审核通过:申请金额 + 已收金额 与运单金额比较
|
||||||
|
BigDecimal totalAmount = applyMoney.add(receivedMoney);
|
||||||
|
if (totalAmount.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
updateWaybill.setPaymentStatus("0"); // 未付款
|
||||||
|
} else if (totalAmount.compareTo(waybillFreight) >= 0) {
|
||||||
|
updateWaybill.setPaymentStatus("1"); // 已付款
|
||||||
|
} else {
|
||||||
|
updateWaybill.setPaymentStatus("2"); // 部分付款
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
updateWaybill.setPaymentStatus("2"); // 部分付款
|
// 审核驳回:只考虑已收金额与运单金额比较
|
||||||
}
|
if (receivedMoney.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
} else {
|
updateWaybill.setPaymentStatus("0"); // 未付款
|
||||||
// 审核驳回:申请金额 + 已收金额 与运单金额比较
|
} else if (receivedMoney.compareTo(waybillFreight) >= 0) {
|
||||||
BigDecimal totalAmount = totalReceivedMoney; // 驳回时只考虑已收金额
|
updateWaybill.setPaymentStatus("1"); // 已付款
|
||||||
if (totalAmount.compareTo(BigDecimal.ZERO) == 0) {
|
} else {
|
||||||
updateWaybill.setPaymentStatus("0"); // 未付款
|
updateWaybill.setPaymentStatus("2"); // 部分付款
|
||||||
} else if (totalAmount.compareTo(waybillFreight) >= 0) {
|
}
|
||||||
updateWaybill.setPaymentStatus("1"); // 已付款
|
|
||||||
} else {
|
|
||||||
updateWaybill.setPaymentStatus("2"); // 部分付款
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新运单付款状态
|
||||||
|
emisWaybillMapper.updatePayedStatus(updateWaybill);
|
||||||
|
|
||||||
|
log.info("运单付款状态更新成功,运单号: {}, 明细ID: {}, 付款状态: {}, 申请金额: {}, 已收金额: {}, 运单运费: {}",
|
||||||
|
billCode, detail.getId(), updateWaybill.getPaymentStatus(), applyMoney, receivedMoney,
|
||||||
|
waybillFreight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新运单付款状态
|
|
||||||
emisWaybillMapper.updatePayedStatus(updateWaybill);
|
|
||||||
|
|
||||||
log.info("运单付款状态更新成功,运单号: {}, 付款状态: {}, 申请金额: {}, 已收金额: {}, 运单运费: {}",
|
|
||||||
billCode, updateWaybill.getPaymentStatus(), totalApplyMoney, totalReceivedMoney,
|
|
||||||
waybillFreight);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("更新运单付款状态失败,运单号: {}", billCode, e);
|
log.error("更新运单付款状态失败,运单号: {}", billCode, e);
|
||||||
// 继续处理其他运单,不抛出异常
|
// 继续处理其他运单,不抛出异常
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user