1.新增默认彩金池配置
2.优化关联彩金池配置的名称显示 3.优化一键测试权重 4.优化底注配置
This commit is contained in:
@@ -17,7 +17,8 @@ use app\dice\model\DiceModel;
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $name 名称
|
||||
* @property $remark 备注
|
||||
* @property $remark 奖池名称(后台展示名)
|
||||
* @property $config_note 配置备注
|
||||
* @property $safety_line 安全线
|
||||
* @property $kill_enabled 是否启用杀分:0=关闭 1=开启
|
||||
* @property $create_time 创建时间
|
||||
@@ -31,6 +32,9 @@ use app\dice\model\DiceModel;
|
||||
*/
|
||||
class DiceLotteryPoolConfig extends DiceModel
|
||||
{
|
||||
/** 玩家默认彩金池(新玩家关联;付费未杀分时运行时读取该池 T1–T5 权重) */
|
||||
public const NAME_PLAYER_DEFAULT = 'playerDefault';
|
||||
|
||||
/**
|
||||
* 数据表主键
|
||||
* @var string
|
||||
@@ -43,6 +47,9 @@ class DiceLotteryPoolConfig extends DiceModel
|
||||
*/
|
||||
protected $table = 'dice_lottery_pool_config';
|
||||
|
||||
/** 列表/关联 JSON 附带奖池展示名 */
|
||||
protected $append = ['display_name'];
|
||||
|
||||
/**
|
||||
* 按名称与渠道查找奖池配置(一键测试等场景,避免命中其他渠道同名配置)
|
||||
*/
|
||||
@@ -53,12 +60,57 @@ class DiceLotteryPoolConfig extends DiceModel
|
||||
return $query->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否玩家默认模板池(运行时按该池权重抽档,改池配置即对所有关联玩家生效)
|
||||
*/
|
||||
public function isPlayerDefaultTemplate(): bool
|
||||
{
|
||||
return (string) ($this->name ?? '') === self::NAME_PLAYER_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台展示用奖池名称:优先 remark,否则 name
|
||||
*
|
||||
* @param array<string, mixed>|self $row
|
||||
*/
|
||||
public static function displayLabel($row): string
|
||||
{
|
||||
// 禁止对模型实例 toArray():append display_name 会再次触发本方法,导致内存耗尽
|
||||
if ($row instanceof self) {
|
||||
$data = $row->getData();
|
||||
$remark = trim((string) ($data['remark'] ?? ''));
|
||||
if ($remark !== '') {
|
||||
return $remark;
|
||||
}
|
||||
return trim((string) ($data['name'] ?? ''));
|
||||
}
|
||||
$remark = trim((string) ($row['remark'] ?? ''));
|
||||
if ($remark !== '') {
|
||||
return $remark;
|
||||
}
|
||||
return trim((string) ($row['name'] ?? ''));
|
||||
}
|
||||
|
||||
public function getDisplayNameAttr(): string
|
||||
{
|
||||
$data = $this->getData();
|
||||
$remark = trim((string) ($data['remark'] ?? ''));
|
||||
if ($remark !== '') {
|
||||
return $remark;
|
||||
}
|
||||
return trim((string) ($data['name'] ?? ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* 名称 搜索
|
||||
*/
|
||||
public function searchNameAttr($query, $value)
|
||||
{
|
||||
$query->where('name', 'like', '%'.$value.'%');
|
||||
$like = '%' . $value . '%';
|
||||
$query->where(function ($q) use ($like) {
|
||||
$q->where('name', 'like', $like)
|
||||
->whereOr('remark', 'like', $like);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user