| | |
| | | @Autowired |
| | | private MultifileMapper multifileMapper; |
| | | @Autowired |
| | | private YwWorkorderLogMapper ywWorkorderLogMapper; |
| | | @Autowired |
| | | private CompanyMapper companyMapper; |
| | | @Autowired |
| | | private YwProjectMapper projectMapper; |
| | |
| | | ywContractMapper.insert(model); |
| | | dealDetailListBiz(model);//处理条款信息 |
| | | dealMultifileBiz(model);//处理附件信息 |
| | | dealLogBiz(model,Constants.YwLogType.CONTRACT_CREATE,null,null);//记录新建日志 |
| | | return model.getId(); |
| | | } |
| | | /** |
| | | * 退租提交 |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public Integer backRent(YwContract param){ |
| | | isParamValidBackRent(param); |
| | | //处理 |
| | | dealBackRentBillBiz(param); |
| | | YwContract update = new YwContract(); |
| | | update.setEditDate(new Date()); |
| | | update.setEditor(param.getLoginUserInfo().getId()); |
| | | update.setBtActDate(update.getEditDate()); |
| | | update.setBtActUserId(update.getEditor()); |
| | | update.setStatus(Constants.THREE); |
| | | update.setBtInfo(param.getBtInfo()); |
| | | update.setBtDate(param.getBtDate()); |
| | | update.setBtType(param.getBtType()); |
| | | update.setBtUserId(param.getBtUserId()); |
| | | update.setBtFee(param.getBtFee()); |
| | | ywContractMapper.updateById(update); |
| | | dealLogBiz(param,Constants.YwLogType.CONTRACT_BACK,null,null); |
| | | return param.getId(); |
| | | } |
| | | |
| | | private void dealBackRentBillBiz(YwContract param) { |
| | | } |
| | | |
| | | private void isParamValidBackRent(YwContract param) { |
| | | if(param.getId()==null |
| | | || param.getBtType() == null |
| | | || param.getBtDate() == null |
| | | || param.getBtUserId() == null |
| | | || param.getBtSignDate() == null |
| | | ||StringUtils.isBlank( param.getBtInfo())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | YwContract model = ywContractMapper.selectById(param.getId()); |
| | | if(model==null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,合同信息不存在,请返回列表刷新重试!"); |
| | | } |
| | | |
| | | SystemUser user = systemUserMapper.selectById(param.getUserId()); |
| | | if(user ==null || (user.getDeleted()!=null&& user.getDeleted() )){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,经办人信息不存在!"); |
| | | } |
| | | if(param.getAddBillList()!=null && param.getAddBillList().size()>0){ |
| | | for(YwContractBill bill: param.getAddBillList()){ |
| | | if(bill.getCostType() == null |
| | | ||bill.getFeeType() == null |
| | | ||bill.getReceivableFee() == null |
| | | ||bill.getCompanyId() == null |
| | | ||bill.getPlanPayDate() == null |
| | | ||(Constants.equalsInteger(bill.getFeeType(),Constants.ZERO) |
| | | && (bill.getStartDate() ==null || bill.getEndDate() ==null) )){ |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void dealDetailListBiz(YwContract model) { |
| | |
| | | bill.setStatus(Constants.ZERO); |
| | | bill.setStartDate(model.getStartDate()); |
| | | bill.setEndDate(model.getEndDate()); |
| | | bill.setType(type); |
| | | bill.setType(Constants.ZERO); |
| | | bill.setCostType(type); |
| | | bill.setTotleFee(type==Constants.THREE?model.getZlDeposit():model.getWyDeposit());//押金费用 |
| | | bill.setSortnum(0); |
| | | bill.setTitle(type==Constants.THREE?"租赁押金":"物业押金" ); |
| | | return bill; |
| | | } |
| | | |
| | |
| | | bill.setContractId(model.getId()); |
| | | bill.setStatus(Constants.ZERO); |
| | | bill.setDetailId(d.getId()); |
| | | bill.setType(d.getType()); |
| | | bill.setCostType(d.getType()); |
| | | bill.setType(Constants.ZERO); |
| | | return bill; |
| | | } |
| | | |
| | |
| | | this.updateById(ywContract); |
| | | } |
| | | } |
| | | |
| | | private void dealLogBiz(YwContract model,Constants.YwLogType type,String param1,String param2) { |
| | | YwWorkorderLog log = new YwWorkorderLog(); |
| | | log.setCreateDate(model.getEditDate()); |
| | | log.setCreator(model.getCreator()); |
| | | log.setJobId(model.getId()); |
| | | log.setIsdeleted(Constants.ZERO); |
| | | log.setObjId(model.getId()+""); |
| | | log.setObjType(type.getKey()); |
| | | log.setParam1(param1); |
| | | log.setParam2(param2); |
| | | log.setTitle(type.getNoteinfo()); |
| | | ywWorkorderLogMapper.insert(log); |
| | | } |
| | | @Override |
| | | public YwContract findById(Integer id) { |
| | | MPJLambdaWrapper<YwContract> queryWrapper = new MPJLambdaWrapper<>(); |
| | |
| | | .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId); |
| | | YwContract model = ywContractMapper.selectJoinOne(YwContract.class,queryWrapper); |
| | | if(model != null){ |
| | | //合同附件 |
| | | initFiles(model); |
| | | //查询房源信息数据 |
| | | MPJLambdaWrapper<YwRoom> rw = new MPJLambdaWrapper<>(); |
| | | rw.selectAll(YwRoom.class ) |
| | | .selectAs(YwProject::getName,YwRoom::getProjectName) |
| | | .selectAs(YwFloor::getName,YwRoom::getFloorName) |
| | | .selectAs(YwBuilding::getName,YwRoom::getBuildingName) |
| | | .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId) |
| | | .leftJoin(YwBuilding.class,YwBuilding::getId,YwRoom::getBuildingId) |
| | | .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor) |
| | | .eq(YwRoom::getIsdeleted,Constants.ZERO) |
| | | .exists("(select a.id from yw_contract_room a where a.isdeleted=1 and a.room_id=t.id and a.contract_id="+model.getId()+")"); |
| | | model.setRoomList(roomMapper.selectJoinList(YwRoom.class,rw)); |
| | | |
| | | //查询租賃条款信息 |
| | | MPJLambdaWrapper<YwContractDetail> dw = new MPJLambdaWrapper<>(); |
| | | dw.selectAll(YwContractDetail.class ) |
| | | .eq(YwContractDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(YwContractDetail::getContractId,model.getId()) |
| | | .in(YwContractDetail::getType,Constants.ZERO,Constants.TWO) |
| | | .orderByAsc(YwContractDetail::getSortnum); |
| | | model.setZlDetailList(ywContractDetailMapper.selectJoinList(YwContractDetail.class,dw)); |
| | | //查询物業条款信息 |
| | | dw = new MPJLambdaWrapper<>(); |
| | | dw.selectAll(YwContractDetail.class ) |
| | | .eq(YwContractDetail::getIsdeleted,Constants.ZERO) |
| | | .eq(YwContractDetail::getContractId,model.getId()) |
| | | .in(YwContractDetail::getType,Constants.ONE,Constants.THREE) |
| | | .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))); |
| | | |
| | | //查询账单集合 |
| | | 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))); |
| | | } |
| | | |
| | | return model; |