|  |  |  | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.YwContractBillMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.YwContractRevenueMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.YwContractRoomMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.YwRoomMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.system.MultifileMapper; | 
|---|
|  |  |  | import com.doumee.dao.system.model.Multifile; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.YwContractBillService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private YwContractMapper ywContractMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | YwContract ywContract = ywContractMapper.selectById(ywContractBill.getContractId()); | 
|---|
|  |  |  | if(Objects.isNull(ywContract)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(ywContract.getStatus(),Constants.THREE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合同状态已流转,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = ywContractBill.getLoginUserInfo(); | 
|---|
|  |  |  | ywContractBill.setReceivableFee(ywContractBill.getTotleFee()); | 
|---|
|  |  |  | ywContractBill.setCreateDate(new Date()); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(Objects.isNull(ywContractBill)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //房源数据 | 
|---|
|  |  |  | ywContractBill.setYwContractRoomList(ywContractRoomMapper.selectJoinList(YwContractRoom.class,new MPJLambdaWrapper<YwContractRoom>() | 
|---|
|  |  |  | .selectAll(YwContractRoom.class) | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(YwContractRoom::getContractId,id) | 
|---|
|  |  |  | .eq(YwContractRoom::getType,Constants.ONE) | 
|---|
|  |  |  | )); | 
|---|
|  |  |  | //收支明细 | 
|---|
|  |  |  | ywContractBill.setYwContractRevenueList( | 
|---|
|  |  |  | ywContractRevenueMapper.selectJoinList(YwContractRevenue.class,new MPJLambdaWrapper<YwContractRevenue>() | 
|---|
|  |  |  | .selectAll(YwContractRevenue.class) | 
|---|
|  |  |  | .selectAs(YwCustomer::getName,YwContractRevenue::getCustomerNme) | 
|---|
|  |  |  | .leftJoin(YwContract.class,YwContract::getId,YwContractRevenue::getContractId) | 
|---|
|  |  |  | .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId) | 
|---|
|  |  |  | .eq(YwContractRevenue::getBillId,id) | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //附件数据 | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda() | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectJoinList(Multifile.class,new MPJLambdaWrapper<Multifile>() | 
|---|
|  |  |  | .selectAll(Multifile.class) | 
|---|
|  |  |  | .selectAs(SystemUser::getRealname,Multifile::getUserName) | 
|---|
|  |  |  | .leftJoin(SystemUser.class,SystemUser::getId,Multifile::getCreator) | 
|---|
|  |  |  | .eq(Multifile::getObjId,id) | 
|---|
|  |  |  | .eq(Multifile::getObjType,Constants.MultiFile.FN_CONTRACT_BILL_FILE.getKey())); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | YwContractBill::getType,model.getType()) | 
|---|
|  |  |  | .eq(Objects.nonNull(model)&&Objects.nonNull(model.getContractId()), | 
|---|
|  |  |  | YwContractBill::getContractId,model.getContractId()) | 
|---|
|  |  |  | .ge(YwContractBill::getPlanPayDate, Utils.Date.getStart(model.getPlanPayDateStart())) | 
|---|
|  |  |  | .le(YwContractBill::getPlanPayDate, Utils.Date.getEnd(model.getPlanPayDateEnd())) ) | 
|---|
|  |  |  | .ge(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateStart()),YwContractBill::getPlanPayDate, Utils.Date.getStart(model.getPlanPayDateStart())) | 
|---|
|  |  |  | .le(Objects.nonNull(model)&&Objects.nonNull(model.getPlanPayDateEnd()),YwContractBill::getPlanPayDate, Utils.Date.getEnd(model.getPlanPayDateEnd())) ) | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | this.dealRoomDetail(iPage.getRecords()); | 
|---|
|  |  |  | for (YwContractBill ywContractBill:iPage.getRecords()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | ywContractBill.setNeedReceivableFee( | 
|---|
|  |  |  | ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //是否逾期 | 
|---|
|  |  |  | if(Constants.equalsInteger(ywContractBill.getStatus(),Constants.ZERO) && (Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.ZERO) | 
|---|
|  |  |  | || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.TWO) | 
|---|
|  |  |  | || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.THREE) | 
|---|
|  |  |  | || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.FOUR)) | 
|---|
|  |  |  | && ywContractBill.getEndDate().getTime() < System.currentTimeMillis()){ | 
|---|
|  |  |  | ywContractBill.setIsOverdue(Constants.ONE); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | ywContractBill.setIsOverdue(Constants.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //楼宇名称 | 
|---|
|  |  |  | List<YwContractRoom> ywContractRoomList = ywContractBill.getYwContractRoomList(); | 
|---|
|  |  |  | StringBuilder roomPathName = new StringBuilder(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ywContractBill.setRoomPathName(roomPathName.toString()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return PageData.from(iPage); | 
|---|