钱包修改

This commit is contained in:
2026-04-17 11:53:19 +08:00
parent 7f3a7c34f0
commit ad74accfcc
10 changed files with 136 additions and 24 deletions

View File

@@ -17,27 +17,6 @@ class UserScoreLog extends model
protected $autoWriteTimestamp = true;
protected $updateTime = false;
/**
* 入库前
* @throws Throwable
*/
public static function onBeforeInsert($model): void
{
$user = User::where('id', $model->user_id)->lock(true)->find();
if (!$user) {
throw new Exception("The user can't find it");
}
if (!$model->memo) {
throw new Exception("Change note cannot be blank");
}
$model->before = $user->score;
$user->score += $model->score;
$user->save();
$model->after = $user->score;
}
public static function onBeforeDelete(): bool
{
return false;