| | |
| | | import com.tourguide.modules.order.domain.OrderStatus; |
| | | import com.tourguide.modules.order.entity.TourOrder; |
| | | import com.tourguide.modules.order.mapper.TourOrderMapper; |
| | | import com.tourguide.modules.order.service.GuideSessionTransitionService; |
| | | import com.tourguide.modules.user.dto.GuideReceivingOptionResponse; |
| | | import com.tourguide.modules.user.dto.GuideReceivingStartRequest; |
| | | import com.tourguide.modules.user.entity.GuideRealtimeStatus; |
| | |
| | | private final GuideRealtimeStatusMapper realtimeStatusMapper; |
| | | private final PlatformSettingsService platformSettingsService; |
| | | private final TourOrderMapper orderMapper; |
| | | private final GuideSessionTransitionService sessionTransitionService; |
| | | |
| | | public GuideReceivingService(GuideUserService guideUserService, GuideScenicConfigMapper guideScenicMapper, |
| | | GuideTeamScenicConfigMapper teamScenicMapper, OperationScenicSpotMapper scenicMapper, |
| | | ScenicMeetingPointMapper meetingPointMapper, ScenicPricingMapper pricingMapper, |
| | | GuideReceivingSessionMapper sessionMapper, GuideRealtimeStatusMapper realtimeStatusMapper, |
| | | PlatformSettingsService platformSettingsService, TourOrderMapper orderMapper) { |
| | | PlatformSettingsService platformSettingsService, TourOrderMapper orderMapper, |
| | | GuideSessionTransitionService sessionTransitionService) { |
| | | this.guideUserService = guideUserService; |
| | | this.guideScenicMapper = guideScenicMapper; |
| | | this.teamScenicMapper = teamScenicMapper; |
| | |
| | | this.realtimeStatusMapper = realtimeStatusMapper; |
| | | this.platformSettingsService = platformSettingsService; |
| | | this.orderMapper = orderMapper; |
| | | this.sessionTransitionService = sessionTransitionService; |
| | | } |
| | | |
| | | public GuideReceivingOptionResponse options(Long guideId) { |
| | |
| | | } |
| | | |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | int orderCount = orderMapper.completeSessionOrders(guideId, session.getId(), now); |
| | | if (orderCount == 0) { |
| | | if (!sessionTransitionService.completeSession(session, now)) { |
| | | throw new BusinessException(400, "no active service order"); |
| | | } |
| | | |
| | | sessionMapper.update(null, new LambdaUpdateWrapper<GuideReceivingSession>() |
| | | .eq(GuideReceivingSession::getId, session.getId()) |
| | | .eq(GuideReceivingSession::getGuideId, guideId) |
| | | .eq(GuideReceivingSession::getStatus, "IN_SERVICE") |
| | | .set(GuideReceivingSession::getStatus, "STOPPED")); |
| | | realtimeStatusMapper.update(null, new LambdaUpdateWrapper<GuideRealtimeStatus>() |
| | | .eq(GuideRealtimeStatus::getGuideId, guideId) |
| | | .set(GuideRealtimeStatus::getOnlineStatus, 0) |
| | | .set(GuideRealtimeStatus::getAvailableStatus, 0)); |
| | | } |
| | | |
| | | private Set<String> configuredScenicNames(GuideUser guide) { |