package com.hfkj.controller; import com.alibaba.fastjson.JSONObject; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.HttpsUtils; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsUser; import com.hfkj.model.ResponseData; import com.hfkj.model.UserSessionObject; import com.hfkj.service.elm.ElmService; import com.hfkj.service.meituan.MeiTuanService; import com.hfkj.service.pdd.PddService; import com.hfkj.service.taobao.TaoBaoService; import com.hfkj.service.user.BsUserContributeService; import com.hfkj.service.user.BsUserGradeService; import com.hfkj.service.user.BsUserParentRelService; import com.hfkj.service.user.BsUserService; import com.hfkj.sysenum.user.UserGradeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; @Controller @RequestMapping(value="/test") @Api(value="测试") public class TestController { private static Logger log = LoggerFactory.getLogger(TestController.class); @Autowired private UserCenter userCenter; @Resource private BsUserService bsUserService; @RequestMapping(value="/getPublisherInfo",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "淘宝客-公用-私域用户备案") public ResponseData getPublisherInfo(@RequestParam(value = "code" , required = false) String code ) { try { // 用户session UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); JSONObject tokenJson = TaoBaoService.getToken(code); String token = tokenJson.getString("token_result"); JSONObject tokenResult = JSONObject.parseObject(token); BsUser user = bsUserService.getUser(userSession.getUser().getId()); // 用户备案 JSONObject jsonObject = TaoBaoService.getPublisherInfo(tokenResult.getString("access_token") , Long.valueOf(user.getRelationId()), user.getSpecialId()); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("error!",e); return ResponseMsgUtil.exception(e); } } }