m
This commit is contained in:
@@ -11,7 +11,7 @@ interface UserServiceInterface
|
||||
|
||||
public function getOtherActiveUsers(User $currentUser): \Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
public function sendThankcards(User $sender, string $receiverMsnv, int $amount): void;
|
||||
public function sendThankcards(User $sender, string $receiverMsnv, int $amount, ?int $templateId = 1): void;
|
||||
|
||||
public function updatePassword(User $user, string $newPassword): void;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class UserService implements UserServiceInterface
|
||||
->get();
|
||||
}
|
||||
|
||||
public function sendThankcards(User $sender, string $receiverMsnv, int $amount): void
|
||||
public function sendThankcards(User $sender, string $receiverMsnv, int $amount, ?int $templateId = 1): void
|
||||
{
|
||||
if ($sender->flag_send == config('constants.FLAG_SEND_DISABLED')) {
|
||||
throw new \App\Exceptions\ThankCardException(__('messages.error.no_send_permission'));
|
||||
@@ -47,7 +47,7 @@ class UserService implements UserServiceInterface
|
||||
$startOfMonth = Carbon::now()->startOfMonth();
|
||||
$endOfMonth = Carbon::now()->endOfMonth();
|
||||
|
||||
DB::transaction(function () use ($sender, $receiverMsnv, $amount, $startOfMonth, $endOfMonth) {
|
||||
DB::transaction(function () use ($sender, $receiverMsnv, $amount, $startOfMonth, $endOfMonth, $templateId) {
|
||||
// Lock sender record to prevent concurrent transaction modifications
|
||||
$lockedSender = User::where('id', $sender->id)->lockForUpdate()->first();
|
||||
|
||||
@@ -76,21 +76,23 @@ class UserService implements UserServiceInterface
|
||||
}
|
||||
|
||||
Administration::create([
|
||||
'msnv' => $receiverMsnv,
|
||||
'received' => $amount,
|
||||
'sender' => $lockedSender->msnv,
|
||||
'sent' => 0,
|
||||
'receiver' => null,
|
||||
'date' => Carbon::today(),
|
||||
'msnv' => $receiverMsnv,
|
||||
'received' => $amount,
|
||||
'sender' => $lockedSender->msnv,
|
||||
'sent' => 0,
|
||||
'receiver' => null,
|
||||
'date' => Carbon::today(),
|
||||
'template_id' => $templateId,
|
||||
]);
|
||||
|
||||
Administration::create([
|
||||
'msnv' => $lockedSender->msnv,
|
||||
'received' => 0,
|
||||
'sender' => null,
|
||||
'sent' => $amount,
|
||||
'receiver' => $receiverMsnv,
|
||||
'date' => Carbon::today(),
|
||||
'msnv' => $lockedSender->msnv,
|
||||
'received' => 0,
|
||||
'sender' => null,
|
||||
'sent' => $amount,
|
||||
'receiver' => $receiverMsnv,
|
||||
'date' => Carbon::today(),
|
||||
'template_id' => $templateId,
|
||||
]);
|
||||
|
||||
$lockedSender->card -= $amount;
|
||||
|
||||
Reference in New Issue
Block a user