抽奖次数
This commit is contained in:
parent
6ffa4d5bf8
commit
8ffb5bb329
|
|
@ -5,13 +5,14 @@ import com.sqx.modules.taskCenter.entity.TaskCenterReward;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TaskCenterRewardDao extends BaseMapper<TaskCenterReward> {
|
public interface TaskCenterRewardDao extends BaseMapper<TaskCenterReward> {
|
||||||
|
|
||||||
@Select("SELECT type,number FROM `task_center_reward` where task_id = #{taskId}")
|
@Select("SELECT type,number FROM `task_center_reward` where task_id = #{taskId}")
|
||||||
Map<Integer, Integer> getRewardMap(Long taskId);
|
List<TaskCenterReward> getRewardMap(Long taskId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,10 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class TaskCenterRewardServiceImpl extends ServiceImpl<TaskCenterRewardDao, TaskCenterReward> implements TaskCenterRewardService {
|
public class TaskCenterRewardServiceImpl extends ServiceImpl<TaskCenterRewardDao, TaskCenterReward> implements TaskCenterRewardService {
|
||||||
|
|
@ -17,7 +20,14 @@ public class TaskCenterRewardServiceImpl extends ServiceImpl<TaskCenterRewardDao
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Integer, Integer> getRewardMap(Long taskId) {
|
public Map<Integer, Integer> getRewardMap(Long taskId) {
|
||||||
return baseMapper.getRewardMap(taskId);
|
List<TaskCenterReward> rewards = baseMapper.getRewardMap(taskId);
|
||||||
|
|
||||||
|
Map<Integer, Integer> map = rewards.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
TaskCenterReward::getType,
|
||||||
|
Collectors.summingInt(TaskCenterReward::getNumber)
|
||||||
|
));
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,14 +91,19 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
||||||
//周任务
|
//周任务
|
||||||
if (s.getNumber() > 1 && s.getNumber() < 8) {
|
if (s.getNumber() > 1 && s.getNumber() < 8) {
|
||||||
if (rewardMap.containsKey(9)) {
|
if (rewardMap.containsKey(9)) {
|
||||||
|
boolean isBreak = false;
|
||||||
//抽奖次数
|
//抽奖次数
|
||||||
Map<Integer, Integer> taskWCount = signRecordService.getTaskWCount(userId, rewardMap.get(9));
|
Map<Long, Integer> taskWCount = signRecordService.getTaskWCount(userId, rewardMap.get(9));
|
||||||
if (CollectionUtil.isNotEmpty(taskWCount)) {
|
if (CollectionUtil.isNotEmpty(taskWCount)) {
|
||||||
for (Integer value : taskWCount.values()) {
|
for (Integer value : taskWCount.values()) {
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
|
isBreak=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isBreak){
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Integer wSignCount = signRecordService.getWSignCount(userId);
|
Integer wSignCount = signRecordService.getWSignCount(userId);
|
||||||
|
|
@ -264,14 +269,14 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
||||||
Map<Integer, Integer> taskWRedisMap = new HashMap<>();
|
Map<Integer, Integer> taskWRedisMap = new HashMap<>();
|
||||||
if ("2".equals(type)) {
|
if ("2".equals(type)) {
|
||||||
//抽奖次数
|
//抽奖次数
|
||||||
Map<Integer, Integer> taskWCount = signRecordService.getTaskWCount(userId, rewardMap.get(9));
|
Map<Long, Integer> taskWCount = signRecordService.getTaskWCount(userId, rewardMap.get(9));
|
||||||
if (CollectionUtil.isNotEmpty(taskWCount)) {
|
if (CollectionUtil.isNotEmpty(taskWCount)) {
|
||||||
for (Map.Entry<Integer, Integer> entry : taskWCount.entrySet()) {
|
for (Map.Entry<Long, Integer> entry : taskWCount.entrySet()) {
|
||||||
Integer key = entry.getKey();
|
Long key = entry.getKey();
|
||||||
Integer value = entry.getValue();
|
Integer value = entry.getValue();
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
countTaskDisc = countTaskDisc + value;
|
countTaskDisc = countTaskDisc + value;
|
||||||
taskWRedisMap.put(key, value);
|
taskWRedisMap.put(key.intValue(), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@ import java.util.Map;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface UserSignRecordDao extends BaseMapper<UserSignRecord> {
|
public interface UserSignRecordDao extends BaseMapper<UserSignRecord> {
|
||||||
//周 抽奖次数
|
//周 抽奖次数
|
||||||
Map<Integer,Integer> getTaskWCount(long userId, int wCount,String time,List<Integer> ids);
|
List<UserSignRecord> getTaskWCount(long userId, int wCount,String time,List<Long> ids);
|
||||||
List getNoRecordTask(long userId, String time);
|
|
||||||
|
List<Long> getNoRecordTask(long userId, String time);
|
||||||
//周 签到 次数 连续签到
|
//周 签到 次数 连续签到
|
||||||
Integer getWSignCount(long userId,String time);
|
Integer getWSignCount(long userId,String time);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public interface UserSignRecordService extends IService<UserSignRecord> {
|
||||||
//获取当月签到次数
|
//获取当月签到次数
|
||||||
int getUserSignCount(long userId);
|
int getUserSignCount(long userId);
|
||||||
//周 剩余抽奖次数
|
//周 剩余抽奖次数
|
||||||
Map<Integer,Integer> getTaskWCount(long userId, int wCount);
|
Map<Long,Integer> getTaskWCount(long userId, int wCount);
|
||||||
//周 签到 次数
|
//周 签到 次数
|
||||||
Integer getWSignCount(long userId);
|
Integer getWSignCount(long userId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import com.sqx.modules.app.dao.UserDao;
|
||||||
import com.sqx.modules.app.entity.UserEntity;
|
import com.sqx.modules.app.entity.UserEntity;
|
||||||
import com.sqx.modules.common.dao.CommonInfoDao;
|
import com.sqx.modules.common.dao.CommonInfoDao;
|
||||||
import com.sqx.modules.common.entity.CommonInfo;
|
import com.sqx.modules.common.entity.CommonInfo;
|
||||||
|
import com.sqx.modules.taskCenter.entity.TaskCenterReward;
|
||||||
import com.sqx.modules.userSign.dao.UserSignRecordDao;
|
import com.sqx.modules.userSign.dao.UserSignRecordDao;
|
||||||
import com.sqx.modules.userSign.dto.UserSignDTO;
|
import com.sqx.modules.userSign.dto.UserSignDTO;
|
||||||
import com.sqx.modules.userSign.dto.UserSignRecordDTO;
|
import com.sqx.modules.userSign.dto.UserSignRecordDTO;
|
||||||
|
|
@ -132,10 +133,16 @@ public class UserSignRecordServiceImpl extends ServiceImpl<UserSignRecordDao, Us
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Integer,Integer> getTaskWCount(long userId,int wCount) {
|
public Map<Long,Integer> getTaskWCount(long userId,int wCount) {
|
||||||
Date thirtyDaysAgo = DateUtil.offsetDay(new Date(), -30);
|
Date thirtyDaysAgo = DateUtil.offsetDay(new Date(), -30);
|
||||||
List<Integer> noRecordTasks = baseMapper.getNoRecordTask(userId, DateUtil.format(thirtyDaysAgo, "yyyy-MM-dd") + " 00:00:00");
|
List<Long> noRecordTasks = baseMapper.getNoRecordTask(userId, DateUtil.format(thirtyDaysAgo, "yyyy-MM-dd") + " 00:00:00");
|
||||||
return baseMapper.getTaskWCount(userId, wCount, DateUtil.format(thirtyDaysAgo, "yyyy-MM-dd") + " 00:00:00", noRecordTasks);
|
List<UserSignRecord> taskWCount = baseMapper.getTaskWCount(userId, wCount, DateUtil.format(thirtyDaysAgo, "yyyy-MM-dd") + " 00:00:00", noRecordTasks);
|
||||||
|
Map<Long, Integer> map = taskWCount.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
UserSignRecord::getId,
|
||||||
|
Collectors.summingInt(UserSignRecord::getDay)
|
||||||
|
));
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.sqx.modules.userSign.dao.UserSignRecordDao">
|
<mapper namespace="com.sqx.modules.userSign.dao.UserSignRecordDao">
|
||||||
|
|
||||||
<select id="getNoRecordTask" resultType="List">
|
<select id="getNoRecordTask" resultType="Long">
|
||||||
SELECT
|
SELECT
|
||||||
sign.id
|
sign.id
|
||||||
FROM
|
FROM
|
||||||
|
|
@ -16,10 +16,10 @@
|
||||||
order by sign.create_time asc
|
order by sign.create_time asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTaskWCount" resultType="Map">
|
<select id="getTaskWCount" resultType="com.sqx.modules.userSign.entity.UserSignRecord">
|
||||||
SELECT
|
SELECT
|
||||||
sign.id,
|
sign.id as id,
|
||||||
#{wCount} - COUNT(CASE WHEN spRecord.source_id IS NOT NULL THEN 1 END) AS record_count
|
#{wCount} - COUNT(CASE WHEN spRecord.source_id IS NOT NULL THEN 1 END) AS `day`
|
||||||
FROM
|
FROM
|
||||||
user_sign_record sign
|
user_sign_record sign
|
||||||
LEFT JOIN disc_spinning_record spRecord ON sign.id = spRecord.source_id
|
LEFT JOIN disc_spinning_record spRecord ON sign.id = spRecord.source_id
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue