| | |
| | |
|
| | | 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;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | // 计入记录
|
| | |
|
| | | try {
|
| | | String result = TaoKeApiUtil.getAccessToken(code, Constant.TAOBAO_AUTH_APPKEY,
|
| | | Constant.TAOBAO_AUTH_APPSECRET);
|
| | | 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");
|
| | |
|
| | | // LogHelper.test("uid:" + uid + "\n accessToken:" + accessToken);
|
| | |
|
| | | // 获取渠道ID与会员ID
|
| | | 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 {
|
| | | String specialId = TaoKeApiUtil.getSpecialId(accessToken, Constant.TAOBAO_AUTH_APPKEY,
|
| | | Constant.TAOBAO_AUTH_APPSECRET);
|
| | | userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, true);
|
| | | 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,nickName, true);
|
| | | } catch (UserExtraTaoBaoInfoException e) {
|
| | | LogHelper.test(e.getMsg());
|
| | | errCode = 5;
|
| | | }
|
| | | } else if ("zigou".equalsIgnoreCase(source)) {
|
| | | 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, nickName, true);
|
| | | } catch (UserExtraTaoBaoInfoException e) {
|
| | | LogHelper.test(e.getMsg());
|
| | | errCode = 5;
|
| | | }
|
| | | } else if ("bind".equalsIgnoreCase(source)) {
|
| | | |
| | | boolean bindInfo = true;
|
| | | // 绑定淘宝:V1.5.3
|
| | | String relationId = TaoKeApiUtil.getRelationId(accessToken, Constant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.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,
|
| | | TaoBaoConstant.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 {
|
| | |
| | | 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) {
|
| | |
|