| | |
| | | import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService; |
| | | import com.yeshi.fanli.service.inter.user.tb.TaoBaoUnionAuthRecordService; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.service.manger.user.TBAuthManager; |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import net.sf.json.JSONObject; |
| | |
| | | |
| | | /** |
| | | * 授权回调 |
| | | * |
| | | * @author Administrator |
| | | * |
| | | * @author Administrator |
| | | */ |
| | | @Controller |
| | | @RequestMapping("client/v1/auth/callback") |
| | | public class AuthCallBackController { |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | @Resource |
| | | private TaoBaoUnionAuthRecordService taoBaoUnionAuthRecordService; |
| | | |
| | | @Resource |
| | | private TaoBaoUnionAuthRecordService taoBaoUnionAuthRecordService; |
| | | @Resource |
| | | private UserAccountMsgNotificationService userAccountMsgNotificationService; |
| | | |
| | | @Resource |
| | | private UserAccountMsgNotificationService userAccountMsgNotificationService; |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private UserInfoModifyRecordService userInfoModifyRecordService; |
| | | @Resource |
| | | private UserActiveLogService userActiveLogService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | @Resource |
| | | private TBAuthManager tbAuthManager; |
| | | |
| | | @Resource |
| | | private UserActiveLogService userActiveLogService; |
| | | |
| | | @RequestMapping(value = "tb") |
| | | public void tb(String code, String state, HttpServletRequest request, HttpServletResponse response) { |
| | | LogManager.getLogger(LogType.taobaoAuth).info("淘宝授权回调:" + code + ":" + state); |
| | | if (StringUtil.isNullOrEmpty(code) || StringUtil.isNullOrEmpty(state)) { |
| | | LogHelper.error("淘宝授权回调出错"); |
| | | try { |
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html?code=1"); |
| | | } catch (IOException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | return; |
| | | } |
| | | private int processAuth(TBAuthManager.TaoBaoAuthOriginInfo taoBaoAuthOriginInfo, String code) { |
| | | int errCode = 0; |
| | | //判断用户ID |
| | | if (taoBaoAuthOriginInfo.getUid() == null || taoBaoAuthOriginInfo.getUid().longValue() == 0L) |
| | | return 3; |
| | | //解析淘宝用户信息 |
| | | TBAuthManager.TaoBaoUserInfo taoBaoUserInfo = null; |
| | | try { |
| | | taoBaoUserInfo = TBAuthManager.parseTaoBaoUser(code); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | LogHelper.userInfo("淘宝授权出错:" + e.getMessage()); |
| | | } |
| | | if (taoBaoUserInfo == null) { |
| | | return 4; |
| | | } |
| | | |
| | | try { |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoCode, code); |
| | | if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) |
| | | return; |
| | | redisManager.cacheCommonString(key, 1 + "", 5); |
| | | } catch (Exception e) { |
| | | //添加淘宝授权记录 |
| | | TaoBaoUnionAuthRecord record = new TaoBaoUnionAuthRecord(); |
| | | record.setUser(new UserInfo(taoBaoAuthOriginInfo.getUid())); |
| | | record.setTaoBaoOpenUid(taoBaoUserInfo.getOpenUid()); |
| | | record.setTaoBaoUserId(taoBaoUserInfo.getTaoBaoUid()); |
| | | record.setTaoBaoUserNick(taoBaoUserInfo.getNickName()); |
| | | record.setCreateTime(new Date()); |
| | | taoBaoUnionAuthRecordService.addAuthRecord(record); |
| | | |
| | | } |
| | | |
| | | String stateStr = null; |
| | | Long time = null; |
| | | Long uid = null; |
| | | String source = null; |
| | | try { |
| | | stateStr = AESUtil.decrypt(state, Constant.UIDAESKEY); |
| | | JSONObject json = JSONObject.fromObject(stateStr); |
| | | time = json.optLong("t"); |
| | | uid = json.optLong("u"); |
| | | source = json.optString("s"); |
| | | } catch (Exception e) { |
| | | try { |
| | | state = URLDecoder.decode(state, "UTF-8"); |
| | | } catch (UnsupportedEncodingException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | stateStr = AESUtil.decrypt(state, Constant.UIDAESKEY); |
| | | JSONObject json = JSONObject.fromObject(stateStr); |
| | | time = json.optLong("t"); |
| | | uid = json.optLong("u"); |
| | | source = json.optString("s"); |
| | | } |
| | | switch (taoBaoAuthOriginInfo.getSource()) { |
| | | case "zigou": |
| | | try { |
| | | tbAuthManager.authSpecialId(taoBaoAuthOriginInfo.getUid(), taoBaoUserInfo); |
| | | return 0; |
| | | } catch (TaoBaoAuthException e) { |
| | | LogHelper.userInfo("淘宝授权出错:" + e.getMessage()); |
| | | if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME) |
| | | userAccountMsgNotificationService.taoBaoAuthFail(taoBaoAuthOriginInfo.getUid(), taoBaoUserInfo.getNickName(), "淘宝账号未实名"); |
| | | } catch (UserExtraTaoBaoInfoException e) { |
| | | LogHelper.userInfo("淘宝授权出错:" + e.getMessage()); |
| | | e.printStackTrace(); |
| | | return 5; |
| | | } |
| | | break; |
| | | case "share": |
| | | try { |
| | | tbAuthManager.authRelationId(taoBaoAuthOriginInfo.getUid(), taoBaoUserInfo); |
| | | return 0; |
| | | } catch (TaoBaoAuthException e) { |
| | | LogHelper.userInfo("淘宝授权出错:" + e.getMessage()); |
| | | if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME) |
| | | userAccountMsgNotificationService.taoBaoAuthFail(taoBaoAuthOriginInfo.getUid(), taoBaoUserInfo.getNickName(), "淘宝账号未实名"); |
| | | } catch (UserExtraTaoBaoInfoException e) { |
| | | LogHelper.userInfo("淘宝授权出错:" + e.getMessage()); |
| | | e.printStackTrace(); |
| | | return 5; |
| | | } |
| | | |
| | | LogManager.getLogger(LogType.taobaoAuth).info("淘宝授权回调state:" + state); |
| | | break; |
| | | case "bind": |
| | | try { |
| | | tbAuthManager.authSpecialId(taoBaoAuthOriginInfo.getUid(), taoBaoUserInfo); |
| | | tbAuthManager.authRelationId(taoBaoAuthOriginInfo.getUid(), taoBaoUserInfo); |
| | | return 0; |
| | | } catch (TaoBaoAuthException e) { |
| | | LogHelper.userInfo("淘宝授权出错:" + e.getMessage()); |
| | | // if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME) |
| | | userAccountMsgNotificationService.taoBaoAuthFail(taoBaoAuthOriginInfo.getUid(), taoBaoUserInfo.getNickName(), e.getMessage()); |
| | | } catch (UserExtraTaoBaoInfoException e) { |
| | | LogHelper.userInfo("淘宝授权出错:" + e.getMessage()); |
| | | return 5; |
| | | } |
| | | break; |
| | | } |
| | | return errCode; |
| | | } |
| | | |
| | | LogManager.getLogger(LogType.taobaoAuth).info("淘宝授权回调解密:" + stateStr); |
| | | |
| | | int errCode = 0; |
| | | if (StringUtil.isNullOrEmpty(stateStr)) { |
| | | // 解密错误 |
| | | errCode = 1; |
| | | } |
| | | @RequestMapping(value = "tb") |
| | | public void tb(String code, String state, HttpServletRequest request, HttpServletResponse response) { |
| | | LogManager.getLogger(LogType.taobaoAuth).info("淘宝授权回调:" + code + ":" + state); |
| | | if (StringUtil.isNullOrEmpty(code) || StringUtil.isNullOrEmpty(state)) { |
| | | LogHelper.error("淘宝授权回调出错"); |
| | | try { |
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html?code=1"); |
| | | } catch (IOException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | if (System.currentTimeMillis() - time > 1000 * 60 * 10L) { |
| | | // 过时 |
| | | errCode = 2; |
| | | } |
| | | if (uid == null || uid.longValue() == 0L) |
| | | errCode = 3; |
| | | try { |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoCode, code); |
| | | if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) |
| | | return; |
| | | redisManager.cacheCommonString(key, 1 + "", 5); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | // 计入记录 |
| | | int errCode = 0; |
| | | //解密原始授权信息 |
| | | TBAuthManager.TaoBaoAuthOriginInfo taoBaoAuthOriginInfo = null; |
| | | try { |
| | | taoBaoAuthOriginInfo = TBAuthManager.decryptAuthOriginInfo(state); |
| | | } catch (Exception e) { |
| | | } |
| | | if (taoBaoAuthOriginInfo == null) { |
| | | errCode = 1; |
| | | } else { |
| | | if (System.currentTimeMillis() - taoBaoAuthOriginInfo.getTime() > 1000 * 60 * 10L) { |
| | | // 过时 |
| | | errCode = 2; |
| | | } |
| | | } |
| | | |
| | | try { |
| | | // |
| | | String result = TaoKeApiUtil.getAccessToken(code, TaoBaoConstant.TAOBAO_AUTH_APPKEY, |
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | JSONObject data = JSONObject.fromObject(result); |
| | | data = data.optJSONObject("top_auth_token_create_response").optJSONObject("token_result"); |
| | | String accessToken = data.optString("access_token"); |
| | | String openUid = data.optString("taobao_open_uid"); |
| | | String taoBaoUid = data.optString("taobao_user_id"); |
| | | String nickName = data.optString("taobao_user_nick"); |
| | | try { |
| | | nickName = URLDecoder.decode(nickName, "UTF-8"); |
| | | } catch (Exception e) { |
| | | } |
| | | final String name = nickName; |
| | | LogManager.getLogger(LogType.taobaoAuth).info("uid:" + uid + "\n accessToken:" + accessToken); |
| | | if (errCode == 0) { |
| | | errCode = processAuth(taoBaoAuthOriginInfo, code); |
| | | } else { |
| | | //基础信息解析失败 |
| | | try { |
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html?code=1"); |
| | | } catch (IOException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | return; |
| | | } |
| | | // 计入记录 |
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(taoBaoAuthOriginInfo.getUid()); |
| | | |
| | | //执行绑定 |
| | | source="bind"; |
| | | // 获取渠道ID与会员ID |
| | | if ("share".equalsIgnoreCase(source)) { |
| | | String relationId = null; |
| | | boolean isNewJump = false; |
| | | if (activeLog != null) { |
| | | String platform = null; |
| | | String version = activeLog.getVersionCode(); |
| | | if (activeLog.getChannel().equalsIgnoreCase("appstore")) { |
| | | platform = "ios"; |
| | | } else { |
| | | platform = "android"; |
| | | } |
| | | if (VersionUtil.greaterThan_2_0(platform, version)) { |
| | | isNewJump = true; |
| | | } |
| | | } |
| | | |
| | | try { |
| | | 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, "淘宝账号未实名"); |
| | | } |
| | | try { |
| | | if (errCode == 0)// 成功 |
| | | { |
| | | if ("share".equalsIgnoreCase(taoBaoAuthOriginInfo.getSource())) { |
| | | if (isNewJump) |
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/success.html"); |
| | | else |
| | | closeWebPage(response.getWriter()); |
| | | } else if ("zigou".equalsIgnoreCase(taoBaoAuthOriginInfo.getSource())) { |
| | | if (isNewJump) |
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/success.html"); |
| | | else |
| | | closeWebPage(response.getWriter()); |
| | | } else if ("bind".equalsIgnoreCase(taoBaoAuthOriginInfo.getSource())) { |
| | | if (isNewJump) |
| | | 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>", |
| | | StringUtil.getBase64String("恭喜你,淘宝绑定成功")); |
| | | response.getWriter().print(script); |
| | | } |
| | | } |
| | | } else {// 失败 |
| | | if ("share".equalsIgnoreCase(taoBaoAuthOriginInfo.getSource())) { |
| | | if (isNewJump) |
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html"); |
| | | else |
| | | closeWebPage(response.getWriter()); |
| | | } else if ("zigou".equalsIgnoreCase(taoBaoAuthOriginInfo.getSource())) { |
| | | if (isNewJump) |
| | | response.sendRedirect("http://apph5.banliapp.com/flqWeb/h5/tbauth/fail.html"); |
| | | else |
| | | closeWebPage(response.getWriter()); |
| | | } else if ("bind".equalsIgnoreCase(taoBaoAuthOriginInfo.getSource())) { |
| | | if (isNewJump) |
| | | 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>", |
| | | StringUtil.getBase64String("抱歉,淘宝绑定失败")); |
| | | response.getWriter().print(script); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | |
| | | try { |
| | | userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid, nickName, true); |
| | | } catch (UserExtraTaoBaoInfoException e) { |
| | | LogHelper.test(e.getMsg()); |
| | | errCode = 5; |
| | | } |
| | | 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); |
| | | } |
| | | |
| | | final String relationId2 = relationId; |
| | | // 异步申请会员ID |
| | | final Long fuid = uid; |
| | | // 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) { |
| | | // LogManager.getLogger(LogType.taobaoAuth).error(fuid + "会员备案失败:" + e1.getMessage()); |
| | | // } |
| | | // |
| | | // try { |
| | | // userExtraTaoBaoInfoService.addSpecialId(fuid, specialId, taoBaoUid, name, true); |
| | | // |
| | | // if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId2)) |
| | | // userInfoModifyRecordService.addModifyRecord(fuid, ModifyTypeEnum.bindTaoBao, taoBaoUid); |
| | | // } catch (UserExtraTaoBaoInfoException e) { |
| | | // LogHelper.test(e.getMsg()); |
| | | // } |
| | | // } |
| | | // }); |
| | | @RequestMapping(value = "pinduoduo") |
| | | public void pinDuoDuo(HttpServletResponse response) { |
| | | |
| | | // 稍作延迟 |
| | | Thread.sleep(50); |
| | | } else if ("zigou".equalsIgnoreCase(source)) { |
| | | 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, "淘宝账号未实名"); |
| | | LogManager.getLogger(LogType.taobaoAuth).error(uid + "会员备案失败:" + e.getMessage()); |
| | | |
| | | LogHelper.test("淘宝授权:"+uid + "会员备案失败:" + e.getMessage()); |
| | | } |
| | | |
| | | LogHelper.test("淘宝授权:"+specialId); |
| | | |
| | | try { |
| | | userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, nickName, true); |
| | | } catch (UserExtraTaoBaoInfoException e) { |
| | | LogHelper.test(e.getMsg()); |
| | | errCode = 5; |
| | | } |
| | | final Long fuid = uid; |
| | | |
| | | final String specialId2 = specialId; |
| | | // 异步申请渠道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) { |
| | | // LogManager.getLogger(LogType.taobaoAuth).error(fuid + "渠道备案失败:" + e1.getMessage()); |
| | | // } |
| | | // try { |
| | | // userExtraTaoBaoInfoService.addRelationId(fuid, relationId, taoBaoUid, name, true); |
| | | // |
| | | // if (!StringUtil.isNullOrEmpty(specialId2) && !StringUtil.isNullOrEmpty(relationId)) |
| | | // userInfoModifyRecordService.addModifyRecord(fuid, ModifyTypeEnum.bindTaoBao, taoBaoUid); |
| | | // } catch (UserExtraTaoBaoInfoException e) { |
| | | // LogHelper.test(e.getMsg()); |
| | | // } |
| | | // } |
| | | // }); |
| | | // 稍作延迟 |
| | | Thread.sleep(50); |
| | | |
| | | } else if ("bind".equalsIgnoreCase(source)) { |
| | | |
| | | boolean bindInfo = true; |
| | | // 绑定淘宝:V1.5.3 |
| | | String relationId = null; |
| | | |
| | | int tbErrorCode = 0; |
| | | try { |
| | | 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)) { |
| | | bindInfo = false; |
| | | } |
| | | |
| | | String specialId = null; |
| | | if (bindInfo) { |
| | | try { |
| | | specialId = TaoKeApiUtil.getSpecialId(accessToken, Constant.TAOBAO_AUTH_APPKEY, |
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | } catch (TaoBaoAuthException e) { |
| | | tbErrorCode = e.getCode(); |
| | | LogManager.getLogger(LogType.taobaoAuth).error(uid + "会员备案失败"); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(specialId)) { |
| | | bindInfo = false; |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(nickName)) |
| | | try { |
| | | nickName = URLDecoder.decode(nickName, "UTF-8"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | TaoBaoUnionAuthRecord record = new TaoBaoUnionAuthRecord(); |
| | | record.setUser(new UserInfo(uid)); |
| | | record.setTaoBaoOpenUid(openUid); |
| | | record.setTaoBaoUserId(taoBaoUid); |
| | | record.setTaoBaoUserNick(nickName); |
| | | record.setCreateTime(new Date()); |
| | | taoBaoUnionAuthRecordService.addAuthRecord(record); |
| | | |
| | | } catch (Exception e) { |
| | | errCode = 4; |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | |
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(uid); |
| | | |
| | | boolean isNewJump = false; |
| | | if (activeLog != null) { |
| | | String platform = null; |
| | | String version = activeLog.getVersionCode(); |
| | | if (activeLog.getChannel().equalsIgnoreCase("appstore")) { |
| | | platform = "ios"; |
| | | } else { |
| | | platform = "android"; |
| | | } |
| | | if (VersionUtil.greaterThan_2_0(platform, version)) { |
| | | isNewJump = true; |
| | | } |
| | | } |
| | | |
| | | try { |
| | | if (errCode == 0)// 成功 |
| | | { |
| | | if ("share".equalsIgnoreCase(source)) { |
| | | if (isNewJump) |
| | | 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.banliapp.com/flqWeb/h5/tbauth/success.html"); |
| | | else |
| | | closeWebPage(response.getWriter()); |
| | | } else if ("bind".equalsIgnoreCase(source)) { |
| | | if (isNewJump) |
| | | 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>", |
| | | StringUtil.getBase64String("恭喜你,淘宝绑定成功")); |
| | | response.getWriter().print(script); |
| | | } |
| | | } |
| | | } else {// 失败 |
| | | if ("share".equalsIgnoreCase(source)) { |
| | | if (isNewJump) |
| | | 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.banliapp.com/flqWeb/h5/tbauth/fail.html"); |
| | | else |
| | | closeWebPage(response.getWriter()); |
| | | } else if ("bind".equalsIgnoreCase(source)) { |
| | | if (isNewJump) |
| | | 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>", |
| | | StringUtil.getBase64String("抱歉,淘宝绑定失败")); |
| | | response.getWriter().print(script); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | |
| | | 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) { |
| | | |
| | | } |
| | | } |
| | | |
| | | } |