| | |
| | | package com.ruoyi.cwgl.service.impl; |
| | | |
| | | 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.SecurityUtils; |
| | | import com.ruoyi.cwgl.domain.EstimatedReceivableBill; |
| | | import com.ruoyi.cwgl.mapper.EstimatedReceivableLogMapper; |
| | | 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; |
| | |
| | | protected final Logger logger = LoggerFactory.getLogger(getClass()); |
| | | @Resource |
| | | private EstimatedReceivableMapper estimatedReceivableMapper; |
| | | |
| | | @Autowired |
| | | private IEstimatedReceivableLogService logService; |
| | | |
| | | /** |
| | | * 查询预估应收管理 |
| | |
| | | @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("结算中或已结算无法修改"); |
| | | } |
| | | estimatedReceivable.setUpdateTime(DateUtils.getNowDate()); |
| | | String username = SecurityUtils.getUsername(); |
| | | logService.insertEstimatedReceivableLog("修改应收",estimatedReceivable.getId(),username); |
| | | return estimatedReceivableMapper.updateEstimatedReceivable(estimatedReceivable); |
| | | } |
| | | |
| | |
| | | { |
| | | 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("无需重复确认"); |
| | | |
| | | } |
| | | 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("无需重复取消"); |
| | | |
| | | } |
| | | 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); |
| | | } |
| | | } |