mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 04:24:16 +00:00
8b01421be7
-Update Non Segment Constant Service Class -Create Non Standard Segment Constant Logic Class -Update Non Standard Segment Constant Logic Class -Delete Non Standard Segment Logic Class
175 lines
8.2 KiB
PHP
175 lines
8.2 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\SegmentConstants\ControllersLogic;
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
|
|
use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
|
|
|
|
use App\Classes\Modules\SegmentConstants\Standards\Rules\CanUpdateStandardSegmentConstant;
|
|
|
|
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantTax;
|
|
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
|
|
|
|
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantBillingFee;
|
|
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
|
|
|
|
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantServiceCharge;
|
|
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
|
|
|
|
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantBookingAmountMax;
|
|
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
|
|
|
|
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantPaymentAttemptExpiryTime;
|
|
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttemptExpiryTimeObject;
|
|
|
|
use App\Http\Resources\SegmentConstantResource;
|
|
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class UpdateSegmentConstantLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Updated Segment Constant',
|
|
'message' => 'You have successfully updated the Segment Constant'
|
|
];
|
|
}
|
|
|
|
/** @var CanUpdateStandardSegmentConstant */
|
|
private $canUpdateStandardSegmentConstant;
|
|
|
|
/** @var UpdatesSegmentConstantTax */
|
|
private $updatesSegmentConstantTax;
|
|
|
|
/** @var UpdatesSegmentConstantBillingFee */
|
|
private $updatesSegmentConstantBillingFee;
|
|
|
|
/** @var UpdatesSegmentConstantServiceCharge */
|
|
private $updatesSegmentConstantServiceCharge;
|
|
|
|
/** @var UpdatesSegmentConstantBookingAmountMax */
|
|
private $updatesSegmentConstantBookingAmountMax;
|
|
|
|
/** @var UpdatesSegmentConstantPaymentAttemptExpiryTime */
|
|
private $updatesSegmentConstantPaymentAttemptExpiryTime;
|
|
|
|
/** @var FetchesSegmentConstant */
|
|
private $fetchesSegmentConstant;
|
|
|
|
/**
|
|
* UpdateStandardSegmentConstantLogic constructor.
|
|
* @param CanUpdateStandardSegmentConstant $canUpdateStandardSegmentConstant
|
|
* @param UpdatesSegmentConstantTax $updatesSegmentConstantTax
|
|
* @param UpdatesSegmentConstantBillingFee $updatesSegmentConstantBillingFee
|
|
* @param UpdatesSegmentConstantServiceCharge $updatesSegmentConstantServiceCharge
|
|
* @param UpdatesSegmentConstantBookingAmountMax $updatesSegmentConstantBookingAmountMax
|
|
* @param UpdatesSegmentConstantPaymentAttemptExpiryTime $updatesSegmentConstantPaymentAttemptExpiryTime
|
|
* @param FetchesSegmentConstant $fetchesSegmentConstant
|
|
*/
|
|
public function __construct(
|
|
CanUpdateStandardSegmentConstant $canUpdateStandardSegmentConstant,
|
|
UpdatesSegmentConstantTax $updatesSegmentConstantTax,
|
|
UpdatesSegmentConstantBillingFee $updatesSegmentConstantBillingFee,
|
|
UpdatesSegmentConstantServiceCharge $updatesSegmentConstantServiceCharge,
|
|
UpdatesSegmentConstantBookingAmountMax $updatesSegmentConstantBookingAmountMax,
|
|
UpdatesSegmentConstantPaymentAttemptExpiryTime $updatesSegmentConstantPaymentAttemptExpiryTime,
|
|
FetchesSegmentConstant $fetchesSegmentConstant
|
|
)
|
|
{
|
|
$this->canUpdateStandardSegmentConstant = $canUpdateStandardSegmentConstant;
|
|
$this->updatesSegmentConstantTax = $updatesSegmentConstantTax;
|
|
$this->updatesSegmentConstantBillingFee = $updatesSegmentConstantBillingFee;
|
|
$this->updatesSegmentConstantServiceCharge = $updatesSegmentConstantServiceCharge;
|
|
$this->updatesSegmentConstantBookingAmountMax = $updatesSegmentConstantBookingAmountMax;
|
|
$this->updatesSegmentConstantPaymentAttemptExpiryTime = $updatesSegmentConstantPaymentAttemptExpiryTime;
|
|
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
try {
|
|
DB::beginTransaction();
|
|
|
|
$segment_constant_query = $this->fetchesSegmentConstant->execute(['id' => $request->route('id')]);
|
|
|
|
if ($segment_constant_query->reference == 'TAX') {
|
|
$segment_constant_object = new SegmentConstantTaxObject(
|
|
$segment_constant_query->segment_id,
|
|
$segment_constant_query->name,
|
|
$segment_constant_query->reference,
|
|
$segment_constant_query->detail->type,
|
|
$request->input('value')
|
|
);
|
|
|
|
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
|
$segment_constant_query = $this->updatesSegmentConstantTax->execute($segment_constant_query, $segment_constant_object);
|
|
}
|
|
elseif ($segment_constant_query->reference == 'BILLING_FEE') {
|
|
$segment_constant_object = new SegmentConstantBillingFeeObject(
|
|
$segment_constant_query->segment_id,
|
|
$segment_constant_query->name,
|
|
$segment_constant_query->reference,
|
|
$segment_constant_query->detail->type,
|
|
$request->input('value')
|
|
);
|
|
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
|
$segment_constant_query = $this->updatesSegmentConstantBillingFee->execute($segment_constant_query, $segment_constant_object);
|
|
}
|
|
elseif ($segment_constant_query->reference == 'SERVICE_CHARGE') {
|
|
$segment_constant_object = new SegmentConstantServiceChargeObject(
|
|
$segment_constant_query->segment_id,
|
|
$segment_constant_query->name,
|
|
$segment_constant_query->reference,
|
|
$segment_constant_query->detail->type,
|
|
$request->input('value')
|
|
);
|
|
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
|
$segment_constant_query = $this->updatesSegmentConstantServiceCharge->execute($segment_constant_query, $segment_constant_object);
|
|
}
|
|
elseif ($segment_constant_query->reference == 'BOOKING_AMOUNT_MAX') {
|
|
$segment_constant_object = new SegmentConstantBookingAmountMaxObject(
|
|
$segment_constant_query->segment_id,
|
|
$segment_constant_query->name,
|
|
$segment_constant_query->reference,
|
|
$segment_constant_query->detail->type,
|
|
$request->input('value'),
|
|
$segment_constant_query->detail->currency_id
|
|
);
|
|
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
|
$segment_constant_query = $this->updatesSegmentConstantBookingAmountMax->execute($segment_constant_query, $segment_constant_object);
|
|
}
|
|
elseif ($segment_constant_query->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
|
|
$segment_constant_object = new SegmentConstantPaymentAttemptExpiryTimeObject(
|
|
$segment_constant_query->segment_id,
|
|
$segment_constant_query->name,
|
|
$segment_constant_query->reference,
|
|
$segment_constant_query->detail->type,
|
|
$request->input('value')
|
|
);
|
|
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
|
$segment_constant_query = $this->updatesSegmentConstantPaymentAttemptExpiryTime->execute($segment_constant_query, $segment_constant_object);
|
|
}
|
|
|
|
DB::commit();
|
|
|
|
return $this->resourceResponse(new SegmentConstantResource($segment_constant_query));
|
|
|
|
} catch (\Exception $exception){
|
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
|
}
|
|
}
|
|
|
|
} |