| | |
| | | dealMultifileBiz(model);//处理附件信息 |
| | | dealRoomsForContract(model);//处理房源关联表 |
| | | dealLogBiz(model,Constants.YwLogType.CONTRACT_CREATE,model.getLoginUserInfo().getRealname(),"【"+model.getRemark().replace("合同摘要:","")+"】");//记录新建日志 |
| | | |
| | | return model.getId(); |
| | | } |
| | | |
| | | private void dealRoomsForContract(YwContract model) { |
| | | this.dealRoomsValid(model); |
| | | List<YwContractRoom> list = new ArrayList<>(); |
| | | for(YwRoom room :model.getRoomList()){ |
| | | YwContractRoom t = new YwContractRoom(); |
| | |
| | | } |
| | | ywContractRoomMapper.insert(list); |
| | | } |
| | | |
| | | private void dealRoomsValid(YwContract model){ |
| | | List<Integer> roomIds = model.getRoomList().stream().map(i->i.getId()).collect(Collectors.toList()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(roomIds)){ |
| | | if(ywContractMapper.selectJoinCount(new MPJLambdaWrapper<YwContract>() |
| | | .leftJoin(YwContractRoom.class,YwContractRoom::getContractId,YwContract::getId) |
| | | .eq(YwContractRoom::getType,Constants.ZERO) |
| | | .in(YwContractRoom::getRoomId,roomIds) |
| | | .in(YwContract::getStatus,Constants.ZERO,Constants.ONE,Constants.TWO) |
| | | .apply(" (" + |
| | | " ( t.START_DATE < '"+DateUtil.getFomartDate(model.getEndDate(),"yyyy-MM-dd HH:mm:ss")+"' and t.END_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " + |
| | | "or " + |
| | | " ( t.START_DATE < '"+DateUtil.getFomartDate(model.getEndDate(),"yyyy-MM-dd HH:mm:ss")+"' and t.END_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " + |
| | | " ) ") |
| | | |
| | | )>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"房源已被占用请刷新重试"); |
| | | }; |
| | | |
| | | if(ywContractMapper.selectJoinCount(new MPJLambdaWrapper<YwContract>() |
| | | .leftJoin(YwContractRoom.class,YwContractRoom::getContractId,YwContract::getId) |
| | | .eq(YwContractRoom::getType,Constants.ZERO) |
| | | .in(YwContractRoom::getRoomId,roomIds) |
| | | .in(YwContract::getStatus,Constants.THREE) |
| | | .apply(" ( t.START_DATE < '"+DateUtil.getFomartDate(model.getEndDate(),"yyyy-MM-dd HH:mm:ss")+"' " + |
| | | " and t.BT_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " ) |
| | | )>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"房源已被占用请刷新重试"); |
| | | }; |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<YwContractBill> getBillList(YwContract model){ |
| | |
| | | if(!(model.getZlFreeEndDate()==null && model.getZlFreeStartDate()==null) && ( |
| | | (model.getZlFreeEndDate()!=null && model.getZlFreeStartDate()==null) |
| | | ||(model.getZlFreeEndDate()==null && model.getZlFreeStartDate()!=null) |
| | | ||model.getZlFreeEndDate().getTime()<= model.getZlFreeStartDate().getTime()) |
| | | ||model.getZlFreeEndDate().getTime()< model.getZlFreeStartDate().getTime()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请选择正确的租赁条款免租期信息!"); |
| | | } |
| | |
| | | } |
| | | for(YwContractDetail d :model.getWyDetailList()){ |
| | | if( d.getStartDate() == null |
| | | ||d.getEditDate() == null |
| | | ||d.getEndDate() == null |
| | | ||d.getPrice() == null |
| | | ||d.getCircleType() == null |
| | | || d.getCircleType()>6 |
| | |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请按页面要求填写物业条款信息!"); |
| | | } |
| | | if(d.getEndDate().getTime()<= d.getStartDate().getTime()){ |
| | | if(d.getEndDate().getTime()< d.getStartDate().getTime()){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,物业条款有效期结束时间不得早于开始时间!"); |
| | | } |
| | | if(!Constants.equalsInteger(model.getWyPayType(),Constants.ZERO) && |
| | |
| | | |
| | | String str = ""; |
| | | //起租日2024/06/01,租赁数为500㎡。首期租赁三月一付,租金单价35元/㎡·月。首期物业三月一付,物业单价4.3元/㎡·月 |
| | | String str0 = "合同摘要:起租日{param1},租赁数为{param2}㎡。首期租赁{param3},租金单价{param4}元{param5}。首期物业{param6},物业单价{param7}{param8}"; |
| | | String str1 = "合同摘要:起租日{param1},租赁数为{param2}㎡。首期租赁{param3},租金单价{param4}元{param5}。"; |
| | | String str2 = "合同摘要:起租日{param1},首期物业{param6},物业单价{param7}元{param8}"; |
| | | String str0 = "合同摘要:起租日{param1},租赁数为{param2}㎡。首期租赁{param3},租金单价{param4}{param5}。首期物业{param6},物业单价{param7}{param8}"; |
| | | String str1 = "合同摘要:起租日{param1},租赁数为{param2}㎡。首期租赁{param3},租金单价{param4}{param5}。"; |
| | | String str2 = "合同摘要:起租日{param1},首期物业{param6},物业单价{param7}{param8}"; |
| | | if(Constants.equalsInteger(model.getType(),Constants.ZERO)){ |
| | | str= str0; |
| | | } |
| | |
| | | .replace("{param2}",model.getTotalArea().intValue()+"") |
| | | .replace("{param3}",Constants.getPayTypeByNum(model.getZlPayType())) |
| | | .replace("{param4}",Constants.formatBigdecimal(model.getZlFirstPrice()).intValue()+"") |
| | | .replace("{param5}",Constants.getUnitTypeByNum(model.getZlFirstCircle()) |
| | | .replace("{param5}",Constants.getUnitTypeByNum(model.getZlFirstCircle())) |
| | | .replace("{param6}",Constants.getPayTypeByNum(model.getWyPayType())) |
| | | .replace("{param7}",Constants.formatBigdecimal(model.getWyFirstPrice()).intValue()+"") |
| | | .replace("{param8}",Constants.getUnitTypeByNum(model.getWyFirstCircle()))); |
| | | .replace("{param8}",Constants.getUnitTypeByNum(model.getWyFirstCircle())); |
| | | return str; |
| | | } |
| | | private String getbackRentRemarkByParam(YwContract model) { |
| | | 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}",Integer.toString(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; |
| | |
| | | update.setBtFee(param.getBtFee()); |
| | | update.setBtRemark(getbackRentRemarkByParam(param)); |
| | | ywContractMapper.updateById(update); |
| | | // if(1==1){ |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED); |
| | | // } |
| | | dealLogBiz(param,Constants.YwLogType.CONTRACT_BACK, param.getLoginUserInfo().getRealname(),getbackRentLogByParam(param)); |
| | | return param.getId(); |
| | | } |
| | |
| | | totalBackFee = totalBackFee.add(fee);//累计退款金额 |
| | | } |
| | | } |
| | | List<YwContractBill> ywContractBillList = ywContractBillMapper.selectList(new QueryWrapper<YwContractBill>() |
| | | .lambda().eq(YwContractBill::getContractId,param.getId()).orderByDesc(YwContractBill::getId)); |
| | | Integer sortNum = ywContractBillList.size(); |
| | | if(param.getAddBillList()!=null && param.getAddBillList().size()>0){ |
| | | for(YwContractBill addBill : param.getAddBillList()){ |
| | | sortNum = sortNum + 1 ; |
| | | addBill.setIsdeleted(Constants.ZERO); |
| | | addBill.setContractId(param.getId()); |
| | | addBill.setType(Constants.ONE); |
| | | addBill.setStatus(Constants.ZERO); |
| | | addBill.setTotleFee(addBill.getReceivableFee()); |
| | | if(Constants.equalsInteger(addBill.getFeeType(),Constants.ONE)){ |
| | | addBill.setStartDate(addBill.getPlanPayDate()); |
| | | addBill.setEndDate(addBill.getPlanPayDate()); |
| | |
| | | addBill.setBtFee(Constants.formatBigdecimal(addBill.getActReceivableFee()).multiply(new BigDecimal(-1))); |
| | | } |
| | | totalBackFee = totalBackFee.add(Constants.formatBigdecimal(addBill.getBtFee())); |
| | | addBill.setCreator(param.getEditor()); |
| | | addBill.setCreateDate(param.getEditDate()); |
| | | addBill.setEditDate(param.getEditDate()); |
| | | addBill.setEditor(param.getEditor()); |
| | | addBill.setBtActDate(param.getBtActDate()); |
| | |
| | | addBill.setBtUserId(param.getBtUserId()); |
| | | addBill.setBtSignDate(param.getBtSignDate()); |
| | | addBill.setBtType(param.getBtType()); |
| | | addBill.setSortnum(sortNum ); |
| | | newBills.add(addBill); |
| | | } |
| | | ywContractBillMapper.insert(param.getAddBillList());//批量插入数据 |
| | |
| | | yjBill.setEditDate(param.getEditDate()); |
| | | yjBill.setEditor(param.getEditor()); |
| | | yjBill.setReceivableFee(BigDecimal.ZERO); |
| | | yjBill.setPayStatus(Constants.FOUR); |
| | | if(bill.getActReceivableFee().compareTo(BigDecimal.ZERO)==Constants.ZERO){ |
| | | yjBill.setPayStatus(Constants.FIVE); |
| | | yjBill.setStatus(Constants.ONE); |
| | | }else{ |
| | | yjBill.setPayStatus(Constants.FOUR); |
| | | yjNoBills ++; |
| | | } |
| | | yjBill.setPlanPayDate(canBill.getPlanPayDate()); |
| | | ywContractBillMapper.updateById(yjBill); |
| | | } |
| | | } |
| | | yjNoBills ++; |
| | | |
| | | } |
| | | } |
| | | param.setBtWaitBill(canBills.size() + newBills.size()+yjNoBills);//未清算的账单数量 |
| | |
| | | billList1.get(i).setSortnum(num++); |
| | | } |
| | | } |
| | | num =1; |
| | | num =1; |
| | | for(int i=0;i<billList2.size();i++){ |
| | | if(Constants.equalsInteger( billList2.get(i).getCostType(),Constants.ONE)){ |
| | | billList2.get(i).setSortnum(num++); |
| | |
| | | } |
| | | private BigDecimal getTotalFeeByStartEnd(YwContract model, YwContractDetail d, YwContractBill bill,Date freeStart,Date freeEnd) { |
| | | BigDecimal totalFee = new BigDecimal(0); |
| | | DateCompare dateCompare = DateCompare.dayCompare(bill.getStartDate(),DateUtil.addDaysToDate(bill.getEndDate(),1),freeStart,DateUtil.addDaysToDate(freeEnd,1)); |
| | | DateCompare dateCompare = DateCompare.dayCompare(bill.getStartDate(),bill.getEndDate(),freeStart, freeEnd); |
| | | if(Constants.equalsInteger(d.getCircleType(),Constants.ZERO)){ |
| | | //0=元每平米天 |
| | | int days = dateCompare.getDay() ; |
| | |
| | | bill.setTotleFee(getTotalFeeByStartEnd(model,d,bill,freeStart,freeEnd)); |
| | | bill.setReceivableFee(bill.getTotleFee()); |
| | | bill.setBillType(Constants.ZERO); |
| | | bill.setCompanyId(model.getCompanyId()); |
| | | list.add(bill); |
| | | } |
| | | return list; |
| | |
| | | if(!(model.getZlFreeEndDate()==null && model.getZlFreeStartDate()==null) && ( |
| | | (model.getZlFreeEndDate()!=null && model.getZlFreeStartDate()==null) |
| | | ||(model.getZlFreeEndDate()==null && model.getZlFreeStartDate()!=null) |
| | | ||model.getZlFreeEndDate().getTime()<= model.getZlFreeStartDate().getTime()) |
| | | ||model.getZlFreeEndDate().getTime()< model.getZlFreeStartDate().getTime()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请选择正确的租赁条款免租期信息!"); |
| | | } |
| | |
| | | Constants.equalsInteger(d.getCircleType(),Constants.SIX)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,租赁条款只有选择一次性付款时,才能选择该按每场收费;"); |
| | | } |
| | | if(model.getZlFirstCircle() == null){//首期信息 |
| | | if(model.getZlFirstPrice() == null){//首期信息 |
| | | model.setZlFirstPrice(d.getPrice()); |
| | | model.setZlFirstCircle(d.getCircleType()); |
| | | } |
| | |
| | | Constants.equalsInteger(d.getCircleType(),Constants.SIX)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,物业条款只有选择一次性付款时,才能选择该按每场收费;"); |
| | | } |
| | | if(model.getWyFirstCircle() == null){ |
| | | if(model.getWyFirstPrice() == null){ |
| | | //首期信息 |
| | | model.setWyFirstPrice(d.getPrice()); |
| | | model.setWyFirstCircle(d.getCircleType()); |
| | |
| | | //查询账单集合 |
| | | 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 ") |
| | | //.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 ") |
| | | .select(" ( select ifnull( sum( CASE WHEN t.bill_type = 0 and yw.REVENUE_TYPE = 0 THEN yw.ACT_RECEIVABLE_FEE when t.bill_type = 0 and yw.REVENUE_TYPE = 1 then -yw.ACT_RECEIVABLE_FEE when t.bill_type = 1 and 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))); |