| | |
| | | package com.ruoyi.cwgl.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | estimatedReceivable.setCreateTime(nowDate); |
| | | estimatedReceivable.setFeeSystemNo("YF"+datePart+ RandomUtils.random(5)); |
| | | estimatedReceivable.setFeeType(0); |
| | | PendingSettlementBusiness pendingSettlementBusiness = pendingSettlementBusinessMapper.selectPendingSettlementBusinessByNo(estimatedReceivable.getDispatchNo()); |
| | | if (pendingSettlementBusiness == null){ |
| | | throw new ServiceException("调度单不存在"); |
| | | |
| | | } |
| | | Integer relatedBillStatus = pendingSettlementBusiness.getRelatedBillStatus(); |
| | | if (relatedBillStatus.equals(2)||relatedBillStatus.equals(3)){ |
| | | throw new ServiceException("当前调度单已结算或部分结算无法新增明细"); |
| | | } |
| | | return estimatedReceivableMapper.insertEstimatedReceivable(estimatedReceivable); |
| | | } |
| | | |
| | |
| | | throw new ServiceException("结算中或已结算无法修改"); |
| | | } |
| | | //原本金额 |
| | | Long oldAmount = estimatedReceivable1.getEstimatedAmount(); |
| | | BigDecimal oldAmount = estimatedReceivable1.getEstimatedAmount(); |
| | | //新金额 |
| | | Long newAmount = estimatedReceivable.getEstimatedAmount(); |
| | | BigDecimal newAmount = estimatedReceivable.getEstimatedAmount(); |
| | | if (!oldAmount.equals(newAmount)) { |
| | | |
| | | PendingSettlementBusiness pendingSettlementBusiness = pendingSettlementBusinessMapper.selectPendingSettlementBusinessByNo(estimatedReceivable.getDispatchNo()); |
| | | if (pendingSettlementBusiness!=null) { |
| | | Long estimatedTotalIncome = pendingSettlementBusiness.getEstimatedTotalIncome(); |
| | | pendingSettlementBusiness.setEstimatedTotalIncome(estimatedTotalIncome-oldAmount+newAmount); |
| | | BigDecimal estimatedTotalIncome = pendingSettlementBusiness.getEstimatedTotalIncome(); |
| | | pendingSettlementBusiness.setEstimatedTotalIncome(estimatedTotalIncome.subtract(oldAmount).add(newAmount)); |
| | | pendingSettlementBusinessMapper.updatePendingSettlementBusiness(pendingSettlementBusiness); |
| | | if (pendingSettlementBusiness.getBillId() != null) { |
| | | EstimatedReceivableBill estimatedReceivableBill = estimatedReceivableBillMapper.selectEstimatedReceivableBillById(pendingSettlementBusiness.getBillId()); |
| | | estimatedReceivableBill.setTotalAmount(estimatedReceivableBill.getTotalAmount() -oldAmount + newAmount); |
| | | estimatedReceivableBill.setTotalAmount(estimatedReceivableBill.getTotalAmount().subtract( oldAmount).add( newAmount)); |
| | | estimatedReceivableBillMapper.updateEstimatedReceivableBill(estimatedReceivableBill); |
| | | } |
| | | } |
| | |
| | | throw new ServiceException("无需重复确认"); |
| | | |
| | | } |
| | | PendingSettlementBusiness pendingSettlementBusiness = pendingSettlementBusinessMapper.selectPendingSettlementBusinessByNo(estimatedReceivable.getDispatchNo()); |
| | | if (pendingSettlementBusiness == null){ |
| | | throw new ServiceException("调度单不存在"); |
| | | |
| | | } |
| | | Integer relatedBillStatus = pendingSettlementBusiness.getRelatedBillStatus(); |
| | | if (relatedBillStatus.equals(2)||relatedBillStatus.equals(3)){ |
| | | throw new ServiceException("当前调度单已结算或部分结算无法确认"); |
| | | } |
| | | if (pendingSettlementBusiness.getBillId()!=null){ |
| | | EstimatedReceivableBill estimatedReceivableBill = estimatedReceivableBillMapper.selectEstimatedReceivableBillById(pendingSettlementBusiness.getBillId()); |
| | | BigDecimal totalAmount = estimatedReceivableBill.getTotalAmount(); |
| | | estimatedReceivableBill.setTotalAmount(totalAmount.add(estimatedReceivable.getEstimatedAmount())); |
| | | estimatedReceivableBillMapper.updateEstimatedReceivableBill(estimatedReceivableBill); |
| | | } |
| | | String username = SecurityUtils.getUsername(); |
| | | |
| | | logService.insertEstimatedReceivableLog("确认应收",id,username); |
| | |
| | | throw new ServiceException("无需重复取消"); |
| | | |
| | | } |
| | | PendingSettlementBusiness pendingSettlementBusiness = pendingSettlementBusinessMapper.selectPendingSettlementBusinessByNo(estimatedReceivable.getDispatchNo()); |
| | | if (pendingSettlementBusiness == null){ |
| | | throw new ServiceException("调度单不存在"); |
| | | |
| | | } |
| | | Integer relatedBillStatus = pendingSettlementBusiness.getRelatedBillStatus(); |
| | | if (relatedBillStatus.equals(2)||relatedBillStatus.equals(3)){ |
| | | throw new ServiceException("当前调度单已结算或部分结算无法取消"); |
| | | } |
| | | if (pendingSettlementBusiness.getBillId()!=null){ |
| | | EstimatedReceivableBill estimatedReceivableBill = estimatedReceivableBillMapper.selectEstimatedReceivableBillById(pendingSettlementBusiness.getBillId()); |
| | | BigDecimal totalAmount = estimatedReceivableBill.getTotalAmount(); |
| | | estimatedReceivableBill.setTotalAmount(totalAmount.subtract(estimatedReceivable.getEstimatedAmount())); |
| | | estimatedReceivableBillMapper.updateEstimatedReceivableBill(estimatedReceivableBill); |
| | | } |
| | | String username = SecurityUtils.getUsername(); |
| | | |
| | | logService.insertEstimatedReceivableLog("取消应收",id,username); |
| | | estimatedReceivable.setIsConfirmed(0); |
| | | |
| | | return estimatedReceivableMapper.updateEstimatedReceivable(estimatedReceivable); |
| | | } |
| | | |