nikarayan and payment service

This commit is contained in:
2024-04-08 12:59:01 +03:30
parent 942a9737b6
commit 92c50280fc
8 changed files with 345 additions and 19 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Services\PaymentService;
use Illuminate\Http\Request;
use App\Models\Province;
use App\Models\City;
@@ -353,10 +354,10 @@ class ReceiptController extends Controller
});
}
public function invoiceBill(Request $request, Accident $accident)
public function invoiceBill(Request $request, Accident $accident, PaymentService $paymentService)
{
try {
DB::transaction(function () use ($request, $accident) {
DB::transaction(function () use ($request, $accident, $paymentService) {
$final_amount = $accident->sum - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount);
@@ -366,7 +367,7 @@ class ReceiptController extends Controller
$accident->final_amount = $final_amount;
$accident->bill_code = $this->invoiceBillApi($accident->driver_national_code, $final_amount);
$accident->bill_code = $paymentService->invoiceBillApi($accident->driver_national_code, $final_amount);
$accident->invoiceBill();
@@ -396,13 +397,13 @@ class ReceiptController extends Controller
return $msg;
}
public function callPaymentStatus(Request $request, Accident $accident)
public function callPaymentStatus(Request $request, Accident $accident, PaymentService $paymentService)
{
try {
DB::transaction(function () use ($request, $accident) {
DB::transaction(function () use ($request, $accident, $paymentService) {
if ($accident->final_amount > 0) {
$response = json_decode($this->callPaymentStatusBillApi(explode("/", $accident->bill_code)[0]));
$response = json_decode($paymentService->callPaymentStatusBillApi(explode("/", $accident->bill_code)[0]));
if ($response->isPayed) {
$accident->payBill();

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\V2\Dashboard;
use App\Http\Controllers\Controller;
use App\Services\NikarayanService;
use Illuminate\Http\Request;
use Hekmatinasser\Verta\Verta;
use Illuminate\Support\Facades\Storage;
@@ -425,7 +426,7 @@ class RoadObservationController extends Controller
], 200);
}
public function handle(Request $request, RoadObserved $roadObserved)
public function handle(Request $request, RoadObserved $roadObserved, NikarayanService $nikarayanService)
{
if (! auth()->user()->hasAnyPermission(['show-fast-react-edarate-shahri', 'show-fast-react-province', 'show-fast-react'])) {
return response()->json([
@@ -498,19 +499,9 @@ class RoadObservationController extends Controller
// if ($file_index > 0) {
// $roadObserved->files()->createMany($files_path);
// }
$url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
// $url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
try {
$array = array('strUserName' => 'vaytelrop',
'strPassword' => 'VaYtelROP*2024',
'strAutoID' => $roadObserved->fk_RegisteredEventMessage,
'strStateID' => ($request->input('rms-status') == 1) ? '2' : '3',
'strDescription' => $request->input('rms-description') ?? $roadObserved->rms_description,
'strPreviousImageLink' => "https://rms.rmto.ir/".$files,
'strNextImageLink' => "https://rms.rmto.ir/".$files,
'strRMSDateAndTime' => $roadObserved->updated_at
);
$soap_client = new SoapClient($url);
$result = $soap_client->UpdateInfo_RoadObservedProblems($array);
$result = $nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, $files);
} catch (SoapFault $e) {
$msg = "error in send to nikarayan at".date("Y-m-d H:i:s")."\n".'rms: error in get road observation webservice babe!!!!'."\n";