提交 133f0cc7 编写于 作者:  Peijun.zhao's avatar Peijun.zhao

Merge branch 'release' into 'master'

Release



See merge request !58
流水线 #31913 已失败 于阶段
in 0 second
...@@ -6,6 +6,16 @@ public class DiyAcctInitReq { ...@@ -6,6 +6,16 @@ public class DiyAcctInitReq {
private List<String> decryMobileList; private List<String> decryMobileList;
private List<DiyAcctInit> diyAcctInitList;
public List<DiyAcctInit> getDiyAcctInitList() {
return diyAcctInitList;
}
public void setDiyAcctInitList(List<DiyAcctInit> diyAcctInitList) {
this.diyAcctInitList = diyAcctInitList;
}
public List<String> getDecryMobileList() { public List<String> getDecryMobileList() {
return decryMobileList; return decryMobileList;
} }
......
...@@ -3,9 +3,9 @@ package com.pica.cloud.account.account.server.service.impl; ...@@ -3,9 +3,9 @@ package com.pica.cloud.account.account.server.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.common.req.circle.CircleAcctInit; import com.pica.cloud.account.account.common.req.circle.CircleAcctInit;
import com.pica.cloud.account.account.common.req.circle.CircleAcctInitReq; import com.pica.cloud.account.account.common.req.circle.CircleAcctInitReq;
import com.pica.cloud.account.account.common.req.circle.DiyAcctInit;
import com.pica.cloud.account.account.common.req.shop.ShopAcctInit; import com.pica.cloud.account.account.common.req.shop.ShopAcctInit;
import com.pica.cloud.account.account.common.req.shop.ShopAcctInitReq; import com.pica.cloud.account.account.common.req.shop.ShopAcctInitReq;
import com.pica.cloud.account.account.common.req.circle.DiyAcctInit;
import com.pica.cloud.account.account.common.req.circle.DiyAcctInitReq; import com.pica.cloud.account.account.common.req.circle.DiyAcctInitReq;
import com.pica.cloud.account.account.server.entity.Account; import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum; import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
...@@ -14,6 +14,7 @@ import com.pica.cloud.account.account.server.service.AccountService; ...@@ -14,6 +14,7 @@ import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.account.account.server.service.CircleAccountService; import com.pica.cloud.account.account.server.service.CircleAccountService;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants; import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils; import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -78,20 +79,40 @@ public class CircleAccountServiceImpl implements CircleAccountService { ...@@ -78,20 +79,40 @@ public class CircleAccountServiceImpl implements CircleAccountService {
logger.info("createDiyAccount:{}", JSONObject.toJSONString(diyAcctInitReq)); logger.info("createDiyAccount:{}", JSONObject.toJSONString(diyAcctInitReq));
List<Integer> savedIds = new ArrayList<>(); List<Integer> savedIds = new ArrayList<>();
try { try {
for(String decryMobile : diyAcctInitReq.getDecryMobileList()){ if(CollectionUtils.isNotEmpty(diyAcctInitReq.getDecryMobileList())){
String encryMobile = EncryptUtils.encryptContent(decryMobile, EncryptConstants.ENCRYPT_TYPE_MOBILE); for(String decryMobile : diyAcctInitReq.getDecryMobileList()){
String encryMobile = EncryptUtils.encryptContent(decryMobile, EncryptConstants.ENCRYPT_TYPE_MOBILE);
Account dbAcct = accountMapper.getByMobilePhone(encryMobile); //获取医生表账号信息 Account dbAcct = accountMapper.getByMobilePhone(encryMobile); //获取医生表账号信息
if(null == dbAcct){ if(null == dbAcct){
Account account = new Account(); Account account = new Account();
account.setMobilePhone(encryMobile); account.setMobilePhone(encryMobile);
account.setRegisterSource(5); //admin account.setRegisterSource(5); //admin
accountService.createAccount(account,AccountTypeEnum.PRODUCT_TYPE_ECO_LIVE.getCode()); accountService.createAccount(account,AccountTypeEnum.PRODUCT_TYPE_ECO_LIVE.getCode());
savedIds.add(account.getId().intValue()); savedIds.add(account.getId().intValue());
logger.info("createDiyAccount insert {}",account.getId().intValue()); logger.info("createDiyAccount insert {}",account.getId().intValue());
}else { }else {
savedIds.add(dbAcct.getId().intValue()); savedIds.add(dbAcct.getId().intValue());
logger.info("createDiyAccount exist {}",dbAcct.getId().intValue()); logger.info("createDiyAccount exist {}",dbAcct.getId().intValue());
}
}
}else {
if(CollectionUtils.isNotEmpty(diyAcctInitReq.getDiyAcctInitList())){
for(DiyAcctInit acctInit : diyAcctInitReq.getDiyAcctInitList()){
String encryMobile = EncryptUtils.encryptContent(acctInit.getDecryMobile(), EncryptConstants.ENCRYPT_TYPE_MOBILE);
Account dbAcct = accountMapper.getByMobilePhone(encryMobile); //获取医生表账号信息
if(null == dbAcct){
Account account = new Account();
account.setName(acctInit.getUserName());
account.setMobilePhone(encryMobile);
account.setRegisterSource(5); //admin
accountService.createAccount(account,AccountTypeEnum.PRODUCT_TYPE_ECO_LIVE.getCode());
savedIds.add(account.getId().intValue());
logger.info("createDiyAccount insert {}",account.getId().intValue());
}else {
savedIds.add(dbAcct.getId().intValue());
logger.info("createDiyAccount exist {}",dbAcct.getId().intValue());
}
}
} }
} }
}catch (Exception e){ }catch (Exception e){
......
...@@ -129,7 +129,7 @@ public class LoginServiceImpl implements LoginService { ...@@ -129,7 +129,7 @@ public class LoginServiceImpl implements LoginService {
public LoginResult login(BaseRequest request) { public LoginResult login(BaseRequest request) {
//接入新旭事务一致性 //接入新旭事务一致性
String batchNo = IntactUtils.getUUID(); String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"request:"+ JSON.toJSONString(request)); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "request:" + JSON.toJSONString(request));
String mobile = request.getMobile(); String mobile = request.getMobile();
Integer sourceType = request.getSourceType(); Integer sourceType = request.getSourceType();
String encrypt = AESUtil.encryptV0(mobile); String encrypt = AESUtil.encryptV0(mobile);
...@@ -143,11 +143,11 @@ public class LoginServiceImpl implements LoginService { ...@@ -143,11 +143,11 @@ public class LoginServiceImpl implements LoginService {
// 新版-未设置密码 // 新版-未设置密码
if (StringUtils.isEmpty(oldPwd)) { if (StringUtils.isEmpty(oldPwd)) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) { if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该手机号尚未设置密码,设置密码请前往云鹊医APP,或使用其他方式登录。"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该手机号尚未设置密码,设置密码请前往云鹊医APP,或使用其他方式登录。");
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getCode(), throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getMessage()); AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getMessage());
} else { } else {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该手机号{mobile}尚未设置密码,请先设置密码。"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该手机号{mobile}尚未设置密码,请先设置密码。");
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getCode(), throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getCode(),
AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getMessage() AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getMessage()
...@@ -159,12 +159,12 @@ public class LoginServiceImpl implements LoginService { ...@@ -159,12 +159,12 @@ public class LoginServiceImpl implements LoginService {
String lockKey = Constants.ACCOUNT_LOCK_KEY.replace("{mobile}", mobile); String lockKey = Constants.ACCOUNT_LOCK_KEY.replace("{mobile}", mobile);
if (redisClient.exists(lockKey)) { if (redisClient.exists(lockKey)) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) { if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该账号密码错误次数已达上限请24小时后再试,或请使用其他登录方式"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该账号密码错误次数已达上限请24小时后再试,或请使用其他登录方式");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getCode(), throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getMessage()); AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getMessage());
} else { } else {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该账号{mobile}的密码错误次数已达上限请24小时后再试,或请使用其他登录方式或找回密码"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该账号{mobile}的密码错误次数已达上限请24小时后再试,或请使用其他登录方式或找回密码");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5.getCode(), throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5.getMessage().replace("{mobile}", mobile)); AccountExceptionEnum.PICA_PWD_MISMATCH_5.getMessage().replace("{mobile}", mobile));
...@@ -172,7 +172,7 @@ public class LoginServiceImpl implements LoginService { ...@@ -172,7 +172,7 @@ public class LoginServiceImpl implements LoginService {
} }
if (password.equals(oldPwd)) { if (password.equals(oldPwd)) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"接下来调用pwdLoginCorrect"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "接下来调用pwdLoginCorrect");
return pwdLoginCorrect(request, mobile, encrypt, accountInfoEntity); return pwdLoginCorrect(request, mobile, encrypt, accountInfoEntity);
} else { } else {
...@@ -182,7 +182,7 @@ public class LoginServiceImpl implements LoginService { ...@@ -182,7 +182,7 @@ public class LoginServiceImpl implements LoginService {
errorCount = errorCount + 1; errorCount = errorCount + 1;
redisClient.set(errorKey, errorCount, Constants.PWD_ERROR_NUM_SECONDS); redisClient.set(errorKey, errorCount, Constants.PWD_ERROR_NUM_SECONDS);
if (errorCount <= 4) { if (errorCount <= 4) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"密码错误,请重试"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "密码错误,请重试");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_4.getCode(), throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_4.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_4.getMessage()); AccountExceptionEnum.PICA_PWD_MISMATCH_4.getMessage());
...@@ -190,12 +190,12 @@ public class LoginServiceImpl implements LoginService { ...@@ -190,12 +190,12 @@ public class LoginServiceImpl implements LoginService {
// 设置账号锁定24h // 设置账号锁定24h
redisClient.set(lockKey, mobile, Constants.PWD_ERROR_NUM_SECONDS); redisClient.set(lockKey, mobile, Constants.PWD_ERROR_NUM_SECONDS);
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) { if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该账号密码错误次数已达上限请24小时后再试,或请使用其他登录方式"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该账号密码错误次数已达上限请24小时后再试,或请使用其他登录方式");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getCode(), throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getMessage()); AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getMessage());
} else { } else {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该账号{mobile}的密码错误次数已达上限请24小时后再试,或请使用其他登录方式或找回密码"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该账号{mobile}的密码错误次数已达上限请24小时后再试,或请使用其他登录方式或找回密码");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5.getCode(), throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5.getMessage().replace("{mobile}", mobile)); AccountExceptionEnum.PICA_PWD_MISMATCH_5.getMessage().replace("{mobile}", mobile));
...@@ -203,7 +203,7 @@ public class LoginServiceImpl implements LoginService { ...@@ -203,7 +203,7 @@ public class LoginServiceImpl implements LoginService {
} }
} else { } else {
redisClient.set(errorKey, 1, Constants.PWD_ERROR_NUM_SECONDS); redisClient.set(errorKey, 1, Constants.PWD_ERROR_NUM_SECONDS);
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"密码错误,请重试"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "密码错误,请重试");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_4.getCode(), throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_4.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_4.getMessage()); AccountExceptionEnum.PICA_PWD_MISMATCH_4.getMessage());
...@@ -214,12 +214,12 @@ public class LoginServiceImpl implements LoginService { ...@@ -214,12 +214,12 @@ public class LoginServiceImpl implements LoginService {
} else { } else {
// 旧版本 // 旧版本
if (password.equals(oldPwd)) { if (password.equals(oldPwd)) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"接下来调用pwdLoginCorrect"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "接下来调用pwdLoginCorrect");
return pwdLoginCorrect(request, mobile, encrypt, accountInfoEntity); return pwdLoginCorrect(request, mobile, encrypt, accountInfoEntity);
} else { } else {
logger.info("login failure:" + mobile); logger.info("login failure:" + mobile);
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"请输入正确的密码"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "请输入正确的密码");
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_ERROR.getCode(), AccountExceptionEnum.PICA_PASSWORD_ERROR.getMessage()); throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_ERROR.getCode(), AccountExceptionEnum.PICA_PASSWORD_ERROR.getMessage());
} }
...@@ -228,20 +228,20 @@ public class LoginServiceImpl implements LoginService { ...@@ -228,20 +228,20 @@ public class LoginServiceImpl implements LoginService {
if (null != request.getBizType() && if (null != request.getBizType() &&
request.getBizType().equals(1)) { request.getBizType().equals(1)) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) { if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该手机号尚未设置密码,设置密码请前往云鹊医APP,或使用其他方式登录。"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该手机号尚未设置密码,设置密码请前往云鹊医APP,或使用其他方式登录。");
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getCode(), throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getMessage()); AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getMessage());
} else { } else {
// 新版-未注册 // 新版-未注册
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该手机号{mobile}尚未设置密码,请先设置密码。"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该手机号{mobile}尚未设置密码,请先设置密码。");
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getCode(), throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getCode(),
AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getMessage() AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getMessage()
.replace("{mobile}", mobile)); .replace("{mobile}", mobile));
} }
} else { } else {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"未注册,请先注册"); intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "未注册,请先注册");
throw new PicaException(AccountExceptionEnum.PICA_NOT_REGISTER.getCode(), AccountExceptionEnum.PICA_NOT_REGISTER.getMessage()); throw new PicaException(AccountExceptionEnum.PICA_NOT_REGISTER.getCode(), AccountExceptionEnum.PICA_NOT_REGISTER.getMessage());
} }
...@@ -259,16 +259,16 @@ public class LoginServiceImpl implements LoginService { ...@@ -259,16 +259,16 @@ public class LoginServiceImpl implements LoginService {
private LoginResult pwdLoginCorrect(BaseRequest request, String mobile, String encrypt, AccountInfoEntity accountInfoEntity) { private LoginResult pwdLoginCorrect(BaseRequest request, String mobile, String encrypt, AccountInfoEntity accountInfoEntity) {
//接入新旭事务一致性 //接入新旭事务一致性
String batchNo = IntactUtils.getUUID(); String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"pwdLoginCorrect",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"request:"+ JSON.toJSONString(request)+",+mobile:"+mobile+",encrypt:"+encrypt+",accountInfoEntity:"+JSON.toJSONString(accountInfoEntity)); intactUtil.sendIntact(batchNo, "pwdLoginCorrect", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "request:" + JSON.toJSONString(request) + ",+mobile:" + mobile + ",encrypt:" + encrypt + ",accountInfoEntity:" + JSON.toJSONString(accountInfoEntity));
Date currentTime = new Date(); Date currentTime = new Date();
Integer acctId = accountInfoEntity.getId(); Integer acctId = accountInfoEntity.getId();
int productType = request.getProductType(); int productType = request.getProductType();
int sourceType = request.getSourceType(); int sourceType = request.getSourceType();
Doctor doctorInfo = null; Doctor doctorInfo = null;
doctorInfo = doctorInfoMapper.getDoctorInfoByMobile(encrypt); doctorInfo = doctorInfoMapper.getDoctorInfoByMobile(encrypt);
if(null == doctorInfo){ if (null == doctorInfo) {
logger.error("此手机号无用户:{}",mobile); logger.error("此手机号无用户:{}", mobile);
intactUtil.sendIntact(batchNo,"pwdLoginCorrect",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"request:"+ JSON.toJSONString(request)+",+mobile 此手机号无用户:"+mobile+",encrypt:"+",accountInfoEntity:"+JSON.toJSONString(accountInfoEntity)); intactUtil.sendIntact(batchNo, "pwdLoginCorrect", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "request:" + JSON.toJSONString(request) + ",+mobile 此手机号无用户:" + mobile + ",encrypt:" + ",accountInfoEntity:" + JSON.toJSONString(accountInfoEntity));
} }
Integer userId = 0; Integer userId = 0;
if (productType != AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) { if (productType != AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
...@@ -303,232 +303,232 @@ public class LoginServiceImpl implements LoginService { ...@@ -303,232 +303,232 @@ public class LoginServiceImpl implements LoginService {
redisClient.del(pwdErrorNum); redisClient.del(pwdErrorNum);
} }
} }
intactUtil.sendIntact(batchNo,"pwdLoginCorrect",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"request:"+ JSON.toJSONString(request)+",+mobile:"+mobile+",encrypt:"+",accountInfoEntity:"+JSON.toJSONString(accountInfoEntity)); intactUtil.sendIntact(batchNo, "pwdLoginCorrect", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "request:" + JSON.toJSONString(request) + ",+mobile:" + mobile + ",encrypt:" + ",accountInfoEntity:" + JSON.toJSONString(accountInfoEntity));
return result; return result;
} }
@Override @Override
public LoginResult loginAndRegister(BaseRequest baseRequest) { public LoginResult loginAndRegister(BaseRequest baseRequest) {
String mobile = baseRequest.getMobile(); String mobile = baseRequest.getMobile();
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile)); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile));
logger.info("loginAndRegister-accountInfoEntity is null {}, clientIp:{}", (accountInfoEntity == null), baseRequest.getLoginIp()); logger.info("loginAndRegister-accountInfoEntity is null {}, clientIp:{}", (accountInfoEntity == null), baseRequest.getLoginIp());
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
//说明是注册功能 //说明是注册功能
accountUtils.checkRegisterMobilePhoneAndAuthCode(baseRequest.getMobile(), baseRequest.getFlag() + "", baseRequest.getAuthCode()); accountUtils.checkRegisterMobilePhoneAndAuthCode(baseRequest.getMobile(), baseRequest.getFlag() + "", baseRequest.getAuthCode());
return registerService.register(baseRequest); return registerService.register(baseRequest);
} else { } else {
//登录功能 //登录功能
accountUtils.checkMobilePhoneAndAuthCode(baseRequest.getMobile(), AccountTypeEnum.SYSCODE_TYPE_LOGIN.getCode() + "", baseRequest.getAuthCode()); accountUtils.checkMobilePhoneAndAuthCode(baseRequest.getMobile(), AccountTypeEnum.SYSCODE_TYPE_LOGIN.getCode() + "", baseRequest.getAuthCode());
return processLogin(baseRequest, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_CODE.getCode()); return processLogin(baseRequest, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_CODE.getCode());
} }
}
/**
* 登录逻辑处理
* 登录逻辑处理
*
* @param baseRequest
*/
private LoginResult processLogin(BaseRequest baseRequest, Integer acctId, Integer loginType) {
return processLogin(baseRequest, acctId, loginType, null);
}
private LoginResult processLogin(BaseRequest baseRequest, Integer acctId, Integer loginType, QueryMobileEntity queryMobileEntity) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo, "processLogin", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "baseRequest:" + JSON.toJSONString(baseRequest) + ",+acctId:" + acctId + ",loginType:" + loginType + ",queryMobileEntity:" + JSON.toJSONString(queryMobileEntity));
Date currentTime = new Date();
Long userId = accountUtils.getUserIdByAcctId(baseRequest.getProductType(), acctId);
Account account = new Account();
account.setId(userId);
account.setAcctId(acctId);
account.setCreatTime(currentTime);
account.setMobilePhone(baseRequest.getMobile());
account.setRegisterSource(baseRequest.getSourceType());
String newToken = tokenUtils.generateToken(account);
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId);
result.setMobile(baseRequest.getMobile());
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
//是否完善过个人信息(云鹊医app才需要)
if (baseRequest.getProductType() != AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
Doctor doctorEntity = doctorInfoMapper.selectByPrimaryKey(userId.intValue());
result.setEntireFlag(doctorEntity.getEntireFlag());
}
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, baseRequest.getProductType(), baseRequest.getSourceType(),
loginType, baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOG_TYPE_LOGIN.getCode(), newToken, 1, baseRequest.getUserTokenTourist());
if (queryMobileEntity != null) {
entity.setQueryMobileEntity(queryMobileEntity);
} }
picaLogUtils.info(entity);
intactUtil.sendIntact(batchNo, "processLogin", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "baseRequest:" + JSON.toJSONString(baseRequest) + ",+acctId:" + acctId + ",loginType:" + loginType + ",queryMobileEntity:" + JSON.toJSONString(queryMobileEntity));
return result;
}
/** @Override
* 登录逻辑处理 @Transactional
* 登录逻辑处理 public LoginResult loginByWeChat(BaseRequest request) {
* //接入新旭事务一致性
* @param baseRequest String batchNo = IntactUtils.getUUID();
*/ intactUtil.sendIntact(batchNo, "loginByWeChat", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "request:" + JSON.toJSONString(request));
private LoginResult processLogin(BaseRequest baseRequest, Integer acctId, Integer loginType) { WeChatEntity weChatEntity = null;
return processLogin(baseRequest, acctId, loginType, null); if (null != request.getBizType() &&
request.getBizType().equals(1)) {
// h5微信登录 TODO 下次单独拆分出去一个新接口
weChatEntity = WeChatUtils.getAuthorizationInfo(appIdH5, appSecretH5, request.getWeChatCode());
} else {
// 原生微信登录
weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode());
} }
if (weChatEntity == null || StringUtils.isEmpty(weChatEntity.getOpenid()) || StringUtils.isEmpty(weChatEntity.getAccess_token())) {
intactUtil.sendIntact(batchNo, "loginByWeChat", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "微信登录授权code不正确:");
private LoginResult processLogin(BaseRequest baseRequest, Integer acctId, Integer loginType, QueryMobileEntity queryMobileEntity) { throw new PicaException(AccountExceptionEnum.PICA_WECHAT_CODE_ERROR.getCode(), AccountExceptionEnum.PICA_WECHAT_CODE_ERROR.getMessage());
//接入新旭事务一致性 }
String batchNo = IntactUtils.getUUID(); // 微信登录获取个人信息
intactUtil.sendIntact(batchNo,"processLogin",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"baseRequest:"+ JSON.toJSONString(baseRequest)+",+acctId:"+acctId+",loginType:"+loginType+",queryMobileEntity:"+JSON.toJSONString(queryMobileEntity)); Map map = new HashMap();
Date currentTime = new Date(); map.put("access_token", weChatEntity.getAccess_token());
Long userId = accountUtils.getUserIdByAcctId(baseRequest.getProductType(), acctId); map.put("openid", weChatEntity.getOpenid());
Map weChatUserInfo = WeChatUtils.getWeChatUserInfo(map, weChatURL);
WeChatUserInfoEntity weChatUserInfoEntity = WeChatUtils.mergeWechatUserInfo(weChatUserInfo, weChatEntity.getOpenid());
logger.info("loginByWeChat: 获取微信用户信息:{}", JSONObject.toJSONString(weChatUserInfoEntity));
String unionId = weChatUserInfoEntity.getUnionid();
if (StringUtil.isEmpty(unionId)) {
logger.error("loginByWeChat get unionId:{}", unionId);
intactUtil.sendIntact(batchNo, "loginByWeChat", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "微信登录无法获取unionId:");
throw new PicaException(AccountExceptionEnum.PICA_WECHAT_CODE_ERROR.getCode(), AccountExceptionEnum.PICA_WECHAT_CODE_ERROR.getMessage());
}
AccountUnionEntity accountUnionEntity = accountUnionMapper.selectByUnionId(unionId);
logger.info("loginByWeChat accountUnionEntity:{}", JSONObject.toJSONString(accountUnionEntity));
//是否绑定逻辑的判断
if (accountUnionEntity != null) {
Long acctId = accountUnionEntity.getAcctId();
Long userId = accountUtils.getUserIdByAcctId(request.getProductType(), acctId.intValue());
Account account = new Account(); Account account = new Account();
account.setId(userId); account.setId(userId);
account.setAcctId(acctId); account.setAcctId(acctId.intValue());
account.setCreatTime(currentTime); account.setCreatTime(new Date());
account.setMobilePhone(baseRequest.getMobile()); Doctor d = doctorInfoMapper.selectByPrimaryKey(Math.toIntExact(userId));
account.setRegisterSource(baseRequest.getSourceType()); if (d != null && StringUtils.isNotBlank(d.getMobilePhone())) {
account.setMobilePhone(AESUtil.decryptV0(d.getMobilePhone()));
} else {
account.setMobilePhone("");
}
account.setRegisterSource(request.getSourceType());
String newToken = tokenUtils.generateToken(account); String newToken = tokenUtils.generateToken(account);
LoginResult result = new LoginResult(); LoginResult result = new LoginResult();
result.setToken(newToken); result.setToken(newToken);
result.setUserId(userId); result.setUserId(userId);
result.setMobile(baseRequest.getMobile()); result.setBindFlag(AccountTypeEnum.BIND_STATUS_SUCCESS.getCode() + "");
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID)); result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
//是否完善过个人信息(云鹊医app才需要) if (request.getProductType() != AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
if (baseRequest.getProductType() != AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) { PICAPDoctor doctor = doctorInfoMapper.queryDoctor(userId);
Doctor doctorEntity = doctorInfoMapper.selectByPrimaryKey(userId.intValue()); result.setEntireFlag(doctor.getEntire_flag());
result.setEntireFlag(doctorEntity.getEntireFlag()); result.setMobile(AESUtil.decryptV0(doctor.getMobile_phone()));
} }
//记录登录日志 //记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, baseRequest.getProductType(), baseRequest.getSourceType(), LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(
loginType, baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOG_TYPE_LOGIN.getCode(),newToken,1,baseRequest.getUserTokenTourist()); Integer.valueOf(String.valueOf(acctId)),
if (queryMobileEntity != null) { request.getProductType(), request.getSourceType(),
entity.setQueryMobileEntity(queryMobileEntity); AccountTypeEnum.LOGIN_WE_CHAT.getCode(),
} request.getLoginIp(),
AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode(), newToken, 1, request.getUserTokenTourist());
picaLogUtils.info(entity); picaLogUtils.info(entity);
intactUtil.sendIntact(batchNo,"processLogin",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"baseRequest:"+ JSON.toJSONString(baseRequest)+",+acctId:"+acctId+",loginType:"+loginType+",queryMobileEntity:"+JSON.toJSONString(queryMobileEntity)); intactUtil.sendIntact(batchNo, "loginByWeChat", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "request:" + JSON.toJSONString(request));
return result;
}
@Override return result;
@Transactional } else {
public LoginResult loginByWeChat(BaseRequest request) { AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId);
//接入新旭事务一致性 //如果微信信息表数据不存在,就把用户信息存储到微信信息表中。
String batchNo = IntactUtils.getUUID(); if (entity == null) {
intactUtil.sendIntact(batchNo,"loginByWeChat",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"request:"+ JSON.toJSONString(request)); processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType());
WeChatEntity weChatEntity = null;
if (null != request.getBizType() &&
request.getBizType().equals(1)) {
// h5微信登录 TODO 下次单独拆分出去一个新接口
weChatEntity = WeChatUtils.getAuthorizationInfo(appIdH5, appSecretH5, request.getWeChatCode());
} else {
// 原生微信登录
weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode());
}
if (weChatEntity == null || StringUtils.isEmpty(weChatEntity.getOpenid()) || StringUtils.isEmpty(weChatEntity.getAccess_token())) {
intactUtil.sendIntact(batchNo,"loginByWeChat",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"微信登录授权code不正确:");
throw new PicaException(AccountExceptionEnum.PICA_WECHAT_CODE_ERROR.getCode(), AccountExceptionEnum.PICA_WECHAT_CODE_ERROR.getMessage());
}
// 微信登录获取个人信息
Map map = new HashMap();
map.put("access_token", weChatEntity.getAccess_token());
map.put("openid", weChatEntity.getOpenid());
Map weChatUserInfo = WeChatUtils.getWeChatUserInfo(map, weChatURL);
WeChatUserInfoEntity weChatUserInfoEntity = WeChatUtils.mergeWechatUserInfo(weChatUserInfo, weChatEntity.getOpenid());
logger.info("loginByWeChat: 获取微信用户信息:{}",JSONObject.toJSONString(weChatUserInfoEntity));
String unionId = weChatUserInfoEntity.getUnionid();
if(StringUtil.isEmpty(unionId)){
logger.error("loginByWeChat get unionId:{}",unionId);
intactUtil.sendIntact(batchNo,"loginByWeChat",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"微信登录无法获取unionId:");
throw new PicaException(AccountExceptionEnum.PICA_WECHAT_CODE_ERROR.getCode(), AccountExceptionEnum.PICA_WECHAT_CODE_ERROR.getMessage());
} }
AccountUnionEntity accountUnionEntity = accountUnionMapper.selectByUnionId(unionId); LoginResult result = new LoginResult();
logger.info("loginByWeChat accountUnionEntity:{}",JSONObject.toJSONString(accountUnionEntity)); result.setUnionId(unionId);
//是否绑定逻辑的判断 result.setBindFlag(AccountTypeEnum.BIND_STATUS_FAILURE.getCode() + "");
if (accountUnionEntity != null) { intactUtil.sendIntact(batchNo, "loginByWeChat", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "request:" + JSON.toJSONString(request));
Long acctId = accountUnionEntity.getAcctId();
Long userId = accountUtils.getUserIdByAcctId(request.getProductType(), acctId.intValue());
Account account = new Account();
account.setId(userId);
account.setAcctId(acctId.intValue());
account.setCreatTime(new Date());
Doctor d = doctorInfoMapper.selectByPrimaryKey(Math.toIntExact(userId));
if (d != null && StringUtils.isNotBlank(d.getMobilePhone())){
account.setMobilePhone(AESUtil.decryptV0(d.getMobilePhone()));
} else {
account.setMobilePhone("");
}
account.setRegisterSource(request.getSourceType());
String newToken = tokenUtils.generateToken(account);
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId);
result.setBindFlag(AccountTypeEnum.BIND_STATUS_SUCCESS.getCode() + "");
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
if (request.getProductType() != AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
PICAPDoctor doctor = doctorInfoMapper.queryDoctor(userId);
result.setEntireFlag(doctor.getEntire_flag());
result.setMobile(AESUtil.decryptV0(doctor.getMobile_phone()));
}
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(
Integer.valueOf(String.valueOf(acctId)),
request.getProductType(), request.getSourceType(),
AccountTypeEnum.LOGIN_WE_CHAT.getCode(),
request.getLoginIp(),
AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode(),newToken,1,request.getUserTokenTourist());
picaLogUtils.info(entity);
intactUtil.sendIntact(batchNo,"loginByWeChat",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"request:"+ JSON.toJSONString(request));
return result;
} else {
AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId);
//如果微信信息表数据不存在,就把用户信息存储到微信信息表中。
if (entity == null) {
processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType());
}
LoginResult result = new LoginResult();
result.setUnionId(unionId);
result.setBindFlag(AccountTypeEnum.BIND_STATUS_FAILURE.getCode() + "");
intactUtil.sendIntact(batchNo,"loginByWeChat",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"request:"+ JSON.toJSONString(request));
return result; return result;
}
} }
}
@Override @Override
public LoginResult loginByWeChatStep(BaseRequest request) { public LoginResult loginByWeChatStep(BaseRequest request) {
//判断当前手机号是否注册过,注册过,直接登录;没有注册过,进行注册操操作 //判断当前手机号是否注册过,注册过,直接登录;没有注册过,进行注册操操作
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile())); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
logger.info("loginByWeChatStep-accountInfoEntity is null {}, clientIp:{}", (accountInfoEntity == null), request.getLoginIp()); logger.info("loginByWeChatStep-accountInfoEntity is null {}, clientIp:{}", (accountInfoEntity == null), request.getLoginIp());
LoginResult result; LoginResult result;
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
accountUtils.checkRegisterMobilePhoneAndAuthCode( accountUtils.checkRegisterMobilePhoneAndAuthCode(
request.getMobile(), request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_WE_CHAT.getCode() + "", AccountTypeEnum.SYSCODE_TYPE_WE_CHAT.getCode() + "",
request.getAuthCode()); request.getAuthCode());
result = registerService.register(request); result = registerService.register(request);
if (doubleWritingMode) { if (doubleWritingMode) {
//双写模式下,要在doctor表存储unionId //双写模式下,要在doctor表存储unionId
if (result.getUserId() != null) { if (result.getUserId() != null) {
Doctor doctor = new Doctor(); Doctor doctor = new Doctor();
doctor.setId(result.getUserId().intValue()); doctor.setId(result.getUserId().intValue());
doctor.setUnionid(request.getUnionId()); doctor.setUnionid(request.getUnionId());
doctorInfoMapper.updateByPrimaryKeySelective(doctor); doctorInfoMapper.updateByPrimaryKeySelective(doctor);
}
} }
} else {
accountUtils.checkMobilePhoneAndAuthCode(
request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_WE_CHAT.getCode() + "",
request.getAuthCode());
result = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode());
} }
result.setMobile(request.getMobile()); } else {
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile())); accountUtils.checkMobilePhoneAndAuthCode(
Integer acctId = accountInfo.getId(); request.getMobile(),
AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(request.getUnionId()); AccountTypeEnum.SYSCODE_TYPE_WE_CHAT.getCode() + "",
processAccountUnion(acctId, request.getUnionId(), request.getProductType(), entity); request.getAuthCode());
return result; result = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode());
} }
result.setMobile(request.getMobile());
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
Integer acctId = accountInfo.getId();
AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(request.getUnionId());
processAccountUnion(acctId, request.getUnionId(), request.getProductType(), entity);
return result;
}
@Override @Override
@Transactional @Transactional
public void unbindWeChat(long doctorId) { public void unbindWeChat(long doctorId) {
Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId); Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId);
Map<String, Object> map = new HashedMap(2); Map<String, Object> map = new HashedMap(2);
map.put("acctId", acctId); map.put("acctId", acctId);
map.put("unionType", AccountTypeEnum.UNION_LOGIN_WE_CHAT.getCode()); map.put("unionType", AccountTypeEnum.UNION_LOGIN_WE_CHAT.getCode());
accountUnionMapper.updateUnbindByAcctId(map); accountUnionMapper.updateUnbindByAcctId(map);
if (doubleWritingMode) { if (doubleWritingMode) {
doctorService.unbindWeChat(acctId); doctorService.unbindWeChat(acctId);
}
} }
}
@Override @Override
@Transactional @Transactional
public String bindWeChat(long doctorId, BaseRequest request) { public String bindWeChat(long doctorId, BaseRequest request) {
WeChatEntity weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode()); WeChatEntity weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode());
Map map = new HashMap(); Map map = new HashMap();
map.put("access_token", weChatEntity.getAccess_token()); map.put("access_token", weChatEntity.getAccess_token());
map.put("openid", weChatEntity.getOpenid()); map.put("openid", weChatEntity.getOpenid());
Map weChatUserInfo = WeChatUtils.getWeChatUserInfo(map, weChatURL); Map weChatUserInfo = WeChatUtils.getWeChatUserInfo(map, weChatURL);
WeChatUserInfoEntity weChatUserInfoEntity = WeChatUtils.mergeWechatUserInfo(weChatUserInfo, weChatEntity.getOpenid()); WeChatUserInfoEntity weChatUserInfoEntity = WeChatUtils.mergeWechatUserInfo(weChatUserInfo, weChatEntity.getOpenid());
String unionId = weChatUserInfoEntity.getUnionid(); String unionId = weChatUserInfoEntity.getUnionid();
AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId); AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId);
if (entity == null) { if (entity == null) {
processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType()); processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType());
} else { } else {
updateWechatInfoUser(entity, weChatUserInfoEntity); updateWechatInfoUser(entity, weChatUserInfoEntity);
}
Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId);
processAccountUnion(acctId, unionId, request.getProductType(), entity);
return weChatUserInfoEntity.getNickname();
} }
Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId);
processAccountUnion(acctId, unionId, request.getProductType(), entity);
return weChatUserInfoEntity.getNickname();
}
@Override @Override
@Transactional @Transactional
...@@ -548,499 +548,502 @@ public class LoginServiceImpl implements LoginService { ...@@ -548,499 +548,502 @@ public class LoginServiceImpl implements LoginService {
} }
Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId); Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId);
processAccountUnion(acctId, unionId, request.getProductType(), entity); processAccountUnion(acctId, unionId, request.getProductType(), entity);
Map<String,String> rtnMap = new HashMap(); Map<String, String> rtnMap = new HashMap();
rtnMap.put("openId",weChatEntity.getOpenid()); rtnMap.put("openId", weChatEntity.getOpenid());
rtnMap.put("nickname",weChatUserInfoEntity.getNickname()); rtnMap.put("nickname", weChatUserInfoEntity.getNickname());
return rtnMap; return rtnMap;
} }
/** /**
* 把unionId存储到联合登录表中 * 把unionId存储到联合登录表中
* *
* @param acctId * @param acctId
* @param unionId * @param unionId
*/ */
private void processAccountUnion(Integer acctId, String unionId, Integer productType, AccountWeChatInfoEntity entity) { private void processAccountUnion(Integer acctId, String unionId, Integer productType, AccountWeChatInfoEntity entity) {
//接入新旭事务一致性 //接入新旭事务一致性
String batchNo = IntactUtils.getUUID(); String batchNo = IntactUtils.getUUID();
if(null == acctId || 0 == acctId){ if (null == acctId || 0 == acctId) {
throw new PicaException(AccountExceptionEnum.PICA_LOGIN_AGAIN.getCode(), AccountExceptionEnum.PICA_LOGIN_AGAIN.getMessage()); throw new PicaException(AccountExceptionEnum.PICA_LOGIN_AGAIN.getCode(), AccountExceptionEnum.PICA_LOGIN_AGAIN.getMessage());
} }
intactUtil.sendIntact(batchNo,"processAccountUnion",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"acctId:"+acctId+",unionId:"+unionId+",productType:"+productType); intactUtil.sendIntact(batchNo, "processAccountUnion", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "acctId:" + acctId + ",unionId:" + unionId + ",productType:" + productType);
//先查询当前产品线是否有记录?如果有就更新成delete_flag=2; 然后在插入新的绑定记录 //先查询当前产品线是否有记录?如果有就更新成delete_flag=2; 然后在插入新的绑定记录
AccountUnionEntity accountUnionResult = accountUnionMapper.selectByUnionId(unionId); AccountUnionEntity accountUnionResult = accountUnionMapper.selectByUnionId(unionId);
if (accountUnionResult != null) { if (accountUnionResult != null) {
intactUtil.sendIntact(batchNo,"processAccountUnion",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该微信号已绑定其他云鹊医账户,你可以使用微信登录云鹊医,在「设置」页解除绑定"); intactUtil.sendIntact(batchNo, "processAccountUnion", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该微信号已绑定其他云鹊医账户,你可以使用微信登录云鹊医,在「设置」页解除绑定");
if (entity != null) { if (entity != null) {
throw new PicaException(AccountExceptionEnum.PICA_WECHAT_UNBIND.getCode(), AccountExceptionEnum.PICA_WECHAT_UNBIND.getMessage()); throw new PicaException(AccountExceptionEnum.PICA_WECHAT_UNBIND.getCode(), AccountExceptionEnum.PICA_WECHAT_UNBIND.getMessage());
}
} }
Map<String, Object> map = new HashedMap(2); }
map.put("acctId", acctId); Map<String, Object> map = new HashedMap(2);
map.put("unionType", AccountTypeEnum.UNION_LOGIN_WE_CHAT.getCode()); map.put("acctId", acctId);
AccountUnionEntity accountUnionEntityAccount = accountUnionMapper.selectByAcctId(map); map.put("unionType", AccountTypeEnum.UNION_LOGIN_WE_CHAT.getCode());
AccountWeChatInfoEntity entity2 = null; AccountUnionEntity accountUnionEntityAccount = accountUnionMapper.selectByAcctId(map);
AccountWeChatInfoEntity entity2 = null;
if (accountUnionEntityAccount != null) {
intactUtil.sendIntact(batchNo,"processAccountUnion",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该手机号已绑定其他微信号,你可以在「设置」页解除绑定"); if (accountUnionEntityAccount != null) {
if (entity != null) { intactUtil.sendIntact(batchNo, "processAccountUnion", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该手机号已绑定其他微信号,你可以在「设置」页解除绑定");
throw new PicaException(AccountExceptionEnum.PICA_WECHAT_BIND_OTHER.getCode(), AccountExceptionEnum.PICA_WECHAT_BIND_OTHER.getMessage()); if (entity != null) {
} throw new PicaException(AccountExceptionEnum.PICA_WECHAT_BIND_OTHER.getCode(), AccountExceptionEnum.PICA_WECHAT_BIND_OTHER.getMessage());
} }
}
if (accountUnionResult == null || accountUnionEntityAccount == null) {
if (accountUnionResult == null || accountUnionEntityAccount == null) { /**存在刷的数据,account_wechat_info没数据,但是account_union有数据,这时候删除account_union数据重新绑定*/
AccountUnionEntity accountUnionEntity = new AccountUnionEntity(); if (entity == null && accountUnionEntityAccount != null) {
accountUnionEntity.setAcctId(acctId.longValue()); accountUnionMapper.deleteByAcctId(acctId);
accountUnionEntity.setDeleteFlag(1);
accountUnionEntity.setUnionId(unionId);
accountUnionEntity.setCreatedTime(new Date());
accountUnionEntity.setModifiedTime(new Date());
accountUnionEntity.setCreatedId(acctId);
accountUnionEntity.setModifiedId(acctId);
accountUnionEntity.setUnionType(AccountTypeEnum.UNION_LOGIN_WE_CHAT.getCode());
accountUnionMapper.insertSelective(accountUnionEntity);
if (doubleWritingMode) { //双写模式
doctorService.bindWeChat(acctId, unionId);
}
intactUtil.sendIntact(batchNo, "processAccountUnion", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "acctId:" + acctId + ",unionId:" + unionId + ",productType:" + productType);
} }
AccountUnionEntity accountUnionEntity = new AccountUnionEntity();
accountUnionEntity.setAcctId(acctId.longValue());
accountUnionEntity.setDeleteFlag(1);
accountUnionEntity.setUnionId(unionId);
accountUnionEntity.setCreatedTime(new Date());
accountUnionEntity.setModifiedTime(new Date());
accountUnionEntity.setCreatedId(acctId);
accountUnionEntity.setModifiedId(acctId);
accountUnionEntity.setUnionType(AccountTypeEnum.UNION_LOGIN_WE_CHAT.getCode());
accountUnionMapper.insertSelective(accountUnionEntity);
if (doubleWritingMode) { //双写模式
doctorService.bindWeChat(acctId, unionId);
}
intactUtil.sendIntact(batchNo, "processAccountUnion", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "acctId:" + acctId + ",unionId:" + unionId + ",productType:" + productType);
} }
private void processWeChatInfoUser(WeChatUserInfoEntity weChatUserInfoEntity, int type) { }
AccountWeChatInfoEntity accountWeChatInfoEntity = new AccountWeChatInfoEntity();
Date currentTime = new Date();
accountWeChatInfoEntity.setCreatedId(0);
accountWeChatInfoEntity.setCreatedTime(currentTime);
accountWeChatInfoEntity.setDeleteFlag(1);
accountWeChatInfoEntity.setGroupid(weChatUserInfoEntity.getGroupid() + "");
accountWeChatInfoEntity.setType(type);
accountWeChatInfoEntity.setModifiedId(0);
accountWeChatInfoEntity.setModifiedTime(currentTime);
accountWeChatInfoEntity.setOpenid(weChatUserInfoEntity.getOpenid());
accountWeChatInfoEntity.setUnionid(weChatUserInfoEntity.getUnionid());
accountWeChatInfoEntity.setPrivilege(weChatUserInfoEntity.getPrivilege());
accountWeChatInfoEntity.setRemark(weChatUserInfoEntity.getRemark());
accountWeChatInfoEntity.setSubscribe(weChatUserInfoEntity.getSubscribe());
accountWeChatInfoEntity.setSubscribeTime(weChatUserInfoEntity.getSubscribe_time());
accountWeChatInfoEntity.setTagidList(weChatUserInfoEntity.getTagid_list());
accountWeChatInfoEntity.setCity(weChatUserInfoEntity.getCity());
accountWeChatInfoEntity.setNickname(weChatUserInfoEntity.getNickname());
accountWeChatInfoEntity.setHeadImgUrl(weChatUserInfoEntity.getHeadimgurl());
accountWeChatInfoEntity.setCountry(weChatUserInfoEntity.getCountry());
accountWeChatInfoEntity.setSex(null == weChatUserInfoEntity.getSex() ? 0 : weChatUserInfoEntity.getSex());
accountWeChatInfoEntity.setProvince(weChatUserInfoEntity.getProvince());
accountWeChatInfoEntity.setLanguage(weChatUserInfoEntity.getLanguage());
accountWeChatInfoMapper.insertSelective(accountWeChatInfoEntity);
}
private void updateWechatInfoUser(AccountWeChatInfoEntity entity, WeChatUserInfoEntity weChatUserInfoEntity) { private void processWeChatInfoUser(WeChatUserInfoEntity weChatUserInfoEntity, int type) {
String nickname = weChatUserInfoEntity.getNickname(); AccountWeChatInfoEntity accountWeChatInfoEntity = new AccountWeChatInfoEntity();
if (StringUtils.isNotEmpty(nickname) && !nickname.equals(entity.getNickname())) { Date currentTime = new Date();
AccountWeChatInfoEntity info = new AccountWeChatInfoEntity(); accountWeChatInfoEntity.setCreatedId(0);
info.setId(entity.getId()); accountWeChatInfoEntity.setCreatedTime(currentTime);
info.setNickname(nickname); accountWeChatInfoEntity.setDeleteFlag(1);
accountWeChatInfoMapper.updateByPrimaryKeySelective(info); accountWeChatInfoEntity.setGroupid(weChatUserInfoEntity.getGroupid() + "");
} accountWeChatInfoEntity.setType(type);
accountWeChatInfoEntity.setModifiedId(0);
accountWeChatInfoEntity.setModifiedTime(currentTime);
accountWeChatInfoEntity.setOpenid(weChatUserInfoEntity.getOpenid());
accountWeChatInfoEntity.setUnionid(weChatUserInfoEntity.getUnionid());
accountWeChatInfoEntity.setPrivilege(weChatUserInfoEntity.getPrivilege());
accountWeChatInfoEntity.setRemark(weChatUserInfoEntity.getRemark());
accountWeChatInfoEntity.setSubscribe(weChatUserInfoEntity.getSubscribe());
accountWeChatInfoEntity.setSubscribeTime(weChatUserInfoEntity.getSubscribe_time());
accountWeChatInfoEntity.setTagidList(weChatUserInfoEntity.getTagid_list());
accountWeChatInfoEntity.setCity(weChatUserInfoEntity.getCity());
accountWeChatInfoEntity.setNickname(weChatUserInfoEntity.getNickname());
accountWeChatInfoEntity.setHeadImgUrl(weChatUserInfoEntity.getHeadimgurl());
accountWeChatInfoEntity.setCountry(weChatUserInfoEntity.getCountry());
accountWeChatInfoEntity.setSex(null == weChatUserInfoEntity.getSex() ? 0 : weChatUserInfoEntity.getSex());
accountWeChatInfoEntity.setProvince(weChatUserInfoEntity.getProvince());
accountWeChatInfoEntity.setLanguage(weChatUserInfoEntity.getLanguage());
accountWeChatInfoMapper.insertSelective(accountWeChatInfoEntity);
}
private void updateWechatInfoUser(AccountWeChatInfoEntity entity, WeChatUserInfoEntity weChatUserInfoEntity) {
String nickname = weChatUserInfoEntity.getNickname();
if (StringUtils.isNotEmpty(nickname) && !nickname.equals(entity.getNickname())) {
AccountWeChatInfoEntity info = new AccountWeChatInfoEntity();
info.setId(entity.getId());
info.setNickname(nickname);
accountWeChatInfoMapper.updateByPrimaryKeySelective(info);
} }
}
@Override @Override
public PICAPDoctor queryDoctor(long doctorId) { public PICAPDoctor queryDoctor(long doctorId) {
PICAPDoctor doctor = doctorInfoMapper.queryDoctor(doctorId); PICAPDoctor doctor = doctorInfoMapper.queryDoctor(doctorId);
if (doctor == null) { if (doctor == null) {
doctor = new PICAPDoctor(); doctor = new PICAPDoctor();
}
doctor.setAvatar_image_url(this.processDoctorAvatar(doctor.getAvatar_image_url()));
return doctor;
} }
doctor.setAvatar_image_url(this.processDoctorAvatar(doctor.getAvatar_image_url()));
return doctor;
}
@Override @Override
public LoginResult oneClickLogin(OneClickLoginReq req) { public LoginResult oneClickLogin(OneClickLoginReq req) {
QueryMobileEntity queryMobileEntity = oneClickProcessor.tokenExchangeMobile(req.getToken(), req.getSourceType()); QueryMobileEntity queryMobileEntity = oneClickProcessor.tokenExchangeMobile(req.getToken(), req.getSourceType());
if (queryMobileEntity == null || StringUtils.isBlank(queryMobileEntity.getMobile()) || !ValidateUtils.isMobile(queryMobileEntity.getMobile())) { if (queryMobileEntity == null || StringUtils.isBlank(queryMobileEntity.getMobile()) || !ValidateUtils.isMobile(queryMobileEntity.getMobile())) {
logger.error("oneClickLogin 闪验获取出错-queryMobileEntity:{}",JSONObject.toJSONString(queryMobileEntity)); logger.error("oneClickLogin 闪验获取出错-queryMobileEntity:{}", JSONObject.toJSONString(queryMobileEntity));
throw new PicaException(PicaResultCode.INTERFACE_INVOKE_EXCEPTION.code(), "获取手机号失败!"); throw new PicaException(PicaResultCode.INTERFACE_INVOKE_EXCEPTION.code(), "获取手机号失败!");
} }
queryMobileEntity.setSourceType(req.getSourceType()); queryMobileEntity.setSourceType(req.getSourceType());
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(queryMobileEntity.getMobile())); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(queryMobileEntity.getMobile()));
BaseRequest baseRequest = new BaseRequest(); BaseRequest baseRequest = new BaseRequest();
baseRequest.setMobile(queryMobileEntity.getMobile()); baseRequest.setMobile(queryMobileEntity.getMobile());
baseRequest.setSourceType(req.getSourceType()); baseRequest.setSourceType(req.getSourceType());
baseRequest.setProductType(req.getProductType()); baseRequest.setProductType(req.getProductType());
baseRequest.setLoginIp(req.getLoginIp()); baseRequest.setLoginIp(req.getLoginIp());
baseRequest.setUserTokenTourist(req.getUserTokenTourist()); baseRequest.setUserTokenTourist(req.getUserTokenTourist());
LoginResult result; LoginResult result;
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
//说明是注册功能 //说明是注册功能
result = registerService.register(baseRequest, queryMobileEntity); result = registerService.register(baseRequest, queryMobileEntity);
} else { } else {
//登录功能 //登录功能
result = processLogin(baseRequest, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_ONE_CLICK.getCode(), queryMobileEntity); result = processLogin(baseRequest, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_ONE_CLICK.getCode(), queryMobileEntity);
}
return result;
} }
return result;
}
private String processDoctorAvatar(String avatar_image_url) { private String processDoctorAvatar(String avatar_image_url) {
if (StringUtils.isEmpty(avatar_image_url)) { if (StringUtils.isEmpty(avatar_image_url)) {
return DEFAULT_DOCTOR_PICTURE_URL;
} else {
int pos = avatar_image_url.lastIndexOf(".");
if (pos < 0) {
return DEFAULT_DOCTOR_PICTURE_URL; return DEFAULT_DOCTOR_PICTURE_URL;
} else { } else {
int pos = avatar_image_url.lastIndexOf("."); String ext = avatar_image_url.substring(pos + 1, avatar_image_url.length()).toLowerCase();
if (pos < 0) { return !PIC_TYPE_MAP.containsKey(ext) ? DEFAULT_DOCTOR_PICTURE_URL : avatar_image_url;
return DEFAULT_DOCTOR_PICTURE_URL;
} else {
String ext = avatar_image_url.substring(pos + 1, avatar_image_url.length()).toLowerCase();
return !PIC_TYPE_MAP.containsKey(ext) ? DEFAULT_DOCTOR_PICTURE_URL : avatar_image_url;
}
} }
} }
}
/** /**
* @Description 统一校验(传空则不会校验) * @Description 统一校验(传空则不会校验)
* @Author Chongwen.jiang * @Author Chongwen.jiang
* @Date 2020/2/20 16:55 * @Date 2020/2/20 16:55
* @ModifyDate 2020/2/20 16:55 * @ModifyDate 2020/2/20 16:55
* @Params [request] * @Params [request]
* @Return com.pica.cloud.foundation.entity.PicaResponse * @Return com.pica.cloud.foundation.entity.PicaResponse
*/ */
@Override @Override
public void preLoginValidate(BaseRequest request) { public void preLoginValidate(BaseRequest request) {
Integer bizType = request.getBizType(); Integer bizType = request.getBizType();
String mobile = request.getMobile(); String mobile = request.getMobile();
Integer sourceType = request.getSourceType(); Integer sourceType = request.getSourceType();
if (null == bizType) {
logger.info("bizType is null");
throw new PicaWarnException(PicaResultCode.PARAM_IS_BLANK.code(),
PicaResultCode.PARAM_IS_BLANK.message());
}
if (bizType.equals(2)) {
// 手机号规则校验
if (StringUtils.isNotEmpty(mobile) &&
!ValidateUtils.isMobile(mobile)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getCode(),
AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getMessage());
}
} else if (bizType.equals(3)) {
// 手机号规则校验
if (StringUtils.isNotEmpty(mobile) &&
!ValidateUtils.isMobile(mobile)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getCode(),
AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getMessage());
}
// 手机号是否注册
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile));
if (accountInfo == null) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getMessage());
} else {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_REGIST.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_REGIST.getMessage().replace("{mobile}", mobile));
}
}
// 手机号是否设置了密码
if (StringUtils.isEmpty(accountInfo.getPassword())) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getMessage());
} else {
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD.getMessage().replace("{mobile}", mobile));
}
}
}
if (null == bizType) {
logger.info("bizType is null");
throw new PicaWarnException(PicaResultCode.PARAM_IS_BLANK.code(),
PicaResultCode.PARAM_IS_BLANK.message());
} }
/** if (bizType.equals(2)) {
* @Description 苹果登录授权 // 手机号规则校验
* @Author Chongwen.jiang if (StringUtils.isNotEmpty(mobile) &&
* @Date 2020/2/24 19:21 !ValidateUtils.isMobile(mobile)) {
* @ModifyDate 2020/2/24 19:21 throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getCode(),
* @Params [request] AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getMessage());
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
@Transactional
@Override
public LoginResult loginByApple(BaseRequest request) {
long start = System.currentTimeMillis();
// 入参非空判断
if (StringUtils.isEmpty(request.getIdentifyToken())) {
throw new PicaException(AccountExceptionEnum.PICA_PARAMS_ERROR.getCode(),
AccountExceptionEnum.PICA_PARAMS_ERROR.getMessage());
} }
// identifyToken校验 } else if (bizType.equals(3)) {
if(!checkIdentifyToken(request)){ // 手机号规则校验
throw new PicaException( if (StringUtils.isNotEmpty(mobile) &&
AccountExceptionEnum.PICA_APPLE_TOKEN_ERROR.getCode(), !ValidateUtils.isMobile(mobile)) {
AccountExceptionEnum.PICA_APPLE_TOKEN_ERROR.getMessage()); throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getCode(),
AccountExceptionEnum.PICA_MOBILE_REG_FALSE.getMessage());
} }
// apple授权登录用户信息入库 // 手机号是否注册
AccountUnionEntity accountUnion = accountUnionMapper.selectByUnionId(request.getAppleUserId()); AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile));
//是否绑定逻辑的判断 if (accountInfo == null) {
if (accountUnion != null) { if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
Long acctId = accountUnion.getAcctId(); throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getCode(),
Long userId = accountUtils.getUserIdByAcctId(null, acctId.intValue()); AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getMessage());
Account account = new Account(); } else {
account.setId(userId); throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_REGIST.getCode(),
account.setAcctId(acctId.intValue()); AccountExceptionEnum.PICA_MOBILE_NOT_REGIST.getMessage().replace("{mobile}", mobile));
account.setCreatTime(new Date());
account.setMobilePhone("");
account.setRegisterSource(request.getSourceType());
String newToken = tokenUtils.generateToken(account);
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId);
result.setBindFlag(AccountTypeEnum.BIND_STATUS_SUCCESS.getCode() + "");
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
if (request.getProductType() != AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
PICAPDoctor doctor = doctorInfoMapper.queryDoctor(userId);
result.setEntireFlag(doctor.getEntire_flag());
result.setMobile(AESUtil.decryptV0(doctor.getMobile_phone()));
} }
//记录登录日志 }
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity( // 手机号是否设置了密码
Integer.valueOf(String.valueOf(acctId)), if (StringUtils.isEmpty(accountInfo.getPassword())) {
request.getProductType(), request.getSourceType(), if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
AccountTypeEnum.LOGIN_APPLE.getCode(), throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getCode(),
request.getLoginIp(), AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getMessage());
AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), } else {
AccountTypeEnum.LOG_TYPE_LOGIN.getCode(),newToken,1,request.getUserTokenTourist()); throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD.getCode(),
picaLogUtils.info(entity); AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD.getMessage().replace("{mobile}", mobile));
long end1 = System.currentTimeMillis();
logger.info("loginByApple1-duration {} millionSeconds", (end1-start));
return result;
} else {
AccountAppleInfo entity = accountAppleInfoMapper.selectByUserId(request.getAppleUserId());
//如果apple信息表数据不存在,就把用户信息存储到apple信息表中。
if (entity == null) {
processAppleInfoUser(request);
} }
LoginResult result = new LoginResult();
result.setUnionId(request.getAppleUserId());
result.setBindFlag(AccountTypeEnum.BIND_STATUS_FAILURE.getCode() + "");
long end1 = System.currentTimeMillis();
logger.info("loginByApple2-duration {} millionSeconds", (end1-start));
return result;
} }
} }
/**
* @Description apple登录--identifyToken校验
* @Author Chongwen.jiang
* @Date 2020/2/24 19:28
* @ModifyDate 2020/2/24 19:28
* @Params [identifyToekn]
* @Return boolean false:未通过token校验,true:通过校验
*/
private boolean checkIdentifyToken(BaseRequest request) {
String identifyToken = request.getIdentifyToken();
logger.info("checkIdentifyToken-identifyToken:{}", identifyToken);
// 向苹果后台获取公钥参数
String appleResp = null;
try {
appleResp = HttpClientCloudUtils.getHttpExecute(Constants.APPLE_GET_PUBLIC_KEY_URL);
logger.info("checkIdentifyToken-appleResp:{}", appleResp);
} catch (Exception e) {
logger.info("checkIdentifyToken-get apple public key fail " + e.getMessage());
throw new PicaException("get apple public key fail Exception", "get apple public key fail");
}
JSONObject appleRespJson = JSONObject.parseObject(appleResp);
String keys = appleRespJson.getString("keys");
JSONArray keysArr = JSONObject.parseArray(keys);
if (identifyToken.split("\\.").length < 2) { }
throw new PicaException("get identifyToken fail Exception", "get identifyToken format Exception");
}
JSONObject useAppleAuth = new JSONObject();
String inAuth = new String(Base64.decodeBase64(identifyToken.split("\\.")[0]));
String inKid = JSONObject.parseObject(inAuth).get("kid").toString();
for(Object obj : keysArr){
JSONObject appleAuth = JSONObject.parseObject(obj.toString());
if(inKid.equals(appleAuth.getString("kid"))){
useAppleAuth = appleAuth;
logger.info("checkIdentifyToken-jsonObject1:{}", useAppleAuth);
break;
}
}
// 通过jar生成publicKey /**
PublicKey publicKey; * @Description 苹果登录授权
try { * @Author Chongwen.jiang
Jwk jwa = Jwk.fromValues(useAppleAuth); * @Date 2020/2/24 19:21
publicKey = jwa.getPublicKey(); * @ModifyDate 2020/2/24 19:21
} catch (Exception e) { * @Params [request]
logger.info("checkIdentifyToken-generate publicKey fail " + e.getMessage()); * @Return com.pica.cloud.account.account.server.entity.LoginResult
throw new PicaException("checkIdentifyToken-generate publicKey fail", "generate publicKey fail"); */
@Transactional
@Override
public LoginResult loginByApple(BaseRequest request) {
long start = System.currentTimeMillis();
// 入参非空判断
if (StringUtils.isEmpty(request.getIdentifyToken())) {
throw new PicaException(AccountExceptionEnum.PICA_PARAMS_ERROR.getCode(),
AccountExceptionEnum.PICA_PARAMS_ERROR.getMessage());
}
// identifyToken校验
if (!checkIdentifyToken(request)) {
throw new PicaException(
AccountExceptionEnum.PICA_APPLE_TOKEN_ERROR.getCode(),
AccountExceptionEnum.PICA_APPLE_TOKEN_ERROR.getMessage());
}
// apple授权登录用户信息入库
AccountUnionEntity accountUnion = accountUnionMapper.selectByUnionId(request.getAppleUserId());
//是否绑定逻辑的判断
if (accountUnion != null) {
Long acctId = accountUnion.getAcctId();
Long userId = accountUtils.getUserIdByAcctId(null, acctId.intValue());
Account account = new Account();
account.setId(userId);
account.setAcctId(acctId.intValue());
account.setCreatTime(new Date());
account.setMobilePhone("");
account.setRegisterSource(request.getSourceType());
String newToken = tokenUtils.generateToken(account);
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId);
result.setBindFlag(AccountTypeEnum.BIND_STATUS_SUCCESS.getCode() + "");
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
if (request.getProductType() != AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
PICAPDoctor doctor = doctorInfoMapper.queryDoctor(userId);
result.setEntireFlag(doctor.getEntire_flag());
result.setMobile(AESUtil.decryptV0(doctor.getMobile_phone()));
} }
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(
Integer.valueOf(String.valueOf(acctId)),
request.getProductType(), request.getSourceType(),
AccountTypeEnum.LOGIN_APPLE.getCode(),
request.getLoginIp(),
AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode(), newToken, 1, request.getUserTokenTourist());
picaLogUtils.info(entity);
// 分割前台传过来的identifyToken(jwt格式的token)用base64解码使用 long end1 = System.currentTimeMillis();
String aud; logger.info("loginByApple1-duration {} millionSeconds", (end1 - start));
String sub; return result;
try { } else {
String claim = new String(Base64.decodeBase64(identifyToken.split("\\.")[1])); AccountAppleInfo entity = accountAppleInfoMapper.selectByUserId(request.getAppleUserId());
//logger.info("checkIdentifyToken-claim:{}", claim); //如果apple信息表数据不存在,就把用户信息存储到apple信息表中。
aud = JSONObject.parseObject(claim).get("aud").toString(); if (entity == null) {
sub = JSONObject.parseObject(claim).get("sub").toString(); processAppleInfoUser(request);
// appleUserId从token中解码取出后赋值
request.setAppleUserId(sub);
} catch (Exception e) {
logger.info("checkIdentifyToken-token decode fail " + e.getMessage());
throw new PicaException("checkIdentifyToken-token decode fail Exception", "token decode fail");
} }
return this.verify(publicKey, identifyToken, aud, sub, request); LoginResult result = new LoginResult();
result.setUnionId(request.getAppleUserId());
result.setBindFlag(AccountTypeEnum.BIND_STATUS_FAILURE.getCode() + "");
long end1 = System.currentTimeMillis();
logger.info("loginByApple2-duration {} millionSeconds", (end1 - start));
return result;
} }
}
/** /**
* @Description 验证苹果公钥 * @Description apple登录--identifyToken校验
* @Author Chongwen.jiang * @Author Chongwen.jiang
* @Date 2020/2/24 19:49 * @Date 2020/2/24 19:28
* @ModifyDate 2020/2/24 19:49 * @ModifyDate 2020/2/24 19:28
* @Params [key, jwt, audience, subject] * @Params [identifyToekn]
* @Return boolean * @Return boolean false:未通过token校验,true:通过校验
*/ */
private boolean verify(PublicKey key, String jwt, String audience, String subject, BaseRequest request) { private boolean checkIdentifyToken(BaseRequest request) {
JwtParser jwtParser = Jwts.parser().setSigningKey(key); String identifyToken = request.getIdentifyToken();
jwtParser.requireIssuer(Constants.APPLE_ISSUE_URL); logger.info("checkIdentifyToken-identifyToken:{}", identifyToken);
jwtParser.requireAudience(audience); // 向苹果后台获取公钥参数
jwtParser.requireSubject(subject); String appleResp = null;
try { try {
logger.info("checkIdentifyToken-apple-verify-starting"); appleResp = HttpClientCloudUtils.getHttpExecute(Constants.APPLE_GET_PUBLIC_KEY_URL);
Jws<Claims> claim = jwtParser.parseClaimsJws(jwt); logger.info("checkIdentifyToken-appleResp:{}", appleResp);
logger.info("acheckIdentifyToken-apple-verify-claim:{}", JSON.toJSONString(claim)); } catch (Exception e) {
//logger.info("apple-verify-claim.getBody:{}", JSON.toJSONString(claim.getBody())); logger.info("checkIdentifyToken-get apple public key fail " + e.getMessage());
if (claim != null && claim.getBody().containsKey("auth_time")) { throw new PicaException("get apple public key fail Exception", "get apple public key fail");
request.setInfo(JSON.toJSONString(claim.getBody())); }
JSONObject claimBody = JSONObject.parseObject(JSON.toJSONString(claim.getBody()), JSONObject.class); JSONObject appleRespJson = JSONObject.parseObject(appleResp);
request.setAppleId(claimBody.getString("email")); String keys = appleRespJson.getString("keys");
return true; JSONArray keysArr = JSONObject.parseArray(keys);
}
return false; if (identifyToken.split("\\.").length < 2) {
} catch (ExpiredJwtException e) { throw new PicaException("get identifyToken fail Exception", "get identifyToken format Exception");
logger.info("checkIdentifyToken-apple token expired " + e.getMessage()); }
throw new PicaException("apple token expired Exception", "apple token expired"); JSONObject useAppleAuth = new JSONObject();
} catch (Exception e) { String inAuth = new String(Base64.decodeBase64(identifyToken.split("\\.")[0]));
logger.info("checkIdentifyToken-apple token illegal " + e.getMessage()); String inKid = JSONObject.parseObject(inAuth).get("kid").toString();
throw new PicaException("apple token illegal Exception", "apple token illegal"); for (Object obj : keysArr) {
JSONObject appleAuth = JSONObject.parseObject(obj.toString());
if (inKid.equals(appleAuth.getString("kid"))) {
useAppleAuth = appleAuth;
logger.info("checkIdentifyToken-jsonObject1:{}", useAppleAuth);
break;
} }
} }
/** // 通过jar生成publicKey
* @Description apple用户信息入表 PublicKey publicKey;
* @Author Chongwen.jiang try {
* @Date 2020/2/24 11:00 Jwk jwa = Jwk.fromValues(useAppleAuth);
* @ModifyDate 2020/2/24 11:00 publicKey = jwa.getPublicKey();
* @Params [request] } catch (Exception e) {
* @Return void logger.info("checkIdentifyToken-generate publicKey fail " + e.getMessage());
*/ throw new PicaException("checkIdentifyToken-generate publicKey fail", "generate publicKey fail");
private void processAppleInfoUser(BaseRequest request) {
AccountAppleInfo appleInfo = new AccountAppleInfo();
appleInfo.setCreatedId(0);
appleInfo.setModifiedId(0);
appleInfo.setAppleUserId(request.getAppleUserId());
appleInfo.setAppleId(request.getAppleId());
appleInfo.setInfo(request.getInfo());
accountAppleInfoMapper.insertSelective(appleInfo);
} }
/** // 分割前台传过来的identifyToken(jwt格式的token)用base64解码使用
* @Description 苹果登录绑定手机号 String aud;
* @Author Chongwen.jiang String sub;
* @Date 2020/2/24 11:40 try {
* @ModifyDate 2020/2/24 11:40 String claim = new String(Base64.decodeBase64(identifyToken.split("\\.")[1]));
* @Params [request] //logger.info("checkIdentifyToken-claim:{}", claim);
* @Return com.pica.cloud.account.account.server.entity.LoginResult aud = JSONObject.parseObject(claim).get("aud").toString();
*/ sub = JSONObject.parseObject(claim).get("sub").toString();
@Override // appleUserId从token中解码取出后赋值
public LoginResult loginByAppleStep(BaseRequest request) { request.setAppleUserId(sub);
// 判断当前手机号是否注册过: 没有注册过,进行注册操操作, 注册过,直接登录; } catch (Exception e) {
AccountInfoEntity accountInfoDb = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile())); logger.info("checkIdentifyToken-token decode fail " + e.getMessage());
logger.info("loginByAppleStep-account is null {}, request:{}", accountInfoDb == null, JSON.toJSONString(request)); throw new PicaException("checkIdentifyToken-token decode fail Exception", "token decode fail");
LoginResult result;
if (accountInfoDb == null) {
// 验证码校验
accountUtils.checkRegisterMobilePhoneAndAuthCode(
request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_APPLE.getCode() + "",
request.getAuthCode());
result = registerService.register(request);
logger.info("loginByAppleStep-register");
} else {
// 验证码校验
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_APPLE.getCode() + "",
request.getAuthCode());
result = processLogin(request, accountInfoDb.getId(),
AccountTypeEnum.LOGIN_APPLE.getCode());
logger.info("loginByAppleStep-processLogin");
}
result.setMobile(request.getMobile());
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
Integer acctId = accountInfo.getId();
// insert account_apple_info表数据
logger.info("loginByAppleStep-insert-account_apple_info-start");
processAccountUnionApple(acctId, request.getAppleUserId());
logger.info("loginByAppleStep-insert-account_apple_info-end");
return result;
} }
return this.verify(publicKey, identifyToken, aud, sub, request);
}
/** /**
* @Description account_apple_info insert * @Description 验证苹果公钥
* @Author Chongwen.jiang * @Author Chongwen.jiang
* @Date 2020/2/24 11:34 * @Date 2020/2/24 19:49
* @ModifyDate 2020/2/24 11:34 * @ModifyDate 2020/2/24 19:49
* @Params [acctId, appleUserId] * @Params [key, jwt, audience, subject]
* @Return void * @Return boolean
*/ */
private void processAccountUnionApple(Integer acctId, String appleUserId) { private boolean verify(PublicKey key, String jwt, String audience, String subject, BaseRequest request) {
AccountUnionEntity accountUnion = accountUnionMapper.selectByUnionId(appleUserId); JwtParser jwtParser = Jwts.parser().setSigningKey(key);
if (accountUnion != null) { jwtParser.requireIssuer(Constants.APPLE_ISSUE_URL);
throw new PicaException( jwtParser.requireAudience(audience);
AccountExceptionEnum.PICA_APPLE_BIND_OTHER.getCode(), jwtParser.requireSubject(subject);
AccountExceptionEnum.PICA_APPLE_BIND_OTHER.getMessage()); try {
} logger.info("checkIdentifyToken-apple-verify-starting");
Map<String, Object> map = new HashedMap(2); Jws<Claims> claim = jwtParser.parseClaimsJws(jwt);
map.put("acctId", acctId); logger.info("acheckIdentifyToken-apple-verify-claim:{}", JSON.toJSONString(claim));
map.put("unionType", AccountTypeEnum.UNION_LOGIN_APPLE.getCode()); //logger.info("apple-verify-claim.getBody:{}", JSON.toJSONString(claim.getBody()));
AccountUnionEntity accountUnionEntityAccount = accountUnionMapper.selectByAcctId(map); if (claim != null && claim.getBody().containsKey("auth_time")) {
if (accountUnionEntityAccount != null) { request.setInfo(JSON.toJSONString(claim.getBody()));
throw new PicaException( JSONObject claimBody = JSONObject.parseObject(JSON.toJSONString(claim.getBody()), JSONObject.class);
AccountExceptionEnum.PICA_MOBILE_BIND_OTHER.getCode(), request.setAppleId(claimBody.getString("email"));
AccountExceptionEnum.PICA_MOBILE_BIND_OTHER.getMessage()); return true;
} }
AccountUnionEntity accountUnionEntity = new AccountUnionEntity(); return false;
accountUnionEntity.setAcctId(acctId.longValue()); } catch (ExpiredJwtException e) {
accountUnionEntity.setUnionId(appleUserId); logger.info("checkIdentifyToken-apple token expired " + e.getMessage());
accountUnionEntity.setCreatedId(acctId); throw new PicaException("apple token expired Exception", "apple token expired");
accountUnionEntity.setModifiedId(acctId); } catch (Exception e) {
accountUnionEntity.setUnionType(AccountTypeEnum.UNION_LOGIN_APPLE.getCode()); logger.info("checkIdentifyToken-apple token illegal " + e.getMessage());
accountUnionMapper.insertSelective(accountUnionEntity); throw new PicaException("apple token illegal Exception", "apple token illegal");
} }
}
/**
* @Description apple用户信息入表
* @Author Chongwen.jiang
* @Date 2020/2/24 11:00
* @ModifyDate 2020/2/24 11:00
* @Params [request]
* @Return void
*/
private void processAppleInfoUser(BaseRequest request) {
AccountAppleInfo appleInfo = new AccountAppleInfo();
appleInfo.setCreatedId(0);
appleInfo.setModifiedId(0);
appleInfo.setAppleUserId(request.getAppleUserId());
appleInfo.setAppleId(request.getAppleId());
appleInfo.setInfo(request.getInfo());
accountAppleInfoMapper.insertSelective(appleInfo);
}
/** /**
* @Description TODO * @Description 苹果登录绑定手机号
* @Author peijun.zhao * @Author Chongwen.jiang
* @Date 2020/4/22 17:14 * @Date 2020/2/24 11:40
* @ModifyDate 2020/4/22 17:14 * @ModifyDate 2020/2/24 11:40
* @Params [aes] * @Params [request]
* @Return int * @Return com.pica.cloud.account.account.server.entity.LoginResult
*/ */
@Override @Override
public int insertLoginAesLog(LogLoginAes aes){ public LoginResult loginByAppleStep(BaseRequest request) {
aes.setDeleteFlag(1); // 判断当前手机号是否注册过: 没有注册过,进行注册操操作, 注册过,直接登录;
aes.setCreateId(999999); AccountInfoEntity accountInfoDb = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
aes.setModifyId(999999); logger.info("loginByAppleStep-account is null {}, request:{}", accountInfoDb == null, JSON.toJSONString(request));
aes.setCreateTime(new Date()); LoginResult result;
aes.setModifyTime(new Date()); if (accountInfoDb == null) {
return logLoginAesMapper.insert(aes); // 验证码校验
accountUtils.checkRegisterMobilePhoneAndAuthCode(
request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_APPLE.getCode() + "",
request.getAuthCode());
result = registerService.register(request);
logger.info("loginByAppleStep-register");
} else {
// 验证码校验
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_APPLE.getCode() + "",
request.getAuthCode());
result = processLogin(request, accountInfoDb.getId(),
AccountTypeEnum.LOGIN_APPLE.getCode());
logger.info("loginByAppleStep-processLogin");
} }
result.setMobile(request.getMobile());
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
Integer acctId = accountInfo.getId();
// insert account_apple_info表数据
logger.info("loginByAppleStep-insert-account_apple_info-start");
processAccountUnionApple(acctId, request.getAppleUserId());
logger.info("loginByAppleStep-insert-account_apple_info-end");
return result;
}
/**
* @Description account_apple_info insert
* @Author Chongwen.jiang
* @Date 2020/2/24 11:34
* @ModifyDate 2020/2/24 11:34
* @Params [acctId, appleUserId]
* @Return void
*/
private void processAccountUnionApple(Integer acctId, String appleUserId) {
AccountUnionEntity accountUnion = accountUnionMapper.selectByUnionId(appleUserId);
if (accountUnion != null) {
throw new PicaException(
AccountExceptionEnum.PICA_APPLE_BIND_OTHER.getCode(),
AccountExceptionEnum.PICA_APPLE_BIND_OTHER.getMessage());
}
Map<String, Object> map = new HashedMap(2);
map.put("acctId", acctId);
map.put("unionType", AccountTypeEnum.UNION_LOGIN_APPLE.getCode());
AccountUnionEntity accountUnionEntityAccount = accountUnionMapper.selectByAcctId(map);
if (accountUnionEntityAccount != null) {
throw new PicaException(
AccountExceptionEnum.PICA_MOBILE_BIND_OTHER.getCode(),
AccountExceptionEnum.PICA_MOBILE_BIND_OTHER.getMessage());
}
AccountUnionEntity accountUnionEntity = new AccountUnionEntity();
accountUnionEntity.setAcctId(acctId.longValue());
accountUnionEntity.setUnionId(appleUserId);
accountUnionEntity.setCreatedId(acctId);
accountUnionEntity.setModifiedId(acctId);
accountUnionEntity.setUnionType(AccountTypeEnum.UNION_LOGIN_APPLE.getCode());
accountUnionMapper.insertSelective(accountUnionEntity);
} }
/**
* @Description TODO
* @Author peijun.zhao
* @Date 2020/4/22 17:14
* @ModifyDate 2020/4/22 17:14
* @Params [aes]
* @Return int
*/
@Override
public int insertLoginAesLog(LogLoginAes aes) {
aes.setDeleteFlag(1);
aes.setCreateId(999999);
aes.setModifyId(999999);
aes.setCreateTime(new Date());
aes.setModifyTime(new Date());
return logLoginAesMapper.insert(aes);
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册