From 573c491b4a1ba60e12a5678a01c1546c0077c1ee Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 30 七月 2019 09:07:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java | 133 ++++++++++++++++++++++++++++++++++++++------ 1 files changed, 115 insertions(+), 18 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java b/fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java index 56f284c..74cc47c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java @@ -1,6 +1,7 @@ package com.yeshi.fanli.controller; import java.io.IOException; +import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.Date; @@ -14,8 +15,10 @@ import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.taobao.TaoBaoUnionAuthRecord; +import com.yeshi.fanli.exception.taobao.TaoBaoAuthException; import com.yeshi.fanli.exception.user.UserExtraTaoBaoInfoException; import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.msg.UserAccountMsgNotificationService; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionAuthRecordService; import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService; import com.yeshi.fanli.util.AESUtil; @@ -23,6 +26,7 @@ import com.yeshi.fanli.util.RedisManager; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TaoBaoConstant; +import com.yeshi.fanli.util.ThreadUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import net.sf.json.JSONObject; @@ -42,6 +46,9 @@ @Resource private TaoBaoUnionAuthRecordService taoBaoUnionAuthRecordService; + + @Resource + private UserAccountMsgNotificationService userAccountMsgNotificationService; @Resource private RedisManager redisManager; @@ -99,12 +106,21 @@ nickName = URLDecoder.decode(nickName, "UTF-8"); } catch (Exception e) { } - // LogHelper.test("uid:" + uid + "\n accessToken:" + accessToken); + final String name = nickName; + LogHelper.test("uid:" + uid + "\n accessToken:" + accessToken); // 鑾峰彇娓犻亾ID涓庝細鍛業D if ("share".equalsIgnoreCase(source)) { - String relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, - TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 娓犻亾ID + String relationId = null; + + try { + relationId= TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, + TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 娓犻亾ID + } catch (TaoBaoAuthException e) { + if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME) + userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "娣樺疂璐﹀彿鏈疄鍚�"); + } + if (StringUtil.isNullOrEmpty(relationId)) LogHelper.test(uid + "娓犻亾澶囨澶辫触"); try { @@ -113,9 +129,41 @@ LogHelper.test(e.getMsg()); errCode = 5; } + // 寮傛鐢宠浼氬憳ID + ThreadUtil.run(new Runnable() { + + @Override + public void run() { + String specialId = null; + try { + specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, + TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + } catch (TaoBaoAuthException e1) { + + } + + if (StringUtil.isNullOrEmpty(specialId)) + LogHelper.test(uid + "浼氬憳澶囨澶辫触"); + try { + userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, name, true); + } catch (UserExtraTaoBaoInfoException e) { + LogHelper.test(e.getMsg()); + } + } + }); + + //绋嶄綔寤惰繜 + Thread.sleep(50); } else if ("zigou".equalsIgnoreCase(source)) { - String specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, - TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + String specialId = null; + + try { + specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, + TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + } catch (TaoBaoAuthException e) { + if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME) + userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "娣樺疂璐﹀彿鏈疄鍚�"); + } if (StringUtil.isNullOrEmpty(specialId)) LogHelper.test(uid + "浼氬憳澶囨澶辫触"); @@ -125,12 +173,44 @@ LogHelper.test(e.getMsg()); errCode = 5; } + + // 寮傛鐢宠娓犻亾ID + ThreadUtil.run(new Runnable() { + + @Override + public void run() { + String relationId = null; + try { + relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, + TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + } catch (TaoBaoAuthException e1) { + } // 娓犻亾ID + if (StringUtil.isNullOrEmpty(relationId)) + LogHelper.test(uid + "娓犻亾澶囨澶辫触"); + try { + userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid, name, true); + } catch (UserExtraTaoBaoInfoException e) { + LogHelper.test(e.getMsg()); + } + } + }); + //绋嶄綔寤惰繜 + Thread.sleep(50); + } else if ("bind".equalsIgnoreCase(source)) { boolean bindInfo = true; // 缁戝畾娣樺疂锛歏1.5.3 - String relationId = TaoKeApiUtil.getRelationId(accessToken, Constant.TAOBAO_AUTH_APPKEY, - TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 娓犻亾ID + String relationId = null; + + int tbErrorCode = 0; + try { + relationId = TaoKeApiUtil.getRelationId(accessToken, Constant.TAOBAO_AUTH_APPKEY, + TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 娓犻亾ID + } catch (TaoBaoAuthException e) { + tbErrorCode = e.getCode(); + } + if (StringUtil.isNullOrEmpty(relationId)) { LogHelper.test(uid + "娓犻亾澶囨澶辫触"); bindInfo = false; @@ -138,8 +218,12 @@ String specialId = null; if (bindInfo) { - specialId = TaoKeApiUtil.getSpecialId(accessToken, Constant.TAOBAO_AUTH_APPKEY, - TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + try { + specialId = TaoKeApiUtil.getSpecialId(accessToken, Constant.TAOBAO_AUTH_APPKEY, + TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + } catch (TaoBaoAuthException e) { + tbErrorCode = e.getCode(); + } if (StringUtil.isNullOrEmpty(specialId)) { LogHelper.test(uid + "浼氬憳澶囨澶辫触"); bindInfo = false; @@ -147,6 +231,9 @@ } if (!bindInfo) { + if (tbErrorCode == TaoBaoAuthException.CODE_NOT_REAL_NAME) { + userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "娣樺疂璐﹀彿鏈疄鍚�"); + } errCode = 5;// 淇℃伅鑾峰彇涓嶅叏 } else { try { @@ -176,20 +263,18 @@ } catch (Exception e) { errCode = 4; - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } + LogHelper.errorDetailInfo(e); } try { if (errCode == 0)// 鎴愬姛 { if ("share".equalsIgnoreCase(source)) { - response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_bonusState.html?code=0"); + // response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_bonusState.html?code=0"); + closeWebPage(response.getWriter()); } else if ("zigou".equalsIgnoreCase(source)) { - response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_rebateState.html?code=0"); + // response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_rebateState.html?code=0"); + closeWebPage(response.getWriter()); } else if ("bind".equalsIgnoreCase(source)) { 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>", @@ -198,9 +283,11 @@ } } else {// 澶辫触 if ("share".equalsIgnoreCase(source)) { - response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_bonusState.html?code=1"); + // response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_bonusState.html?code=1"); + closeWebPage(response.getWriter()); } else if ("zigou".equalsIgnoreCase(source)) { - response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_rebateState.html?code=1"); + // response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_rebateState.html?code=1"); + closeWebPage(response.getWriter()); } else if ("bind".equalsIgnoreCase(source)) { 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>", @@ -214,4 +301,14 @@ } + private void closeWebPage(PrintWriter out) { + String script = "<script>if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {setTimeout(function(){window.location.href = 'yestv://finishPage';},100);} else {yestv.finishPage();}</script>"; + out.print(script); + } + + @RequestMapping(value = "pinduoduo") + public void pinDuoDuo(HttpServletResponse response) { + + } + } -- Gitblit v1.8.0