新增统计,小游戏,系统设置
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user