1.新增默认彩金池配置
2.优化关联彩金池配置的名称显示 3.优化一键测试权重 4.优化底注配置
This commit is contained in:
@@ -24,6 +24,7 @@ class DiceAnteConfigLogic extends DiceBaseLogic
|
||||
public function add(array $data): mixed
|
||||
{
|
||||
return $this->transaction(function () use ($data) {
|
||||
$this->applyNameTitleFromMult($data);
|
||||
$this->normalizeDefaultField($data);
|
||||
$deptId = AdminScopeHelper::resolveConfigDeptId(null, $data['dept_id'] ?? AdminScopeHelper::DEFAULT_TEMPLATE_DEPT);
|
||||
if ((int) ($data['is_default'] ?? 0) === 1) {
|
||||
@@ -38,6 +39,7 @@ class DiceAnteConfigLogic extends DiceBaseLogic
|
||||
$pickedDeptId = AdminScopeHelper::pickRequestDeptId($requestDeptId, $data);
|
||||
$deptId = AdminScopeHelper::resolveConfigDeptId($adminInfo, $pickedDeptId);
|
||||
return $this->transaction(function () use ($id, $data, $deptId, $adminInfo, $pickedDeptId) {
|
||||
$this->applyNameTitleFromMult($data);
|
||||
$this->normalizeDefaultField($data);
|
||||
if ((int) ($data['is_default'] ?? 0) === 1) {
|
||||
$this->clearOtherDefaults((int) $id, $deptId);
|
||||
@@ -92,6 +94,21 @@ class DiceAnteConfigLogic extends DiceBaseLogic
|
||||
$data['is_default'] = ((int) $data['is_default']) === 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
/** 名称、标题随底注倍率自动设为 xN */
|
||||
private function applyNameTitleFromMult(array &$data): void
|
||||
{
|
||||
if (!array_key_exists('mult', $data)) {
|
||||
return;
|
||||
}
|
||||
$mult = (int) $data['mult'];
|
||||
if ($mult <= 0) {
|
||||
return;
|
||||
}
|
||||
$label = 'x' . $mult;
|
||||
$data['name'] = $label;
|
||||
$data['title'] = $label;
|
||||
}
|
||||
|
||||
private function clearOtherDefaults(?int $excludeId = null, int $deptId = AdminScopeHelper::DEFAULT_TEMPLATE_DEPT): void
|
||||
{
|
||||
$query = $this->model->where('is_default', 1);
|
||||
|
||||
@@ -598,41 +598,100 @@ class DiceRewardLogic
|
||||
if ($configCw !== null) {
|
||||
$tier = isset($configCw['tier']) ? trim((string) $configCw['tier']) : '';
|
||||
if ($tier !== '') {
|
||||
$rows[] = [
|
||||
'tier' => $tier,
|
||||
'direction' => DiceReward::DIRECTION_CLOCKWISE,
|
||||
'weight' => self::WEIGHT_MIN,
|
||||
'grid_number' => $gridNumber,
|
||||
'start_index' => $startId,
|
||||
'end_index' => isset($configCw['id']) ? (int) $configCw['id'] : 0,
|
||||
'ui_text' => $configCw['ui_text'] ?? '',
|
||||
'real_ev' => $configCw['real_ev'] ?? null,
|
||||
'remark' => $configCw['remark'] ?? '',
|
||||
'type' => isset($configCw['type']) ? (int) $configCw['type'] : 0,
|
||||
];
|
||||
$rows[] = $this->buildReferenceRowFromLandingConfig(
|
||||
$tier,
|
||||
$configCw,
|
||||
DiceReward::DIRECTION_CLOCKWISE,
|
||||
$gridNumber,
|
||||
$startId
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($configCcw !== null) {
|
||||
$tier = isset($configCcw['tier']) ? trim((string) $configCcw['tier']) : '';
|
||||
if ($tier !== '') {
|
||||
$rows[] = [
|
||||
'tier' => $tier,
|
||||
'direction' => DiceReward::DIRECTION_COUNTERCLOCKWISE,
|
||||
'weight' => self::WEIGHT_MIN,
|
||||
'grid_number' => $gridNumber,
|
||||
'start_index' => $startId,
|
||||
'end_index' => isset($configCcw['id']) ? (int) $configCcw['id'] : 0,
|
||||
'ui_text' => $configCcw['ui_text'] ?? '',
|
||||
'real_ev' => $configCcw['real_ev'] ?? null,
|
||||
'remark' => $configCcw['remark'] ?? '',
|
||||
'type' => isset($configCcw['type']) ? (int) $configCcw['type'] : 0,
|
||||
];
|
||||
$rows[] = $this->buildReferenceRowFromLandingConfig(
|
||||
$tier,
|
||||
$configCcw,
|
||||
DiceReward::DIRECTION_COUNTERCLOCKWISE,
|
||||
$gridNumber,
|
||||
$startId
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['rows' => $rows, 'skipped' => $skipped];
|
||||
}
|
||||
|
||||
/**
|
||||
* 对照表落点行:档位按结算金额推断,备注与奖励配置页规则一致
|
||||
*
|
||||
* @param array<string, mixed> $landingConfig
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function buildReferenceRowFromLandingConfig(
|
||||
string $tier,
|
||||
array $landingConfig,
|
||||
int $direction,
|
||||
int $gridNumber,
|
||||
int $startId
|
||||
): array {
|
||||
$realEv = isset($landingConfig['real_ev']) ? (float) $landingConfig['real_ev'] : 0.0;
|
||||
if ($tier !== 'BIGWIN') {
|
||||
$inferred = $this->inferTierFromRealEv($realEv);
|
||||
if ($inferred !== '') {
|
||||
$tier = $inferred;
|
||||
}
|
||||
}
|
||||
return [
|
||||
'tier' => $tier,
|
||||
'direction' => $direction,
|
||||
'weight' => self::WEIGHT_MIN,
|
||||
'grid_number' => $gridNumber,
|
||||
'start_index' => $startId,
|
||||
'end_index' => isset($landingConfig['id']) ? (int) $landingConfig['id'] : 0,
|
||||
'ui_text' => $landingConfig['ui_text'] ?? '',
|
||||
'real_ev' => $landingConfig['real_ev'] ?? null,
|
||||
'remark' => $this->defaultRemarkForTier($tier),
|
||||
'type' => isset($landingConfig['type']) ? (int) $landingConfig['type'] : 0,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 按结算金额推断档位(与前端 generateIndexByRules 一致)
|
||||
*/
|
||||
private function inferTierFromRealEv(float $realEv): string
|
||||
{
|
||||
if ($realEv > 2) {
|
||||
return 'T1';
|
||||
}
|
||||
if ($realEv > 1) {
|
||||
return 'T2';
|
||||
}
|
||||
if ($realEv > 0) {
|
||||
return 'T3';
|
||||
}
|
||||
if ($realEv < 0) {
|
||||
return 'T4';
|
||||
}
|
||||
return 'T5';
|
||||
}
|
||||
|
||||
/**
|
||||
* 档位默认备注
|
||||
*/
|
||||
private function defaultRemarkForTier(string $tier): string
|
||||
{
|
||||
return match ($tier) {
|
||||
'T1', 'BIGWIN' => '大奖',
|
||||
'T2' => '小赚',
|
||||
'T3' => '抽水',
|
||||
'T4' => '惩罚',
|
||||
'T5' => '再来一次',
|
||||
default => '',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 读出当前 dice_reward(用于对比/复用权重)。key = "direction:grid_number"
|
||||
* @return array<string, array<string, mixed>>
|
||||
|
||||
@@ -283,7 +283,12 @@ class DiceRewardConfigRecordLogic extends DiceBaseLogic
|
||||
$paidN = isset($params['paid_n_count']) ? (int) $params['paid_n_count'] : 0;
|
||||
$chainFreeMode = !empty($params['chain_free_mode']);
|
||||
$killModeEnabled = !empty($params['kill_mode_enabled']);
|
||||
$testSafetyLine = isset($params['test_safety_line']) ? (int) $params['test_safety_line'] : 5000;
|
||||
if (array_key_exists('test_safety_line', $params) && $params['test_safety_line'] !== null && $params['test_safety_line'] !== '') {
|
||||
$testSafetyLine = (int) $params['test_safety_line'];
|
||||
} else {
|
||||
$defaultPool = DiceLotteryPoolConfig::findByNameForDept('default', $deptId);
|
||||
$testSafetyLine = (int) ($defaultPool->safety_line ?? 0);
|
||||
}
|
||||
if ($testSafetyLine < 0) {
|
||||
throw new ApiException('test_safety_line must be greater than or equal to 0');
|
||||
}
|
||||
@@ -405,6 +410,9 @@ class DiceRewardConfigRecordLogic extends DiceBaseLogic
|
||||
if ($chainFreeMode) {
|
||||
$tierWeightsSnapshot['chain_free_mode'] = true;
|
||||
}
|
||||
if (!empty($params['ante_random'])) {
|
||||
$tierWeightsSnapshot['ante_random'] = true;
|
||||
}
|
||||
|
||||
$record = new DiceRewardConfigRecord();
|
||||
$plannedPaidSpins = $paidS + $paidN;
|
||||
@@ -494,6 +502,21 @@ class DiceRewardConfigRecordLogic extends DiceBaseLogic
|
||||
*/
|
||||
private function resolveWeightTestAnte(array $params, int $deptId): int
|
||||
{
|
||||
if (!empty($params['ante_random'])) {
|
||||
$anteQuery = DiceAnteConfig::field('id,mult')->order('mult', 'asc');
|
||||
ConfigScopeEditHelper::applyDeptIdWhere($anteQuery, $deptId);
|
||||
$rows = $anteQuery->select()->toArray();
|
||||
if ($rows === []) {
|
||||
throw new ApiException('No ante config in current channel');
|
||||
}
|
||||
$picked = $rows[random_int(0, count($rows) - 1)];
|
||||
$mult = (int) ($picked['mult'] ?? 0);
|
||||
if ($mult <= 0) {
|
||||
throw new ApiException('ANTE_MUST_POSITIVE');
|
||||
}
|
||||
return $mult;
|
||||
}
|
||||
|
||||
$anteConfigId = isset($params['ante_config_id']) ? (int) $params['ante_config_id'] : 0;
|
||||
if ($anteConfigId > 0) {
|
||||
$config = DiceAnteConfig::find($anteConfigId);
|
||||
|
||||
Reference in New Issue
Block a user