| | |
| | | package com.ruoyi.cwgl.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.common.utils.DateUtils; |
| | |
| | | |
| | | import com.ruoyi.cwgl.mapper.InvoiceManageMapper; |
| | | import com.ruoyi.cwgl.domain.InvoiceManage; |
| | | import com.ruoyi.cwgl.domain.InvoiceManageLog; |
| | | import com.ruoyi.cwgl.service.IInvoiceManageService; |
| | | import com.ruoyi.cwgl.service.IInvoiceManageLogService; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | |
| | | /** |
| | |
| | | protected final Logger logger = LoggerFactory.getLogger(getClass()); |
| | | @Resource |
| | | private InvoiceManageMapper invoiceManageMapper; |
| | | |
| | | @Resource |
| | | private IInvoiceManageLogService invoiceManageLogService; |
| | | |
| | | |
| | | /** |
| | |
| | | invoiceManage.setCreateTime(DateUtils.getNowDate()); |
| | | int rows = invoiceManageMapper.insertInvoiceManage(invoiceManage); |
| | | insertInvoiceDetail(invoiceManage); |
| | | |
| | | // 记录新增发票管理日志 |
| | | if (rows > 0) { |
| | | recordInvoiceManageLog(invoiceManage, "新增发票管理"); |
| | | } |
| | | |
| | | return rows; |
| | | } |
| | | |
| | |
| | | public int insertInvoiceManageBatch(List<InvoiceManage> invoiceManages) |
| | | { |
| | | int rows = invoiceManageMapper.insertInvoiceManageBatch(invoiceManages); |
| | | |
| | | // 记录批量新增发票管理日志 |
| | | if (rows > 0 && invoiceManages != null && !invoiceManages.isEmpty()) { |
| | | for (InvoiceManage invoiceManage : invoiceManages) { |
| | | recordInvoiceManageLog(invoiceManage, "批量新增发票管理"); |
| | | } |
| | | } |
| | | |
| | | return rows; |
| | | } |
| | | |
| | |
| | | public int updateInvoiceManage(InvoiceManage invoiceManage) |
| | | { |
| | | invoiceManage.setUpdateTime(DateUtils.getNowDate()); |
| | | invoiceManageMapper.deleteInvoiceDetailByInvoiceManageId(invoiceManage.getId()); |
| | | insertInvoiceDetail(invoiceManage); |
| | | return invoiceManageMapper.updateInvoiceManage(invoiceManage); |
| | | // invoiceManageMapper.deleteInvoiceDetailByInvoiceManageId(invoiceManage.getId()); |
| | | // insertInvoiceDetail(invoiceManage); |
| | | int rows = invoiceManageMapper.updateInvoiceManage(invoiceManage); |
| | | |
| | | // 记录修改发票管理日志 |
| | | if (rows > 0) { |
| | | recordInvoiceManageLog(invoiceManage, "修改发票管理"); |
| | | } |
| | | |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int updateInvoiceManageBatch(List<InvoiceManage> invoiceManages){ |
| | | return invoiceManageMapper.updateInvoiceManageBatch(invoiceManages); |
| | | int rows = invoiceManageMapper.updateInvoiceManageBatch(invoiceManages); |
| | | |
| | | // 记录批量修改发票管理日志 |
| | | if (rows > 0 && invoiceManages != null && !invoiceManages.isEmpty()) { |
| | | for (InvoiceManage invoiceManage : invoiceManages) { |
| | | recordInvoiceManageLog(invoiceManage, "批量修改发票管理"); |
| | | } |
| | | } |
| | | |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | |
| | | for (InvoiceDetail invoiceDetail : invoiceDetailList) |
| | | { |
| | | invoiceDetail.setInvoiceManageId(id); |
| | | invoiceDetail.setCreateTime(new Date()); |
| | | list.add(invoiceDetail); |
| | | } |
| | | if (list.size() > 0) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 记录发票管理操作日志 |
| | | * |
| | | * @param invoiceManage 发票管理对象 |
| | | * @param operationType 操作类型 |
| | | */ |
| | | private void recordInvoiceManageLog(InvoiceManage invoiceManage, String operationType) |
| | | { |
| | | try { |
| | | InvoiceManageLog log = new InvoiceManageLog(); |
| | | log.setInvoiceManageId(invoiceManage.getId()); |
| | | log.setOperator(invoiceManage.getCreateBy()); |
| | | log.setOperationTime(DateUtils.getNowDate()); |
| | | |
| | | // 构建操作描述,包含开票金额、关联账单编号和对应开票金额 |
| | | StringBuilder descBuilder = new StringBuilder(); |
| | | descBuilder.append(operationType).append(": "); |
| | | |
| | | if (invoiceManage.getInvoiceAmount() != null) { |
| | | descBuilder.append("开票金额=").append(invoiceManage.getInvoiceAmount()).append("; "); |
| | | } |
| | | |
| | | // 获取关联账单信息 |
| | | if (invoiceManage.getInvoiceDetailList() != null && !invoiceManage.getInvoiceDetailList().isEmpty()) { |
| | | descBuilder.append("关联账单信息: "); |
| | | for (InvoiceDetail detail : invoiceManage.getInvoiceDetailList()) { |
| | | if (detail.getReceivableBillNo() != null) { |
| | | descBuilder.append("账单编号=").append(detail.getReceivableBillNo()); |
| | | } |
| | | if (detail.getCurrentBilledAmount() != null) { |
| | | descBuilder.append(", 本次开票金额=").append(detail.getCurrentBilledAmount()); |
| | | } |
| | | descBuilder.append("; "); |
| | | } |
| | | } |
| | | |
| | | log.setOperationDesc(descBuilder.toString()); |
| | | log.setCreateTime(DateUtils.getNowDate()); |
| | | |
| | | invoiceManageLogService.insertInvoiceManageLog(log); |
| | | } catch (Exception e) { |
| | | logger.error("记录发票管理操作日志失败: {}", e.getMessage()); |
| | | } |
| | | } |
| | | } |