wip
This commit is contained in:
@@ -2,21 +2,15 @@
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\CardBalance\Actions;
|
||||
|
||||
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Nova\Actions\Action;
|
||||
use Laravel\Nova\Actions\ActionResponse;
|
||||
use Laravel\Nova\Fields\ActionFields;
|
||||
use Laravel\Nova\Fields\Date;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Markwalet\NovaModalResponse\ModalResponse;
|
||||
use Mpdf\Mpdf;
|
||||
|
||||
class DownloadCardBalance extends Action
|
||||
{
|
||||
@@ -34,7 +28,7 @@ class DownloadCardBalance extends Action
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param \Laravel\Nova\Fields\ActionFields $fields
|
||||
* @param \Illuminate\Support\Collection $models
|
||||
* @param \Illuminate\Support\Collection<array-key, \Illuminate\Database\Eloquent\Model> $models
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
@@ -49,20 +43,24 @@ class DownloadCardBalance extends Action
|
||||
return ActionResponse::danger($data->message);
|
||||
}
|
||||
|
||||
return Action::modal('modal-response', [
|
||||
'title' => __('Card balance'),
|
||||
'html' => Blade::render(
|
||||
file_get_contents(app_path('Nova/Resources/Order/Card/CardBalance/Views/card-balance.blade.php')),
|
||||
['data' => $data]
|
||||
)
|
||||
info([
|
||||
'data' => $data,
|
||||
]);
|
||||
|
||||
// return Action::modal('modal-response', [
|
||||
// 'title' => __('Card balance'),
|
||||
// 'html' => Blade::render(
|
||||
// file_get_contents(app_path('Nova/Resources/Order/Card/CardBalance/Views/card-balance.blade.php')),
|
||||
// ['data' => $data]
|
||||
// ),
|
||||
// ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
* @return array<int, \Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
@@ -72,20 +70,38 @@ class DownloadCardBalance extends Action
|
||||
/**
|
||||
* Fetch api
|
||||
*
|
||||
* @param \App\Models\Order\Card\Requisite\CardRequisite $model
|
||||
* @param \App\Models\Order\Card\CardBalance\CardBalance $model
|
||||
*/
|
||||
public function fetchApi($model)
|
||||
public function fetchApi($model): object
|
||||
{
|
||||
$date = today()->format('d.m.Y');
|
||||
|
||||
$response = DownloadCardTransaction::make()->fetchApi(
|
||||
passport_serie: $model->passport_serie,
|
||||
passport_id: $model->passport_id,
|
||||
card_number_masked: Str::mask($model->card_number, '*', 6, 6),
|
||||
card_expire_date: $model->card_month.'/'.substr($model->card_year, 2),
|
||||
start_date: $date,
|
||||
end_date: $date,
|
||||
);
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => 'http://10.3.158.102:9999/api/clientinfo/all',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => sprintf(
|
||||
'{ "idSeria": "%s", "idNo": "%s", "cardMaskNumber": "%s", "expDate": "%s" }',
|
||||
$model->passport_serie,
|
||||
$model->passport_id,
|
||||
Str::mask($model->card_number, '*', 6, 6),
|
||||
$model->card_month.'/'.substr($model->card_year, 2)
|
||||
),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return Str::isJson($response)
|
||||
? json_decode($response)
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Nova\Resource;
|
||||
use App\Nova\Resources\Order\Card\CardBalance\Actions\DownloadCardBalance;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\Hidden;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
@@ -33,7 +32,7 @@ class CardBalance extends Resource
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public static $search = [
|
||||
'unique_id',
|
||||
@@ -81,7 +80,7 @@ class CardBalance extends Resource
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
* @return array<int, \Laravel\Nova\Panel|\Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
@@ -124,44 +123,11 @@ class CardBalance extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cards available for the request.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function cards(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filters available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function filters(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lenses available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function lenses(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
* @return array<int, \Laravel\Nova\Actions\Action>
|
||||
*/
|
||||
public function actions(NovaRequest $request)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ class DownloadCardTransaction extends Action
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param \Laravel\Nova\Fields\ActionFields $fields
|
||||
* @param \Illuminate\Support\Collection $models
|
||||
* @param \Illuminate\Support\Collection<array-key, \Illuminate\Database\Eloquent\Model> $models
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
@@ -77,17 +77,19 @@ class DownloadCardTransaction extends Action
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
* @return array<int, \Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
Date::make(__('Start date'), 'start_date')
|
||||
->default(date('Y-m-d', strtotime('-6 months')))
|
||||
->fullWidth()
|
||||
->rules('required'),
|
||||
|
||||
Date::make(__('End date'), 'end_date')
|
||||
->default(date('Y-m-d'))
|
||||
->fullWidth()
|
||||
->rules('required'),
|
||||
];
|
||||
}
|
||||
@@ -101,6 +103,8 @@ class DownloadCardTransaction extends Action
|
||||
* @param string $card_expire_date
|
||||
* @param string $start_date
|
||||
* @param string $end_date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetchApi(
|
||||
string $passport_serie,
|
||||
@@ -140,7 +144,7 @@ class DownloadCardTransaction extends Action
|
||||
* @param ResponseTypes\AzatApiClientInfoAllResponse $data
|
||||
* @param string $fileDest
|
||||
*/
|
||||
public function generateFile($data, $fileDest)
|
||||
public function generateFile($data, $fileDest): void
|
||||
{
|
||||
$mpdf = new Mpdf;
|
||||
|
||||
@@ -159,7 +163,7 @@ class DownloadCardTransaction extends Action
|
||||
/**
|
||||
* @param ResponseTypes\AzatApiClientInfoAllResponse $data
|
||||
*/
|
||||
public function getExtraVariables($data)
|
||||
public function getExtraVariables($data): object
|
||||
{
|
||||
if (count($data->transactions) < 1) {
|
||||
return emptyClass(basdakyGalyndy: 0, ahyrkyGalyndy: 0, girdeji: 0, cykdajy: 0);
|
||||
|
||||
@@ -38,14 +38,14 @@ class AzatApiClientInfoAllResponse
|
||||
|
||||
public string $phone;
|
||||
|
||||
public string $errCode;
|
||||
public int $errCode;
|
||||
|
||||
public int $message;
|
||||
public string $message;
|
||||
|
||||
public string $messageRu;
|
||||
|
||||
public string $messageEn;
|
||||
|
||||
/** array<int, Object{'trandate': string, 'currency': string, 'opersum': float, 'actionName': string, 'opername': string}> */
|
||||
/** @var array<int, object> */
|
||||
public array $transactions;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Nova\Resource;
|
||||
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\Hidden;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
@@ -33,7 +32,7 @@ class CardTransaction extends Resource
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public static $search = [
|
||||
'unique_id',
|
||||
@@ -81,7 +80,7 @@ class CardTransaction extends Resource
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
* @return array<int, \Laravel\Nova\Panel|\Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
@@ -124,46 +123,13 @@ class CardTransaction extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cards available for the request.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function cards(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filters available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function filters(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lenses available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function lenses(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
* @return array<int, \Laravel\Nova\Actions\Action>
|
||||
*/
|
||||
public function actions(NovaRequest $request)
|
||||
public function actions(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
DownloadCardTransaction::make()
|
||||
|
||||
@@ -22,7 +22,7 @@ class DownloadCardRequisite extends Action
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param \Laravel\Nova\Fields\ActionFields $fields
|
||||
* @param \Illuminate\Support\Collection $models
|
||||
* @param \Illuminate\Support\Collection<array-key, \Illuminate\Database\Eloquent\Model> $models
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
@@ -49,7 +49,7 @@ class DownloadCardRequisite extends Action
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
* @return array<int, \Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
@@ -60,6 +60,7 @@ class DownloadCardRequisite extends Action
|
||||
* Fetch api
|
||||
*
|
||||
* @param \App\Models\Order\Card\Requisite\CardRequisite $model
|
||||
* @return object
|
||||
*/
|
||||
public function fetchApi($model)
|
||||
{
|
||||
@@ -84,6 +85,8 @@ class DownloadCardRequisite extends Action
|
||||
*
|
||||
* @param \App\Models\Order\Card\Requisite\CardRequisite $model
|
||||
* @param \App\Nova\Resources\Order\Card\CardTransaction\Actions\ResponseTypes\AzatApiClientInfoAllResponse $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateFile($model, $data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user