diff --git a/app/Service/v3/Implementations/FinancialRecordService.php b/app/Service/v3/Implementations/FinancialRecordService.php index 72bf54f..b4c020d 100644 --- a/app/Service/v3/Implementations/FinancialRecordService.php +++ b/app/Service/v3/Implementations/FinancialRecordService.php @@ -40,7 +40,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface } // 获取当前用户的流水前余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $record['user_type'], 'source_id' => $user_id ]); @@ -78,7 +78,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护社区服务点余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -103,7 +103,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护社区服务点余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -127,7 +127,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护社区服务点余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -152,7 +152,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -176,7 +176,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -253,7 +253,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -277,7 +277,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -385,7 +385,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface { $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -424,7 +424,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -449,7 +449,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -474,7 +474,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -499,7 +499,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]); @@ -524,7 +524,7 @@ class FinancialRecordService implements FinancialRecordServiceInterface $this->recordAll($user_id, $source_id, $money, $user_type, $source_type, $money_type, $desc, $comment); // 维护余额 - $balance = UserBalance::query()->firstOrNew([ + $balance = UserBalance::query()->lockForUpdate()->firstOrNew([ 'user_type' => $user_type, 'source_id' => $user_id ]);