| | |
| | | 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;
|
| | |
| | |
|
| | | @RequestMapping(value = "tb")
|
| | | public void tb(String code, String state, HttpServletRequest request, HttpServletResponse response) {
|
| | |
|
| | | LogHelper.test("淘宝授权回调:" + code + ":" + state);
|
| | | if (StringUtil.isNullOrEmpty(code) || StringUtil.isNullOrEmpty(state)) {
|
| | | LogHelper.error("淘宝授权回调出错");
|
| | |
| | | }
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | String key = StringUtil.Md5("taobao-code-" + code);
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaoCode, code);
|
| | | if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key)))
|
| | | return;
|
| | | redisManager.cacheCommonString(key, 1 + "", 5);
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | LogHelper.userErrorInfo("淘宝授权回调state:"+state);
|
| | | String stateStr = AESUtil.decrypt(state, Constant.UIDAESKEY);
|
| | | LogHelper.userErrorInfo("淘宝授权回调解密:"+stateStr);
|
| | | |
| | |
|
| | | 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");
|
| | | }
|
| | |
|
| | | LogHelper.userErrorInfo("淘宝授权回调state:" + state);
|
| | |
|
| | | LogHelper.userErrorInfo("淘宝授权回调解密:" + stateStr);
|
| | |
|
| | | int errCode = 0;
|
| | | if (StringUtil.isNullOrEmpty(stateStr)) {
|
| | | // 解密错误
|
| | | errCode = 1;
|
| | | }
|
| | | JSONObject json = JSONObject.fromObject(stateStr);
|
| | | Long time = json.optLong("t");
|
| | | Long uid = json.optLong("u");
|
| | | String source = json.optString("s");
|
| | |
|
| | | if (System.currentTimeMillis() - time > 1000 * 60 * 10L) {
|
| | | // 过时
|
| | | errCode = 2;
|
| | |
| | |
|
| | | final String relationId2 = relationId;
|
| | | // 异步申请会员ID
|
| | | final Long fuid=uid;
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(specialId))
|
| | | LogHelper.test(uid + "会员备案失败");
|
| | | LogHelper.test(fuid + "会员备案失败");
|
| | | try {
|
| | | userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, name, true);
|
| | | userExtraTaoBaoInfoService.addSpecialId(fuid, specialId, taoBaoUid, name, true);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId2))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
|
| | | userInfoModifyRecordService.addModifyRecord(fuid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
|
| | | } catch (UserExtraTaoBaoInfoException e) {
|
| | | LogHelper.test(e.getMsg());
|
| | | }
|
| | |
| | | LogHelper.test(e.getMsg());
|
| | | errCode = 5;
|
| | | }
|
| | | final Long fuid=uid;
|
| | |
|
| | | final String specialId2 = specialId;
|
| | | // 异步申请渠道ID
|
| | |
| | | } catch (TaoBaoAuthException e1) {
|
| | | } // 渠道ID
|
| | | if (StringUtil.isNullOrEmpty(relationId))
|
| | | LogHelper.test(uid + "渠道备案失败");
|
| | | LogHelper.test(fuid + "渠道备案失败");
|
| | | try {
|
| | | userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid, name, true);
|
| | | userExtraTaoBaoInfoService.addRelationId(fuid, relationId, taoBaoUid, name, true);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(specialId2) && !StringUtil.isNullOrEmpty(relationId))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
|
| | | userInfoModifyRecordService.addModifyRecord(fuid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
|
| | | } catch (UserExtraTaoBaoInfoException e) {
|
| | | LogHelper.test(e.getMsg());
|
| | | }
|