some progress on card balance
This commit is contained in:
1 parent
e19372eed1
commit
a07bcd3a5b
6 files changed
+350
-2
No files matched your search
@@ -6,7 +6,9 @@
|
|||||||
use App\Filament\Clusters\Cards\CardsCluster;
|
use App\Filament\Clusters\Cards\CardsCluster;
|
||||||
use App\Modules\AppHelpers\Repositories\DateHelper;
|
use App\Modules\AppHelpers\Repositories\DateHelper;
|
||||||
use App\Modules\Card\Models\Card;
|
use App\Modules\Card\Models\Card;
|
||||||
|
use App\Modules\CardBalance\Repositories\CardBalanceRepository;
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\DeleteAction;
|
use Filament\Actions\DeleteAction;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
@@ -19,6 +21,7 @@
|
|||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class CardResource extends Resource
|
class CardResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -114,8 +117,29 @@ public static function table(Table $table): Table
|
|||||||
//
|
//
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make(),
|
Action::make('card_balance')
|
||||||
DeleteAction::make(),
|
->label(__('Card balance'))
|
||||||
|
->icon('heroicon-m-credit-card')
|
||||||
|
->modalContent(function (Card $record) {
|
||||||
|
/** @var \App\Modules\CardBalance\Type\CardBalanceResponse */
|
||||||
|
$data = CardBalanceRepository::make()->fetchCardBalance(
|
||||||
|
passport_serie: user()->getOption('passport_serie'),
|
||||||
|
passport_id: user()->getOption('passport_id'),
|
||||||
|
card_masked: Str::mask($record->number, '*', 6, 6),
|
||||||
|
card_expire_date: $record->month.'/'.substr($record->year, 2),
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($data->errCode != 0) {
|
||||||
|
return $data->message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('module.card-balance::card-balance-modal', compact('data'));
|
||||||
|
}),
|
||||||
|
|
||||||
|
EditAction::make()
|
||||||
|
->label(''),
|
||||||
|
DeleteAction::make()
|
||||||
|
->label(''),
|
||||||
])
|
])
|
||||||
->toolbarActions([
|
->toolbarActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\CardBalance;
|
||||||
|
|
||||||
|
use App\Modules\Makeable;
|
||||||
|
use App\Modules\ModuleContract;
|
||||||
|
|
||||||
|
class CardBalanceModule implements ModuleContract
|
||||||
|
{
|
||||||
|
use Makeable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module is enabled
|
||||||
|
*/
|
||||||
|
protected bool $enabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if is module enabled
|
||||||
|
*/
|
||||||
|
public function isEnabled(): bool
|
||||||
|
{
|
||||||
|
return $this->enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable module
|
||||||
|
*/
|
||||||
|
public function disable(): void
|
||||||
|
{
|
||||||
|
$this->enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable module
|
||||||
|
*/
|
||||||
|
public function enable(): void
|
||||||
|
{
|
||||||
|
$this->enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if module has a filament resource
|
||||||
|
*/
|
||||||
|
public function hasFilamentResource(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer requirements
|
||||||
|
*/
|
||||||
|
public function getComposerRequirements(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer suggestions
|
||||||
|
*/
|
||||||
|
public function getComposerSuggestions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\CardBalance\Repositories;
|
||||||
|
|
||||||
|
use App\Modules\Card\Models\Card;
|
||||||
|
use App\Modules\Makeable;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class CardBalanceRepository
|
||||||
|
{
|
||||||
|
use Makeable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show card balance
|
||||||
|
* @param Card $record
|
||||||
|
*/
|
||||||
|
public function showCardBalance(Card $record)
|
||||||
|
{
|
||||||
|
/** @var \App\Modules\CardBalance\Type\CardBalanceResponse */
|
||||||
|
$data = $this->fetchCardBalance(
|
||||||
|
passport_serie: user()->getOption('passport_serie'),
|
||||||
|
passport_id: user()->getOption('passport_id'),
|
||||||
|
card_masked: Str::mask($record->number, '*', 6, 6),
|
||||||
|
card_expire_date: $record->month.'/'.substr($record->year, 2),
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($data->errCode != 0) {
|
||||||
|
return $data->message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('module.card-balance::card-balance-modal', compact('data'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch card balance
|
||||||
|
*
|
||||||
|
* @param string|int $passport_serie
|
||||||
|
* @param string|int $passport_id
|
||||||
|
* @param string $card_masked
|
||||||
|
* @param string $card_expire_date
|
||||||
|
*/
|
||||||
|
public function fetchCardBalance($passport_serie, $passport_id, $card_masked, $card_expire_date): object
|
||||||
|
{
|
||||||
|
$curl = curl_init();
|
||||||
|
|
||||||
|
curl_setopt_array($curl, [
|
||||||
|
CURLOPT_URL => 'http://10.3.158.102:9999/api/clientcardinfo',
|
||||||
|
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"
|
||||||
|
}', $passport_serie, $passport_id, $card_masked, $card_expire_date),
|
||||||
|
CURLOPT_HTTPHEADER => [
|
||||||
|
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
|
||||||
|
'Content-Type: application/json',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
|
||||||
|
curl_close($curl);
|
||||||
|
|
||||||
|
return Str::isJson($response)
|
||||||
|
? json_decode($response)
|
||||||
|
: emptyClass(errCode: 1, message: 'Connection issue to VP');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Card Balance</title>
|
||||||
|
<style>
|
||||||
|
a,hr{color:inherit}progress,sub,sup{vertical-align:baseline}blockquote,body,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,menu,ol,p,pre,ul{margin:0}.p-0,dialog,fieldset,legend,menu,ol,ul{padding:0}*,:after,:before{--font-sans:'Inter Variable'}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:var(--font-sans),ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{line-height:inherit;font-synthesis-weight:none;text-rendering:optimizeLegibility}hr{height:0;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--font-mono),ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}menu,ol,ul{list-style:none}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}*{border-color:hsl(var(--border))}html{scroll-behavior:smooth}.mb-2{margin-bottom:.5rem}.mb-8{margin-bottom:2rem}.flex{display:flex}.inline-flex{display:inline-flex}.grid{display:grid}.h-10{height:2.5rem}.h-4{height:1rem}.h-6{height:1.5rem}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-4{width:1rem}.w-6{width:1.5rem}.w-full{width:100%}.max-w-md{max-width:28rem}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.whitespace-nowrap{white-space:nowrap}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.border{border-width:1px}.bg-card{background-color:hsl(var(--card))}.p-4{padding:1rem}.p-6{padding:1.5rem}.font-mono{font-family:var(--font-mono),ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.uppercase{text-transform:uppercase}.tracking-wider{letter-spacing:.05em}.text-card-foreground{color:hsl(var(--card-foreground))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity,1))}.shadow-lg{--tw-shadow:0 10px 15px -3px rgb(0 0 0 / 0.1),0 4px 6px -4px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,-webkit-text-decoration-color;transition-timing-function:cubic-bezier(0.4,0,0.2,1);transition-duration:150ms}@keyframes enter{from{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw
Line truncated
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="flex items-center justify-center p-4" style="background-color: rgb(241, 245, 249);">
|
||||||
|
<div class="rounded-lg bg-card text-card-foreground w-full max-w-md border shadow-lg" data-v0-t="card" style="background-color: rgb(255, 255, 255); border-color: rgb(226, 232, 240);">
|
||||||
|
<div class="p-6">
|
||||||
|
<div class="flex items-center gap-3 mb-8">
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<img src="/assets/images/logo.svg" width="55" height="55" alt="">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h1 class="text-xl font-bold" style="color: rgb(30, 41, 59);">{{ $data->depName }}</h1>
|
||||||
|
<p class="text-sm" style="color: rgb(100, 116, 139);">{{ $data->cardName }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-6">
|
||||||
|
<div>
|
||||||
|
<p class="text-xs uppercase tracking-wider mb-2" style="color: rgb(100, 116, 139);">
|
||||||
|
{{ __('Card number') }}
|
||||||
|
</p>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<p class="text-lg font-mono tracking-wider" style="color: rgb(30, 41, 59);">
|
||||||
|
{{ $data->cardMaskNumber }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<p class="text-xs uppercase tracking-wider mb-2" style="color: rgb(100, 116, 139);">
|
||||||
|
{{ __('Card holder name') }}
|
||||||
|
</p>
|
||||||
|
<p class="text-sm font-medium" style="color: rgb(30, 41, 59);">
|
||||||
|
{{ $data->clientName }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="text-xs uppercase tracking-wider mb-2" style="color: rgb(100, 116, 139);">
|
||||||
|
{{ __('Expiry date') }}
|
||||||
|
</p>
|
||||||
|
<p class="text-sm font-medium" style="color: rgb(30, 41, 59);">
|
||||||
|
{{ $data->expDate }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="rounded-lg p-4 border" style="background-color: rgb(248, 250, 252); border-color: rgb(226, 232, 240);">
|
||||||
|
<div class="flex items-center justify-between mb-2">
|
||||||
|
<p class="text-xs uppercase tracking-wider" style="color: rgb(100, 116, 139);">
|
||||||
|
{{ __('Money Balance') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<p class="text-2xl font-bold" style="color: rgb(5, 150, 105);">
|
||||||
|
{{ $data->balance }} {{ $data->valCode }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\CardBalance\Type;
|
||||||
|
|
||||||
|
class CardBalanceResponse
|
||||||
|
{
|
||||||
|
public string $idSeria;
|
||||||
|
|
||||||
|
public string $idNo;
|
||||||
|
|
||||||
|
public string $cardMaskNumber;
|
||||||
|
|
||||||
|
public string $expDate;
|
||||||
|
|
||||||
|
public string $clientType;
|
||||||
|
|
||||||
|
public string $fromDate;
|
||||||
|
|
||||||
|
public string $toDate;
|
||||||
|
|
||||||
|
public string $clientName;
|
||||||
|
|
||||||
|
public string $depName;
|
||||||
|
|
||||||
|
public string $cardName;
|
||||||
|
|
||||||
|
public string $cardPan;
|
||||||
|
|
||||||
|
public string $cardAccountNumber;
|
||||||
|
|
||||||
|
public string $birthDate;
|
||||||
|
|
||||||
|
public string $mfo;
|
||||||
|
|
||||||
|
public string $inn;
|
||||||
|
|
||||||
|
public string $passOrg;
|
||||||
|
|
||||||
|
public string $passDate;
|
||||||
|
|
||||||
|
public string $address;
|
||||||
|
|
||||||
|
public string $phone;
|
||||||
|
|
||||||
|
public string $accountNumber;
|
||||||
|
|
||||||
|
public int $errCode;
|
||||||
|
|
||||||
|
public string $message;
|
||||||
|
|
||||||
|
public string $messageRu;
|
||||||
|
|
||||||
|
public string $messageEn;
|
||||||
|
|
||||||
|
/** @var array<int, object> */
|
||||||
|
public array $transactions;
|
||||||
|
}
|
||||||
@@ -45,3 +45,63 @@ function emptyModule(): ModuleContract
|
|||||||
{
|
{
|
||||||
return modular()->emptyModule();
|
return modular()->emptyModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an anonymous class that acts as a dynamic object.
|
||||||
|
*
|
||||||
|
* @param mixed ...$arguments Key-value pairs passed as an associative array.
|
||||||
|
* @return object Anonymous class instance with dynamic properties.
|
||||||
|
*/
|
||||||
|
function emptyClass(...$arguments): object
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array<string, mixed> $arguments
|
||||||
|
*/
|
||||||
|
return new class($arguments)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Internal data storage.
|
||||||
|
*
|
||||||
|
* @var array<string, mixed>
|
||||||
|
*/
|
||||||
|
private array $data = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor that sets properties.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $props
|
||||||
|
*/
|
||||||
|
public function __construct(array $props)
|
||||||
|
{
|
||||||
|
foreach ($props as $key => $value) {
|
||||||
|
$this->data[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic getter.
|
||||||
|
*
|
||||||
|
* @return mixed|null
|
||||||
|
*/
|
||||||
|
public function __get(string $key): mixed
|
||||||
|
{
|
||||||
|
return $this->data[$key] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic setter.
|
||||||
|
*/
|
||||||
|
public function __set(string $key, mixed $value): void
|
||||||
|
{
|
||||||
|
$this->data[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic isset.
|
||||||
|
*/
|
||||||
|
public function __isset(string $key): bool
|
||||||
|
{
|
||||||
|
return isset($this->data[$key]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in new issue
Block a user