guohongjin
2024-04-28 689567d23a1f3333421aa35214490077b0ac9a0f
修改预约提示
1个文件已修改
8 ■■■■■ 已修改文件
rest/src/main/java/cn/stylefeng/rest/modular/user/controller/CounsellingInfoController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rest/src/main/java/cn/stylefeng/rest/modular/user/controller/CounsellingInfoController.java
@@ -624,10 +624,12 @@
        if (counsellingOrder == null){
            throw new ServiceException("没有在咨询的订单,无法进行预约!");
        }
        RLock lock = redissonClient.getLock("counsel:" + counsellingReservationRequest.getCounsellingId()+"_"+counsellingReservationRequest.getDayTime()+"_"+counsellingReservationRequest.getTimePoint());
        String key = "counsel:" + counsellingReservationRequest.getCounsellingId()+"_"+counsellingReservationRequest.getDayTime()+"_"+counsellingReservationRequest.getTimePoint();
        RLock lock = redissonClient.getLock(key);
        boolean tryLock = false;
        try {
            tryLock = lock.tryLock(10, TimeUnit.SECONDS);
            log.info("咨询key:"+key+",userId:"+counsellingOrder.getUserId());
            tryLock = lock.tryLock(20, TimeUnit.SECONDS);
            if (!tryLock) {
                throw new ServiceException("当前时间段已预约,请选择其他时间段!");
            }
@@ -796,7 +798,7 @@
            return new SuccessResponseData<>(counsellingOrderReservation);
        }catch (Exception ex){
            log.error("咨询预约服务异常",ex.getStackTrace());
            throw new ServiceException("服务异常,请稍后再试");
            throw new ServiceException("当前时间段已预约,请选择其他时间段!");
        }finally {
            if(tryLock){
                lock.unlock();