...
|
...
|
@@ -1751,6 +1751,8 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
if(!topicSend){
|
|
|
sendPublishReward(articleId, uid, (int)(createTime/1000));
|
|
|
}
|
|
|
//首帖奖励和以上两种奖励可叠加
|
|
|
sendFirstPublishReward(articleId, uid, (int)(createTime/1000));
|
|
|
}
|
|
|
|
|
|
//发放审核奖励
|
...
|
...
|
@@ -1758,19 +1760,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
try{
|
|
|
List<GrassRewardsConfig> rewardsConfigList = grassRewardsConfigDAO.selectByType(1);
|
|
|
// int now = DateUtil.getCurrentTimeSeconds();
|
|
|
GrassRewardsConfig grassRewardsConfig =null;
|
|
|
for (GrassRewardsConfig rewardsConfig : rewardsConfigList) {
|
|
|
if(rewardsConfig.getStartTime()!= 0 && publishTime < rewardsConfig.getStartTime()){
|
|
|
logger.info("sendPublishReward rewardsConfig not start, rewardId is {}, startTime is {}",rewardsConfig.getId(), rewardsConfig.getStartTime());
|
|
|
continue;
|
|
|
}
|
|
|
if(rewardsConfig.getEndTime()!= 0 && publishTime > rewardsConfig.getEndTime()){
|
|
|
logger.info("sendPublishReward rewardsConfig already end, rewardId is {}, endTime is {}",rewardsConfig.getId(), rewardsConfig.getEndTime());
|
|
|
continue;
|
|
|
}
|
|
|
grassRewardsConfig = rewardsConfig;
|
|
|
break;
|
|
|
}
|
|
|
GrassRewardsConfig grassRewardsConfig = getValidRewardConfig(rewardsConfigList, publishTime);
|
|
|
if(grassRewardsConfig == null){
|
|
|
return;
|
|
|
}
|
...
|
...
|
@@ -1868,6 +1858,66 @@ public class GrassArticleServiceImpl implements IGrassArticleService { |
|
|
return hasSend;
|
|
|
}
|
|
|
|
|
|
//首次发帖奖励
|
|
|
private void sendFirstPublishReward(Integer articleId,Integer uid,int publishTime){
|
|
|
try{
|
|
|
//查询奖励配置,type=3, 没有配置则不奖励
|
|
|
List<GrassRewardsConfig> rewardsConfigList = grassRewardsConfigDAO.selectByType(3);
|
|
|
// int now = DateUtil.getCurrentTimeSeconds();
|
|
|
GrassRewardsConfig grassRewardsConfig = getValidRewardConfig(rewardsConfigList, publishTime);
|
|
|
if(grassRewardsConfig == null){
|
|
|
logger.info("sendFirstPublishReward : no rewards config found");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//判断用户时候发过帖子且被审核通过 大于一:当前帖子已被审核通过
|
|
|
List<GrassArticle> userPublishList = grassArticleDao.selectByAuthorAndStatus(uid, 1);
|
|
|
if(CollectionUtils.isNotEmpty(userPublishList) && userPublishList.size() > 1){
|
|
|
logger.info("sendFirstPublishReward: user already published article, userPublishList size is {}", userPublishList.size());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//虽然首帖奖励只应该奖励一次,但是还是走通用流程,按配置来,由配置保证次数
|
|
|
//一个奖励周期, 单位 天 //未配置 则 奖励周期为活动的开始结束时间
|
|
|
Integer rewardInterval = grassRewardsConfig.getRewardInterval();
|
|
|
Integer startTime = grassRewardsConfig.getStartTime();
|
|
|
Integer endTime = grassRewardsConfig.getEndTime();
|
|
|
if(rewardInterval != null && rewardInterval != 0){
|
|
|
startTime = getTimeIntInterval(startTime, publishTime , rewardInterval);
|
|
|
}
|
|
|
List<RewardsSendRecords> userRecords = rewardsSendRecordsDAO.selectByRewardsIdAndTimeBetween(uid,grassRewardsConfig.getId(), startTime,endTime);
|
|
|
if(userRecords.stream().anyMatch(rewardsSendRecords -> rewardsSendRecords.getArticleId().equals(articleId))){
|
|
|
logger.info("sendFirstPublishReward user has recieved reward, rewardId is {}, articleId is {},uid is {}",grassRewardsConfig.getId(), articleId, uid);
|
|
|
return;
|
|
|
}
|
|
|
if(CollectionUtils.isNotEmpty(userRecords) && userRecords.size() >= grassRewardsConfig.getMaxTime()){
|
|
|
logger.info("sendFirstPublishReward reward send times reach maxtimes, rewardId is {}, articleId is {}, uid is {}",grassRewardsConfig.getId(), articleId, uid);
|
|
|
return;
|
|
|
}
|
|
|
callSnsSendReward(articleId, grassRewardsConfig.getId(), 3, uid);
|
|
|
}catch (Exception e){
|
|
|
logger.warn("sendFirstPublishReward error, articleId is {}, e is {}", articleId, e);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private GrassRewardsConfig getValidRewardConfig(List<GrassRewardsConfig> rewardsConfigList, int publishTime){
|
|
|
GrassRewardsConfig grassRewardsConfig =null;
|
|
|
for (GrassRewardsConfig rewardsConfig : rewardsConfigList) {
|
|
|
if(rewardsConfig.getStartTime()!= 0 && publishTime < rewardsConfig.getStartTime()){
|
|
|
logger.info("sendPublishReward rewardsConfig not start, rewardId is {}, startTime is {}",rewardsConfig.getId(), rewardsConfig.getStartTime());
|
|
|
continue;
|
|
|
}
|
|
|
if(rewardsConfig.getEndTime()!= 0 && publishTime > rewardsConfig.getEndTime()){
|
|
|
logger.info("sendPublishReward rewardsConfig already end, rewardId is {}, endTime is {}",rewardsConfig.getId(), rewardsConfig.getEndTime());
|
|
|
continue;
|
|
|
}
|
|
|
grassRewardsConfig = rewardsConfig;
|
|
|
break;
|
|
|
}
|
|
|
return grassRewardsConfig;
|
|
|
}
|
|
|
|
|
|
private void callSnsSendReward(Integer articleId, Integer rewardId, Integer type,Integer uid){
|
|
|
try {
|
|
|
Map<String, Object> reqMap = Maps.newHashMap();
|
...
|
...
|
|