优化杀分逻辑

This commit is contained in:
2026-03-17 15:36:14 +08:00
parent 1892c7bcb7
commit 150d31eac5
9 changed files with 38 additions and 37 deletions

View File

@@ -34,7 +34,7 @@ class DiceLotteryPoolConfigLogic extends BaseLogic
* 获取当前彩金池type=0+ 杀分权重为 type=1 的只读展示
* profit_amount 每次从 DB 实时读取t1_weightt5_weight 来自 type=1杀分权重不可在弹窗内修改
*
* @return array{id:int,name:string,safety_line:int,t1_weight:int,...,t5_weight:int,profit_amount:float}
* @return array{id:int,name:string,safety_line:int,kill_enabled:int,t1_weight:int,...,t5_weight:int,profit_amount:float}
*/
public function getCurrentPool(): array
{
@@ -49,6 +49,7 @@ class DiceLotteryPoolConfigLogic extends BaseLogic
'id' => (int) $row0['id'],
'name' => (string) ($row0['name'] ?? ''),
'safety_line' => (int) ($row0['safety_line'] ?? 0),
'kill_enabled' => (int) ($row0['kill_enabled'] ?? 1),
'profit_amount' => $profitAmount,
];
$row1 = $configType1 ? $configType1->toArray() : [];
@@ -61,19 +62,28 @@ class DiceLotteryPoolConfigLogic extends BaseLogic
}
/**
* 更新当前彩金池:仅允许修改 type=0 的 safety_line杀分权重来自 type=1不可在此接口修改
* 更新当前彩金池:仅允许修改 type=0 的 safety_line、kill_enabled(杀分权重来自 type=1不可在此接口修改
*
* @param array{safety_line?:int} $data
* @param array{safety_line?:int,kill_enabled?:int} $data
*/
public function updateCurrentPool(array $data): void
{
$pool = $this->getCurrentPool();
$id = (int) $pool['id'];
if (!array_key_exists('safety_line', $data)) {
if (!array_key_exists('safety_line', $data) && !array_key_exists('kill_enabled', $data)) {
return;
}
$safetyLine = (int) $data['safety_line'];
DiceLotteryPoolConfig::where('id', $id)->update(['safety_line' => $safetyLine]);
$update = [];
if (array_key_exists('safety_line', $data)) {
$update['safety_line'] = (int) $data['safety_line'];
}
if (array_key_exists('kill_enabled', $data)) {
$update['kill_enabled'] = ((int) $data['kill_enabled']) === 1 ? 1 : 0;
}
if ($update === []) {
return;
}
DiceLotteryPoolConfig::where('id', $id)->update($update);
}
/**

View File

@@ -11,13 +11,14 @@ use plugin\saiadmin\basic\think\BaseModel;
/**
* 色子奖池配置模型
*
* dice_lottery_config 色子奖池配置
* dice_lottery_pool_config 色子奖池配置
*
* @property $id ID
* @property $name 名称
* @property $remark 备注
* @property $type 奖池类型
* @property $safety_line 安全线
* @property $kill_enabled 是否启用杀分0=关闭 1=开启
* @property $create_time 创建时间
* @property $update_time 修改时间
* @property $t1_weight T1池权重
@@ -39,7 +40,7 @@ class DiceLotteryPoolConfig extends BaseModel
* 数据库表名称
* @var string
*/
protected $table = 'dice_lottery_config';
protected $table = 'dice_lottery_pool_config';
/**
* 名称 搜索