|  |  |  | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | YwContractBill ywContractBill = ywContractBillMapper.selectById(ywContractRevenue.getBillId()); | 
|---|
|  |  |  | YwContractBill ywContractBill = ywContractBillMapper.selectJoinOne(YwContractBill.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<YwContractBill>() | 
|---|
|  |  |  | .selectAll(YwContractBill.class) | 
|---|
|  |  |  | .selectAs(YwContract::getStatus, YwContractBill::getContractStatus) | 
|---|
|  |  |  | .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId) | 
|---|
|  |  |  | .eq(YwContractBill::getId,ywContractRevenue.getBillId())); | 
|---|
|  |  |  | if(Objects.isNull(ywContractBill)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到账单信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | ywContractRevenueMapper.insert(ywContractRevenue); | 
|---|
|  |  |  | ywContractBillMapper.updateById(ywContractBill); | 
|---|
|  |  |  | //如果账单完结,则查询合同下开启中的账单是否存在退款中 如果不存在则标记合同已退款 | 
|---|
|  |  |  | if(Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.ONE)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(ywContractBill.getContractStatus(),Constants.THREE) | 
|---|
|  |  |  | && Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.ONE)){ | 
|---|
|  |  |  | if( ywContractBillMapper | 
|---|
|  |  |  | .selectCount(new QueryWrapper<YwContractBill>().lambda().eq(YwContractBill::getContractId,ywContractBill.getContractId()) | 
|---|
|  |  |  | .ne(YwContractBill::getId,ywContractBill.getId()) | 
|---|