| | |
| | | package com.tcm.training.admin.app.register.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.tcm.training.admin.app.auth.service.AppAuthSessionService; |
| | | import com.tcm.training.admin.app.auth.service.AppSmsCodeService; |
| | |
| | | import com.tcm.training.admin.app.register.vo.AppRegisterRegionDatasetVO; |
| | | import com.tcm.training.admin.app.register.vo.AppRegisterRegionOptionVO; |
| | | import com.tcm.training.admin.common.PhoneMasker; |
| | | import com.tcm.training.admin.utils.VzanHttpUtil; |
| | | import com.tcm.training.admin.live.entity.Clinic; |
| | | import com.tcm.training.admin.live.mapper.ClinicMapper; |
| | | import com.tcm.training.admin.member.entity.AppUser; |
| | | import com.tcm.training.admin.member.mapper.UserMapper; |
| | | import cn.dev33.satoken.stp.SaTokenInfo; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | * APP 注册服务,负责普通用户、经营者注册与海诊通资料同步。 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class AppRegisterService { |
| | | |
| | | private static final Pattern PHONE_PATTERN = Pattern.compile("^1\\d{10}$"); |
| | |
| | | private final StringRedisTemplate stringRedisTemplate; |
| | | private final ObjectMapper objectMapper; |
| | | private final AppShareService appShareService; |
| | | private final VzanHttpUtil vzanHttpUtil; |
| | | |
| | | /** |
| | | * 注入注册链路所需的本地库、海诊通库、验证码与缓存能力。 |
| | |
| | | HztClinicMapper hztClinicMapper, |
| | | StringRedisTemplate stringRedisTemplate, |
| | | ObjectMapper objectMapper, |
| | | AppShareService appShareService) { |
| | | AppShareService appShareService, |
| | | VzanHttpUtil vzanHttpUtil) { |
| | | this.userMapper = userMapper; |
| | | this.clinicMapper = clinicMapper; |
| | | this.appSmsCodeService = appSmsCodeService; |
| | |
| | | this.stringRedisTemplate = stringRedisTemplate; |
| | | this.objectMapper = objectMapper; |
| | | this.appShareService = appShareService; |
| | | this.vzanHttpUtil = vzanHttpUtil; |
| | | } |
| | | |
| | | /** |
| | |
| | | user.setClinicId(clinic.getId()); |
| | | userMapper.insert(user); |
| | | |
| | | Integer provinceCode = parseRegionCode(clinic.getProvinceCode(), "省编码"); |
| | | Integer cityCode = parseRegionCode(clinic.getCityCode(), "市编码"); |
| | | Integer areaCode = parseRegionCode(clinic.getDistrictCode(), "区县编码"); |
| | | log.info("调用微赞创建门店,入参 title={}, provinceCode={}, cityCode={}, areaCode={}, address={}, telephone={}", |
| | | clinic.getName(), provinceCode, cityCode, areaCode, clinic.getAddress(), clinic.getContactPhone()); |
| | | try { |
| | | JsonNode vzanResponse = vzanHttpUtil.createStore(clinic.getName(), provinceCode, cityCode, areaCode, clinic.getAddress(), clinic.getContactPhone()); |
| | | log.info("微赞创建门店成功,出参={}", vzanResponse); |
| | | } catch (RuntimeException ex) { |
| | | log.error("微赞创建门店失败,本地事务将回滚,入参 title={}, provinceCode={}, cityCode={}, areaCode={}, address={}, telephone={}", |
| | | clinic.getName(), provinceCode, cityCode, areaCode, clinic.getAddress(), clinic.getContactPhone(), ex); |
| | | throw new IllegalStateException("微赞创建门店失败", ex); |
| | | } |
| | | |
| | | clearDraft(request.getRegisterTicket()); |
| | | return createLoginResponse(user); |
| | | } |
| | | |
| | | private Integer parseRegionCode(String code, String label) { |
| | | String normalized = code == null ? null : code.trim(); |
| | | if (normalized == null || normalized.isEmpty()) { |
| | | throw new IllegalArgumentException(label + "不能为空"); |
| | | } |
| | | try { |
| | | return Integer.valueOf(normalized); |
| | | } catch (NumberFormatException ex) { |
| | | throw new IllegalArgumentException(label + "格式错误", ex); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 使用海诊通用户快照填充本地用户资料。 |
| | | */ |