49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace app\admin\model;
|
|
|
|
use Throwable;
|
|
use think\model;
|
|
use think\Exception;
|
|
use think\model\relation\BelongsTo;
|
|
|
|
/**
|
|
* UserScoreLog 模型
|
|
* 1. 创建积分日志自动完成会员积分的添加
|
|
* 2. 创建积分日志时,请开启事务
|
|
*/
|
|
class UserScoreLog extends model
|
|
{
|
|
protected $autoWriteTimestamp = true;
|
|
protected $updateTime = false;
|
|
|
|
const GAME_TYPE_LIST = [
|
|
1001 => 'Lucky Wheel', // 大转盘
|
|
1002 => 'Golden Eggs', // 砸金蛋
|
|
1003 => 'Daily Mission', // 每日任务
|
|
1004 => 'Plinko Ball', // 普林科弹球
|
|
];
|
|
|
|
public static function onBeforeDelete(): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
public function getGameTypeTextAttr($value, $data)
|
|
{
|
|
$gameType = $data['game_type'] ?? 0;
|
|
|
|
// 如果需要严格的多语言,可以在这里根据 $lang 切换,或者直接配合系统的 lang() 助手函数
|
|
// 这里我们先直接返回对应的标准国际化名称
|
|
return self::GAME_TYPE_LIST[$gameType] ?? 'Unknown Game';
|
|
}
|
|
|
|
// 3. 别忘了把获取器追加到模型的可见输出数组里
|
|
protected $append = ['game_type_text'];
|
|
|
|
} |