Merge branch 'test' into dev
This commit is contained in:
commit
e4cbc46ab6
|
|
@ -53,6 +53,7 @@ public class ShiroConfig {
|
|||
filterMap.put("/captcha.jpg", "anon");
|
||||
filterMap.put("/search/**", "anon");
|
||||
filterMap.put("/cashOutAudit/batchCashOutOrder", "anon");
|
||||
filterMap.put("/app/discSpinning/receive1", "anon");
|
||||
filterMap.put("/**", "oauth2");
|
||||
|
||||
shiroFilter.setFilterChainDefinitionMap(filterMap);
|
||||
|
|
|
|||
|
|
@ -268,6 +268,7 @@ public class AppController {
|
|||
}
|
||||
Map<String, Object> map = BeanUtil.beanToMap(user);
|
||||
map.putAll(BeanUtil.beanToMap(userInfo));
|
||||
map.put("userId",map.get("userId").toString());
|
||||
if (StrUtil.isBlank(user.getZhiFuBaoName()) && StrUtil.isNotBlank(userInfo.getCertName())) {
|
||||
map.put("zhiFuBaoName", userInfo.getCertName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
|
|||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
|
@ -14,6 +15,7 @@ import java.util.Date;
|
|||
*/
|
||||
@TableName(value ="user_info")
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
public class UserInfo implements Serializable {
|
||||
/**
|
||||
*
|
||||
|
|
@ -64,53 +66,13 @@ public class UserInfo implements Serializable {
|
|||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String name;
|
||||
@TableField(exist = false)
|
||||
private String phone;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
UserInfo other = (UserInfo) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
|
||||
&& (this.getCertName() == null ? other.getCertName() == null : this.getCertName().equals(other.getCertName()))
|
||||
&& (this.getCertNo() == null ? other.getCertNo() == null : this.getCertNo().equals(other.getCertNo()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
|
||||
result = prime * result + ((getCertName() == null) ? 0 : getCertName().hashCode());
|
||||
result = prime * result + ((getCertNo() == null) ? 0 : getCertNo().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", userId=").append(userId);
|
||||
sb.append(", certName=").append(certName);
|
||||
sb.append(", certNo=").append(certNo);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,4 +30,6 @@ public interface UserInfoService extends IService<UserInfo> {
|
|||
Integer countCertCount(String name, String idNum, String accountNo, String mobile);
|
||||
|
||||
int getAuthUserTag(long userId);
|
||||
|
||||
Object getList(Integer page, Integer size, String phone, String name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,18 @@ import cn.hutool.core.util.StrUtil;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.modules.app.dao.UserDao;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserInfo;
|
||||
import com.sqx.modules.app.mapper.UserInfoMapper;
|
||||
import com.sqx.modules.app.service.UserInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
|
|
@ -21,6 +26,13 @@ import java.util.List;
|
|||
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
||||
implements UserInfoService {
|
||||
|
||||
private final UserDao userDao;
|
||||
|
||||
public UserInfoServiceImpl(UserDao userDao) {
|
||||
this.userDao = userDao;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserInfo getByUserIdOrSave(long userId) {
|
||||
UserInfo userInfo = getOne(new LambdaQueryWrapper<UserInfo>()
|
||||
|
|
@ -114,6 +126,34 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
|||
// 老用户
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getList(Integer page, Integer size, String phone, String name) {
|
||||
LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(phone)) {
|
||||
UserEntity userEntity = userDao.selectOne(new LambdaQueryWrapper<UserEntity>().eq(UserEntity::getPhone, phone));
|
||||
lambdaQueryWrapper.eq(UserInfo::getUserId, userEntity == null ? -99999 : userEntity.getUserId());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
lambdaQueryWrapper.like(UserInfo::getCertName, name);
|
||||
}
|
||||
PageHelper.startPage(page, size);
|
||||
List<UserInfo> userInfoList = list(lambdaQueryWrapper);
|
||||
PageInfo<UserInfo> userInfoPageInfo = new PageInfo<>(userInfoList);
|
||||
|
||||
Set<Long> userIdList = userInfoList.stream().map(UserInfo::getUserId).collect(Collectors.toSet());
|
||||
Map<Long, UserEntity> userMap = userIdList.isEmpty() ? new HashMap<>() : userDao.selectList(new LambdaQueryWrapper<UserEntity>().in(UserEntity::getUserId, userIdList))
|
||||
.stream().collect(Collectors.toMap(UserEntity::getUserId, item -> item));
|
||||
|
||||
userInfoList.forEach(item -> {
|
||||
UserEntity userEntity = userMap.get(item.getUserId());
|
||||
if (userEntity == null) return;
|
||||
item.setName(userEntity.getUserName());
|
||||
item.setPhone(userEntity.getPhone());
|
||||
});
|
||||
return PageUtils.page(userInfoPageInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.sqx.modules.common.service.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
|
@ -66,6 +67,7 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
|||
}
|
||||
commonInfoDao.updateById(commonInfo);
|
||||
cleanAppKv();
|
||||
//cleanAppOssKv(commonInfo.getType());
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
@ -77,6 +79,10 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
|||
@CacheEvict(key = "#id")
|
||||
@Override
|
||||
public Result delete(long id) {
|
||||
CommonInfo commonInfo = commonInfoDao.selectById(id);
|
||||
if(commonInfo != null){
|
||||
//cleanAppOssKv(commonInfo.getType());
|
||||
}
|
||||
commonInfoDao.deleteById(id);
|
||||
cleanAppKv();
|
||||
return Result.success();
|
||||
|
|
@ -86,7 +92,9 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
|||
@Override
|
||||
public Result updateBody(CommonInfo commonInfo) {
|
||||
commonInfoDao.updateById(commonInfo);
|
||||
|
||||
cleanAppKv();
|
||||
//cleanAppOssKv(commonInfo.getType());
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
@ -111,21 +119,27 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
|||
return new HashMap<>(0);
|
||||
}
|
||||
Map<Integer, String> data = list.stream().collect(Collectors.toMap(CommonInfo::getType, CommonInfo::getValue));
|
||||
String url = putOss();
|
||||
//String url = putOss();
|
||||
// 移除 条款、服务协议、隐私政策 这些长text字段,为减缓宽带消耗,放到oss中加载
|
||||
data.put(154, url);
|
||||
data.put(155, url);
|
||||
data.put(246, url);
|
||||
//data.put(154, url);
|
||||
//data.put(155, url);
|
||||
//data.put(246, url);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanAppKv() {
|
||||
cacheManager.getCache("commonInfoAppKv").clear();
|
||||
redisUtils.delete(SYS_OSS_CONFIG_JSON_URL_KEY);
|
||||
}
|
||||
|
||||
private void cleanAppOssKv(Integer key) {
|
||||
if (ArrayUtil.contains(PUT_OSS_KEYS, key)) {
|
||||
redisUtils.delete(SYS_OSS_CONFIG_JSON_URL_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String SYS_OSS_CONFIG_JSON_URL_KEY = "SYS_OSS_CONFIG_JSON_URL";
|
||||
private static final Integer[] PUT_OSS_KEYS = {154, 155, 246};
|
||||
|
||||
@Override
|
||||
public String putOss() {
|
||||
|
|
@ -135,7 +149,7 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
|||
}
|
||||
List<CommonInfo> list = commonInfoDao.selectList(Wrappers.<CommonInfo>lambdaQuery()
|
||||
.eq(CommonInfo::getIsAppUse, 1)
|
||||
.in(CommonInfo::getType, 154, 155, 246));
|
||||
.in(CommonInfo::getType, PUT_OSS_KEYS));
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.sqx.modules.discSpinning.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
|
|
@ -35,7 +34,7 @@ public class DiscSpinningAmountController {
|
|||
@ApiOperation("添加现金红包 抽奖配置")
|
||||
public Result insertDiscSpinningAmount(@RequestBody DiscSpinningAmount discSpinningAmount) {
|
||||
discSpinningAmountService.save(discSpinningAmount);
|
||||
redisUtils.delete(RedisKeys.getDateKey("spinning:amount"));
|
||||
redisUtils.delete(RedisKeys.getDateKey("spinning:amount:"+discSpinningAmount.getType()));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +48,7 @@ public class DiscSpinningAmountController {
|
|||
@ApiOperation("修改现金红包 抽奖配置")
|
||||
public Result updateDiscSpinningAmount(@RequestBody DiscSpinningAmount discSpinningAmount) {
|
||||
discSpinningAmountService.updateById(discSpinningAmount);
|
||||
redisUtils.delete(RedisKeys.getDateKey("spinning:amount"));
|
||||
redisUtils.delete(RedisKeys.getDateKey("spinning:amount:"+discSpinningAmount.getType()));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
@ -63,9 +62,12 @@ public class DiscSpinningAmountController {
|
|||
|
||||
@GetMapping("/selectDiscSpinningAmount")
|
||||
@ApiOperation("查询现金红包 抽奖配置")
|
||||
public Result selectDiscSpinningAmount(Integer page, Integer limit) {
|
||||
public Result selectDiscSpinningAmount(@RequestParam(required = false, defaultValue = "1")Integer page,
|
||||
@RequestParam(required = false, defaultValue = "10")Integer limit,
|
||||
@RequestParam(required = false, defaultValue = "1")Integer type) {
|
||||
PageHelper.startPage(page, limit);
|
||||
List<DiscSpinningAmount> list = discSpinningAmountService.list(new QueryWrapper<DiscSpinningAmount>().orderByDesc("status").orderByAsc("num", "random", "max_amount"));
|
||||
List<DiscSpinningAmount> list = discSpinningAmountService.list(new QueryWrapper<DiscSpinningAmount>()
|
||||
.eq("type",type).orderByDesc("status").orderByAsc("num", "random", "max_amount"));
|
||||
PageInfo<DiscSpinningAmount> pageInfo = new PageInfo<>(list);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo, true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.sqx.modules.discSpinning.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.exception.CzgException;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.common.utils.*;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.service.UserInfoService;
|
||||
|
|
@ -23,7 +25,6 @@ import com.sqx.modules.taskCenter.service.TaskCenterService;
|
|||
import io.swagger.annotations.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ public class DiscSpinningController {
|
|||
public DiscSpinningController(CommonInfoService commonRepository, DiscSpinningService discSpinningService,
|
||||
OrdersService ordersService, DiscSpinningRecordService recordService,
|
||||
TaskCenterService taskCenterService, UserService userService, RedisUtils redisUtils,
|
||||
TaskCenterRecordService taskRecordService,UserInfoService userInfoService) {
|
||||
TaskCenterRecordService taskRecordService, UserInfoService userInfoService) {
|
||||
this.commonRepository = commonRepository;
|
||||
this.discSpinningService = discSpinningService;
|
||||
this.ordersService = ordersService;
|
||||
|
|
@ -68,26 +69,21 @@ public class DiscSpinningController {
|
|||
|
||||
@PostMapping("/discSpinning/insertDiscSpinning")
|
||||
@ApiOperation("添加大转盘")
|
||||
@Transactional
|
||||
public Result insertDiscSpinning(@RequestBody DiscSpinning discSpinning) {
|
||||
discSpinning.setCreateTime(DateUtils.format(new Date()));
|
||||
discSpinning.setNumber(discSpinning.getOdds());
|
||||
discSpinningService.save(discSpinning);
|
||||
|
||||
List<DiscSpinning> prizes = discSpinningService.list(new QueryWrapper<DiscSpinning>().eq("disc_type", discSpinning.getDiscType()).orderByAsc("type", "id"));
|
||||
BigDecimal number = BigDecimal.ZERO;
|
||||
for (DiscSpinning prize : prizes) {
|
||||
number = number.add(prize.getOdds());
|
||||
prize.setNumber(number);
|
||||
}
|
||||
BigDecimal totalOdds = prizes.stream()
|
||||
.map(DiscSpinning::getOdds)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
if (totalOdds.compareTo(new BigDecimal(100)) > 0) {
|
||||
discSpinning.setNumber(number.add(discSpinning.getOdds()));
|
||||
if (discSpinning.getNumber().compareTo(new BigDecimal(100)) > 0) {
|
||||
return Result.error("中奖概率总和 不可超过100");
|
||||
}
|
||||
discSpinning.setCreateTime(DateUtils.format(new Date()));
|
||||
discSpinning.setNumber(discSpinning.getOdds());
|
||||
discSpinningService.updateBatchById(prizes);
|
||||
discSpinningService.save(discSpinning);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
@ -100,22 +96,22 @@ public class DiscSpinningController {
|
|||
@PostMapping("/discSpinning/updateDiscSpinning")
|
||||
@ApiOperation("修改大转盘")
|
||||
public Result updateDiscSpinning(@RequestBody DiscSpinning discSpinning) {
|
||||
discSpinningService.updateById(discSpinning);
|
||||
|
||||
List<DiscSpinning> prizes = discSpinningService.list(new QueryWrapper<DiscSpinning>().eq("disc_type", discSpinning.getDiscType()).orderByAsc("type", "id"));
|
||||
List<DiscSpinning> upPrizes = new ArrayList<>();
|
||||
BigDecimal number = BigDecimal.ZERO;
|
||||
for (DiscSpinning prize : prizes) {
|
||||
//当前
|
||||
if (discSpinning.getId().equals(prize.getId())) {
|
||||
prize = discSpinning;
|
||||
}
|
||||
number = number.add(prize.getOdds());
|
||||
prize.setNumber(number);
|
||||
upPrizes.add(prize);
|
||||
}
|
||||
BigDecimal totalOdds = prizes.stream()
|
||||
.map(DiscSpinning::getOdds)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
if (totalOdds.compareTo(new BigDecimal(100)) > 0) {
|
||||
if (number.compareTo(new BigDecimal(100)) > 0) {
|
||||
return Result.error("中奖概率总和 不可超过100");
|
||||
}
|
||||
discSpinningService.updateBatchById(prizes);
|
||||
discSpinningService.updateBatchById(upPrizes);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
@ -173,73 +169,101 @@ public class DiscSpinningController {
|
|||
@ApiImplicitParam(name = "source", value = "1 普通转盘 2 周任务转盘 3 月任务转盘", dataTypeClass = Integer.class),
|
||||
})
|
||||
@ApiOperation("抽取大转盘")
|
||||
@Debounce(interval = 3000, value = "#userId")
|
||||
@Debounce(value = "#userId")
|
||||
public Result draw(@ApiIgnore @RequestAttribute("userId") Long userId, @RequestParam(required = false, defaultValue = "1") Integer source) throws CzgException {
|
||||
double amount = 0;
|
||||
Long sourceId = null;
|
||||
Integer i = recordService.countDraw(userId);
|
||||
if ((i != null && i.equals(2)) || !source.equals(1)) {
|
||||
boolean auth = userInfoService.isAuth(userId);
|
||||
if(!auth) return Result.error("剩余抽奖活动需要实名认证后进行");
|
||||
String lockKey = StrUtil.format("user:disc-spinning:limit:user:lock:{}", userId);
|
||||
if (redisUtils.hasKey(lockKey)) {
|
||||
return Result.error("抽奖进行中,请等待!");
|
||||
}
|
||||
if (source == null || source.equals(1)) {
|
||||
source = 1;
|
||||
//订单抽奖
|
||||
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
|
||||
if (i != null && i >= drawCount) {
|
||||
throw new CzgException("当日可抽奖次数已超限");
|
||||
}
|
||||
Orders orders = ordersService.selectOrdersByDay(userId);
|
||||
if (orders == null) {
|
||||
throw new CzgException("无可抽奖机会");
|
||||
}
|
||||
amount = orders.getPayMoney().doubleValue();
|
||||
sourceId = orders.getOrdersId();
|
||||
} else {
|
||||
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<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(Long.valueOf(entry.getKey()));
|
||||
if (source.equals(2)) {
|
||||
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;
|
||||
String intervalKey = StrUtil.format("user:disc-spinning:interval:limit:user:{}", userId);
|
||||
if (redisUtils.hasKey(intervalKey)) {
|
||||
return Result.error("抽奖请求过于频繁,请稍后再试!");
|
||||
}
|
||||
redisUtils.set(lockKey, true, 30);
|
||||
Result ret = Result.error();
|
||||
try {
|
||||
double amount = 0;
|
||||
Long sourceId = null;
|
||||
Integer i = recordService.countDraw(userId);
|
||||
if ((i != null && i.equals(2)) || !source.equals(1)) {
|
||||
boolean auth = userInfoService.isAuth(userId);
|
||||
if (!auth) {
|
||||
return Result.error("剩余抽奖活动需要实名认证后进行");
|
||||
}
|
||||
}
|
||||
redisUtils.set(redisKey, week, DateUtils.todayAfterSecond());
|
||||
}
|
||||
if (source == 1 && sourceId == null) {
|
||||
throw new CzgException("异常请求");
|
||||
}
|
||||
if (DataLimitUtil.isAllowed(RedisKeys.getDateKey("spinning:draw:") + sourceId, 120)) {
|
||||
DiscSpinningRecord draws = discSpinningService.draws(i == null ? 1 : i + 1, amount, sourceId, userId, source);
|
||||
executor.schedule(() -> discSpinningService.receive1(draws), 4, TimeUnit.SECONDS);
|
||||
return new Result().put("data", draws);
|
||||
} else {
|
||||
throw new CzgException("异常请求");
|
||||
if (source == null || source.equals(1)) {
|
||||
source = 1;
|
||||
//订单抽奖
|
||||
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
|
||||
if (i != null && i >= drawCount) {
|
||||
throw new CzgException("当日可抽奖次数已超限");
|
||||
}
|
||||
Orders orders = ordersService.selectOrdersByDay(userId);
|
||||
if (orders == null) {
|
||||
throw new CzgException("无可抽奖机会");
|
||||
}
|
||||
amount = orders.getPayMoney().doubleValue();
|
||||
sourceId = orders.getOrdersId();
|
||||
} else {
|
||||
String redisKey = "";
|
||||
if (source.equals(2)) {
|
||||
redisKey = RedisKeys.getDateKey("spinning:draw:taskW") + userId;
|
||||
} else if (source.equals(3)) {
|
||||
redisKey = RedisKeys.getDateKey("spinning:draw:taskM") + userId;
|
||||
}
|
||||
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(Long.valueOf(entry.getKey()));
|
||||
if (source.equals(2)) {
|
||||
sourceId = Long.valueOf(entry.getKey());
|
||||
centerRecord.setSourceId(sourceId);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
redisUtils.set(redisKey, week, DateUtils.todayAfterSecond());
|
||||
}
|
||||
if (source == 1 && sourceId == null) {
|
||||
throw new CzgException("异常请求");
|
||||
}
|
||||
if (sourceId == null) {
|
||||
return Result.error("请求失败,请联系管理员");
|
||||
}
|
||||
if (DataLimitUtil.isAllowed(RedisKeys.getDateKey("spinning:draw:") + sourceId, 120)) {
|
||||
DiscSpinningRecord draws = discSpinningService.draws(i == null ? 1 : i + 1, amount, sourceId, userId, source);
|
||||
executor.schedule(() -> discSpinningService.receive1(draws), 4, TimeUnit.SECONDS);
|
||||
redisUtils.set(intervalKey, true, 5);
|
||||
return new Result().put("data", draws);
|
||||
} else {
|
||||
throw new CzgException("异常请求");
|
||||
}
|
||||
} catch (CzgException e) {
|
||||
throw e;
|
||||
} catch (SqxException e) {
|
||||
ret.put("msg", e.getMsg());
|
||||
} catch (Exception e) {
|
||||
log.error("抽奖异常", e);
|
||||
ret.put("msg", "请求失败,请联系管理员");
|
||||
} finally {
|
||||
redisUtils.delete(lockKey);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ApiOperation("大转盘奖项领取")
|
||||
|
|
@ -249,7 +273,5 @@ public class DiscSpinningController {
|
|||
// userService.addBlackUser(userId, "转盘奖项领取");
|
||||
return Result.success().put("data", 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.sqx.modules.discSpinning.entity;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -16,6 +18,7 @@ import java.math.BigDecimal;
|
|||
@TableName("disc_spinning")
|
||||
public class DiscSpinning extends Model<DiscSpinning> {
|
||||
//主键
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
//图标
|
||||
private String url;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -19,7 +21,10 @@ import lombok.Data;
|
|||
@ApiModel(value = "现金红包 抽奖配置 实体类")
|
||||
public class DiscSpinningAmount extends Model<DiscSpinningAmount> {
|
||||
@ApiModelProperty("主键id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
@ApiModelProperty("1 订单 2 周任务转盘 3 月任务转盘")
|
||||
private Integer type;
|
||||
@ApiModelProperty("从第几次开始变化")
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private Integer num;
|
||||
|
|
|
|||
|
|
@ -2,18 +2,17 @@ package com.sqx.modules.discSpinning.service.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.modules.app.entity.UserEntity;
|
||||
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.app.service.UserService;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.discSpinning.dao.DiscSpinningDao;
|
||||
import com.sqx.modules.discSpinning.entity.DiscSpinning;
|
||||
|
|
@ -21,20 +20,13 @@ import com.sqx.modules.discSpinning.entity.DiscSpinningAmount;
|
|||
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
|
||||
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
|
||||
import com.sqx.modules.discSpinning.service.DiscSpinningService;
|
||||
import com.sqx.modules.pay.entity.CashOut;
|
||||
import com.sqx.modules.pay.entity.WithdrawTypeEnum;
|
||||
import com.sqx.modules.pay.service.CashOutService;
|
||||
import com.sqx.modules.pay.wuyou.BaseResp;
|
||||
import com.sqx.modules.pay.wuyou.WuyouPay;
|
||||
import com.sqx.modules.utils.AliPayOrderUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
|
@ -90,7 +82,7 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails(
|
||||
receive.getUserId(), null, null, "[现金大转盘]", 5, 1, 2,
|
||||
receive.getNumber(), "现金红包奖励" + receive.getNumber() + "元", 1,receive.getId());
|
||||
receive.getNumber(), "现金红包奖励" + receive.getNumber() + "元", 1, receive.getId());
|
||||
//上一秒
|
||||
userMoneyDetails.setCreateTime(DateUtil.format(new Date(System.currentTimeMillis() - 1000), "yyyy-MM-dd HH:mm:ss"));
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
|
|
@ -106,26 +98,34 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
@Transactional
|
||||
public DiscSpinningRecord draws(int drawCount, double orderAmount, Long sourceId, Long userId, Integer source) {
|
||||
DiscSpinning result = new DiscSpinning("谢谢惠顾", 1, BigDecimal.ZERO);
|
||||
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("number"));
|
||||
if (CollectionUtil.isEmpty(prizes)) {
|
||||
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), sourceId, userId, result.getUrl(), result.getType(),
|
||||
result.getNumber(), DateUtils.formatYMD(new Date()), DateUtils.format(new Date()), source);
|
||||
recordService.save(record);
|
||||
return record;
|
||||
}
|
||||
Random random = new Random();
|
||||
|
||||
BigDecimal maxNumber = prizes.stream()
|
||||
.map(DiscSpinning::getNumber)
|
||||
.max(BigDecimal::compareTo)
|
||||
.orElse(null);
|
||||
BigDecimal randomNum = new BigDecimal(ThreadLocalRandom.current().nextDouble(0.01, maxNumber.doubleValue()));
|
||||
|
||||
.orElse(BigDecimal.ZERO);
|
||||
if (maxNumber.equals(BigDecimal.ZERO)) {
|
||||
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), sourceId, userId, result.getUrl(), result.getType(),
|
||||
result.getNumber(), DateUtils.formatYMD(new Date()), DateUtils.format(new Date()), source);
|
||||
recordService.save(record);
|
||||
return record;
|
||||
}
|
||||
Random random = new Random();
|
||||
BigDecimal randomNum = new BigDecimal(random.nextInt(maxNumber.intValue()));
|
||||
List<DiscSpinningAmount> amounts = new ArrayList<>();
|
||||
Map<String, List<DiscSpinningAmount>> amountMaps = redisUtils.getMapData(RedisKeys.getDateKey("spinning:amount"), "setDiscSpinningAmounts", DiscSpinningAmount.class);
|
||||
for (int i = drawCount; i >= 0; i--) {
|
||||
if (amountMaps.containsKey(i + "")) {
|
||||
amounts = amountMaps.get(i + "");
|
||||
break;
|
||||
Map<String, List<DiscSpinningAmount>> amountMaps = redisUtils.getMapData(RedisKeys.getDateKey("spinning:amount:") + source, "setDiscSpinningAmounts", DiscSpinningAmount.class);
|
||||
if (CollectionUtil.isNotEmpty(amountMaps)) {
|
||||
for (int i = drawCount; i >= 0; i--) {
|
||||
if (amountMaps.containsKey(i + "")) {
|
||||
amounts = amountMaps.get(i + "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (DiscSpinning prize : prizes) {
|
||||
|
|
@ -134,11 +134,11 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
int maxAmount = Integer.parseInt(commonRepository.findOne(900).getValue());
|
||||
double resultAmount = 0;
|
||||
if (prize.getType() == 2) {
|
||||
double baseRandom = random.nextDouble();
|
||||
double baseRandom = RandomUtil.randomDouble(0.01, 1);
|
||||
double baseAmount = 0;
|
||||
for (DiscSpinningAmount amount : amounts) {
|
||||
if (baseRandom < amount.getRandom()) {
|
||||
resultAmount = baseAmount + random.nextDouble() * (amount.getMaxAmount() - baseAmount);
|
||||
resultAmount = baseAmount + RandomUtil.randomDouble(0.01, 1) * (amount.getMaxAmount() - baseAmount);
|
||||
break;
|
||||
}
|
||||
baseAmount = amount.getMaxAmount();
|
||||
|
|
@ -158,6 +158,7 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
if (source != 1) {
|
||||
result = prize;
|
||||
result.setNumber(BigDecimal.ONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -182,5 +183,12 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
receiveAsync(record);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static BigDecimal getSmallDouble(int maxValue) {
|
||||
Random random = new Random();
|
||||
int value = random.nextInt(maxValue) * random.nextInt(maxValue);
|
||||
return new BigDecimal(value / 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,9 +43,13 @@ public class RedisServiceImpl implements RedisService {
|
|||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
|
||||
//spinning:amount:3
|
||||
@Override
|
||||
public void setDiscSpinningAmounts(String key) {
|
||||
List<DiscSpinningAmount> amounts = amountService.list(new QueryWrapper<DiscSpinningAmount>().eq("status", 1).orderByAsc("max_amount"));
|
||||
List<DiscSpinningAmount> amounts = amountService.list(new QueryWrapper<DiscSpinningAmount>()
|
||||
.eq("status", 1)
|
||||
.eq("type",key.split(":")[3])
|
||||
.orderByAsc("max_amount"));
|
||||
Map<Integer, List<DiscSpinningAmount>> map =
|
||||
amounts.stream().collect(Collectors.groupingBy(
|
||||
disc -> disc.getNum() == null ? 0 : disc.getNum()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.sqx.modules.taskCenter.entity;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -18,6 +20,7 @@ import lombok.Data;
|
|||
@ApiModel(value = "任务中心 实体类")
|
||||
public class TaskCenter extends Model<TaskCenter> {
|
||||
@ApiModelProperty("id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
@ApiModelProperty("标题")
|
||||
private String title;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -20,17 +22,22 @@ import lombok.Data;
|
|||
public class TaskCenterRecord extends Model<TaskCenterRecord> {
|
||||
@TableId(type = IdType.ID_WORKER)
|
||||
@ApiModelProperty(value = "id",hidden = true)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "用户id",hidden = true)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
@ApiModelProperty("任务Id 周任务转盘奖励时 该值为 user_sign_record的id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long taskId;
|
||||
@ApiModelProperty("来源Id 周任务(签到的Id) 实物(物品Id)")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long sourceId;
|
||||
@ApiModelProperty("奖励名称")
|
||||
private String name;
|
||||
@ApiModelProperty("奖励类型 1 金币 2 现金 3 虚拟物品 4 5 9转盘")
|
||||
private Integer type;
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long targetId;
|
||||
@ApiModelProperty("数量")
|
||||
private Integer number;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.sqx.modules.taskCenter.entity;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -18,8 +20,10 @@ import lombok.Data;
|
|||
@ApiModel(value = "任务奖励 实体类")
|
||||
public class TaskCenterReward extends Model<TaskCenterReward> {
|
||||
@ApiModelProperty("id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
@ApiModelProperty("任务Id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long taskId;
|
||||
@ApiModelProperty("图片")
|
||||
private String img;
|
||||
|
|
@ -28,6 +32,7 @@ public class TaskCenterReward extends Model<TaskCenterReward> {
|
|||
@ApiModelProperty("奖励类型 1 金币 2 现金红包 3 4 5 9 大转盘抽奖次数")
|
||||
private Integer type;
|
||||
@TableField(exist = false)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long targetId;
|
||||
@ApiModelProperty("数量")
|
||||
private Integer number;
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||
if (CollectionUtil.isEmpty(rewardMap)) {
|
||||
continue;
|
||||
}
|
||||
Map<Integer, Integer> taskWRedisMap = new HashMap<>();
|
||||
Map<Long, Integer> taskWRedisMap = new HashMap<>();
|
||||
if ("2".equals(type)) {
|
||||
//抽奖次数
|
||||
Map<Long, Integer> taskWCount = signRecordService.getTaskWCount(userId, rewardMap.get(9));
|
||||
|
|
@ -358,12 +358,12 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||
Integer value = entry.getValue();
|
||||
if (value > 0) {
|
||||
countTaskDisc = countTaskDisc + value;
|
||||
taskWRedisMap.put(key.intValue(), value);
|
||||
taskWRedisMap.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(taskWRedisMap)) {
|
||||
redisUtils.set(RedisKeys.getDateKey("spinning:amount:taskW") + userId, taskWRedisMap, DateUtils.todayAfterSecond());
|
||||
redisUtils.set(RedisKeys.getDateKey("spinning:draw:taskW") + userId, taskWRedisMap, DateUtils.todayAfterSecond());
|
||||
}
|
||||
} else if ("3".equals(type)) {
|
||||
if (signCount == null) {
|
||||
|
|
@ -374,12 +374,12 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||
Integer spinningCount = discSpinningRecordService.countSourceRecord(taskCenter.getId());
|
||||
countTaskDisc = rewardMap.get(9) + (spinningCount == null ? 0 : spinningCount);
|
||||
if (countTaskDisc > 0) {
|
||||
taskWRedisMap.put(taskCenter.getId().intValue(), countTaskDisc);
|
||||
taskWRedisMap.put(taskCenter.getId(), countTaskDisc);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(taskWRedisMap)) {
|
||||
redisUtils.set(RedisKeys.getDateKey("spinning:amount:taskM") + userId, taskWRedisMap, DateUtils.todayAfterSecond());
|
||||
redisUtils.set(RedisKeys.getDateKey("spinning:draw:taskM") + userId, taskWRedisMap, DateUtils.todayAfterSecond());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -22,8 +24,10 @@ import java.util.Date;
|
|||
public class UserSignRecord extends Model<UserSignRecord> {
|
||||
@TableId(type = IdType.ID_WORKER)
|
||||
@ApiModelProperty("id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
@ApiModelProperty("用户id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
@ApiModelProperty("累计签到")
|
||||
private Integer day;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package com.sqx.modules.userinfo.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserInfo;
|
||||
import com.sqx.modules.app.service.UserInfoService;
|
||||
import com.sqx.modules.userinfo.dao.UserInfoDAO;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/userInfo")
|
||||
public class UserInfoController {
|
||||
|
||||
private final UserInfoService userInfoService;
|
||||
|
||||
public UserInfoController(UserInfoService userInfoService) {
|
||||
this.userInfoService = userInfoService;
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result getList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) String phone, @RequestParam(required = false) String name) {
|
||||
|
||||
return Result.success().put("data", userInfoService.getList(page, size, phone, name));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping
|
||||
public Result update(@RequestBody @Validated UserInfoDAO userInfoDAO) {
|
||||
UserInfo info = new UserInfo();
|
||||
BeanUtil.copyProperties(userInfoDAO, info);
|
||||
info.setUpdateTime(DateUtil.date());
|
||||
return Result.success().put("data", userInfoService.update(info, new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getUserId, userInfoDAO.getUserId())));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public Result delete(@RequestBody @Validated UserInfoDAO userInfoDAO) {
|
||||
return Result.success().put("data", userInfoService.remove(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getUserId, userInfoDAO.getUserId())));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.sqx.modules.userinfo.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class UserInfoDAO {
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@NotNull
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String certName;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
private String certNo;
|
||||
|
||||
/**
|
||||
* 银行账号
|
||||
*/
|
||||
private String accountNo;
|
||||
|
||||
/**
|
||||
* 银行预留手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 银行预留手机号
|
||||
*/
|
||||
private String bankName;
|
||||
}
|
||||
Loading…
Reference in New Issue