抽奖 金额
This commit is contained in:
parent
6771ad1d25
commit
7c1685f993
|
|
@ -3,13 +3,11 @@ package com.sqx.modules.discSpinning.controller;
|
|||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.util.concurrent.RateLimiter;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
|
|
@ -39,11 +37,8 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
|
@ -282,29 +277,38 @@ public class DiscSpinningController {
|
|||
double baseRandom = random.nextDouble();
|
||||
if (baseRandom < 0.8) {
|
||||
// 0.8到0.82范围内概率最大(这里示例以当前订单金额为基础,模拟类似0.8的情况)
|
||||
resultAmount = orderAmount + (random.nextDouble() * 0.02);
|
||||
resultAmount = random.nextDouble() * 0.02;
|
||||
} else if (baseRandom < 0.9) {
|
||||
// 0.82 - 0.85范围概率小一些
|
||||
resultAmount = orderAmount + (0.02 + (random.nextDouble() * 0.03));
|
||||
resultAmount = 0.02 + (random.nextDouble() * 0.03);
|
||||
} else if (baseRandom < 0.95) {
|
||||
// 0.85 - 0.9概率更小
|
||||
resultAmount = orderAmount + (0.05 + (random.nextDouble() * 0.05));
|
||||
} else if (baseRandom < 0.99) {
|
||||
resultAmount = 0.05 + (random.nextDouble() * 0.05);
|
||||
} else if (baseRandom < 0.97) {
|
||||
// 0.9 - 1概率更小
|
||||
resultAmount = orderAmount + (0.1 + (random.nextDouble() * 0.1));
|
||||
} else {
|
||||
// 1 - 20概率依次递减
|
||||
// 控制最大金额为80
|
||||
resultAmount = 1 + (random.nextDouble() * (maxAmount - 1));
|
||||
resultAmount = 0.1 + (random.nextDouble() * 0.1);
|
||||
} else if (baseRandom < 0.99) {
|
||||
//1 - 1.3 概率更小
|
||||
resultAmount = 0.2 + (random.nextDouble() * 0.3);
|
||||
}
|
||||
// else {
|
||||
// // 1.3 - 控制最大金额为80
|
||||
// resultAmount = 1 + (random.nextDouble() * (maxAmount - 1));
|
||||
// }
|
||||
if (resultAmount == 0) {
|
||||
resultAmount = 0.01;
|
||||
}
|
||||
resultAmount = orderAmount + resultAmount;
|
||||
if (resultAmount > maxAmount) {
|
||||
resultAmount = maxAmount;
|
||||
}
|
||||
}
|
||||
if (resultAmount > maxAmount) {
|
||||
resultAmount = maxAmount;
|
||||
}
|
||||
result = new DiscSpinning(prize.getName(), 2, new BigDecimal(resultAmount).setScale(2, RoundingMode.HALF_UP));
|
||||
} else {
|
||||
result = prize;
|
||||
break;
|
||||
}
|
||||
// else {
|
||||
// result = prize;
|
||||
// }
|
||||
}
|
||||
}
|
||||
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), orderId, userId, result.getType(),
|
||||
|
|
|
|||
|
|
@ -2,14 +2,13 @@ package com.sqx.modules.taskCenter.controller;
|
|||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.taskCenter.entity.TaskCenter;
|
||||
import com.sqx.modules.taskCenter.service.TaskCenterService;
|
||||
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.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
|
|
@ -19,8 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(value = "任务中心", tags = {"任务中心"})
|
||||
|
|
@ -64,7 +61,7 @@ public class TaskCenterController {
|
|||
@GetMapping("/taskCenter/selectTaskCenter")
|
||||
@ApiOperation("查询任务中心")
|
||||
public Result selectTaskCenter(Integer page, Integer limit) {
|
||||
return Result.success().put("data", taskCenterService.page(new Page<>(page, limit), new QueryWrapper<TaskCenter>().orderByDesc("id")));
|
||||
return Result.success().put("data", taskCenterService.page(new Page<>(page, limit), new QueryWrapper<TaskCenter>().orderByAsc("sort","type")));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||
@Override
|
||||
public Result queryTaskCenter(Integer page, Integer limit, Long userId) {
|
||||
//任务
|
||||
IPage<TaskCenter> taskPage = baseMapper.selectPage(new Page<>(page, limit), new QueryWrapper<TaskCenter>().eq("shows", 1).orderByDesc("sort"));
|
||||
IPage<TaskCenter> taskPage = baseMapper.selectPage(new Page<>(page, limit), new QueryWrapper<TaskCenter>().eq("shows", 1).orderByAsc("sort","type"));
|
||||
boolean todaySign = true;
|
||||
//月 签到记录
|
||||
QueryWrapper<UserSignRecord> signWrapper = new QueryWrapper<>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue