| | |
| | | import com.tourguide.modules.user.dto.GuideApplicationResponse; |
| | | import com.tourguide.modules.user.entity.GuideApplication; |
| | | import com.tourguide.modules.user.mapper.GuideApplicationMapper; |
| | | import com.tourguide.modules.system.service.GuideNotificationService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | private static final int REJECTED = 2; |
| | | private final GuideApplicationMapper applicationMapper; |
| | | private final GuideUserService guideUserService; |
| | | private final GuideNotificationService notificationService; |
| | | private final GuideAuditSmsService auditSmsService; |
| | | |
| | | public GuideApplicationService(GuideApplicationMapper applicationMapper, GuideUserService guideUserService) { |
| | | public GuideApplicationService(GuideApplicationMapper applicationMapper, GuideUserService guideUserService, |
| | | GuideNotificationService notificationService, |
| | | GuideAuditSmsService auditSmsService) { |
| | | this.applicationMapper = applicationMapper; |
| | | this.guideUserService = guideUserService; |
| | | this.notificationService = notificationService; |
| | | this.auditSmsService = auditSmsService; |
| | | } |
| | | |
| | | public PageResponse<GuideApplicationResponse> page(long page, long size, String keyword, Integer auditStatus, |
| | |
| | | if (application.getAuditStatus() == null || application.getAuditStatus() != PENDING) { |
| | | throw new BusinessException(409, "该申请已审核,请勿重复操作"); |
| | | } |
| | | if (auditStatus == APPROVED) { |
| | | guideUserService.createFromApprovedApplication(application); |
| | | } |
| | | if (auditStatus == APPROVED) guideUserService.createFromApprovedApplication(application); |
| | | LambdaUpdateWrapper<GuideApplication> update = new LambdaUpdateWrapper<GuideApplication>() |
| | | .eq(GuideApplication::getId, id) |
| | | .eq(GuideApplication::getAuditStatus, PENDING) |
| | |
| | | if (applicationMapper.update(null, update) != 1) { |
| | | throw new BusinessException(409, "该申请已被其他管理员处理"); |
| | | } |
| | | com.tourguide.modules.user.entity.GuideUser guide = guideUserService.findByPhone(application.getMobile()); |
| | | if (guide != null) notificationService.notifyAuditResult(guide.getId(), auditStatus == APPROVED); |
| | | auditSmsService.send(application.getMobile(), application.getRealName(), auditStatus == APPROVED); |
| | | return detail(id); |
| | | } |
| | | |