liaoyongfei 4 år sedan
förälder
incheckning
bf06656eb6

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

@@ -91,7 +91,7 @@ public class WechatController {
 						@RequestParam(name = "code", defaultValue = "", required = false) String code,
 						@RequestParam(name = "id", defaultValue = "", required = false) String id,// ID参数占位
 						@RequestParam(name = "redirectCode", defaultValue = "", required = false) String redirectCode,
-						@RequestParam(name = "identity", defaultValue = "0", required = false) Integer identity,
+						@RequestParam(name = "identity", required = false) Integer identity,
 						HttpServletRequest request, HttpServletResponse response) throws IOException {
 		String fillInfoPath = redirectPathSource.getFillInfo();
 		if (StringUtils.isBlank(code)) {
@@ -137,43 +137,37 @@ public class WechatController {
 		cookie1.setMaxAge(24 * 60 * 60);
 		cookie1.setDomain("360lj.com");
 		response.addCookie(cookie1);
-//    if (netLoginVideoAccess.contains(redirectCode)) {
-//      if (identity.equals(0)) {  //用户授权
-//        if (StringUtils.isBlank(userAccount.getNickname())) {
-//          String url = redirectPathSource.getRedirectPath(redirectCode, userAccount, id);
-//          logger.debug("将跳转至:" + url);
-//          response.sendRedirect(url);
-//          return;
-//        }
-//      }
-//      String url = redirectPathSource.getRedirectPath(redirectCode, null, "");
-//      logger.debug("将跳转至:"+url);
-//      response.sendRedirect(url);
-//      return;
-//    }
-		
-		if (identity.equals(0)) {  //用户授权
-			// 判断是否有该用户,如果有跳转个人中心,没有则跳转注册页面
-			if (userAccount == null) {
-				JSONObject userInfo = WechatHandle.getUserInfo(openid, appid, secret, code);
-				userAccountService.create(userInfo);
-				logger.info("将跳转至: " + fillInfoPath);
-				String html = "<script type='text/javascript'>location.href='" + fillInfoPath + "';</script>";
-				response.getWriter().print(html);
-				return;
-			}
-			if (StringUtils.isBlank(userAccount.getMobile())) {
-				logger.info("将跳转至: " + fillInfoPath);
-				String html = "<script type='text/javascript'>location.href='" + fillInfoPath + "';</script>";
-				response.getWriter().print(html);
-				return;
-			}
-		} else if (identity.equals(1) || identity.equals(2)) { //医生合伙人授权
-			userRoleService.checkRole(identity, userAccount, id, redirectCode, response);
-			return;
-		}
-		
-		
+
+		if(identity!=null) {
+      if (identity.equals(0)) {  //用户授权
+        if (StringUtils.isNotBlank(userAccount.getNickname())) {
+          response.sendRedirect(redirectPathSource.getRedirectPath(redirectCode, userAccount, id));
+          return;
+        }
+        response.sendRedirect(redirectPathSource.getRedirectPath(redirectCode, null, ""));
+        return;
+      } else if (identity.equals(1) || identity.equals(2)) { //医生合伙人授权
+        userRoleService.checkRole(identity, userAccount, id, redirectCode, response);
+        return;
+      }
+    }
+
+    // 判断是否有该用户,如果有跳转个人中心,没有则跳转注册页面
+    if (userAccount == null) {
+      JSONObject userInfo = WechatHandle.getUserInfo(openid, appid, secret, code);
+      userAccountService.create(userInfo);
+      logger.info("将跳转至: " + fillInfoPath);
+      String html = "<script type='text/javascript'>location.href='" + fillInfoPath + "';</script>";
+      response.getWriter().print(html);
+      return;
+    }
+    if (StringUtils.isBlank(userAccount.getMobile())) {
+      logger.info("将跳转至: " + fillInfoPath);
+      String html = "<script type='text/javascript'>location.href='" + fillInfoPath + "';</script>";
+      response.getWriter().print(html);
+      return;
+    }
+
 		String otherRedirectPath = redirectPathSource.getRedirectPath(redirectCode, userAccount, id);
 		logger.info("将跳转至: " + otherRedirectPath);
 		String html = "<script type='text/javascript'>" +