admin
2020-05-06 24a8d17e007545f7426c48352109aa1a9c6587ee
fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java
@@ -20,6 +20,8 @@
import com.yeshi.fanli.exception.taobao.TaoBaoAuthException;
import com.yeshi.fanli.exception.user.UserExtraTaoBaoInfoException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.log.LogManager;
import com.yeshi.fanli.log.LogType;
import com.yeshi.fanli.service.inter.user.UserActiveLogService;
import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService;
@@ -67,11 +69,11 @@
   @RequestMapping(value = "tb")
   public void tb(String code, String state, HttpServletRequest request, HttpServletResponse response) {
      LogHelper.test("淘宝授权回调:" + code + ":" + state);
      LogManager.getLogger(LogType.taobaoAuth).info("淘宝授权回调:" + code + ":" + state);
      if (StringUtil.isNullOrEmpty(code) || StringUtil.isNullOrEmpty(state)) {
         LogHelper.error("淘宝授权回调出错");
         try {
            response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html?code=1");
            response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html?code=1");
         } catch (IOException e1) {
            e1.printStackTrace();
         }
@@ -110,9 +112,9 @@
         source = json.optString("s");
      }
      LogHelper.userErrorInfo("淘宝授权回调state:" + state);
      LogManager.getLogger(LogType.taobaoAuth).info("淘宝授权回调state:" + state);
      LogHelper.userErrorInfo("淘宝授权回调解密:" + stateStr);
      LogManager.getLogger(LogType.taobaoAuth).info("淘宝授权回调解密:" + stateStr);
      int errCode = 0;
      if (StringUtil.isNullOrEmpty(stateStr)) {
@@ -143,7 +145,7 @@
         } catch (Exception e) {
         }
         final String name = nickName;
         LogHelper.test("uid:" + uid + "\n accessToken:" + accessToken);
         LogManager.getLogger(LogType.taobaoAuth).info("uid:" + uid + "\n accessToken:" + accessToken);
         // 获取渠道ID与会员ID
         if ("share".equalsIgnoreCase(source)) {
@@ -153,12 +155,11 @@
               relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
                     TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID
            } catch (TaoBaoAuthException e) {
               LogManager.getLogger(LogType.taobaoAuth).error(uid + "渠道备案失败:" + e.getMessage());
               if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME)
                  userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "淘宝账号未实名");
            }
            if (StringUtil.isNullOrEmpty(relationId))
               LogHelper.test(uid + "渠道备案失败");
            try {
               userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid, nickName, true);
            } catch (UserExtraTaoBaoInfoException e) {
@@ -168,7 +169,7 @@
            final String relationId2 = relationId;
            // 异步申请会员ID
            final Long fuid=uid;
            final Long fuid = uid;
            ThreadUtil.run(new Runnable() {
               @Override
@@ -178,11 +179,9 @@
                     specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
                           TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
                  } catch (TaoBaoAuthException e1) {
                     LogManager.getLogger(LogType.taobaoAuth).error(fuid + "会员备案失败:" + e1.getMessage());
                  }
                  if (StringUtil.isNullOrEmpty(specialId))
                     LogHelper.test(fuid + "会员备案失败");
                  try {
                     userExtraTaoBaoInfoService.addSpecialId(fuid, specialId, taoBaoUid, name, true);
@@ -205,17 +204,16 @@
            } catch (TaoBaoAuthException e) {
               if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME)
                  userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "淘宝账号未实名");
               LogManager.getLogger(LogType.taobaoAuth).error(uid + "会员备案失败:" + e.getMessage());
            }
            if (StringUtil.isNullOrEmpty(specialId))
               LogHelper.test(uid + "会员备案失败");
            try {
               userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, nickName, true);
            } catch (UserExtraTaoBaoInfoException e) {
               LogHelper.test(e.getMsg());
               errCode = 5;
            }
            final Long fuid=uid;
            final Long fuid = uid;
            final String specialId2 = specialId;
            // 异步申请渠道ID
@@ -228,9 +226,8 @@
                     relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
                           TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
                  } catch (TaoBaoAuthException e1) {
                  } // 渠道ID
                  if (StringUtil.isNullOrEmpty(relationId))
                     LogHelper.test(fuid + "渠道备案失败");
                     LogManager.getLogger(LogType.taobaoAuth).error(fuid + "渠道备案失败:" + e1.getMessage());
                  }
                  try {
                     userExtraTaoBaoInfoService.addRelationId(fuid, relationId, taoBaoUid, name, true);
@@ -255,11 +252,11 @@
               relationId = TaoKeApiUtil.getRelationId(accessToken, Constant.TAOBAO_AUTH_APPKEY,
                     TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID
            } catch (TaoBaoAuthException e) {
               LogManager.getLogger(LogType.taobaoAuth).error(uid + "渠道备案失败");
               tbErrorCode = e.getCode();
            }
            if (StringUtil.isNullOrEmpty(relationId)) {
               LogHelper.test(uid + "渠道备案失败");
               bindInfo = false;
            }
@@ -270,9 +267,9 @@
                        TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
               } catch (TaoBaoAuthException e) {
                  tbErrorCode = e.getCode();
                  LogManager.getLogger(LogType.taobaoAuth).error(uid + "会员备案失败");
               }
               if (StringUtil.isNullOrEmpty(specialId)) {
                  LogHelper.test(uid + "会员备案失败");
                  bindInfo = false;
               }
            }
@@ -337,17 +334,17 @@
         {
            if ("share".equalsIgnoreCase(source)) {
               if (isNewJump)
                  response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/success.html");
                  response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/success.html");
               else
                  closeWebPage(response.getWriter());
            } else if ("zigou".equalsIgnoreCase(source)) {
               if (isNewJump)
                  response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/success.html");
                  response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/success.html");
               else
                  closeWebPage(response.getWriter());
            } else if ("bind".equalsIgnoreCase(source)) {
               if (isNewJump)
                  response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/success.html");
                  response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/success.html");
               else {
                  String script = String.format(
                        "<script>if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {window.location.href = 'yestv://toast#%s';setTimeout(function(){window.location.href = 'yestv://finishPage';},100);} else {yestv.toast(\"恭喜你,淘宝绑定成功\");yestv.finishPage();}</script>",
@@ -358,17 +355,17 @@
         } else {// 失败
            if ("share".equalsIgnoreCase(source)) {
               if (isNewJump)
                  response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html");
                  response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html");
               else
                  closeWebPage(response.getWriter());
            } else if ("zigou".equalsIgnoreCase(source)) {
               if (isNewJump)
                  response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html");
                  response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html");
               else
                  closeWebPage(response.getWriter());
            } else if ("bind".equalsIgnoreCase(source)) {
               if (isNewJump)
                  response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html");
                  response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html");
               else {
                  String script = String.format(
                        "<script>if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {window.location.href = 'yestv://toast#%s';setTimeout(function(){window.location.href = 'yestv://finishPage';},100);} else {yestv.toast(\"抱歉,淘宝绑定失败\");yestv.finishPage();}</script>",
@@ -378,9 +375,8 @@
            }
         }
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
      }
   }
   private void closeWebPage(PrintWriter out) {