renkang
2024-12-03 fbfb89873a326fd5429a2f21f61e659ab80dc03d
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java
@@ -91,6 +91,7 @@
    }
    private void dealRoomsForContract(YwContract model) {
        this.dealRoomsValid(model);
        List<YwContractRoom> list = new ArrayList<>();
        for(YwRoom room :model.getRoomList()){
            YwContractRoom t = new YwContractRoom();
@@ -106,6 +107,46 @@
        }
        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.getBtDate(),"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(),"房源已被占用请刷新重试");
            };
        }
    }
    @Override
    public   List<YwContractBill> getBillList(YwContract model){
@@ -311,9 +352,6 @@
        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();
    }
@@ -441,12 +479,17 @@
                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());
@@ -470,6 +513,7 @@
                addBill.setBtUserId(param.getBtUserId());
                addBill.setBtSignDate(param.getBtSignDate());
                addBill.setBtType(param.getBtType());
                addBill.setSortnum(sortNum );
                newBills.add(addBill);
            }
            ywContractBillMapper.insert(param.getAddBillList());//批量插入数据
@@ -648,12 +692,15 @@
        }
        int num =1;
        for(int i=0;i<billList1.size();i++){
            billList1.get(i).setSortnum(num);
            num++;
            if(Constants.equalsInteger( billList1.get(i).getCostType(),Constants.ZERO)){
                billList1.get(i).setSortnum(num++);
            }
        }
        num =1;
        for(int i=0;i<billList2.size();i++){
            billList2.get(i).setSortnum(num);
            num++;
            if(Constants.equalsInteger( billList2.get(i).getCostType(),Constants.ONE)){
                billList2.get(i).setSortnum(num++);
            }
        }
        if(model.getId()!=null){
            ywContractBillMapper.insert(billList1);