|
@@ -49,7 +49,6 @@ public class ApiAuthController extends ApiBaseAction {
|
|
|
@PostMapping("login_by_weixin")
|
|
|
public Object loginByWeixin() {
|
|
|
Map<String, Object> resultObj = new HashMap();
|
|
|
- //
|
|
|
JSONObject jsonParam = this.getJsonRequest();
|
|
|
FullUserInfo fullUserInfo = null;
|
|
|
Long storeId = jsonParam.getLong("storeId");
|
|
@@ -62,12 +61,19 @@ public class ApiAuthController extends ApiBaseAction {
|
|
|
}
|
|
|
//
|
|
|
UserInfo userInfo = fullUserInfo.getUserInfo();
|
|
|
+ if(userInfo == null){
|
|
|
+ return toResponsFail("登录失败");
|
|
|
+ }
|
|
|
//获取openid
|
|
|
String requestUrl = ApiUserUtils.getWebAccess(code);//通过自定义工具类组合出小程序需要的登录凭证 code
|
|
|
logger.info("》》》组合token为:" + requestUrl);
|
|
|
JSONObject sessionData = CommonUtil.httpsRequest(requestUrl, "GET", null);
|
|
|
|
|
|
- if (null == sessionData || StringUtils.isNullOrEmpty(sessionData.getString("openid"))) {
|
|
|
+ if (null == sessionData) {
|
|
|
+ return toResponsFail("登录失败");
|
|
|
+ }
|
|
|
+ String openId = sessionData.getString("openid");
|
|
|
+ if (StringUtils.isNullOrEmpty(openId)) {
|
|
|
return toResponsFail("登录失败");
|
|
|
}
|
|
|
//验证用户信息完整性
|
|
@@ -76,11 +82,11 @@ public class ApiAuthController extends ApiBaseAction {
|
|
|
return toResponsFail("登录失败");
|
|
|
}
|
|
|
Date nowTime = new Date();
|
|
|
- UserVo userVo = userService.queryByOpenId(sessionData.getString("openid"));
|
|
|
+ UserVo userVo = userService.queryByOpenId(openId);
|
|
|
userInfo.setNickName(filterEmoji(userInfo.getNickName()));;
|
|
|
if (null == userVo) {
|
|
|
userVo = new UserVo();
|
|
|
- userVo.setPassword(sessionData.getString("openid"));
|
|
|
+ userVo.setPassword(openId);
|
|
|
userVo.setRegister_time(nowTime);
|
|
|
userVo.setRegister_ip(this.getClientIp());
|
|
|
userVo.setLast_login_ip(userVo.getRegister_ip());
|