parent
53f6a8c24e
commit
1b1a1e6c49
|
|
@ -120,9 +120,13 @@ public class DiscSpinningController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/app/discSpinning/selectDiscSpinning")
|
@GetMapping("/app/discSpinning/selectDiscSpinning")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "type", value = "`1`普通转盘 `2`任务转盘", dataTypeClass = String.class, paramType = "body"),
|
||||||
|
})
|
||||||
@ApiOperation("查询大转盘")
|
@ApiOperation("查询大转盘")
|
||||||
public Result selectDiscSpinning() {
|
public Result selectDiscSpinning(@RequestParam(required = false, defaultValue = "1") Integer type) {
|
||||||
return Result.success().put("data", discSpinningService.page(new Page<>(0, 8), new QueryWrapper<DiscSpinning>().orderByAsc("odds")));
|
return Result.success().put("data", discSpinningService.page(new Page<>(1, 20),
|
||||||
|
new QueryWrapper<DiscSpinning>().eq("disc_type", type).orderByAsc("disc_type", "odds")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Login
|
@Login
|
||||||
|
|
@ -268,7 +272,7 @@ public class DiscSpinningController {
|
||||||
@Transactional
|
@Transactional
|
||||||
public DiscSpinningRecord draws(double orderAmount, Long orderId, Long userId, String source) {
|
public DiscSpinningRecord draws(double orderAmount, Long orderId, Long userId, String source) {
|
||||||
DiscSpinning result = new DiscSpinning("谢谢惠顾", 1, null);
|
DiscSpinning result = new DiscSpinning("谢谢惠顾", 1, null);
|
||||||
List<DiscSpinning> prizes = discSpinningService.list(new QueryWrapper<DiscSpinning>().orderByAsc("odds"));
|
List<DiscSpinning> prizes = discSpinningService.list(new QueryWrapper<DiscSpinning>().eq("disc_type", "order".equals(source) ? 1 : 2).orderByAsc("odds"));
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
double randomDouble;
|
double randomDouble;
|
||||||
do {
|
do {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.sqx.modules.taskCenter.controller;
|
package com.sqx.modules.taskCenter.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sqx.modules.app.annotation.Login;
|
||||||
import com.sqx.modules.taskCenter.entity.TaskCenter;
|
import com.sqx.modules.taskCenter.entity.TaskCenter;
|
||||||
import com.sqx.modules.taskCenter.service.TaskCenterService;
|
import com.sqx.modules.taskCenter.service.TaskCenterService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
|
@ -8,10 +9,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.sqx.common.utils.DateUtils;
|
import com.sqx.common.utils.DateUtils;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
@ -61,12 +65,21 @@ public class TaskCenterController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Login
|
||||||
//disabled 是否可领取
|
|
||||||
@GetMapping("/app/taskCenter/selectTaskCenter")
|
@GetMapping("/app/taskCenter/selectTaskCenter")
|
||||||
@ApiOperation("App查询任务中心")
|
@ApiOperation("App查询任务中心")
|
||||||
public Result selectAppTaskCenter(Integer page, Integer limit) {
|
public Result selectAppTaskCenter(Integer page, Integer limit, @ApiIgnore @RequestAttribute("userId") Long userId) {
|
||||||
return Result.success().put("data", taskCenterService.page(new Page<>(page, limit), new QueryWrapper<TaskCenter>().orderByDesc("id")));
|
return taskCenterService.queryTaskCenter(page, limit, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Login
|
||||||
|
@GetMapping("/app/taskCenter/taskReceive")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "id", value = "任务id", dataTypeClass = Long.class),
|
||||||
|
})
|
||||||
|
@ApiOperation("App 任务中心 领取")
|
||||||
|
public Result taskReceive(@ApiIgnore @RequestAttribute("userId") Long userId,Long id) {
|
||||||
|
return taskCenterService.taskReceive(userId,id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.sqx.modules.taskCenter.entity;
|
package com.sqx.modules.taskCenter.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
|
@ -43,6 +44,8 @@ public class TaskCenter extends Model<TaskCenter> {
|
||||||
private String createTime;
|
private String createTime;
|
||||||
private String updateTime;
|
private String updateTime;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private boolean disabled = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,17 @@
|
||||||
package com.sqx.modules.taskCenter.service;
|
package com.sqx.modules.taskCenter.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.sqx.common.utils.Result;
|
||||||
import com.sqx.modules.taskCenter.entity.TaskCenter;
|
import com.sqx.modules.taskCenter.entity.TaskCenter;
|
||||||
|
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface TaskCenterService extends IService<TaskCenter> {
|
public interface TaskCenterService extends IService<TaskCenter> {
|
||||||
|
|
||||||
|
Result queryTaskCenter(Integer page, Integer limit, Long userId);
|
||||||
|
Result taskReceive(Long userId,Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,143 @@
|
||||||
package com.sqx.modules.taskCenter.service.impl;
|
package com.sqx.modules.taskCenter.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
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.Result;
|
||||||
|
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||||
|
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||||
|
import com.sqx.modules.app.service.UserMoneyService;
|
||||||
|
import com.sqx.modules.course.entity.CourseUser;
|
||||||
|
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;
|
||||||
|
import com.sqx.modules.taskCenter.entity.TaskCenterReward;
|
||||||
|
import com.sqx.modules.taskCenter.service.TaskCenterRewardService;
|
||||||
import com.sqx.modules.taskCenter.service.TaskCenterService;
|
import com.sqx.modules.taskCenter.service.TaskCenterService;
|
||||||
|
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||||
|
import com.sqx.modules.userSign.service.UserSignRecordService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
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 org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter> implements TaskCenterService {
|
public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter> implements TaskCenterService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserSignRecordService signRecordService;
|
||||||
|
@Autowired
|
||||||
|
private OrdersService ordersService;
|
||||||
|
@Autowired
|
||||||
|
private TaskCenterRewardService taskCenterRewardService;
|
||||||
|
@Autowired
|
||||||
|
private UserMoneyService userMoneyService;
|
||||||
|
@Autowired
|
||||||
|
private UserMoneyDetailsService userMoneyDetailsService;
|
||||||
|
@Override
|
||||||
|
public Result queryTaskCenter(Integer page, Integer limit, Long userId) {
|
||||||
|
//任务
|
||||||
|
IPage<TaskCenter> taskPage = baseMapper.selectPage(new Page<>(page, limit), new QueryWrapper<TaskCenter>().orderByDesc("sort"));
|
||||||
|
boolean todaySign = true;
|
||||||
|
//月 签到记录
|
||||||
|
QueryWrapper<UserSignRecord> signWrapper = new QueryWrapper<>();
|
||||||
|
signWrapper.eq("user_id", userId);
|
||||||
|
signWrapper.lt("sign_day", DateUtil.format(new Date(), "yyyy-MM") + "-00");
|
||||||
|
signWrapper.orderByAsc("create_time");
|
||||||
|
List<UserSignRecord> signRecordList = signRecordService.list(signWrapper);
|
||||||
|
for (TaskCenter s : taskPage.getRecords()) {
|
||||||
|
//签到任务
|
||||||
|
if (s.getType() == 2) {
|
||||||
|
if (s.getNumber().equals(1)) {
|
||||||
|
Integer dayOrderNum = ordersService.countOrderNum(userId, DateUtil.today() + " 00:00:00");
|
||||||
|
if (dayOrderNum < 3) {
|
||||||
|
s.setDisabled(false);
|
||||||
|
todaySign = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (todaySign) {
|
||||||
|
if (signRecordList.size() < (s.getNumber().intValue() - 1)) {
|
||||||
|
s.setDisabled(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (signRecordList.size() < s.getNumber().intValue()) {
|
||||||
|
s.setDisabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.success().put("data", taskPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Result taskReceive(Long userId, Long id) {
|
||||||
|
TaskCenter taskCenter = baseMapper.selectById(id);
|
||||||
|
//月 签到记录
|
||||||
|
QueryWrapper<UserSignRecord> signWrapper = new QueryWrapper<>();
|
||||||
|
signWrapper.eq("user_id", userId);
|
||||||
|
signWrapper.lt("sign_day", DateUtil.format(new Date(), "yyyy-MM") + "-00");
|
||||||
|
signWrapper.orderByAsc("create_time");
|
||||||
|
List<UserSignRecord> signRecordList = signRecordService.list(signWrapper);
|
||||||
|
|
||||||
|
if (taskCenter.getType().equals(2)) {
|
||||||
|
if (taskCenter.getType() == 2) {
|
||||||
|
Integer dayOrderNum = ordersService.countOrderNum(userId, DateUtil.today() + " 00:00:00");
|
||||||
|
if (taskCenter.getNumber().equals(1)) {
|
||||||
|
if (dayOrderNum < 3) {
|
||||||
|
return Result.error("领取失败,未达成领取条件");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dayOrderNum > 2) {
|
||||||
|
if (signRecordList.size() < (taskCenter.getNumber().intValue() - 1)) {
|
||||||
|
return Result.error("领取失败,未达成领取条件");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (signRecordList.size() < taskCenter.getNumber().intValue()) {
|
||||||
|
return Result.error("领取失败,未达成领取条件");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QueryWrapper<TaskCenterReward> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("task_id",id);
|
||||||
|
List<TaskCenterReward> list = taskCenterRewardService.list(queryWrapper);
|
||||||
|
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||||
|
userMoneyDetails.setClassify(8);
|
||||||
|
userMoneyDetails.setUserId(userId);
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
|
||||||
|
userMoneyDetails.setTitle("任务中心");
|
||||||
|
userMoneyDetails.setState(2);
|
||||||
|
userMoneyDetails.setType(1);
|
||||||
|
for (TaskCenterReward reward : list) {
|
||||||
|
userMoneyDetails.setMoney(new BigDecimal(reward.getNumber()));
|
||||||
|
switch (reward.getType()){
|
||||||
|
case 1:
|
||||||
|
userMoneyDetails.setContent(taskCenter.getTitle()+"任务完成,金豆奖励" + reward.getNumber());
|
||||||
|
userMoneyService.updateMoney(1, userId, reward.getNumber());
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
userMoneyDetails.setContent(taskCenter.getTitle()+"任务完成,现金奖励" + reward.getNumber());
|
||||||
|
userMoneyService.updateAmount(1, userId, reward.getNumber());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
userMoneyDetailsService.save(userMoneyDetails);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.sqx.modules.userSign.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||||
|
import com.sqx.modules.userSign.service.UserSignRecordService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.sqx.common.utils.DateUtils;
|
||||||
|
import com.sqx.common.utils.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@Api(value = "用户签到", tags = {"用户签到"})
|
||||||
|
@RequestMapping(value = "/userSignRecord")
|
||||||
|
public class UserSignRecordController {
|
||||||
|
/**
|
||||||
|
* 服务对象
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private UserSignRecordService userSignRecordService;
|
||||||
|
|
||||||
|
// @GetMapping("/selectUserSignRecord")
|
||||||
|
// @ApiOperation("查询用户签到表")
|
||||||
|
// public Result selectUserSignRecord(Integer page, Integer limit,@RequestAttribute("userId") Long userId) {
|
||||||
|
// return Result.success().put("data", userSignRecordService.page(new Page<>(page, limit), new QueryWrapper<UserSignRecord>().orderByAsc("create_time")));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.sqx.modules.userSign.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UserSignRecordDao extends BaseMapper<UserSignRecord> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.sqx.modules.userSign.entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户签到表(UserSignRecord)表实体类
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2024-12-07 11:37:10
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("user_sign_record")
|
||||||
|
@ApiModel(value = "用户签到表 实体类")
|
||||||
|
public class UserSignRecord extends Model<UserSignRecord> {
|
||||||
|
@ApiModelProperty("id")
|
||||||
|
private Long id;
|
||||||
|
@ApiModelProperty("用户id")
|
||||||
|
private Long userId;
|
||||||
|
@ApiModelProperty("累计签到")
|
||||||
|
private Integer day;
|
||||||
|
@ApiModelProperty("签到日")
|
||||||
|
private String signDay;
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.sqx.modules.userSign.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface UserSignRecordService extends IService<UserSignRecord> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.sqx.modules.userSign.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.sqx.modules.userSign.dao.UserSignRecordDao;
|
||||||
|
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||||
|
import com.sqx.modules.userSign.service.UserSignRecordService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserSignRecordServiceImpl extends ServiceImpl<UserSignRecordDao, UserSignRecord> implements UserSignRecordService {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue