1.将部门修改为渠道,并且所有dice_表关联渠道表
2.将所有配置表,记录表设置关联渠道 3.优化后台页面设置
This commit is contained in:
25
server/app/dice/model/DiceModel.php
Normal file
25
server/app/dice/model/DiceModel.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\dice\model;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel as SaiBaseModel;
|
||||
|
||||
/**
|
||||
* 大富翁模块模型基类:删除均为硬删除(物理删除)
|
||||
*/
|
||||
abstract class DiceModel extends SaiBaseModel
|
||||
{
|
||||
/**
|
||||
* @param mixed $data
|
||||
*/
|
||||
public static function destroy($data, bool $force = true): bool
|
||||
{
|
||||
return parent::destroy($data, true);
|
||||
}
|
||||
|
||||
public function delete(): bool
|
||||
{
|
||||
return $this->force()->delete();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\ante_config;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
|
||||
/**
|
||||
* 底注配置模型
|
||||
@@ -19,7 +19,7 @@ use plugin\saiadmin\basic\think\BaseModel;
|
||||
* @property string $create_time 创建时间
|
||||
* @property string $update_time 更新时间
|
||||
*/
|
||||
class DiceAnteConfig extends BaseModel
|
||||
class DiceAnteConfig extends DiceModel
|
||||
{
|
||||
protected $pk = 'id';
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\config;
|
||||
|
||||
use plugin\saiadmin\basic\eloquent\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
|
||||
/**
|
||||
* 摇色子配置模型
|
||||
@@ -23,7 +23,7 @@ use plugin\saiadmin\basic\eloquent\BaseModel;
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
*/
|
||||
class DiceConfig extends BaseModel
|
||||
class DiceConfig extends DiceModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\game;
|
||||
|
||||
use plugin\saiadmin\basic\eloquent\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
|
||||
/**
|
||||
* 游戏管理模型
|
||||
*
|
||||
* dice_game 游戏配置表
|
||||
*/
|
||||
class DiceGame extends BaseModel
|
||||
class DiceGame extends DiceModel
|
||||
{
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\lottery_pool_config;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\helper\AdminScopeHelper;
|
||||
use app\dice\helper\ConfigScopeEditHelper;
|
||||
use app\dice\model\DiceModel;
|
||||
|
||||
/**
|
||||
* 色子奖池配置模型
|
||||
@@ -27,7 +29,7 @@ use plugin\saiadmin\basic\think\BaseModel;
|
||||
* @property $t5_weight T5池权重
|
||||
* @property $profit_amount 池子累计盈利(每局付费按 win_coin-paid_amount,免费按 win_coin 累加;仅展示不可编辑)
|
||||
*/
|
||||
class DiceLotteryPoolConfig extends BaseModel
|
||||
class DiceLotteryPoolConfig extends DiceModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
@@ -41,6 +43,16 @@ class DiceLotteryPoolConfig extends BaseModel
|
||||
*/
|
||||
protected $table = 'dice_lottery_pool_config';
|
||||
|
||||
/**
|
||||
* 按名称与渠道查找奖池配置(一键测试等场景,避免命中其他渠道同名配置)
|
||||
*/
|
||||
public static function findByNameForDept(string $name, int $deptId): ?self
|
||||
{
|
||||
$query = (new self())->where('name', $name);
|
||||
ConfigScopeEditHelper::applyDeptIdWhere($query, AdminScopeHelper::normalizeRecordDeptId($deptId));
|
||||
return $query->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 名称 搜索
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace app\dice\model\play_record;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
use think\model\relation\BelongsTo;
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ use think\model\relation\BelongsTo;
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
*/
|
||||
class DicePlayRecord extends BaseModel
|
||||
class DicePlayRecord extends DiceModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\play_record_test;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use think\model\relation\BelongsTo;
|
||||
@@ -37,7 +37,7 @@ use think\model\relation\BelongsTo;
|
||||
* @property $admin_id 所属管理员
|
||||
* @property int|null $reward_config_record_id 关联 DiceRewardConfigRecord.id(权重测试记录)
|
||||
*/
|
||||
class DicePlayRecordTest extends BaseModel
|
||||
class DicePlayRecordTest extends DiceModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\player;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
|
||||
/**
|
||||
@@ -15,7 +15,8 @@ use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
* dice_player 大富翁-玩家
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $username 用户名
|
||||
* @property $dept_id 所属渠道ID
|
||||
* @property $username 用户名(同渠道内唯一)
|
||||
* @property $phone 手机
|
||||
* @property $uid uid
|
||||
* @property $name 昵称
|
||||
@@ -37,7 +38,7 @@ use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
* @property $update_time 更新时间
|
||||
* @property $delete_time 删除时间
|
||||
*/
|
||||
class DicePlayer extends BaseModel
|
||||
class DicePlayer extends DiceModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace app\dice\model\player_ticket_record;
|
||||
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
use think\model\relation\BelongsTo;
|
||||
|
||||
/**
|
||||
@@ -27,7 +27,7 @@ use think\model\relation\BelongsTo;
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
*/
|
||||
class DicePlayerTicketRecord extends BaseModel
|
||||
class DicePlayerTicketRecord extends DiceModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace app\dice\model\player_wallet_record;
|
||||
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
use plugin\saiadmin\app\model\system\SystemUser;
|
||||
use think\model\relation\BelongsTo;
|
||||
|
||||
@@ -31,7 +31,7 @@ use think\model\relation\BelongsTo;
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
*/
|
||||
class DicePlayerWalletRecord extends BaseModel
|
||||
class DicePlayerWalletRecord extends DiceModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\reward;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\helper\AdminScopeHelper;
|
||||
use app\dice\helper\ConfigScopeEditHelper;
|
||||
use app\dice\model\DiceModel;
|
||||
use support\think\Cache;
|
||||
|
||||
/**
|
||||
@@ -25,42 +27,70 @@ use support\think\Cache;
|
||||
* @property $remark 备注(来自config)
|
||||
* @property $type 奖励类型(来自config)
|
||||
*/
|
||||
class DiceReward extends BaseModel
|
||||
class DiceReward extends DiceModel
|
||||
{
|
||||
/** 方向:顺时针 */
|
||||
public const DIRECTION_CLOCKWISE = 0;
|
||||
/** 方向:逆时针 */
|
||||
public const DIRECTION_COUNTERCLOCKWISE = 1;
|
||||
|
||||
/** 缓存键:奖励对照实例 */
|
||||
/** 缓存键前缀:奖励对照实例(按渠道分键) */
|
||||
private const CACHE_KEY_INSTANCE = 'dice:reward:instance';
|
||||
|
||||
private const CACHE_TTL = 86400 * 30;
|
||||
|
||||
private static ?array $instance = null;
|
||||
|
||||
private static ?int $requestDeptId = null;
|
||||
|
||||
protected $table = 'dice_reward';
|
||||
|
||||
/** 主键 id 自增,唯一约束 (direction, grid_number) */
|
||||
protected $pk = 'id';
|
||||
|
||||
private static function cacheKeyForDept(int $deptId): string
|
||||
{
|
||||
return self::CACHE_KEY_INSTANCE . ':' . $deptId;
|
||||
}
|
||||
|
||||
private static function resolveDeptId(?int $deptId): int
|
||||
{
|
||||
if ($deptId !== null) {
|
||||
return AdminScopeHelper::normalizeRecordDeptId($deptId);
|
||||
}
|
||||
if (self::$requestDeptId !== null) {
|
||||
return self::$requestDeptId;
|
||||
}
|
||||
return AdminScopeHelper::DEFAULT_TEMPLATE_DEPT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求级设置当前渠道(一键测试 worker 内调用 simulateOnePlay 前设置)
|
||||
*/
|
||||
public static function setRequestDeptId(?int $deptId): void
|
||||
{
|
||||
self::$requestDeptId = $deptId !== null
|
||||
? AdminScopeHelper::normalizeRecordDeptId($deptId)
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取奖励对照实例(按档位+方向索引,用于抽奖与权重配比)
|
||||
* 优先从共享缓存读取,保证多进程(如一键测试 worker)与数据库一致
|
||||
* @return array{list: array, by_tier_direction: array}
|
||||
*/
|
||||
public static function getCachedInstance(): array
|
||||
public static function getCachedInstance(?int $deptId = null): array
|
||||
{
|
||||
$instance = Cache::get(self::CACHE_KEY_INSTANCE);
|
||||
$deptId = self::resolveDeptId($deptId);
|
||||
$cacheKey = self::cacheKeyForDept($deptId);
|
||||
$instance = Cache::get($cacheKey);
|
||||
if ($instance !== null && is_array($instance)) {
|
||||
self::$instance = $instance;
|
||||
return $instance;
|
||||
}
|
||||
if (self::$instance !== null) {
|
||||
if (self::$instance !== null && self::$requestDeptId === $deptId) {
|
||||
return self::$instance;
|
||||
}
|
||||
self::refreshCache();
|
||||
$instance = Cache::get(self::CACHE_KEY_INSTANCE);
|
||||
self::refreshCache($deptId);
|
||||
$instance = Cache::get($cacheKey);
|
||||
self::$instance = is_array($instance) ? $instance : self::buildEmptyInstance();
|
||||
return self::$instance;
|
||||
}
|
||||
@@ -69,9 +99,9 @@ class DiceReward extends BaseModel
|
||||
* 按档位+方向取权重列表(用于抽奖:该档位该方向下 end_index => weight)
|
||||
* @return array<int, int> end_index => weight
|
||||
*/
|
||||
public static function getCachedByTierAndDirection(string $tier, int $direction): array
|
||||
public static function getCachedByTierAndDirection(string $tier, int $direction, ?int $deptId = null): array
|
||||
{
|
||||
$inst = self::getCachedInstance();
|
||||
$inst = self::getCachedInstance($deptId);
|
||||
$byTierDirection = $inst['by_tier_direction'] ?? [];
|
||||
$list = $byTierDirection[$tier][$direction] ?? [];
|
||||
$result = [];
|
||||
@@ -84,11 +114,14 @@ class DiceReward extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新从数据库加载并写入缓存;修改/新增/删除后需调用以实例化
|
||||
* 按渠道从数据库加载并写入缓存
|
||||
*/
|
||||
public static function refreshCache(): void
|
||||
public static function refreshCache(?int $deptId = null): void
|
||||
{
|
||||
$list = (new self())->order('tier')->order('direction')->order('end_index')->select()->toArray();
|
||||
$deptId = self::resolveDeptId($deptId);
|
||||
$query = (new self())->order('tier')->order('direction')->order('end_index');
|
||||
ConfigScopeEditHelper::applyDeptIdWhere($query, $deptId);
|
||||
$list = $query->select()->toArray();
|
||||
$byTierDirection = [];
|
||||
foreach ($list as $row) {
|
||||
$tier = isset($row['tier']) ? (string) $row['tier'] : '';
|
||||
@@ -103,11 +136,12 @@ class DiceReward extends BaseModel
|
||||
$byTierDirection[$tier][$direction][] = $row;
|
||||
}
|
||||
}
|
||||
self::$instance = [
|
||||
$instance = [
|
||||
'list' => $list,
|
||||
'by_tier_direction' => $byTierDirection,
|
||||
];
|
||||
Cache::set(self::CACHE_KEY_INSTANCE, self::$instance, self::CACHE_TTL);
|
||||
self::$instance = $instance;
|
||||
Cache::set(self::cacheKeyForDept($deptId), $instance, self::CACHE_TTL);
|
||||
}
|
||||
|
||||
private static function buildEmptyInstance(): array
|
||||
@@ -121,20 +155,29 @@ class DiceReward extends BaseModel
|
||||
public static function clearRequestInstance(): void
|
||||
{
|
||||
self::$instance = null;
|
||||
self::$requestDeptId = null;
|
||||
}
|
||||
|
||||
private static function refreshCacheForModel($model): void
|
||||
{
|
||||
$deptId = AdminScopeHelper::normalizeRecordDeptId(
|
||||
is_array($model) ? ($model['dept_id'] ?? null) : ($model->dept_id ?? null)
|
||||
);
|
||||
self::refreshCache($deptId);
|
||||
}
|
||||
|
||||
public static function onAfterInsert($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
self::refreshCacheForModel($model);
|
||||
}
|
||||
|
||||
public static function onAfterUpdate($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
self::refreshCacheForModel($model);
|
||||
}
|
||||
|
||||
public static function onAfterDelete($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
self::refreshCacheForModel($model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\reward_config;
|
||||
|
||||
use app\dice\helper\AdminScopeHelper;
|
||||
use app\dice\helper\ConfigScopeEditHelper;
|
||||
use app\dice\model\reward\DiceReward;
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
use support\think\Cache;
|
||||
|
||||
/**
|
||||
@@ -27,7 +29,7 @@ use support\think\Cache;
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
*/
|
||||
class DiceRewardConfig extends BaseModel
|
||||
class DiceRewardConfig extends DiceModel
|
||||
{
|
||||
/** 缓存键:彩金池奖励列表实例 */
|
||||
private const CACHE_KEY_INSTANCE = 'dice:reward_config:instance';
|
||||
@@ -45,31 +47,35 @@ class DiceRewardConfig extends BaseModel
|
||||
* 优先从共享缓存读取,保证多进程(如一键测试 worker)能拿到最新配置,与数据库一致
|
||||
* @return array{list: array, by_tier: array, by_tier_grid: array, min_real_ev: float}
|
||||
*/
|
||||
public static function getCachedInstance(): array
|
||||
public static function getCachedInstance(?int $deptId = null): array
|
||||
{
|
||||
$instance = Cache::get(self::CACHE_KEY_INSTANCE);
|
||||
if ($deptId === null) {
|
||||
$deptId = AdminScopeHelper::DEFAULT_TEMPLATE_DEPT;
|
||||
}
|
||||
$cacheKey = self::cacheKeyForDept($deptId);
|
||||
$instance = Cache::get($cacheKey);
|
||||
if ($instance !== null && is_array($instance)) {
|
||||
self::$instance = $instance;
|
||||
return $instance;
|
||||
}
|
||||
if (self::$instance !== null) {
|
||||
return self::$instance;
|
||||
}
|
||||
self::refreshCache();
|
||||
$instance = Cache::get(self::CACHE_KEY_INSTANCE);
|
||||
self::$instance = is_array($instance) ? $instance : self::buildEmptyInstance();
|
||||
return self::$instance;
|
||||
self::refreshCache($deptId);
|
||||
$instance = Cache::get($cacheKey);
|
||||
return is_array($instance) ? $instance : self::buildEmptyInstance();
|
||||
}
|
||||
|
||||
public static function getCachedList(): array
|
||||
private static function cacheKeyForDept(int $deptId): string
|
||||
{
|
||||
$inst = self::getCachedInstance();
|
||||
return self::CACHE_KEY_INSTANCE . ':' . $deptId;
|
||||
}
|
||||
|
||||
public static function getCachedList(?int $deptId = null): array
|
||||
{
|
||||
$inst = self::getCachedInstance($deptId);
|
||||
return $inst['list'] ?? [];
|
||||
}
|
||||
|
||||
public static function getCachedById(int $id): ?array
|
||||
public static function getCachedById(int $id, ?int $deptId = null): ?array
|
||||
{
|
||||
$list = self::getCachedList();
|
||||
$list = self::getCachedList($deptId);
|
||||
foreach ($list as $row) {
|
||||
if (isset($row['id']) && (int) $row['id'] === $id) {
|
||||
return $row;
|
||||
@@ -79,11 +85,16 @@ class DiceRewardConfig extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新从数据库加载并写入缓存(按档位+权重抽 grid_number,含 by_tier、by_tier_grid)
|
||||
* 按渠道从数据库加载并写入缓存(避免多渠道配置混在同一缓存键)
|
||||
*/
|
||||
public static function refreshCache(): void
|
||||
public static function refreshCache(?int $deptId = null): void
|
||||
{
|
||||
$list = (new self())->order('id', 'asc')->select()->toArray();
|
||||
if ($deptId === null) {
|
||||
$deptId = AdminScopeHelper::DEFAULT_TEMPLATE_DEPT;
|
||||
}
|
||||
$query = (new self())->order('id', 'asc');
|
||||
ConfigScopeEditHelper::applyDeptIdWhere($query, $deptId);
|
||||
$list = $query->select()->toArray();
|
||||
$byTier = [];
|
||||
$byTierGrid = [];
|
||||
foreach ($list as $row) {
|
||||
@@ -103,13 +114,16 @@ class DiceRewardConfig extends BaseModel
|
||||
}
|
||||
}
|
||||
$minRealEv = empty($list) ? 0.0 : (float) min(array_column($list, 'real_ev'));
|
||||
self::$instance = [
|
||||
$instance = [
|
||||
'list' => $list,
|
||||
'by_tier' => $byTier,
|
||||
'by_tier_grid' => $byTierGrid,
|
||||
'min_real_ev' => $minRealEv,
|
||||
];
|
||||
Cache::set(self::CACHE_KEY_INSTANCE, self::$instance, self::CACHE_TTL);
|
||||
Cache::set(self::cacheKeyForDept($deptId), $instance, self::CACHE_TTL);
|
||||
if ($deptId === AdminScopeHelper::DEFAULT_TEMPLATE_DEPT) {
|
||||
self::$instance = $instance;
|
||||
}
|
||||
}
|
||||
|
||||
private static function buildEmptyInstance(): array
|
||||
@@ -125,9 +139,9 @@ class DiceRewardConfig extends BaseModel
|
||||
/**
|
||||
* 按档位+色子点数取一条(用于 BIGWIN)
|
||||
*/
|
||||
public static function getCachedByTierAndGridNumber(string $tier, int $gridNumber): ?array
|
||||
public static function getCachedByTierAndGridNumber(string $tier, int $gridNumber, ?int $deptId = null): ?array
|
||||
{
|
||||
$inst = self::getCachedInstance();
|
||||
$inst = self::getCachedInstance($deptId);
|
||||
$byTierGrid = $inst['by_tier_grid'] ?? [];
|
||||
$tierData = $byTierGrid[$tier] ?? [];
|
||||
$row = $tierData[$gridNumber] ?? null;
|
||||
@@ -143,9 +157,9 @@ class DiceRewardConfig extends BaseModel
|
||||
/**
|
||||
* 从缓存按档位取奖励列表(不含权重,仅配置)
|
||||
*/
|
||||
public static function getCachedByTier(string $tier): array
|
||||
public static function getCachedByTier(string $tier, ?int $deptId = null): array
|
||||
{
|
||||
$inst = self::getCachedInstance();
|
||||
$inst = self::getCachedInstance($deptId);
|
||||
$byTier = $inst['by_tier'] ?? [];
|
||||
return $byTier[$tier] ?? [];
|
||||
}
|
||||
@@ -155,10 +169,10 @@ class DiceRewardConfig extends BaseModel
|
||||
* @param int $direction 0=顺时针, 1=逆时针
|
||||
* @return array 每行含 id, grid_number, real_ev, tier, weight 等
|
||||
*/
|
||||
public static function getCachedByTierForDirection(string $tier, int $direction): array
|
||||
public static function getCachedByTierForDirection(string $tier, int $direction, ?int $deptId = null): array
|
||||
{
|
||||
$list = self::getCachedByTier($tier);
|
||||
$weightMap = DiceReward::getCachedByTierAndDirection($tier, $direction);
|
||||
$list = self::getCachedByTier($tier, $deptId);
|
||||
$weightMap = DiceReward::getCachedByTierAndDirection($tier, $direction, $deptId);
|
||||
foreach ($list as $i => $row) {
|
||||
$id = isset($row['id']) ? (int) $row['id'] : 0;
|
||||
$list[$i]['weight'] = $weightMap[$id] ?? 1;
|
||||
@@ -171,19 +185,27 @@ class DiceRewardConfig extends BaseModel
|
||||
self::$instance = null;
|
||||
}
|
||||
|
||||
private static function refreshCacheForModel($model): void
|
||||
{
|
||||
$deptId = AdminScopeHelper::normalizeRecordDeptId(
|
||||
is_array($model) ? ($model['dept_id'] ?? null) : ($model->dept_id ?? null)
|
||||
);
|
||||
self::refreshCache($deptId);
|
||||
}
|
||||
|
||||
public static function onAfterInsert($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
self::refreshCacheForModel($model);
|
||||
}
|
||||
|
||||
public static function onAfterUpdate($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
self::refreshCacheForModel($model);
|
||||
}
|
||||
|
||||
public static function onAfterDelete($model): void
|
||||
{
|
||||
self::refreshCache();
|
||||
self::refreshCacheForModel($model);
|
||||
}
|
||||
|
||||
public function searchGridNumberMinAttr($query, $value)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\reward_config;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
|
||||
/**
|
||||
* 权重配比测试记录模型
|
||||
@@ -20,7 +20,7 @@ use plugin\saiadmin\basic\think\BaseModel;
|
||||
* @property int|null $admin_id 执行测试的管理员ID
|
||||
* @property string|null $create_time 创建时间
|
||||
*/
|
||||
class DiceRewardConfigRecord extends BaseModel
|
||||
class DiceRewardConfigRecord extends DiceModel
|
||||
{
|
||||
protected $pk = 'id';
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace app\dice\model\reward_config_record;
|
||||
|
||||
use app\dice\model\play_record_test\DicePlayRecordTest;
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
use app\dice\model\DiceModel;
|
||||
use think\model\relation\HasMany;
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ use think\model\relation\HasMany;
|
||||
* @property int|null $admin_id 执行测试的管理员ID
|
||||
* @property string|null $create_time 创建时间
|
||||
*/
|
||||
class DiceRewardConfigRecord extends BaseModel
|
||||
class DiceRewardConfigRecord extends DiceModel
|
||||
{
|
||||
/** 状态:失败 */
|
||||
public const STATUS_FAIL = -1;
|
||||
|
||||
Reference in New Issue
Block a user