任务 抽奖 签到
This commit is contained in:
parent
4750dca914
commit
f4e93e748e
|
|
@ -1,5 +1,6 @@
|
||||||
package com.sqx.common.utils;
|
package com.sqx.common.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
|
@ -159,4 +160,17 @@ public class DateUtils {
|
||||||
DateTime dateTime = new DateTime(date);
|
DateTime dateTime = new DateTime(date);
|
||||||
return dateTime.plusYears(years).toDate();
|
return dateTime.plusYears(years).toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//获取当日剩余秒数
|
||||||
|
public static long todayAfterSecond() {
|
||||||
|
Date now = new Date();
|
||||||
|
// 获取当天结束时间(即当天23:59:59对应的Date对象)
|
||||||
|
Date endOfDay = DateUtil.endOfDay(now);
|
||||||
|
// 计算时间差(单位为毫秒)
|
||||||
|
long diffMillis = endOfDay.getTime() - now.getTime();
|
||||||
|
// 将毫秒转换为秒
|
||||||
|
long diffSeconds = diffMillis / 1000;
|
||||||
|
return diffSeconds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
package com.sqx.modules.discSpinning.controller;
|
package com.sqx.modules.discSpinning.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.sqx.common.annotation.Debounce;
|
import com.sqx.common.annotation.Debounce;
|
||||||
import com.sqx.common.utils.DateUtils;
|
import com.sqx.common.utils.DateUtils;
|
||||||
|
import com.sqx.common.utils.RedisKeys;
|
||||||
|
import com.sqx.common.utils.RedisUtils;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
import com.sqx.modules.app.annotation.Login;
|
import com.sqx.modules.app.annotation.Login;
|
||||||
import com.sqx.modules.app.entity.UserEntity;
|
import com.sqx.modules.app.entity.UserEntity;
|
||||||
|
|
@ -16,6 +19,8 @@ import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
|
||||||
import com.sqx.modules.discSpinning.service.DiscSpinningService;
|
import com.sqx.modules.discSpinning.service.DiscSpinningService;
|
||||||
import com.sqx.modules.orders.entity.Orders;
|
import com.sqx.modules.orders.entity.Orders;
|
||||||
import com.sqx.modules.orders.service.OrdersService;
|
import com.sqx.modules.orders.service.OrdersService;
|
||||||
|
import com.sqx.modules.taskCenter.entity.TaskCenterRecord;
|
||||||
|
import com.sqx.modules.taskCenter.service.TaskCenterRecordService;
|
||||||
import com.sqx.modules.taskCenter.service.TaskCenterService;
|
import com.sqx.modules.taskCenter.service.TaskCenterService;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -41,18 +46,23 @@ public class DiscSpinningController {
|
||||||
private final CommonInfoService commonRepository;
|
private final CommonInfoService commonRepository;
|
||||||
private final OrdersService ordersService;
|
private final OrdersService ordersService;
|
||||||
private final TaskCenterService taskCenterService;
|
private final TaskCenterService taskCenterService;
|
||||||
|
private final TaskCenterRecordService taskRecordService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
private final RedisUtils redisUtils;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DiscSpinningController(CommonInfoService commonRepository, DiscSpinningService discSpinningService,
|
public DiscSpinningController(CommonInfoService commonRepository, DiscSpinningService discSpinningService,
|
||||||
OrdersService ordersService, DiscSpinningRecordService recordService,
|
OrdersService ordersService, DiscSpinningRecordService recordService,
|
||||||
TaskCenterService taskCenterService, UserService userService) {
|
TaskCenterService taskCenterService, UserService userService, RedisUtils redisUtils,
|
||||||
|
TaskCenterRecordService taskRecordService) {
|
||||||
this.commonRepository = commonRepository;
|
this.commonRepository = commonRepository;
|
||||||
this.discSpinningService = discSpinningService;
|
this.discSpinningService = discSpinningService;
|
||||||
this.ordersService = ordersService;
|
this.ordersService = ordersService;
|
||||||
this.recordService = recordService;
|
this.recordService = recordService;
|
||||||
this.taskCenterService = taskCenterService;
|
this.taskCenterService = taskCenterService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
|
this.redisUtils = redisUtils;
|
||||||
|
this.taskRecordService = taskRecordService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/discSpinning/insertDiscSpinning")
|
@PostMapping("/discSpinning/insertDiscSpinning")
|
||||||
|
|
@ -143,6 +153,7 @@ public class DiscSpinningController {
|
||||||
//任务可抽奖次数
|
//任务可抽奖次数
|
||||||
map.put("count", taskCenterService.countTaskDisc(userId, source.toString()));
|
map.put("count", taskCenterService.countTaskDisc(userId, source.toString()));
|
||||||
} else {
|
} else {
|
||||||
|
//订单可抽奖次数
|
||||||
int i = recordService.countDraw(userId);
|
int i = recordService.countDraw(userId);
|
||||||
if (drawCount - i > 0) {
|
if (drawCount - i > 0) {
|
||||||
map.put("count", ordersService.selectOrdersCountStatisticsByDay(userId, drawCount - i));
|
map.put("count", ordersService.selectOrdersCountStatisticsByDay(userId, drawCount - i));
|
||||||
|
|
@ -161,10 +172,11 @@ public class DiscSpinningController {
|
||||||
@ApiOperation("抽取大转盘")
|
@ApiOperation("抽取大转盘")
|
||||||
public Result draw(@ApiIgnore @RequestAttribute("userId") Long userId, @RequestParam(required = false, defaultValue = "1") Integer source) {
|
public Result draw(@ApiIgnore @RequestAttribute("userId") Long userId, @RequestParam(required = false, defaultValue = "1") Integer source) {
|
||||||
double amount = 0;
|
double amount = 0;
|
||||||
Long orderId = null;
|
Long sourceId = null;
|
||||||
Integer i = recordService.countDraw(userId);
|
Integer i = recordService.countDraw(userId);
|
||||||
if (source != null && source.equals(1)) {
|
if (source == null || source.equals(1)) {
|
||||||
//任务抽奖
|
source = 1;
|
||||||
|
//订单抽奖
|
||||||
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
|
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
|
||||||
if (i != null && i >= drawCount) {
|
if (i != null && i >= drawCount) {
|
||||||
return Result.error("当日可抽奖次数已超限");
|
return Result.error("当日可抽奖次数已超限");
|
||||||
|
|
@ -174,12 +186,41 @@ public class DiscSpinningController {
|
||||||
return Result.error("无可抽奖机会");
|
return Result.error("无可抽奖机会");
|
||||||
}
|
}
|
||||||
amount = orders.getPayMoney().doubleValue();
|
amount = orders.getPayMoney().doubleValue();
|
||||||
orderId = orders.getOrdersId();
|
sourceId = orders.getOrdersId();
|
||||||
} else if (source == null) {
|
} else {
|
||||||
source = 1;
|
String redisKey = "";
|
||||||
|
if (source.equals(2)){
|
||||||
|
redisKey = RedisKeys.getDateKey("spinning:amount:taskW") + userId;
|
||||||
|
}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();
|
||||||
|
if (value > 1) {
|
||||||
|
value = value - 1;
|
||||||
|
week.put(entry.getKey(), value);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
TaskCenterRecord centerRecord = new TaskCenterRecord();
|
||||||
|
centerRecord.setUserId(userId);
|
||||||
|
centerRecord.setTaskId(entry.getKey().longValue());
|
||||||
|
if(source.equals(2)){
|
||||||
|
centerRecord.setSourceId(entry.getKey().longValue());
|
||||||
|
}
|
||||||
|
centerRecord.setName(source.equals(2) ? "周任务奖励" : "月任务奖励");
|
||||||
|
centerRecord.setType(9);
|
||||||
|
centerRecord.setNumber(1);
|
||||||
|
centerRecord.setCreateTime(DateUtil.now());
|
||||||
|
taskRecordService.save(centerRecord);
|
||||||
|
week.remove(entry.getKey());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
redisUtils.set(redisKey,week,DateUtils.todayAfterSecond());
|
||||||
}
|
}
|
||||||
return new Result().put("data",
|
return new Result().put("data",
|
||||||
discSpinningService.draws(i == null ? 1 : i + 1, amount, orderId, userId, source));
|
discSpinningService.draws(i == null ? 1 : i + 1, amount, sourceId, userId, source));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("大转盘奖项领取")
|
@ApiOperation("大转盘奖项领取")
|
||||||
|
|
@ -191,9 +232,11 @@ public class DiscSpinningController {
|
||||||
discSpinningService.receiveAsync(record);
|
discSpinningService.receiveAsync(record);
|
||||||
});
|
});
|
||||||
UserEntity userInfo = userService.queryByUserId(record.getUserId());
|
UserEntity userInfo = userService.queryByUserId(record.getUserId());
|
||||||
int res = 0;
|
int res = 1;
|
||||||
if (StringUtils.isNotBlank(userInfo.getZhiFuBao()) && StringUtils.isNotBlank(userInfo.getZhiFuBaoName())) {
|
if (receive.getType().equals(2)) {
|
||||||
res = 1;
|
if (StringUtils.isBlank(userInfo.getZhiFuBao()) && StringUtils.isBlank(userInfo.getZhiFuBaoName())) {
|
||||||
|
res = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Result.success().put("data", res);
|
return Result.success().put("data", res);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public class DiscSpinningRecord extends Model<DiscSpinningRecord> {
|
||||||
//主键
|
//主键
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private Long orderId;
|
private Long sourceId;
|
||||||
|
|
||||||
private Long userId;
|
private Long userId;
|
||||||
//描述
|
//描述
|
||||||
|
|
@ -46,11 +46,11 @@ public class DiscSpinningRecord extends Model<DiscSpinningRecord> {
|
||||||
public DiscSpinningRecord() {
|
public DiscSpinningRecord() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscSpinningRecord(String name, Long orderId, Long userId, Integer type, BigDecimal number,
|
public DiscSpinningRecord(String name, Long sourceId, Long userId, Integer type, BigDecimal number,
|
||||||
String drawDay, String createTime, Integer source) {
|
String drawDay, String createTime, Integer source) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.orderId = orderId;
|
this.sourceId = sourceId;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.number = number;
|
this.number = number;
|
||||||
this.drawDay = drawDay;
|
this.drawDay = drawDay;
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,7 @@ import java.util.Map;
|
||||||
public interface DiscSpinningRecordService extends IService<DiscSpinningRecord> {
|
public interface DiscSpinningRecordService extends IService<DiscSpinningRecord> {
|
||||||
|
|
||||||
Integer countDraw(Long userId);
|
Integer countDraw(Long userId);
|
||||||
|
//当月的 月记录 已抽 抽奖次数
|
||||||
|
Integer countSourceRecord(Long sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
package com.sqx.modules.discSpinning.service.impl;
|
package com.sqx.modules.discSpinning.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.sqx.modules.discSpinning.dao.DiscSpinningRecordDao;
|
import com.sqx.modules.discSpinning.dao.DiscSpinningRecordDao;
|
||||||
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
|
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
|
||||||
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
|
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
|
||||||
|
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
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.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -21,5 +24,13 @@ public class DiscSpinningRecordServiceImpl extends ServiceImpl<DiscSpinningRecor
|
||||||
public Integer countDraw(Long userId) {
|
public Integer countDraw(Long userId) {
|
||||||
return discSpinningRecordDao.countDraw(userId);
|
return discSpinningRecordDao.countDraw(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer countSourceRecord(Long sourceId) {
|
||||||
|
QueryWrapper<DiscSpinningRecord> recordQuery = new QueryWrapper<>();
|
||||||
|
recordQuery.eq("source_id", sourceId);
|
||||||
|
recordQuery.gt("create_time", DateUtil.beginOfMonth(new Date()));
|
||||||
|
return discSpinningRecordDao.selectCount(recordQuery);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public DiscSpinningRecord draws(int drawCount, double orderAmount, Long orderId, Long userId, Integer source) {
|
public DiscSpinningRecord draws(int drawCount, double orderAmount, Long sourceId, Long userId, Integer source) {
|
||||||
DiscSpinning result = new DiscSpinning("谢谢惠顾", 1, null);
|
DiscSpinning result = new DiscSpinning("谢谢惠顾", 1, null);
|
||||||
List<DiscSpinning> prizes = baseMapper.selectList(new QueryWrapper<DiscSpinning>().eq("disc_type", source).orderByAsc("odds"));
|
List<DiscSpinning> prizes = baseMapper.selectList(new QueryWrapper<DiscSpinning>().eq("disc_type", source).orderByAsc("odds"));
|
||||||
|
|
||||||
|
|
@ -221,7 +221,7 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), orderId, userId, result.getType(),
|
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), sourceId, userId, result.getType(),
|
||||||
result.getNumber(), DateUtils.formatYMD(new Date()), DateUtils.format(new Date()), source);
|
result.getNumber(), DateUtils.formatYMD(new Date()), DateUtils.format(new Date()), source);
|
||||||
recordService.save(record);
|
recordService.save(record);
|
||||||
return record;
|
return record;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,5 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TaskCenterDao extends BaseMapper<TaskCenter> {
|
public interface TaskCenterDao extends BaseMapper<TaskCenter> {
|
||||||
|
|
||||||
//大转盘任务
|
|
||||||
List<TaskCenter> queryTaskDiscCenter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,15 @@ package com.sqx.modules.taskCenter.dao;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.sqx.modules.taskCenter.entity.TaskCenterReward;
|
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 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}")
|
||||||
|
Map<Integer, Integer> getRewardMap(Long taskId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,10 @@ public class TaskCenterRecord extends Model<TaskCenterRecord> {
|
||||||
private Long id;
|
private Long id;
|
||||||
@ApiModelProperty("用户id")
|
@ApiModelProperty("用户id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
@ApiModelProperty("任务Id")
|
@ApiModelProperty("任务Id 周任务转盘奖励时 该值为 user_sign_record的id")
|
||||||
private Long taskId;
|
private Long taskId;
|
||||||
|
@ApiModelProperty("来源Id 目前仅周任务使用")
|
||||||
|
private Long sourceId;
|
||||||
@ApiModelProperty("奖励名称")
|
@ApiModelProperty("奖励名称")
|
||||||
private String name;
|
private String name;
|
||||||
@ApiModelProperty("奖励类型 1 金币 2 现金 3 4 5 9转盘")
|
@ApiModelProperty("奖励类型 1 金币 2 现金 3 4 5 9转盘")
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,6 @@ import java.util.Map;
|
||||||
|
|
||||||
public interface TaskCenterRewardService extends IService<TaskCenterReward> {
|
public interface TaskCenterRewardService extends IService<TaskCenterReward> {
|
||||||
|
|
||||||
|
Map<Integer, Integer> getRewardMap(Long taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,13 @@ import java.util.Map;
|
||||||
|
|
||||||
public interface TaskCenterService extends IService<TaskCenter> {
|
public interface TaskCenterService extends IService<TaskCenter> {
|
||||||
|
|
||||||
|
//查询任务中心
|
||||||
Result queryTaskCenter(Long userId);
|
Result queryTaskCenter(Long userId);
|
||||||
|
|
||||||
|
//任务领取
|
||||||
Result taskReceive(Long userId, Long id);
|
Result taskReceive(Long userId, Long id);
|
||||||
|
|
||||||
|
//获取大转盘抽奖次数
|
||||||
int countTaskDisc(Long userId,String type);
|
int countTaskDisc(Long userId,String type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,9 @@ import java.util.Map;
|
||||||
public class TaskCenterRewardServiceImpl extends ServiceImpl<TaskCenterRewardDao, TaskCenterReward> implements TaskCenterRewardService {
|
public class TaskCenterRewardServiceImpl extends ServiceImpl<TaskCenterRewardDao, TaskCenterReward> implements TaskCenterRewardService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Integer, Integer> getRewardMap(Long taskId) {
|
||||||
|
return baseMapper.getRewardMap(taskId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,21 @@
|
||||||
package com.sqx.modules.taskCenter.service.impl;
|
package com.sqx.modules.taskCenter.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.sqx.common.utils.DateUtils;
|
||||||
|
import com.sqx.common.utils.RedisKeys;
|
||||||
|
import com.sqx.common.utils.RedisUtils;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
|
import com.sqx.modules.app.entity.UserEntity;
|
||||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||||
import com.sqx.modules.app.service.UserMoneyService;
|
import com.sqx.modules.app.service.UserMoneyService;
|
||||||
|
import com.sqx.modules.app.service.UserService;
|
||||||
|
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
|
||||||
import com.sqx.modules.orders.service.OrdersService;
|
import com.sqx.modules.orders.service.OrdersService;
|
||||||
import com.sqx.modules.taskCenter.dao.TaskCenterDao;
|
import com.sqx.modules.taskCenter.dao.TaskCenterDao;
|
||||||
import com.sqx.modules.taskCenter.entity.TaskCenter;
|
import com.sqx.modules.taskCenter.entity.TaskCenter;
|
||||||
|
|
@ -25,9 +32,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter> implements TaskCenterService {
|
public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter> implements TaskCenterService {
|
||||||
|
|
@ -44,62 +49,89 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
||||||
private UserMoneyService userMoneyService;
|
private UserMoneyService userMoneyService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserMoneyDetailsService userMoneyDetailsService;
|
private UserMoneyDetailsService userMoneyDetailsService;
|
||||||
|
@Autowired
|
||||||
|
private DiscSpinningRecordService discSpinningRecordService;
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@Autowired
|
||||||
|
private RedisUtils redisUtils;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result queryTaskCenter(Long userId) {
|
public Result queryTaskCenter(Long userId) {
|
||||||
//任务
|
//任务
|
||||||
List<TaskCenter> taskPage = baseMapper.selectList(new QueryWrapper<TaskCenter>().eq("shows", 1).orderByAsc("sort", "type"));
|
List<TaskCenter> taskPage = baseMapper.selectList(new QueryWrapper<TaskCenter>().eq("shows", 1).orderByAsc("sort", "type"));
|
||||||
|
List<TaskCenter> resultTask = new ArrayList<>();
|
||||||
boolean todaySign = true;
|
boolean todaySign = true;
|
||||||
//月 签到记录
|
Integer signCount = null;
|
||||||
QueryWrapper<UserSignRecord> signWrapper = new QueryWrapper<>();
|
|
||||||
signWrapper.eq("user_id", userId);
|
|
||||||
signWrapper.gt("sign_day", DateUtil.format(new Date(), "yyyy-MM") + "-00");
|
|
||||||
signWrapper.orderByAsc("create_time");
|
|
||||||
int signCount = signRecordService.count(signWrapper);
|
|
||||||
TaskCenter reTaskCenter = null;
|
|
||||||
for (TaskCenter s : taskPage) {
|
for (TaskCenter s : taskPage) {
|
||||||
|
Map<Integer, Integer> rewardMap = taskCenterRewardService.getRewardMap(s.getId());
|
||||||
|
if (CollectionUtil.isEmpty(rewardMap)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch (s.getType()) {
|
switch (s.getType()) {
|
||||||
//签到任务
|
//签到任务
|
||||||
case 2:
|
case 2:
|
||||||
|
//日任务
|
||||||
if (s.getNumber().equals(1)) {
|
if (s.getNumber().equals(1)) {
|
||||||
Integer dayOrderNum = ordersService.countOrderNum(userId, DateUtil.today() + " 00:00:00");
|
Integer dayOrderNum = ordersService.countOrderNum(userId, DateUtil.today() + " 00:00:00");
|
||||||
if (dayOrderNum < 3) {
|
if (dayOrderNum < 3) {
|
||||||
s.setDiscNumber(dayOrderNum);
|
s.setDiscNumber(dayOrderNum);
|
||||||
s.setNumber(3);
|
s.setNumber(3);
|
||||||
// s.setDisabled(false);
|
|
||||||
todaySign = false;
|
todaySign = false;
|
||||||
} else if (recordService.countTaskNum(userId, s.getId(), DateUtil.today() + " 00:00:00") > 0) {
|
} else if (recordService.countTaskNum(userId, s.getId(), DateUtil.today() + " 00:00:00") > 0) {
|
||||||
s.setButtonTitle("已领取");
|
s.setButtonTitle("已领取");
|
||||||
s.setNumber(null);
|
s.setNumber(null);
|
||||||
// s.setDisabled(false);
|
|
||||||
} else {
|
} else {
|
||||||
s.setDiscNumber(0);
|
s.setDiscNumber(0);
|
||||||
s.setNumber(null);
|
s.setNumber(null);
|
||||||
s.setJumpType(0);
|
s.setJumpType(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (todaySign) {
|
//周任务
|
||||||
if ((signCount < (s.getNumber().intValue() - 1))) {
|
if (s.getNumber() > 1 && s.getNumber() < 8) {
|
||||||
s.setDiscNumber(signCount);
|
if (rewardMap.containsKey(9)) {
|
||||||
s.setNumber(null);
|
//抽奖次数
|
||||||
s.setDisabled(false);
|
Map<Integer, Integer> taskWCount = signRecordService.getTaskWCount(userId, rewardMap.get(9));
|
||||||
} else if (recordService.countTaskNum(userId, s.getId(), DateUtil.beginOfMonth(new Date()).toString()) > 0) {
|
if (CollectionUtil.isNotEmpty(taskWCount)) {
|
||||||
s.setButtonTitle("已领取");
|
for (Integer value : taskWCount.values()) {
|
||||||
s.setDisabled(false);
|
if (value > 0) {
|
||||||
s.setNumber(null);
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
Integer wSignCount = signRecordService.getWSignCount(userId);
|
||||||
if ((signCount < s.getNumber().intValue())) {
|
if (wSignCount == null || wSignCount + (todaySign ? 1 : 0) < s.getNumber()) {
|
||||||
s.setDiscNumber(signCount);
|
s.setDiscNumber(wSignCount == null ? 0 : wSignCount);
|
||||||
s.setDisabled(false);
|
s.setDisabled(false);
|
||||||
s.setNumber(null);
|
} else {
|
||||||
} else if (recordService.countTaskNum(userId, s.getId(), DateUtil.beginOfMonth(new Date()).toString()) > 0) {
|
|
||||||
s.setButtonTitle("已领取");
|
s.setButtonTitle("已领取");
|
||||||
s.setDisabled(false);
|
s.setDisabled(false);
|
||||||
s.setNumber(null);
|
s.setNumber(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//月任务
|
||||||
|
else if (s.getNumber() > 7 && s.getNumber() < 32) {
|
||||||
|
if (signCount == null) {
|
||||||
|
signCount = signRecordService.getUserSignCount(userId);
|
||||||
|
}
|
||||||
|
if (signCount + (todaySign ? 1 : 0) < s.getNumber()) {
|
||||||
|
s.setDiscNumber(signCount);
|
||||||
|
s.setDisabled(false);
|
||||||
|
} else {
|
||||||
|
if (rewardMap.containsKey(9)) {
|
||||||
|
Integer spinningCount = discSpinningRecordService.countSourceRecord(s.getId());
|
||||||
|
if (spinningCount == null || spinningCount > 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
s.setButtonTitle("已领取");
|
||||||
|
s.setDisabled(false);
|
||||||
|
s.setNumber(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//一次性任务
|
//一次性任务
|
||||||
|
|
@ -110,32 +142,29 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
||||||
s.setDiscNumber(sumOrderNum);
|
s.setDiscNumber(sumOrderNum);
|
||||||
s.setNumber(s.getNumber());
|
s.setNumber(s.getNumber());
|
||||||
} else if (recordService.countTaskNum(userId, s.getId(), null) > 0) {
|
} else if (recordService.countTaskNum(userId, s.getId(), null) > 0) {
|
||||||
reTaskCenter = s;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
s.setDiscNumber(0);
|
s.setDiscNumber(0);
|
||||||
s.setNumber(null);
|
s.setNumber(null);
|
||||||
s.setJumpType(0);
|
s.setJumpType(0);
|
||||||
}
|
}
|
||||||
|
} else if (s.getDetail().contains("绑定支付宝")) {
|
||||||
|
UserEntity userInfo = userService.queryByUserId(userId);
|
||||||
|
if (StringUtils.isNotBlank(userInfo.getZhiFuBao()) && StringUtils.isNotBlank(userInfo.getZhiFuBaoName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
resultTask.add(s);
|
||||||
}
|
}
|
||||||
if (reTaskCenter != null) {
|
return Result.success().put("data", resultTask);
|
||||||
taskPage.remove(reTaskCenter);
|
|
||||||
}
|
|
||||||
return Result.success().put("data", taskPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Result taskReceive(Long userId, Long id) {
|
public Result taskReceive(Long userId, Long id) {
|
||||||
TaskCenter taskCenter = baseMapper.selectById(id);
|
TaskCenter taskCenter = baseMapper.selectById(id);
|
||||||
//月 签到记录
|
|
||||||
QueryWrapper<UserSignRecord> signWrapper = new QueryWrapper<>();
|
|
||||||
signWrapper.eq("user_id", userId);
|
|
||||||
signWrapper.gt("sign_day", DateUtil.format(new Date(), "yyyy-MM") + "-00");
|
|
||||||
signWrapper.orderByAsc("create_time");
|
|
||||||
int signCount = signRecordService.count(signWrapper);
|
|
||||||
|
|
||||||
if (taskCenter.getType().equals(2)) {
|
if (taskCenter.getType().equals(2)) {
|
||||||
Integer dayOrderNum = ordersService.countOrderNum(userId, DateUtil.today() + " 00:00:00");
|
Integer dayOrderNum = ordersService.countOrderNum(userId, DateUtil.today() + " 00:00:00");
|
||||||
|
|
@ -143,7 +172,7 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
||||||
UserSignRecord yesterday = signRecordService.getOne(new QueryWrapper<UserSignRecord>().eq("user_id", userId).eq("sign_day",
|
UserSignRecord yesterday = signRecordService.getOne(new QueryWrapper<UserSignRecord>().eq("user_id", userId).eq("sign_day",
|
||||||
DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd")));
|
DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd")));
|
||||||
UserSignRecord signRecord = new UserSignRecord();
|
UserSignRecord signRecord = new UserSignRecord();
|
||||||
if (yesterday != null && yesterday.getDay() != null) {
|
if (yesterday != null && yesterday.getDay() != null && yesterday.getDay() != 7) {
|
||||||
signRecord.setDay(yesterday.getDay() + 1);
|
signRecord.setDay(yesterday.getDay() + 1);
|
||||||
} else {
|
} else {
|
||||||
signRecord.setDay(1);
|
signRecord.setDay(1);
|
||||||
|
|
@ -158,22 +187,6 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
||||||
return Result.error("不可重复领取");
|
return Result.error("不可重复领取");
|
||||||
}
|
}
|
||||||
signRecordService.save(signRecord);
|
signRecordService.save(signRecord);
|
||||||
} else {
|
|
||||||
if (dayOrderNum > 2) {
|
|
||||||
if (signCount < (taskCenter.getNumber().intValue() - 1)) {
|
|
||||||
return Result.error("领取失败,未达成领取条件");
|
|
||||||
}
|
|
||||||
if (recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.today() + " 00:00:00") > 0) {
|
|
||||||
return Result.error("不可重复领取");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (signCount < taskCenter.getNumber().intValue()) {
|
|
||||||
return Result.error("领取失败,未达成领取条件");
|
|
||||||
}
|
|
||||||
if (recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.today() + " 00:00:00") > 0) {
|
|
||||||
return Result.error("不可重复领取");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (taskCenter.getType().equals(3) && taskCenter.getId().equals(1L)) {
|
} else if (taskCenter.getType().equals(3) && taskCenter.getId().equals(1L)) {
|
||||||
Integer sumOrderNum = ordersService.countOrderNum(userId, null);
|
Integer sumOrderNum = ordersService.countOrderNum(userId, null);
|
||||||
|
|
@ -228,49 +241,59 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countTaskDisc(Long userId, String type) {
|
public int countTaskDisc(Long userId, String type) {
|
||||||
|
int countTaskDisc = 0;
|
||||||
|
Integer signCount = null;
|
||||||
if (StringUtils.isBlank(type) || "1".equals(type)) {
|
if (StringUtils.isBlank(type) || "1".equals(type)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//月 签到记录
|
QueryWrapper<TaskCenter> queryWrapper = new QueryWrapper<>();
|
||||||
QueryWrapper<UserSignRecord> signWrapper = new QueryWrapper<>();
|
queryWrapper.eq("type", 2);
|
||||||
signWrapper.eq("user_id", userId);
|
if ("2".equals(type)) {
|
||||||
signWrapper.gt("sign_day", DateUtil.format(new Date(), "yyyy-MM") + "-00");
|
queryWrapper.gt("number", 1);
|
||||||
signWrapper.orderByAsc("create_time");
|
queryWrapper.lt("number", 8);
|
||||||
int signCount = signRecordService.count(signWrapper);
|
} else if ("3".equals(type)) {
|
||||||
|
queryWrapper.gt("number", 7);
|
||||||
//TaskCenter的number为大转盘次数
|
queryWrapper.lt("number", 32);
|
||||||
List<TaskCenter> taskCenters = baseMapper.queryTaskDiscCenter();
|
}
|
||||||
int countTaskDisc = 0;
|
List<TaskCenter> taskCenters = baseMapper.selectList(queryWrapper);
|
||||||
Integer dayOrderNum = ordersService.countOrderNum(userId, DateUtil.today() + " 00:00:00");
|
|
||||||
for (TaskCenter taskCenter : taskCenters) {
|
for (TaskCenter taskCenter : taskCenters) {
|
||||||
if (taskCenter.getType().equals(2)) {
|
Map<Integer, Integer> rewardMap = taskCenterRewardService.getRewardMap(taskCenter.getId());
|
||||||
if (taskCenter.getNumber().equals(1)) {
|
if (CollectionUtil.isEmpty(rewardMap)) {
|
||||||
if (dayOrderNum > 2 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.today() + " 00:00:00") < 1) {
|
continue;
|
||||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
}
|
||||||
}
|
Map<Integer, Integer> taskWRedisMap = new HashMap<>();
|
||||||
} else {
|
if ("2".equals(type)) {
|
||||||
if ("2".equals(type) && taskCenter.getNumber().intValue() > 1 && taskCenter.getNumber().intValue() < 8) {
|
//抽奖次数
|
||||||
if (dayOrderNum > 2) {
|
Map<Integer, Integer> taskWCount = signRecordService.getTaskWCount(userId, rewardMap.get(9));
|
||||||
if (signCount - taskCenter.getNumber().intValue() >= -1 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.beginOfMonth(new Date()).toString()) < 1) {
|
if (CollectionUtil.isNotEmpty(taskWCount)) {
|
||||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
for (Map.Entry<Integer, Integer> entry : taskWCount.entrySet()) {
|
||||||
}
|
Integer key = entry.getKey();
|
||||||
} else {
|
Integer value = entry.getValue();
|
||||||
if (signCount - taskCenter.getNumber().intValue() >= 0 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.beginOfMonth(new Date()).toString()) < 1) {
|
if (value > 0) {
|
||||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
countTaskDisc = countTaskDisc + value;
|
||||||
}
|
taskWRedisMap.put(key, value);
|
||||||
}
|
|
||||||
} else if ("3".equals(type) && taskCenter.getNumber().intValue() > 7 && taskCenter.getNumber().intValue() < 32) {
|
|
||||||
if (dayOrderNum > 2) {
|
|
||||||
if (signCount - taskCenter.getNumber().intValue() >= -1 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.beginOfMonth(new Date()).toString()) < 1) {
|
|
||||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (signCount - taskCenter.getNumber().intValue() >= 0 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.beginOfMonth(new Date()).toString()) < 1) {
|
|
||||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(taskWRedisMap)) {
|
||||||
|
redisUtils.set(RedisKeys.getDateKey("spinning:amount:taskW") + userId, taskWRedisMap, DateUtils.todayAfterSecond());
|
||||||
|
}
|
||||||
|
} else if ("3".equals(type)) {
|
||||||
|
if (signCount == null) {
|
||||||
|
signCount = signRecordService.getUserSignCount(userId);
|
||||||
|
}
|
||||||
|
if (signCount >= taskCenter.getNumber()) {
|
||||||
|
if (rewardMap.containsKey(9)) {
|
||||||
|
Integer spinningCount = discSpinningRecordService.countSourceRecord(taskCenter.getId());
|
||||||
|
countTaskDisc = countTaskDisc + (spinningCount == null ? 0 : spinningCount);
|
||||||
|
if (countTaskDisc > 0) {
|
||||||
|
taskWRedisMap.put(taskCenter.getId().intValue(), countTaskDisc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(taskWRedisMap)) {
|
||||||
|
redisUtils.set(RedisKeys.getDateKey("spinning:amount:taskM") + userId, taskWRedisMap, DateUtils.todayAfterSecond());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return countTaskDisc;
|
return countTaskDisc;
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.sqx.modules.userSign.entity.UserSignRecord;
|
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
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);
|
||||||
|
//周 签到 次数 连续签到
|
||||||
|
Integer getWSignCount(long userId,String time);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,19 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.sqx.modules.userSign.dto.UserSignDTO;
|
import com.sqx.modules.userSign.dto.UserSignDTO;
|
||||||
import com.sqx.modules.userSign.entity.UserSignRecord;
|
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public interface UserSignRecordService extends IService<UserSignRecord> {
|
public interface UserSignRecordService extends IService<UserSignRecord> {
|
||||||
|
|
||||||
UserSignDTO getUserSignData(long userId);
|
UserSignDTO getUserSignData(long userId);
|
||||||
|
|
||||||
|
//获取当月签到次数
|
||||||
|
int getUserSignCount(long userId);
|
||||||
|
//周 剩余抽奖次数
|
||||||
|
Map<Integer,Integer> getTaskWCount(long userId, int wCount);
|
||||||
|
//周 签到 次数
|
||||||
|
Integer getWSignCount(long userId);
|
||||||
|
|
||||||
String[] getUserSignAwardConfig();
|
String[] getUserSignAwardConfig();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.sqx.common.exception.SqxException;
|
import com.sqx.common.exception.SqxException;
|
||||||
|
|
@ -120,6 +121,27 @@ public class UserSignRecordServiceImpl extends ServiceImpl<UserSignRecordDao, Us
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getUserSignCount(long userId) {
|
||||||
|
QueryWrapper<UserSignRecord> signWrapper = new QueryWrapper<>();
|
||||||
|
signWrapper.eq("user_id", userId);
|
||||||
|
signWrapper.gt("sign_day", DateUtil.format(new Date(), "yyyy-MM") + "-00");
|
||||||
|
signWrapper.orderByAsc("create_time");
|
||||||
|
int signCount = baseMapper.selectCount(signWrapper);
|
||||||
|
return signCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Integer,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");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getWSignCount(long userId) {
|
||||||
|
return baseMapper.getWSignCount(userId, DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd") + " 00:00:00");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getUserSignAwardConfig() {
|
public String[] getUserSignAwardConfig() {
|
||||||
CommonInfo config = commonInfoDao.findOne(918);
|
CommonInfo config = commonInfoDao.findOne(918);
|
||||||
|
|
|
||||||
|
|
@ -279,25 +279,21 @@
|
||||||
|
|
||||||
|
|
||||||
<select id="selectOrdersCountStatisticsByDay" resultType="Integer">
|
<select id="selectOrdersCountStatisticsByDay" resultType="Integer">
|
||||||
SELECT
|
SELECT count(*)
|
||||||
count(*)
|
FROM orders
|
||||||
FROM
|
LEFT JOIN disc_spinning_record record ON orders.orders_id = record.source_id
|
||||||
orders
|
WHERE orders.user_id = #{userId}
|
||||||
LEFT JOIN disc_spinning_record record ON orders.orders_id = record.order_id
|
|
||||||
WHERE
|
|
||||||
orders.user_id = #{userId}
|
|
||||||
AND orders.`status` = 1
|
AND orders.`status` = 1
|
||||||
AND orders.`pay_way` = 9
|
AND orders.`pay_way` = 9
|
||||||
AND orders.create_time > DATE_FORMAT( CURDATE(), '%Y-%m-%d 00:00:00' )
|
AND orders.create_time > DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00:00')
|
||||||
AND record.order_id IS NULL
|
AND record.order_id IS NULL
|
||||||
ORDER BY
|
ORDER BY orders.create_time
|
||||||
orders.create_time
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectOrdersByDay" resultType="com.sqx.modules.orders.entity.Orders">
|
<select id="selectOrdersByDay" resultType="com.sqx.modules.orders.entity.Orders">
|
||||||
SELECT orders.*
|
SELECT orders.*
|
||||||
FROM orders
|
FROM orders
|
||||||
LEFT JOIN disc_spinning_record record ON orders.orders_id = record.order_id
|
LEFT JOIN disc_spinning_record record ON orders.orders_id = record.source_id
|
||||||
WHERE orders.user_id = #{userId}
|
WHERE orders.user_id = #{userId}
|
||||||
AND orders.`status` = 1
|
AND orders.`status` = 1
|
||||||
AND orders.`pay_way` = 9
|
AND orders.`pay_way` = 9
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,4 @@
|
||||||
<!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.taskCenter.dao.TaskCenterDao">
|
<mapper namespace="com.sqx.modules.taskCenter.dao.TaskCenterDao">
|
||||||
|
|
||||||
|
|
||||||
<select id="queryTaskDiscCenter" resultType="com.sqx.modules.taskCenter.entity.TaskCenter">
|
|
||||||
SELECT task.*,
|
|
||||||
reward.number as discNumber
|
|
||||||
FROM task_center_reward reward
|
|
||||||
INNER JOIN task_center task ON reward.task_id = task.id and task.shows = 1
|
|
||||||
where reward.type = 9
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?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.sqx.modules.userSign.dao.UserSignRecordDao">
|
||||||
|
|
||||||
|
<select id="getTaskWCount" resultType="Map">
|
||||||
|
SELECT
|
||||||
|
sign.id,
|
||||||
|
#{wCount} - COUNT(CASE WHEN cenRecord.id IS NULL and record.source_id IS NOT NULL THEN 1 END) AS record_count
|
||||||
|
|
||||||
|
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}
|
||||||
|
order by sign.create_time asc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getWSignCount" resultType="Integer">
|
||||||
|
SELECT `day`
|
||||||
|
FROM user_sign_record
|
||||||
|
WHERE user_id = #{userId}
|
||||||
|
and create_time > #{time}
|
||||||
|
ORDER BY create_time desc
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue