add cache lock
This commit is contained in:
@@ -51,6 +51,7 @@ class DamageManagementController extends Controller
|
||||
'unit' => $request->unit,
|
||||
'base_price' => $request->base_price,
|
||||
'status' => 1,
|
||||
'update_time' => now()
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
@@ -76,6 +77,7 @@ class DamageManagementController extends Controller
|
||||
'title' => $request->title,
|
||||
'unit' => $request->unit,
|
||||
'base_price' => $request->base_price,
|
||||
'update_time' => now()
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
|
||||
@@ -23,6 +23,7 @@ use App\Services\NominatimService;
|
||||
use App\Services\PaymentService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
@@ -283,6 +284,9 @@ class AccidentReceiptController extends Controller
|
||||
*/
|
||||
public function submitInvoice(Accident $accident, PaymentService $paymentService, SubmitInvoiceRequest $request): JsonResponse
|
||||
{
|
||||
$lock = Cache::lock("accidentPayment-{$accident->id}", 10);
|
||||
throw_if(!$lock->get(), new ProhibitedAction('امکان درخواست مجدد تا 10 ثانیه دیگر وجود ندارد'));
|
||||
|
||||
$final_amount = $accident->driver_share_amount - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount);
|
||||
|
||||
throw_if($final_amount < 0, new ProhibitedAction('مبالغ داغی و بیمه از مبلغ کل بیشتر می باشد.'));
|
||||
@@ -305,6 +309,8 @@ class AccidentReceiptController extends Controller
|
||||
|
||||
Sms::sendSms($accident->driver_phone_number, $msg);
|
||||
|
||||
$lock->release();
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user