From 1da17d215d48e3e3aa9e8d7a3ef526904764f408 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期一, 08 四月 2019 14:06:12 +0800 Subject: [PATCH] 1.5.3部分需求 提交 --- fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java | 99 +++++++++++++++++++++++++++++++++++++------------ 1 files changed, 75 insertions(+), 24 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 cb412c7..3939b78 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java @@ -6,6 +6,7 @@ import java.util.Date; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; @@ -13,6 +14,8 @@ import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.taobao.TaoBaoUnionAuthRecord; +import com.yeshi.fanli.exception.user.UserExtraTaoBaoInfoException; +import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionAuthRecordService; import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService; import com.yeshi.fanli.util.AESUtil; @@ -39,9 +42,10 @@ private TaoBaoUnionAuthRecordService taoBaoUnionAuthRecordService; @RequestMapping(value = "tb") - public void tb(String code, String state, HttpServletResponse response) { - if (StringUtil.isNullOrEmpty(code) || StringUtil.isNullOrEmpty(state)) - { + public void tb(String code, String state, HttpServletRequest request, HttpServletResponse response) { + LogHelper.test("娣樺疂鎺堟潈鍥炶皟:" + code + "锛�" + state); + if (StringUtil.isNullOrEmpty(code) || StringUtil.isNullOrEmpty(state)) { + LogHelper.error("娣樺疂鎺堟潈鍥炶皟鍑洪敊"); try { response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_bonusState.html?code=1"); } catch (IOException e1) { @@ -66,20 +70,6 @@ if (uid == null || uid.longValue() == 0L) errCode = 3; - if (uid == 911382L) { - try { - if ("share".equalsIgnoreCase(source)) - - response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_bonusState.html?code=1"); - - else - response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_rebateState.html?code=1"); - } catch (IOException e) { - - } - return; - } - // 璁″叆璁板綍 try { @@ -91,16 +81,65 @@ String openUid = data.optString("taobao_open_uid"); String taoBaoUid = data.optString("taobao_user_id"); String nickName = data.optString("taobao_user_nick"); + + // LogHelper.test("uid:" + uid + "\n accessToken:" + accessToken); + // 鑾峰彇娓犻亾ID涓庝細鍛業D if ("share".equalsIgnoreCase(source)) { String relationId = TaoKeApiUtil.getRelationId(accessToken, Constant.TAOBAO_AUTH_APPKEY, Constant.TAOBAO_AUTH_APPSECRET);// 娓犻亾ID - userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid, true); - } else { + if (StringUtil.isNullOrEmpty(relationId)) + LogHelper.test(uid + "娓犻亾澶囨澶辫触"); + try { + userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid,nickName, true); + } catch (UserExtraTaoBaoInfoException e) { + LogHelper.test(e.getMsg()); + errCode = 5; + } + } else if ("zigou".equalsIgnoreCase(source)) { String specialId = TaoKeApiUtil.getSpecialId(accessToken, Constant.TAOBAO_AUTH_APPKEY, Constant.TAOBAO_AUTH_APPSECRET); - userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, true); + if (StringUtil.isNullOrEmpty(specialId)) + LogHelper.test(uid + "浼氬憳澶囨澶辫触"); + try { + userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, nickName, true); + } catch (UserExtraTaoBaoInfoException e) { + LogHelper.test(e.getMsg()); + errCode = 5; + } + } else if ("bind".equalsIgnoreCase(source)) { + + boolean bindInfo = true; + // 缁戝畾娣樺疂锛歏1.5.3 + String relationId = TaoKeApiUtil.getRelationId(accessToken, Constant.TAOBAO_AUTH_APPKEY, Constant.TAOBAO_AUTH_APPSECRET);// 娓犻亾ID + if (StringUtil.isNullOrEmpty(relationId)) { + LogHelper.test(uid + "娓犻亾澶囨澶辫触"); + bindInfo = false; + } + + String specialId = null; + if(bindInfo) { + specialId = TaoKeApiUtil.getSpecialId(accessToken, Constant.TAOBAO_AUTH_APPKEY, + Constant.TAOBAO_AUTH_APPSECRET); + if (StringUtil.isNullOrEmpty(specialId)) { + LogHelper.test(uid + "浼氬憳澶囨澶辫触"); + bindInfo = false; + } + } + + if (!bindInfo) { + errCode = 5;// 淇℃伅鑾峰彇涓嶅叏 + } else { + try { + userExtraTaoBaoInfoService.saveUserTaoBaoInfo(uid, relationId, specialId, taoBaoUid, nickName, true); + } catch (UserExtraTaoBaoInfoException e) { + LogHelper.test(e.getMsg()); + errCode = 6; + } + } + } + if (!StringUtil.isNullOrEmpty(nickName)) try { @@ -115,22 +154,34 @@ record.setTaoBaoUserNick(nickName); record.setCreateTime(new Date()); taoBaoUnionAuthRecordService.addAuthRecord(record); + } catch (Exception e) { errCode = 4; + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } } try { if (errCode == 0)// 鎴愬姛 { - if ("share".equalsIgnoreCase(source)) + if ("share".equalsIgnoreCase(source)) { response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_bonusState.html?code=0"); - else + } else if ("zigou".equalsIgnoreCase(source)) { response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_rebateState.html?code=0"); + } else if ("bind".equalsIgnoreCase(source)) { + response.getWriter().print("<script>yestv.toast(\"鎭枩浣狅紝娣樺疂缁戝畾鎴愬姛\");yestv.finishPage();</script>"); + } } else {// 澶辫触 - if ("share".equalsIgnoreCase(source)) + if ("share".equalsIgnoreCase(source)) { response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_bonusState.html?code=1"); - else + } else if ("zigou".equalsIgnoreCase(source)) { response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_rebateState.html?code=1"); + } else if ("bind".equalsIgnoreCase(source)) { + response.getWriter().print("<script>yestv.toast(\"鎶辨瓑锛屾窐瀹濈粦瀹氬け璐");yestv.finishPage();</script>"); + } } } catch (Exception e) { -- Gitblit v1.8.0