| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.tcm.training.admin.member.enums.UserStatusEnum; |
| | | import com.tcm.training.admin.member.enums.UserTypeEnum; |
| | | |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | |
| | | |
| | | AppUser user = new AppUser(); |
| | | user.setPhone(phone); |
| | | user.setType(0); |
| | | user.setStatus(1); |
| | | user.setType(UserTypeEnum.DOCTOR.getValue()); |
| | | user.setStatus(UserStatusEnum.ENABLED.getValue()); |
| | | |
| | | // 优先同步海诊通同手机号用户资料,未命中时使用手机号兜底昵称。 |
| | | HztAppUser hztAppUser = findHztAppUserByPhone(phone); |
| | |
| | | /** |
| | | * 完成经营者第二步,创建本地诊所与诊所用户。 |
| | | */ |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AppLoginResponse completeOperatorRegister(AppRegisterOperatorCompleteRequest request) { |
| | | OperatorRegisterDraft draft = loadDraft(normalizeRegisterTicket(request.getRegisterTicket())); |
| | | ensurePhoneAvailable(draft.getPhone()); |
| | |
| | | clinic.setAddress(trimRequired(request.getDetailAddress(), "请输入详细地址")); |
| | | clinic.setBusinessLicenseUrl(trimToNull(request.getBusinessLicenseUrl())); |
| | | clinic.setInviteCode(generateInviteCode()); |
| | | clinic.setStatus(1); |
| | | clinic.setStatus(UserStatusEnum.ENABLED.getValue()); |
| | | |
| | | clinic.setAgentId(4L); // 绑定到默认的省代上面 |
| | | |
| | | clinicMapper.insert(clinic); |
| | | |
| | | AppUser user = new AppUser(); |
| | | user.setNickname(clinic.getName()); |
| | | user.setPhone(draft.getPhone()); |
| | | user.setType(1); |
| | | user.setStatus(1); |
| | | user.setType(UserTypeEnum.CLINIC.getValue()); |
| | | user.setStatus(UserStatusEnum.ENABLED.getValue()); |
| | | 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()); |
| | | 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); |
| | | // 注册阶段暂未绑定区域代理,parentMobile 传空,由微赞按一级代理处理。 |
| | | log.info("调用微赞创建一级代理,入参 agentMobile={}, agentName={}, levelCode=1, storeName={}, parentMobile=18510939636", |
| | | clinic.getContactPhone(), clinic.getName(), clinic.getName()); |
| | | JsonNode vzanAgentResponse = vzanHttpUtil.createAgent( |
| | | clinic.getContactPhone(), clinic.getName(), 1, "18510939636", clinic.getName()); |
| | | log.info("微赞创建一级代理成功,出参={}", vzanAgentResponse); |
| | | } 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); |
| | | log.error("微赞创建门店或一级代理失败,本地事务将回滚,clinicId={}", clinic.getId(), ex); |
| | | throw new IllegalStateException("微赞门店或一级代理创建失败", ex); |
| | | } |
| | | |
| | | clearDraft(request.getRegisterTicket()); |