use of com.ch999.haha.admin.vo.mappervo.AdoptionSuccessNewsVO in project haha by hahafreeasair666.
the class CreditComponent method newsHandle.
private void newsHandle(Adoption li, AdoptionSuccessNewsVO adoptionSuccessNewsVO, Integer times) {
long date = new Date().getTime();
switch(times) {
case 1:
if (date > adoptionSuccessNewsVO.getTime1().getTime()) {
Wrapper<News> newsWrapper = new EntityWrapper<>();
newsWrapper.eq("parentid", li.getAdoptionId()).lt("createtime", adoptionSuccessNewsVO.getTime1());
List<News> news = newsService.selectList(newsWrapper);
// 到时间没写就减10分信誉分
if (CollectionUtils.isEmpty(news)) {
updateUserCredit(li.getUserId(), 10, false);
// 写了就加5分
} else {
updateUserCredit(li.getUserId(), 5, true);
}
li.setFirstHandle(true);
}
break;
case 2:
if (date > adoptionSuccessNewsVO.getTime2().getTime()) {
Wrapper<News> newsWrapper = new EntityWrapper<>();
newsWrapper.eq("parentid", li.getAdoptionId()).lt("createtime", adoptionSuccessNewsVO.getTime2());
List<News> news = newsService.selectList(newsWrapper);
// 到时间没写就减10分信誉分
if (CollectionUtils.isEmpty(news)) {
updateUserCredit(li.getUserId(), 10, false);
// 写了就加5分
} else {
updateUserCredit(li.getUserId(), 5, true);
}
li.setSecondHandle(true);
}
break;
case 3:
if (date > adoptionSuccessNewsVO.getTime3().getTime()) {
Wrapper<News> newsWrapper = new EntityWrapper<>();
newsWrapper.eq("parentid", li.getAdoptionId()).lt("createtime", adoptionSuccessNewsVO.getTime3());
List<News> news = newsService.selectList(newsWrapper);
// 到时间没写就减10分信誉分
if (CollectionUtils.isEmpty(news)) {
updateUserCredit(li.getUserId(), 10, false);
} else {
// 写了就加5分
updateUserCredit(li.getUserId(), 5, true);
}
li.setThirdHandle(true);
}
break;
default:
break;
}
}
use of com.ch999.haha.admin.vo.mappervo.AdoptionSuccessNewsVO in project haha by hahafreeasair666.
the class CreditComponent method timedTaskOfZan.
/*@Scheduled(fixedRate = 5000*1)
public void testTimedTask(){
System.out.println("哈哈自在如风");
}*/
/**
* 对反馈公告的赞进行每日赞数量检测进行发布者信用积分的修改
*/
@Scheduled(cron = "0 0 0 * * ?")
public void timedTaskOfZan() {
try {
// 对收养反馈公告的赞数量进行发布者信用积分改变
Wrapper<AdoptionFeedBack> wrapper = new EntityWrapper<>();
adoptionFeedBackService.selectList(wrapper).forEach(li -> {
News news = newsService.selectById(li.getNewsId());
if (news.getZan() > li.getLastTimeZan()) {
updateUserCredit(news.getCreateUserId(), getNumber(news.getZan() - li.getLastTimeZan()), true);
li.setLastTimeZan(news.getZan());
adoptionFeedBackService.updateById(li);
}
});
// 对成功收养的反馈公告进行检查对信用积分改变
Wrapper<Adoption> wrapper1 = new EntityWrapper<>();
wrapper1.eq("isadoption", 1);
adoptionService.selectList(wrapper1).forEach(li -> {
AdoptionSuccessNewsVO adoptionSuccessNewsVO = adoptionMapper.checkUserIsSendNews(li.getId());
// 第一次
if (!li.getFirstHandle()) {
newsHandle(li, adoptionSuccessNewsVO, 1);
// 第二次
} else if (!li.getSecondHandle()) {
newsHandle(li, adoptionSuccessNewsVO, 2);
// 第三次
} else if (!li.getThirdHandle()) {
newsHandle(li, adoptionSuccessNewsVO, 3);
}
adoptionService.updateById(li);
});
log.info("定时任务处理完毕 " + new Date());
} catch (Exception e) {
log.error("拉闸,定时任务异常..............");
}
}
Aggregations