菜单按钮权限设置-后台可以设置新增的按钮权限

This commit is contained in:
2026-03-17 20:30:37 +08:00
parent bdf50e61f5
commit f63616e735
15 changed files with 125 additions and 113 deletions

View File

@@ -59,10 +59,21 @@
</template> </template>
<template #footer> <template #footer>
<el-button @click="handleClose">{{ $t('form.close') }}</el-button> <el-button @click="handleClose">{{ $t('form.close') }}</el-button>
<el-button :loading="resetting" :disabled="!pool" @click="handleResetProfit"> <el-button
v-permission="'dice:lottery_pool_config:index:resetProfitAmount'"
:loading="resetting"
:disabled="!pool"
@click="handleResetProfit"
>
{{ $t('page.form.btnResetProfit') }} {{ $t('page.form.btnResetProfit') }}
</el-button> </el-button>
<el-button type="primary" :loading="saving" :disabled="!pool" @click="handleSubmit"> <el-button
v-permission="'dice:lottery_pool_config:index:updateCurrentPool'"
type="primary"
:loading="saving"
:disabled="!pool"
@click="handleSubmit"
>
{{ $t('page.form.btnSaveSafetyLine') }} {{ $t('page.form.btnSaveSafetyLine') }}
</el-button> </el-button>
</template> </template>

View File

@@ -23,7 +23,7 @@
{{ $t('table.actions.delete') }} {{ $t('table.actions.delete') }}
</ElButton> </ElButton>
<ElButton <ElButton
v-permission="'dice:play_record_test:index:destroy'" v-permission="'dice:play_record_test:index:clearAll'"
type="danger" type="danger"
plain plain
@click="handleClearAll" @click="handleClearAll"

View File

@@ -14,7 +14,7 @@
<template #left> <template #left>
<ElSpace wrap> <ElSpace wrap>
<ElButton <ElButton
v-permission="'dice:reward:index:update'" v-permission="'dice:reward:index:batchUpdateWeights'"
type="primary" type="primary"
@click="weightRatioVisible = true" @click="weightRatioVisible = true"
v-ripple v-ripple
@@ -22,7 +22,7 @@
{{ $t('page.toolbar.weightRatio') }} {{ $t('page.toolbar.weightRatio') }}
</ElButton> </ElButton>
<ElButton <ElButton
v-permission="'dice:reward:index:index'" v-permission="'dice:reward:index:startWeightTest'"
@click="weightTestVisible = true" @click="weightTestVisible = true"
v-ripple v-ripple
> >

View File

@@ -302,7 +302,12 @@
</div> </div>
<template #footer> <template #footer>
<el-button @click="handleClose">取消</el-button> <el-button @click="handleClose">取消</el-button>
<el-button type="primary" :loading="submitting" @click="handleSubmit">提交</el-button> <el-button
v-permission="'dice:reward:index:batchUpdateWeights'"
type="primary"
:loading="submitting"
@click="handleSubmit"
>提交</el-button>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>

View File

@@ -7,6 +7,15 @@
destroy-on-close destroy-on-close
@close="onClose" @close="onClose"
> >
<ElAlert
type="info"
:closable="false"
show-icon
class="weight-test-tip"
>
<template #title>彩金池逻辑说明</template>
playStart 抽奖逻辑一致使用 name=default 的安全线杀分开关盈利未达安全线时付费抽奖券使用玩家自身权重下方自定义档位免费抽奖券使用 killScore 配置盈利达到安全线且杀分开启时付费/免费均使用 killScore 配置
</ElAlert>
<ElForm ref="formRef" :model="form" label-width="140px"> <ElForm ref="formRef" :model="form" label-width="140px">
<ElSteps :active="currentStep" finish-status="success" simple class="steps-wrap"> <ElSteps :active="currentStep" finish-status="success" simple class="steps-wrap">
<ElStep title="付费抽奖券" /> <ElStep title="付费抽奖券" />
@@ -123,7 +132,12 @@
<ElButton v-if="currentStep < 1" type="primary" :disabled="running" @click="currentStep++" <ElButton v-if="currentStep < 1" type="primary" :disabled="running" @click="currentStep++"
>下一步</ElButton >下一步</ElButton
> >
<ElButton v-if="currentStep === 1" type="primary" :loading="running" @click="handleStart" <ElButton
v-if="currentStep === 1"
v-permission="'dice:reward:index:startWeightTest'"
type="primary"
:loading="running"
@click="handleStart"
>开始测试</ElButton >开始测试</ElButton
> >
<ElButton :disabled="running" @click="visible = false">取消</ElButton> <ElButton :disabled="running" @click="visible = false">取消</ElButton>
@@ -310,6 +324,9 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.weight-test-tip {
margin-bottom: 16px;
}
.steps-wrap { .steps-wrap {
margin-bottom: 16px; margin-bottom: 16px;
} }

View File

@@ -5,7 +5,7 @@
<div class="card-header"> <div class="card-header">
<span>{{ $t('page.toolbar.gameRewardConfig') }}</span> <span>{{ $t('page.toolbar.gameRewardConfig') }}</span>
<ElButton <ElButton
v-permission="'dice:reward_config:index:update'" v-permission="'dice:reward_config:index:createRewardReference'"
type="warning" type="warning"
:loading="createRewardLoading" :loading="createRewardLoading"
@click="handleCreateRewardReference" @click="handleCreateRewardReference"
@@ -91,7 +91,11 @@
</ElTable> </ElTable>
</div> </div>
<div class="tab-footer"> <div class="tab-footer">
<ElButton type="primary" :loading="savingIndex" @click="handleSaveIndex" <ElButton
v-permission="'dice:reward_config:index:batchUpdate'"
type="primary"
:loading="savingIndex"
@click="handleSaveIndex"
>保存</ElButton >保存</ElButton
> >
<ElButton @click="handleResetIndex">重置</ElButton> <ElButton @click="handleResetIndex">重置</ElButton>
@@ -174,7 +178,11 @@
暂无 BIGWIN 档位配置请在奖励索引中设置 tier BIGWIN 暂无 BIGWIN 档位配置请在奖励索引中设置 tier BIGWIN
</div> </div>
<div class="tab-footer"> <div class="tab-footer">
<ElButton type="primary" :loading="savingBigwin" @click="handleSaveBigwin" <ElButton
v-permission="'dice:reward_config:index:saveBigwinWeightsByGrid'"
type="primary"
:loading="savingBigwin"
@click="handleSaveBigwin"
>保存</ElButton >保存</ElButton
> >
<ElButton @click="handleResetBigwin">重置</ElButton> <ElButton @click="handleResetBigwin">重置</ElButton>

View File

@@ -136,7 +136,12 @@
</el-tabs> </el-tabs>
<template #footer> <template #footer>
<el-button @click="handleClose">取消</el-button> <el-button @click="handleClose">取消</el-button>
<el-button type="primary" :loading="submitting" @click="handleSubmit">提交</el-button> <el-button
v-permission="'dice:reward_config:index:batchUpdateWeights'"
type="primary"
:loading="submitting"
@click="handleSubmit"
>提交</el-button>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>

View File

@@ -140,7 +140,12 @@
</div> </div>
<div class="detail-section footer-actions"> <div class="detail-section footer-actions">
<el-button type="primary" :loading="importing" @click="openImport"> <el-button
v-permission="'dice:reward_config_record:index:importFromRecord'"
type="primary"
:loading="importing"
@click="openImport"
>
导入到当前配置 导入到当前配置
</el-button> </el-button>
</div> </div>
@@ -197,7 +202,12 @@
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="importVisible = false">取消</el-button> <el-button @click="importVisible = false">取消</el-button>
<el-button type="primary" :loading="importing" @click="confirmImport">确认导入</el-button> <el-button
v-permission="'dice:reward_config_record:index:importFromRecord'"
type="primary"
:loading="importing"
@click="confirmImport"
>确认导入</el-button>
</template> </template>
</el-dialog> </el-dialog>
</el-drawer> </el-drawer>

View File

@@ -86,10 +86,13 @@ class PlayStartLogic
$playerProfitTotal = $playerWinSum - 100.0 * $playerPlayCount; $playerProfitTotal = $playerWinSum - 100.0 * $playerPlayCount;
$safetyLine = (int) ($configType0->safety_line ?? 0); $safetyLine = (int) ($configType0->safety_line ?? 0);
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1; $killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
// 玩家累计盈利>=安全线杀分:无论付费/免费都用 type=1 的 T*_weight未达到时一律按玩家权重 // 盈利>=安全线且开启杀分:付费/免费都用 killScore盈利<安全线:付费用玩家权重,免费用 killScore无则用 default
// 记录 lottery_config_id杀分记 type=1未杀分统一记当前池 type=0 // 记录 lottery_config_id用池权重时记对应池,付费用玩家权重时记 default
$usePoolWeights = $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null; $usePoolWeights = ($ticketType === self::LOTTERY_TYPE_PAID && $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null)
$config = $usePoolWeights ? $configType1 : $configType0; || ($ticketType === self::LOTTERY_TYPE_FREE);
$config = $usePoolWeights
? (($ticketType === self::LOTTERY_TYPE_FREE && $configType1 === null) ? $configType0 : $configType1)
: $configType0;
// 按档位 T1-T5 抽取后,从 DiceReward 表按当前方向取该档位数据,再按 weight 抽取一条得到 grid_number // 按档位 T1-T5 抽取后,从 DiceReward 表按当前方向取该档位数据,再按 weight 抽取一条得到 grid_number
$rewardInstance = DiceReward::getCachedInstance(); $rewardInstance = DiceReward::getCachedInstance();

View File

@@ -140,7 +140,7 @@ class DicePlayRecordTestController extends BaseController
* @param Request $request * @param Request $request
* @return Response * @return Response
*/ */
#[Permission('玩家抽奖记录(测试数据)删除', 'dice:play_record_test:index:destroy')] #[Permission('玩家抽奖记录(测试数据)删除', 'dice:play_record_test:index:clearAll')]
public function clearAll(Request $request): Response public function clearAll(Request $request): Response
{ {
try { try {

View File

@@ -124,7 +124,7 @@ class DicePlayerWalletRecordController extends BaseController
* @param Request $request * @param Request $request
* @return Response * @return Response
*/ */
#[Permission('玩家钱包流水添加', 'dice:player_wallet_record:index:save')] #[Permission('玩家钱包流水添加', 'dice:player_wallet_record:index:adminOperate')]
public function adminOperate(Request $request): Response public function adminOperate(Request $request): Response
{ {
$data = $request->post(); $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 * @param Request $request
@@ -217,25 +199,4 @@ class DicePlayerWalletRecordController extends BaseController
return $this->fail('update failed'); 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');
}
}
} }

View File

@@ -85,7 +85,7 @@ class DiceRewardController extends BaseController
* 参数lottery_config_id 可选,不选则传 paid_tier_weights / free_tier_weights 自定义档位; * 参数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 * 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 public function startWeightTest(Request $request): Response
{ {
$post = is_array($request->post()) ? $request->post() : []; $post = is_array($request->post()) ? $request->post() : [];
@@ -157,7 +157,7 @@ class DiceRewardController extends BaseController
* 权重编辑弹窗:按方向+点数批量更新权重(写入 dice_reward * 权重编辑弹窗:按方向+点数批量更新权重(写入 dice_reward
* 参数items: [{ grid_number, weight_clockwise, weight_counterclockwise }, ...] * 参数items: [{ grid_number, weight_clockwise, weight_counterclockwise }, ...]
*/ */
#[Permission('奖励对照修改', 'dice:reward:index:update')] #[Permission('权重配比', 'dice:reward:index:batchUpdateWeights')]
public function batchUpdateWeights(Request $request): Response public function batchUpdateWeights(Request $request): Response
{ {
$items = $request->post('items', []); $items = $request->post('items', []);

View File

@@ -109,7 +109,7 @@ class DiceRewardConfigController extends BaseController
* @param Request $request items: [{ id, grid_number?, ui_text?, real_ev?, tier?, remark? }, ...] * @param Request $request items: [{ id, grid_number?, ui_text?, real_ev?, tier?, remark? }, ...]
* @return Response * @return Response
*/ */
#[Permission('奖励配置修改', 'dice:reward_config:index:update')] #[Permission('修改奖励索引', 'dice:reward_config:index:batchUpdate')]
public function batchUpdate(Request $request): Response public function batchUpdate(Request $request): Response
{ {
$items = $request->post('items', []); $items = $request->post('items', []);
@@ -166,7 +166,7 @@ class DiceRewardConfigController extends BaseController
* @param Request $request * @param Request $request
* @return Response * @return Response
*/ */
#[Permission('奖励配置修改', 'dice:reward_config:index:update')] #[Permission('修改色子点数权重', 'dice:reward_config:index:batchUpdateWeights')]
public function batchUpdateWeights(Request $request): Response public function batchUpdateWeights(Request $request): Response
{ {
$items = $request->post('items', []); $items = $request->post('items', []);
@@ -188,7 +188,7 @@ class DiceRewardConfigController extends BaseController
* @param Request $request * @param Request $request
* @return Response * @return Response
*/ */
#[Permission('奖励配置修改', 'dice:reward_config:index:update')] #[Permission('大奖权重修改', 'dice:reward_config:index:saveBigwinWeightsByGrid')]
public function saveBigwinWeightsByGrid(Request $request): Response public function saveBigwinWeightsByGrid(Request $request): Response
{ {
$items = $request->post('items', []); $items = $request->post('items', []);
@@ -209,7 +209,7 @@ class DiceRewardConfigController extends BaseController
* @param Request $request * @param Request $request
* @return Response * @return Response
*/ */
#[Permission('奖励配置修改', 'dice:reward_config:index:update')] #[Permission('创建奖励对照', 'dice:reward_config:index:createRewardReference')]
public function createRewardReference(Request $request): Response public function createRewardReference(Request $request): Response
{ {
try { try {

View File

@@ -144,7 +144,7 @@ class DiceRewardConfigRecordController extends BaseController
* 导入:测试记录 → DiceReward、DiceRewardConfig(BIGWIN)、DiceLotteryPoolConfig(付费/免费 T1-T5) * 导入:测试记录 → DiceReward、DiceRewardConfig(BIGWIN)、DiceLotteryPoolConfig(付费/免费 T1-T5)
* @param Request $request record_id, paid_lottery_config_id(可选), free_lottery_config_id(可选), lottery_config_id(兼容旧版) * @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 public function importFromRecord(Request $request): Response
{ {
$recordId = (int) $request->post('record_id', 0); $recordId = (int) $request->post('record_id', 0);

View File

@@ -14,6 +14,7 @@ use support\think\Db;
/** /**
* 一键测试权重:单进程后台执行模拟摇色子,写入 dice_play_record_test 并更新 dice_reward_config_record 进度 * 一键测试权重:单进程后台执行模拟摇色子,写入 dice_play_record_test 并更新 dice_reward_config_record 进度
* 抽奖逻辑与 PlayStartLogic 一致:使用 name=default 的安全线、杀分开关;盈利<安全线时付费用玩家权重、免费用 killScore盈利>=安全线且杀分开启时付费/免费均用 killScore
*/ */
class WeightTestRunner class WeightTestRunner
{ {
@@ -21,7 +22,7 @@ class WeightTestRunner
/** /**
* 执行指定测试记录:按付费/免费、顺/逆方向交替模拟(付费顺→付费逆→免费顺→免费逆),每 10 条写入一次测试表并更新进度 * 执行指定测试记录:按付费/免费、顺/逆方向交替模拟(付费顺→付费逆→免费顺→免费逆),每 10 条写入一次测试表并更新进度
* 支持1lottery_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 * @param int $recordId dice_reward_config_record.id
*/ */
public function run(int $recordId): void public function run(int $recordId): void
@@ -50,48 +51,37 @@ class WeightTestRunner
$total = $paidS + $paidN + $freeS + $freeN; $total = $paidS + $paidN + $freeS + $freeN;
} }
$paidConfigId = (int) ($record->paid_lottery_config_id ?? 0); $configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
$freeConfigId = (int) ($record->free_lottery_config_id ?? 0); $configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
if ($paidConfigId <= 0) { if (!$configType0) {
$paidConfigId = (int) ($record->lottery_config_id ?? 0); $this->markFailed($recordId, '彩金池配置 name=default 不存在');
}
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, '免费奖池配置不存在');
return; 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 !== []) $paidTierWeights = (is_array($record->paid_tier_weights ?? null) && $record->paid_tier_weights !== [])
? $record->paid_tier_weights ? $record->paid_tier_weights
: null; : [
$freeTierWeights = (is_array($record->free_tier_weights ?? null) && $record->free_tier_weights !== []) 'T1' => (int) ($configType0->t1_weight ?? 0),
? $record->free_tier_weights 'T2' => (int) ($configType0->t2_weight ?? 0),
: null; 'T3' => (int) ($configType0->t3_weight ?? 0),
if ($paidConfig === null && $paidTierWeights === null) { 'T4' => (int) ($configType0->t4_weight ?? 0),
$this->markFailed($recordId, '付费未选奖池时需提供 paid_tier_weights'); 'T5' => (int) ($configType0->t5_weight ?? 0),
return; ];
} if (array_sum($paidTierWeights) <= 0) {
if ($freeConfig === null && $freeTierWeights === null) { $this->markFailed($recordId, '需提供 paid_tier_weights(玩家权重,盈利未达安全线时付费抽奖使用)或选择 default 奖池');
$this->markFailed($recordId, '免费未选奖池时需提供 free_tier_weights');
return; return;
} }
$freeConfig = $configType1 !== null ? $configType1 : $configType0;
// 每次测试开始前清空进程内静态缓存,强制从共享缓存读取最新 BIGWIN/奖励配置,与数据库一致 // 每次测试开始前清空进程内静态缓存,强制从共享缓存读取最新 BIGWIN/奖励配置,与数据库一致
DiceRewardConfig::clearRequestInstance(); DiceRewardConfig::clearRequestInstance();
DiceReward::clearRequestInstance(); DiceReward::clearRequestInstance();
// 测试时按“单个虚拟玩家”累计中奖金额来判断是否触发杀分:达到 safety_line 前用自定义档位(玩家权重),达到后用奖池权重 //“玩家”盈利: 玩家累计盈利:仅统计 lottery_config_id=default 的成功对局win_coin - 100与 PlayStartLogic 一致
$paidSafetyLine = $paidConfig !== null ? (int) ($paidConfig->safety_line ?? 0) : 0; $playerProfitTotal = 0.0;
$freeSafetyLine = $freeConfig !== null ? (int) ($freeConfig->safety_line ?? 0) : 0;
$paidPlayerWinTotal = 0.0;
$freePlayerWinTotal = 0.0;
$playLogic = new PlayStartLogic(); $playLogic = new PlayStartLogic();
$resultCounts = []; $resultCounts = [];
@@ -101,40 +91,36 @@ class WeightTestRunner
try { try {
for ($i = 0; $i < $paidS; $i++) { 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; $customWeights = $usePoolWeights ? null : $paidTierWeights;
$row = $playLogic->simulateOnePlay($paidConfig, 0, 0, $customWeights); $row = $playLogic->simulateOnePlay($paidConfig, 0, 0, $customWeights);
$this->accumulatePlayerWin($row, $paidPlayerWinTotal); $this->accumulateProfitForDefault($row, 0, $paidConfig, $configType0, $playerProfitTotal);
$this->aggregate($row, $resultCounts, $tierCounts); $this->aggregate($row, $resultCounts, $tierCounts);
$buffer[] = $this->rowForInsert($row, $recordId); $buffer[] = $this->rowForInsert($row, $recordId);
$done++; $done++;
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts); $this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
} }
for ($i = 0; $i < $paidN; $i++) { 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; $customWeights = $usePoolWeights ? null : $paidTierWeights;
$row = $playLogic->simulateOnePlay($paidConfig, 1, 0, $customWeights); $row = $playLogic->simulateOnePlay($paidConfig, 1, 0, $customWeights);
$this->accumulatePlayerWin($row, $paidPlayerWinTotal); $this->accumulateProfitForDefault($row, 0, $paidConfig, $configType0, $playerProfitTotal);
$this->aggregate($row, $resultCounts, $tierCounts); $this->aggregate($row, $resultCounts, $tierCounts);
$buffer[] = $this->rowForInsert($row, $recordId); $buffer[] = $this->rowForInsert($row, $recordId);
$done++; $done++;
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts); $this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
} }
for ($i = 0; $i < $freeS; $i++) { for ($i = 0; $i < $freeS; $i++) {
$usePoolWeights = $freeConfig !== null && $freePlayerWinTotal >= $freeSafetyLine && $freeSafetyLine > 0; $row = $playLogic->simulateOnePlay($freeConfig, 0, 1, null);
$customWeights = $usePoolWeights ? null : $freeTierWeights;
$row = $playLogic->simulateOnePlay($freeConfig, 0, 1, $customWeights);
$this->accumulatePlayerWin($row, $freePlayerWinTotal);
$this->aggregate($row, $resultCounts, $tierCounts); $this->aggregate($row, $resultCounts, $tierCounts);
$buffer[] = $this->rowForInsert($row, $recordId); $buffer[] = $this->rowForInsert($row, $recordId);
$done++; $done++;
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts); $this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
} }
for ($i = 0; $i < $freeN; $i++) { for ($i = 0; $i < $freeN; $i++) {
$usePoolWeights = $freeConfig !== null && $freePlayerWinTotal >= $freeSafetyLine && $freeSafetyLine > 0; $row = $playLogic->simulateOnePlay($freeConfig, 1, 1, null);
$customWeights = $usePoolWeights ? null : $freeTierWeights;
$row = $playLogic->simulateOnePlay($freeConfig, 1, 1, $customWeights);
$this->accumulatePlayerWin($row, $freePlayerWinTotal);
$this->aggregate($row, $resultCounts, $tierCounts); $this->aggregate($row, $resultCounts, $tierCounts);
$buffer[] = $this->rowForInsert($row, $recordId); $buffer[] = $this->rowForInsert($row, $recordId);
$done++; $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; 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 private function aggregate(array $row, array &$resultCounts, array &$tierCounts): void