From fdfd8e3a55428bf877c0ca93914c8509309da54a Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 05 九月 2019 17:40:47 +0800
Subject: [PATCH] 抖音广告监测
---
fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java | 101 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 81 insertions(+), 20 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 25945d3..de82022 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java
@@ -14,11 +14,15 @@
import org.springframework.web.bind.annotation.RequestMapping;
import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum;
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.service.inter.user.UserInfoModifyRecordService;
import com.yeshi.fanli.util.AESUtil;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.RedisManager;
@@ -44,6 +48,12 @@
@Resource
private TaoBaoUnionAuthRecordService taoBaoUnionAuthRecordService;
+
+ @Resource
+ private UserAccountMsgNotificationService userAccountMsgNotificationService;
+
+ @Resource
+ private UserInfoModifyRecordService userInfoModifyRecordService;
@Resource
private RedisManager redisManager;
@@ -102,12 +112,20 @@
} catch (Exception e) {
}
final String name = nickName;
- // LogHelper.test("uid:" + uid + "\n accessToken:" + accessToken);
+ 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 {
@@ -116,27 +134,46 @@
LogHelper.test(e.getMsg());
errCode = 5;
}
+
+ final String relationId2 = relationId;
// 寮傛鐢宠浼氬憳ID
ThreadUtil.run(new Runnable() {
@Override
public void run() {
- 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 e1) {
+
+ }
if (StringUtil.isNullOrEmpty(specialId))
LogHelper.test(uid + "浼氬憳澶囨澶辫触");
try {
userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, name, true);
+
+ if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId2))
+ userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
} 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 + "浼氬憳澶囨澶辫触");
@@ -147,29 +184,47 @@
errCode = 5;
}
+ final String specialId2 = specialId;
// 寮傛鐢宠娓犻亾ID
ThreadUtil.run(new Runnable() {
@Override
public void run() {
- 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);
+ } catch (TaoBaoAuthException e1) {
+ } // 娓犻亾ID
if (StringUtil.isNullOrEmpty(relationId))
LogHelper.test(uid + "娓犻亾澶囨澶辫触");
try {
userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid, name, true);
+
+ if (!StringUtil.isNullOrEmpty(specialId2) && !StringUtil.isNullOrEmpty(relationId))
+ userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
} 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;
@@ -177,8 +232,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;
@@ -186,11 +245,17 @@
}
if (!bindInfo) {
+ if (tbErrorCode == TaoBaoAuthException.CODE_NOT_REAL_NAME) {
+ userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "娣樺疂璐﹀彿鏈疄鍚�");
+ }
errCode = 5;// 淇℃伅鑾峰彇涓嶅叏
} else {
try {
userExtraTaoBaoInfoService.saveUserTaoBaoInfo(uid, relationId, specialId, taoBaoUid, nickName,
true);
+
+ if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId))
+ userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
} catch (UserExtraTaoBaoInfoException e) {
LogHelper.test(e.getMsg());
errCode = 6;
@@ -215,11 +280,7 @@
} catch (Exception e) {
errCode = 4;
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
+ LogHelper.errorDetailInfo(e);
}
try {
@@ -258,7 +319,7 @@
}
private void closeWebPage(PrintWriter out) {
- String script = "<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.finishPage();}</script>";
+ 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);
}
--
Gitblit v1.8.0