Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -3,6 +3,7 @@ package com.sqx;
|
||||
import com.sqx.modules.pay.wuyou.WuyouPay;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@@ -11,6 +12,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@EnableCaching
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
public class SqxApplication {
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
package com.sqx.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* Redis配置
|
||||
*
|
||||
@@ -16,6 +23,18 @@ public class RedisConfig {
|
||||
@Autowired
|
||||
private RedisConnectionFactory factory;
|
||||
|
||||
@Bean
|
||||
public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisCacheConfiguration cacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(30))
|
||||
// 设置缓存过期时间为30分钟
|
||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer()))
|
||||
.disableCachingNullValues();
|
||||
|
||||
return RedisCacheManager.builder(redisConnectionFactory)
|
||||
.cacheDefaults(cacheConfiguration)
|
||||
.build();
|
||||
}
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate() {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,10 +15,11 @@ import java.util.List;
|
||||
* @date 2020/7/8
|
||||
*/
|
||||
@Mapper
|
||||
@CacheConfig(cacheNames = "common")
|
||||
public interface CommonInfoDao extends BaseMapper<CommonInfo> {
|
||||
|
||||
List<CommonInfo> findByCondition(@Param("condition") String condition);
|
||||
|
||||
@Cacheable(key = "#type")
|
||||
CommonInfo findOne(@Param("type") int type);
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,10 @@ import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.course.service.CourseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -16,6 +20,7 @@ import java.util.Date;
|
||||
* @author fang
|
||||
* @date 2020/7/8
|
||||
*/
|
||||
@CacheConfig(cacheNames = "common")
|
||||
@Service
|
||||
public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo> implements CommonInfoService {
|
||||
|
||||
@@ -25,7 +30,7 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
||||
private CourseService courseService;
|
||||
|
||||
|
||||
|
||||
@CacheEvict(key = "#commonInfo.id")
|
||||
@Override
|
||||
public Result update(CommonInfo commonInfo) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
@@ -43,19 +48,19 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommonInfo findOne(int type) {
|
||||
return commonInfoDao.findOne(type);
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#id")
|
||||
@Override
|
||||
public Result delete(long id) {
|
||||
commonInfoDao.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@CacheEvict(key = "#commonInfo.id")
|
||||
@Override
|
||||
public Result updateBody(CommonInfo commonInfo) {
|
||||
commonInfoDao.updateById(commonInfo);
|
||||
|
||||
@@ -194,24 +194,27 @@ public class DiscSpinningController {
|
||||
}else if(source.equals(3)){
|
||||
redisKey = RedisKeys.getDateKey("spinning:amount:taskM") + userId;
|
||||
}
|
||||
Map<Integer, Integer> week = redisUtils.get(redisKey, Map.class);
|
||||
for (Map.Entry<Integer, Integer> entry : week.entrySet()) {
|
||||
Integer value = entry.getValue();
|
||||
Map<String, Object> week = redisUtils.get(redisKey, Map.class);
|
||||
for (Map.Entry<String, Object> entry : week.entrySet()) {
|
||||
int value = new BigDecimal(entry.getValue().toString()).intValue();
|
||||
if (value > 1) {
|
||||
value = value - 1;
|
||||
week.put(entry.getKey(), value);
|
||||
sourceId = Long.valueOf(entry.getKey());
|
||||
break;
|
||||
} else {
|
||||
TaskCenterRecord centerRecord = new TaskCenterRecord();
|
||||
centerRecord.setUserId(userId);
|
||||
centerRecord.setTaskId(entry.getKey().longValue());
|
||||
centerRecord.setTaskId(Long.valueOf(entry.getKey()));
|
||||
if(source.equals(2)){
|
||||
centerRecord.setSourceId(entry.getKey().longValue());
|
||||
sourceId = Long.valueOf(entry.getKey());
|
||||
centerRecord.setSourceId(Long.getLong(entry.getKey()));
|
||||
}
|
||||
centerRecord.setName(source.equals(2) ? "周任务奖励" : "月任务奖励");
|
||||
centerRecord.setType(9);
|
||||
centerRecord.setNumber(1);
|
||||
centerRecord.setCreateTime(DateUtil.now());
|
||||
centerRecord.setUpdateTime(DateUtil.now());
|
||||
taskRecordService.save(centerRecord);
|
||||
week.remove(entry.getKey());
|
||||
break;
|
||||
|
||||
@@ -5,13 +5,14 @@ import com.sqx.modules.taskCenter.entity.TaskCenterReward;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface TaskCenterRewardDao extends BaseMapper<TaskCenterReward> {
|
||||
|
||||
@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 org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class TaskCenterRewardServiceImpl extends ServiceImpl<TaskCenterRewardDao, TaskCenterReward> implements TaskCenterRewardService {
|
||||
@@ -17,7 +20,14 @@ public class TaskCenterRewardServiceImpl extends ServiceImpl<TaskCenterRewardDao
|
||||
|
||||
@Override
|
||||
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,21 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
||||
//周任务
|
||||
if (s.getNumber() > 1 && s.getNumber() < 8) {
|
||||
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)) {
|
||||
for (Integer value : taskWCount.values()) {
|
||||
if (value > 0) {
|
||||
isBreak=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isBreak){
|
||||
s.setDiscNumber(null);
|
||||
s.setNumber(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Integer wSignCount = signRecordService.getWSignCount(userId);
|
||||
@@ -123,6 +130,8 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
||||
if (rewardMap.containsKey(9)) {
|
||||
Integer spinningCount = discSpinningRecordService.countSourceRecord(s.getId());
|
||||
if (spinningCount == null || spinningCount > 0) {
|
||||
s.setDiscNumber(null);
|
||||
s.setNumber(null);
|
||||
break;
|
||||
} else {
|
||||
s.setButtonTitle("已领取");
|
||||
@@ -264,14 +273,14 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
||||
Map<Integer, Integer> taskWRedisMap = new HashMap<>();
|
||||
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)) {
|
||||
for (Map.Entry<Integer, Integer> entry : taskWCount.entrySet()) {
|
||||
Integer key = entry.getKey();
|
||||
for (Map.Entry<Long, Integer> entry : taskWCount.entrySet()) {
|
||||
Long key = entry.getKey();
|
||||
Integer value = entry.getValue();
|
||||
if (value > 0) {
|
||||
countTaskDisc = countTaskDisc + value;
|
||||
taskWRedisMap.put(key, value);
|
||||
taskWRedisMap.put(key.intValue(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,15 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserSignRecordDao extends BaseMapper<UserSignRecord> {
|
||||
//周 抽奖次数
|
||||
Map<Integer,Integer> getTaskWCount(long userId, int wCount,String time);
|
||||
List<UserSignRecord> getTaskWCount(long userId, int wCount,String time,List<Long> ids);
|
||||
|
||||
List<Long> getNoRecordTask(long userId, String time);
|
||||
//周 签到 次数 连续签到
|
||||
Integer getWSignCount(long userId,String time);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public interface UserSignRecordService extends IService<UserSignRecord> {
|
||||
//获取当月签到次数
|
||||
int getUserSignCount(long userId);
|
||||
//周 剩余抽奖次数
|
||||
Map<Integer,Integer> getTaskWCount(long userId, int wCount);
|
||||
Map<Long,Integer> getTaskWCount(long userId, int wCount);
|
||||
//周 签到 次数
|
||||
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.common.dao.CommonInfoDao;
|
||||
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.dto.UserSignDTO;
|
||||
import com.sqx.modules.userSign.dto.UserSignRecordDTO;
|
||||
@@ -132,9 +133,16 @@ public class UserSignRecordServiceImpl extends ServiceImpl<UserSignRecordDao, Us
|
||||
}
|
||||
|
||||
@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);
|
||||
return baseMapper.getTaskWCount(userId,wCount,DateUtil.format(thirtyDaysAgo, "yyyy-MM-dd")+" 00:00:00");
|
||||
List<Long> noRecordTasks = baseMapper.getNoRecordTask(userId, DateUtil.format(thirtyDaysAgo, "yyyy-MM-dd") + " 00:00:00");
|
||||
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
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
c.msg_url as msgUrl,
|
||||
c.pay_num as payNum,
|
||||
c.price,
|
||||
c.wholesale_price as wholesalePrice,
|
||||
c.is_over as isOver,
|
||||
c.title,
|
||||
c.is_price as isPrice,
|
||||
@@ -139,6 +140,7 @@
|
||||
c.msg_url as msgUrl,
|
||||
c.pay_num as payNum,
|
||||
c.price,
|
||||
c.wholesale_price as wholesalePrice,
|
||||
c.is_over as isOver,
|
||||
c.title,
|
||||
c.is_price as isPrice,
|
||||
@@ -264,6 +266,7 @@
|
||||
c.msg_url as msgUrl,
|
||||
c.pay_num as payNum,
|
||||
c.price,
|
||||
c.wholesale_price as wholesalePrice,
|
||||
c.status,
|
||||
c.title,
|
||||
c.title_img as titleImg,
|
||||
|
||||
@@ -281,12 +281,12 @@
|
||||
<select id="selectOrdersCountStatisticsByDay" resultType="Integer">
|
||||
SELECT count(*)
|
||||
FROM orders
|
||||
LEFT JOIN disc_spinning_record record ON orders.orders_id = record.source_id
|
||||
LEFT JOIN disc_spinning_record record ON orders.orders_id = record.source_id and record.source = 'order'
|
||||
WHERE orders.user_id = #{userId}
|
||||
AND orders.`status` = 1
|
||||
AND orders.`pay_way` = 9
|
||||
AND orders.create_time > DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00:00')
|
||||
AND record.order_id IS NULL
|
||||
AND record.source_id IS NULL
|
||||
ORDER BY orders.create_time
|
||||
</select>
|
||||
|
||||
@@ -298,7 +298,7 @@
|
||||
AND orders.`status` = 1
|
||||
AND orders.`pay_way` = 9
|
||||
AND orders.create_time > DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00:00')
|
||||
AND record.order_id IS NULL
|
||||
AND record.source_id IS NULL
|
||||
ORDER BY orders.create_time LIMIT 1
|
||||
</select>
|
||||
|
||||
|
||||
@@ -2,19 +2,38 @@
|
||||
<!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">
|
||||
|
||||
<select id="getTaskWCount" resultType="Map">
|
||||
<select id="getNoRecordTask" resultType="Long">
|
||||
SELECT
|
||||
sign.id,
|
||||
#{wCount} - COUNT(CASE WHEN cenRecord.id IS NULL and record.source_id IS NOT NULL THEN 1 END) AS record_count
|
||||
|
||||
sign.id
|
||||
FROM
|
||||
user_sign_record sign
|
||||
LEFT JOIN task_center_record cenRecord ON sign.id = cenRecord.source_id
|
||||
WHERE
|
||||
sign.`DAY` = 7
|
||||
AND sign.user_id = #{userId}
|
||||
and sign.create_time > #{time}
|
||||
AND cenRecord.id IS NULL
|
||||
order by sign.create_time asc
|
||||
</select>
|
||||
|
||||
<select id="getTaskWCount" resultType="com.sqx.modules.userSign.entity.UserSignRecord">
|
||||
SELECT
|
||||
sign.id as id,
|
||||
#{wCount} - COUNT(CASE WHEN spRecord.source_id IS NOT NULL THEN 1 END) AS `day`
|
||||
FROM
|
||||
user_sign_record sign
|
||||
LEFT JOIN task_center_record cenRecord on sign.id = cenRecord.source_id
|
||||
LEFT JOIN disc_spinning_record spRecord ON sign.id = spRecord.source_id
|
||||
WHERE
|
||||
sign.`DAY` = 7;
|
||||
AND sign.user_id = #{userId}
|
||||
and sign.create_time > #{time}
|
||||
sign.`DAY` = 7
|
||||
AND sign.user_id = #{userId}
|
||||
AND sign.create_time > #{time}
|
||||
<if test="ids!= null and ids.size() > 0">
|
||||
AND sign.id in
|
||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY sign.id
|
||||
order by sign.create_time asc
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user