From e0cc9278a0bcbf480446f87a78b9d7ddd8819eeb Mon Sep 17 00:00:00 2001 From: sen <sen@qq.com> Date: 星期一, 18 八月 2025 11:32:43 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/yagwly_fa_master' into yagwly_fa_master --- service/src/main/java/com/ruoyi/cwgl/service/impl/EstimatedReceivableServiceImpl.java | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 153 insertions(+), 2 deletions(-) diff --git a/service/src/main/java/com/ruoyi/cwgl/service/impl/EstimatedReceivableServiceImpl.java b/service/src/main/java/com/ruoyi/cwgl/service/impl/EstimatedReceivableServiceImpl.java index 765e21a..564fa6a 100644 --- a/service/src/main/java/com/ruoyi/cwgl/service/impl/EstimatedReceivableServiceImpl.java +++ b/service/src/main/java/com/ruoyi/cwgl/service/impl/EstimatedReceivableServiceImpl.java @@ -1,9 +1,23 @@ package com.ruoyi.cwgl.service.impl; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DateUtils; import javax.annotation.Resource; + +import com.ruoyi.common.utils.RandomUtils; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.cwgl.domain.EstimatedReceivableBill; +import com.ruoyi.cwgl.domain.PendingSettlementBusiness; +import com.ruoyi.cwgl.mapper.EstimatedReceivableBillMapper; +import com.ruoyi.cwgl.mapper.EstimatedReceivableLogMapper; +import com.ruoyi.cwgl.mapper.PendingSettlementBusinessMapper; +import com.ruoyi.cwgl.service.IEstimatedReceivableLogService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.stereotype.Service; import org.springframework.scheduling.annotation.Async; @@ -33,7 +47,12 @@ protected final Logger logger = LoggerFactory.getLogger(getClass()); @Resource private EstimatedReceivableMapper estimatedReceivableMapper; - + @Autowired + private IEstimatedReceivableLogService logService; + @Resource + private PendingSettlementBusinessMapper pendingSettlementBusinessMapper; + @Resource + private EstimatedReceivableBillMapper estimatedReceivableBillMapper; /** * 鏌ヨ棰勪及搴旀敹绠$悊 @@ -102,7 +121,22 @@ @Override public int insertEstimatedReceivable(EstimatedReceivable estimatedReceivable) { - estimatedReceivable.setCreateTime(DateUtils.getNowDate()); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd"); + + Date nowDate = DateUtils.getNowDate(); + String datePart = dateFormat.format(nowDate); + 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); } @@ -128,7 +162,32 @@ @Override public int updateEstimatedReceivable(EstimatedReceivable estimatedReceivable) { + Integer id = estimatedReceivable.getId(); + EstimatedReceivable estimatedReceivable1 = estimatedReceivableMapper.selectEstimatedReceivableById(id); + if (estimatedReceivable1.getRelatedBillStatus().equals(2)||estimatedReceivable1.getRelatedBillStatus().equals(3)){ + throw new ServiceException("缁撶畻涓垨宸茬粨绠楁棤娉曚慨鏀�"); + } + //鍘熸湰閲戦 + BigDecimal oldAmount = estimatedReceivable1.getEstimatedAmount(); + //鏂伴噾棰� + BigDecimal newAmount = estimatedReceivable.getEstimatedAmount(); + if (!oldAmount.equals(newAmount)) { + + PendingSettlementBusiness pendingSettlementBusiness = pendingSettlementBusinessMapper.selectPendingSettlementBusinessByNo(estimatedReceivable.getDispatchNo()); + if (pendingSettlementBusiness!=null) { + 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().subtract( oldAmount).add( newAmount)); + estimatedReceivableBillMapper.updateEstimatedReceivableBill(estimatedReceivableBill); + } + } + } estimatedReceivable.setUpdateTime(DateUtils.getNowDate()); + String username = SecurityUtils.getUsername(); + logService.insertEstimatedReceivableLog("淇敼搴旀敹",estimatedReceivable.getId(),username); return estimatedReceivableMapper.updateEstimatedReceivable(estimatedReceivable); } @@ -179,4 +238,96 @@ { return estimatedReceivableMapper.deleteEstimatedReceivableById(id); } + + @Override + public int confirm(Integer id) { + EstimatedReceivable estimatedReceivable = estimatedReceivableMapper.selectEstimatedReceivableById(id); + if (estimatedReceivable==null){ + throw new ServiceException("鏁版嵁涓嶅瓨鍦�"); + } + if (estimatedReceivable.getIsConfirmed().equals(2)) { + throw new ServiceException("璇ユ暟鎹凡浣滃簾"); + + } + if (estimatedReceivable.getIsConfirmed().equals(1)) { + 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); + estimatedReceivable.setIsConfirmed(1); + estimatedReceivable.setConfirmBy(username); + estimatedReceivable.setConfirmTime(new Date()); + return estimatedReceivableMapper.updateEstimatedReceivable(estimatedReceivable); + } + + @Override + public int cancel(Integer id) { + EstimatedReceivable estimatedReceivable = estimatedReceivableMapper.selectEstimatedReceivableById(id); + if (estimatedReceivable==null){ + throw new ServiceException("鏁版嵁涓嶅瓨鍦�"); + } + if (estimatedReceivable.getIsConfirmed().equals(2)) { + throw new ServiceException("璇ユ暟鎹凡浣滃簾"); + + } + if (estimatedReceivable.getIsConfirmed().equals(0)) { + 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); + } + + @Override + public int invalid(Integer id) { + EstimatedReceivable estimatedReceivable = estimatedReceivableMapper.selectEstimatedReceivableById(id); + if (estimatedReceivable==null){ + throw new ServiceException("鏁版嵁涓嶅瓨鍦�"); + } + if (estimatedReceivable.getIsConfirmed().equals(2)) { + throw new ServiceException("鏃犻渶閲嶅浣滃簾"); + + } + String username = SecurityUtils.getUsername(); + + logService.insertEstimatedReceivableLog("浣滃簾搴旀敹",id,username); + estimatedReceivable.setIsConfirmed(2); + return estimatedReceivableMapper.updateEstimatedReceivable(estimatedReceivable); + } } -- Gitblit v1.8.0