Authored by chenly5

发现好物达人搭配兼容历史数据

... ... @@ -75,6 +75,9 @@ public class ArticleChannelServiceImpl implements IArticleChannelService {
@Resource
private ConfigReader configReader;
@Resource
private IGrassArticleDao grassArticleDao;
@Override
public ApiResponse updateGrassArticleChannel(GrassChannelReq req) {
... ... @@ -98,8 +101,8 @@ public class ArticleChannelServiceImpl implements IArticleChannelService {
grassArticleChannelDao.insertArticleChannels(grassArticleChannelList);
}
//同时更新发现好物表,兼容以前逻辑
grassFindGoodsDAO.deleteByArticleId(req.getArticleId());
//同时更新发现好物表,兼容以前逻辑
if(Arrays.asList(channelIdArray).contains("1")){
long time = System.currentTimeMillis();
List<GrassArticleProduct> grassArticleProductList = grassArticleProductDao.selectByArticleId(req.getArticleId());
... ... @@ -129,6 +132,15 @@ public class ArticleChannelServiceImpl implements IArticleChannelService {
}
}
//更新达人搭配列表,兼容以前逻辑
int markFlag = 0;
Long markTime = null;
if(Arrays.asList(channelIdArray).contains("2")){
markFlag = 1;
markTime = System.currentTimeMillis();
}
grassArticleDao.updateMarkFlag(req.getArticleId(),markFlag,markTime,null);
return new ApiResponse.ApiResponseBuilder().build();
}
... ...
... ... @@ -293,6 +293,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService {
try {
if (CollectionUtils.isNotEmpty(grassArticleChannels) && sort != 3) {
grassArticleChannelDao.insertArticleChannels(grassArticleChannels);
updateFindgoodsList(article.getId(),channelIds);
}
} catch (Exception e) {
logger.warn("publishArticle ,grassArticleChannelDao insertArticleChannels error, uid is {}, e is {}", req.getAuthorUid(), e);
... ... @@ -332,6 +333,40 @@ public class GrassArticleServiceImpl implements IGrassArticleService {
return article.getId();
}
private void updateFindgoodsList(Integer articleId , List<Integer> channelIdList){
grassFindGoodsDAO.deleteByArticleId(articleId);
//同时更新发现好物表,兼容以前逻辑
if(channelIdList.contains(1)){
long time = System.currentTimeMillis();
List<GrassArticleProduct> grassArticleProductList = grassArticleProductDao.selectByArticleId(articleId);
if (CollectionUtils.isNotEmpty(grassArticleProductList)) {
GrassArticleProduct product = grassArticleProductList.get(0);
GrassFindGoods grassFindGoods = new GrassFindGoods();
grassFindGoods.setCreateTime(time);
grassFindGoods.setArticleId(articleId);
grassFindGoods.setOrderBy(1);
grassFindGoods.setProductType(product.getProductSource());
grassFindGoods.setProductSkn(product.getProductSkn());
grassFindGoods.setUpdateTime(time);
//发现好物初始喜欢数
String initThresholdStr = configReader.getString("platform.grass.findgoods.favoriteNum.initThreshold", "");
//取区间随机数
String[] initStr = initThresholdStr.split(",");
int min = Integer.valueOf(initStr[0]);
int max = Integer.valueOf(initStr[1]);
grassFindGoods.setVirtualNum((new Random().nextInt(max - min)) + min);
grassFindGoodsDAO.insert(grassFindGoods);
//清除发现好物列表缓存
logger.info("clear findgoodlist, type=1008");
GrassCacheReq cacheReq = new GrassCacheReq();
cacheReq.setClearCode(1008);
grassRefreshCacheService.refreshGrassCache(cacheReq);
}
}
}
private List<GrassArticleLabel> buildArticleLabels(int articleId, List<Integer> lableList, Integer authStatus) {
List<GrassArticleLabel> grassArticleLables = Lists.newArrayList();
for (Integer lableId : lableList) {
... ... @@ -802,6 +837,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService {
try {
if (CollectionUtils.isNotEmpty(grassArticleChannels) && 3 != sort) {
grassArticleChannelDao.insertArticleChannels(grassArticleChannels);
updateFindgoodsList(articleId,channels);
}
} catch (Exception e) {
logger.warn("updateArticle grassArticleChannelDao insertArticleChannels error, uid is {}, e is {}", req.getAuthorUid(), e);
... ... @@ -1416,6 +1452,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService {
}
}
grassArticleChannelDao.insertArticleChannels(grassArticleChannels);
updateFindgoodsList(articleId,channels);
}
} catch (Exception e) {
logger.warn("updateArticleDraft ,grassArticleChannelDao insertArticleChannels error, uid is {}, e is {}", req.getAuthorUid(), e);
... ... @@ -1609,6 +1646,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService {
channel.setCreateTime(time);
}
grassArticleChannelDao.insertArticleChannels(grassArticleChannels);
updateFindgoodsList(article.getId(),channels);
}
} catch (Exception e) {
logger.warn("timerPublish ,grassArticleChannelDao insertArticleChannels error, uid is {}, e is {}", req.getAuthorUid(), e);
... ...