增加每日池子7个

master
ck 5 years ago
parent 0a03abcabc
commit fa0bfaabae

@ -6,4 +6,5 @@ import org.springframework.stereotype.Repository;
@Repository
public interface AwardRuleMapper extends CommonMapper<AwardRule> {
int updateDayAwardTask();
}

@ -1,5 +1,7 @@
package com.jingcheng.template.quartz;
import com.jingcheng.template.mapper.AwardRuleMapper;
import com.jingcheng.template.service.AwardRecordService;
import com.jingcheng.template.service.UsersService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -15,6 +17,8 @@ public class ScheduledTask {
@Resource
UsersService usersService;
@Resource
AwardRecordService awardRecordService;
private static final String CHANCE_TASK = "0 0 0 * * ?";
/**
@ -24,5 +28,6 @@ public class ScheduledTask {
@Scheduled(cron = CHANCE_TASK)
public void downloadWxEmployee() {
usersService.chancesTask();
awardRecordService.refreshDayAwards();
}
}

@ -54,4 +54,6 @@ public interface AwardRecordService<AwardRecord> extends BaseService<AwardRecord
* @return
*/
AjaxResult isHaveDayShare(String userId);
void refreshDayAwards();
}

@ -106,10 +106,12 @@ public class AwardRecordServiceImpl extends BaseServiceImpl<AwardRecordMapper, A
//今日抽总次数
Integer todayCount = awardRecordMapper.selectCountByExample(awardRecordExample2);
Integer awardNum = awardRule.getAwardNum();
AwardRule todayAward = awardRuleMapper.selectByPrimaryKey(2L);
Integer todayAwardNum = todayAward.getAwardNum();
if (todayAwardCount >= 1){
logger.info("此用户已抽中过奖品");
isAward = false;
}else {
}else if (todayAwardNum > 0){
int range = (int) (1 / awardRate);
int num = 1 + (int)(Math.random()*(range - 1 + 1));
if ( 0 == isHaveBigAward){
@ -150,6 +152,8 @@ public class AwardRecordServiceImpl extends BaseServiceImpl<AwardRecordMapper, A
awardRule.setUpdateDateTime(new Date());
}else {
awardRule.setAwardNum(awardNum - 1);
todayAward.setAwardNum(todayAwardNum -1);
awardRuleMapper.updateByPrimaryKeySelective(todayAward);
}
awardRuleMapper.updateByPrimaryKeySelective(awardRule);
}else {
@ -396,4 +400,11 @@ public class AwardRecordServiceImpl extends BaseServiceImpl<AwardRecordMapper, A
}
return ajaxResult;
}
@Override
public void refreshDayAwards() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
logger.info(simpleDateFormat.format(new Date())+ "刷新每日中奖池");
awardRuleMapper.updateDayAwardTask();
}
}

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jingcheng.template.mapper.AwardRuleMapper">
<update id="updateDayAwardTask">
update award_rule set award_num = 7 where id = 2
</update>
</mapper>
Loading…
Cancel
Save