| | |
| | | BigDecimal fee = Constants.formatBigdecimal(model.getBtFee()); |
| | | String str = "退租摘要:剩余未结清账单{param1}份,关闭账单{param2}份【退租日{param3},退租费用合计需{param4}{param5}元。】"; |
| | | str = str.replace("{param1}",model.getBtWaitBill()+"") |
| | | .replace("{param2}",DateUtil.getDateLongSlash(model.getBtDate())) |
| | | .replace("{param3}",fee.compareTo(new BigDecimal(0)) >=0?"收":"付") |
| | | .replace("{param4}",(fee.compareTo(new BigDecimal(0)) >=0? |
| | | .replace("{param2}",model.getBtCLoseBill()+"") |
| | | .replace("{param3}",DateUtil.getDateLongSlash(model.getBtDate())) |
| | | .replace("{param4}",fee.compareTo(new BigDecimal(0)) >=0?"收":"付") |
| | | .replace("{param5}",(fee.compareTo(new BigDecimal(0)) >=0? |
| | | Constants.formatBigdecimal(model.getBtFee()).intValue() |
| | | :(Constants.formatBigdecimal(model.getBtFee()).intValue() * -1))+"" ); |
| | | return str; |
| | |
| | | } |
| | | @Override |
| | | public YwContract findById(Integer id) { |
| | | |
| | | YwContract model =queryDetailInfoById(id); |
| | | //查询操作日志记录 |
| | | YwWorkorderLog log = new YwWorkorderLog(); |
| | | log.setJobId(model.getId()); |
| | | log.setIsdeleted(Constants.ZERO); |
| | | model.setLogList(ywWorkorderLogMapper.selectList(new QueryWrapper<YwWorkorderLog>(log) |
| | | .lambda() |
| | | .in(YwWorkorderLog::getObjType,Constants.YwLogType.CONTRACT_BACK.getKey() |
| | | ,Constants.YwLogType.CONTRACT_CREATE.getKey() |
| | | ,Constants.YwLogType.CONTRACT_UPDATE.getKey()) |
| | | .orderByAsc(YwWorkorderLog::getCreateDate))); |
| | | |
| | | //查询账单集合 |
| | | queryBillListByModel(model,new Date()); |
| | | return model; |
| | | } |
| | | private YwContract queryDetailInfoById(Integer id) { |
| | | MPJLambdaWrapper<YwContract> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(YwContract.class ) |
| | | .selectAs(Company::getName,YwContract::getCompanyName ) |
| | |
| | | .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId) |
| | | .eq( YwContract::getId,id); |
| | | YwContract model = ywContractMapper.selectJoinOne(YwContract.class,queryWrapper); |
| | | if(model != null){ |
| | | if (model == null) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | //合同附件 |
| | | initFiles(model); |
| | | //查询房源信息数据 |
| | |
| | | .orderByAsc(YwContractDetail::getSortnum); |
| | | model.setWyDetailList(ywContractDetailMapper.selectJoinList(YwContractDetail.class,dw)); |
| | | |
| | | //查询操作日志记录 |
| | | YwWorkorderLog log = new YwWorkorderLog(); |
| | | log.setJobId(model.getId()); |
| | | log.setIsdeleted(Constants.ZERO); |
| | | model.setLogList(ywWorkorderLogMapper.selectList(new QueryWrapper<YwWorkorderLog>(log) |
| | | .lambda() |
| | | .in(YwWorkorderLog::getObjType,Constants.YwLogType.CONTRACT_BACK.getKey() |
| | | ,Constants.YwLogType.CONTRACT_CREATE.getKey() |
| | | ,Constants.YwLogType.CONTRACT_UPDATE.getKey()) |
| | | .orderByAsc(YwWorkorderLog::getCreateDate))); |
| | | |
| | | //查询账单集合 |
| | | |
| | | queryBillListByModel(model,new Date()); |
| | | } |
| | | return model; |
| | | } |
| | | |
| | | @Override |
| | | public YwContract findForBills(YwContract model) { |
| | | queryBillListByModel(model,model.getBtDate()); |
| | | public YwContract findForBills(YwContract param) { |
| | | YwContract model = queryDetailInfoById(param.getId()); |
| | | queryBillListByModel(model,param.getBtDate()); |
| | | return model; |
| | | |
| | | } |
| | | private void queryBillListByModel(YwContract model,Date date) { |
| | | if(date ==null){ |
| | | date = new Date(); |
| | | } |
| | | //查询账单集合 |
| | | model.setBillList(ywContractBillMapper.selectJoinList(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>() |
| | | .selectAll(YwContractBill.class ) |
| | |
| | | .eq( YwContractBill::getContractId,model.getId()) |
| | | .eq(YwContractBill::getIsdeleted,Constants.ZERO) |
| | | .orderByAsc(YwContractBill::getSortnum,YwContractBill::getCreateDate))); |
| | | |
| | | for (YwContractBill ywContractBill:model.getBillList()) { |
| | | ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee())); |
| | | ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee()); |
| | | // ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee())); |
| | | } |
| | | model.setCanBackRentBills(new ArrayList<>()); |
| | | long nowStart = Utils.Date.getStart(date).getTime(); |
| | |
| | | continue; |
| | | } |
| | | model.getCanBackRentBills().add(bill); |
| | | |
| | | }else if(Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){ |
| | | if(bill.getEndDate().getTime()<nowStart){ |
| | | //如果已结清,账单直接关闭 |
| | |
| | | model.getCanBackRentBills().add(bill); |
| | | } |
| | | } |
| | | for(YwContractBill bill : model.getCanBackRentBills()){ |
| | | YwContractDetail detail = null; |
| | | if(Constants.equalsInteger(bill.getCostType(),Constants.ZERO)){ |
| | | detail = getDetailByIdFromList(bill.getDetailId(),model.getZlDetailList()); |
| | | if(detail!=null&& bill.getStartDate()!=null && bill.getEndDate()!=null |
| | | &&(date.getTime() <= bill.getStartDate().getTime() || (date.getTime() >= bill.getStartDate().getTime() && date.getTime()<= bill.getEndDate().getTime()))){ |
| | | Date odate = bill.getEndDate(); |
| | | bill.setEndDate(date); |
| | | BigDecimal actFee = getTotalFeeByStartEnd(model,detail,bill,model.getZlFreeStartDate(),model.getZlFreeEndDate()); |
| | | bill.setEndDate(odate); |
| | | bill.setNeedReceivableFee(actFee); |
| | | } |
| | | }else if(Constants.equalsInteger(bill.getCostType(),Constants.ONE)){ |
| | | detail = getDetailByIdFromList(bill.getDetailId(),model.getWyDetailList()); |
| | | if(detail!=null&& bill.getStartDate()!=null && bill.getEndDate()!=null |
| | | &&(date.getTime() <= bill.getStartDate().getTime() || (date.getTime() >= bill.getStartDate().getTime() && date.getTime()<= bill.getEndDate().getTime()))){ |
| | | Date odate = bill.getEndDate(); |
| | | bill.setEndDate(date); |
| | | BigDecimal actFee = getTotalFeeByStartEnd(model,detail,bill,model.getWyFreeStartDate(),model.getWyFreeEndDate()); |
| | | bill.setEndDate(odate); |
| | | bill.setNeedReceivableFee(actFee); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private YwContractDetail getDetailByIdFromList(Integer detailId, List<YwContractDetail> list) { |
| | | if(list!=null){ |
| | | for(YwContractDetail d : list){ |
| | | if(Constants.equalsInteger(detailId,d.getId())){ |
| | | return d; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |