From 0de49bbc0f8bef524a16a877a166ba656cf2e929 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期二, 11 六月 2019 09:15:30 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java | 90 +++++++++++++++++++++++++++++++++++++++-----
1 files changed, 79 insertions(+), 11 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 5ae3bc5..fa0a438 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;
@@ -20,8 +21,10 @@
import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.util.AESUtil;
import com.yeshi.fanli.util.Constant;
+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,8 +45,12 @@
@Resource
private TaoBaoUnionAuthRecordService taoBaoUnionAuthRecordService;
+ @Resource
+ private RedisManager redisManager;
+
@RequestMapping(value = "tb")
public void tb(String code, String state, HttpServletRequest request, HttpServletResponse response) {
+
LogHelper.test("娣樺疂鎺堟潈鍥炶皟:" + code + "锛�" + state);
if (StringUtil.isNullOrEmpty(code) || StringUtil.isNullOrEmpty(state)) {
LogHelper.error("娣樺疂鎺堟潈鍥炶皟鍑洪敊");
@@ -53,6 +60,14 @@
e1.printStackTrace();
}
return;
+ }
+ try {
+ String key = StringUtil.Md5("taobao-code-" + code);
+ if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key)))
+ return;
+ redisManager.cacheCommonString(key, 1 + "", 5);
+ } catch (Exception e) {
+
}
String stateStr = AESUtil.decrypt(state, Constant.UIDAESKEY);
int errCode = 0;
@@ -86,6 +101,7 @@
nickName = URLDecoder.decode(nickName, "UTF-8");
} catch (Exception e) {
}
+ final String name = nickName;
// LogHelper.test("uid:" + uid + "\n accessToken:" + accessToken);
// 鑾峰彇娓犻亾ID涓庝細鍛業D
@@ -100,6 +116,24 @@
LogHelper.test(e.getMsg());
errCode = 5;
}
+ // 寮傛鐢宠浼氬憳ID
+ ThreadUtil.run(new Runnable() {
+
+ @Override
+ public void run() {
+ String specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
+ TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
+
+ if (StringUtil.isNullOrEmpty(specialId))
+ LogHelper.test(uid + "浼氬憳澶囨澶辫触");
+ try {
+ userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, name, true);
+ } catch (UserExtraTaoBaoInfoException e) {
+ LogHelper.test(e.getMsg());
+ }
+ }
+ });
+
} else if ("zigou".equalsIgnoreCase(source)) {
String specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
@@ -112,6 +146,24 @@
LogHelper.test(e.getMsg());
errCode = 5;
}
+
+ // 寮傛鐢宠娓犻亾ID
+ ThreadUtil.run(new Runnable() {
+
+ @Override
+ public void run() {
+ String relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
+ TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 娓犻亾ID
+ if (StringUtil.isNullOrEmpty(relationId))
+ LogHelper.test(uid + "娓犻亾澶囨澶辫触");
+ try {
+ userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid, name, true);
+ } catch (UserExtraTaoBaoInfoException e) {
+ LogHelper.test(e.getMsg());
+ }
+ }
+ });
+
} else if ("bind".equalsIgnoreCase(source)) {
boolean bindInfo = true;
@@ -163,30 +215,36 @@
} 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)) {
- response.getWriter().print("<script>yestv.toast(\"鎭枩浣狅紝娣樺疂缁戝畾鎴愬姛\");yestv.finishPage();</script>");
+ 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>",
+ StringUtil.getBase64String("鎭枩浣狅紝娣樺疂缁戝畾鎴愬姛"));
+ response.getWriter().print(script);
}
} 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)) {
- response.getWriter().print("<script>yestv.toast(\"鎶辨瓑锛屾窐瀹濈粦瀹氬け璐");yestv.finishPage();</script>");
+ 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>",
+ StringUtil.getBase64String("鎶辨瓑锛屾窐瀹濈粦瀹氬け璐�"));
+ response.getWriter().print(script);
}
}
} catch (Exception e) {
@@ -195,4 +253,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