wujianwei
2026-03-27 279366f14d6e1361b6caf7c05b74f0cea4227a36
service/src/main/java/com/ruoyi/cwgl/service/impl/PayableBillManagementServiceImpl.java
@@ -4,6 +4,11 @@
import com.ruoyi.common.utils.DateUtils;
import javax.annotation.Resource;
import com.ruoyi.cwgl.mapper.PayableFeeManagementMapper;
import com.ruoyi.cwgl.service.IPayableBillManagementLogService;
import com.ruoyi.cwgl.service.IPayableFeeManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import org.springframework.scheduling.annotation.Async;
@@ -17,8 +22,10 @@
import com.ruoyi.cwgl.mapper.PayableBillManagementMapper;
import com.ruoyi.cwgl.domain.PayableBillManagement;
import com.ruoyi.cwgl.domain.PayableBillManagementLog;
import com.ruoyi.cwgl.service.IPayableBillManagementService;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.SecurityUtils;
/**
 * 应付账单管理Service业务层处理
@@ -33,7 +40,10 @@
    protected final Logger logger = LoggerFactory.getLogger(getClass());
    @Resource
    private PayableBillManagementMapper payableBillManagementMapper;
    @Autowired
    private IPayableBillManagementLogService logService;
    @Resource
    private PayableFeeManagementMapper payableFeeManagementMapper;
    /**
     * 查询应付账单管理
@@ -129,7 +139,19 @@
    public int updatePayableBillManagement(PayableBillManagement payableBillManagement)
    {
        payableBillManagement.setUpdateTime(DateUtils.getNowDate());
        return payableBillManagementMapper.updatePayableBillManagement(payableBillManagement);
        int result = payableBillManagementMapper.updatePayableBillManagement(payableBillManagement);
        // 记录操作日志
        if (result > 0) {
            PayableBillManagementLog log = new PayableBillManagementLog();
            log.setBillId(payableBillManagement.getId());
            log.setCreateBy(SecurityUtils.getUsername());
            log.setCreateTime(DateUtils.getNowDate());
            log.setOperation("修改应付账单,账单编号:" + payableBillManagement.getSystemNo());
            logService.insertPayableBillManagementLog(log);
        }
        return result;
    }
    /**
@@ -182,7 +204,7 @@
    
    /**
     * 作废应付账单管理记录
     *
     *
     * @param id 应付账单管理ID
     * @return 结果
     */
@@ -204,6 +226,29 @@
        bill.setStatus("2");
        bill.setUpdateTime(DateUtils.getNowDate());
        
        return updatePayableBillManagement(bill);
        int result = updatePayableBillManagement(bill);
        if (result > 0) {
            // 作废应付账单后,需要将关联的应付费用记录恢复为待生成账单状态
            String relatedBillNo = bill.getSystemNo();
            if (relatedBillNo != null && !relatedBillNo.isEmpty()) {
                payableFeeManagementMapper.updatePayableFeeManagementByRelatedBillNo(relatedBillNo);
            }
        }
        return result;
    }
    /**
     * 根据系统编号查询应付账单管理
     *
     * @param systemNo 系统编号
     * @return 应付账单管理
     */
    @DataSource(DataSourceType.SLAVE)
    @Override
    public PayableBillManagement selectPayableBillManagementBySystemNo(String systemNo)
    {
        return payableBillManagementMapper.selectPayableBillManagementBySystemNo(systemNo);
    }
}