| | |
| | | import com.tourguide.modules.review.mapper.OrderReviewMapper; |
| | | import com.tourguide.modules.user.entity.GuideUser; |
| | | import com.tourguide.modules.user.mapper.GuideUserMapper; |
| | | import com.tourguide.modules.user.service.GuideAutoDisableService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | private final OrderReviewMapper reviewMapper; |
| | | private final TourOrderMapper orderMapper; |
| | | private final GuideUserMapper guideUserMapper; |
| | | private final GuideAutoDisableService autoDisableService; |
| | | |
| | | public OrderReviewService(OrderReviewMapper reviewMapper, TourOrderMapper orderMapper, GuideUserMapper guideUserMapper) { |
| | | public OrderReviewService(OrderReviewMapper reviewMapper, TourOrderMapper orderMapper, |
| | | GuideUserMapper guideUserMapper, |
| | | GuideAutoDisableService autoDisableService) { |
| | | this.reviewMapper = reviewMapper; |
| | | this.orderMapper = orderMapper; |
| | | this.guideUserMapper = guideUserMapper; |
| | | this.autoDisableService = autoDisableService; |
| | | } |
| | | |
| | | public PageResponse<OrderReviewResponse> page(long page, long size, String keyword, Integer status, |
| | |
| | | BigDecimal average = reviewMapper.selectAverageScore(guideId); |
| | | guide.setRating(average == null ? BigDecimal.ZERO : average.setScale(2, RoundingMode.HALF_UP)); |
| | | guideUserMapper.updateById(guide); |
| | | autoDisableService.disableGuideIfEligible(guideId); |
| | | } |
| | | |
| | | private String generateReviewNo() { |