抽奖值
This commit is contained in:
@@ -267,10 +267,25 @@ public class DiscSpinningController {
|
||||
cashOutService.saveBody(cashOut);
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/app/discSpinning/draw1")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "source", value = "`task`任务拉起抽奖 或者 `order` 订单拉起抽奖", dataTypeClass = String.class, paramType = "body"),
|
||||
})
|
||||
@ApiOperation("抽取大转盘")
|
||||
public Result draw() {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
DiscSpinningRecord task = draws(0, null, null, "task");
|
||||
System.out.println(task.getNumber());
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public DiscSpinningRecord draws(double orderAmount, Long orderId, Long userId, String source) {
|
||||
DiscSpinning result = new DiscSpinning("谢谢惠顾", 1, null);
|
||||
List<DiscSpinning> prizes = discSpinningService.list(new QueryWrapper<DiscSpinning>().eq("disc_type", "order".equals(source) ? 1 : 2).orderByAsc("odds"));
|
||||
List<DiscSpinning> prizes = discSpinningService.list(new QueryWrapper<DiscSpinning>().eq("disc_type", 1).orderByAsc("odds"));
|
||||
Random random = new Random();
|
||||
double randomDouble;
|
||||
do {
|
||||
@@ -289,11 +304,12 @@ public class DiscSpinningController {
|
||||
for (DiscSpinningAmount amount : amounts) {
|
||||
if (baseRandom < amount.getRandom()) {
|
||||
resultAmount = baseAmount + random.nextDouble() * (amount.getMaxAmount() - baseAmount);
|
||||
break;
|
||||
}
|
||||
baseAmount = amount.getMaxAmount();
|
||||
}
|
||||
|
||||
if (resultAmount == 0) {
|
||||
if (resultAmount < 0.01) {
|
||||
resultAmount = 0.01;
|
||||
}
|
||||
resultAmount = orderAmount + resultAmount;
|
||||
@@ -311,7 +327,8 @@ public class DiscSpinningController {
|
||||
}
|
||||
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), orderId, userId, result.getType(),
|
||||
result.getNumber(), DateUtils.formatYMD(new Date()), DateUtils.format(new Date()), source);
|
||||
recordService.save(record);
|
||||
// recordService.save(record);
|
||||
System.out.println(record);
|
||||
return record;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user