提交 17fb0f36 authored 作者: 吕本才's avatar 吕本才

fix(lottery): 修正抽奖奖品配置和中奖概率逻辑

1. 调整奖品列表顺序并补充注释说明下标对应关系 2. 更新中奖概率配置:一等奖10%、二等奖20%、三等奖40%、谢谢参与30% 3. 修正概率判断分支逻辑匹配新的奖品配置
上级 6724e4f0
...@@ -3,7 +3,6 @@ package com.wangxiaolu.promotion; ...@@ -3,7 +3,6 @@ package com.wangxiaolu.promotion;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
......
...@@ -63,14 +63,16 @@ public class LotteryCoreDaoImpl implements LotteryCoreDao { ...@@ -63,14 +63,16 @@ public class LotteryCoreDaoImpl implements LotteryCoreDao {
LotteryRecordDto result = BeanUtils.transitionDto(record, LotteryRecordDto.class); LotteryRecordDto result = BeanUtils.transitionDto(record, LotteryRecordDto.class);
ArrayList<String> prizeList = new ArrayList<>(); ArrayList<String> prizeList = new ArrayList<>();
prizeList.add("三等奖"); // 下标和抽奖返回的数值有关系,0:一等奖, 1:二等奖, 2:三等奖, -1:未中奖
prizeList.add("一等奖"); prizeList.add("一等奖");
prizeList.add("二等奖"); prizeList.add("二等奖");
prizeList.add("三等奖"); prizeList.add("三等奖");
prizeList.add("二等奖"); prizeList.add("谢谢参与");
prizeList.add("三等奖"); prizeList.add("三等奖");
prizeList.add("二等奖"); prizeList.add("二等奖");
prizeList.add("三等奖"); prizeList.add("三等奖");
prizeList.add("谢谢参与");
result.setPrizes(prizeList); result.setPrizes(prizeList);
return result; return result;
...@@ -135,12 +137,15 @@ public class LotteryCoreDaoImpl implements LotteryCoreDao { ...@@ -135,12 +137,15 @@ public class LotteryCoreDaoImpl implements LotteryCoreDao {
/** /**
* 简单动态概率 * 简单动态概率
* 一等奖:10%,二等奖:20%,三等奖:40%,谢谢参与:30%
*/ */
private int simpleDynamicPrize() { private int simpleDynamicPrize() {
int r = new Random().nextInt(100); int r = new Random().nextInt(100);
if (r < 10) { if (r < 10) {
return 1; return 0;
} else if (r < 30) { } else if (r < 30) {
return 1;
} else if (r < 70) {
return 2; return 2;
} else { } else {
return 3; return 3;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论