Browse Source

更新账户地理信息

pzc 4 years ago
parent
commit
02bf06b686

+ 13 - 13
ymall/src/main/java/com/liangjian11/ymall/controller/common/WechatController.java

@@ -116,18 +116,18 @@ public class WechatController {
 		redirectCodeCoookie.setMaxAge(3600);
 		response.addCookie(redirectCodeCoookie);
 
+    JSONObject userInfoJson = WechatHandle.getUserInfo(openid, appid, secret, code);
+    UserAccount userAccount = userAccountService.checkAccountByUnionid(userInfoJson);
+    Document document = MongoDBUtil.queryVLoginToken(userAccount.getId());
+    Calendar calendar = Calendar.getInstance();
+    calendar.add(Calendar.DAY_OF_YEAR,30);
+    String loginToken = UUID.randomUUID().toString();
+    if( Objects.isNull(document)){
+      MongoDBUtil.insertVLoginToken(calendar.getTime(),userAccount.getId(),loginToken,1);
+    }else{
+      MongoDBUtil.updateVLoginTOken(calendar.getTime(),userAccount.getId(),loginToken);
+    }
     if (netLoginVideoAccess.contains(redirectCode)) {
-      JSONObject userInfoJson = WechatHandle.getUserInfo(openid, appid, secret, code);
-      UserAccount userAccount = userAccountService.checkAccountByUnionid(userInfoJson);
-      Document document = MongoDBUtil.queryVLoginToken(userAccount.getId());
-      Calendar calendar = Calendar.getInstance();
-      calendar.add(Calendar.DAY_OF_YEAR,30);
-      String loginToken = UUID.randomUUID().toString();
-      if( Objects.isNull(document)){
-        MongoDBUtil.insertVLoginToken(calendar.getTime(),userAccount.getId(),loginToken,1);
-      }else{
-        MongoDBUtil.updateVLoginTOken(calendar.getTime(),userAccount.getId(),loginToken);
-      }
       Cookie cookie0 = new Cookie("loginTokenAccount", userAccount.getId());
       cookie0.setPath("/");
       cookie0.setMaxAge(24 * 60 * 60);
@@ -154,8 +154,8 @@ public class WechatController {
     }
 
     //原.net授权
-    JSONObject userInfoJson = WechatHandle.getUserInfo(openid, appid, secret, code);
-    UserAccount user = userAccountService.checkAccountByUnionid(userInfoJson);
+    JSONObject userInfoJson1 = WechatHandle.getUserInfo(openid, appid, secret, code);
+    UserAccount user = userAccountService.checkAccountByUnionid(userInfoJson1);
     Cookie cookie1 = new Cookie("loginTokenAccount", user.getId());
     cookie1.setPath("/");
     cookie1.setMaxAge(24 * 60 * 60);