元气优淘服务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
youtao/cweb/src/main/java/com/hfkj/controller/ElmController.java

65 lines
2.3 KiB

package com.hfkj.controller;
import com.hfkj.common.security.UserCenter;
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.user.BsUserService;
import com.taobao.api.response.AlibabaAlscUnionMediaZoneAddResponse;
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.ResponseBody;
import javax.annotation.Resource;
@Controller
@RequestMapping(value="/elm")
@Api(value="饿了么")
public class ElmController {
private static Logger log = LoggerFactory.getLogger(ElmController.class);
@Autowired
private UserCenter userCenter;
@Resource
private BsUserService bsUserService;
@RequestMapping(value="/officialactivity",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "本地联盟饿了么推广官方活动查询")
public ResponseData officialactivity() {
try {
// 用户session
UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class);
BsUser user = bsUserService.getUser(session.getUser().getId());
String pid = "alsc_28560886_9016007_22442020";
if(user != null){
if (user.getElmPid() == null) {
AlibabaAlscUnionMediaZoneAddResponse mediaZone = ElmService.mediaZone(user.getPhone());
pid = mediaZone.getResult().getPid();
user.setElmPid(pid);
bsUserService.editData(user);
} else {
pid = user.getElmPid();
}
}
return ResponseMsgUtil.success(ElmService.officialactivity(session.getUser().getId() , "10144" , pid));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}