钱包修改
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user