|
|
@ -199,13 +199,15 @@ public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService |
|
|
* @return 是否操作成功 |
|
|
* @return 是否操作成功 |
|
|
*/ |
|
|
*/ |
|
|
private EnterpriseUser saveOrUpdateEnterpriseUser(JSONObject userInfo) { |
|
|
private EnterpriseUser saveOrUpdateEnterpriseUser(JSONObject userInfo) { |
|
|
String phone = IdCardCryptoUtil.symmetricDecryptIdCard(secretKey, userInfo.getString("phone")); |
|
|
String phone = safeDecryptPhone(userInfo.getString("phone")); |
|
|
String account = userInfo.getString("account"); |
|
|
String account = userInfo.getString("account"); |
|
|
|
|
|
String siqUserId = userInfo.getString("userId"); |
|
|
String loginName = StringUtils.isNotEmpty(account) ? account : phone; |
|
|
String loginName = StringUtils.isNotEmpty(account) ? account : phone; |
|
|
|
|
|
loginName = StringUtils.isNotEmpty(loginName) ? loginName : siqUserId; |
|
|
String userType = UserType.APP_USER.getUserType(); |
|
|
String userType = UserType.APP_USER.getUserType(); |
|
|
EnterpriseUser newUser = null; |
|
|
EnterpriseUser newUser = null; |
|
|
if (StringUtils.isEmpty(loginName)) { |
|
|
if (StringUtils.isEmpty(loginName)) { |
|
|
log.error("深i企用户账号和手机号均为空"); |
|
|
log.error("深i企用户账号、手机号、用户ID均为空"); |
|
|
throw new BaseException("深i企用户账号不能为空"); |
|
|
throw new BaseException("深i企用户账号不能为空"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -213,7 +215,6 @@ public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService |
|
|
queryWrapper.eq(EnterpriseUser::getLoginName, loginName); |
|
|
queryWrapper.eq(EnterpriseUser::getLoginName, loginName); |
|
|
|
|
|
|
|
|
EnterpriseUser existUser = enterpriseUserMapper.selectOne(queryWrapper); |
|
|
EnterpriseUser existUser = enterpriseUserMapper.selectOne(queryWrapper); |
|
|
Long userId; |
|
|
|
|
|
if (existUser == null) { |
|
|
if (existUser == null) { |
|
|
log.info("企业用户不存在,执行新增操作: userName={}, userType={}", loginName, userType); |
|
|
log.info("企业用户不存在,执行新增操作: userName={}, userType={}", loginName, userType); |
|
|
newUser = buildEnterpriseUser(userInfo, userType); |
|
|
newUser = buildEnterpriseUser(userInfo, userType); |
|
|
@ -238,15 +239,18 @@ public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService |
|
|
*/ |
|
|
*/ |
|
|
private EnterpriseUser buildEnterpriseUser(JSONObject userInfo, String userType) { |
|
|
private EnterpriseUser buildEnterpriseUser(JSONObject userInfo, String userType) { |
|
|
EnterpriseUser user = new EnterpriseUser(); |
|
|
EnterpriseUser user = new EnterpriseUser(); |
|
|
String phone = IdCardCryptoUtil.symmetricDecryptIdCard(secretKey, userInfo.getString("phone")); |
|
|
String phone = safeDecryptPhone(userInfo.getString("phone")); |
|
|
String account = userInfo.getString("account"); |
|
|
String account = userInfo.getString("account"); |
|
|
|
|
|
String siqUserId = userInfo.getString("userId"); |
|
|
String loginName = StringUtils.isNotEmpty(account) ? account : phone; |
|
|
String loginName = StringUtils.isNotEmpty(account) ? account : phone; |
|
|
|
|
|
loginName = StringUtils.isNotEmpty(loginName) ? loginName : siqUserId; |
|
|
// 基本信息
|
|
|
// 基本信息
|
|
|
user.setUserName(userInfo.getString("userName")); |
|
|
user.setUserName(userInfo.getString("userName")); |
|
|
user.setUserType(userType); |
|
|
user.setUserType(userType); |
|
|
user.setLoginName(loginName); |
|
|
user.setLoginName(loginName); |
|
|
user.setPhonenumber(phone); |
|
|
user.setPhonenumber(phone); |
|
|
user.setNickName(userInfo.getString("userName")); |
|
|
user.setNickName(userInfo.getString("userName")); |
|
|
|
|
|
user.setSiqUserId(siqUserId); |
|
|
|
|
|
|
|
|
// 设置默认部门ID
|
|
|
// 设置默认部门ID
|
|
|
user.setDeptId(UserConstants.DEFAULT_DEPT); |
|
|
user.setDeptId(UserConstants.DEFAULT_DEPT); |
|
|
@ -550,4 +554,16 @@ public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService |
|
|
|
|
|
|
|
|
return token; |
|
|
return token; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String safeDecryptPhone(String phone) { |
|
|
|
|
|
if (StringUtils.isEmpty(phone)) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
return IdCardCryptoUtil.symmetricDecryptIdCard(secretKey, phone); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.warn("解密手机号失败: {}", phone, e); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|