| | |
| | | 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(),"对不起,请选择正确的租赁条款免租期信息!"); |
| | | } |
| | |
| | | ){ |
| | | 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) && |
| | |
| | | BigDecimal fee = Constants.formatBigdecimal(model.getBtFee()); |
| | | String str = "退租摘要:剩余未结清账单{param1}份,关闭账单{param2}份【退租日{param3},退租费用合计需{param4}{param5}元。】"; |
| | | str = str.replace("{param1}",model.getBtWaitBill()+"") |
| | | .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? |
| | | .replace("{param2}",DateUtil.getDateLongSlash(model.getBtDate())) |
| | | .replace("{param3}",fee.compareTo(new BigDecimal(0)) >=0?"收":"付") |
| | | .replace("{param4}",(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); |
| | | if(bill.getActReceivableFee().compareTo(BigDecimal.ZERO)==Constants.ZERO){ |
| | | yjBill.setPayStatus(Constants.FIVE); |
| | | yjBill.setStatus(Constants.ONE); |
| | | }else{ |
| | | yjBill.setPayStatus(Constants.FOUR); |
| | | yjNoBills ++; |
| | | } |
| | | yjBill.setPayStatus(Constants.FOUR); |
| | | yjBill.setPlanPayDate(canBill.getPlanPayDate()); |
| | | ywContractBillMapper.updateById(yjBill); |
| | | } |
| | | } |
| | | |
| | | yjNoBills ++; |
| | | } |
| | | } |
| | | param.setBtWaitBill(canBills.size() + newBills.size()+yjNoBills);//未清算的账单数量 |
| | |
| | | } |
| | | int num =1; |
| | | for(int i=0;i<billList1.size();i++){ |
| | | if(Constants.equalsInteger( billList1.get(i).getCostType(),Constants.ZERO)){ |
| | | billList1.get(i).setSortnum(num++); |
| | | } |
| | | billList1.get(i).setSortnum(num); |
| | | num++; |
| | | } |
| | | num =1; |
| | | for(int i=0;i<billList2.size();i++){ |
| | | if(Constants.equalsInteger( billList2.get(i).getCostType(),Constants.ONE)){ |
| | | billList2.get(i).setSortnum(num++); |
| | | } |
| | | billList2.get(i).setSortnum(num); |
| | | num++; |
| | | } |
| | | if(model.getId()!=null){ |
| | | ywContractBillMapper.insert(billList1); |
| | |
| | | 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.getZlFirstPrice() == null){//首期信息 |
| | | if(model.getZlFirstCircle() == null){//首期信息 |
| | | model.setZlFirstPrice(d.getPrice()); |
| | | model.setZlFirstCircle(d.getCircleType()); |
| | | } |
| | |
| | | Constants.equalsInteger(d.getCircleType(),Constants.SIX)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,物业条款只有选择一次性付款时,才能选择该按每场收费;"); |
| | | } |
| | | if(model.getWyFirstPrice() == null){ |
| | | if(model.getWyFirstCircle() == null){ |
| | | //首期信息 |
| | | model.setWyFirstPrice(d.getPrice()); |
| | | model.setWyFirstCircle(d.getCircleType()); |
| | |
| | | .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 ") |
| | | .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))); |
| | | |
| | | for (YwContractBill ywContractBill:model.getBillList()) { |
| | | ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee())); |
| | | } |
| | | queryBillListByModel(model,new Date()); |
| | | } |
| | | return model; |
| | | } |
| | | @Override |
| | | public YwContract findForBills(YwContract model) { |
| | | queryBillListByModel(model,model.getBtDate()); |
| | | return model; |
| | | |
| | | 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); |
| | | } |
| | | 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 ") |
| | | .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))); |
| | | |
| | | }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 |