新增自动化测试砍价逻辑和控制大转盘玩法
This commit is contained in:
parent
25e02c2dd1
commit
ed5e357dff
@ -182,8 +182,10 @@ public class RollDiceUtils {
|
||||
int point = (Integer) config.get("doubleValue");
|
||||
distribution.put(point, 0);
|
||||
}
|
||||
BigDecimal salePrice = new BigDecimal("47");
|
||||
int accNum=100;
|
||||
BigDecimal limitPrice=new BigDecimal("9.9");
|
||||
BigDecimal salePrice = new BigDecimal("47").subtract(limitPrice).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
int accNum=rollCount;
|
||||
// 摇骰子多次并统计
|
||||
for (int i = 0; i < rollCount; i++) {
|
||||
List<Integer> arr= randMoney(salePrice, accNum);
|
||||
@ -196,7 +198,7 @@ public class RollDiceUtils {
|
||||
distribution.put(result, distribution.get(result) + 1);
|
||||
accNum--;
|
||||
}
|
||||
|
||||
System.out.println("最终金额:"+limitPrice);
|
||||
return distribution;
|
||||
}
|
||||
|
||||
@ -239,12 +241,12 @@ public class RollDiceUtils {
|
||||
List<Map<String, Object>> configs = new ArrayList<>();
|
||||
|
||||
// 添加配置项
|
||||
configs.add(createDiceConfig(1, 45));
|
||||
configs.add(createDiceConfig(2, 45));
|
||||
configs.add(createDiceConfig(3, 3));
|
||||
configs.add(createDiceConfig(4, 2));
|
||||
configs.add(createDiceConfig(5, 3));
|
||||
configs.add(createDiceConfig(6, 2));
|
||||
configs.add(createDiceConfig(1, 40));
|
||||
configs.add(createDiceConfig(2, 40));
|
||||
configs.add(createDiceConfig(3, 5));
|
||||
configs.add(createDiceConfig(4, 5));
|
||||
configs.add(createDiceConfig(5, 5));
|
||||
configs.add(createDiceConfig(6, 5));
|
||||
|
||||
// 创建骰子游戏实例
|
||||
DiceGame diceGame = new DiceGame(configs);
|
||||
@ -261,7 +263,7 @@ public class RollDiceUtils {
|
||||
|
||||
// 测试概率分布
|
||||
System.out.println("\n=== 概率分布测试(100次) ===");
|
||||
int testCount = 100;
|
||||
int testCount = 18;
|
||||
Map<Integer, Integer> distribution = diceGame.testDistribution(testCount);
|
||||
|
||||
System.out.println("点数\t出现次数\t实际概率\t预期概率");
|
||||
|
||||
@ -958,6 +958,13 @@ public class ShopActivityCutpriceServiceImpl extends BaseServiceImpl<ShopActivit
|
||||
return CommonResult.failed(I18nUtil._("抱歉,砍价活动已失效啦!"));
|
||||
}
|
||||
|
||||
String str_activity_rule = activityBase.getActivity_rule();
|
||||
com.alibaba.fastjson.JSONObject activity_rule = com.alibaba.fastjson.JSONObject.parseObject(str_activity_rule);
|
||||
Integer cut_down_type = activity_rule.getObject("cut_down_type", Integer.class);
|
||||
if(cut_down_type == 1) {
|
||||
return CommonResult.failed(I18nUtil._("固定金额砍价无法进行大转盘活动"));
|
||||
}
|
||||
|
||||
// 检查活动状态是否正常
|
||||
if (!ObjectUtil.equal(activityBase.getActivity_state(), StateCode.ACTIVITY_STATE_NORMAL)) {
|
||||
if (ObjectUtil.equal(activityBase.getActivity_state(), StateCode.ACTIVITY_STATE_FINISHED)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user