shiyunteng
2026-06-11 45847670fea5d7354c2bfb4b53a321887271dcd4
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java
@@ -627,11 +627,12 @@
               }
            }
         }
         //更新合同开票状态
         contract.setBillingStatus("2");
         contract.setBillingAmout(contract.getBillingAmout().subtract(invoice.getInvoiceTotalPriceTax()));
         contractMapper.updateById(contract);
         //更新合同开票状态 前提出库完成
         if (StrUtil.equals(contract.getBillingStatus(),"3")) {
            contract.setBillingStatus("2");
            contract.setBillingAmout(contract.getBillingAmout().subtract(invoice.getInvoiceTotalPriceTax()));
            contractMapper.updateById(contract);
         }
         blueInvoice.setRedReversal("1");
         baseMapper.updateById(blueInvoice);
@@ -652,18 +653,25 @@
   @Override
   public void refuseApproval(Long id) {
      ContractInvoice invoice = baseMapper.selectById(id);
      //更新合同出库单状态
      String[] outBoundIds = invoice.getOutBoundId().split(",");
      Arrays.stream(outBoundIds).forEach(outBoundId -> {
         ContractOutBound bound = contractOutBoundMapper.selectById(outBoundId);
         bound.setInvoiceStatus("0");
         contractOutBoundMapper.updateById(bound);
      });
      invoice.setApprovalStatus("2");
      baseMapper.updateById(invoice);
      ContractInvoice blueInvoice = baseMapper.selectById(invoice.getBlueInvoiceId());
      blueInvoice.setRedReversal("0");
      baseMapper.updateById(blueInvoice);
      //蓝票
      if (invoice.getInvoiceCategory().equals("1")) {
         //更新合同出库单状态
         List<ContractOutBoundInvoiceVo> outBoundInvoiceVoList = BeanUtil.copyToList(JSONArray.parseArray(invoice.getInvoicePreviewParam()),ContractOutBoundInvoiceVo.class);
         if (ArrayUtil.isNotEmpty(outBoundInvoiceVoList.toArray())){
            outBoundInvoiceVoList.stream().forEach(contractOutBoundInvoiceVo -> {
               ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
               contractOutBound.setInvoiceNum(contractOutBound.getInvoiceNum().subtract(contractOutBoundInvoiceVo.getInvoiceNum()));
               contractOutBoundMapper.updateById(contractOutBound);
            });
         }
      }
      //红票
      if (invoice.getInvoiceCategory().equals("2")) {
         ContractInvoice blueInvoice = baseMapper.selectById(invoice.getBlueInvoiceId());
         blueInvoice.setRedReversal("0");
         baseMapper.updateById(blueInvoice);
      }
   }
}