抽奖值
This commit is contained in:
@@ -267,10 +267,25 @@ public class DiscSpinningController {
|
|||||||
cashOutService.saveBody(cashOut);
|
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
|
@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>().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();
|
Random random = new Random();
|
||||||
double randomDouble;
|
double randomDouble;
|
||||||
do {
|
do {
|
||||||
@@ -289,11 +304,12 @@ public class DiscSpinningController {
|
|||||||
for (DiscSpinningAmount amount : amounts) {
|
for (DiscSpinningAmount amount : amounts) {
|
||||||
if (baseRandom < amount.getRandom()) {
|
if (baseRandom < amount.getRandom()) {
|
||||||
resultAmount = baseAmount + random.nextDouble() * (amount.getMaxAmount() - baseAmount);
|
resultAmount = baseAmount + random.nextDouble() * (amount.getMaxAmount() - baseAmount);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
baseAmount = amount.getMaxAmount();
|
baseAmount = amount.getMaxAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultAmount == 0) {
|
if (resultAmount < 0.01) {
|
||||||
resultAmount = 0.01;
|
resultAmount = 0.01;
|
||||||
}
|
}
|
||||||
resultAmount = orderAmount + resultAmount;
|
resultAmount = orderAmount + resultAmount;
|
||||||
@@ -311,7 +327,8 @@ public class DiscSpinningController {
|
|||||||
}
|
}
|
||||||
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), orderId, userId, result.getType(),
|
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), orderId, 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);
|
||||||
|
System.out.println(record);
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user