Authored by hugufei

活动返回信息添加头像

... ... @@ -35,8 +35,7 @@ public class DrawlineUserActivityInfoRest {
@ResponseBody
public ApiResponse getUserActivityInfo(DlUserActivityInfoReqBO userActivityInfoReqBO) {
logger.info("Enter getUserActivityInfo. param userActivityInfoReqBO is {}", userActivityInfoReqBO);
DlUserActivityInfoRespBO data = new DlUserActivityInfoRespBO();
data = drawlineUserActivityInfoService.getUserActivityInfo(userActivityInfoReqBO);
DlUserActivityInfoRespBO data = drawlineUserActivityInfoService.getUserActivityInfo(userActivityInfoReqBO);
return new ApiResponse.ApiResponseBuilder().code(USER_ACTIVITY_INFO_CODE).message(USER_ACTIVITY_INFO_MSG).data(data).build();
}
}
... ...
... ... @@ -2,12 +2,14 @@ package com.yoho.activity.queue.service.impl;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yoho.activity.queue.service.IDrawlineUserActivityInfoService;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.exception.ServiceException;
import com.yoho.queue.dal.IDrawlineActivityDAO;
import com.yoho.queue.dal.IDrawlineLuckyUserDAO;
... ... @@ -18,8 +20,10 @@ import com.yoho.queue.dal.model.DrawlineLuckyUser;
import com.yoho.queue.dal.model.DrawlinePrizeSetting;
import com.yoho.queue.dal.model.DrawlineUserQueue;
import com.yoho.service.model.activity.drawline.request.DlUserActivityInfoReqBO;
import com.yoho.service.model.activity.drawline.request.UserBaseReqBO;
import com.yoho.service.model.activity.drawline.response.DlUserActivityInfoPrompt;
import com.yoho.service.model.activity.drawline.response.DlUserActivityInfoRespBO;
import com.yoho.service.model.activity.drawline.response.UserBaseRspBO;
/**
* @author hugufei
... ... @@ -37,10 +41,14 @@ public class DrawlineUserActivityInfoServiceImpl implements IDrawlineUserActivit
private IDrawlineLuckyUserDAO drawlineLuckyUserDAO;
@Autowired
private IDrawlineActivityDAO drawlineActivityDAO;
@Autowired
private ServiceCaller service;
private static final DlUserActivityInfoPrompt PROMPT_ACTEND_LUCKY = new DlUserActivityInfoPrompt("OOPS!", "中啦!恭喜您限购码get,请到个人中心查看明细。");;
private static final DlUserActivityInfoPrompt PROMPT_ACTEND_NOT_LUCKY = new DlUserActivityInfoPrompt("OOPS!", "幸运女神擦肩而过,不要灰心下次就是您!");
private static final String USER_BASE_URL = "users.selectUserBaseInfo";
@Override
public DlUserActivityInfoRespBO getUserActivityInfo(DlUserActivityInfoReqBO userActivityInfoReqBO) {
logger.info("Enter getUserActivityInfo. param userActivityInfoReqBO is {}", userActivityInfoReqBO);
... ... @@ -60,11 +68,25 @@ public class DrawlineUserActivityInfoServiceImpl implements IDrawlineUserActivit
throw new ServiceException(900001003, "活动不存在");
}
// 4、查看是否排队(如果未排队,则不可能中奖,直接返回)
// 4、查询用户头像
try {
UserBaseReqBO req = new UserBaseReqBO();
req.setUid(uid);
UserBaseRspBO userBaseRspBO = service.call(USER_BASE_URL, req, UserBaseRspBO.class);
if (userBaseRspBO != null && !StringUtils.isBlank(userBaseRspBO.getHeadIco())) {
userActivityInfoRespBO.setHeadIco(userBaseRspBO.getHeadIco());
} else {
userActivityInfoRespBO.setHeadIco("");
}
} catch (Exception e) {
logger.warn("service call users.selectUserBaseInfo execption:", e.toString());
userActivityInfoRespBO.setHeadIco("");
}
// 5、查看是否排队(如果未排队,则不可能中奖,直接返回)
DrawlineUserQueue drawlineUserQueue = drawlineUserQueueDAO.selectByUidAndActivityIdAndUserType(uid, activityId, userType);
logger.debug(
"getUserActivityInfo: drawlineUserQueueDAO.selectByUidAndActivityIdAndUserType. uid is {}, activityId is {}, userType is {}, drawlineUserQueue is {}",
uid, activityId, userType, drawlineUserQueue);
logger.debug("getUserActivityInfo: drawlineUserQueueDAO.selectByUidAndActivityIdAndUserType. uid is {}, activityId is {}, userType is {}, drawlineUserQueue is {}", uid,
activityId, userType, drawlineUserQueue);
if (drawlineUserQueue == null) {
return userActivityInfoRespBO;
}
... ... @@ -72,13 +94,12 @@ public class DrawlineUserActivityInfoServiceImpl implements IDrawlineUserActivit
userActivityInfoRespBO.setIsDrawline(1);
userActivityInfoRespBO.setSort(drawlineUserQueue.getSort());
// 4、查看是否中奖
// 6、查看是否中奖
DrawlineLuckyUser drawlineLuckyUser = drawlineLuckyUserDAO.selectByActivityIdAndUidAndUserType(activityId, uid, userType);
logger.debug(
"getUserActivityInfo: drawlineLuckyUserDAO.selectByActivityIdAndUidAndUserType. uid is {}, activityId is {}, userType is {}, drawlineLuckyUser is {}",
uid, activityId, userType, drawlineLuckyUser);
logger.debug("getUserActivityInfo: drawlineLuckyUserDAO.selectByActivityIdAndUidAndUserType. uid is {}, activityId is {}, userType is {}, drawlineLuckyUser is {}", uid,
activityId, userType, drawlineLuckyUser);
if (drawlineLuckyUser != null) {
// 4.1、中奖了,则查询奖品信息(目前活动和奖品是一对一)
// 6.1、中奖了,则查询奖品信息(目前活动和奖品是一对一)
DrawlinePrizeSetting drawlinePrizeSetting = drawlinePrizeSettingDAO.selectByActivityId(drawlineLuckyUser.getActivityId());
logger.debug("getUserActivityInfo: drawlinePrizeSettingDAO.selectByActivityId.activityId is {}", activityId);
if (drawlinePrizeSetting == null) {
... ... @@ -89,7 +110,7 @@ public class DrawlineUserActivityInfoServiceImpl implements IDrawlineUserActivit
userActivityInfoRespBO.setPrizeType(Integer.valueOf(drawlinePrizeSetting.getPrizeType()));
}
// 5、判断活动是否结束
// 7、判断活动是否结束
boolean isActivityEnd = false;
Integer activityEndTime = drawlineActivity.getEndTime();
if (activityEndTime != null) {
... ... @@ -99,13 +120,12 @@ public class DrawlineUserActivityInfoServiceImpl implements IDrawlineUserActivit
}
}
// 6、构造prompt(活动结束了才有提示信息)
// 8、构造prompt(活动结束了才有提示信息)
DlUserActivityInfoPrompt prompt = null;
if (isActivityEnd) {
prompt = userActivityInfoRespBO.getIsLucky() > 0 ? PROMPT_ACTEND_LUCKY : PROMPT_ACTEND_NOT_LUCKY;
userActivityInfoRespBO.setPrompt(prompt);
}
return userActivityInfoRespBO;
}
... ...