first commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Poct;
|
||||
|
||||
use App\Models\Poct\Patients;
|
||||
use App\Models\Poct\Request\ListPemeriksaanRequest;
|
||||
use App\Models\Poct\Request\ListPemeriksaanResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ListPemeriksaanService
|
||||
{
|
||||
public function fetchPemeriksaan(ListPemeriksaanRequest $data, ListPemeriksaanResponse $result, $flag)
|
||||
{
|
||||
if ($flag == 'list') {
|
||||
$list_pemeriksaan = DB::connection('sqlsrv')->table('Patient')
|
||||
->select('Patient.ID as pasien_id', 'Patient.Lab_PatientID as pasien_norm', 'Patient.Location as pasien_ruangan', 'Patient.lastUpdDatetime as pasien_last_up_date', 'Result.ID as result_id',
|
||||
'Result.UnivTestName as result_test_name', 'Result.RValue as result_value', 'Result.Unit as result_unit', 'Result.ANormalFlag as result_normal_flag',
|
||||
'Result.TestEndDate as result_speciment_date', 'Operator.FirstName as operator_first_name', 'Operator.LastName as operator_last_name')
|
||||
->leftJoin('Result', 'Result._PID', '=', 'Patient.ID')
|
||||
->leftJoin('Operator', 'Operator.OperatorID', '=', 'Result.OperatiorID')
|
||||
->whereNotNull('Result.RValue')
|
||||
->whereRaw('LEN(Patient.Lab_PatientID) >= 10')
|
||||
->where(DB::raw("(convert(date,Result.TestEndDate))"), "=", $data->gettgl_order())
|
||||
->orderBy('Result.TestEndDate', 'DESC')
|
||||
->orderBy('Patient.Lab_PatientID', 'DESC')
|
||||
->get();
|
||||
} else {
|
||||
$list_pemeriksaan = DB::connection('sqlsrv')->table('Patient')
|
||||
->select('Patient.ID as pasien_id', 'Patient.Lab_PatientID as pasien_norm', 'Patient.Location as pasien_ruangan', 'Patient.lastUpdDatetime as pasien_last_up_date', 'Result.ID as result_id',
|
||||
'Result.UnivTestName as result_test_name', 'Result.RValue as result_value', 'Result.Unit as result_unit', 'Result.ANormalFlag as result_normal_flag',
|
||||
'Result.TestEndDate as result_speciment_date', 'Operator.FirstName as operator_first_name', 'Operator.LastName as operator_last_name')
|
||||
->leftJoin('Result', 'Result._PID', '=', 'Patient.ID')
|
||||
->leftJoin('Operator', 'Operator.OperatorID', '=', 'Result.OperatiorID')
|
||||
->whereNotNull('Result.RValue')
|
||||
->whereRaw('LEN(Patient.Lab_PatientID) >= 10')
|
||||
->where(DB::raw("(convert(date,Result.TestEndDate))"), ">=", $data->gettgl_awal())
|
||||
->where(DB::raw("(convert(date,Result.TestEndDate))"), "<=", $data->gettgl_akhir())
|
||||
->orderBy('Result.TestEndDate', 'DESC')
|
||||
->orderBy('Patient.Lab_PatientID', 'DESC')
|
||||
->get();
|
||||
}
|
||||
|
||||
if (count($list_pemeriksaan) > 0) {
|
||||
$result->setcountData(count($list_pemeriksaan));
|
||||
$data = [];
|
||||
foreach ($list_pemeriksaan as $ind => $item) {
|
||||
$data[$ind]['pasien_id'] = $item->pasien_id;
|
||||
$data[$ind]['pasien_norm'] = $item->pasien_norm;
|
||||
$data[$ind]['pasien_ruangan'] = $item->pasien_ruangan;
|
||||
$data[$ind]['pasien_last_up_date'] = $item->pasien_last_up_date;
|
||||
$data[$ind]['result_id'] = $item->result_id;
|
||||
$data[$ind]['result_test_name'] = $item->result_test_name;
|
||||
$data[$ind]['result_value'] = $item->result_value;
|
||||
$data[$ind]['result_unit'] = $item->result_unit;
|
||||
$data[$ind]['result_normal_flag'] = $item->result_normal_flag;
|
||||
$data[$ind]['result_speciment_date'] = $item->result_speciment_date;
|
||||
$data[$ind]['operator_first_name'] = $item->operator_first_name;
|
||||
$data[$ind]['operator_last_name'] = $item->operator_last_name;
|
||||
}
|
||||
$result->setresponseData($data);
|
||||
} else {
|
||||
$result->setresponseCode("01");
|
||||
$result->setresponseMessage("Data Pemeriksaan Tidak Ditemukan!");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Qris\v1;
|
||||
|
||||
use App\Models\PaymentBank;
|
||||
use App\Models\PaymentJatimLogs;
|
||||
use App\Models\Qris\v1\QrisJatimPaymentRequest;
|
||||
use App\Models\Qris\v1\QrisJatimPaymentResponse;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
class QrisJatimService
|
||||
{
|
||||
protected $settings;
|
||||
protected $defaultHeaders = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->settings = array(
|
||||
'apiUrl' => env('BANK_JATIM_URL', 'https://jatimva.bankjatim.co.id/'),
|
||||
'merchant' => env('BANK_JATIM_MERCHANT', '9360011400001347721'),
|
||||
'hashcode' => env('BANK_JATIM_HASCODE', 'Y1MACZ4B5R'),
|
||||
'terminalUser' => env('BANK_JATIM_TERMINAL_USER', 'ID2024310949969'),
|
||||
'username' => env('BANK_JATIM_USERNAME', 'ID2024310949969'),
|
||||
'password' => env('BANK_JATIM_PASSWORD', 'ID2024310949969'),
|
||||
);
|
||||
$this->defaultHeaders = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
'Origin' => request()->getHost(),
|
||||
];
|
||||
$configs = [
|
||||
'base_uri' => $this->settings['apiUrl'],
|
||||
'headers' => $this->defaultHeaders,
|
||||
];
|
||||
$this->client = new Client($configs);
|
||||
}
|
||||
|
||||
public function generateApiQris($data)
|
||||
{
|
||||
$aa = "";
|
||||
try {
|
||||
$request = $this->client->post('/MC/Qris/Dynamic', [
|
||||
'json' => $aa
|
||||
]);
|
||||
$response = json_decode($request->getBody()->getContents());
|
||||
} catch (RequestException $e) {
|
||||
dd($e);
|
||||
$response = json_decode($e->getResponse()->getBody()->getContents());
|
||||
|
||||
// $this->log('va/status', $data, $e->getResponse()->getBody()->getContents());
|
||||
}
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
public function checkStatusQrisPayment($data)
|
||||
{
|
||||
try {
|
||||
$request = $this->client->post('/MC/PaymentQr', [
|
||||
'json' => $data
|
||||
]);
|
||||
$response = json_decode($request->getBody()->getContents());
|
||||
} catch (RequestException $e) {
|
||||
$response = json_decode($e->getResponse()->getBody()->getContents());
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function updateQris(QrisJatimPaymentRequest $data, QrisJatimPaymentResponse $result)
|
||||
{
|
||||
$pembayaran = PaymentBank::where('invoice_number', $data->getinvoice_number())->first();
|
||||
|
||||
if (!$pembayaran){
|
||||
$result->setresponsCode("01");
|
||||
$result->setresponsDesc("Data Pembayaran Qris tidak ditemukan!");
|
||||
}else{
|
||||
if ($pembayaran->payment_status == 1) {
|
||||
$pembayaran->payment_status = 2;
|
||||
$pembayaran->save();
|
||||
}else{
|
||||
$result->setresponsCode("01");
|
||||
$result->setresponsDesc("Data Pembayaran Qris telah terkonfirmasi!");
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function log($type, $request, $response)
|
||||
{
|
||||
$log = PaymentJatimLogs::create([
|
||||
'type' => $type,
|
||||
'request' => json_encode($request),
|
||||
'response' => json_encode($response),
|
||||
]);
|
||||
return $log;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
class RouteService
|
||||
{
|
||||
public function isProduction()
|
||||
{
|
||||
return env('APP_ENV') === 'production';
|
||||
}
|
||||
|
||||
public function isStaging()
|
||||
{
|
||||
return env('APP_ENV') === 'staging';
|
||||
}
|
||||
|
||||
public function getPaymentsSubdomain()
|
||||
{
|
||||
$domain = request()->getHost();
|
||||
return $domain;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: USER
|
||||
* Date: 14/05/2024
|
||||
* Time: 9:43
|
||||
*/
|
||||
|
||||
namespace App\Services\Va\v1;
|
||||
|
||||
|
||||
use App\Models\PaymentJatimLogs;
|
||||
use App\Models\PaymentVirtualAccount;
|
||||
use App\Models\PaymentVirtualAccountDetail;
|
||||
use App\Models\Va\v1\VirtualAccountJatimRequest;
|
||||
use App\Models\Va\v1\VirtualAccountJatimResponse;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class VirtualAccountJatimService
|
||||
{
|
||||
protected $settings;
|
||||
protected $defaultHeaders = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->settings = array(
|
||||
'apiUrl' => env('BANK_JATIM_URL', 'https://jatimva.bankjatim.co.id/'),
|
||||
'merchant' => env('BANK_JATIM_MERCHANT', '9360011400001347721'),
|
||||
'hashcode' => env('BANK_JATIM_HASCODE', 'Y1MACZ4B5R'),
|
||||
'terminalUser' => env('BANK_JATIM_TERMINAL_USER', 'ID2024310949969'),
|
||||
'username' => env('BANK_JATIM_USERNAME', 'ID2024310949969'),
|
||||
'password' => env('BANK_JATIM_PASSWORD', 'ID2024310949969'),
|
||||
);
|
||||
$this->defaultHeaders = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
'Origin' => request()->getHost(),
|
||||
];
|
||||
$configs = [
|
||||
'base_uri' => $this->settings['apiUrl'],
|
||||
'headers' => $this->defaultHeaders,
|
||||
];
|
||||
|
||||
$this->client = new Client($configs);
|
||||
}
|
||||
|
||||
public function updatePayment(VirtualAccountJatimRequest $data, VirtualAccountJatimResponse $result)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
$pembayaran = PaymentVirtualAccount::where('virtual_account', $data->getVirtualAccount())->first();
|
||||
if (!$pembayaran) {
|
||||
$result->setStatus(array(
|
||||
"IsError" => "True",
|
||||
"ResponseCode" => "01",
|
||||
"ErrorDesc" => "Virtual Account Tidak Ditemukan!"
|
||||
));
|
||||
} else {
|
||||
if ($pembayaran->flags_lunas == "F") {
|
||||
$result->setStatus(array(
|
||||
"IsError" => "True",
|
||||
"ResponseCode" => "01",
|
||||
"ErrorDesc" => "Tagihan anda telah lunas!"
|
||||
));
|
||||
} else {
|
||||
if ($pembayaran->endpoint == "full") {
|
||||
$pembayaran->bayar = $data->getAmount();
|
||||
$pembayaran->flags_lunas = "F";
|
||||
$pembayaran->save();
|
||||
} else {
|
||||
if ($data->getAmount() > $pembayaran->totalamount) {
|
||||
$result->setStatus(array(
|
||||
"IsError" => "True",
|
||||
"ResponseCode" => "01",
|
||||
"ErrorDesc" => "Nominal bayar melebihi jumlah tagihan!"
|
||||
));
|
||||
} else {
|
||||
$sisa = $pembayaran->totalamount - $pembayaran->bayar;
|
||||
if ($data->getAmount() > $sisa) {
|
||||
$result->setStatus(array(
|
||||
"IsError" => "True",
|
||||
"ResponseCode" => "01",
|
||||
"ErrorDesc" => "Nominal bayar melebihi sisa jumlah tagihan!"
|
||||
));
|
||||
} else {
|
||||
|
||||
$pembayaran->bayar = $pembayaran->bayar + $data->getAmount();
|
||||
$pembayaran->flags_lunas = ($pembayaran->bayar == $pembayaran->totalamount) ? "F" : "O";
|
||||
$pembayaran->save();
|
||||
|
||||
if (empty($pembayaran->bayar)){
|
||||
$detail_sisa = $pembayaran->totalamount - $data->getAmount();
|
||||
}else{
|
||||
$detail_sisa = $pembayaran->totalamount - $pembayaran->bayar;
|
||||
}
|
||||
|
||||
//insert history pembayaran partial
|
||||
$detail = new PaymentVirtualAccountDetail();
|
||||
$detail->payment_virtualaccount_id = $pembayaran->id;
|
||||
$detail->nomr = $pembayaran->nomr;
|
||||
$detail->idxdaftar = $pembayaran->idxdaftar;
|
||||
$detail->bayar = $data->getAmount();
|
||||
$detail->sisabayar = $detail_sisa;
|
||||
$detail->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
DB::commit();
|
||||
}catch (\Exception $e){
|
||||
DB::rollback();
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function log($type, $request, $response)
|
||||
{
|
||||
$log = PaymentJatimLogs::create([
|
||||
'type' => $type,
|
||||
'request' => json_encode($request),
|
||||
'response' => json_encode($response),
|
||||
]);
|
||||
return $log;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user