This commit is contained in:
linfso 2025-05-16 17:17:46 +08:00
parent 7edad142c1
commit 2c9ef3a359
2 changed files with 83 additions and 50 deletions

View File

@ -304,7 +304,6 @@ public class EmisSettleBillController extends BaseController
}
/**
* 新增运单总账单
*/

View File

@ -761,11 +761,8 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
// 获取收款记录
List<EmisSettlePayRecord> payRecordList=emisSettlePayRecordMapper.selectSettlePayRecordListBySettleBillNo(settleBillNo);
// 全部收款金额
BigDecimal totalAllPayMoney = BigDecimal.ZERO;
// 计算已收款金额
BigDecimal totalPayMoney = BigDecimal.ZERO;
BigDecimal totalHasPayMoney = BigDecimal.ZERO;
// 抵扣金额
BigDecimal satisfyMoney = BigDecimal.ZERO;
@ -782,9 +779,8 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
log.debug("reCalcSettleBillPayStatus===>应收:{}",oldBill.getRecMoney());
for(EmisSettlePayRecord item:payRecordList){
if("1".equals(item.getRecType())) {
totalPayMoney = totalPayMoney.add(item.getPayMoney());
totalHasPayMoney = totalHasPayMoney.add(item.getPayMoney());
satisfyMoney = satisfyMoney.add(item.getSatisfyMoney() == null ? BigDecimal.ZERO : item.getSatisfyMoney());
allowanceMoney = allowanceMoney.add(item.getAllowanceMoney() == null ? BigDecimal.ZERO : item.getAllowanceMoney());
deductionMoney = deductionMoney.add(item.getDeductionMoney() == null ? BigDecimal.ZERO : item.getDeductionMoney());
@ -795,54 +791,13 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
}
}
// 总应收金额
log.debug("reCalcSettleBillPayStatus===>totalPayMoney:{},satisfyMoney:{},allowanceMoney:{},deductionMoney:{},otherMoney:{}"
,totalPayMoney,satisfyMoney,allowanceMoney,allowanceMoney,deductionMoney,otherMoney);
// 收款金额-退款金额
totalAllPayMoney=totalAllPayMoney
.add(totalPayMoney)
.add(satisfyMoney)
.add(allowanceMoney)
.add(deductionMoney)
.add(otherMoney)
.subtract(refundMoney)
;
EmisSettleBill newBill = new EmisSettleBill();
newBill.setId(oldBill.getId());
newBill.setRecedMoney(totalPayMoney.subtract(refundMoney));
newBill.setSatisfyMoney(satisfyMoney);
newBill.setAllowanceMoney(allowanceMoney);
newBill.setOtherMoney(otherMoney);
// 退款金额
newBill.setRefundMoney(refundMoney);
// 更新账单收款状态 收款金额
int rstDif=totalAllPayMoney.compareTo(oldBill.getRecMoney());
log.debug("reCalcSettleBillPayStatus===>收款金额:{},应收:{}",totalAllPayMoney,oldBill.getRecMoney());
if( totalAllPayMoney.compareTo(BigDecimal.ZERO) == 0 ){
newBill.setPaymentStatus("0");
}else{
if( rstDif >= 0 ){
// 已收款
newBill.setPaymentStatus("1");
emisSettleBillMapper.updateEmisSettleBill(newBill);
}
else{
// 部分收款
newBill.setPaymentStatus("2");
emisSettleBillMapper.updateEmisSettleBill(newBill);
}
}
emisSettleBillMapper.updateEmisSettleBill(newBill);
// 更新运单的收款状态
if(totalAllPayMoney.compareTo(BigDecimal.ZERO) > 0){
if(totalHasPayMoney.compareTo(BigDecimal.ZERO) > 0){
BigDecimal totalMoney = BigDecimal.ZERO;
// 更新运单收款记录
List<Map> listRel=emisSettlePayRelMapper.selectHasPayMapList(settleBillNo);
if(!CollectionUtils.isEmpty(listRel)) {
for(Map item:listRel){
String billNo= MapUtils.getString(item,"billNo",null);
@ -896,9 +851,88 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
// emisBizError.printStackTrace();
// }
}
// 全部收款金额
BigDecimal totalAllPayMoney = BigDecimal.ZERO;
// 收款金额-退款金额
totalAllPayMoney=totalMoney
.add(satisfyMoney)
.add(allowanceMoney)
.add(deductionMoney)
.add(otherMoney)
.subtract(refundMoney);
EmisSettleBill newBill = new EmisSettleBill();
newBill.setId(oldBill.getId());
newBill.setRecedMoney(totalMoney);
newBill.setSatisfyMoney(satisfyMoney);
newBill.setAllowanceMoney(allowanceMoney);
newBill.setOtherMoney(otherMoney);
// 退款金额
newBill.setRefundMoney(refundMoney);
// 更新账单收款状态 收款金额
int rstDif=totalMoney.compareTo(oldBill.getRecMoney());
log.debug("reCalcSettleBillPayStatus===>收款金额:{},应收:{}",totalMoney,oldBill.getRecMoney());
if( totalAllPayMoney.compareTo(BigDecimal.ZERO) == 0 ){
newBill.setPaymentStatus("0");
}else{
if( rstDif >= 0 ){
// 已收款
newBill.setPaymentStatus("1");
emisSettleBillMapper.updateEmisSettleBill(newBill);
}
else{
// 部分收款
newBill.setPaymentStatus("2");
emisSettleBillMapper.updateEmisSettleBill(newBill);
}
}
emisSettleBillMapper.updateEmisSettleBill(newBill);
}
}
else{
// 全部收款金额
BigDecimal totalAllPayMoney = BigDecimal.ZERO;
BigDecimal totalMoney = BigDecimal.ZERO;
// 收款金额-退款金额
totalAllPayMoney=totalMoney
.add(satisfyMoney)
.add(allowanceMoney)
.add(deductionMoney)
.add(otherMoney)
.subtract(refundMoney);
EmisSettleBill newBill = new EmisSettleBill();
newBill.setId(oldBill.getId());
newBill.setRecedMoney(totalMoney);
newBill.setSatisfyMoney(satisfyMoney);
newBill.setAllowanceMoney(allowanceMoney);
newBill.setOtherMoney(otherMoney);
// 退款金额
newBill.setRefundMoney(refundMoney);
// 更新账单收款状态 收款金额
int rstDif=totalMoney.compareTo(oldBill.getRecMoney());
log.debug("reCalcSettleBillPayStatus===>收款金额:{},应收:{}",totalMoney,oldBill.getRecMoney());
if( totalAllPayMoney.compareTo(BigDecimal.ZERO) == 0 ){
newBill.setPaymentStatus("0");
}else{
if( rstDif >= 0 ){
// 已收款
newBill.setPaymentStatus("1");
emisSettleBillMapper.updateEmisSettleBill(newBill);
}
else{
// 部分收款
newBill.setPaymentStatus("2");
emisSettleBillMapper.updateEmisSettleBill(newBill);
}
}
emisSettleBillMapper.updateEmisSettleBill(newBill);
// 未收款则更新运单状态未收款状态
List<EmisSettleSubBill> list = emisBaseService.selectSubBillListBySettleBillNo(settleBillNo);
if (!CollectionUtils.isEmpty(list)) {