新增统计,小游戏,系统设置

This commit is contained in:
2026-06-11 13:49:20 +08:00
parent 3120c56620
commit 064ba727e0
11 changed files with 827 additions and 144 deletions

View File

@@ -2,11 +2,9 @@
namespace app\admin\model;
use think\Exception;
use think\model;
use think\model\relation\BelongsTo;
use Throwable;
use app\admin\model\UserScoreLog;
/**
* UserScoreLog 模型
@@ -29,6 +27,11 @@ class UserScore extends model
if (bccomp($before, $after, 2) !== 0) {
// 计算分值变动after - before
$change = bcsub($after, $before);
if ($change >= 0) {
$type = 1;
} else {
$type = 2;
}
$userScoreLog = new UserScoreLog();
$userScoreLog->save([
'user_id' => $model->user_id,
@@ -36,7 +39,9 @@ class UserScore extends model
'before' => $before,
'after' => $after,
'score' => $change,
'memo' => '管理员手动调整', // 建议增加备注字段区分来源
'memo' => $model->memo ?? '',
'type' => $type,
'created_by'=> $model->created_by ?? null,
]);
}
}