Compare commits
275 Commits
f93ce0ba88
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| aaacac26d6 | |||
| 377acc18cf | |||
| c05a6972b8 | |||
| 1b27664780 | |||
| 03c692adbb | |||
| 2bd2c45ddb | |||
| e98674aa26 | |||
| d0d49d6517 | |||
| 45ca714b17 | |||
| 924ed64527 | |||
| ca2112d0e6 | |||
| 395e400b7f | |||
| 4d562baacd | |||
| 3e7d246273 | |||
| e6488343c1 | |||
| e5b600df5b | |||
| db3800921e | |||
| 2b2704f6d2 | |||
| 8ecf58de7c | |||
| f81acada2c | |||
| c336af2b6f | |||
| 9fc7d5c1e4 | |||
| 3c3d74ec34 | |||
| 33ec2e11e6 | |||
| 475c21af85 | |||
| fa41d7b9b0 | |||
| 328c2829f7 | |||
| 9b961ef647 | |||
| e736b8501d | |||
| 07a6679e9f | |||
| 50996ddacd | |||
| ef7c30a235 | |||
| 7ca24207fb | |||
| e64cf34c90 | |||
| 673042dd32 | |||
| 84348a1807 | |||
| 9f22e506b2 | |||
| 067ae91c2e | |||
| 82c17b41f6 | |||
| 4b0334fc48 | |||
| 5245f484a0 | |||
| 19f87050dd | |||
| 23ee71f4a4 | |||
| 5896fe4d56 | |||
| 76f6f1c3a3 | |||
| a622f7651a | |||
| a1521ace7a | |||
| d157c21883 | |||
| 6dab1a38c6 | |||
| a5e086237e | |||
| 44613f944e | |||
| 4ff92fe530 | |||
| 051ec52547 | |||
| 9cecd6c465 | |||
| 71e0f1c18d | |||
| 741de26eea | |||
| 574176e4b2 | |||
| 8d7633048b | |||
| 3a6a871c2f | |||
| bf21918a5a | |||
| f138a6c7cb | |||
| f2a94c3c49 | |||
| 4d4a499a56 | |||
| d89f86a534 | |||
| b8bdea33cb | |||
| 5a4759a137 | |||
| 161f993099 | |||
| d4a4c3d3f4 | |||
| 146266226b | |||
| 2e82b19563 | |||
| fc95d6c9f9 | |||
| 2368ea2a50 | |||
| 6aa44e3fa5 | |||
| f610474328 | |||
| 4f1dd64fba | |||
| 6abfc4ac48 | |||
| 7617e08632 | |||
| 84c0e99004 | |||
| 548d1040bb | |||
| df2f2979b5 | |||
| 5c6aff312a | |||
| 7513d6a9a9 | |||
| ffd43d32c2 | |||
| b5e57bccc8 | |||
| 1c00a28744 | |||
| c0dd8f269a | |||
| b3ed503742 | |||
| 014da27f66 | |||
| 2453fac7cf | |||
| fa04f374aa | |||
| 96c3122b2a | |||
| 78d7065b86 | |||
| daaa3bc360 | |||
| 3e04b17edf | |||
| ed65172b07 | |||
| 40565033b6 | |||
| 5cb2f9027c | |||
| 0b63d9098e | |||
| 4e1f286eb5 | |||
| 7efad097ef | |||
| 03d3e03f35 | |||
| 9186bc73e1 | |||
| 840358cc6a | |||
| 90c053689b | |||
| c7d6d947c9 | |||
| 9a330c18ad | |||
| cc31403a8a | |||
| 1b918348e5 | |||
| 640457b979 | |||
| c54535e197 | |||
| 5b4fa96956 | |||
| 2a840e3cc5 | |||
| df0a5eb329 | |||
| 53100e6be3 | |||
| cf8146fb4c | |||
| b509a23f7a | |||
| 44217fb8b9 | |||
| 975d03d2a1 | |||
| 3ad4a3b86b | |||
| ee555e899c | |||
| 054e2de5e6 | |||
| ea9b028c23 | |||
| 9c236aa8a8 | |||
| 5ebf573da2 | |||
| c348416c05 | |||
| 7c623e802f | |||
| 7d2ad13ae7 | |||
| 67457b5bc7 | |||
| f2564221ca | |||
| 703ae1bb0b | |||
| 028f11da9c | |||
| 0480ebad91 | |||
| eefe130ad3 | |||
| 772ac9ad0f | |||
| 5732d7eabe | |||
| 5abe97e20c | |||
| 405967fcea | |||
| 4d75c110e9 | |||
| afeefc7aed | |||
| 8a96772634 | |||
| eca675ae68 | |||
| 3d07137f71 | |||
| 652edb0896 | |||
| d9c463b427 | |||
| 1746ba4a60 | |||
| cfcfdefc36 | |||
| 647979fdef | |||
| aaf8d067f9 | |||
| 6eb3628fd8 | |||
| f257559f42 | |||
| 6540668f9f | |||
| 251c19319a | |||
| 8ce7bd981a | |||
| 094232cc79 | |||
| 571b422454 | |||
| df985789f1 | |||
| 5bfe3a955c | |||
| 67f5eadec8 | |||
| 61e0a45708 | |||
| b0a2b50ec7 | |||
| b883f0f66d | |||
| 0248aa7422 | |||
| fa4cf3eebc | |||
| 88370db5da | |||
| 95696a54c9 | |||
| 4b0a2566a4 | |||
| 85e776f18f | |||
| ef1a0b8cf7 | |||
| e60530fc00 | |||
| b795a84503 | |||
| fd7e11a21a | |||
| d1c690ba4c | |||
| 915d32a121 | |||
| b7b3f3ded4 | |||
| c2298d1550 | |||
| 66af4f913a | |||
| e72f494da7 | |||
| 26714e4192 | |||
| 2265958317 | |||
| de4d74f849 | |||
| d90e2966c7 | |||
| 3583f49a9b | |||
| b81e9c7d31 | |||
| 7c541ab9af | |||
| fb063215d2 | |||
| bf30d27526 | |||
| 8a8ac40a2a | |||
| 9f29e13322 | |||
| 689f50e2e6 | |||
| 96a949f421 | |||
| 135008e7df | |||
| 438bfa26f6 | |||
| 990ef13691 | |||
| a86d9be969 | |||
| 6b1624c4ec | |||
| 198b35a007 | |||
| 57a255a928 | |||
| 501966f94c | |||
| 8b68068587 | |||
| 193e7801c5 | |||
| 7505ea4c05 | |||
| fe97a26ebb | |||
| 5dfce35a84 | |||
| 10361e9422 | |||
| 8acc40d53f | |||
| f375791d5d | |||
| 589a3ed988 | |||
| bdfd550f4e | |||
| 390235ef5b | |||
| 7136873b24 | |||
| 0a60f0f3f7 | |||
| b5aea2a98d | |||
| fe7f643420 | |||
| 2ab46a862f | |||
| 259dba3bd3 | |||
| 8f7e9131f9 | |||
| 0e146e23a2 | |||
| 442cdb1ec9 | |||
| be1c72e3e2 | |||
| 4dd345253c | |||
| c782e6fdf2 | |||
| 92f0eeb2e0 | |||
| 8d0b21aee1 | |||
| 6cbb54c74b | |||
| 9123eed007 | |||
| 0035c604e1 | |||
| b81de72c4e | |||
| e69de6f5dd | |||
| 505f6bb37b | |||
| 1b96fb1a99 | |||
| 5bbce48bf1 | |||
| 90b1e82518 | |||
| eb55263a1c | |||
| c99e98cd1a | |||
| c98560359c | |||
| a2864cb376 | |||
| 615eb3da0d | |||
| 72745e6360 | |||
| 10e6a6bbed | |||
| 6d22e1f51e | |||
| c37391f165 | |||
| bf69695439 | |||
| 5d32857472 | |||
| 1bd7035227 | |||
| 0a4220707e | |||
| f6743c7ffc | |||
| 78b4729a5d | |||
| 0796806a8b | |||
| 9dde39e851 | |||
| 3dc1496b45 | |||
| d0d26039d3 | |||
| 808742b781 | |||
| 3c94fb0501 | |||
| 7e1960779b | |||
| 4af1363b8b | |||
| b87afba780 | |||
| 45694ce3d8 | |||
| ae92e2adde | |||
| 51657eaba2 | |||
| 991bf6fd40 | |||
| b4ae9293b9 | |||
| 29b128f5ab | |||
| 778bd9030c | |||
| ebded8c39d | |||
| 7433f2125c | |||
| cc54713a6a | |||
| a3a5871cd5 | |||
| 80fc1c6316 | |||
| f165bdb8c1 | |||
| 88ef230b17 | |||
| 5c5c8ba655 | |||
| ba90905c48 | |||
| 97b76b29d9 | |||
| bf33e14e43 | |||
| 09df813425 |
@@ -1,7 +1,11 @@
|
||||
@servers(['web' => ['nurmuhammet@online.tbbank.gov.tm']])
|
||||
@servers([
|
||||
'web' => ['nurmuhammet@online.tbbank.gov.tm']
|
||||
])
|
||||
|
||||
@task('deploy', ['on' => 'web'])
|
||||
sudo su
|
||||
cd /var/www/online.tbbank.gov.tm
|
||||
git pull
|
||||
exit
|
||||
exit
|
||||
@endtask
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Jobs\SendSberToSystem;
|
||||
use App\Jobs\SendVisaToSystem;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
@@ -12,7 +14,11 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
$schedule->command('backup:run')->saturdays();
|
||||
$schedule->job(new SendSberToSystem)
|
||||
->everyMinute();
|
||||
|
||||
$schedule->job(new SendVisaToSystem)
|
||||
->everyMinute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
8
app/Contracts/Paymentable.php
Normal file
8
app/Contracts/Paymentable.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
*/
|
||||
interface Paymentable {}
|
||||
@@ -1,14 +1,20 @@
|
||||
<?php
|
||||
|
||||
use App\Events\EventType;
|
||||
use App\Models\Payment\OnlinePaymentHistory;
|
||||
use App\Models\System\Roles\Permission;
|
||||
use App\Models\System\Verification;
|
||||
use App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem;
|
||||
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem;
|
||||
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Psr7\Request as GuzzleRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Stevebauman\Location\Facades\Location;
|
||||
use Symfony\Component\HttpFoundation\IpUtils;
|
||||
|
||||
@@ -65,7 +71,7 @@ function isTurkmenIp(string $ip = ''): bool
|
||||
}
|
||||
|
||||
/**
|
||||
* Un mask phone from "+(993)-xx-xx-xx-xx"
|
||||
* Un mask phone
|
||||
*/
|
||||
function unMaskPhone(string|int $phone): string
|
||||
{
|
||||
@@ -114,7 +120,7 @@ function sendSMS(string|int $phone, string|int $message)
|
||||
*/
|
||||
function sendSMSVerification(string|int $phone_number): ?Verification
|
||||
{
|
||||
$phone_code = rand(10000, 99999);
|
||||
$phone_code = rand(100000, 999999);
|
||||
$verification = Verification::where(['username' => $phone_number])->first();
|
||||
$verification ? $verification->update(['code' => $phone_code]) : Verification::create(['username' => $phone_number, 'code' => $phone_code]);
|
||||
|
||||
@@ -141,7 +147,7 @@ function storeAuthEvent(string $name, Request $request): void
|
||||
$request->getPort(),
|
||||
isLocalIp($request->ip())
|
||||
? 'TM'
|
||||
: Location::get($request->ip())?->countryCode ?? 'TM',
|
||||
: Location::get('95.85.34.23')?->countryCode ?? 'TM',
|
||||
$request->user()->id ?? '-',
|
||||
));
|
||||
}
|
||||
@@ -290,9 +296,463 @@ function cached(string $name, mixed $value, int $seconds = 60): mixed
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* view-loan-order-permission-id
|
||||
*/
|
||||
function view_loan_order_permission_id(): int
|
||||
{
|
||||
return Cache::rememberForever('view_loan_order_permission_id', function () {
|
||||
return Permission::query()->where('name', 'ViewLoanOrders')->first(['id', 'name'])->id;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* VP fetch client info all
|
||||
*
|
||||
* @param $model
|
||||
* @param $start_date
|
||||
* @param $end_date
|
||||
*/
|
||||
function vp_fetch_ClientInfoAll($model, $start_date, $end_date)
|
||||
{
|
||||
return fetchCardTransactionFromAzat(
|
||||
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: $start_date,
|
||||
end_date: $end_date,
|
||||
);
|
||||
}
|
||||
|
||||
function fetchCardTransactionFromAzat($passport_serie, $passport_id, $card_number_masked, $card_expire_date, $start_date, $end_date)
|
||||
{
|
||||
$response = DownloadCardTransaction::make()->fetchApi($passport_serie, $passport_id, $card_number_masked, $card_expire_date, $start_date, $end_date);
|
||||
|
||||
return Str::isJson($response)
|
||||
? json_decode($response)
|
||||
: emptyClass(errCode: 1, message: 'Connection issue to VP');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function __get(string $key): mixed
|
||||
{
|
||||
return $this->data[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic setter.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function __set(string $key, mixed $value): void
|
||||
{
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic isset.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset(string $key): bool
|
||||
{
|
||||
return isset($this->data[$key]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check online payment
|
||||
*
|
||||
* @param string $orderId
|
||||
* @param int|string $username
|
||||
* @param string $password
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function checkOnlinePayment(string $orderId, int|string $username, string $password): mixed
|
||||
{
|
||||
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatusExtended.do', [
|
||||
'language' => 'ru',
|
||||
'orderId' => $orderId,
|
||||
'userName' => $username,
|
||||
'password' => $password,
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync with bank system
|
||||
*
|
||||
* @param string $online_payment_order_uuid
|
||||
* @param string $bank_unique_code
|
||||
* @param string $online_payment_terminal_id
|
||||
* @param string $user_deposit_account
|
||||
* @param string $online_payment_auth_ref_num
|
||||
* @param string $online_payment_tmt_amount
|
||||
* @param string $pay_purpose
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function syncWithBankSystem(
|
||||
$online_payment_order_uuid,
|
||||
$bank_unique_code,
|
||||
$online_payment_terminal_id,
|
||||
$user_deposit_account,
|
||||
$online_payment_auth_ref_num,
|
||||
$online_payment_tmt_amount,
|
||||
$pay_purpose
|
||||
): mixed {
|
||||
$ecomId = $online_payment_order_uuid;
|
||||
$agentId = $bank_unique_code;
|
||||
$eposId = $online_payment_terminal_id;
|
||||
$account = $user_deposit_account;
|
||||
$rrn = $online_payment_auth_ref_num;
|
||||
$amount = $online_payment_tmt_amount;
|
||||
$payPurpose = $pay_purpose;
|
||||
|
||||
$client = new Client([
|
||||
'timeout' => 5, // seconds before it fails
|
||||
'connect_timeout' => 1, // seconds to wait for connection
|
||||
]);
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => 'Basic YWRtaW46UUFad3N4MTIz',
|
||||
];
|
||||
$body = sprintf('{
|
||||
"ecomId": "%s",
|
||||
"agentId": "%s",
|
||||
"eposId": "%s",
|
||||
"account": "%s",
|
||||
"rrn": "%s",
|
||||
"amount": "%s",
|
||||
"payPurpose": "%s"
|
||||
}', $ecomId, $agentId, $eposId, $account, $rrn, $amount, $payPurpose);
|
||||
|
||||
$request = new GuzzleRequest('POST', 'http://10.3.158.102:8888/api/paytrn/new', $headers, $body);
|
||||
|
||||
try {
|
||||
$res = $client->sendAsync($request)->wait();
|
||||
|
||||
return (string) $res->getBody();
|
||||
} catch (Exception $e) {
|
||||
info([$e->getMessage(), $e->getTraceAsString()]);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Sber credentials for a given payment item.
|
||||
*
|
||||
* @param SberPaymentOrderItem $item
|
||||
* @return array{username?: string, password?: string, onlinePaymentResource?: OnlinePaymentHistory, relatedResource?: mixed, error?: string, type?: 'danger'|'modal'}
|
||||
*/
|
||||
function getSberCredentials(SberPaymentOrderItem $item): array
|
||||
{
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory|null $onlinePaymentResource */
|
||||
$onlinePaymentResource = OnlinePaymentHistory::find($item->online_payment_history_id);
|
||||
|
||||
if (! $onlinePaymentResource) {
|
||||
return ['error' => 'Online payment resource tapylmady', 'type' => 'danger'];
|
||||
}
|
||||
|
||||
$relatedResource = (new $onlinePaymentResource->online_paymantable_type)
|
||||
->find(id: $onlinePaymentResource->online_paymantable_id);
|
||||
|
||||
if (! $relatedResource) {
|
||||
return ['error' => 'Bu resource tapylmady', 'type' => 'danger'];
|
||||
}
|
||||
|
||||
$relatedResource->loadMissing(['branch']);
|
||||
|
||||
if (! $relatedResource->branch) {
|
||||
return ['error' => 'Şahamça bilen birikdirilmedik', 'type' => 'danger'];
|
||||
}
|
||||
|
||||
$username = $relatedResource->branch->billing_sber_username;
|
||||
$password = $relatedResource->branch->billing_sber_password;
|
||||
|
||||
if (empty($username) || empty($password)) {
|
||||
return ['error' => 'Ulanyjy ady bilen açar sözi gabat gelmedi', 'type' => 'modal'];
|
||||
}
|
||||
|
||||
return [
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
'onlinePaymentResource' => $onlinePaymentResource,
|
||||
'relatedResource' => $relatedResource,
|
||||
];
|
||||
}
|
||||
|
||||
function syncSberWithAzatAPI(SberPaymentOrderItem $orderItem): array
|
||||
{
|
||||
$result = getSberCredentials($orderItem);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory $onlinePaymentResource */
|
||||
$onlinePaymentResource = $result['onlinePaymentResource'];
|
||||
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $sberPaymentOrder */
|
||||
$sberPaymentOrder = $result['relatedResource'];
|
||||
|
||||
$response = checkOnlinePayment($onlinePaymentResource->orderId, $result['username'], $result['password']);
|
||||
|
||||
if ($response['errorCode'] != 0) {
|
||||
return [
|
||||
'error' => $response['errorMessage'],
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
if (! isset($response['authRefNum'])) {
|
||||
warn('missing-authRefNum', $onlinePaymentResource->orderId);
|
||||
ignoreSberPayment('missing-authRefNum', $orderItem);
|
||||
|
||||
return [
|
||||
'error' => 'authRefNum missing',
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$systemRawResponse = syncWithBankSystem(
|
||||
online_payment_order_uuid: $onlinePaymentResource->orderId,
|
||||
bank_unique_code: $sberPaymentOrder->branch->unique_code,
|
||||
online_payment_terminal_id: $response['terminalId'],
|
||||
user_deposit_account: number_format($sberPaymentOrder->sender_deposit_account, 0, '', ''),
|
||||
online_payment_auth_ref_num: $response['authRefNum'],
|
||||
online_payment_tmt_amount: $orderItem->tmt_payment_amount,
|
||||
pay_purpose: $orderItem->created_at->translatedFormat('F').' '.$orderItem->created_at->format('Y')
|
||||
);
|
||||
|
||||
if ($systemRawResponse == null) {
|
||||
return [
|
||||
'error' => 'Connection issue to SYSTEM',
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$systemResponse = json_decode($systemRawResponse);
|
||||
|
||||
$success = false;
|
||||
if (is_object($systemResponse)) {
|
||||
$success = $systemResponse->errCode == 0;
|
||||
}
|
||||
|
||||
if (! $success) {
|
||||
$message = 'Error';
|
||||
|
||||
if (isset($systemResponse->msgSys)) {
|
||||
$message .= ' '.$systemResponse->msgSys;
|
||||
}
|
||||
|
||||
return [
|
||||
'error' => $message,
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$orderItem->update([
|
||||
'synced_with_system' => true,
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Sber credentials for a given payment item.
|
||||
*
|
||||
* @param SberPaymentOrderItem $item
|
||||
* @return array{username?: string, password?: string, onlinePaymentResource?: OnlinePaymentHistory, relatedResource?: mixed, error?: string, type?: 'danger'|'modal'}
|
||||
*/
|
||||
function getVisaCredentials(VisaMasterPaymentOrderItem $item): array
|
||||
{
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory|null $onlinePaymentResource */
|
||||
$onlinePaymentResource = OnlinePaymentHistory::find($item->online_payment_history_id);
|
||||
|
||||
if (! $onlinePaymentResource) {
|
||||
return ['error' => 'Online payment resource tapylmady', 'type' => 'danger'];
|
||||
}
|
||||
|
||||
$relatedResource = (new $onlinePaymentResource->online_paymantable_type)
|
||||
->find(id: $onlinePaymentResource->online_paymantable_id);
|
||||
|
||||
if (! $relatedResource) {
|
||||
return ['error' => 'Bu resource tapylmady', 'type' => 'danger'];
|
||||
}
|
||||
|
||||
$relatedResource->loadMissing(['branch']);
|
||||
|
||||
if (! $relatedResource->branch) {
|
||||
return ['error' => 'Şahamça bilen birikdirilmedik', 'type' => 'danger'];
|
||||
}
|
||||
|
||||
$username = $relatedResource->branch->billing_visa_master_username;
|
||||
$password = $relatedResource->branch->billing_visa_master_password;
|
||||
|
||||
if (empty($username) || empty($password)) {
|
||||
return ['error' => 'Ulanyjy ady bilen açar sözi gabat gelmedi', 'type' => 'modal'];
|
||||
}
|
||||
|
||||
return [
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
'onlinePaymentResource' => $onlinePaymentResource,
|
||||
'relatedResource' => $relatedResource,
|
||||
];
|
||||
}
|
||||
|
||||
function syncVisaWithAzatAPI(VisaMasterPaymentOrderItem $orderItem): array
|
||||
{
|
||||
$result = getVisaCredentials($orderItem);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory $onlinePaymentResource */
|
||||
$onlinePaymentResource = $result['onlinePaymentResource'];
|
||||
|
||||
/** @var \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder $sberPaymentOrder */
|
||||
$visaPaymentOrder = $result['relatedResource'];
|
||||
|
||||
$response = checkOnlinePayment($onlinePaymentResource->orderId, $result['username'], $result['password']);
|
||||
|
||||
if ($response['errorCode'] != 0) {
|
||||
return [
|
||||
'error' => $response['errorMessage'],
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
if (! isset($response['authRefNum'])) {
|
||||
warn('missing-authRefNum', $onlinePaymentResource->orderId);
|
||||
ignoreVisaPayment('missing-authRefNum', $orderItem);
|
||||
|
||||
return [
|
||||
'error' => 'authRefNum missing',
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$systemRawResponse = syncWithBankSystem(
|
||||
online_payment_order_uuid: $onlinePaymentResource->orderId,
|
||||
bank_unique_code: $visaPaymentOrder->branch->unique_code,
|
||||
online_payment_terminal_id: $response['terminalId'],
|
||||
user_deposit_account: number_format($visaPaymentOrder->sender_deposit_account, 0, '', ''),
|
||||
online_payment_auth_ref_num: $response['authRefNum'],
|
||||
online_payment_tmt_amount: $orderItem->tmt_payment_amount,
|
||||
pay_purpose: $orderItem->created_at->translatedFormat('F').' '.$orderItem->created_at->format('Y')
|
||||
);
|
||||
|
||||
if ($systemRawResponse == null) {
|
||||
return [
|
||||
'error' => 'Connection issue to SYSTEM',
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$systemResponse = json_decode($systemRawResponse);
|
||||
|
||||
$success = false;
|
||||
if (is_object($systemResponse)) {
|
||||
$success = $systemResponse->errCode == 0;
|
||||
}
|
||||
|
||||
if (! $success) {
|
||||
$message = 'Error';
|
||||
|
||||
if (isset($systemResponse->msgSys)) {
|
||||
$message .= ' '.$systemResponse->msgSys;
|
||||
}
|
||||
|
||||
return [
|
||||
'error' => $message,
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$orderItem->update([
|
||||
'synced_with_system' => true,
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
function warn($message, $content) {
|
||||
DB::table('warnings')->insert([
|
||||
'message' => $message,
|
||||
'content' => $content,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
function ignoreVisaPayment($message, $item) {
|
||||
DB::table('ignore_visa_payments')->insert([
|
||||
'message' => $message,
|
||||
'payment_id' => $item->id,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
function ignoreSberPayment($message, $item) {
|
||||
DB::table('ignore_sber_payments')->insert([
|
||||
'message' => $message,
|
||||
'payment_id' => $item->id,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ class AlertController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get alerts for user
|
||||
*
|
||||
* `Alert`-lar, dine api dereje gosulyar, `mobile app`-lar dine `GET` edip alyp gorkezip bilyarler `app`-a girende.
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
@@ -29,6 +31,23 @@ class AlertController extends Controller
|
||||
return response()->json($this->format($alerts));
|
||||
}
|
||||
|
||||
/**
|
||||
* All alerts
|
||||
*/
|
||||
public function all(): JsonResponse
|
||||
{
|
||||
/** @var \App\Models\User */
|
||||
$user = auth()->user();
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Builder<Alert> */
|
||||
$alerstQuery = $user->alerts();
|
||||
|
||||
/** @var Collection<array-key, Alert> */
|
||||
$alerts = $alerstQuery->get();
|
||||
|
||||
return response()->json($this->format($alerts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Format
|
||||
*
|
||||
|
||||
230
app/Http/Controllers/Api/CardBalance/CardBalanceController.php
Normal file
230
app/Http/Controllers/Api/CardBalance/CardBalanceController.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardBalance;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order\Card\CardBalance\CardBalance;
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Nova\Resources\Order\Card\CardBalance\Actions\DownloadCardBalance;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
#[Group('Sargytlar - Kart - Kart galyndylary')]
|
||||
class CardBalanceController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST*
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(
|
||||
CardBalance::query()
|
||||
->where('user_id', auth()->id())
|
||||
->latest()
|
||||
->get()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE*
|
||||
*/
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
/**
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['required', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['required', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* @example 9934612100000243
|
||||
*/
|
||||
'card_number' => ['required', 'digits:16'],
|
||||
|
||||
/**
|
||||
* @example 12
|
||||
*/
|
||||
'card_month' => ['required', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
/**
|
||||
* @example 2049
|
||||
*/
|
||||
'card_year' => ['required', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
]);
|
||||
|
||||
CardBalance::forceCreate([
|
||||
...$data,
|
||||
...[
|
||||
'user_id' => auth()->id(),
|
||||
],
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW*
|
||||
*
|
||||
* ID ugradyp alyan route -da. Soň page-da download button bolmaly, basaňdan soň, modal çykmaly, start date bilen end date ugradyp download basanda `/api/card-transactions-download/{order}` route gelyan pdf download etmeli.
|
||||
*/
|
||||
public function show(CardBalance $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
return response()->json($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download*
|
||||
*
|
||||
* Download card transaction file
|
||||
*/
|
||||
public function download(Request $request, CardBalance $order)
|
||||
{
|
||||
$response = DownloadCardBalance::make()->fetchApi(
|
||||
passport_serie: $order->passport_serie,
|
||||
passport_id: $order->passport_id,
|
||||
card_masked: Str::mask($order->card_number, '*', 6, 6),
|
||||
card_expire_date: $order->card_month.'/'.substr($order->card_year, 2),
|
||||
);
|
||||
|
||||
if ($response->errCode != 0) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $response->message,
|
||||
'url' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'data' => $response,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE*
|
||||
*
|
||||
* ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function update(Request $request, CardBalance $order): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
/**
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['sometimes', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* @example 9934612100000243
|
||||
*/
|
||||
'card_number' => ['sometimes', 'digits:16'],
|
||||
|
||||
/**
|
||||
* @example 12
|
||||
*/
|
||||
'card_month' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
/**
|
||||
* @example 2049
|
||||
*/
|
||||
'card_year' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
]);
|
||||
|
||||
Model::unguarded(function () use ($order, $data) {
|
||||
$order->update($data);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully updated'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE*
|
||||
*/
|
||||
public function destroy(CardBalance $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
$order->delete();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully deleted'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick card balance check
|
||||
*/
|
||||
public function quickCheck(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
/**
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['sometimes', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* @example 9934612100000243
|
||||
*/
|
||||
'card_number' => ['sometimes', 'digits:16'],
|
||||
|
||||
/**
|
||||
* @example 12
|
||||
*/
|
||||
'card_month' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
/**
|
||||
* @example 2049
|
||||
*/
|
||||
'card_year' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
]);
|
||||
|
||||
$response = DownloadCardBalance::make()->fetchApi(
|
||||
passport_serie: $request->passport_serie,
|
||||
passport_id: $request->passport_id,
|
||||
card_masked: Str::mask($request->card_number, '*', 6, 6),
|
||||
card_expire_date: $request->card_month.'/'.substr($request->card_year, 2),
|
||||
);
|
||||
|
||||
if ($response->errCode != 0) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $response->message,
|
||||
'url' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'data' => $response,
|
||||
]);
|
||||
}
|
||||
}
|
||||
133
app/Http/Controllers/Api/CardOrder/CardOrderController.php
Normal file
133
app/Http/Controllers/Api/CardOrder/CardOrderController.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardOrder;
|
||||
|
||||
use App\Http\Controllers\Api\CardOrder\Requests\CardOrderStoreRequest;
|
||||
use App\Http\Controllers\Api\CardOrder\Requests\CardOrderUpdateRequest;
|
||||
use App\Http\Controllers\Api\CardOrder\Resources\CardOrderIndexResource;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order\Card\CardOrder;
|
||||
use App\Repos\Order\Card\CardOrderRepo;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\Payment\OnlinePaymentRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
#[Group('Sargytlar - Kart - Täze kart')]
|
||||
class CardOrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST*
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(CardOrderIndexResource::collection(
|
||||
CardOrder::query()
|
||||
->with(['branch', 'cardState', 'cardType'])
|
||||
->where('user_id', auth()->id())
|
||||
->latest()
|
||||
->get()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE*
|
||||
*
|
||||
* POST ugradanyňdan soň, halkbank toleg link berer, webwiew -da açmaly. Şul route-da ýetende, break etse bolyar, `https://online.tbbank.gov.tm/online-payment-store`
|
||||
*/
|
||||
public function store(CardOrderStoreRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
|
||||
$model = CardOrder::forceCreate([
|
||||
...$data,
|
||||
...[
|
||||
'user_id' => auth()->id(),
|
||||
'citizenship' => 'TM',
|
||||
'status' => OrderRepo::PENDING,
|
||||
],
|
||||
...$this->uploadedFiles($request),
|
||||
]);
|
||||
|
||||
CardOrderRepo::created()($model);
|
||||
|
||||
$payment = (new OnlinePaymentRepo)->payCardOrder($model);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
'payment' => [
|
||||
'status' => $payment['status'] === 'success',
|
||||
'url' => $payment['status'] === 'success' ? $payment['url'] : '',
|
||||
],
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload files
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function uploadedFiles(Request $request): array
|
||||
{
|
||||
$files = [];
|
||||
|
||||
foreach (['passport_one', 'passport_two', 'passport_three', 'passport_four'] as $field) {
|
||||
if ($request->hasFile($field)) {
|
||||
$files[$field] = Str::after($request->file($field)->store('public'), 'public/');
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW*
|
||||
*
|
||||
* ID ugradyp alyan route -da.
|
||||
*/
|
||||
public function show(CardOrder $cardOrder)
|
||||
{
|
||||
if ($cardOrder->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
return response()->json(new CardOrderIndexResource($cardOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE*
|
||||
*
|
||||
* ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function update(CardOrderUpdateRequest $request, CardOrder $cardOrder): JsonResponse
|
||||
{
|
||||
$data = array_merge($request->validated(), $this->uploadedFiles($request));
|
||||
|
||||
Model::unguarded(function () use ($cardOrder, $data) {
|
||||
$cardOrder->update($data);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully updated'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE*
|
||||
*/
|
||||
public function destroy(CardOrder $cardOrder): JsonResponse
|
||||
{
|
||||
if ($cardOrder->user_id !== auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
$cardOrder->delete();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully deleted'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardOrder\Requests;
|
||||
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CardOrderStoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<int, string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
* Card state id (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'card_state_id' => ['required', 'integer', Rule::exists('card_states', 'id')],
|
||||
|
||||
/**
|
||||
* Card type id (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'card_type_id' => ['required', 'integer', Rule::exists('card_types', 'id')],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*
|
||||
* @example ag
|
||||
*/
|
||||
'region' => ['required', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Branch id (https://online.tbbank.gov.tm/api/branches)
|
||||
*/
|
||||
'branch_id' => ['required', 'integer', Rule::exists('branches', 'id')],
|
||||
|
||||
/**
|
||||
* Customer name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'customer_name' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer surname
|
||||
*
|
||||
* @example Allaberdiyev
|
||||
*/
|
||||
'customer_surname' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer patronic name
|
||||
*
|
||||
* @example Öwezowiç
|
||||
*/
|
||||
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 10.10.2000
|
||||
*/
|
||||
'born_at' => ['required', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Old surname
|
||||
*/
|
||||
'old_surname' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['required', 'string', Rule::in(PassportRepo::values())],
|
||||
|
||||
/**
|
||||
* Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'passport_id' => ['required', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Passport date of issue
|
||||
*
|
||||
* @example 10.10.2020
|
||||
*/
|
||||
'passport_given_at' => ['required', 'date', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Passport given by
|
||||
*
|
||||
* @example Ashgabat shaher polisiya tarapyndan
|
||||
*/
|
||||
'passport_given_by' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Born place
|
||||
*
|
||||
* @example Ashgabat shaher
|
||||
*/
|
||||
'born_place' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Işleýän ýeriňiz we wezipäňiz
|
||||
*
|
||||
* @example Aşgabat şäheriniň "TÜRKMENBAŞY" PAÝDARLAR TÄJIRÇILIK bankynyň Baş bugalteri
|
||||
*/
|
||||
'job_location' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Passport address
|
||||
*
|
||||
* @example Kemine 100/190
|
||||
*/
|
||||
'passport_address' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Real address
|
||||
*
|
||||
* @example Kemine 100/190
|
||||
*/
|
||||
'real_address' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['required', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Phone number (additional)
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone_additional' => ['nullable', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Passport (sahypa 1)
|
||||
*/
|
||||
'passport_one' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (2-3-nji sahypa)
|
||||
*/
|
||||
'passport_two' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (8-9 sahypa)
|
||||
*/
|
||||
'passport_three' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (32-nji sahypa)
|
||||
*/
|
||||
'passport_four' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardOrder\Requests;
|
||||
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CardOrderUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<int, string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
* Card state id (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'card_state_id' => ['sometimes', 'integer', Rule::exists('card_states', 'id')],
|
||||
|
||||
/**
|
||||
* Card type id (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'card_type_id' => ['sometimes', 'integer', Rule::exists('card_types', 'id')],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*
|
||||
* @example ag
|
||||
*/
|
||||
'region' => ['sometimes', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Branch id (https://online.tbbank.gov.tm/api/branches)
|
||||
*/
|
||||
'branch_id' => ['sometimes', 'integer', Rule::exists('branches', 'id')],
|
||||
|
||||
/**
|
||||
* Customer name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'customer_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer surname
|
||||
*
|
||||
* @example Allaberdiyev
|
||||
*/
|
||||
'customer_surname' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer patronic name
|
||||
*
|
||||
* @example Öwezowiç
|
||||
*/
|
||||
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 10.10.2000
|
||||
*/
|
||||
'born_at' => ['sometimes', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Old surname
|
||||
*/
|
||||
'old_surname' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['sometimes', 'string', Rule::in(PassportRepo::values())],
|
||||
|
||||
/**
|
||||
* Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Passport date of issue
|
||||
*
|
||||
* @example 10.10.2020
|
||||
*/
|
||||
'passport_given_at' => ['sometimes', 'date', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Passport given by
|
||||
*
|
||||
* @example Ashgabat shaher polisiya tarapyndan
|
||||
*/
|
||||
'passport_given_by' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Born place
|
||||
*
|
||||
* @example Ashgabat shaher
|
||||
*/
|
||||
'born_place' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Işleýän ýeriňiz we wezipäňiz
|
||||
*
|
||||
* @example Aşgabat şäheriniň "TÜRKMENBAŞY" PAÝDARLAR TÄJIRÇILIK bankynyň Baş bugalteri
|
||||
*/
|
||||
'job_location' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Passport address
|
||||
*
|
||||
* @example Kemine 100/190
|
||||
*/
|
||||
'passport_address' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Real address
|
||||
*
|
||||
* @example Kemine 100/190
|
||||
*/
|
||||
'real_address' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['sometimes', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Phone number (additional)
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone_additional' => ['nullable', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Passport (sahypa 1)
|
||||
*/
|
||||
'passport_one' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (2-3-nji sahypa)
|
||||
*/
|
||||
'passport_two' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (8-9 sahypa)
|
||||
*/
|
||||
'passport_three' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (32-nji sahypa)
|
||||
*/
|
||||
'passport_four' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardOrder\Resources;
|
||||
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Order\Card\CardOrder
|
||||
*/
|
||||
class CardOrderIndexResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'unique_id' => $this->unique_id,
|
||||
|
||||
'paid' => $this->paid,
|
||||
|
||||
'card_state_id' => $this->cardState?->name,
|
||||
|
||||
'card_type_id' => $this->cardType?->name,
|
||||
|
||||
'region' => RegionRepo::label($this->region),
|
||||
'branch_id' => $this->branch?->name,
|
||||
|
||||
'customer_name' => $this->customer_name,
|
||||
'customer_surname' => $this->customer_surname,
|
||||
'customer_patronic_name' => $this->customer_patronic_name,
|
||||
'old_surname' => $this->old_surname,
|
||||
'born_at' => $this->born_at,
|
||||
|
||||
'passport_serie' => $this->passport_serie,
|
||||
'passport_id' => $this->passport_id,
|
||||
'passport_given_at' => $this->passport_given_at,
|
||||
'passport_given_by' => $this->passport_given_by,
|
||||
'born_place' => $this->born_place,
|
||||
'passport_address' => $this->passport_address,
|
||||
'real_address' => $this->real_address,
|
||||
|
||||
'job_location' => $this->job_location,
|
||||
|
||||
'phone' => $this->phone,
|
||||
'phone_additional' => $this->phone_additional,
|
||||
|
||||
'status' => OrderRepo::statusFormatted($this->status),
|
||||
|
||||
'passport_one' => url('/storage/'.$this->passport_one),
|
||||
'passport_two' => url('/storage/'.$this->passport_two),
|
||||
'passport_three' => url('/storage/'.$this->passport_three),
|
||||
'passport_four' => url('/storage/'.$this->passport_four),
|
||||
|
||||
'notes' => $this->notes,
|
||||
|
||||
'user_id' => $this->user_id,
|
||||
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'deleted_at' => $this->deleted_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
120
app/Http/Controllers/Api/CardPin/CardPinController.php
Normal file
120
app/Http/Controllers/Api/CardPin/CardPinController.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardPin;
|
||||
|
||||
use App\Http\Controllers\Api\CardPin\Requests\CardPinIndexResource;
|
||||
use App\Http\Controllers\Api\CardPin\Requests\CardPinStoreRequest;
|
||||
use App\Http\Controllers\Api\CardPin\Requests\CardPinUpdateRequest;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order\Card\CardPin\CardPin;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
#[Group('Sargytlar - Kart - Kart pin bukjalar')]
|
||||
class CardPinController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST*
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(CardPinIndexResource::collection(
|
||||
CardPin::query()
|
||||
->with('branch', 'cardType')
|
||||
->where('user_id', auth()->id())
|
||||
->latest()
|
||||
->get()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE*
|
||||
*/
|
||||
public function store(CardPinStoreRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
|
||||
CardPin::forceCreate([
|
||||
...$data,
|
||||
...[
|
||||
'status' => OrderRepo::PENDING,
|
||||
'user_id' => auth()->id(),
|
||||
],
|
||||
...$this->uploadedFiles($request),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload files
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function uploadedFiles(Request $request): array
|
||||
{
|
||||
$files = [];
|
||||
|
||||
foreach (['passport_one', 'passport_two', 'passport_three', 'passport_four'] as $field) {
|
||||
if ($request->hasFile($field)) {
|
||||
$files[$field] = Str::after($request->file($field)->store('public'), 'public/');
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW*
|
||||
*
|
||||
* ID ugradyp alyan route -da.
|
||||
*/
|
||||
public function show(CardPin $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
return response()->json(new CardPinIndexResource($order));
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE*
|
||||
*
|
||||
* ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function update(CardPinUpdateRequest $request, CardPin $order): JsonResponse
|
||||
{
|
||||
$data = array_merge($request->all(), $this->uploadedFiles($request));
|
||||
|
||||
Model::unguarded(function () use ($order, $data) {
|
||||
$order->update($data);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully updated'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE*
|
||||
*/
|
||||
public function destroy(CardPin $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
$order->delete();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully deleted'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardPin\Requests;
|
||||
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Order\Card\CardPin\CardPin
|
||||
*/
|
||||
class CardPinIndexResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'unique_id' => $this->unique_id,
|
||||
|
||||
'card_type_id' => $this->cardType?->name,
|
||||
|
||||
'card_number' => $this->card_number,
|
||||
|
||||
'region' => RegionRepo::label($this->region),
|
||||
'branch_id' => $this->branch?->name,
|
||||
|
||||
'customer_name' => $this->customer_name,
|
||||
'customer_surname' => $this->customer_surname,
|
||||
'customer_patronic_name' => $this->customer_patronic_name,
|
||||
'born_at' => $this->born_at,
|
||||
|
||||
'phone' => $this->phone,
|
||||
|
||||
'status' => OrderRepo::statusFormatted($this->status),
|
||||
|
||||
'passport_serie' => $this->passport_serie,
|
||||
'passport_id' => $this->passport_id,
|
||||
'passport_one' => url('/storage/'.$this->passport_one),
|
||||
'passport_two' => url('/storage/'.$this->passport_two),
|
||||
'passport_three' => url('/storage/'.$this->passport_three),
|
||||
'passport_four' => url('/storage/'.$this->passport_four),
|
||||
|
||||
'notes' => $this->notes,
|
||||
|
||||
'user_id' => $this->user_id,
|
||||
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'deleted_at' => $this->deleted_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardPin\Requests;
|
||||
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CardPinStoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<int, string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
* Card type id (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'card_type_id' => ['required', 'integer', Rule::exists('card_types', 'id')],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*
|
||||
* @example ag
|
||||
*/
|
||||
'region' => ['required', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Branch id (https://online.tbbank.gov.tm/api/branches)
|
||||
*/
|
||||
'branch_id' => ['required', 'integer', Rule::exists('branches', 'id')],
|
||||
|
||||
/**
|
||||
* Customer name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'customer_name' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer surname
|
||||
*
|
||||
* @example Allaberdiyev
|
||||
*/
|
||||
'customer_surname' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer patronic name
|
||||
*
|
||||
* @example Öwezowiç
|
||||
*/
|
||||
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 10.10.2000
|
||||
*/
|
||||
'born_at' => ['required', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['required', 'string', Rule::in(PassportRepo::values())],
|
||||
|
||||
/**
|
||||
* Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'passport_id' => ['required', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Card number
|
||||
*
|
||||
* @example 9934 2312 2342 0249
|
||||
*/
|
||||
'card_number' => ['required', 'string'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['required', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Passport (sahypa 1)
|
||||
*/
|
||||
'passport_one' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (2-3-nji sahypa)
|
||||
*/
|
||||
'passport_two' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (8-9 sahypa)
|
||||
*/
|
||||
'passport_three' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (32-nji sahypa)
|
||||
*/
|
||||
'passport_four' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardPin\Requests;
|
||||
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CardPinUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<int, string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
* Card type id (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'card_type_id' => ['sometimes', 'integer', Rule::exists('card_types', 'id')],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*
|
||||
* @example ag
|
||||
*/
|
||||
'region' => ['sometimes', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Branch id (https://online.tbbank.gov.tm/api/branches)
|
||||
*/
|
||||
'branch_id' => ['sometimes', 'integer', Rule::exists('branches', 'id')],
|
||||
|
||||
/**
|
||||
* Customer name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'customer_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer surname
|
||||
*
|
||||
* @example Allaberdiyev
|
||||
*/
|
||||
'customer_surname' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer patronic name
|
||||
*
|
||||
* @example Öwezowiç
|
||||
*/
|
||||
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 10.10.2000
|
||||
*/
|
||||
'born_at' => ['sometimes', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['sometimes', 'string', Rule::in(PassportRepo::values())],
|
||||
|
||||
/**
|
||||
* Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Card number
|
||||
*
|
||||
* @example 9934 2312 2342 0249
|
||||
*/
|
||||
'card_number' => ['sometimes', 'string'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['sometimes', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Passport (sahypa 1)
|
||||
*/
|
||||
'passport_one' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (2-3-nji sahypa)
|
||||
*/
|
||||
'passport_two' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (8-9 sahypa)
|
||||
*/
|
||||
'passport_three' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (32-nji sahypa)
|
||||
*/
|
||||
'passport_four' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardRequisite;
|
||||
|
||||
use App\Http\Controllers\Api\CardRequisite\Requests\CardRequisiteStoreRequest;
|
||||
use App\Http\Controllers\Api\CardRequisite\Requests\CardRequisiteUpdateRequest;
|
||||
use App\Http\Controllers\Api\CardRequisite\Resources\CardRequisiteIndexResource;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order\Card\Requisite\CardRequisite;
|
||||
use App\Nova\Resources\Order\Card\Requisite\Actions\DownloadCardRequisite;
|
||||
use App\Repos\Order\Card\CardOrderRepo;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
#[Group('Sargytlar - Kart - Kart rekwizitler')]
|
||||
class CardRequisiteController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST*
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(CardRequisiteIndexResource::collection(
|
||||
CardRequisite::query()
|
||||
->with(['cardType', 'branch'])
|
||||
->where('user_id', auth()->id())
|
||||
->latest()
|
||||
->get()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE*
|
||||
*/
|
||||
public function store(CardRequisiteStoreRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
|
||||
$model = CardRequisite::forceCreate([
|
||||
...$data,
|
||||
...[
|
||||
'user_id' => auth()->id(),
|
||||
'status' => OrderRepo::PENDING,
|
||||
],
|
||||
...$this->uploadedFiles($request),
|
||||
]);
|
||||
|
||||
$model->update(['unique_id' => CardOrderRepo::fillUniqueId($model)]);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload files
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function uploadedFiles(Request $request): array
|
||||
{
|
||||
$files = [];
|
||||
|
||||
foreach (['passport_one', 'passport_two', 'passport_three', 'passport_four'] as $field) {
|
||||
if ($request->hasFile($field)) {
|
||||
$files[$field] = Str::after($request->file($field)->store('public'), 'public/');
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW*
|
||||
*
|
||||
* ID ugradyp alyan route -da. Soň page-da download button bolmaly, basaňdan soň, `/api/card-requisites-download/{order}` route gelyan file download etmeli.
|
||||
*/
|
||||
public function show(CardRequisite $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
return response()->json(new CardRequisiteIndexResource($order));
|
||||
}
|
||||
|
||||
/**
|
||||
* Download*
|
||||
*
|
||||
* Download card transaction file
|
||||
*/
|
||||
public function download(Request $request, CardRequisite $order)
|
||||
{
|
||||
$date = today()->format('d.m.Y');
|
||||
|
||||
$response = vp_fetch_ClientInfoAll($order, $date, $date);
|
||||
|
||||
if ($response->errCode != 0) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $response->message,
|
||||
'url' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
$path = DownloadCardRequisite::make()->generateFile($order, $response);
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => $response->message,
|
||||
'url' => url($path),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE*
|
||||
*
|
||||
* ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function update(CardRequisiteUpdateRequest $request, CardRequisite $order): JsonResponse
|
||||
{
|
||||
$data = array_merge($request->validated(), $this->uploadedFiles($request));
|
||||
|
||||
Model::unguarded(function () use ($order, $data) {
|
||||
$order->update($data);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully updated'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE*
|
||||
*/
|
||||
public function destroy(CardRequisite $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
$order->delete();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully deleted'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardRequisite\Requests;
|
||||
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CardRequisiteStoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<int, string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
* Card type id (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'card_type_id' => ['required', 'integer', Rule::exists('card_types', 'id')],
|
||||
|
||||
/**
|
||||
* @example 9934612100000243
|
||||
*/
|
||||
'card_number' => ['required', 'digits:16'],
|
||||
|
||||
/**
|
||||
* @example 12
|
||||
*/
|
||||
'card_month' => ['required', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
/**
|
||||
* @example 2049
|
||||
*/
|
||||
'card_year' => ['required', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*
|
||||
* @example ag
|
||||
*/
|
||||
'region' => ['required', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Branch id (https://online.tbbank.gov.tm/api/branches)
|
||||
*/
|
||||
'branch_id' => ['required', 'integer', Rule::exists('branches', 'id')],
|
||||
|
||||
/**
|
||||
* Customer name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'customer_name' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer surname
|
||||
*
|
||||
* @example Allaberdiyev
|
||||
*/
|
||||
'customer_surname' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer patronic name
|
||||
*
|
||||
* @example Öwezowiç
|
||||
*/
|
||||
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 10.10.2000
|
||||
*/
|
||||
'born_at' => ['required', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['required', 'integer', 'between:61000000, 71999999'],
|
||||
/**
|
||||
* Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['required', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['required', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Passport (sahypa 1)
|
||||
*/
|
||||
'passport_one' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (2-3-nji sahypa)
|
||||
*/
|
||||
'passport_two' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (8-9 sahypa)
|
||||
*/
|
||||
'passport_three' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (32-nji sahypa)
|
||||
*/
|
||||
'passport_four' => ['required', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardRequisite\Requests;
|
||||
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CardRequisiteUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<int, string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
* Card type id (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'card_type_id' => ['sometimes', 'integer', Rule::exists('card_types', 'id')],
|
||||
|
||||
/**
|
||||
* @example 9934612100000243
|
||||
*/
|
||||
'card_number' => ['sometimes', 'digits:16'],
|
||||
|
||||
/**
|
||||
* @example 12
|
||||
*/
|
||||
'card_month' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
/**
|
||||
* @example 2049
|
||||
*/
|
||||
'card_year' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*
|
||||
* @example ag
|
||||
*/
|
||||
'region' => ['sometimes', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Branch id (https://online.tbbank.gov.tm/api/branches)
|
||||
*/
|
||||
'branch_id' => ['sometimes', 'integer', Rule::exists('branches', 'id')],
|
||||
|
||||
/**
|
||||
* Customer name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'customer_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer surname
|
||||
*
|
||||
* @example Allaberdiyev
|
||||
*/
|
||||
'customer_surname' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer patronic name
|
||||
*
|
||||
* @example Öwezowiç
|
||||
*/
|
||||
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 10.10.2000
|
||||
*/
|
||||
'born_at' => ['sometimes', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['sometimes', 'integer', 'between:61000000, 71999999'],
|
||||
/**
|
||||
* Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['sometimes', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Passport (sahypa 1)
|
||||
*/
|
||||
'passport_one' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (2-3-nji sahypa)
|
||||
*/
|
||||
'passport_two' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (8-9 sahypa)
|
||||
*/
|
||||
'passport_three' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (32-nji sahypa)
|
||||
*/
|
||||
'passport_four' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardRequisite\Resources;
|
||||
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Order\Card\Requisite\CardRequisite
|
||||
*/
|
||||
class CardRequisiteIndexResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'unique_id' => $this->unique_id,
|
||||
|
||||
'card_type_id' => $this->cardType?->name,
|
||||
'card_number' => $this->card_number,
|
||||
'card_month' => $this->card_month,
|
||||
'card_year' => $this->card_year,
|
||||
|
||||
'region' => RegionRepo::label($this->region),
|
||||
'branch_id' => $this->branch?->name,
|
||||
|
||||
'customer_name' => $this->customer_name,
|
||||
'customer_surname' => $this->customer_surname,
|
||||
'customer_patronic_name' => $this->customer_patronic_name,
|
||||
|
||||
'born_at' => $this->born_at,
|
||||
'phone' => $this->phone,
|
||||
|
||||
'passport_serie' => $this->passport_serie,
|
||||
'passport_id' => $this->passport_id,
|
||||
|
||||
'passport_one' => url('/storage/'.$this->passport_one),
|
||||
'passport_two' => url('/storage/'.$this->passport_two),
|
||||
'passport_three' => url('/storage/'.$this->passport_three),
|
||||
'passport_four' => url('/storage/'.$this->passport_four),
|
||||
|
||||
'notes' => $this->notes,
|
||||
'user_id' => $this->user_id,
|
||||
|
||||
'status' => OrderRepo::statusFormatted($this->status),
|
||||
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\CardTransaction;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order\Card\CardTransaction\CardTransaction;
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
#[Group('Sargytlar - Kart - Kart hereketleri')]
|
||||
class CardTransactionsController extends Controller
|
||||
{
|
||||
/**
|
||||
* This month transactions on card
|
||||
*/
|
||||
public function lastMonth(): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$start_date = today()->subDays(10)->format('d.m.Y');
|
||||
$end_date = today()->format('d.m.Y');
|
||||
$passport_serie = $user->getOption('passport_serie');
|
||||
$passport_id = $user->getOption('passport_id');
|
||||
$card_number = $user->getOption('card_number');
|
||||
$card_month = $user->getOption('card_month');
|
||||
$card_year = $user->getOption('card_year');
|
||||
|
||||
if (
|
||||
is_null($passport_serie) || $passport_serie === '' ||
|
||||
is_null($passport_id) || $passport_id === '' ||
|
||||
is_null($card_number) || $card_number === '' ||
|
||||
is_null($card_month) || $card_month === '' ||
|
||||
is_null($card_year) || $card_year === ''
|
||||
) {
|
||||
return response()->rest([
|
||||
'status' => false,
|
||||
'message' => 'Profile data needed',
|
||||
'data' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
$card_month = str_pad($card_month, 2, '0', STR_PAD_LEFT);
|
||||
|
||||
$response = fetchCardTransactionFromAzat(
|
||||
passport_serie: $passport_serie,
|
||||
passport_id: $passport_id,
|
||||
card_number_masked: Str::mask($card_number, '*', 6, 6),
|
||||
card_expire_date: $card_month.'/'.substr($card_year, 2),
|
||||
start_date: $start_date,
|
||||
end_date: $end_date,
|
||||
);
|
||||
|
||||
if ($response->errCode != 0) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $response->message,
|
||||
'data' => [],
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'a',
|
||||
'data' => $response,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* LIST*
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(
|
||||
CardTransaction::query()
|
||||
->where('user_id', auth()->id())
|
||||
->latest()
|
||||
->get()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE*
|
||||
*/
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
/**
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['required', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['required', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* @example 9934612100000243
|
||||
*/
|
||||
'card_number' => ['required', 'digits:16'],
|
||||
|
||||
/**
|
||||
* @example 12
|
||||
*/
|
||||
'card_month' => ['required', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
/**
|
||||
* @example 2049
|
||||
*/
|
||||
'card_year' => ['required', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
]);
|
||||
|
||||
CardTransaction::forceCreate([
|
||||
...$data,
|
||||
...[
|
||||
'user_id' => auth()->id(),
|
||||
],
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW*
|
||||
*
|
||||
* ID ugradyp alyan route -da. Soň page-da download button bolmaly, basaňdan soň, modal çykmaly, start date bilen end date ugradyp download basanda `/api/card-transactions-download/{order}` route gelyan pdf download etmeli.
|
||||
*/
|
||||
public function show(CardTransaction $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
return response()->json($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download*
|
||||
*
|
||||
* Download card transaction file
|
||||
*/
|
||||
public function download(Request $request, CardTransaction $order)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'start_date' => ['required', 'string', 'date'],
|
||||
'end_date' => ['required', 'string', 'date', 'after:start_date'],
|
||||
]);
|
||||
|
||||
$start_date = Carbon::create($data['start_date'])->format('d.m.Y');
|
||||
$end_date = Carbon::create($data['end_date'])->format('d.m.Y');
|
||||
|
||||
$response = vp_fetch_ClientInfoAll($order, $start_date, $end_date);
|
||||
|
||||
if ($response->errCode != 0) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $response->message,
|
||||
'url' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
$url = DownloadCardTransaction::make()->doFiles($order, $response);
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => $response->message,
|
||||
'url' => $url,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE*
|
||||
*
|
||||
* ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function update(Request $request, CardTransaction $order): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
/**
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['sometimes', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* @example 9934612100000243
|
||||
*/
|
||||
'card_number' => ['sometimes', 'digits:16'],
|
||||
|
||||
/**
|
||||
* @example 12
|
||||
*/
|
||||
'card_month' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
/**
|
||||
* @example 2049
|
||||
*/
|
||||
'card_year' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
]);
|
||||
|
||||
Model::unguarded(function () use ($order, $data) {
|
||||
$order->update($data);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully updated'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE*
|
||||
*/
|
||||
public function destroy(CardTransaction $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
$order->delete();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully deleted'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
43
app/Http/Controllers/Api/ContactUsController.php
Normal file
43
app/Http/Controllers/Api/ContactUsController.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CMS\ContactUs;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ContactUsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Store contact us message
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
/**
|
||||
* Message Title
|
||||
*
|
||||
* @example Salam
|
||||
*/
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Message content
|
||||
*
|
||||
* @example Bet app
|
||||
*/
|
||||
'message' => ['required', 'string', 'max:255'],
|
||||
]);
|
||||
|
||||
ContactUs::forceCreate(
|
||||
...$data,
|
||||
...[
|
||||
'user_id' => auth()->id(),
|
||||
],
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Dedoc\Scramble\Attributes\ExcludeRouteFromDocs;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -11,6 +12,7 @@ class FetchLoanHistoryController extends Controller
|
||||
/**
|
||||
* Fetch loan history
|
||||
*/
|
||||
#[ExcludeRouteFromDocs]
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\LoanOrder\Remaining;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Modules\LoanRemainingOrder\Models\LoanRemainingOrder;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
#[Group('Sargytlar - Karz - Karzyň galyndysy')]
|
||||
class LoanOrderRemainingOrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST*
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(
|
||||
LoanRemainingOrder::query()
|
||||
->where('user_id', auth()->id())
|
||||
->latest()
|
||||
->get()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE*
|
||||
*/
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
/**
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['required', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['required', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* @example 14208934130700002997232
|
||||
*/
|
||||
'account_number' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
LoanRemainingOrder::forceCreate([
|
||||
...$data,
|
||||
...[
|
||||
'user_id' => auth()->id(),
|
||||
],
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW*
|
||||
*
|
||||
* ID ugradyp alyan route -da.
|
||||
*/
|
||||
public function show(LoanRemainingOrder $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
return response()->json($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE*
|
||||
*
|
||||
* ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function update(Request $request, LoanRemainingOrder $order): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
/**
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['sometimes', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* @example 379514
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* @example 14208934130700002997232
|
||||
*/
|
||||
'account_number' => ['sometimes', 'string'],
|
||||
]);
|
||||
|
||||
Model::unguarded(function () use ($order, $data) {
|
||||
$order->update($data);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully updated'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE*
|
||||
*/
|
||||
public function destroy(LoanRemainingOrder $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
$order->delete();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully deleted'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class LoanPaidOffLetterOrderStoreRequest extends FormRequest
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 2000
|
||||
* @example 10.10.2000
|
||||
*/
|
||||
'born_at' => ['required', 'before_or_equal:today'],
|
||||
|
||||
|
||||
@@ -6,14 +6,20 @@ use App\Http\Controllers\Api\LoanPaidOffLetterOrder\Requests\LoanPaidOffLetterOr
|
||||
use App\Http\Controllers\Api\LoanPaidOffLetterOrder\Resources\LoanPaidOffLetterOrderIndexResource;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order\Loan\LoanPaidOffLetterOrder;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
#[Group('Sargytlar - Karz - Karzyň ýapylandygy barada güwanama')]
|
||||
class LoanPaidOffLetterOrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST* Loan paid off letters
|
||||
* LIST*
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
@@ -21,12 +27,13 @@ class LoanPaidOffLetterOrderController extends Controller
|
||||
LoanPaidOffLetterOrder::query()
|
||||
->with('branch')
|
||||
->where('user_id', auth()->id())
|
||||
->paginate()
|
||||
->latest()
|
||||
->get()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE* Loan order.
|
||||
* SAVE*
|
||||
*/
|
||||
public function store(LoanPaidOffLetterOrderStoreRequest $request): JsonResponse
|
||||
{
|
||||
@@ -37,11 +44,142 @@ class LoanPaidOffLetterOrderController extends Controller
|
||||
...$data,
|
||||
...[
|
||||
'user_id' => auth()->id(),
|
||||
'status' => OrderRepo::PENDING,
|
||||
'source' => OrderRepo::MOBILE_DEVICE,
|
||||
],
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully created'),
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW*
|
||||
*
|
||||
* ID ugradyp alyan route -da.
|
||||
*/
|
||||
public function show(LoanPaidOffLetterOrder $order)
|
||||
{
|
||||
if ($order->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
return response()->json(new LoanPaidOffLetterOrderIndexResource($order));
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE*
|
||||
*
|
||||
* ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function update(Request $request, LoanPaidOffLetterOrder $order): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'region' => ['sometimes', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Branch id (https://online.tbbank.gov.tm/api/branches)
|
||||
*/
|
||||
'branch_id' => ['sometimes', 'integer', Rule::exists('branches', 'id')],
|
||||
|
||||
/**
|
||||
* Customer name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'customer_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer surname
|
||||
*
|
||||
* @example Allaberdiyev
|
||||
*/
|
||||
'customer_surname' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer patronic name
|
||||
*
|
||||
* @example Öwezowiç
|
||||
*/
|
||||
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Passport serie
|
||||
*/
|
||||
'passport_serie' => ['sometimes', 'string', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 10.10.2000
|
||||
*/
|
||||
'born_at' => ['sometimes', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['sometimes', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Contract number
|
||||
*
|
||||
* @example 3242358989234
|
||||
*/
|
||||
'loan_contract_number' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Contract date
|
||||
*
|
||||
* @example 20.34.23
|
||||
*/
|
||||
'loan_contract_date' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Loan amount
|
||||
*
|
||||
* @example 20000
|
||||
*/
|
||||
'loan_amount' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Loan reason
|
||||
*
|
||||
* @example Puldan pul yasamak ucin
|
||||
*/
|
||||
'loan_reason' => ['sometimes', 'string', 'max:255'],
|
||||
]);
|
||||
|
||||
Model::unguarded(function () use ($order, $data) {
|
||||
$order->update($data);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully updated'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE*
|
||||
*/
|
||||
public function destroy(LoanPaidOffLetterOrder $order): JsonResponse
|
||||
{
|
||||
if ($order->user_id !== auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
$order->delete();
|
||||
|
||||
return response()->json();
|
||||
}
|
||||
}
|
||||
|
||||
35
app/Http/Controllers/ApiTesterController.php
Normal file
35
app/Http/Controllers/ApiTesterController.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApiTesterController extends Controller
|
||||
{
|
||||
public function index(Request $request): mixed
|
||||
{
|
||||
$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 => '{ "idSeria": "I-AH", "idNo": "152304", "clientType": "recipient", "cardMaskNumber": "993403******8088", "expDate": "02/34", "fromDate" : "01.01.2020", "toDate" : "09.05.2025" }',
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return "<pre>{$response}</pre>";
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class ResetPasswordController extends Controller
|
||||
{
|
||||
$request->validate([
|
||||
'username' => ['required', 'string', 'max:250', 'exists:users,username'],
|
||||
'verification' => ['nullable', 'integer', 'digits:5', Rule::requiredIf(fn () => $request->filled('step-verification'))],
|
||||
'verification' => ['nullable', 'integer', Rule::requiredIf(fn () => $request->filled('step-verification'))],
|
||||
'step-sms' => ['nullable'],
|
||||
'step-verification' => ['nullable'],
|
||||
'step-password' => ['nullable'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use Dedoc\Scramble\Attributes\ExcludeRouteFromDocs;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -14,6 +15,7 @@ class FetchCardHistoryController extends Controller
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
#[ExcludeRouteFromDocs]
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Modules\LoanRemainingOrder\Actions\FetchRemainingLoanFromBilling;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use Dedoc\Scramble\Attributes\ExcludeRouteFromDocs;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -15,6 +16,7 @@ class FetchLoanRemainingController extends Controller
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
#[ExcludeRouteFromDocs]
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
|
||||
11
app/Http/Controllers/GitPullController.php
Normal file
11
app/Http/Controllers/GitPullController.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class GitPullController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return 'a';
|
||||
}
|
||||
}
|
||||
@@ -25,27 +25,6 @@ class OnlinePaymentController extends Controller
|
||||
{
|
||||
$data = OnlinePaymentRepo::checkPaymentVisaMaster($request);
|
||||
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory */
|
||||
$paymentHistory = $data['paymentHistory'];
|
||||
|
||||
/** @var \App\Models\Branch\Branch */
|
||||
$bank = $data['bank_branch'];
|
||||
|
||||
/** @var \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem */
|
||||
$resource = $data['resource'];
|
||||
|
||||
// if ($data['success'] && $paymentHistory && is_array($paymentHistory->api_response)) {
|
||||
// info(OnlinePaymentRepo::syncWithBilling(
|
||||
// uuid: $paymentHistory->orderId,
|
||||
// bank_code: $bank->unique_code,
|
||||
// terminal_id: $paymentHistory->api_response['terminalId'],
|
||||
// account_number: $resource->parent->sender_datas[0]['deposit_account'],
|
||||
// rrn: $paymentHistory->api_response['authRefNum'],
|
||||
// amount: $resource->tmt_payment_amount,
|
||||
// pay_purpose: $resource->created_at->translatedFormat('F').' '.$resource->created_at->format('Y'),
|
||||
// ));
|
||||
// }
|
||||
|
||||
return view(OnlinePaymentRepo::statusView(), $data);
|
||||
}
|
||||
|
||||
@@ -56,8 +35,6 @@ class OnlinePaymentController extends Controller
|
||||
{
|
||||
$data = OnlinePaymentRepo::checkPaymentSber($request);
|
||||
|
||||
// OnlinePaymentRepo::syncWithBilling();
|
||||
|
||||
return view(OnlinePaymentRepo::statusView(), $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\UpdateUserProfileRequest;
|
||||
use App\Http\Resources\ProfileResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class ProfileController extends Controller
|
||||
@@ -15,12 +16,7 @@ class ProfileController extends Controller
|
||||
/** @var \App\Models\User */
|
||||
$user = auth()->user();
|
||||
|
||||
return response()->json([
|
||||
'name' => $user->name,
|
||||
'phone' => $user->phone,
|
||||
'passport_serie' => $user->getOption('passport_serie'),
|
||||
'passport_id' => $user->getOption('passport_id'),
|
||||
]);
|
||||
return response()->json(new ProfileResponse($user));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,6 +32,10 @@ class ProfileController extends Controller
|
||||
'phone' => $request->phone,
|
||||
'options->passport_serie' => $request->passport_serie,
|
||||
'options->passport_id' => $request->passport_id,
|
||||
'options->card_number' => $request->card_number,
|
||||
'options->card_month' => $request->card_month,
|
||||
'options->card_year' => $request->card_year,
|
||||
'options->card_name' => $request->card_name,
|
||||
];
|
||||
|
||||
if ($request->password) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -47,14 +48,34 @@ class UpdateUserProfileRequest extends FormRequest
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'passport_serie' => ['nullable', 'string', Rule::in(array_keys(PassportRepo::values()))],
|
||||
'passport_serie' => ['sometimes', 'string', Rule::in(array_keys(PassportRepo::values()))],
|
||||
|
||||
/**
|
||||
* Passport id
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'passport_id' => ['nullable', 'numeric', 'digits:6'],
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* @example 9934612100000543
|
||||
*/
|
||||
'card_number' => ['sometimes', 'digits:16'],
|
||||
|
||||
/**
|
||||
* @example 12
|
||||
*/
|
||||
'card_month' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberMonths()))],
|
||||
|
||||
/**
|
||||
* @example 2049
|
||||
*/
|
||||
'card_year' => ['sometimes', Rule::in(array_keys(DateHelperRepository::staticNumberYears()))],
|
||||
|
||||
/**
|
||||
* @example Nurmuhammet Allanov
|
||||
*/
|
||||
'card_name' => ['sometimes', 'string', 'max:255'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
31
app/Http/Resources/ProfileResponse.php
Normal file
31
app/Http/Resources/ProfileResponse.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\User
|
||||
*/
|
||||
class ProfileResponse extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->name,
|
||||
'phone' => $this->phone,
|
||||
'passport_serie' => $this->getOption('passport_serie'),
|
||||
'passport_id' => $this->getOption('passport_id'),
|
||||
'card_number' => $this->getOption('card_number'),
|
||||
'card_month' => $this->getOption('card_month'),
|
||||
'card_year' => $this->getOption('card_year'),
|
||||
'card_name' => $this->getOption('card_name'),
|
||||
];
|
||||
}
|
||||
}
|
||||
64
app/Jobs/SendSberToSystem.php
Normal file
64
app/Jobs/SendSberToSystem.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendSberToSystem implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* The number of seconds the job can run before timing out.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 5;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$ignore = DB::table('ignore_sber_payments')->pluck('payment_id');
|
||||
|
||||
$orderItems = SberPaymentOrderItem::query()
|
||||
->where('paid', true)
|
||||
->where('synced_with_system', false)
|
||||
->whereDate('created_at', '>', '2025-09-05')
|
||||
->whereIntegerNotInRaw('id', $ignore)
|
||||
->limit(2)
|
||||
->get()
|
||||
->each(function ($orderItem) {
|
||||
if (! $orderItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result = syncSberWithAzatAPI($orderItem);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
ignoreSberPayment($result['error'], $orderItem);
|
||||
|
||||
Log::channel('sber_job')->error(json_encode([
|
||||
'error' => $result['error'],
|
||||
'orderItem' => $orderItem,
|
||||
]));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
50
app/Jobs/SendVisaToSystem.php
Normal file
50
app/Jobs/SendVisaToSystem.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendVisaToSystem implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$ignore = DB::table('ignore_visa_payments')->pluck('payment_id');
|
||||
|
||||
$orderItems = VisaMasterPaymentOrderItem::query()
|
||||
->where('paid', true)
|
||||
->where('synced_with_system', false)
|
||||
->whereDate('created_at', '>', '2025-09-05')
|
||||
->whereIntegerNotInRaw('id', $ignore)
|
||||
->limit(2)
|
||||
->get()
|
||||
->each(function ($orderItem) {
|
||||
if (! $orderItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result = syncVisaWithAzatAPI($orderItem);
|
||||
|
||||
if (isset($result['error'])) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
19
app/Models/CMS/ContactUs.php
Normal file
19
app/Models/CMS/ContactUs.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\CMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property string $title
|
||||
* @property string $message
|
||||
* @property \Illuminate\Support\Facades\Date $created_at
|
||||
* @property \Illuminate\Support\Facades\Date $updated_at
|
||||
*/
|
||||
class ContactUs extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/IgnoreSberPayment.php
Normal file
11
app/Models/IgnoreSberPayment.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class IgnoreSberPayment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/IgnoreVisaPayment.php
Normal file
11
app/Models/IgnoreVisaPayment.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class IgnoreVisaPayment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
26
app/Models/Order/Card/CardBalance/CardBalance.php
Normal file
26
app/Models/Order/Card/CardBalance/CardBalance.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Order\Card\CardBalance;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laravel\Nova\Actions\Actionable;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property string $passport_serie
|
||||
* @property string $passport_id
|
||||
* @property string $card_number
|
||||
* @property string $card_month
|
||||
* @property string $card_year
|
||||
* @property \Illuminate\Support\Carbon $created_at
|
||||
* @property \Illuminate\Support\Carbon $updated_at
|
||||
*/
|
||||
class CardBalance extends Model
|
||||
{
|
||||
use Actionable;
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class CardOrder extends Model
|
||||
/**
|
||||
* Price for order
|
||||
*/
|
||||
public function priceAmount(): float
|
||||
public function priceAmount(): string|int|float
|
||||
{
|
||||
return $this->cardState->price ?? 32;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,37 @@ namespace App\Models\Order\Card\CardPin;
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Order\Card\CardType;
|
||||
use App\Models\User;
|
||||
use App\Repos\Order\Loan\LoanOrderRepo;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property null|string $unique_id
|
||||
* @property int $card_type_id
|
||||
* @property string $card_number
|
||||
* @property string $region
|
||||
* @property int $branch_id
|
||||
* @property string $customer_name
|
||||
* @property string $customer_surname
|
||||
* @property null|string $customer_patronic_name
|
||||
* @property null|string $born_at
|
||||
* @property null|string $phone
|
||||
* @property string $passport_serie
|
||||
* @property string $passport_id
|
||||
* @property null|string $status
|
||||
* @property null|string $passport_one
|
||||
* @property null|string $passport_two
|
||||
* @property null|string $passport_three
|
||||
* @property null|string $passport_four
|
||||
* @property null|string $notes
|
||||
* @property int $user_id
|
||||
* @property null|string $created_at
|
||||
* @property null|string $updated_at
|
||||
* @property null|string $deleted_at
|
||||
*/
|
||||
class CardPin extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
@@ -96,4 +122,14 @@ class CardPin extends Model
|
||||
{
|
||||
return 3.02;
|
||||
}
|
||||
|
||||
/**
|
||||
* "boot" method for model
|
||||
*/
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::created(LoanOrderRepo::created());
|
||||
}
|
||||
}
|
||||
|
||||
26
app/Models/Order/Card/CardTransaction/CardTransaction.php
Normal file
26
app/Models/Order/Card/CardTransaction/CardTransaction.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Order\Card\CardTransaction;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laravel\Nova\Actions\Actionable;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property string $passport_serie
|
||||
* @property string $passport_id
|
||||
* @property string $card_number
|
||||
* @property string $card_month
|
||||
* @property string $card_year
|
||||
* @property \Illuminate\Support\Carbon $created_at
|
||||
* @property \Illuminate\Support\Carbon $updated_at
|
||||
*/
|
||||
class CardTransaction extends Model
|
||||
{
|
||||
use Actionable;
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
}
|
||||
@@ -10,6 +10,33 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* @property int $int
|
||||
* @property string $unique_id
|
||||
* @property string $card_type_id
|
||||
* @property string $card_number
|
||||
* @property string $card_year
|
||||
* @property string $card_month
|
||||
* @property string $region
|
||||
* @property string $branch_id
|
||||
* @property string $customer_name
|
||||
* @property string $customer_surname
|
||||
* @property string $customer_patronic_name
|
||||
* @property string $born_at
|
||||
* @property string $phone
|
||||
* @property string $passport_serie
|
||||
* @property string $passport_id
|
||||
* @property string $status
|
||||
* @property string $passport_one
|
||||
* @property string $passport_two
|
||||
* @property string $passport_three
|
||||
* @property string $passport_four
|
||||
* @property string $notes
|
||||
* @property string $user_id
|
||||
* @property string $ready_files
|
||||
* @property \Illuminate\Support\Carbon $created_at
|
||||
* @property \Illuminate\Support\Carbon $updated_at
|
||||
*/
|
||||
class CardRequisite extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models\Order\Loan;
|
||||
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\User;
|
||||
use App\Repos\Order\Loan\LoanOrderRepo;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -39,6 +40,8 @@ class LoanPaidOffLetterOrder extends Model
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'loan_paid_off_letter_orders';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
@@ -92,4 +95,15 @@ class LoanPaidOffLetterOrder extends Model
|
||||
{
|
||||
return $this->belongsTo(Branch::class, 'branch_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* "boot" method for model
|
||||
*/
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(LoanOrderRepo::creating());
|
||||
static::created(LoanOrderRepo::created());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Models\System\Roles;
|
||||
|
||||
use Laravel\Nova\Actions\Actionable;
|
||||
use Spatie\Permission\Models\Permission as SpatiePermission;
|
||||
use Spatie\Translatable\HasTranslations;
|
||||
|
||||
class Permission extends SpatiePermission
|
||||
{
|
||||
use Actionable;
|
||||
use HasTranslations;
|
||||
|
||||
/**
|
||||
|
||||
@@ -175,12 +175,20 @@ class User extends Authenticatable
|
||||
return $this->hasRole('operator');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is a currency maintainer.
|
||||
*/
|
||||
public function isCurrencyMaintainer(): bool
|
||||
{
|
||||
return $this->hasRole('currency_maintainer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Is System User
|
||||
*/
|
||||
public function isSystemUser(): bool
|
||||
{
|
||||
return $this->isAdmin() || $this->isOperator();
|
||||
return $this->isAdmin() || $this->isOperator() || $this->isCurrencyMaintainer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
11
app/Models/Warning.php
Normal file
11
app/Models/Warning.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Warning extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Modules\ApiAuth\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\ProfileResponse;
|
||||
use App\Models\User;
|
||||
use App\Modules\ApiAuth\Requests\AuthLoginRequest;
|
||||
use App\Modules\ApiAuth\Requests\AuthRegisterRequest;
|
||||
@@ -59,7 +60,10 @@ class ApiAuthController extends Controller
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => $user->createToken(bin2hex(random_bytes(20)))->plainTextToken,
|
||||
'success' => true,
|
||||
'token' => $user->createToken(bin2hex(random_bytes(20)))->plainTextToken,
|
||||
'message' => __('successfully verified'),
|
||||
'user' => new ProfileResponse($user),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,23 @@
|
||||
namespace App\Modules\BaseAppEnum\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repos\Order\Card\CardStateRepo;
|
||||
use App\Repos\Order\Card\CardTypeRepo;
|
||||
use App\Repos\Order\Loan\LoanTypeRepo;
|
||||
use App\Repos\System\Settings\Legal\EducationRepo;
|
||||
use App\Repos\System\Settings\Legal\MarriageRepo;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
|
||||
#[Group('1. App enums')]
|
||||
class BaseAppEnumController extends Controller
|
||||
{
|
||||
/**
|
||||
* Base app enums
|
||||
*
|
||||
* `System` -daky esasy bolup biljek `Maglumatlar`, köplenç `Select` -larda ulanylýar.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function index(): array
|
||||
@@ -24,6 +30,8 @@ class BaseAppEnumController extends Controller
|
||||
'educations' => $this->educationValues(),
|
||||
'marriage_statuses' => MarriageRepo::values(),
|
||||
'passport_series' => PassportRepo::values(),
|
||||
'card_types' => CardTypeRepo::values(),
|
||||
'card_states' => CardStateRepo::values(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ class BranchController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST branches
|
||||
*
|
||||
* Bank şahamçalary. http://online.tbbank.gov.tm/work-place/resources/branches
|
||||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
@@ -34,7 +34,9 @@ class RetryNovaCardOrderPayment extends Action
|
||||
*/
|
||||
public function authorizedToRun(Request $request, $model)
|
||||
{
|
||||
$this->authorizedToRunAction = ! $model->paid && $model->status === OrderRepo::PENDING;
|
||||
/** @var \App\Models\Order\Card\CardOrder */
|
||||
$cardOrder = $model;
|
||||
$this->authorizedToRunAction = ! $cardOrder->paid && $cardOrder->status === OrderRepo::PENDING;
|
||||
|
||||
return $this->authorizedToRunAction;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,29 @@ class DateHelperRepository
|
||||
return $month;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static numbers for months
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function staticNumberMonths(): array
|
||||
{
|
||||
return [
|
||||
'01' => '01',
|
||||
'02' => '02',
|
||||
'03' => '03',
|
||||
'04' => '04',
|
||||
'05' => '05',
|
||||
'06' => '06',
|
||||
'07' => '07',
|
||||
'08' => '08',
|
||||
'09' => '09',
|
||||
'10' => '10',
|
||||
'11' => '11',
|
||||
'12' => '12',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Years until
|
||||
*
|
||||
@@ -39,4 +62,82 @@ class DateHelperRepository
|
||||
|
||||
return $years;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static numbers for years
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function staticNumberYears(): array
|
||||
{
|
||||
return [
|
||||
'2024' => '2024',
|
||||
'2025' => '2025',
|
||||
'2026' => '2026',
|
||||
'2027' => '2027',
|
||||
'2028' => '2028',
|
||||
'2029' => '2029',
|
||||
'2030' => '2030',
|
||||
'2031' => '2031',
|
||||
'2032' => '2032',
|
||||
'2033' => '2033',
|
||||
'2034' => '2034',
|
||||
'2035' => '2035',
|
||||
'2036' => '2036',
|
||||
'2037' => '2037',
|
||||
'2038' => '2038',
|
||||
'2039' => '2039',
|
||||
'2040' => '2040',
|
||||
'2041' => '2041',
|
||||
'2042' => '2042',
|
||||
'2043' => '2043',
|
||||
'2044' => '2044',
|
||||
'2045' => '2045',
|
||||
'2046' => '2046',
|
||||
'2047' => '2047',
|
||||
'2048' => '2048',
|
||||
'2049' => '2049',
|
||||
'2050' => '2050',
|
||||
'2051' => '2051',
|
||||
'2052' => '2052',
|
||||
'2053' => '2053',
|
||||
'2054' => '2054',
|
||||
'2055' => '2055',
|
||||
'2056' => '2056',
|
||||
'2057' => '2057',
|
||||
'2058' => '2058',
|
||||
'2059' => '2059',
|
||||
'2060' => '2060',
|
||||
'2061' => '2061',
|
||||
'2062' => '2062',
|
||||
'2063' => '2063',
|
||||
'2064' => '2064',
|
||||
'2065' => '2065',
|
||||
'2066' => '2066',
|
||||
'2067' => '2067',
|
||||
'2068' => '2068',
|
||||
'2069' => '2069',
|
||||
'2070' => '2070',
|
||||
'2071' => '2071',
|
||||
'2072' => '2072',
|
||||
'2073' => '2073',
|
||||
'2074' => '2074',
|
||||
'2075' => '2075',
|
||||
'2076' => '2076',
|
||||
'2077' => '2077',
|
||||
'2078' => '2078',
|
||||
'2079' => '2079',
|
||||
'2080' => '2080',
|
||||
'2081' => '2081',
|
||||
'2082' => '2082',
|
||||
'2083' => '2083',
|
||||
'2084' => '2084',
|
||||
'2085' => '2085',
|
||||
'2086' => '2086',
|
||||
'2087' => '2087',
|
||||
'2088' => '2088',
|
||||
'2089' => '2089',
|
||||
'2090' => '2090',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,52 +4,50 @@ namespace App\Modules\LoanOrder\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order\Loan\LoanOrder;
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Modules\LoanOrder\Controllers\Requests\LoanOrderStoreRequest;
|
||||
use App\Modules\LoanOrder\Controllers\Resources\LoanOrderIndexResource;
|
||||
use App\Modules\LoanOrder\Controllers\Requests\LoanOrderUpdateRequest;
|
||||
use App\Modules\LoanOrder\Controllers\Resources\LoanOrderShowResource;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
#[Group('Sargytlar - Karz - Karz sargytlary Mobile')]
|
||||
class LoanOrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* LIST* Loan orders.
|
||||
*
|
||||
* `Karz sargytlary list`-leri list gornushde gelyar. https://online.tbbank.gov.tm/work-place/resources/loan-order-mobiles dan `Label` gorup bilyan. `BaseAppEnum` dan gerek yerlerini match edishene gora alyan.
|
||||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json(LoanOrderIndexResource::collection(
|
||||
return response()->json(
|
||||
LoanOrder::query()
|
||||
->where('user_id', auth()->id())
|
||||
->where('source', OrderRepo::MOBILE_DEVICE)
|
||||
->paginate()
|
||||
));
|
||||
->latest()
|
||||
->get()
|
||||
->map(fn (LoanOrder $loanOrder) => [
|
||||
'id' => $loanOrder->id,
|
||||
'loan_type' => $loanOrder->loanType?->name,
|
||||
'loan_amount' => $loanOrder->loan_amount,
|
||||
'created_at' => $loanOrder->created_at,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SAVE* Loan order.
|
||||
*
|
||||
* `Karz sargytlary save`. Example bar, online panelkadan gorup hem bilersin. Update store daky yaly, yone oz ugratyan zadyn update bolyar, eger ugratmasaň, üýtgemez.
|
||||
*/
|
||||
public function store(LoanOrderStoreRequest $request): JsonResponse
|
||||
{
|
||||
Log::channel('form_logs')->info('loan-order-store-request', $request->all());
|
||||
|
||||
$data = $request->validated();
|
||||
|
||||
$months = DateHelperRepository::monthsAsNumber();
|
||||
$years = DateHelperRepository::yearsUntil();
|
||||
|
||||
$data['card_month'] = indexByValue($request->card_month, $months);
|
||||
$data['card_year'] = indexByValue($request->card_year, $years);
|
||||
|
||||
$data['guarantor_card_month'] = indexByValue($request->guarantor_card_month, $months);
|
||||
$data['guarantor_card_year'] = indexByValue($request->guarantor_card_year, $years);
|
||||
|
||||
$data['guarantor_2_card_month'] = indexByValue($request->guarantor_2_card_month, $months);
|
||||
$data['guarantor_2_card_year'] = indexByValue($request->guarantor_2_card_year, $years);
|
||||
|
||||
LoanOrder::forceCreate([
|
||||
...$data,
|
||||
...[
|
||||
@@ -72,16 +70,21 @@ class LoanOrderController extends Controller
|
||||
*/
|
||||
public function uploadedFiles(Request $request): array
|
||||
{
|
||||
return [
|
||||
'passport_one' => Str::after($request->file('passport_one')->store('public'), 'public/'),
|
||||
'passport_two' => Str::after($request->file('passport_two')->store('public'), 'public/'),
|
||||
'passport_three' => Str::after($request->file('passport_three')->store('public'), 'public/'),
|
||||
'passport_four' => Str::after($request->file('passport_four')->store('public'), 'public/'),
|
||||
];
|
||||
$files = [];
|
||||
|
||||
foreach (['passport_one', 'passport_two', 'passport_three', 'passport_four'] as $field) {
|
||||
if ($request->hasFile($field)) {
|
||||
$files[$field] = Str::after($request->file($field)->store('public'), 'public/');
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHOW* Loan order
|
||||
*
|
||||
* `Karz sargytlary show by id`. ID ugradyp alyan route -da. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function show(LoanOrder $loanOrder): JsonResponse
|
||||
{
|
||||
@@ -93,11 +96,21 @@ class LoanOrderController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* UPDATE* Loan order
|
||||
*
|
||||
* `Karz sargytlary update`. ID ugradyp `route`-da update edip bilyan. Base App Enum-lardan peydalan. Panelkadan gor.
|
||||
*/
|
||||
public function update(Request $request): void
|
||||
public function update(LoanOrderUpdateRequest $request, LoanOrder $loanOrder): JsonResponse
|
||||
{
|
||||
//
|
||||
$data = array_merge($request->all(), $this->uploadedFiles($request));
|
||||
|
||||
Model::unguarded(function () use ($loanOrder, $data) {
|
||||
$loanOrder->update($data);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Successfully updated'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +118,7 @@ class LoanOrderController extends Controller
|
||||
*/
|
||||
public function destroy(LoanOrder $loanOrder): JsonResponse
|
||||
{
|
||||
if ($loanOrder->user_id === auth()->id()) {
|
||||
if ($loanOrder->user_id != auth()->id()) {
|
||||
return response()->json(status: 403);
|
||||
}
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ class LoanOrderStoreRequest extends FormRequest
|
||||
*
|
||||
* @example Owezowic
|
||||
*/
|
||||
'guarantor_patronic_name' => ['required', 'string', 'max:255'],
|
||||
'guarantor_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Guarantor card number
|
||||
|
||||
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\LoanOrder\Controllers\Requests;
|
||||
|
||||
use App\Repos\System\Settings\Legal\EducationRepo;
|
||||
use App\Repos\System\Settings\Legal\MarriageRepo;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class LoanOrderUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<int, string>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
/**
|
||||
* Loan type id (https://online.tbbank.gov.tm/api/loan-types)
|
||||
*/
|
||||
'loan_type' => ['sometimes', 'integer', Rule::exists('loan_types', 'id')],
|
||||
|
||||
/**
|
||||
* Loan amount
|
||||
*
|
||||
* @example 20000
|
||||
*/
|
||||
'loan_amount' => ['sometimes', 'integer', 'max:40000'],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'region' => ['sometimes', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Branch id (https://online.tbbank.gov.tm/api/branches)
|
||||
*/
|
||||
'branch_id' => ['sometimes', 'integer', Rule::exists('branches', 'id')],
|
||||
|
||||
/**
|
||||
* Customer name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'customer_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer surname
|
||||
*
|
||||
* @example Allaberdiyev
|
||||
*/
|
||||
'customer_surname' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Customer patronic name
|
||||
*
|
||||
* @example Öwezowiç
|
||||
*/
|
||||
'customer_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Date of birth
|
||||
*
|
||||
* @example 2000
|
||||
*/
|
||||
'born_at' => ['sometimes', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Education (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'education' => ['sometimes', 'string', Rule::in(array_keys(EducationRepo::values()))],
|
||||
|
||||
/**
|
||||
* Marriage status (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'marriage_status' => ['sometimes', 'string', Rule::in(array_keys(MarriageRepo::values()))],
|
||||
|
||||
/**
|
||||
* Passport address
|
||||
*
|
||||
* @example Kemine 100/190
|
||||
*/
|
||||
'passport_address' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Real address
|
||||
*
|
||||
* @example Kemine 100/200
|
||||
*/
|
||||
'real_address' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Passport serie
|
||||
*/
|
||||
'passport_serie' => ['sometimes', 'string', Rule::in(PassportRepo::values())],
|
||||
|
||||
/**
|
||||
* Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* Passport date of issue
|
||||
*
|
||||
* @example 2024-01-10
|
||||
*/
|
||||
'passport_given_at' => ['sometimes', 'date', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Passport given by
|
||||
*
|
||||
* @example Ashgabat shaher polisiya tarapyndan
|
||||
*/
|
||||
'passport_given_by' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Born place
|
||||
*
|
||||
* @example Ashgabat shaher
|
||||
*/
|
||||
'born_place' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Email
|
||||
*
|
||||
* @example mahmyt1206@gmail.com
|
||||
*/
|
||||
'email' => ['nullable', 'email', 'max:255'],
|
||||
|
||||
/**
|
||||
* Phone number
|
||||
*
|
||||
* @example 65999990
|
||||
*/
|
||||
'phone' => ['sometimes', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Phone number (additional)
|
||||
*
|
||||
* @example 61126667
|
||||
*/
|
||||
'phone_additional' => ['nullable', 'integer', 'between:61000000, 71999999'],
|
||||
|
||||
/**
|
||||
* Phone number (home)
|
||||
*
|
||||
* @example 92-92-92
|
||||
*/
|
||||
'phone_home' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Card number
|
||||
*
|
||||
* @example 4434345434423442
|
||||
*/
|
||||
'card_number' => ['sometimes', 'digits:16'],
|
||||
|
||||
/**
|
||||
* Name on card
|
||||
*
|
||||
* @example 'Mahmyt Allaberdiyev'
|
||||
*/
|
||||
'card_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Card expiration month
|
||||
*
|
||||
* @example 06
|
||||
*/
|
||||
'card_month' => ['required'],
|
||||
|
||||
/**
|
||||
* Card expiration year
|
||||
*
|
||||
* @example 2040
|
||||
*/
|
||||
'card_year' => ['required'],
|
||||
|
||||
/**
|
||||
* Card number
|
||||
*
|
||||
* @example 4434345434423442
|
||||
*/
|
||||
'loan_card_number' => ['nullable', 'digits:16'],
|
||||
|
||||
/**
|
||||
* Name on card
|
||||
*
|
||||
* @example 'Mahmyt Allaberdiyev'
|
||||
*/
|
||||
'loan_card_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Card expiration month
|
||||
*
|
||||
* @example 06
|
||||
*/
|
||||
'loan_card_month' => ['nullable'],
|
||||
|
||||
/**
|
||||
* Card expiration year
|
||||
*
|
||||
* @example 2040
|
||||
*/
|
||||
'loan_card_year' => ['nullable'],
|
||||
|
||||
/**
|
||||
* Region (https://online.tbbank.gov.tm/api/base-app-enums)
|
||||
*/
|
||||
'work_region' => ['sometimes', 'string', Rule::in(array_keys(RegionRepo::values()))],
|
||||
|
||||
/**
|
||||
* Provinces (https://online.tbbank.gov.tm/api/provinces)
|
||||
*/
|
||||
'work_province_id' => ['sometimes', 'integer', Rule::exists('provinces', 'id')],
|
||||
|
||||
/**
|
||||
* Work company name
|
||||
*
|
||||
* @example WebUglam HJ
|
||||
*/
|
||||
'work_company' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* HR department number
|
||||
*
|
||||
* @example 707012
|
||||
*/
|
||||
'work_company_accountant_number' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Work position
|
||||
*
|
||||
* @example Bugalter
|
||||
*/
|
||||
'work_position' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Salary
|
||||
*
|
||||
* @example 40000
|
||||
*/
|
||||
'work_salary' => ['sometimes', 'numeric', 'max_digits:8'],
|
||||
|
||||
/**
|
||||
* Work start date
|
||||
*
|
||||
* @example 2024-01-16
|
||||
*/
|
||||
'work_started_at' => ['sometimes', 'date', 'before_or_equal:today'],
|
||||
|
||||
/**
|
||||
* Passport (sahypa 1)
|
||||
*/
|
||||
'passport_one' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (2-3-nji sahypa)
|
||||
*/
|
||||
'passport_two' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (8-9 sahypa)
|
||||
*/
|
||||
'passport_three' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Pasport (32-nji sahypa)
|
||||
*/
|
||||
'passport_four' => ['sometimes', 'file', 'max:2048', 'mimes:jpg,png,jpeg'],
|
||||
|
||||
/**
|
||||
* Guarantor name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'guarantor_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Guarantor surname
|
||||
*
|
||||
* @example Allaberdiev
|
||||
*/
|
||||
'guarantor_surname' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Guarantor surname
|
||||
*
|
||||
* @example Owezowic
|
||||
*/
|
||||
'guarantor_patronic_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Guarantor card number
|
||||
*
|
||||
* @example 4323344234423443
|
||||
*/
|
||||
'guarantor_card_number' => ['sometimes', 'string', 'digits:16'],
|
||||
|
||||
/**
|
||||
* Guarantor name on card
|
||||
*
|
||||
* @example Mahmyt Allaberdiyev
|
||||
*/
|
||||
'guarantor_card_name' => ['sometimes', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* Guarantor Card month
|
||||
*
|
||||
* @example 06
|
||||
*/
|
||||
'guarantor_card_month' => ['sometimes', 'string'],
|
||||
|
||||
/**
|
||||
* Guarantor Card year
|
||||
*
|
||||
* @example 2040
|
||||
*/
|
||||
'guarantor_card_year' => ['sometimes', 'string'],
|
||||
|
||||
/**
|
||||
* Guarantor Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'guarantor_passport_serie' => ['sometimes', 'string', Rule::in(PassportRepo::values())],
|
||||
|
||||
/**
|
||||
* Guarantor Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'guarantor_passport_id' => ['sometimes', 'numeric', 'digits:6'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor name
|
||||
*
|
||||
* @example Mahmyt
|
||||
*/
|
||||
'guarantor_2_name' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor surname
|
||||
*
|
||||
* @example Allaberdiev
|
||||
*/
|
||||
'guarantor_2_surname' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor patronic name
|
||||
*
|
||||
* @example Owezowich
|
||||
*/
|
||||
'guarantor_2_patronic_name' => ['nullable', 'string', 'max:255'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor card number
|
||||
*
|
||||
* @example 4323344234423443
|
||||
*/
|
||||
'guarantor_2_card_number' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string', 'digits:16'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor name on card
|
||||
*
|
||||
* @example Mahmyt Allaberdiyev
|
||||
*/
|
||||
'guarantor_2_card_name' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor Card month
|
||||
*
|
||||
* @example 06
|
||||
*/
|
||||
'guarantor_2_card_month' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string'],
|
||||
|
||||
/**
|
||||
* 2. Guarantor Card year
|
||||
*
|
||||
* @example 2040
|
||||
*/
|
||||
'guarantor_2_card_year' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string'],
|
||||
|
||||
/**
|
||||
* Guarantor Passport serie
|
||||
*
|
||||
* @example I-AS
|
||||
*/
|
||||
'guarantor_2_passport_serie' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'string', Rule::in(PassportRepo::values())],
|
||||
|
||||
/**
|
||||
* Guarantor Passport number
|
||||
*
|
||||
* @example 100999
|
||||
*/
|
||||
'guarantor_2_passport_id' => [Rule::requiredIf($this->input('loan_amount') > 20000), 'numeric', 'digits:6'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -48,10 +48,10 @@ class LoanOrderIndexResource extends JsonResource
|
||||
'work_position' => $this->work_position,
|
||||
'education' => $this->education,
|
||||
'marriage_status' => $this->marriage_status,
|
||||
'passport_one' => $this->passport_one,
|
||||
'passport_two' => $this->passport_two,
|
||||
'passport_three' => $this->passport_three,
|
||||
'passport_four' => $this->passport_four,
|
||||
'passport_one' => url('/storage/'.$this->passport_one),
|
||||
'passport_two' => url('/storage/'.$this->passport_two),
|
||||
'passport_three' => url('/storage/'.$this->passport_three),
|
||||
'passport_four' => url('/storage/'.$this->passport_four),
|
||||
'user_id' => $this->user_id,
|
||||
'status' => $this->status,
|
||||
'notes' => $this->notes,
|
||||
|
||||
@@ -5,14 +5,16 @@ namespace App\Modules\LoanRemainingOrder\Controllers;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Modules\LoanRemainingOrder\Actions\FetchRemainingLoanFromBilling;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
use Dedoc\Scramble\Attributes\Group;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
#[Group('Sargytlar - Karz - Karzyň galyndysy')]
|
||||
class LoanRemainingOrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* Return remaning loan of person.
|
||||
* Galan karzyny görip biler, zaýawka içinde knopka bolýar, basaňdan soň modal jogaby bermeli.
|
||||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
@@ -30,36 +32,4 @@ class LoanRemainingOrderController extends Controller
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Request $request): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Request $request): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laravel\Nova\Actions\Actionable;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
|
||||
@@ -25,6 +26,10 @@ use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
* @property int $user_id
|
||||
* @property string $address
|
||||
* @property array $sender_datas
|
||||
* @property ?string $sender_full_name
|
||||
* @property ?string $sender_passport_serie
|
||||
* @property ?string $sender_passport_number
|
||||
* @property ?string $sender_deposit_account
|
||||
* @property array $payment_reciever
|
||||
* @property string $documents
|
||||
* @property string $status
|
||||
@@ -36,6 +41,7 @@ use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
*/
|
||||
class SberPaymentOrder extends Model implements HasMedia
|
||||
{
|
||||
use Actionable;
|
||||
use InteractsWithMedia;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
* @property string $tmt_payment_amount
|
||||
* @property string $usd_payment_amount
|
||||
* @property bool $paid
|
||||
* @property bool $synced_with_system
|
||||
* @property \Illuminate\Support\Carbon $created_at
|
||||
* @property \Illuminate\Support\Carbon $updated_at
|
||||
*/
|
||||
@@ -36,6 +37,16 @@ class SberPaymentOrderItem extends Model implements HasMedia
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'paid' => 'boolean',
|
||||
'synced_with_system' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* Parent order
|
||||
*
|
||||
|
||||
@@ -8,6 +8,44 @@ use Illuminate\Http\Request;
|
||||
|
||||
trait NovaSberPaymentOrderAuth
|
||||
{
|
||||
/**
|
||||
* Determine if the resource should be available for the given request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function authorizeToViewAny(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isSystemUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var SberPaymentOrder $resource */
|
||||
$resource = $this->resource;
|
||||
if ($resource->user_id == auth()->id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AuthorizationException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the resource should be available for the given request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return bool
|
||||
*/
|
||||
public static function authorizedToViewAny(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** View */
|
||||
public function authorizeToView(Request $request)
|
||||
{
|
||||
@@ -57,7 +95,7 @@ trait NovaSberPaymentOrderAuth
|
||||
}
|
||||
|
||||
/** Delete button */
|
||||
public function authorizedToDelete(Request $request)
|
||||
public function authorizedToDelete(Request $request): bool
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
|
||||
@@ -72,26 +72,21 @@ class SberPaymentOrderFieldsForDetail
|
||||
Text::make(__('Current Residence'), 'address'),
|
||||
]),
|
||||
new Panel(__('Payment'), [
|
||||
SimpleRepeatable::make(__('Payment sender data'), 'sender_datas', [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
->options(PassportRepo::values()),
|
||||
Text::make(__('Payment sender data'), function () use ($resource) {
|
||||
return sprintf(
|
||||
'<strong>%s-%s %s</strong>',
|
||||
$resource->sender_passport_serie,
|
||||
$resource->sender_passport_number,
|
||||
$resource->sender_full_name
|
||||
);
|
||||
})->asHtml(),
|
||||
|
||||
NovaInputmask::make(__('Passport number'), 'passport_number')
|
||||
->mask('999999'),
|
||||
|
||||
Text::make(
|
||||
name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
|
||||
attribute: 'full_name'
|
||||
)
|
||||
->rules('required', 'max:255'),
|
||||
|
||||
Text::make(
|
||||
name: __('Goýum hasaby'),
|
||||
attribute: 'deposit_account'
|
||||
)
|
||||
->rules('required', 'max:255'),
|
||||
])->minRows(1)->rules('required'),
|
||||
Text::make(__('Töleg ugradyjynyň goýum hasaby'), function () use ($resource) {
|
||||
return sprintf(
|
||||
'<strong>%s</strong>',
|
||||
number_format($resource->sender_deposit_account, 0, '', '')
|
||||
);
|
||||
})->asHtml(),
|
||||
|
||||
SimpleRepeatable::make(__('Payee information'), 'payment_reciever', [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
|
||||
@@ -28,42 +28,18 @@ trait NovaSberPaymentOrderItemAuth
|
||||
/** Edit button */
|
||||
public function authorizedToUpdate(Request $request): bool
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Update */
|
||||
public function authorizeToUpdate(Request $request): void
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe()) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AuthorizationException;
|
||||
}
|
||||
|
||||
/** Delete button */
|
||||
public function authorizedToDelete(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Force delete */
|
||||
public function authorizedToForceDelete(Request $request)
|
||||
{
|
||||
return auth()->user()->isMe() ? true : false;
|
||||
return auth()->user()->isMe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ class NovaSberPaymentOrder extends Resource
|
||||
*/
|
||||
public static function indexQuery(NovaRequest $request, mixed $query): Builder
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
@@ -252,32 +253,38 @@ class NovaSberPaymentOrder extends Resource
|
||||
->hideFromIndex(),
|
||||
]),
|
||||
|
||||
new Panel(__('Payment'), [
|
||||
SimpleRepeatable::make(__('Payment sender data'), 'sender_datas', [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(PassportRepo::values())
|
||||
->rules('required')
|
||||
->sortable(),
|
||||
new Panel(__('Payment sender data'), [
|
||||
Select::make(__('Passport serie'), 'sender_passport_serie')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(PassportRepo::values())
|
||||
->rules('required')
|
||||
->fullWidth()
|
||||
->sortable(),
|
||||
|
||||
NovaInputmask::make(__('Passport number'), 'passport_number')
|
||||
->mask('999999')
|
||||
->rules('required', 'max:255'),
|
||||
NovaInputmask::make(__('Passport number'), 'sender_passport_number')
|
||||
->mask('999999')
|
||||
->fullWidth()
|
||||
->rules('required', 'max:255'),
|
||||
|
||||
Text::make(
|
||||
name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
|
||||
attribute: 'full_name'
|
||||
)
|
||||
->rules('required', 'max:255'),
|
||||
Text::make(
|
||||
name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
|
||||
attribute: 'sender_full_name'
|
||||
)
|
||||
->fullWidth()
|
||||
->rules('required', 'max:255'),
|
||||
|
||||
Text::make(
|
||||
name: __('Goýum hasaby'),
|
||||
attribute: 'deposit_account'
|
||||
)
|
||||
->rules('required', 'max:255'),
|
||||
])->minRows(1)->rules('required'),
|
||||
Text::make(
|
||||
name: __('Goýum hasaby'),
|
||||
attribute: 'sender_deposit_account'
|
||||
)->fullWidth()
|
||||
->rules('required', 'digits:15')
|
||||
->fillUsing(function ($request, $model, $attribute) {
|
||||
$model->sender_deposit_account = strval($request->sender_deposit_account);
|
||||
}),
|
||||
]),
|
||||
|
||||
new Panel(__('Payee information'), [
|
||||
SimpleRepeatable::make(__('Payee information'), 'payment_reciever', [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
@@ -343,22 +350,22 @@ class NovaSberPaymentOrder extends Resource
|
||||
public function actions(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
MakeSberPaymentAction::make()
|
||||
->icon('credit-card')
|
||||
->sole()
|
||||
->canSee(function ($request) {
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $resource */
|
||||
$resource = $this->resource;
|
||||
// MakeSberPaymentAction::make()
|
||||
// ->icon('credit-card')
|
||||
// ->sole()
|
||||
// ->canSee(function ($request) {
|
||||
// /** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $resource */
|
||||
// $resource = $this->resource;
|
||||
|
||||
if (in_array($resource->status, [
|
||||
OrderRepo::PENDING,
|
||||
OrderRepo::CANCELLED,
|
||||
])) {
|
||||
return false;
|
||||
}
|
||||
// if (in_array($resource->status, [
|
||||
// OrderRepo::PENDING,
|
||||
// OrderRepo::CANCELLED,
|
||||
// ])) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}),
|
||||
// return true;
|
||||
// }),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\Branch\Branch;
|
||||
use App\Models\Payment\OnlinePaymentHistory;
|
||||
use App\Modules\SberPaymentOrder\Nova\Resources\Item\NovaSberPaymentOrderItemAuth;
|
||||
use App\Nova\Actions\CheckOnlinePayment;
|
||||
use App\Nova\Actions\Sber\SyncWithSystem;
|
||||
use App\Nova\Resource;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -119,6 +120,8 @@ class NovaSberPaymentOrderItem extends Resource
|
||||
Text::make('Amalyň referensi', fn ($model) => $model->payment_order_number),
|
||||
|
||||
Boolean::make(__('Paid'), 'paid'),
|
||||
|
||||
Boolean::make(__('Synced with system'), 'synced_with_system'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -171,7 +174,18 @@ class NovaSberPaymentOrderItem extends Resource
|
||||
]);
|
||||
})->icon('server')
|
||||
->sole()
|
||||
->withoutConfirmation(),
|
||||
->withoutConfirmation()
|
||||
->canSee(function ($request) {
|
||||
return auth()->user()->isSystemUser();
|
||||
}),
|
||||
|
||||
SyncWithSystem::make()
|
||||
->icon('cloud')
|
||||
->sole()
|
||||
->withoutConfirmation()
|
||||
->canSee(function ($request) {
|
||||
return auth()->user()->isAdmin();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\VisaMasterPaymentOrder\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class VisaMasterPaymentOrderController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json();
|
||||
}
|
||||
}
|
||||
@@ -116,30 +116,21 @@ class VisaMasterPaymentOrderFieldsForDetail
|
||||
->hideFromIndex(),
|
||||
]),
|
||||
new Panel(__('Payment'), [
|
||||
SimpleRepeatable::make(__('Payment sender data'), 'sender_datas', [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(PassportRepo::values())
|
||||
->rules('required')
|
||||
->sortable(),
|
||||
Text::make(__('Payment sender data'), function () use ($resource) {
|
||||
return sprintf(
|
||||
'<strong>%s-%s %s</strong>',
|
||||
$resource->sender_passport_serie,
|
||||
$resource->sender_passport_number,
|
||||
$resource->sender_full_name
|
||||
);
|
||||
})->asHtml(),
|
||||
|
||||
NovaInputmask::make(__('Passport number'), 'passport_number')
|
||||
->mask('999999')
|
||||
->rules('required', 'max:255'),
|
||||
|
||||
Text::make(
|
||||
name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
|
||||
attribute: 'full_name'
|
||||
)
|
||||
->rules('required', 'max:255'),
|
||||
|
||||
Text::make(
|
||||
name: __('Goýum hasaby'),
|
||||
attribute: 'deposit_account'
|
||||
)
|
||||
->rules('required', 'max:255'),
|
||||
])->minRows(1)->rules('required'),
|
||||
Text::make(__('Töleg ugradyjynyň goýum hasaby'), function () use ($resource) {
|
||||
return sprintf(
|
||||
'<strong>%s</strong>',
|
||||
number_format($resource->sender_deposit_account, 0, '', '')
|
||||
);
|
||||
})->asHtml(),
|
||||
|
||||
SimpleRepeatable::make(__('Payee information'), 'payment_reciever', [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
|
||||
@@ -263,32 +263,38 @@ class NovaVisaMasterPaymentOrder extends Resource
|
||||
->hideFromIndex(),
|
||||
]),
|
||||
|
||||
new Panel(__('Payment'), [
|
||||
SimpleRepeatable::make(__('Payment sender data'), 'sender_datas', [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(PassportRepo::values())
|
||||
->rules('required')
|
||||
->sortable(),
|
||||
new Panel(__('Payment sender data'), [
|
||||
Select::make(__('Passport serie'), 'sender_passport_serie')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(PassportRepo::values())
|
||||
->rules('required')
|
||||
->fullWidth()
|
||||
->sortable(),
|
||||
|
||||
NovaInputmask::make(__('Passport number'), 'passport_number')
|
||||
->mask('999999')
|
||||
->rules('required', 'max:255'),
|
||||
NovaInputmask::make(__('Passport number'), 'sender_passport_number')
|
||||
->mask('999999')
|
||||
->fullWidth()
|
||||
->rules('required', 'max:255'),
|
||||
|
||||
Text::make(
|
||||
name: sprintf('%s %s %s', __('Surname'), __('Name'), __('Patronic name')),
|
||||
attribute: 'full_name'
|
||||
)
|
||||
->rules('required', 'max:255'),
|
||||
Text::make(
|
||||
name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
|
||||
attribute: 'sender_full_name'
|
||||
)
|
||||
->fullWidth()
|
||||
->rules('required', 'max:255'),
|
||||
|
||||
Text::make(
|
||||
name: __('Goýum hasaby'),
|
||||
attribute: 'deposit_account'
|
||||
)
|
||||
->rules('required', 'max:255'),
|
||||
])->minRows(1)->rules('required'),
|
||||
Text::make(
|
||||
name: __('Goýum hasaby'),
|
||||
attribute: 'sender_deposit_account'
|
||||
)->fullWidth()
|
||||
->rules('required', 'string', 'max:255')
|
||||
->fillUsing(function ($request, $model, $attribute) {
|
||||
$model->sender_deposit_account = strval($request->sender_deposit_account);
|
||||
}),
|
||||
]),
|
||||
|
||||
new Panel(__('Payee information'), [
|
||||
SimpleRepeatable::make(__('Payee information'), 'payment_reciever', [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
|
||||
@@ -120,6 +120,8 @@ class NovaVisaMasterPaymentOrderItem extends Resource
|
||||
Text::make('Amalyň referensi', fn ($model) => $model->payment_order_number),
|
||||
|
||||
Boolean::make(__('Paid'), 'paid'),
|
||||
|
||||
Boolean::make(__('Synced with system'), 'synced_with_system'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,12 @@ class CheckOnlinePaymentStatus 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)
|
||||
{
|
||||
/** @var \App\Models\Order\Card\CardOrder */
|
||||
$item = $models->first();
|
||||
|
||||
$onlinePaymentResource = OnlinePaymentHistory::query()
|
||||
@@ -58,7 +59,14 @@ class CheckOnlinePaymentStatus extends Action
|
||||
$username = $item->branch->billing_username;
|
||||
$password = $item->branch->billing_password;
|
||||
|
||||
if (($username == '' || $password == '') || (is_null($username) || is_null($password))) {
|
||||
if (is_null($username) || is_null($password)) {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'HALKBANK API',
|
||||
'body' => 'Ulanyjy ady bilen açar sözi gabat gelmedi',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($username == '' || $password == '') {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'HALKBANK API',
|
||||
'body' => 'Ulanyjy ady bilen açar sözi gabat gelmedi',
|
||||
@@ -82,9 +90,9 @@ class CheckOnlinePaymentStatus 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)
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
]);
|
||||
}
|
||||
|
||||
$total_amount = floatval(number_format($payment_amount, 2, '.', '')) + 23;
|
||||
$total_amount = floatval(number_format($payment_amount, 2, '.', '')) + 115;
|
||||
|
||||
$payment = $this->order($resource, $total_amount);
|
||||
|
||||
@@ -126,8 +126,8 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
return [
|
||||
Heading::make(Blade::render(<<<HTML
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 USD = $usd_to_tmt TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">Bankyň tutumy: 20 TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">GBÜS tutumy: 3 TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">Bankyň tutumy: 100 TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">GBÜS tutumy: 15 TMT</h3>
|
||||
HTML))->asHtml(),
|
||||
|
||||
Text::make(__('Töleg aý'), 'month')
|
||||
@@ -173,7 +173,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
|
||||
if ($payment_amount) {
|
||||
$field->setValue(
|
||||
floatval(number_format($payment_amount, 2, '.', '')) + 23
|
||||
floatval(number_format($payment_amount, 2, '.', '')) + 115
|
||||
);
|
||||
} else {
|
||||
$field->setValue('');
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Modules\VisaMasterSettings\Models\VisaMasterSettings;
|
||||
use App\Repos\Payment\OnlinePaymentRepo;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
@@ -205,9 +206,11 @@ class MakeSberPaymentAction extends Action
|
||||
|
||||
$orderNumber = $onlinePaymentRepo->generateOrderNumber($resource);
|
||||
|
||||
$final_amount = number_format($amount, 2, '', '');
|
||||
|
||||
$paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
|
||||
'orderNumber' => $orderNumber,
|
||||
'amount' => number_format($amount, 2, '', ''),
|
||||
'amount' => $final_amount,
|
||||
'currency' => 934,
|
||||
'language' => 'ru',
|
||||
'userName' => $resource->branch->billing_sber_username,
|
||||
@@ -283,40 +286,36 @@ class MakeSberPaymentAction extends Action
|
||||
*
|
||||
* @param \Illuminate\Support\Carbon $today
|
||||
*/
|
||||
public function canAcceptPayment($today): bool
|
||||
public function canAcceptPayment(Carbon $today): bool
|
||||
{
|
||||
$year = $today->format('Y');
|
||||
$month = $today->format('m');
|
||||
$lastDay = lastDayOfMonth(year: $year, month: $month);
|
||||
$lastDay = $today->copy()->endOfMonth();
|
||||
$lastDayOfWeek = $lastDay->format('l');
|
||||
|
||||
// Condition 1: Check if today is the last day of the month
|
||||
if ($today->format('Y-m-d') === $lastDay->format('Y-m-d')) {
|
||||
$oneDayBefore = $lastDay->copy()->subDay(); // Saturday
|
||||
$twoDaysBefore = $lastDay->copy()->subDays(2); // Friday
|
||||
|
||||
// Condition 1: Today is the last day
|
||||
if ($today->isSameDay($lastDay)) {
|
||||
info('check 1');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine the day of the week for the last day of the month
|
||||
$lastDayOfWeek = $lastDay->format('l'); // e.g., 'Sunday', 'Saturday'
|
||||
// Condition 2: Last day is Sunday → forbid Friday & Saturday
|
||||
if ($lastDayOfWeek === 'Sunday' && ($today->isSameDay($oneDayBefore) || $today->isSameDay($twoDaysBefore))) {
|
||||
info('check 2');
|
||||
|
||||
// Condition 2: If the last day is Sunday, disallow Friday, Saturday, Sunday
|
||||
if ($lastDayOfWeek === 'Sunday') {
|
||||
$forbiddenDays = ['Friday', 'Saturday', 'Sunday'];
|
||||
if (in_array($today->format('l'), $forbiddenDays)) {
|
||||
info('check 2');
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Condition 3: If the last day is Saturday, disallow Friday
|
||||
if ($lastDayOfWeek === 'Saturday' && $today->format('l') === 'Friday') {
|
||||
// Condition 3: Last day is Saturday → forbid Friday
|
||||
if ($lastDayOfWeek === 'Saturday' && $today->isSameDay($oneDayBefore)) {
|
||||
info('check 3');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// If none of the conditions match, allow payment
|
||||
// Default: allow payment
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
73
app/Nova/Actions/Sber/SyncWithSystem.php
Normal file
73
app/Nova/Actions/Sber/SyncWithSystem.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Actions\Sber;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Nova\Actions\Action;
|
||||
use Laravel\Nova\Actions\ActionResponse;
|
||||
use Laravel\Nova\Fields\ActionFields;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
class SyncWithSystem extends Action
|
||||
{
|
||||
use InteractsWithQueue, Queueable;
|
||||
|
||||
/**
|
||||
* Name.
|
||||
*/
|
||||
public function name(): string
|
||||
{
|
||||
return __('Sync with system');
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param \Laravel\Nova\Fields\ActionFields $fields
|
||||
* @param \Illuminate\Support\Collection $models
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
{
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem $orderItem */
|
||||
$orderItem = $models->first();
|
||||
|
||||
$result = syncSberWithAzatAPI($orderItem);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
return $this->handleError($result);
|
||||
}
|
||||
|
||||
return ActionResponse::message('Sync with system success');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle error
|
||||
*
|
||||
* @param array $result
|
||||
*/
|
||||
private function handleError(array $result): mixed
|
||||
{
|
||||
if ($result['type'] === 'modal') {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'HALKBANK API',
|
||||
'body' => $result['error'],
|
||||
]);
|
||||
}
|
||||
|
||||
return ActionResponse::danger($result['error']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\CardBalance\Actions;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Nova\Actions\Action;
|
||||
use Laravel\Nova\Actions\ActionResponse;
|
||||
use Laravel\Nova\Fields\ActionFields;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
class DownloadCardBalance extends Action
|
||||
{
|
||||
use InteractsWithQueue, Queueable;
|
||||
|
||||
/**
|
||||
* Name.
|
||||
*/
|
||||
public function name(): string
|
||||
{
|
||||
return __('Download');
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param \Laravel\Nova\Fields\ActionFields $fields
|
||||
* @param \Illuminate\Support\Collection<array-key, \Illuminate\Database\Eloquent\Model> $models
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
{
|
||||
/** @var \App\Models\Order\Card\CardBalance\CardBalance */
|
||||
$model = $models->first();
|
||||
|
||||
/** @var \App\Nova\Resources\Order\Card\CardTransaction\Actions\ResponseTypes\AzatApiClientInfoAllResponse */
|
||||
$data = $this->fetchApi(
|
||||
passport_serie: $model->passport_serie,
|
||||
passport_id: $model->passport_id,
|
||||
card_masked: Str::mask($model->card_number, '*', 6, 6),
|
||||
card_expire_date: $model->card_month.'/'.substr($model->card_year, 2),
|
||||
);
|
||||
|
||||
if ($data->errCode != 0) {
|
||||
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]
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array<int, \Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch api
|
||||
*/
|
||||
public function fetchApi($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');
|
||||
}
|
||||
}
|
||||
140
app/Nova/Resources/Order/Card/CardBalance/CardBalance.php
Normal file
140
app/Nova/Resources/Order/Card/CardBalance/CardBalance.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\CardBalance;
|
||||
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
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 Laravel\Nova\Fields\Hidden;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Nurmuhammet\NovaInputmask\NovaInputmask;
|
||||
|
||||
class CardBalance extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
* @var class-string<\App\Models\Order\Card\CardBalance\CardBalance>
|
||||
*/
|
||||
public static $model = \App\Models\Order\Card\CardBalance\CardBalance::class;
|
||||
|
||||
/**
|
||||
* The single value that should be used to represent the resource when being displayed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $title = 'unique_id';
|
||||
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public static $search = [
|
||||
'unique_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return __('Card balances');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return __('Card balance');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an "index" query for the given resource.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder<\App\Models\Order\Card\CardBalance\CardBalance> $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder<\App\Models\Order\Card\CardBalance\CardBalance>
|
||||
*/
|
||||
public static function indexQuery(NovaRequest $request, $query): Builder
|
||||
{
|
||||
/** @var \App\Models\User */
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
if ($user->isOperator() && count($user->branches()->pluck('branches.id')) < 1) {
|
||||
return $query->whereIn('branch_id', $user->branches()->pluck('branches.id'));
|
||||
}
|
||||
|
||||
return $query->where('user_id', $user->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array<int, \Laravel\Nova\Panel|\Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
ID::make()->sortable(),
|
||||
|
||||
Hidden::make('user_id')
|
||||
->default(auth()->id())
|
||||
->hideWhenUpdating(),
|
||||
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(PassportRepo::values())
|
||||
->size('w-1/2')
|
||||
->rules('required'),
|
||||
|
||||
NovaInputmask::make(__('Passport id'), 'passport_id')
|
||||
->mask('999999')
|
||||
->size('w-1/2')
|
||||
->rules('required', 'numeric', 'digits:6'),
|
||||
|
||||
NovaInputmask::make(__('Card number'), 'card_number')
|
||||
->mask('9999-9999-9999-9999')
|
||||
->storeRawValue()
|
||||
->size('md:w-1/2')
|
||||
->rules('required', 'digits:16'),
|
||||
|
||||
Select::make(__('Card').' '.__('Expiration month'), 'card_month')
|
||||
->searchable()
|
||||
->options(DateHelperRepository::staticNumberMonths())
|
||||
->size('md:w-1/4')
|
||||
->rules('required'),
|
||||
|
||||
Select::make(__('Card').' '.__('Expiration year'), 'card_year')
|
||||
->searchable()
|
||||
->options(DateHelperRepository::staticNumberYears())
|
||||
->size('md:w-1/4')
|
||||
->rules('required'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array<int, \Laravel\Nova\Actions\Action>
|
||||
*/
|
||||
public function actions(NovaRequest $request)
|
||||
{
|
||||
return [
|
||||
DownloadCardBalance::make()
|
||||
->icon('arrow-down-tray')
|
||||
->sole(),
|
||||
];
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -127,7 +127,7 @@ class CardOrder extends Resource
|
||||
return $query;
|
||||
}
|
||||
|
||||
if ($user->isOperator() && count($user->branches()->pluck('branches.id')) < 1) {
|
||||
if ($user->isOperator()) {
|
||||
return $query->whereIn('branch_id', $user->branches()->pluck('branches.id'));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\CardTransaction\Actions;
|
||||
|
||||
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 Mpdf\Mpdf;
|
||||
|
||||
class DownloadCardTransaction extends Action
|
||||
{
|
||||
use InteractsWithQueue, Queueable;
|
||||
|
||||
/**
|
||||
* Name.
|
||||
*/
|
||||
public function name(): string
|
||||
{
|
||||
return __('Download');
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param \Laravel\Nova\Fields\ActionFields $fields
|
||||
* @param \Illuminate\Support\Collection<array-key, \Illuminate\Database\Eloquent\Model> $models
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
{
|
||||
/** @var \App\Models\Order\Card\CardTransaction\CardTransaction */
|
||||
$model = $models->first();
|
||||
|
||||
$start_date = Carbon::create($fields['start_date']);
|
||||
$end_date = Carbon::create($fields['end_date']);
|
||||
|
||||
$response = $this->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: $start_date->format('d.m.Y'),
|
||||
end_date: $end_date->format('d.m.Y'),
|
||||
);
|
||||
|
||||
/** @var ResponseTypes\AzatApiClientInfoAllResponse */
|
||||
$data = Str::isJson($response)
|
||||
? json_decode($response)
|
||||
: emptyClass(errCode: 1, message: 'Connection issue to VP');
|
||||
|
||||
if ($data->errCode != 0) {
|
||||
return ActionResponse::danger($data->message);
|
||||
}
|
||||
|
||||
$url = $this->doFiles($model, $data);
|
||||
|
||||
return ActionResponse::openInNewTab($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @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'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles all file stuff
|
||||
*
|
||||
* @param $model
|
||||
* @param $data
|
||||
*/
|
||||
public function doFiles($model, $data): string
|
||||
{
|
||||
$unique_folder_name = Str::snake(str_replace(':', '-', $model->created_at->toDateTimeString()));
|
||||
$dir = public_path("files/{$unique_folder_name}");
|
||||
|
||||
File::makeDirectory($dir, 0777, true, true);
|
||||
|
||||
$fileDest = $dir."/{$model->id}.pdf";
|
||||
|
||||
$this->generateFile($data, $fileDest);
|
||||
|
||||
return url("files/{$unique_folder_name}/{$model->id}.pdf");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch from internal API
|
||||
*
|
||||
* @param string $passport_serie
|
||||
* @param string $passport_id
|
||||
* @param string $card_number_masked
|
||||
* @param string $card_expire_date
|
||||
* @param string $start_date
|
||||
* @param string $end_date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetchApi(
|
||||
string $passport_serie,
|
||||
string $passport_id,
|
||||
string $card_number_masked,
|
||||
string $card_expire_date,
|
||||
string $start_date,
|
||||
string $end_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", "clientType": "recipient", "cardMaskNumber": "%s", "expDate": "%s", "fromDate" : "%s", "toDate" : "%s" }', $passport_serie, $passport_id, $card_number_masked, $card_expire_date, $start_date, $end_date),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate file
|
||||
*
|
||||
* @param ResponseTypes\AzatApiClientInfoAllResponse $data
|
||||
* @param string $fileDest
|
||||
*/
|
||||
public function generateFile($data, $fileDest): void
|
||||
{
|
||||
$mpdf = new Mpdf;
|
||||
|
||||
// Write HTML content...
|
||||
$html = Blade::render('orders.cards.card-transaction.download-card-transaction', [
|
||||
'data' => $data,
|
||||
'extra' => $this->getExtraVariables($data),
|
||||
]);
|
||||
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
// Save the PDF to a file...
|
||||
$mpdf->Output($fileDest, \Mpdf\Output\Destination::FILE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ResponseTypes\AzatApiClientInfoAllResponse $data
|
||||
*/
|
||||
public function getExtraVariables($data): object
|
||||
{
|
||||
if (count($data->transactions) < 1) {
|
||||
return emptyClass(basdakyGalyndy: 0, ahyrkyGalyndy: 0, girdeji: 0, cykdajy: 0);
|
||||
}
|
||||
|
||||
$basdakyGalyndy = $data->transactions[0]->rest;
|
||||
$basdakyTransaksiya = $data->transactions[0]->currOperSum;
|
||||
$sonkyGalyndy = $data->transactions[count($data->transactions) - 1]->rest;
|
||||
|
||||
$positive = 0;
|
||||
$negative = 0;
|
||||
for ($i = 0; $i < count($data->transactions); $i++) {
|
||||
if ($data->transactions[$i]->sign == '-') {
|
||||
$negative += $data->transactions[$i]->currOperSum;
|
||||
} else {
|
||||
$positive += $data->transactions[$i]->currOperSum;
|
||||
}
|
||||
}
|
||||
|
||||
return emptyClass(
|
||||
basdakyGalyndy: $basdakyGalyndy - ($basdakyTransaksiya),
|
||||
ahyrkyGalyndy: $sonkyGalyndy,
|
||||
girdeji: $positive,
|
||||
cykdajy: $negative
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\CardTransaction\Actions\ResponseTypes;
|
||||
|
||||
class AzatApiClientInfoAllResponse
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\CardTransaction;
|
||||
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
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 Laravel\Nova\Fields\Hidden;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Nurmuhammet\NovaInputmask\NovaInputmask;
|
||||
|
||||
class CardTransaction extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
* @var class-string<\App\Models\Order\Card\CardTransaction\CardTransaction>
|
||||
*/
|
||||
public static $model = \App\Models\Order\Card\CardTransaction\CardTransaction::class;
|
||||
|
||||
/**
|
||||
* The single value that should be used to represent the resource when being displayed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $title = 'unique_id';
|
||||
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public static $search = [
|
||||
'unique_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return __('Card transactions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return __('Card transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an "index" query for the given resource.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder<\App\Models\Order\Card\CardTransaction\CardTransaction> $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder<\App\Models\Order\Card\CardTransaction\CardTransaction>
|
||||
*/
|
||||
public static function indexQuery(NovaRequest $request, $query): Builder
|
||||
{
|
||||
/** @var \App\Models\User */
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
if ($user->isOperator() && count($user->branches()->pluck('branches.id')) < 1) {
|
||||
return $query->whereIn('branch_id', $user->branches()->pluck('branches.id'));
|
||||
}
|
||||
|
||||
return $query->where('user_id', $user->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array<int, \Laravel\Nova\Panel|\Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
ID::make()->sortable(),
|
||||
|
||||
Hidden::make('user_id')
|
||||
->default(auth()->id())
|
||||
->hideWhenUpdating(),
|
||||
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(PassportRepo::values())
|
||||
->size('w-1/2')
|
||||
->rules('required'),
|
||||
|
||||
NovaInputmask::make(__('Passport id'), 'passport_id')
|
||||
->mask('999999')
|
||||
->size('w-1/2')
|
||||
->rules('required', 'numeric', 'digits:6'),
|
||||
|
||||
NovaInputmask::make(__('Card number'), 'card_number')
|
||||
->mask('9999-9999-9999-9999')
|
||||
->storeRawValue()
|
||||
->size('md:w-1/2')
|
||||
->rules('required', 'digits:16'),
|
||||
|
||||
Select::make(__('Card').' '.__('Expiration month'), 'card_month')
|
||||
->searchable()
|
||||
->options(DateHelperRepository::staticNumberMonths())
|
||||
->size('md:w-1/4')
|
||||
->rules('required'),
|
||||
|
||||
Select::make(__('Card').' '.__('Expiration year'), 'card_year')
|
||||
->searchable()
|
||||
->options(DateHelperRepository::staticNumberYears())
|
||||
->size('md:w-1/4')
|
||||
->rules('required'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array<int, \Laravel\Nova\Actions\Action>
|
||||
*/
|
||||
public function actions(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
DownloadCardTransaction::make()
|
||||
->icon('arrow-down-tray')
|
||||
->sole(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\Requisite\Actions;
|
||||
|
||||
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Collection;
|
||||
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\Http\Requests\NovaRequest;
|
||||
use PhpOffice\PhpWord\TemplateProcessor;
|
||||
|
||||
class DownloadCardRequisite extends Action
|
||||
{
|
||||
use InteractsWithQueue, Queueable;
|
||||
|
||||
/**
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param \Laravel\Nova\Fields\ActionFields $fields
|
||||
* @param \Illuminate\Support\Collection<array-key, \Illuminate\Database\Eloquent\Model> $models
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
{
|
||||
/** @var \App\Models\Order\Card\Requisite\CardRequisite */
|
||||
$model = $models->first();
|
||||
|
||||
/** @var \App\Nova\Resources\Order\Card\CardTransaction\Actions\ResponseTypes\AzatApiClientInfoAllResponse */
|
||||
$data = $this->fetchApi($model);
|
||||
|
||||
if ($data->errCode != 0) {
|
||||
return ActionResponse::danger($data->message);
|
||||
}
|
||||
|
||||
$path = $this->generateFile($model, $data);
|
||||
|
||||
return ActionResponse::download(
|
||||
name: 'kart-rekwizit.docx',
|
||||
url: url($path)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array<int, \Laravel\Nova\Fields\Field>
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch api
|
||||
*
|
||||
* @param \App\Models\Order\Card\Requisite\CardRequisite $model
|
||||
* @return object
|
||||
*/
|
||||
public function fetchApi($model)
|
||||
{
|
||||
$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,
|
||||
);
|
||||
|
||||
return Str::isJson($response)
|
||||
? json_decode($response)
|
||||
: emptyClass(errCode: 1, message: 'Connection issue to VP');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate file
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
$doc_path = app_path('Nova/Resources/Order/Card/Requisite/Docs/card-requisite.docx');
|
||||
|
||||
$templateProcessor = new TemplateProcessor($doc_path);
|
||||
$templateProcessor->setValues([
|
||||
'year' => date('Y'),
|
||||
'name' => $data->clientName,
|
||||
'contract' => $data->cardAccountNumber,
|
||||
'bank' => $data->depName,
|
||||
'hasap' => $data->accountNumber,
|
||||
'sb' => $data->inn,
|
||||
'bab' => $data->mfo,
|
||||
'card_type' => $data->cardName,
|
||||
'card_number' => $data->cardPan,
|
||||
'phone' => $data->mobilPhone ?? '-',
|
||||
'contract_date' => '---YOK---',
|
||||
'card_order_date' => '---YOK---',
|
||||
'card_given_date' => '---YOK---',
|
||||
]);
|
||||
|
||||
$unique_folder_name = Str::snake(str_replace(':', '-', $model->created_at->toDateTimeString()));
|
||||
$dir = public_path("files/card-requisite/{$unique_folder_name}");
|
||||
|
||||
File::makeDirectory($dir, 0777, true, true);
|
||||
|
||||
$filePath = $dir."/{$model->id}.docx";
|
||||
|
||||
$templateProcessor->saveAs($filePath);
|
||||
|
||||
return "files/card-requisite/{$unique_folder_name}/{$model->id}.docx";
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,16 @@ namespace App\Nova\Resources\Order\Card\Requisite;
|
||||
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Order\Card\Requisite\CardRequisite as CardRequisiteModel;
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Nova\Filters\RegionFilter;
|
||||
use App\Nova\Filters\StatusFilter;
|
||||
use App\Nova\Nova;
|
||||
use App\Nova\Resource;
|
||||
use App\Nova\Resources\Order\Card\CardType;
|
||||
use App\Nova\Resources\Order\Card\Requisite\Actions\DownloadCardRequisite;
|
||||
use App\Nova\Resources\Order\Card\Requisite\Concerns\CardRequisiteFieldsForDetail;
|
||||
use App\Nova\Resources\Order\Card\Requisite\Concerns\CardRequisiteFieldsForIndex;
|
||||
use App\Repos\Order\Card\CardOrderRepo;
|
||||
use App\Repos\Order\Card\CardTypeRepo;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Nova\NovaRepo;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
@@ -20,8 +22,8 @@ use App\Rules\OnlyLetters;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Nova\Fields\BelongsTo;
|
||||
use Laravel\Nova\Fields\Date;
|
||||
use Laravel\Nova\Fields\File;
|
||||
use Laravel\Nova\Fields\Hidden;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Image;
|
||||
@@ -205,19 +207,28 @@ class CardRequisite extends Resource
|
||||
->canSeeWhen('systemUser', $this),
|
||||
|
||||
new Panel(__('Card'), [
|
||||
Select::make(__('Card type'), 'card_type_id')
|
||||
->displayUsingLabels()
|
||||
->fullWidth()
|
||||
->searchable()
|
||||
->options(CardTypeRepo::values())
|
||||
->size('w-1/2')
|
||||
->rules('required'),
|
||||
BelongsTo::make(__('Type'), 'cardType', CardType::class)
|
||||
->sortable()
|
||||
->size('md:w-1/4')
|
||||
->required(),
|
||||
|
||||
NovaInputmask::make(__('Card number'), 'card_number')
|
||||
->mask('9999 9999 9999 9999')
|
||||
->storeRawValue()
|
||||
->size('w-1/2')
|
||||
->size('md:w-1/4')
|
||||
->rules('required', 'int', 'digits:16'),
|
||||
|
||||
Select::make(__('Card').' '.__('Expiration month'), 'card_month')
|
||||
->searchable()
|
||||
->options(DateHelperRepository::staticNumberMonths())
|
||||
->size('md:w-1/4')
|
||||
->rules('required'),
|
||||
|
||||
Select::make(__('Card').' '.__('Expiration year'), 'card_year')
|
||||
->searchable()
|
||||
->options(DateHelperRepository::staticNumberYears())
|
||||
->size('md:w-1/4')
|
||||
->rules('required'),
|
||||
]),
|
||||
|
||||
new Panel(__('Location'), [
|
||||
@@ -301,13 +312,6 @@ class CardRequisite extends Resource
|
||||
->creationRules('required')
|
||||
->updateRules('nullable'),
|
||||
]),
|
||||
|
||||
new Panel(__('Ready files'), [
|
||||
File::make(__('Card requisite'), 'ready_files')
|
||||
->rules('max:2048', 'mimes:doc,docx,rtf,pdf,jpg,png,jpeg')
|
||||
->hideWhenCreating()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -325,4 +329,18 @@ class CardRequisite extends Resource
|
||||
new StatusFilter,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Actions
|
||||
*
|
||||
* @return array<int, \Laravel\Nova\Actions\Action>
|
||||
*/
|
||||
public function actions(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
DownloadCardRequisite::make()
|
||||
->icon('arrow-down-tray')
|
||||
->sole(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\Requisite\Concerns;
|
||||
|
||||
use App\Modules\DateHelper\Repositories\DateHelperRepository;
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\Order\Card\CardType;
|
||||
use App\Nova\User;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
@@ -12,7 +12,6 @@ use Laravel\Nova\Fields\Badge;
|
||||
use Laravel\Nova\Fields\BelongsTo;
|
||||
use Laravel\Nova\Fields\Date;
|
||||
use Laravel\Nova\Fields\DateTime;
|
||||
use Laravel\Nova\Fields\File;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Image;
|
||||
use Laravel\Nova\Fields\Number;
|
||||
@@ -51,11 +50,15 @@ class CardRequisiteFieldsForDetail
|
||||
BelongsTo::make(__('Created by').': ', 'user', User::class),
|
||||
|
||||
new Panel(__('Card'), [
|
||||
BelongsTo::make(__('Card type'), 'cardType', CardType::class),
|
||||
|
||||
NovaInputmask::make(__('Card number'), 'card_number')
|
||||
->mask('9999 9999 9999 9999')
|
||||
->storeRawValue(),
|
||||
|
||||
Select::make(__('Card').' '.__('Expiration month'), 'card_month')
|
||||
->options(DateHelperRepository::staticNumberMonths()),
|
||||
|
||||
Select::make(__('Card').' '.__('Expiration year'), 'card_year')
|
||||
->options(DateHelperRepository::staticNumberYears()),
|
||||
]),
|
||||
|
||||
new Panel(__('Location'), [
|
||||
@@ -97,10 +100,6 @@ class CardRequisiteFieldsForDetail
|
||||
Image::make(__('Passport (page 8-9)'), 'passport_three'),
|
||||
Image::make(__('Passport (page 32)'), 'passport_four'),
|
||||
]),
|
||||
|
||||
new Panel(__('Ready files'), [
|
||||
File::make(__('Card requisite'), 'ready_files'),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
BIN
app/Nova/Resources/Order/Card/Requisite/Docs/card-requisite.docx
Normal file
BIN
app/Nova/Resources/Order/Card/Requisite/Docs/card-requisite.docx
Normal file
Binary file not shown.
@@ -9,7 +9,6 @@ use App\Nova\Filters\StatusFilter;
|
||||
use App\Nova\Resource;
|
||||
use App\Nova\Resources\Order\Loan\LoanPaidOffLetter\LoanPaidOffLetterOrderFieldsForDetail;
|
||||
use App\Nova\Resources\Order\Loan\LoanPaidOffLetter\LoanPaidOffLetterOrderFieldsForIndex;
|
||||
use App\Repos\Order\Card\CardOrderRepo;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Nova\NovaRepo;
|
||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||
@@ -118,17 +117,6 @@ class LoanPaidOffLetterOrder extends Resource
|
||||
return $query->where('user_id', $request->user()->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* After resource created
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
*/
|
||||
public static function afterCreate(NovaRequest $request, Model $model): void
|
||||
{
|
||||
$model->update(['unique_id' => CardOrderRepo::fillUniqueId($model)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields for index.
|
||||
*
|
||||
|
||||
@@ -13,9 +13,9 @@ class LoanOrderPolicy
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
if ($user->isOperator()) {
|
||||
return $user->getPermissionNames()->contains('ViewLoanOrders');
|
||||
}
|
||||
// if ($user->isOperator()) {
|
||||
// return $user->getPermissionNames()->contains('ViewLoanOrders');
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -29,13 +29,17 @@ class LoanOrderPolicy
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($user->isOperator() && $user->getPermissionNames()->contains('ViewLoanOrders')) {
|
||||
return in_array(
|
||||
$loanOrder->branch_id,
|
||||
$user->branches->pluck('id')->toArray()
|
||||
);
|
||||
if ($user->isOperator()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if ($user->isOperator() && $user->getPermissionNames()->contains('ViewLoanOrders')) {
|
||||
// return in_array(
|
||||
// $loanOrder->branch_id,
|
||||
// $user->branches->pluck('id')->toArray()
|
||||
// );
|
||||
// }
|
||||
|
||||
if ($user->ownsLoanOrder($loanOrder)) {
|
||||
return true;
|
||||
}
|
||||
@@ -48,8 +52,12 @@ class LoanOrderPolicy
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
// if ($user->isOperator()) {
|
||||
// return $user->getPermissionNames()->contains('ViewLoanOrders');
|
||||
// }
|
||||
|
||||
if ($user->isOperator()) {
|
||||
return $user->getPermissionNames()->contains('ViewLoanOrders');
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -64,13 +72,17 @@ class LoanOrderPolicy
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($user->isOperator() && $user->getPermissionNames()->contains('ViewLoanOrders')) {
|
||||
return in_array(
|
||||
$loanOrder->branch_id,
|
||||
$user->branches->pluck('id')->toArray()
|
||||
);
|
||||
if ($user->isOperator()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if ($user->isOperator() && $user->getPermissionNames()->contains('ViewLoanOrders')) {
|
||||
// return in_array(
|
||||
// $loanOrder->branch_id,
|
||||
// $user->branches->pluck('id')->toArray()
|
||||
// );
|
||||
// }
|
||||
|
||||
if ($user->ownsLoanOrder($loanOrder) && in_array($loanOrder->status, [
|
||||
OrderRepo::PENDING,
|
||||
])) {
|
||||
@@ -89,13 +101,17 @@ class LoanOrderPolicy
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($user->isOperator() && $user->getPermissionNames()->contains('ViewLoanOrders')) {
|
||||
return in_array(
|
||||
$loanOrder->branch_id,
|
||||
$user->branches->pluck('id')->toArray()
|
||||
);
|
||||
if ($user->isOperator()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if ($user->isOperator() && $user->getPermissionNames()->contains('ViewLoanOrders')) {
|
||||
// return in_array(
|
||||
// $loanOrder->branch_id,
|
||||
// $user->branches->pluck('id')->toArray()
|
||||
// );
|
||||
// }
|
||||
|
||||
if ($user->ownsLoanOrder($loanOrder)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class PermissionPolicy
|
||||
*/
|
||||
public function update(User $user, Permission $permission): bool
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
if ($user->isMe()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class PermissionPolicy
|
||||
*/
|
||||
public function delete(User $user, Permission $permission): bool
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
if ($user->isMe()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class PermissionPolicy
|
||||
*/
|
||||
public function restore(User $user, Permission $permission): bool
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
if ($user->isMe()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class PermissionPolicy
|
||||
*/
|
||||
public function forceDelete(User $user, Permission $permission): bool
|
||||
{
|
||||
if ($user->isAdmin()) {
|
||||
if ($user->isMe()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
Gate::define('isMe', fn (User $user) => $user->isMe());
|
||||
Gate::define('isSuperAdmin', fn (User $user) => $user->isSuperAdmin());
|
||||
Gate::define('isAdmin', fn (User $user) => $user->isAdmin());
|
||||
Gate::define('isCurrencyMaintainer', fn (User $user) => $user->isCurrencyMaintainer());
|
||||
Gate::define('systemUser', fn (User $user) => $user->isSystemUser());
|
||||
Gate::define('fuck', fn () => true);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class RouteServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
return Limit::perMinute(300)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
|
||||
@@ -39,7 +39,7 @@ trait HandlesBillingSyncing
|
||||
|
||||
$request = new Request(
|
||||
method: 'POST',
|
||||
uri: 'http://10.3.158.102:8888/api/paytrn/new',
|
||||
uri: 'http://10.3.158.102:9999/api/paytrn/new',
|
||||
headers: [
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => 'Basic YWRtaW46UUFad3N4MTIz',
|
||||
@@ -50,16 +50,16 @@ trait HandlesBillingSyncing
|
||||
$client = new Client;
|
||||
$response = $client->sendAsync($request)->wait();
|
||||
|
||||
// curl --location --request POST 'http://10.3.158.102:8888/api/paytrn/new' \
|
||||
// --header 'Authorization: Basic YWRtaW46UUFad3N4MTIz' \
|
||||
// curl --location 'http://10.3.158.102:9999/api/paytrn/new' \
|
||||
// --header 'Content-Type: application/json' \
|
||||
// --data-raw '{
|
||||
// "ecomId" : "0c406ee2-097d-42f7-86c8-18127bd87e10",
|
||||
// "agentId" : "1307",
|
||||
// "eposId" : "30400225",
|
||||
// "account" : "4324234234",
|
||||
// "rnn" : "002959773584",
|
||||
// "amount" : 0.1,
|
||||
// --header 'Authorization: Basic YWRtaW46UUFad3N4MTIz' \
|
||||
// --data '{
|
||||
// "ecomId" : "12345-12345-12345-12345",
|
||||
// "agentId" : "1304",
|
||||
// "eposId" : "30401238",
|
||||
// "account" : "130420912769753",
|
||||
// "rnn" : "110784016238",
|
||||
// "amount" : 895.46,
|
||||
// "payPurpose" : "Mart 2025"
|
||||
// }'
|
||||
|
||||
|
||||
@@ -53,13 +53,13 @@ trait HandlesCardOrderPayments
|
||||
'paymentStatus' => OnlinePaymentRepo::PAID,
|
||||
]);
|
||||
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
|
||||
$paymentHistory->update([
|
||||
'paymentStatus' => OnlinePaymentRepo::FAILED,
|
||||
]);
|
||||
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,8 @@ class OnlinePaymentRepo
|
||||
OnlinePaymentHistory $paymentHistory,
|
||||
Branch $bank_branch,
|
||||
Model $resource,
|
||||
string $returnURL
|
||||
string $returnURL,
|
||||
$response,
|
||||
): array {
|
||||
return [
|
||||
'success' => true,
|
||||
@@ -206,6 +207,7 @@ class OnlinePaymentRepo
|
||||
'bank_branch' => $bank_branch,
|
||||
'resource' => $resource,
|
||||
'paymentHistory' => $paymentHistory,
|
||||
'response' => $response,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -218,7 +220,8 @@ class OnlinePaymentRepo
|
||||
OnlinePaymentHistory $paymentHistory,
|
||||
Branch $bank_branch,
|
||||
Model $resource,
|
||||
string $returnURL
|
||||
string $returnURL,
|
||||
$response,
|
||||
): array {
|
||||
return [
|
||||
'success' => false,
|
||||
@@ -229,7 +232,7 @@ class OnlinePaymentRepo
|
||||
'return_url' => $returnURL,
|
||||
'paymentHistory' => $paymentHistory,
|
||||
'bank_branch' => $bank_branch,
|
||||
'resource' => $resource,
|
||||
'response' => $response,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@ trait HandlesSberPeyments
|
||||
]);
|
||||
|
||||
if ($response->failed()) {
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
|
||||
$payment_status = $response['paymentAmountInfo']['depositedAmount'] > 0;
|
||||
|
||||
$cardholderName = $response['cardAuthInfo']['cardholderName'] ?? '-';
|
||||
$cardPan = $response['cardAuthInfo']['Pan'] ?? '-';
|
||||
$cardPan = $response['cardAuthInfo']['pan'] ?? '-';
|
||||
|
||||
if ($payment_status) {
|
||||
$resource->update([
|
||||
@@ -64,12 +64,12 @@ trait HandlesSberPeyments
|
||||
'api_response' => $response->body(),
|
||||
]);
|
||||
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
|
||||
$resource->update([
|
||||
'payer_name' => $response['cardholderName'] ?? '-',
|
||||
'payer_card' => $response['Pan'] ?? '-',
|
||||
'payer_card' => $response['pan'] ?? '-',
|
||||
'paid' => false,
|
||||
]);
|
||||
|
||||
@@ -80,6 +80,6 @@ trait HandlesSberPeyments
|
||||
'api_response' => $response->body(),
|
||||
]);
|
||||
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,13 +43,13 @@ trait HandlesVisaMasterPayments
|
||||
]);
|
||||
|
||||
if ($response->failed()) {
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
|
||||
$payment_status = $response['paymentAmountInfo']['depositedAmount'] > 0;
|
||||
|
||||
$cardholderName = $response['cardAuthInfo']['cardholderName'] ?? '-';
|
||||
$cardPan = $response['cardAuthInfo']['Pan'] ?? '-';
|
||||
$cardPan = $response['cardAuthInfo']['pan'] ?? '-';
|
||||
|
||||
if ($payment_status) {
|
||||
$resource->update([
|
||||
@@ -65,7 +65,7 @@ trait HandlesVisaMasterPayments
|
||||
'api_response' => $response->json(),
|
||||
]);
|
||||
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
|
||||
$resource->update([
|
||||
@@ -81,6 +81,6 @@ trait HandlesVisaMasterPayments
|
||||
'api_response' => $response->json(),
|
||||
]);
|
||||
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,10 @@ use App\Nova\Dashboards\Main;
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\CurrencyRate;
|
||||
use App\Nova\Resources\NovaVisaMasterSetting;
|
||||
use App\Nova\Resources\Order\Card\CardBalance\CardBalance;
|
||||
use App\Nova\Resources\Order\Card\CardOrder;
|
||||
use App\Nova\Resources\Order\Card\CardState;
|
||||
use App\Nova\Resources\Order\Card\CardTransaction\CardTransaction;
|
||||
use App\Nova\Resources\Order\Card\CardType;
|
||||
use App\Nova\Resources\Order\Card\Pin\CardPin;
|
||||
use App\Nova\Resources\Order\Card\Requisite\CardRequisite;
|
||||
@@ -56,7 +58,9 @@ class NovaMenuRepo
|
||||
|
||||
MenuGroup::make(__('Card department'), [
|
||||
MenuItem::resource(CardOrder::class)->name(__('Order new card')),
|
||||
MenuItem::resource(CardTransaction::class),
|
||||
MenuItem::resource(CardRequisite::class),
|
||||
MenuItem::resource(CardBalance::class),
|
||||
MenuItem::resource(CardPin::class),
|
||||
])->collapsedByDefault(),
|
||||
|
||||
@@ -94,17 +98,18 @@ class NovaMenuRepo
|
||||
MenuItem::resource(Branch::class),
|
||||
])->collapsedByDefault(),
|
||||
|
||||
MenuGroup::make(__('Currencies'), [
|
||||
MenuItem::resource(CurrencyRate::class),
|
||||
MenuItem::resource(NovaVisaMasterSetting::class),
|
||||
])->collapsedByDefault(),
|
||||
|
||||
MenuGroup::make(__('Locale'), [
|
||||
MenuItem::resource(LocaleManagerResource::class),
|
||||
])->collapsedByDefault(),
|
||||
|
||||
])->icon('cog')->collapsedByDefault()->canSee(NovaPermissionRepo::isAdmin()),
|
||||
|
||||
MenuSection::make(__('Currencies'), [
|
||||
MenuItem::resource(CurrencyRate::class),
|
||||
MenuItem::resource(NovaVisaMasterSetting::class),
|
||||
])->icon('currency-dollar')
|
||||
->collapsedByDefault()
|
||||
->canSee(fn () => NovaPermissionRepo::isAdmin() || NovaPermissionRepo::isCurrencyMaintainer()),
|
||||
|
||||
MenuSection::resource(OnlinePaymentHistoryResource::class)
|
||||
->icon('credit-card')
|
||||
->canSee(NovaPermissionRepo::isAdmin()),
|
||||
|
||||
@@ -30,4 +30,12 @@ class NovaPermissionRepo
|
||||
{
|
||||
return fn () => Gate::allows('isAdmin', auth()->user());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is a currency maintainer
|
||||
*/
|
||||
public static function isCurrencyMaintainer(): Closure
|
||||
{
|
||||
return fn () => Gate::allows('isCurrencyMaintainer', auth()->user());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"dedoc/scramble": "^0.11.11",
|
||||
"dedoc/scramble": "^0.12",
|
||||
"denniseilander/pulse-about-application": "^0.1.1",
|
||||
"digital-creative/column-toggler": "^0.2.3",
|
||||
"digital-creative/icon-action-toolbar": "^0.1.2",
|
||||
@@ -26,12 +26,14 @@
|
||||
"maantje/pulse-php-fpm": "^0.2.1",
|
||||
"markwalet/nova-modal-response": "^0.3.0",
|
||||
"morrislaptop/laravel-pulse-4xx": "^0.0.2",
|
||||
"mpdf/mpdf": "^8.2",
|
||||
"nurmuhammet/nova-custom-html": "@dev",
|
||||
"nurmuhammet/nova-inputmask": "^1.0",
|
||||
"outl1ne/nova-detached-filters": "^2.1",
|
||||
"outl1ne/nova-grid": "@dev",
|
||||
"outl1ne/nova-simple-repeatable": "^2.2",
|
||||
"outl1ne/nova-translatable": "^2.2",
|
||||
"phpoffice/phpword": "dev-master",
|
||||
"spatie/laravel-backup": "^8.4",
|
||||
"spatie/laravel-medialibrary": "^11.9",
|
||||
"spatie/laravel-permission": "^6.1",
|
||||
@@ -44,14 +46,12 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"larastan/larastan": "^2.0",
|
||||
"laravel-lang/common": "^5.3",
|
||||
"laravel/envoy": "^2.10",
|
||||
"laravel/pint": "^1.0",
|
||||
"laravel/sail": "^1.18",
|
||||
"mockery/mockery": "^1.4.4",
|
||||
"nunomaduro/collision": "^7.0",
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpunit/phpunit": "^10.1",
|
||||
"spatie/laravel-ignition": "^2.0"
|
||||
},
|
||||
|
||||
1375
composer.lock
generated
1375
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -161,6 +161,20 @@ return [
|
||||
'level' => env('LOG_LEVEL', 'error'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'sber_job' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/sber_job.log'),
|
||||
'level' => env('LOG_LEVEL', 'error'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'visa_job' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/visa_job.log'),
|
||||
'level' => env('LOG_LEVEL', 'error'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -15,6 +15,10 @@ return new class extends PulseMigration
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::dropIfExists('pulse_values');
|
||||
Schema::dropIfExists('pulse_entries');
|
||||
Schema::dropIfExists('pulse_aggregates');
|
||||
|
||||
Schema::create('pulse_values', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('timestamp');
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user