| | |
| | | ,Constants.YwLogType.CONTRACT_UPDATE.getKey()) |
| | | .orderByAsc(YwWorkorderLog::getCreateDate))); |
| | | |
| | | //查询账单集合 |
| | | model.setBillList(ywContractBillMapper.selectJoinList(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>() |
| | | .selectAll(YwContractBill.class ) |
| | | .select(" ( select ifnull(sum(case when yw.REVENUE_TYPE = 0 then yw.ACT_RECEIVABLE_FEE else -yw.ACT_RECEIVABLE_FEE end),0) from yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as actReceivableFee ") |
| | | .eq( YwContractBill::getContractId,model.getId()) |
| | | .eq(YwContractBill::getIsdeleted,Constants.ZERO) |
| | | .orderByAsc(YwContractBill::getSortnum,YwContractBill::getCreateDate))); |
| | | queryBillListByModel(model,new Date()); |
| | | } |
| | | return model; |
| | | } |
| | | @Override |
| | | public YwContract findForBills(YwContract model) { |
| | | queryBillListByModel(model,model.getBtDate()); |
| | | return model; |
| | | |
| | | for (YwContractBill ywContractBill:model.getBillList()) { |
| | | ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee())); |
| | | } |
| | | } |
| | | private void queryBillListByModel(YwContract model,Date date) { |
| | | //查询账单集合 |
| | | model.setBillList(ywContractBillMapper.selectJoinList(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>() |
| | | .selectAll(YwContractBill.class ) |
| | | .select(" ( select ifnull(sum(case when yw.REVENUE_TYPE = 0 then yw.ACT_RECEIVABLE_FEE else -yw.ACT_RECEIVABLE_FEE end),0) from yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as actReceivableFee ") |
| | | .eq( YwContractBill::getContractId,model.getId()) |
| | | .eq(YwContractBill::getIsdeleted,Constants.ZERO) |
| | | .orderByAsc(YwContractBill::getSortnum,YwContractBill::getCreateDate))); |
| | | |
| | | model.setCanBackRentBills(new ArrayList<>()); |
| | | long nowStart = Utils.Date.getStart(new Date()).getTime(); |
| | | long nowEnd = Utils.Date.getEnd(new Date()).getTime(); |
| | | if(model.getBillList()!=null && model.getBillList().size()>0){ |
| | | for(YwContractBill bill: model.getBillList()){ |
| | | //付款状态:0=待收款;1=已结清;2=部分结清;3=待付款;4=待退款;5=已关闭 |
| | | if(Constants.equalsInteger(bill.getPayStatus(),Constants.ZERO) |
| | | ||Constants.equalsInteger(bill.getPayStatus(),Constants.THREE)){ |
| | | if(bill.getStartDate().getTime()>nowEnd){ |
| | | //如果还没开始,账单直接关闭 |
| | | continue; |
| | | } |
| | | model.getCanBackRentBills().add(bill); |
| | | |
| | | }else if(Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){ |
| | | if(bill.getEndDate().getTime()<nowStart){ |
| | | //如果已结清,账单直接关闭 |
| | | continue; |
| | | } |
| | | model.getCanBackRentBills().add(bill); |
| | | }else if(Constants.equalsInteger(bill.getPayStatus(),Constants.TWO) ){ |
| | | model.getCanBackRentBills().add(bill); |
| | | for (YwContractBill ywContractBill:model.getBillList()) { |
| | | ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee())); |
| | | } |
| | | model.setCanBackRentBills(new ArrayList<>()); |
| | | long nowStart = Utils.Date.getStart(date).getTime(); |
| | | long nowEnd = Utils.Date.getEnd(date).getTime(); |
| | | if(model.getBillList()!=null && model.getBillList().size()>0){ |
| | | for(YwContractBill bill: model.getBillList()){ |
| | | //付款状态:0=待收款;1=已结清;2=部分结清;3=待付款;4=待退款;5=已关闭 |
| | | if(Constants.equalsInteger(bill.getPayStatus(),Constants.ZERO) |
| | | ||Constants.equalsInteger(bill.getPayStatus(),Constants.THREE)){ |
| | | if(bill.getStartDate().getTime()>nowEnd){ |
| | | //如果还没开始,账单直接关闭 |
| | | continue; |
| | | } |
| | | model.getCanBackRentBills().add(bill); |
| | | |
| | | }else if(Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){ |
| | | if(bill.getEndDate().getTime()<nowStart){ |
| | | //如果已结清,账单直接关闭 |
| | | continue; |
| | | } |
| | | model.getCanBackRentBills().add(bill); |
| | | }else if(Constants.equalsInteger(bill.getPayStatus(),Constants.TWO) ){ |
| | | model.getCanBackRentBills().add(bill); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | return model; |
| | | } |
| | | |
| | | @Override |