liujie
2026-09-14 15defa991fcd30b9fa60bab17d2230b5929bf2a2
backend/src/main/java/com/tourguide/modules/user/service/GuideRegistrationService.java
@@ -27,6 +27,7 @@
public class GuideRegistrationService {
    private static final int PENDING = 0;
    private static final int APPROVED = 1;
    private static final String REGISTRATION_SCENE = "registration";
    private static final Duration TOKEN_TTL = Duration.ofMinutes(30);
    private static final String TOKEN_KEY_PREFIX = "tourguide:guide-registration:token:";
    private static final DateTimeFormatter APPLICATION_NO_TIME = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
@@ -54,7 +55,7 @@
    public GuideRegistrationTokenResponse verifyPhone(String phone, String code) {
        ensurePhoneCanRegister(phone);
        verificationCodeService.verifyAndConsume(phone, code);
        verificationCodeService.verifyAndConsume(phone, code, REGISTRATION_SCENE);
        String token = UUID.randomUUID().toString().replace("-", "");
        redisTemplate.opsForValue().set(tokenKey(token), phone, TOKEN_TTL);
        return new GuideRegistrationTokenResponse(token, TOKEN_TTL.getSeconds());
@@ -62,7 +63,7 @@
    public SmsCodeResponse sendCode(String phone) {
        ensurePhoneCanRegister(phone);
        return verificationCodeService.send(phone);
        return verificationCodeService.send(phone, REGISTRATION_SCENE);
    }
    public String requireVerifiedPhone(String registrationToken) {
@@ -86,6 +87,7 @@
        }
        if (applicationMapper.selectCount(new LambdaQueryWrapper<GuideApplication>()
                .eq(GuideApplication::getIdCardNo, idCardNo)
                .ne(GuideApplication::getMobile, phone)
                .in(GuideApplication::getAuditStatus, PENDING, APPROVED)) > 0) {
            throw new BusinessException(409, "该身份证号已提交过导游申请");
        }
@@ -122,7 +124,9 @@
    private void ensurePhoneCanRegister(String phone) {
        com.tourguide.modules.user.entity.GuideUser guide = guideUserService.findByPhone(phone);
        if (guide != null && (guide.getStatus() == null || guide.getStatus() != 2)) {
        if (guide != null && (guide.getStatus() == null
                || (guide.getStatus() != GuideUserService.STATUS_PENDING
                && guide.getStatus() != GuideUserService.STATUS_CANCELLED))) {
            throw new BusinessException(409, "该手机号已注册为导游");
        }
        if (applicationMapper.selectCount(new LambdaQueryWrapper<GuideApplication>()