|
|
@@ -186,7 +186,8 @@ public class WxUserGrantController extends BaseController { |
|
|
String session_key = null; |
|
|
String session_key = null; |
|
|
String openId = null; |
|
|
String openId = null; |
|
|
String unionId = null; |
|
|
String unionId = null; |
|
|
boolean bHaveUnionId = false; |
|
|
|
|
|
|
|
|
boolean boolHaveUnionId = false; |
|
|
|
|
|
boolean boolFindByUnionId = false; |
|
|
Long userId = null; |
|
|
Long userId = null; |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
@@ -196,7 +197,7 @@ public class WxUserGrantController extends BaseController { |
|
|
openId = session.getOpenid(); |
|
|
openId = session.getOpenid(); |
|
|
unionId = session.getUnionid(); |
|
|
unionId = session.getUnionid(); |
|
|
if (StringUtils.isNotBlank(unionId)) { |
|
|
if (StringUtils.isNotBlank(unionId)) { |
|
|
bHaveUnionId = true; |
|
|
|
|
|
|
|
|
boolHaveUnionId = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
logger.info("session_key: " + session_key + ", openId: " + openId + ", unionId: " + unionId); |
|
|
logger.info("session_key: " + session_key + ", openId: " + openId + ", unionId: " + unionId); |
|
|
@@ -213,24 +214,26 @@ public class WxUserGrantController extends BaseController { |
|
|
newUser.setTenantId(wxAuthorizerInfo.getTenantId()); |
|
|
newUser.setTenantId(wxAuthorizerInfo.getTenantId()); |
|
|
newUser.setAppId(appId); |
|
|
newUser.setAppId(appId); |
|
|
newUser.setOpenId(openId); |
|
|
newUser.setOpenId(openId); |
|
|
if (bHaveUnionId) { |
|
|
|
|
|
|
|
|
if (boolHaveUnionId) { |
|
|
newUser.setUnionId(unionId); |
|
|
newUser.setUnionId(unionId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
WxCUser oldUser = null; |
|
|
WxCUser oldUser = null; |
|
|
if (bHaveUnionId) { |
|
|
|
|
|
|
|
|
if (boolHaveUnionId) { |
|
|
// 优先根据unionId查询 |
|
|
// 优先根据unionId查询 |
|
|
WxCUser userQ = new WxCUser(); |
|
|
WxCUser userQ = new WxCUser(); |
|
|
userQ.setTenantId(wxAuthorizerInfo.getTenantId()); |
|
|
userQ.setTenantId(wxAuthorizerInfo.getTenantId()); |
|
|
userQ.setUnionId(unionId); |
|
|
userQ.setUnionId(unionId); |
|
|
oldUser = wxCUserService.getByObject(userQ); |
|
|
oldUser = wxCUserService.getByObject(userQ); |
|
|
|
|
|
if(oldUser != null) { |
|
|
|
|
|
boolFindByUnionId = true; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
if (oldUser == null) { |
|
|
if (oldUser == null) { |
|
|
oldUser = wxCUserService.getByOpenId(newUser); |
|
|
oldUser = wxCUserService.getByOpenId(newUser); |
|
|
} |
|
|
} |
|
|
if (oldUser != null) { |
|
|
if (oldUser != null) { |
|
|
// 已有用户 |
|
|
// 已有用户 |
|
|
userId = oldUser.getId(); |
|
|
|
|
|
token = oldUser.createToken(new Date()); |
|
|
token = oldUser.createToken(new Date()); |
|
|
|
|
|
|
|
|
resultMap.put("token", token); |
|
|
resultMap.put("token", token); |
|
|
@@ -241,7 +244,7 @@ public class WxUserGrantController extends BaseController { |
|
|
oldUser.setSessionKey(session_key); |
|
|
oldUser.setSessionKey(session_key); |
|
|
oldUser.setAppId(appId); |
|
|
oldUser.setAppId(appId); |
|
|
oldUser.setOpenId(openId); |
|
|
oldUser.setOpenId(openId); |
|
|
if (bHaveUnionId) { |
|
|
|
|
|
|
|
|
if (boolHaveUnionId) { |
|
|
oldUser.setUnionId(unionId); |
|
|
oldUser.setUnionId(unionId); |
|
|
} |
|
|
} |
|
|
if (StringUtils.isNotBlank(wxAuthorizerInfo.getOpenAppid())) { |
|
|
if (StringUtils.isNotBlank(wxAuthorizerInfo.getOpenAppid())) { |
|
|
@@ -272,9 +275,10 @@ public class WxUserGrantController extends BaseController { |
|
|
userTokenService.saveOrUpdate(oldUser); |
|
|
userTokenService.saveOrUpdate(oldUser); |
|
|
|
|
|
|
|
|
// 登录后处理 |
|
|
// 登录后处理 |
|
|
int score = wxCUserService.actionAfterLogin(oldUser); |
|
|
|
|
|
|
|
|
int score = wxCUserService.actionAfterLogin(oldUser, boolFindByUnionId); |
|
|
resultMap.put("score", score); |
|
|
resultMap.put("score", score); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
// 新用户 |
|
|
newUser.setTenantId(wxAuthorizerInfo.getTenantId()); |
|
|
newUser.setTenantId(wxAuthorizerInfo.getTenantId()); |
|
|
token = newUser.createToken(new Date()); |
|
|
token = newUser.createToken(new Date()); |
|
|
|
|
|
|
|
|
@@ -309,7 +313,7 @@ public class WxUserGrantController extends BaseController { |
|
|
request.setAttribute(Constant.TENANT_ID, newUser.getTenantId()); |
|
|
request.setAttribute(Constant.TENANT_ID, newUser.getTenantId()); |
|
|
|
|
|
|
|
|
// 登录后处理 |
|
|
// 登录后处理 |
|
|
int score = wxCUserService.actionAfterLogin(newUser); |
|
|
|
|
|
|
|
|
int score = wxCUserService.actionAfterLogin(newUser, null); |
|
|
resultMap.put("score", score); |
|
|
resultMap.put("score", score); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|