...
|
...
|
@@ -5,16 +5,20 @@ import com.yoho.activity.common.redis.RedisValueCache; |
|
|
import com.yoho.activity.common.utils.DateUtils;
|
|
|
import com.yoho.activity.dal.ProductLimitUserHelpMapper;
|
|
|
import com.yoho.activity.dal.model.LimitProductHelpUser;
|
|
|
import com.yoho.activity.queue.service.IDrawlineList2MapService;
|
|
|
import com.yoho.activity.queue.service.IProductLimitUserHelpService;
|
|
|
import com.yoho.core.rest.client.hystrix.AsyncFuture;
|
|
|
import com.yoho.service.model.activity.drawline.request.LimitProductHelpUserRequestBO;
|
|
|
import com.yoho.service.model.activity.drawline.response.LimitProductHelpUserListBO;
|
|
|
import com.yoho.service.model.activity.drawline.response.LimitProductHelpUserRespBO;
|
|
|
import com.yoho.service.model.activity.drawline.response.UserBaseRspBO;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
...
|
...
|
@@ -28,7 +32,8 @@ public class ProductLimitUserHelpServiceImpl implements IProductLimitUserHelpSer |
|
|
private RedisValueCache redisValueCache;
|
|
|
@Autowired
|
|
|
private ProductLimitUserHelpMapper productLimitUserHelpMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private IDrawlineList2MapService drawlineList2MapService;
|
|
|
@Override
|
|
|
public List<LimitProductHelpUserRespBO> queryHelpInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) {
|
|
|
//先走缓存,缓存没有再走库里捞
|
...
|
...
|
@@ -43,20 +48,46 @@ public class ProductLimitUserHelpServiceImpl implements IProductLimitUserHelpSer |
|
|
logger.info("ProductLimitUserHelpServiceImpl :: queryHelpInfo result is null");
|
|
|
return null;
|
|
|
}
|
|
|
//获取用户头像
|
|
|
getUserInfo(limitProductHelpUserRequestBO.getUserId(), limitProductHelpUserRespBOList);
|
|
|
limitProductHelpUserListBO.setList(limitProductHelpUserRespBOList);
|
|
|
redisValueCache.set(CacheKeyEnum.LIMIT_USER_HELP_INFO, redisKeySuffix, limitProductHelpUserListBO, 300, TimeUnit.SECONDS);
|
|
|
return limitProductHelpUserListBO.getList();
|
|
|
}
|
|
|
|
|
|
private void getUserInfo(Integer userId, List<LimitProductHelpUserRespBO> limitProductHelpUserRespBOList) {
|
|
|
List<Integer> uidList = new ArrayList<>();
|
|
|
uidList.add(userId);
|
|
|
AsyncFuture<UserBaseRspBO[]> userBaseRspBOArrAsync = drawlineList2MapService.postForUserBaseInfo(uidList);
|
|
|
UserBaseRspBO[] userBaseRspBOs = userBaseRspBOArrAsync.get();
|
|
|
for (LimitProductHelpUserRespBO limitProductHelpUserRespBO : limitProductHelpUserRespBOList){
|
|
|
for (UserBaseRspBO userBaseRspBO : userBaseRspBOs){
|
|
|
if (limitProductHelpUserRespBO.getUserId().equals(userBaseRspBO.getUid())){
|
|
|
limitProductHelpUserRespBO.setUserImgUrl(userBaseRspBO.getHeadIco());
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void addhelpUserInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) {
|
|
|
public void addHelpUserInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) {
|
|
|
LimitProductHelpUser limitProductHelpUser = converToModel(limitProductHelpUserRequestBO);
|
|
|
productLimitUserHelpMapper.addhelpUserInfo(limitProductHelpUser);
|
|
|
productLimitUserHelpMapper.addHelpUserInfo(limitProductHelpUser);
|
|
|
//清除缓存
|
|
|
String redisKeySuffix = limitProductHelpUserRequestBO.getUserId() + ":" + limitProductHelpUserRequestBO.getLimitProductCode();
|
|
|
redisValueCache.delete(CacheKeyEnum.LIMIT_USER_HELP_INFO, redisKeySuffix);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean judgeHelpUserExist(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) {
|
|
|
Integer count = productLimitUserHelpMapper.selectExistHelpInfo(limitProductHelpUserRequestBO.getHelpUserId(),limitProductHelpUserRequestBO.getLimitProductCode());
|
|
|
if (count > 0){
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
private LimitProductHelpUser converToModel(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) {
|
|
|
LimitProductHelpUser limitProductHelpUser = new LimitProductHelpUser();
|
|
|
limitProductHelpUser.setUserId(limitProductHelpUserRequestBO.getUserId());
|
...
|
...
|
|