| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.atomic.AtomicLong; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private String refundAlipayUrl; |
| | | @Value("${refund.wxpay-url}") |
| | | private String refundWxpayUrl; |
| | | |
| | | @Resource |
| | | private RedissonClient redissonClient; |
| | | |
| | | |
| | | |
| | |
| | | @ApiOperation("咨询订单预约") |
| | | @PostResource(name = "咨询订单预约", path = "/counsellingOrderReservation/saveCounsellingOrderReservation") |
| | | public ResponseData<CounsellingOrderReservation> saveCounsellingOrderReservation(@RequestBody CounsellingReservationRequest counsellingReservationRequest) throws ParseException { |
| | | |
| | | //查询咨询师当天是否取消预约 |
| | | CounsellingSpecialTimeConfig specialTimeConfig = this.counsellingSpecialTimeConfigService.getOne(new LambdaQueryWrapper<CounsellingSpecialTimeConfig>().eq(CounsellingSpecialTimeConfig::getCounsellingInfoId,counsellingReservationRequest.getCounsellingId()) |
| | | .eq(CounsellingSpecialTimeConfig::getSpecialDay,counsellingReservationRequest.getDayTime()).eq(CounsellingSpecialTimeConfig::getIsCancelDay,1)); |
| | |
| | | if (counsellingOrder == null){ |
| | | throw new ServiceException("没有在咨询的订单,无法进行预约!"); |
| | | } |
| | | RLock lock = redissonClient.getLock("counsel:" + counsellingReservationRequest.getCounsellingId()+"_"+counsellingReservationRequest.getDayTime()+"_"+counsellingReservationRequest.getTimePoint()); |
| | | boolean tryLock = false; |
| | | try { |
| | | tryLock = lock.tryLock(10, TimeUnit.SECONDS); |
| | | if (!tryLock) { |
| | | throw new ServiceException("当前时间段已预约,请选择其他时间段!"); |
| | | } |
| | | |
| | | //验证未支付的首次咨询订单 |
| | | long counselllingCount = this.counsellingOrderService.count(new LambdaQueryWrapper<CounsellingOrder>().eq(CounsellingOrder::getFirstAppointmentDate,counsellingReservationRequest.getDayTime()) |
| | |
| | | this.counsellingOrderService.updateById(counsellingOrder); |
| | | this.counsellingUserService.updateById(counsellingUserOld); |
| | | |
| | | |
| | | |
| | | CounsellingInfo counsellingInfo = this.counsellingInfoService.getById(counsellingOrder.getCounsellingInfoId()); |
| | | |
| | | |
| | | //将此条消息加入到可聊天的表中t_mental_appointment |
| | | MentalAppointment mentalAppointment = MentalAppointment.builder() |
| | |
| | | customerService.updateCustomerRemoveCache(customer); |
| | | } |
| | | |
| | | try { |
| | | try { |
| | | |
| | | CustomerUpdateRequest customerUpdateRequest = counsellingReservationRequest.getCustomerUpdateRequest(); |
| | | Customer customer = new Customer(); |
| | | BeanUtil.copyProperties(customerUpdateRequest,customer); |
| | | LoginUser loginUser = LoginContext.me().getLoginUser(); |
| | | customer.setCustomerId(loginUser.getUserId()); |
| | | customerService.updateById(customer); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | log.info("编辑用户报错"); |
| | | CustomerUpdateRequest customerUpdateRequest = counsellingReservationRequest.getCustomerUpdateRequest(); |
| | | Customer customer = new Customer(); |
| | | BeanUtil.copyProperties(customerUpdateRequest,customer); |
| | | LoginUser loginUser = LoginContext.me().getLoginUser(); |
| | | customer.setCustomerId(loginUser.getUserId()); |
| | | customerService.updateById(customer); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | log.info("编辑用户报错"); |
| | | } |
| | | return new SuccessResponseData<>(counsellingOrderReservation); |
| | | }catch (Exception ex){ |
| | | log.error("咨询预约服务异常",ex.getStackTrace()); |
| | | throw new ServiceException("服务异常,请稍后再试"); |
| | | }finally { |
| | | if(tryLock){ |
| | | lock.unlock(); |
| | | } |
| | | } |
| | | |
| | | return new SuccessResponseData<>(counsellingOrderReservation); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ApiOperation("根据咨询订单id查询咨询信息") |
| | | @ApiOperation("根据咨询订单id查询咨询信息") |
| | | @GetResource(name = "根据咨询订单id查询咨询信息", path = {"/counsellingOrder/getCounsellingOrderInfoById","/worker/counsellingOrder/getCounsellingOrderInfoById"}) |
| | | public ResponseData<CounsellingOrderResponseDTO> getCounsellingOrderInfoById(Long counsellingOrderId){ |
| | | CounsellingOrder counsellingOrder = this.counsellingOrderService.getById(counsellingOrderId); |