| | |
| | | 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;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum;
|
| | |
| | | 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.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | 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.VersionUtil;
|
| | | import com.yeshi.fanli.util.*;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.net.URLDecoder;
|
| | | import java.util.Date;
|
| | |
|
| | | /**
|
| | | * 授权回调
|
| | |
| | | // 计入记录
|
| | |
|
| | | try {
|
| | | //
|
| | | String result = TaoKeApiUtil.getAccessToken(code, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | JSONObject data = JSONObject.fromObject(result);
|
| | |
| | | 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());
|
| | | }
|
| | | }
|
| | | });
|
| | | // 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());
|
| | | // }
|
| | | // }
|
| | | // });
|
| | |
|
| | | // 稍作延迟
|
| | | Thread.sleep(50);
|
| | |
| | | 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);
|
| | |
| | |
|
| | | 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());
|
| | | }
|
| | | }
|
| | | });
|
| | | // 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);
|
| | |
|