1.新增默认彩金池配置
2.优化关联彩金池配置的名称显示 3.优化一键测试权重 4.优化底注配置
This commit is contained in:
@@ -5,6 +5,7 @@ namespace app\dice\service;
|
||||
|
||||
use app\dice\helper\AdminScopeHelper;
|
||||
use app\dice\logic\reward\DiceRewardLogic;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\reward\DiceReward;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use plugin\saiadmin\app\model\system\SystemDept;
|
||||
@@ -209,9 +210,99 @@ class DiceChannelConfigService
|
||||
}
|
||||
$this->ensureRewardReferenceForDept($deptId);
|
||||
DiceRewardConfig::refreshCache($deptId);
|
||||
$this->ensurePlayerDefaultPoolForDept($deptId);
|
||||
$this->migratePlayersDefaultPoolToPlayerDefault($deptId);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为渠道补齐玩家默认彩金池 name=playerDefault(权重复制自 default)
|
||||
*/
|
||||
public function ensurePlayerDefaultPoolForDept(int $deptId): ?int
|
||||
{
|
||||
if (!$this->tableHasColumn('dice_lottery_pool_config', 'dept_id')) {
|
||||
return null;
|
||||
}
|
||||
$exists = Db::table('dice_lottery_pool_config')
|
||||
->where('dept_id', $deptId)
|
||||
->where('name', DiceLotteryPoolConfig::NAME_PLAYER_DEFAULT)
|
||||
->count();
|
||||
if ($exists > 0) {
|
||||
return (int) Db::table('dice_lottery_pool_config')
|
||||
->where('dept_id', $deptId)
|
||||
->where('name', DiceLotteryPoolConfig::NAME_PLAYER_DEFAULT)
|
||||
->value('id');
|
||||
}
|
||||
$defaultRow = Db::table('dice_lottery_pool_config')
|
||||
->where('dept_id', $deptId)
|
||||
->where('name', 'default')
|
||||
->find();
|
||||
if (!$defaultRow) {
|
||||
return null;
|
||||
}
|
||||
$defaultRow = (array) $defaultRow;
|
||||
unset($defaultRow['id'], $defaultRow['row_id'], $defaultRow['create_time'], $defaultRow['update_time'], $defaultRow['delete_time']);
|
||||
$defaultRow['name'] = DiceLotteryPoolConfig::NAME_PLAYER_DEFAULT;
|
||||
$defaultRow['remark'] = '默认';
|
||||
$defaultRow['safety_line'] = 0;
|
||||
$defaultRow['kill_enabled'] = 0;
|
||||
$defaultRow['profit_amount'] = 0;
|
||||
$defaultRow['dept_id'] = $deptId;
|
||||
return (int) Db::table('dice_lottery_pool_config')->insertGetId($defaultRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将仍关联 name=default 的玩家改为关联 playerDefault(杀分逻辑仍用 default 池)
|
||||
*/
|
||||
public function migratePlayersDefaultPoolToPlayerDefault(int $deptId): int
|
||||
{
|
||||
if (!$this->tableHasColumn('dice_player', 'dept_id')
|
||||
|| !$this->tableHasColumn('dice_player', 'lottery_config_id')) {
|
||||
return 0;
|
||||
}
|
||||
$playerDefaultId = Db::table('dice_lottery_pool_config')
|
||||
->where('dept_id', $deptId)
|
||||
->where('name', DiceLotteryPoolConfig::NAME_PLAYER_DEFAULT)
|
||||
->value('id');
|
||||
if (!$playerDefaultId) {
|
||||
return 0;
|
||||
}
|
||||
$defaultPoolId = Db::table('dice_lottery_pool_config')
|
||||
->where('dept_id', $deptId)
|
||||
->where('name', 'default')
|
||||
->value('id');
|
||||
if (!$defaultPoolId) {
|
||||
return 0;
|
||||
}
|
||||
return Db::table('dice_player')
|
||||
->where('dept_id', $deptId)
|
||||
->where('lottery_config_id', (int) $defaultPoolId)
|
||||
->update(['lottery_config_id' => (int) $playerDefaultId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为全部渠道与默认模板补齐 playerDefault 奖池并迁移玩家关联
|
||||
*/
|
||||
public function ensurePlayerDefaultPoolsAllChannels(): array
|
||||
{
|
||||
$deptIds = [AdminScopeHelper::DEFAULT_TEMPLATE_DEPT];
|
||||
foreach (SystemDept::column('id') as $id) {
|
||||
$id = (int) $id;
|
||||
if ($id > 0) {
|
||||
$deptIds[] = $id;
|
||||
}
|
||||
}
|
||||
$deptIds = array_values(array_unique($deptIds));
|
||||
$summary = [];
|
||||
foreach ($deptIds as $deptId) {
|
||||
$summary[$deptId] = [
|
||||
'pool_id' => $this->ensurePlayerDefaultPoolForDept($deptId),
|
||||
'players_migrated' => $this->migratePlayersDefaultPoolToPlayerDefault($deptId),
|
||||
];
|
||||
}
|
||||
return $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按业务 id 从默认模板补齐配置(dice_config / dice_reward_config)
|
||||
*/
|
||||
@@ -297,6 +388,7 @@ class DiceChannelConfigService
|
||||
}
|
||||
$summary[$deptId] = $this->copyDefaultConfigToDept($deptId);
|
||||
}
|
||||
$summary['_player_default_pools'] = $this->ensurePlayerDefaultPoolsAllChannels();
|
||||
return $summary;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user