| | |
| | | @Scheduled(fixedDelayString = "${tourguide.guide.auto-disable-scan-delay-millis:60000}") |
| | | @Transactional |
| | | public void disableEligibleGuides() { |
| | | synchronizeGuideStatuses(); |
| | | } |
| | | |
| | | @Transactional |
| | | public void synchronizeGuideStatuses() { |
| | | GuideAutoDisableConfig config = configMapper.selectById(1); |
| | | if (!valid(config)) return; |
| | | restoreGuidesNoLongerEligible(config); |
| | | |
| | | Long lastGuideId = null; |
| | | do { |
| | | List<GuideUser> candidates = selectCandidates(config, lastGuideId); |
| | |
| | | guide.getId(), guide.getAcceptedOrderCount(), guide.getRating()); |
| | | } |
| | | |
| | | private void restoreGuidesNoLongerEligible(GuideAutoDisableConfig config) { |
| | | int restored = guideUserMapper.restoreAutoDisabledGuidesNoLongerEligible( |
| | | config.getOrderThreshold(), config.getRatingThreshold()); |
| | | if (restored > 0) { |
| | | log.info("Restored automatically disabled guides after rule reconciliation, count={}", restored); |
| | | } |
| | | } |
| | | |
| | | private boolean hasActiveServiceOrder(Long guideId) { |
| | | return orderMapper.selectCount(new LambdaQueryWrapper<TourOrder>() |
| | | .eq(TourOrder::getGuideId, guideId) |