菜单按钮权限设置-后台可以设置新增的按钮权限
This commit is contained in:
@@ -86,10 +86,13 @@ class PlayStartLogic
|
||||
$playerProfitTotal = $playerWinSum - 100.0 * $playerPlayCount;
|
||||
$safetyLine = (int) ($configType0->safety_line ?? 0);
|
||||
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
|
||||
// 玩家累计盈利>=安全线时杀分:无论付费/免费,都用 type=1 的 T*_weight;未达到时一律按玩家权重
|
||||
// 记录 lottery_config_id:杀分记 type=1;未杀分统一记当前池 type=0
|
||||
$usePoolWeights = $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null;
|
||||
$config = $usePoolWeights ? $configType1 : $configType0;
|
||||
// 盈利>=安全线且开启杀分:付费/免费都用 killScore;盈利<安全线:付费用玩家权重,免费用 killScore(无则用 default)
|
||||
// 记录 lottery_config_id:用池权重时记对应池,付费用玩家权重时记 default
|
||||
$usePoolWeights = ($ticketType === self::LOTTERY_TYPE_PAID && $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null)
|
||||
|| ($ticketType === self::LOTTERY_TYPE_FREE);
|
||||
$config = $usePoolWeights
|
||||
? (($ticketType === self::LOTTERY_TYPE_FREE && $configType1 === null) ? $configType0 : $configType1)
|
||||
: $configType0;
|
||||
|
||||
// 按档位 T1-T5 抽取后,从 DiceReward 表按当前方向取该档位数据,再按 weight 抽取一条得到 grid_number
|
||||
$rewardInstance = DiceReward::getCachedInstance();
|
||||
|
||||
@@ -140,7 +140,7 @@ class DicePlayRecordTestController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家抽奖记录(测试数据)删除', 'dice:play_record_test:index:destroy')]
|
||||
#[Permission('玩家抽奖记录(测试数据)删除', 'dice:play_record_test:index:clearAll')]
|
||||
public function clearAll(Request $request): Response
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -124,7 +124,7 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家钱包流水添加', 'dice:player_wallet_record:index:save')]
|
||||
#[Permission('玩家钱包流水添加', 'dice:player_wallet_record:index:adminOperate')]
|
||||
public function adminOperate(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
@@ -182,24 +182,6 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家钱包流水添加', 'dice:player_wallet_record:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('add success');
|
||||
} else {
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param Request $request
|
||||
@@ -217,25 +199,4 @@ class DicePlayerWalletRecordController extends BaseController
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家钱包流水删除', 'dice:player_wallet_record:index:destroy')]
|
||||
public function destroy(Request $request): Response
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('delete success');
|
||||
} else {
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class DiceRewardController extends BaseController
|
||||
* 参数:lottery_config_id 可选,不选则传 paid_tier_weights / free_tier_weights 自定义档位;
|
||||
* paid_s_count, paid_n_count, free_s_count, free_n_count;或兼容旧版 s_count, n_count
|
||||
*/
|
||||
#[Permission('奖励对照列表', 'dice:reward:index:index')]
|
||||
#[Permission('一键测试权重', 'dice:reward:index:startWeightTest')]
|
||||
public function startWeightTest(Request $request): Response
|
||||
{
|
||||
$post = is_array($request->post()) ? $request->post() : [];
|
||||
@@ -157,7 +157,7 @@ class DiceRewardController extends BaseController
|
||||
* 权重编辑弹窗:按方向+点数批量更新权重(写入 dice_reward)
|
||||
* 参数:items: [{ grid_number, weight_clockwise, weight_counterclockwise }, ...]
|
||||
*/
|
||||
#[Permission('奖励对照修改', 'dice:reward:index:update')]
|
||||
#[Permission('权重配比', 'dice:reward:index:batchUpdateWeights')]
|
||||
public function batchUpdateWeights(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
|
||||
@@ -109,7 +109,7 @@ class DiceRewardConfigController extends BaseController
|
||||
* @param Request $request items: [{ id, grid_number?, ui_text?, real_ev?, tier?, remark? }, ...]
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置修改', 'dice:reward_config:index:update')]
|
||||
#[Permission('修改奖励索引', 'dice:reward_config:index:batchUpdate')]
|
||||
public function batchUpdate(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
@@ -166,7 +166,7 @@ class DiceRewardConfigController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置修改', 'dice:reward_config:index:update')]
|
||||
#[Permission('修改色子点数权重', 'dice:reward_config:index:batchUpdateWeights')]
|
||||
public function batchUpdateWeights(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
@@ -188,7 +188,7 @@ class DiceRewardConfigController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置修改', 'dice:reward_config:index:update')]
|
||||
#[Permission('大奖权重修改', 'dice:reward_config:index:saveBigwinWeightsByGrid')]
|
||||
public function saveBigwinWeightsByGrid(Request $request): Response
|
||||
{
|
||||
$items = $request->post('items', []);
|
||||
@@ -209,7 +209,7 @@ class DiceRewardConfigController extends BaseController
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置修改', 'dice:reward_config:index:update')]
|
||||
#[Permission('创建奖励对照', 'dice:reward_config:index:createRewardReference')]
|
||||
public function createRewardReference(Request $request): Response
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -144,7 +144,7 @@ class DiceRewardConfigRecordController extends BaseController
|
||||
* 导入:测试记录 → DiceReward、DiceRewardConfig(BIGWIN)、DiceLotteryPoolConfig(付费/免费 T1-T5)
|
||||
* @param Request $request record_id, paid_lottery_config_id(可选), free_lottery_config_id(可选), lottery_config_id(兼容旧版)
|
||||
*/
|
||||
#[Permission('奖励配置权重测试记录列表', 'dice:reward_config_record:index:index')]
|
||||
#[Permission('导入权重配置', 'dice:reward_config_record:index:importFromRecord')]
|
||||
public function importFromRecord(Request $request): Response
|
||||
{
|
||||
$recordId = (int) $request->post('record_id', 0);
|
||||
|
||||
@@ -14,6 +14,7 @@ use support\think\Db;
|
||||
|
||||
/**
|
||||
* 一键测试权重:单进程后台执行模拟摇色子,写入 dice_play_record_test 并更新 dice_reward_config_record 进度
|
||||
* 抽奖逻辑与 PlayStartLogic 一致:使用 name=default 的安全线、杀分开关;盈利<安全线时付费用玩家权重、免费用 killScore;盈利>=安全线且杀分开启时付费/免费均用 killScore
|
||||
*/
|
||||
class WeightTestRunner
|
||||
{
|
||||
@@ -21,7 +22,7 @@ class WeightTestRunner
|
||||
|
||||
/**
|
||||
* 执行指定测试记录:按付费/免费、顺/逆方向交替模拟(付费顺→付费逆→免费顺→免费逆),每 10 条写入一次测试表并更新进度
|
||||
* 支持:1)lottery_config_id 有值时用奖池配置档位权重;2)无值时用记录中的 paid_tier_weights / free_tier_weights
|
||||
* 使用与 playStart 相同的彩金池逻辑:name=default 的安全线/kill_enabled;付费用 paid_tier_weights(玩家权重)或 killScore;免费用 killScore
|
||||
* @param int $recordId dice_reward_config_record.id
|
||||
*/
|
||||
public function run(int $recordId): void
|
||||
@@ -50,48 +51,37 @@ class WeightTestRunner
|
||||
$total = $paidS + $paidN + $freeS + $freeN;
|
||||
}
|
||||
|
||||
$paidConfigId = (int) ($record->paid_lottery_config_id ?? 0);
|
||||
$freeConfigId = (int) ($record->free_lottery_config_id ?? 0);
|
||||
if ($paidConfigId <= 0) {
|
||||
$paidConfigId = (int) ($record->lottery_config_id ?? 0);
|
||||
}
|
||||
if ($freeConfigId <= 0) {
|
||||
$freeConfigId = (int) ($record->lottery_config_id ?? 0);
|
||||
}
|
||||
$paidConfig = $paidConfigId > 0 ? DiceLotteryPoolConfig::find($paidConfigId) : null;
|
||||
$freeConfig = $freeConfigId > 0 ? DiceLotteryPoolConfig::find($freeConfigId) : null;
|
||||
if ($paidConfigId > 0 && !$paidConfig) {
|
||||
$this->markFailed($recordId, '付费奖池配置不存在');
|
||||
return;
|
||||
}
|
||||
if ($freeConfigId > 0 && !$freeConfig) {
|
||||
$this->markFailed($recordId, '免费奖池配置不存在');
|
||||
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
$configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
|
||||
if (!$configType0) {
|
||||
$this->markFailed($recordId, '彩金池配置 name=default 不存在');
|
||||
return;
|
||||
}
|
||||
$safetyLine = (int) ($configType0->safety_line ?? 0);
|
||||
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
|
||||
|
||||
$paidTierWeights = (is_array($record->paid_tier_weights ?? null) && $record->paid_tier_weights !== [])
|
||||
? $record->paid_tier_weights
|
||||
: null;
|
||||
$freeTierWeights = (is_array($record->free_tier_weights ?? null) && $record->free_tier_weights !== [])
|
||||
? $record->free_tier_weights
|
||||
: null;
|
||||
if ($paidConfig === null && $paidTierWeights === null) {
|
||||
$this->markFailed($recordId, '付费未选奖池时需提供 paid_tier_weights');
|
||||
return;
|
||||
}
|
||||
if ($freeConfig === null && $freeTierWeights === null) {
|
||||
$this->markFailed($recordId, '免费未选奖池时需提供 free_tier_weights');
|
||||
: [
|
||||
'T1' => (int) ($configType0->t1_weight ?? 0),
|
||||
'T2' => (int) ($configType0->t2_weight ?? 0),
|
||||
'T3' => (int) ($configType0->t3_weight ?? 0),
|
||||
'T4' => (int) ($configType0->t4_weight ?? 0),
|
||||
'T5' => (int) ($configType0->t5_weight ?? 0),
|
||||
];
|
||||
if (array_sum($paidTierWeights) <= 0) {
|
||||
$this->markFailed($recordId, '需提供 paid_tier_weights(玩家权重,盈利未达安全线时付费抽奖使用)或选择 default 奖池');
|
||||
return;
|
||||
}
|
||||
|
||||
$freeConfig = $configType1 !== null ? $configType1 : $configType0;
|
||||
|
||||
// 每次测试开始前清空进程内静态缓存,强制从共享缓存读取最新 BIGWIN/奖励配置,与数据库一致
|
||||
DiceRewardConfig::clearRequestInstance();
|
||||
DiceReward::clearRequestInstance();
|
||||
|
||||
// 测试时按“单个虚拟玩家”累计中奖金额来判断是否触发杀分:达到 safety_line 前用自定义档位(玩家权重),达到后用奖池权重
|
||||
$paidSafetyLine = $paidConfig !== null ? (int) ($paidConfig->safety_line ?? 0) : 0;
|
||||
$freeSafetyLine = $freeConfig !== null ? (int) ($freeConfig->safety_line ?? 0) : 0;
|
||||
$paidPlayerWinTotal = 0.0;
|
||||
$freePlayerWinTotal = 0.0;
|
||||
//“玩家”盈利: 玩家累计盈利:仅统计 lottery_config_id=default 的成功对局(win_coin - 100),与 PlayStartLogic 一致
|
||||
$playerProfitTotal = 0.0;
|
||||
|
||||
$playLogic = new PlayStartLogic();
|
||||
$resultCounts = [];
|
||||
@@ -101,40 +91,36 @@ class WeightTestRunner
|
||||
|
||||
try {
|
||||
for ($i = 0; $i < $paidS; $i++) {
|
||||
$usePoolWeights = $paidConfig !== null && $paidPlayerWinTotal >= $paidSafetyLine && $paidSafetyLine > 0;
|
||||
$usePoolWeights = $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null;
|
||||
$paidConfig = $usePoolWeights ? $configType1 : $configType0;
|
||||
$customWeights = $usePoolWeights ? null : $paidTierWeights;
|
||||
$row = $playLogic->simulateOnePlay($paidConfig, 0, 0, $customWeights);
|
||||
$this->accumulatePlayerWin($row, $paidPlayerWinTotal);
|
||||
$this->accumulateProfitForDefault($row, 0, $paidConfig, $configType0, $playerProfitTotal);
|
||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||
$done++;
|
||||
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
|
||||
}
|
||||
for ($i = 0; $i < $paidN; $i++) {
|
||||
$usePoolWeights = $paidConfig !== null && $paidPlayerWinTotal >= $paidSafetyLine && $paidSafetyLine > 0;
|
||||
$usePoolWeights = $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null;
|
||||
$paidConfig = $usePoolWeights ? $configType1 : $configType0;
|
||||
$customWeights = $usePoolWeights ? null : $paidTierWeights;
|
||||
$row = $playLogic->simulateOnePlay($paidConfig, 1, 0, $customWeights);
|
||||
$this->accumulatePlayerWin($row, $paidPlayerWinTotal);
|
||||
$this->accumulateProfitForDefault($row, 0, $paidConfig, $configType0, $playerProfitTotal);
|
||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||
$done++;
|
||||
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
|
||||
}
|
||||
for ($i = 0; $i < $freeS; $i++) {
|
||||
$usePoolWeights = $freeConfig !== null && $freePlayerWinTotal >= $freeSafetyLine && $freeSafetyLine > 0;
|
||||
$customWeights = $usePoolWeights ? null : $freeTierWeights;
|
||||
$row = $playLogic->simulateOnePlay($freeConfig, 0, 1, $customWeights);
|
||||
$this->accumulatePlayerWin($row, $freePlayerWinTotal);
|
||||
$row = $playLogic->simulateOnePlay($freeConfig, 0, 1, null);
|
||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||
$done++;
|
||||
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
|
||||
}
|
||||
for ($i = 0; $i < $freeN; $i++) {
|
||||
$usePoolWeights = $freeConfig !== null && $freePlayerWinTotal >= $freeSafetyLine && $freeSafetyLine > 0;
|
||||
$customWeights = $usePoolWeights ? null : $freeTierWeights;
|
||||
$row = $playLogic->simulateOnePlay($freeConfig, 1, 1, $customWeights);
|
||||
$this->accumulatePlayerWin($row, $freePlayerWinTotal);
|
||||
$row = $playLogic->simulateOnePlay($freeConfig, 1, 1, null);
|
||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||
$done++;
|
||||
@@ -152,13 +138,19 @@ class WeightTestRunner
|
||||
}
|
||||
}
|
||||
|
||||
/** 累加单个虚拟玩家在测试过程中的中奖金额(win_coin) */
|
||||
private function accumulatePlayerWin(array $row, float &$runningWinTotal): void
|
||||
/**
|
||||
* 仅当付费抽奖且使用 default 池时累加玩家盈利(win_coin - 100),与 PlayStartLogic 一致
|
||||
* @param object $usedConfig 本次使用的奖池配置
|
||||
* @param object $configType0 name=default 的彩金池
|
||||
*/
|
||||
private function accumulateProfitForDefault(array $row, int $lotteryType, $usedConfig, $configType0, float &$playerProfitTotal): void
|
||||
{
|
||||
if (!isset($row['win_coin'])) {
|
||||
if ($lotteryType !== 0 || $usedConfig === null || $configType0 === null || !isset($row['win_coin'])) {
|
||||
return;
|
||||
}
|
||||
$runningWinTotal += (float) $row['win_coin'];
|
||||
if ((int) $usedConfig->id === (int) $configType0->id) {
|
||||
$playerProfitTotal += (float) $row['win_coin'] - 100.0;
|
||||
}
|
||||
}
|
||||
|
||||
private function aggregate(array $row, array &$resultCounts, array &$tierCounts): void
|
||||
|
||||
Reference in New Issue
Block a user