mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b0454329df |
@@ -53,5 +53,3 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
@@ -63,7 +63,7 @@ abstract class AbstractControllerLogic
|
||||
|
||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
$exception->getCode() ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ClaimantId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('claimant_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Delivered implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('packingList', function($packingList){
|
||||
return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereHas('container',
|
||||
function($container) {
|
||||
return $container->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
}
|
||||
)->whereHas('deliverySchedules',
|
||||
function($schedule) {
|
||||
return $schedule->where('eta', '<', Carbon::now())->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class InDestinationWarehouse implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('packingList', function($packingList){
|
||||
return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereHas('container',
|
||||
function($container) {
|
||||
return $container->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
}
|
||||
)->whereDoesntHave('deliverySchedules',
|
||||
function($schedule) {
|
||||
return $schedule->where('etd', '<', Carbon::now())->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class InOriginWarehouse implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('packingList', function($packingList){
|
||||
return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereDoesntHave('shippingSchedules',
|
||||
function($schedule) {
|
||||
return $schedule->where('etd', '<', Carbon::now())
|
||||
->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class InTransit implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('packingList', function($packingList){
|
||||
return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereHas('container',
|
||||
function($container) {
|
||||
return $container->where('containers.status', ApprovalStatus::PENDING_VERIFICATION);
|
||||
}
|
||||
)->whereHas('shippingSchedules',
|
||||
function($schedule) {
|
||||
return $schedule->where('etd', '<', Carbon::now())
|
||||
->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OwnerId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('owner_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OwnerId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('owner_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PackingListDeliveryStatus implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $value == 1 ? $builder->whereHas('containers', function ($query){
|
||||
$query->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
})->whereDoesntHave('transports') : ($value == 2 ? $builder->whereHas('transports', function (Builder $query) use ($value) {
|
||||
$query->whereDoesntHave('schedules', function (Builder $query) use ($value) {
|
||||
$query->where('status', '!=', ApprovalStatus::EXPIRED)->where('eta', '<=', Carbon::now());
|
||||
});
|
||||
}) : $builder->whereHas('transports', function (Builder $query) use ($value) {
|
||||
$query->whereHas('schedules', function (Builder $query) use ($value) {
|
||||
$query->where('status', '!=', ApprovalStatus::EXPIRED)->where('eta', '<=', Carbon::now());
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TargetId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('target_type', User::class)->where('target_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WarehouseParcels implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('packingList', function ($query){
|
||||
return $query->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->where('status', ApprovalStatus::APPROVED);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
interface Notifiable
|
||||
{
|
||||
public function subject(): MorphTo;
|
||||
|
||||
public function target(): MorphTo;
|
||||
|
||||
public function causer(): MorphTo;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Transactionable
|
||||
{
|
||||
|
||||
public function transactions(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CurlContainerListJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private $page;
|
||||
|
||||
public function __construct($page = 1)
|
||||
{
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$cookies = $this->getCookie();
|
||||
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => $cookies,
|
||||
];
|
||||
|
||||
$last_two_month = Carbon::now()->subMonth(2)->format('Y-m-d');
|
||||
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', [\GuzzleHttp\RequestOptions::JSON => json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":' . $this->page . ',"PageSize":10,"PageOffset":0,"SortExpression":"CreatedOn DESC","GroupExpression":"","Filter":["LoadedTime:<=%js%\"' . $last_two_month . 'T00:00:00.000\"\u0000"],"ContextKey":"view1","FilterIsExternal":false,"LookupContextFieldName":null,"LookupContextController":null,"LookupContextView":null,"LookupContext":null,"Inserting":false,"LastCommandName":null,"ExternalFilter":[],"DoesNotRequireData":false,"LastView":"grid1","Tag":null,"RequiresFirstLetters":false,"ViewType":"Grid","SupportsCaching":true,"SystemFilter":null,"RequiresRowCount":true,"QuickFindHint":null,"RequiresPivot":false,"PivotDefinitions":null,"RequiresMetaData":true}}')]);
|
||||
|
||||
$data = json_decode($res->getBody()->getContents());
|
||||
|
||||
if (!empty($data->d->Rows)) {
|
||||
// insert data here
|
||||
|
||||
// next page
|
||||
$this->page = $this->page > 0 ? $this->page + 1 : 1;
|
||||
CurlContainerListJob::dispatch($this->page + 1)
|
||||
->delay(Carbon::now()->addSeconds(10));
|
||||
}
|
||||
}
|
||||
|
||||
public function getCookie()
|
||||
{
|
||||
// get latest cookies
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
$r = $client->request('GET', 'http://portal.vtnation.com.my');
|
||||
$call_cookie = $client->getConfig('cookies');
|
||||
$call_cookie = $call_cookie->toArray();
|
||||
$latest_cookie = [];
|
||||
|
||||
foreach ($call_cookie as $key => $row) {
|
||||
$latest_cookie[] = $row['Name'] . '=' . $row['Value'];
|
||||
}
|
||||
$latest_cookie = implode(';', $latest_cookie);
|
||||
|
||||
// get access token
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => $latest_cookie,
|
||||
];
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('http://portal.vtnation.com.my/Services/DataControllerService.asmx/Login', [\GuzzleHttp\RequestOptions::JSON => [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
]]);
|
||||
|
||||
$token = json_decode($res->getBody()->getContents());
|
||||
$token = $token->d->AccessToken;
|
||||
|
||||
$latest_cookie = $latest_cookie . ';AppVTCC=' . $token;
|
||||
return $latest_cookie;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
(App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\ResourceConflictException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\UserResource;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AddNewMemberLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
public function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Email',
|
||||
'message' => 'Successfully updated email'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @var AssignEmployeeProcessor
|
||||
*/
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/**
|
||||
* @var GenerateEmailVerificationAttemptProcessor
|
||||
*/
|
||||
private $generateEmailVerificationAttemptProcessor;
|
||||
|
||||
/**
|
||||
* AddNewMemberLogic constructor.
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||
*/
|
||||
public function __construct(AssignEmployeeProcessor $assignEmployeeProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor)
|
||||
{
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ResourceConflictException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$user = Auth::user()->replicate();
|
||||
$user->email = $request->input('email');
|
||||
$user->status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
$user->save();
|
||||
} catch (QueryException $exception){
|
||||
throw new ResourceConflictException('Unable to change your email address as it already exists');
|
||||
}
|
||||
|
||||
if($company = Auth::user()->companyModule()->first()){
|
||||
$Object = new EmploymentObject($company, $user);
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
}
|
||||
|
||||
$this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
|
||||
return $this->resourceResponse(new UserResource($user));
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ class LogoutUserLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function __construct(InvalidatesAuthenticationToken $invalidatesAuthenticationToken)
|
||||
{
|
||||
logger("logout user logic");
|
||||
$this->invalidatesAuthenticationToken = $invalidatesAuthenticationToken;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,12 @@ namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesDistrict;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -45,29 +39,19 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* CreateAddressLogic constructor.
|
||||
* @param CanCreateAddress $canCreateAddress
|
||||
* @param FetchesDistrict $fetchesDistrict
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
*/
|
||||
public function __construct(CanCreateAddress $canCreateAddress, FetchesDistrict $fetchesDistrict, FetchesCompanyModule $fetchesCompanyModule, CreatesAddress $createsAddress, CreateContactProcessor $createContactProcessor, CreateRemarkProcessor $createRemarkProcessor)
|
||||
public function __construct(CanCreateAddress $canCreateAddress, FetchesDistrict $fetchesDistrict, FetchesCompanyModule $fetchesCompanyModule, CreatesAddress $createsAddress)
|
||||
{
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
$this->fetchesDistrict = $fetchesDistrict;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,19 +70,8 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canCreateAddress->passes($object);
|
||||
|
||||
/** @var Address $address */
|
||||
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
||||
|
||||
if($request->input('phone')){
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if($request->input('remark')){
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsStates;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\StateResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListStatesLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Addresses',
|
||||
'message' => 'You have successfully retrieved a list of Addresses'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListsStates */
|
||||
private $listStates;
|
||||
|
||||
/**
|
||||
* ListStatesLogic constructor.
|
||||
* @param ListsStates $listStates
|
||||
*/
|
||||
public function __construct(ListsStates $listStates)
|
||||
{
|
||||
$this->listStates = $listStates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$query = $this->listStates->execute($this->listStates->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(StateResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,12 +9,7 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesDistrict;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanUpdateAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -43,31 +38,22 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/** @var FetchesDistrict */
|
||||
private $fetchesDistrict;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* UpdateAddressLogic constructor.
|
||||
* @param CanUpdateAddress $canUpdateAddress
|
||||
* @param UpdatesAddress $updatesAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param FetchesDistrict $fetchesDistrict
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
*/
|
||||
public function __construct(CanUpdateAddress $canUpdateAddress, UpdatesAddress $updatesAddress, FetchesAddress $fetchesAddress, FetchesDistrict $fetchesDistrict, CreateContactProcessor $createContactProcessor, CreateRemarkProcessor $createRemarkProcessor)
|
||||
public function __construct(CanUpdateAddress $canUpdateAddress, UpdatesAddress $updatesAddress, FetchesAddress $fetchesAddress, FetchesDistrict $fetchesDistrict)
|
||||
{
|
||||
$this->canUpdateAddress = $canUpdateAddress;
|
||||
$this->updatesAddress = $updatesAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->fetchesDistrict = $fetchesDistrict;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
@@ -85,21 +71,8 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||
|
||||
/** @var Address $address */
|
||||
$address = $this->updatesAddress->execute($address, $object);
|
||||
|
||||
$address->contacts()->delete(); $address->remarks()->delete();
|
||||
|
||||
if($request->input('phone')){
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if($request->input('remark')){
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use App\Models\State;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListsStates extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var State */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsStates constructor.
|
||||
* @param State $repository
|
||||
*/
|
||||
public function __construct(State $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Processors\AssignAnnouncementToSegmentProcessor;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignAnnouncementToSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Assign Announcement To Segment',
|
||||
'message' => 'You have successfully assigned Announcement to segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var AssignAnnouncementToSegmentProcessor */
|
||||
private $assignAnnouncementToSegmentProcessor;
|
||||
|
||||
/**
|
||||
* AssignAnnouncementToSegmentLogic constructor.
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
*/
|
||||
public function __construct(FetchesAnnouncement $fetchesAnnouncement, AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor)
|
||||
{
|
||||
$this->fetchesAnnouncement = $fetchesAnnouncement;
|
||||
$this->assignAnnouncementToSegmentProcessor = $assignAnnouncementToSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$announcement = $this->fetchesAnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->assignAnnouncementToSegmentProcessor->execute($announcement, $request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanCreateAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\CreatesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Processors\AssignAnnouncementToSegmentProcessor;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Annoucement',
|
||||
'message' => 'You have successfully created a new Annoucements'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateAnnouncement */
|
||||
private $canCreateAnnouncement;
|
||||
|
||||
/** @var CreatesAnnoucement */
|
||||
private $createsAnnoucement;
|
||||
|
||||
/** @var AssignAnnouncementToSegmentProcessor */
|
||||
private $assignAnnouncementToSegmentProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CreateAnnouncementLogic constructor.
|
||||
* @param CanCreateAnnoucement $canCreateAnnoucement
|
||||
* @param CreatesAnnoucement $createsAnnoucement
|
||||
* @param AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
CanCreateAnnouncement $canCreateAnnouncement,
|
||||
CreatesAnnouncement $createsAnnoucement,
|
||||
AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
) {
|
||||
$this->canCreateAnnouncement = $canCreateAnnouncement;
|
||||
$this->createsAnnoucement = $createsAnnoucement;
|
||||
$this->assignAnnouncementToSegmentProcessor = $assignAnnouncementToSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$annoucement_object = new AnnouncementObject(
|
||||
$request->input('title'),
|
||||
$request->input('description'),
|
||||
$request->input('starting_on'),
|
||||
$request->input('ending_on')
|
||||
);
|
||||
|
||||
$this->canCreateAnnouncement->passes($annoucement_object);
|
||||
|
||||
$announcement = $this->createsAnnoucement->execute($annoucement_object);
|
||||
|
||||
$this->assignAnnouncementToSegmentProcessor->execute($announcement);
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanDeleteAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\DeletesAnnouncement;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Delete Announcement',
|
||||
'message' => 'You have successfully deleted the Announcement'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanDeleteAnnouncement */
|
||||
private $canDeleteAnnouncement;
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var DeletesAnnouncement */
|
||||
private $deletesAnnouncement;
|
||||
|
||||
/**
|
||||
* DeleteAnnouncementLogic constructor.
|
||||
* @param CanDeleteAnnouncement $canDeleteAnnouncement
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param DeletesAnnouncement $deletesAnnouncement
|
||||
*/
|
||||
public function __construct(
|
||||
CanDeleteAnnouncement $canDeleteAnnoucement,
|
||||
FetchesAnnouncement $fetchesAnnoucement,
|
||||
DeletesAnnouncement $deletesAnnoucement
|
||||
) {
|
||||
$this->canDeleteAnnoucement = $canDeleteAnnoucement;
|
||||
$this->fetchesAnnoucement = $fetchesAnnoucement;
|
||||
$this->deletesAnnoucement = $deletesAnnoucement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canDeleteAnnoucement->passes();
|
||||
|
||||
$annoucement = $this->fetchesAnnoucement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesAnnoucement->execute($annoucement);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Announcements\Services\ListsAnnouncements;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanListAnnouncements;
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListAnnouncementsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieve Announcements',
|
||||
'message' => 'You have successfully retrieved a list of Announcements'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListAnnouncements */
|
||||
private $canListAnnouncements;
|
||||
|
||||
/** @var ListsAnnouncements */
|
||||
private $listsAnnouncements;
|
||||
|
||||
/**
|
||||
* ListAnnouncementsLogic constructor.
|
||||
* @param CanListAnnouncements $canListAnnouncements
|
||||
* @param ListsAnnouncements $listsAnnouncements
|
||||
*/
|
||||
public function __construct(CanListAnnouncements $canListAnnouncements, ListsAnnouncements $listsAnnouncements)
|
||||
{
|
||||
$this->canListAnnouncements = $canListAnnouncements;
|
||||
$this->listsAnnouncements = $listsAnnouncements;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canListAnnouncements->passes();
|
||||
|
||||
$annoucements = $this->listsAnnouncements->execute($this->listsAnnouncements->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(AnnouncementResource::collection($annoucements));
|
||||
}
|
||||
}
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\Announcements\Services\RemovesAnnouncementFromSegment;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemoveSegmentFromAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Detach Announcement From Segment',
|
||||
'message' => 'You have successfully detached Announcement from segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnnouncement;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var RemovesAnnouncementFromSegment */
|
||||
private $removesAnnouncementFromSegment;
|
||||
|
||||
/**
|
||||
* RemoveSegmentFromAnnouncementLogic constructor.
|
||||
* @param FetchesAnnouncement $fetchesAnnnouncement
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param RemovesAnnouncementFromSegment $removesAnnouncementFromSegment
|
||||
*/
|
||||
public function __construct(FetchesAnnouncement $fetchesAnnnouncement, FetchesSegment $fetchesSegment, RemovesAnnouncementFromSegment $removesAnnouncementFromSegment)
|
||||
{
|
||||
$this->fetchesAnnnouncement = $fetchesAnnnouncement;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->removesAnnouncementFromSegment = $removesAnnouncementFromSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$announcement = $this->fetchesAnnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('segment_id')]);
|
||||
|
||||
$this->removesAnnouncementFromSegment->execute($announcement, $segment);
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanUpdateAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\UpdatesAnnouncement;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class UpdateAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Update Announcement',
|
||||
'message' => 'You have successfully updated the Announcement'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateAnnouncement */
|
||||
private $canUpdateAnnouncement;
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var UpdatesAnnouncement */
|
||||
private $updatesAnnouncement;
|
||||
|
||||
/**
|
||||
* UpdateAnnouncementLogic constructor.
|
||||
* @param CanUpdateAnnouncement $canUpdateAnnouncement
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param UpdatesAnnouncement $updatesAnnouncement
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateAnnouncement $canUpdateAnnouncement,
|
||||
FetchesAnnouncement $fetchesAnnouncement,
|
||||
UpdatesAnnouncement $updatesAnnouncement
|
||||
) {
|
||||
$this->canUpdateAnnouncement = $canUpdateAnnouncement;
|
||||
$this->fetchesAnnouncement = $fetchesAnnouncement;
|
||||
$this->updatesAnnouncement = $updatesAnnouncement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$annoucement_object = new AnnouncementObject(
|
||||
$request->input('title'),
|
||||
$request->input('description'),
|
||||
$request->input('starting_on'),
|
||||
$request->input('ending_on')
|
||||
);
|
||||
|
||||
$this->canUpdateAnnouncement->passes($annoucement_object);
|
||||
|
||||
$annoucement = $this->fetchesAnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$announcement_query = $this->updatesAnnouncement->execute($annoucement, $annoucement_object);
|
||||
|
||||
//$announcement_query->segments()->sync($request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement_query));
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
class AnnouncementObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $title;
|
||||
|
||||
/** @var string */
|
||||
private $description;
|
||||
|
||||
/** @var string */
|
||||
private $starting_on;
|
||||
|
||||
/** @var string */
|
||||
private $ending_on;
|
||||
|
||||
|
||||
/**
|
||||
* AnnouncementObject constructor.
|
||||
* @param string $title
|
||||
* @param string $description
|
||||
* @param string $start_date
|
||||
* @param string $end_date
|
||||
*/
|
||||
|
||||
public function __construct(string $title, string $description, string $starting_on, string $ending_on)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->description = $description;
|
||||
$this->starting_on = $starting_on;
|
||||
$this->ending_on = $ending_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStartingOn(): string
|
||||
{
|
||||
return $this->starting_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEndingOn(): string
|
||||
{
|
||||
return $this->ending_on;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Processors;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\AssignsAnnouncementToSegment;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanAssignSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\Announcement;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AssignAnnouncementToSegmentProcessor
|
||||
{
|
||||
|
||||
/** @var CanAssignSegment */
|
||||
private $canAssignSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var AssignAnnouncementToSegment */
|
||||
private $assignsAnnouncementToSegment;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* AssignAnnouncementToSegmentProcessor constructor.
|
||||
* @param CanAssignSegment $canAssignSegment
|
||||
* @param AssignAnnouncementToSegment $assignsAnnouncementToSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(CanAssignSegment $canAssignSegment, FetchesSegment $fetchesSegment, AssignsAnnouncementToSegment $assignsAnnouncementToSegment)
|
||||
{
|
||||
$this->canAssignSegment = $canAssignSegment;
|
||||
$this->assignsAnnouncementToSegment = $assignsAnnouncementToSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Announcement $announcement
|
||||
* @param int|null $segmentId
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Announcement $announcement, ?int $segmentId = SegmentConstants::STANDARD_SEGMENT): Model
|
||||
{
|
||||
$this->canAssignSegment->passes();
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $segmentId]);
|
||||
|
||||
return $this->assignsAnnouncementToSegment->execute($announcement, $segment);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class AssignsAnnouncementToSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Announcement $announcement
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $announcement, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$announcement->segments()->attach($segment);
|
||||
|
||||
return $announcement;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class CreatesAnnouncement extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(AnnouncementObject $object)
|
||||
{
|
||||
$model = new Announcement();
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->starting_on = $object->getStartingOn();
|
||||
$model->ending_on = $object->getEndingOn();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class DeletesAnnouncement extends AbstractDeleteRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Announcement $model
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $model) {
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class FetchesAnnouncement extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Announcement */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesAnnouncement constructor.
|
||||
* @param Announcement $repository
|
||||
*/
|
||||
public function __construct(Announcement $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class ListsAnnouncements extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Announcement */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsAnnouncement constructor.
|
||||
* @param Announcement $repository
|
||||
*/
|
||||
public function __construct(Announcement $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class RemovesAnnouncementFromSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Announcement $announcement
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $announcement, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$announcement->segments()->detach($segment);
|
||||
|
||||
return $announcement;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class UpdatesAnnouncement extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Announcement $model
|
||||
* @param AnnouncementObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $model, AnnouncementObject $object)
|
||||
{
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->starting_on = $object->getStartingOn();
|
||||
$model->ending_on = $object->getEndingOn();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantObject;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
|
||||
class CanAssignSegment extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\Standards\Validators\AnnouncementValidation;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanCreateAnnouncement extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var AnnouncementValidation */
|
||||
private $AnnouncementValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAnnouncement constructor.
|
||||
* @param AnnouncementValidation $AnnouncementValidation
|
||||
*/
|
||||
public function __construct(AnnouncementValidation $AnnouncementValidation)
|
||||
{
|
||||
$this->AnnouncementValidation = $AnnouncementValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->AnnouncementValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcement\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanDeleteAnnouncement extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanListAnnouncements extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Validators\AnnouncementValidation;
|
||||
|
||||
class CanUpdateAnnouncement extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var AnnouncementValidation */
|
||||
private $AnnouncementValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanUpdateAnnouncement constructor.
|
||||
* @param AnnouncementValidation $AnnouncementValidation
|
||||
*/
|
||||
public function __construct(AnnouncementValidation $AnnouncementValidation)
|
||||
{
|
||||
$this->AnnouncementValidation = $AnnouncementValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->AnnouncementValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class AnnouncementValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'title' => $object->getTitle(),
|
||||
'description' => $object->getDescription(),
|
||||
'starting_on' => $object->getStartingOn(),
|
||||
'ending_on' => $object->getEndingOn()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required',
|
||||
'description' => 'required',
|
||||
'starting_on' => 'required',
|
||||
'ending_on' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Models\Booking;
|
||||
use App\Models\User;
|
||||
use App\Models\Wallet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CallbackBillplzLogic
|
||||
{
|
||||
|
||||
|
||||
/** @var GetBillplzBill */
|
||||
private $getBillplzBill;
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWalletBalance $updatesWalletBalance)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws MalformedRequestException
|
||||
* @throws ResourceNotFoundException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
$billplzXSignatureObject = new BillplzXSignatureObject($request);
|
||||
|
||||
if(!$billplzXSignatureObject->isValidSignature()){
|
||||
throw new MalformedRequestException('Billplz Payment validation failed.');
|
||||
}
|
||||
|
||||
$billPlz = $this->getBillplzBill->execute($billplzXSignatureObject->getBillPlzId());
|
||||
|
||||
if(!$billPlz) throw new ResourceNotFoundException('Billplz bill not found.');
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
|
||||
|
||||
if($billPlz->state === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
if($billPlz->state === 'due') {
|
||||
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
||||
}
|
||||
|
||||
if($transaction->status !== ApprovalStatus::COMPLETED){
|
||||
|
||||
if($transaction->owner instanceof Wallet && $transaction->status !== ApprovalStatus::APPROVED && $status === ApprovalStatus::APPROVED) {
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
}
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
$marking = $transaction->owner instanceof Booking ? $transaction->booking->marking : $transaction->owner->owner->bookings()->orderBy('id', 'DESC')->first()->marking;
|
||||
|
||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $marking, 'transaction' => $transaction, 'status' => $status]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
|
||||
use ErrorException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateBillplzBillLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Billplz Bill',
|
||||
'message' => 'You have successfully created a new Bill'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/**
|
||||
* CreateBookingLogic constructor.
|
||||
* @param CreatesBillplzBill $createsBillplzBill
|
||||
*/
|
||||
public function __construct(CreatesBillplzBill $createsBillplzBill)
|
||||
{
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$billPlz = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, $request->input('description'), 200, $request->input('bankName'));
|
||||
|
||||
if(!$billPlz) throw new MalformedRequestException('Unable to get correct response from billplz server.');
|
||||
|
||||
return $this->response(['data' => $billPlz]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use function PHPSTORM_META\map;
|
||||
|
||||
class BillplzXSignatureObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $billPlzId;
|
||||
|
||||
/** @var string */
|
||||
private $status;
|
||||
|
||||
/** @var array */
|
||||
private $billPlzConstructArray;
|
||||
|
||||
/** @var string */
|
||||
private $billPlzConstructString;
|
||||
|
||||
/** @var string */
|
||||
private $billPlzComputedXSignature;
|
||||
|
||||
/** @var string */
|
||||
private $type;
|
||||
|
||||
/** @var Request */
|
||||
private $request;
|
||||
|
||||
/** @var string */
|
||||
private $requestXSignature;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
|
||||
$this->type = $request->exists('billplz') ? 'redirect' : 'callback';
|
||||
|
||||
$this->request = $this->type === 'redirect' ? $request->input('billplz') : $request;
|
||||
|
||||
$this->billPlzId = $this->request['id'];
|
||||
|
||||
$this->status = $this->request['transaction_status'];
|
||||
|
||||
$this->requestXSignature = $this->request['x_signature'];
|
||||
|
||||
$this->_constructBillplzArray()->_natSortBillplzArray()->_constructBillplzString()->_computeBillplzXSignature();
|
||||
}
|
||||
|
||||
private function _constructBillplzArray(){
|
||||
|
||||
$this->billPlzConstructArray = collect($this->request)->forget('x_signature')->map(function($item, $key){
|
||||
return $this->type === 'redirect' ? 'billplz'.$key.$item : $key.$item;
|
||||
})->toArray();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _natCaseSortBillplzArray(){
|
||||
natcasesort($this->billPlzConstructArray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _natSortBillplzArray(){
|
||||
natsort($this->billPlzConstructArray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _constructBillplzString(){
|
||||
$this->billPlzConstructString = implode('|', $this->billPlzConstructArray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _computeBillplzXSignature(){
|
||||
$this->billPlzComputedXSignature = hash_hmac('sha256', $this->billPlzConstructString, config('billplz.x_signature_key'));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBillPlzId(): string
|
||||
{
|
||||
return $this->billPlzId;
|
||||
}
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getBillPlzConstructArray(): array
|
||||
{
|
||||
return $this->billPlzConstructArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBillPlzConstructString(): string
|
||||
{
|
||||
return $this->billPlzConstructString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBillPlzComputedXSignature(): string
|
||||
{
|
||||
return $this->billPlzComputedXSignature;
|
||||
}
|
||||
|
||||
public function isValidSignature(): bool
|
||||
{
|
||||
return $this->billPlzComputedXSignature === $this->requestXSignature ? true : false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
|
||||
class CreatesBillplzBill
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $email
|
||||
* @param string $description
|
||||
* @param float $amount
|
||||
* @param string $billNumber
|
||||
* @param null|string $bankCode
|
||||
* @param null|Boolean $wallet
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?bool $wallet = null) {
|
||||
try{
|
||||
// config('billplz.maybank')
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||
'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'),
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'description' => $description,
|
||||
'amount' => $this->finalizeAmount($amount),
|
||||
'redirect_url' => route('online_payment.redirect'),
|
||||
'callback_url' => route('api.online_payment.callback'),
|
||||
'reference_1_label' => 'Bank Code',
|
||||
'reference_1' => $bankCode ? $bankCode : '',
|
||||
'reference_2_label' => 'Bill Number',
|
||||
'reference_2' => $billNumber
|
||||
]);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
$data['url'] = $data['url'].'?auto_submit=true';
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from billplz server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function finalizeAmount($amount){
|
||||
$number = round($amount, 2) * 100;
|
||||
return (string) $number;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class GetBillplzBill
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $billPlzId
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $billPlzId) {
|
||||
try{
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$billPlzId);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from billplz server');
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-18
@@ -14,8 +14,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
||||
Use App\Classes\Modules\Notifications\Processors\CreateNotificationProcessor;
|
||||
|
||||
use App\Models\Document;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -52,9 +50,6 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
/** @var UpdatesOrdersStatus */
|
||||
private $updatesOrdersStatus;
|
||||
|
||||
/** @var CreateNotificationProcessor */
|
||||
private $createNotificationProcessor;
|
||||
|
||||
/**
|
||||
* ApproveIdentificationDocumentLogic constructor.
|
||||
* @param CanApproveDocument $canApproveDocument
|
||||
@@ -63,9 +58,8 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
* @param FetchesDocument $fetchesDocument
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param UpdatesOrdersStatus $updatesOrdersStatus
|
||||
* @param CreateNotificationProcessor $createNotificationProcessor
|
||||
*/
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor)
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus)
|
||||
{
|
||||
$this->canApproveDocument = $canApproveDocument;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
@@ -73,7 +67,6 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
$this->fetchesDocument = $fetchesDocument;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->updatesOrdersStatus = $updatesOrdersStatus;
|
||||
$this->createNotificationProcessor = $createNotificationProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,16 +90,6 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
$this->updatesCompanyStatus->execute($document->owner, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
$object = new NotificationObject(
|
||||
'ID Verification ' . ( $status === 'approve' ? 'Approved' : 'Rejected' ),
|
||||
( $status === 'approve' ? 'Dear user, congratulations that your ' : 'Dear user, we are sorry to inform you that your ' ) . ( $document->type === 'IDENTITY_CARD' ? 'IC' : 'SSM' ) . ( $status === 'approve' ? ' has been approved. Start your first order now!' : ' has been rejected due to ' . ( $request->input('rejectRemark') ?? '' ) . ', please resubmit it for further action.' ),
|
||||
$document->owner,
|
||||
$document->owner->companyModules()->first()->employees()->first(),
|
||||
$document,
|
||||
);
|
||||
|
||||
$this->createNotificationProcessor->execute($object);
|
||||
|
||||
if($status === 'approve'){
|
||||
$orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||
use App\Http\Resources\CompanyModuleResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Company Moduels',
|
||||
'message' => 'You have successfully retrieved a list of Companies'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListCompanies */
|
||||
private $canListCompanies;
|
||||
|
||||
/** @var ListsCompanyModules */
|
||||
private $listsCompanyModules;
|
||||
|
||||
/**
|
||||
* ListCompaniesControllersLogic constructor.
|
||||
* @param CanListCompanies $canListCompanies
|
||||
* @param ListsCompanyModules $listsCompanyModules
|
||||
*/
|
||||
public function __construct(CanListCompanies $canListCompanies, ListsCompanyModules $listsCompanyModules)
|
||||
{
|
||||
$this->canListCompanies = $canListCompanies;
|
||||
$this->listsCompanyModules = $listsCompanyModules;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListCompanies->passes();
|
||||
|
||||
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
||||
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleName;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
@@ -36,22 +35,17 @@ class UpdateCompanyLogic extends AbstractControllerLogic
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatesCompanyModuleName */
|
||||
private $updatesCompanyModuleName;
|
||||
|
||||
/**
|
||||
* UpdateCompanyControllersLogic constructor.
|
||||
* @param CanUpdateCompany $canUpdateCompany
|
||||
* @param UpdatesCompany $updatesCompany
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param UpdatesCompanyModuleName $updatesCompanyModuleName
|
||||
*/
|
||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany, UpdatesCompanyModuleName $updatesCompanyModuleName)
|
||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->canUpdateCompany = $canUpdateCompany;
|
||||
$this->updatesCompany = $updatesCompany;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->updatesCompanyModuleName = $updatesCompanyModuleName;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,17 +56,23 @@ class UpdateCompanyLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new CompanyObject($request->input('name'), $request->input('reference'), $request->input('type'));
|
||||
try {
|
||||
|
||||
$this->canUpdateCompany->passes($object);
|
||||
$object = new CompanyObject($request->input('reference_no'), $request->input('name'), $request->input('type'));
|
||||
|
||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
$this->canUpdateCompany->passes($object);
|
||||
|
||||
$query = $this->updatesCompany->execute($query, $object);
|
||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->updatesCompanyModuleName->execute($query->companyModules()->first(), $object->getName());
|
||||
$query = $this->updatesCompany->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\CompanyModule;
|
||||
|
||||
class ListsCompanyModules extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var CompanyModule */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsCompanyModules constructor.
|
||||
* @param CompanyModule $repository
|
||||
*/
|
||||
public function __construct(CompanyModule $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesCompany extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $model
|
||||
* @param CompanyObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $model, CompanyObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->type = $object->getType();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyModuleObject;
|
||||
use App\Models\CompanyModule;
|
||||
|
||||
class UpdatesCompanyModuleName extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param CompanyModule $model
|
||||
* @param CompanyModuleObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $model, string $name)
|
||||
{
|
||||
$model->name = $name;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Classes\Modules\Companies\Standards\Validators\CompanyValidation;
|
||||
|
||||
class CanUpdateCompany extends AbstractRule
|
||||
{
|
||||
/** @var CompanyValidation */
|
||||
private $companyValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanUpdateCompany constructor.
|
||||
* @param CompanyValidation $companyValidation
|
||||
*/
|
||||
public function __construct(CompanyValidation $companyValidation)
|
||||
{
|
||||
$this->companyValidation = $companyValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompanyObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->companyValidation->validate($object, 'PUT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompanyObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,7 @@ class CompanyValidation extends AbstractValidation
|
||||
{
|
||||
return [
|
||||
'company_name' => $object->getName(),
|
||||
'company_reference' => $object->getReference(),
|
||||
'type' => $object->getType()
|
||||
'company_reference' => $object->getReference()
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace App\Classes\Modules\Contacts\Processors;
|
||||
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CreateContactProcessor
|
||||
@@ -14,9 +15,6 @@ class CreateContactProcessor
|
||||
/** @var CanCreateContact */
|
||||
private $canCreateContact;
|
||||
|
||||
/** @var CreatesContact */
|
||||
private $createsContact;
|
||||
|
||||
/**
|
||||
* CreateContactProcessor constructor.
|
||||
* @param CanCreateContact $canCreateContact
|
||||
@@ -30,17 +28,17 @@ class CreateContactProcessor
|
||||
|
||||
/**
|
||||
* @param ContactObject $object
|
||||
* @param Contactable $contactable
|
||||
* @param Company $company
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(ContactObject $object, Contactable $contactable): Model
|
||||
public function execute(ContactObject $object, Company $company): Model
|
||||
{
|
||||
|
||||
$this->canCreateContact->passes($object);
|
||||
|
||||
return $this->createsContact->execute($contactable,$object);
|
||||
return $this->createsContact->execute($company,$object);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class ListDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canListDocuments->passes();
|
||||
|
||||
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
|
||||
$query = $this->listsDocuments->execute($this->listsDocuments->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(DocumentResource::collection($query));
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanUpdateDocumentReference;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
use App\Classes\Modules\Documents\Services\UpdatesDocumentReference;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateDocumentReferenceLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Document Reference',
|
||||
'message' => 'You have successfully updated the Document Reference'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateDocumentReference*/
|
||||
private $canUpdateDocumentReference;
|
||||
|
||||
/** @var UpdatesDocumentReference */
|
||||
private $updatesDocumentReference;
|
||||
|
||||
/** @var FetchesDocument */
|
||||
private $fetchesDocument;
|
||||
|
||||
|
||||
/**
|
||||
* RejectDocumentLogic constructor.
|
||||
* @param CanApproveDocument $canApproveDocument
|
||||
* @param ApprovesDocument $approvesDocument
|
||||
* @param FetchesDocument $fetchesDocument
|
||||
*/
|
||||
public function __construct(CanUpdateDocumentReference $canUpdateDocumentReference, UpdatesDocumentReference $updatesDocumentReference, FetchesDocument $fetchesDocument)
|
||||
{
|
||||
$this->canUpdateDocumentReference = $canUpdateDocumentReference;
|
||||
$this->updatesDocumentReference = $updatesDocumentReference;
|
||||
$this->fetchesDocument = $fetchesDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$document = $this->fetchesDocument->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->canUpdateDocumentReference->passes();
|
||||
|
||||
$document_query = $this->updatesDocumentReference->execute($document, $request->input('identification_number'));
|
||||
|
||||
return $this->resourceResponse(new DocumentResource($document_query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Document;
|
||||
|
||||
class UpdatesDocumentReference extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Document $model
|
||||
* @return mixed
|
||||
*/
|
||||
public function execute(Document $model, string $reference) {
|
||||
$model->reference = $reference;
|
||||
return $this->handler($model);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
class CanUpdateDocumentReference extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Container;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ExportsContainerPackingList implements FromQuery, WithHeadingRow, WithMapping
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
protected $id;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Marking',
|
||||
'Refrence',
|
||||
'Quantity',
|
||||
'CBM',
|
||||
'Status',
|
||||
'Delivery Phone',
|
||||
'Delivery Refrence',
|
||||
'Delivery Address',
|
||||
'Remark',
|
||||
'Delivery Date'
|
||||
];
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return Container::find($this->id)->packingLists();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Company $container
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($packing_list): array
|
||||
{
|
||||
$order = $packing_list->owner()->first();
|
||||
$address = $order->addresses()->first();
|
||||
$company = $order->companyModule()->first();
|
||||
$connection = $company->inviters()->withPivot('invitee_reference')->first();
|
||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
||||
|
||||
$quantity = 0;
|
||||
$cbm = 0;
|
||||
foreach ($packing_list->packages()->get() as $key => $row) {
|
||||
$quantity += $row->quantity;
|
||||
$cbm += (($row->width / 100) * ($row->height / 100) * ($row->length / 100)) * $row->quantity;
|
||||
}
|
||||
|
||||
$status = '';
|
||||
if ($packing_list->transports()->count() > 0) {
|
||||
$status = 'Delivery';
|
||||
}
|
||||
elseif ($packing_list->status == ApprovalStatus::SUSPENDED) {
|
||||
$status = 'On Hold';
|
||||
}
|
||||
elseif ($packing_list->status != ApprovalStatus::SUSPENDED) {
|
||||
$status = 'Release';
|
||||
}
|
||||
|
||||
return [
|
||||
$marking,
|
||||
$order->reference,
|
||||
$quantity,
|
||||
$cbm,
|
||||
$status,
|
||||
$address->contacts()->first() ? $address->contacts()->first()->phone : 'n/a',
|
||||
$address->contacts()->first() ? $address->contacts()->first()->reference : 'n/a',
|
||||
$address->street_one . ' ' . $address->street_two . ' ' . $address->district->name . ' ' . $address->post_code . ' ' . $address->state->name . ' ' . $address->country->name,
|
||||
$address->remarks()->first() ? $address->remarks()->first()->content : 'n/a',
|
||||
$packing_list->transports()->first() ? $packing_list->transports()->current_schedule->eta : 'n/a'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\CompanyModule;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class ExportsCustomersOrderLatestDate implements FromQuery, WithHeadingRow, WithMapping
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Marking',
|
||||
'Name',
|
||||
'Email',
|
||||
'Latest Order'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return CompanyModule::where('type', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($company): array
|
||||
{
|
||||
$connection = $company->inviters()->withPivot('invitee_reference')->first();
|
||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
||||
|
||||
$employees = $company->employees()->first();
|
||||
|
||||
$order = $company->orders()
|
||||
->join('packing_lists', 'packing_lists.owner_id', '=', 'orders.id')
|
||||
->join('transport_arrangements', 'transport_arrangements.owner_id', '=', 'packing_lists.id')
|
||||
->orderBy('drop_date', 'desc')
|
||||
->first();
|
||||
|
||||
return [
|
||||
$marking,
|
||||
$employees ? $employees->name : '',
|
||||
$employees ? $employees->email : '',
|
||||
$order ? $order->drop_date : ''
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Notifications\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Notifications\Services\ListsNotification;
|
||||
use App\Http\Resources\NotificationResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListNotificationsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieve Notifications',
|
||||
'message' => 'You have successfully retrieved a list of Notifications'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListsNotification */
|
||||
private $listsNotification;
|
||||
|
||||
/**
|
||||
* ListNotificationsLogic constructor.
|
||||
* @param ListsNotification $listsNotification
|
||||
*/
|
||||
public function __construct(
|
||||
ListsNotification $listsNotification
|
||||
)
|
||||
{
|
||||
$this->listsNotification = $listsNotification;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$filters = [
|
||||
// 'target_id'=>auth()->user()->id,
|
||||
// 'per_page'=>$request->route('per_page')
|
||||
];
|
||||
|
||||
$notifications = $this->listsNotification->execute($filters);
|
||||
|
||||
return $this->collectionResponse(NotificationResource::collection($notifications));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Notifications\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\Notifiable;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
class NotificationObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $title;
|
||||
|
||||
/** @var string */
|
||||
private $description;
|
||||
|
||||
/** @var Notifiable */
|
||||
private $subject;
|
||||
|
||||
/** @var Notifiable */
|
||||
private $target;
|
||||
|
||||
/** @var Notifiable */
|
||||
private $causer;
|
||||
|
||||
/** @var int|null */
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* OrderObject constructor.
|
||||
* @param string $reference
|
||||
* @param int $type
|
||||
* @param int|null $status
|
||||
*/
|
||||
public function __construct(
|
||||
string $title,
|
||||
string $description,
|
||||
Notifiable $subject,
|
||||
Notifiable $target,
|
||||
Notifiable $causer,
|
||||
?int $status = ApprovalStatus::PENDING_VERIFICATION
|
||||
)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->description = $description;
|
||||
$this->subject = $subject;
|
||||
$this->target = $target;
|
||||
$this->causer = $causer;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Notifiable
|
||||
*/
|
||||
public function getSubject(): Notifiable
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Notifiable
|
||||
*/
|
||||
public function getTarget(): Notifiable
|
||||
{
|
||||
return $this->target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Notifiable
|
||||
*/
|
||||
public function getCauser(): Notifiable
|
||||
{
|
||||
return $this->causer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Notifications\Processors;
|
||||
|
||||
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
||||
use App\Classes\Modules\Notifications\Services\CreatesNotification;
|
||||
|
||||
class CreateNotificationProcessor
|
||||
{
|
||||
/** @var CreatesNotification */
|
||||
private $createsNotification;
|
||||
|
||||
/**
|
||||
* CreateNotificationProcessor constructor.
|
||||
* @param CreatesNotification $createsNotification
|
||||
*/
|
||||
public function __construct(CreatesNotification $createsNotification)
|
||||
{
|
||||
$this->createsNotification = $createsNotification;
|
||||
}
|
||||
|
||||
public function execute(NotificationObject $object)
|
||||
{
|
||||
$notification = $this->createsNotification->execute($object);
|
||||
return $notification;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Notifications\Services;
|
||||
|
||||
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
||||
use App\Models\Notification;
|
||||
|
||||
class CreatesNotification
|
||||
{
|
||||
/**
|
||||
* @param NotificationObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(NotificationObject $object) {
|
||||
$model = new Notification();
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->status = $object->getStatus();
|
||||
$model->subject_type = get_class($object->getSubject());
|
||||
$model->subject_id = $object->getSubject()->id;
|
||||
$model->target_type = get_class($object->getTarget());
|
||||
$model->target_id = $object->getTarget()->id;
|
||||
$model->causer_type = get_class($object->getCauser());
|
||||
$model->causer_id = $object->getCauser()->id;
|
||||
$model->save();
|
||||
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Notifications\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Notification;
|
||||
|
||||
class ListsNotification extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Bank */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsBank constructor.
|
||||
* @param Notification $repository
|
||||
*/
|
||||
public function __construct(Notification $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\CreatesOrderRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignOrderRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order Remark',
|
||||
'message' => 'You have successfully created a new Order Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesOrderRemark */
|
||||
private $createsOrderRemark;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesOrderRemark $createsOrderRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesOrderRemark $createsOrderRemark, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsOrderRemark = $createsOrderRemark;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject(
|
||||
$request->input('content'),
|
||||
$request->route('id')
|
||||
);
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$query = $this->createsOrderRemark->execute($this->fetchesOrder->execute(['id' => $request->route('id')]), $object);
|
||||
return $this->resourceResponse( new RemarkResource($query));
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,12 @@
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -59,21 +57,12 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
|
||||
public function logic(Request $request) : JsonResponse {
|
||||
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('address_id')]);
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||
|
||||
if(!in_array($company->companyModules()->importers()->first()->id, WarehouseReferences::YD_EXEMPT_LIST)){
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU ? WarehouseReferences::YD_GUANG_ZHOU : WarehouseReferences::YD_YIWU]);
|
||||
}
|
||||
|
||||
if($originWarehouse->reference === WarehouseReferences::YD_YIWU && in_array($address->state_id, [5, 13, 14])) {
|
||||
throw new RequestValidationException('Our Yiwu warehouse is unable to ship goods to Sabah & Sarawak at the moment. you can select our Guangzhou warehouse as an alternative.');
|
||||
}
|
||||
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
|
||||
@@ -19,7 +19,6 @@ use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
@@ -81,9 +80,6 @@ class CreateShippingPackingListLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
@@ -97,8 +93,6 @@ class CreateShippingPackingListLogic extends AbstractControllerLogic
|
||||
PackingListType::SHIPPING_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$packages = $request->input('packages');
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\ErrorException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Orders\Services\UpdateOrderReference;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Models\Company;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateOrderLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Update Order',
|
||||
'message' => 'You have successfully update the order'
|
||||
];
|
||||
}
|
||||
|
||||
private $updateOrderReference;
|
||||
private $fetchesOrder;
|
||||
|
||||
public function __construct(UpdateOrderReference $updateOrderReference, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->updateOrderReference = $updateOrderReference;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
protected function logic(Request $request): JsonResponse
|
||||
{
|
||||
$reference_id = $request->input('reference_id');
|
||||
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||
|
||||
$order = $this->updateOrderReference->execute($order, $reference_id);
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanApproveChangeOrderAddress;
|
||||
use App\Classes\Modules\Orders\Services\UpdatesOrdersAddress;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApproveChangeOrderAddressProcessor
|
||||
@@ -20,27 +20,17 @@ class ApproveChangeOrderAddressProcessor
|
||||
/** @var UpdatesOrdersAddress */
|
||||
private $updatesOrdersAddress;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/**
|
||||
* ApproveChangeOrderAddressProcessor constructor.
|
||||
* @param CanApproveChangeOrderAddress $canApproveChangeOrderAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param UpdatesOrdersAddress $updatesOrdersAddress
|
||||
* @param \App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
*/
|
||||
public function __construct(CanApproveChangeOrderAddress $canApproveChangeOrderAddress, FetchesAddress $fetchesAddress, UpdatesOrdersAddress $updatesOrdersAddress, \App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
public function __construct(CanApproveChangeOrderAddress $canApproveChangeOrderAddress, FetchesAddress $fetchesAddress, UpdatesOrdersAddress $updatesOrdersAddress)
|
||||
{
|
||||
$this->canApproveChangeOrderAddress = $canApproveChangeOrderAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->updatesOrdersAddress = $updatesOrdersAddress;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,13 +38,12 @@ class ApproveChangeOrderAddressProcessor
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\InternalServerErrorException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
|
||||
$status = (int) $request->route('status');
|
||||
|
||||
$this->canApproveChangeOrderAddress->passes();
|
||||
@@ -63,13 +52,9 @@ class ApproveChangeOrderAddressProcessor
|
||||
|
||||
if($status === ApprovalStatus::APPROVED){
|
||||
$address->owner->addresses()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
|
||||
$appointee = $address->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
$appointee === 2 ? $this->updateDoFromVTPortalProcessor->execute($address) : $this->updateDoFromYDPortalProcessor->execute($address);
|
||||
|
||||
}
|
||||
|
||||
$address = $this->updatesOrdersAddress->execute($address, $status);
|
||||
$this->updatesOrdersAddress->execute($address, $status);
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
@@ -8,11 +8,6 @@ use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\CreatesOrder;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanCreateOrder;
|
||||
@@ -38,12 +33,6 @@ class CreateOrderProcessor
|
||||
/** @var CreateOrderRolesProcessor */
|
||||
private $createOrderRolesProcessor;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* CreateOrderProcessor constructor.
|
||||
* @param CanCreateOrder $canCreateOrder
|
||||
@@ -51,14 +40,12 @@ class CreateOrderProcessor
|
||||
* @param CreatesAddress $createAddress
|
||||
* @param CreateOrderRolesProcessor $createOrderRolesProcessor
|
||||
*/
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreatesAddress $createAddress, CreateOrderRolesProcessor $createOrderRolesProcessor, CreateContactProcessor $createContactProcessor, CreateRemarkProcessor $createRemarkProcessor)
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreatesAddress $createAddress, CreateOrderRolesProcessor $createOrderRolesProcessor)
|
||||
{
|
||||
$this->canCreateOrder = $canCreateOrder;
|
||||
$this->createsOrder = $createsOrder;
|
||||
$this->createAddress = $createAddress;
|
||||
$this->createOrderRolesProcessor = $createOrderRolesProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,37 +73,7 @@ class CreateOrderProcessor
|
||||
|
||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode,$address->reference);
|
||||
|
||||
/** @var Address $order_address */
|
||||
$order_address = $this->createAddress->execute($order, $addressObject);
|
||||
|
||||
$contact = $address->contacts()->first();
|
||||
|
||||
if ($contact) {
|
||||
$contactObject = new ContactObject(
|
||||
$contact->reference,
|
||||
$contact->phone,
|
||||
'',
|
||||
''
|
||||
);
|
||||
|
||||
if($contactObject->getPhone()){
|
||||
$order_remark = $this->createContactProcessor->execute($contactObject, $order_address);
|
||||
}
|
||||
}
|
||||
|
||||
$remark = $address->remarks()->first();
|
||||
|
||||
if ($remark){
|
||||
$remarkObject = new RemarkObject(
|
||||
$remark->content,
|
||||
Auth()->user()->id
|
||||
);
|
||||
|
||||
if($remarkObject->getContent()){
|
||||
$this->createRemarkProcessor->execute($order_address, $remarkObject);
|
||||
}
|
||||
}
|
||||
|
||||
$this->createAddress->execute($order, $addressObject);
|
||||
|
||||
$this->createOrderRolesProcessor->execute($originWarehouse, $order);
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class CreateOrderRolesProcessor
|
||||
$importer = $order->companyModule;
|
||||
|
||||
/** @var CompanyModule $destinationWarehouse */
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::YD_GUANG_ZHOU || $originWarehouse->reference === WarehouseReferences::YD_YIWU ? WarehouseReferences::YD_DESTINATION_WAREHOUSE : WarehouseReferences::VT_DESTINATION_WAREHOUSE[$address->state_id]]);
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::DESTINATION_WAREHOUSE[$address->state_id ]]);
|
||||
|
||||
/** @var CompanyModule $freightForwarder */
|
||||
$freightForwarder = $originWarehouse->company->companyModules()->freightForwarders()->first();
|
||||
@@ -79,9 +79,33 @@ class CreateOrderRolesProcessor
|
||||
$roleObject = new OrderRoleObject($order, $destinationWarehouse, OrderRoleTypes::DESTINATION_WAREHOUSE);
|
||||
$this->createsOrderRole->execute($roleObject);
|
||||
|
||||
|
||||
$roleObject = new OrderRoleObject($order, $freightForwarder, OrderRoleTypes::LAST_MILE_DELIVERY_DRIVER);
|
||||
$this->createsOrderRole->execute($roleObject);
|
||||
|
||||
return true;
|
||||
|
||||
$companies = $this->fetchesCompany->getRepository()->whereIn('id',[1, $request->get('warehouse_id')])->get();
|
||||
|
||||
$cief_company = $companies[0]->id == 1 ? $companies[0] : $companies[1];
|
||||
$warehouse_company = $companies[0]->id != 1 ? $companies[0] : $companies[1];
|
||||
|
||||
$cief_company_module = $cief_company->companyModule()->first();
|
||||
$contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$cief_company_module->unity_hash_id]);
|
||||
$contractEntities[0]->{"company_module_id"} = $cief_company_module->id;
|
||||
|
||||
$warehouse_company_module = $warehouse_company->companyModule()->first();
|
||||
$contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$warehouse_company_module->unity_hash_id]);
|
||||
$contractEntities[1]->{"company_module_id"} = $warehouse_company_module->id;
|
||||
|
||||
foreach($contractEntities as $entity){
|
||||
$order_role_object = new OrderRoleObject($orderId, $entity->company_module_id, $entity->hash_id, $entity->entity_signature_hash_id);
|
||||
|
||||
$this->canCreateOrderRole->passes($order_role_object);
|
||||
|
||||
$this->createsOrderRole->execute($order_role_object);
|
||||
}
|
||||
|
||||
return $contractEntities;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,6 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\DeletesAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -33,12 +29,6 @@ class RequestChangeOrderAddressProcessor
|
||||
/** @var DeletesAddress */
|
||||
private $deletesAddress;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* ChangeOrderAddressProcessor constructor.
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
@@ -46,7 +36,7 @@ class RequestChangeOrderAddressProcessor
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param DeletesAddress $deletesAddress
|
||||
*/
|
||||
public function __construct(CanChangeOrderAddress $canChangeOrderAddress, FetchesOrder $fetchesOrder, CreatesAddress $createsAddress, FetchesAddress $fetchesAddress, DeletesAddress $deletesAddress, CreateContactProcessor $createContactProcessor, CreateRemarkProcessor $createRemarkProcessor)
|
||||
public function __construct(CanChangeOrderAddress $canChangeOrderAddress, FetchesOrder $fetchesOrder, CreatesAddress $createsAddress, FetchesAddress $fetchesAddress, DeletesAddress $deletesAddress)
|
||||
{
|
||||
|
||||
$this->canChangeOrderAddress = $canChangeOrderAddress;
|
||||
@@ -54,20 +44,12 @@ class RequestChangeOrderAddressProcessor
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->deletesAddress = $deletesAddress;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
|
||||
$this->canChangeOrderAddress->passes();
|
||||
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->get('order_id')]);
|
||||
@@ -77,32 +59,7 @@ class RequestChangeOrderAddressProcessor
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->get('address_id')]);
|
||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, $address->reference, ApprovalStatus::PENDING_VERIFICATION);
|
||||
$order_address = $this->createsAddress->execute($order, $addressObject);
|
||||
|
||||
$contact = $address->contacts()->first();
|
||||
if($contact){
|
||||
$contactObject = new ContactObject(
|
||||
$contact->reference,
|
||||
$contact->phone,
|
||||
'',
|
||||
''
|
||||
);
|
||||
|
||||
$this->createContactProcessor->execute($contactObject, $order_address);
|
||||
|
||||
}
|
||||
|
||||
$remark = $address->remarks()->first();
|
||||
|
||||
if($remark){
|
||||
$remarkObject = new RemarkObject(
|
||||
$remark->content,
|
||||
Auth()->user()->id
|
||||
);
|
||||
|
||||
$this->createRemarkProcessor->execute($order_address, $remarkObject);
|
||||
}
|
||||
|
||||
$this->createsAddress->execute($order, $addressObject);
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use App\Classes\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateDoFromVTPortalProcessor
|
||||
{
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var FetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/**
|
||||
* FetchDeliveryListFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, FetchesAddress $fetchesAddress)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $address
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function execute($address) {
|
||||
|
||||
if(!app()->environment(['production'])){
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
$order = $address->owner()->orderBy('id', 'desc')->first();
|
||||
$packing_list = $order->packingLists()->orderBy('id', 'desc')->first();
|
||||
|
||||
if ($packing_list) {
|
||||
$contact = $address->contacts()->first();
|
||||
$remark = $address->remarks()->first();
|
||||
|
||||
$remark = $remark ? $remark->content : 'URGENT!!! PLEASE CALL BEFORE ONE DAY DELIVERY.';
|
||||
$phone = $contact ? $contact->phone : null;
|
||||
$reference = $contact ? $contact->reference : null;
|
||||
|
||||
$status = 'On Hold';
|
||||
|
||||
if (in_array($packing_list->status, [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||
$status = 'Release';
|
||||
}
|
||||
|
||||
$vt_do = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"Do","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"Filter": ["FullMarking:$contains$%js%\"' . $order->reference . '\"\u0000"]}}'), '');
|
||||
|
||||
$vt_do = $this->fetchesDataFRomVTPortal->getResponseBody($vt_do);
|
||||
|
||||
if ($vt_do) {
|
||||
foreach ($vt_do->Rows as $key => $row) {
|
||||
$vt_do_update = $this->fetchesDataFRomVTPortal->clientRequest(
|
||||
'http://portal.vtnation.com.my/Services/DataControllerService.asmx/Execute',
|
||||
'POST',
|
||||
json_decode('{
|
||||
"controller": "Do",
|
||||
"view": "editForm1",
|
||||
"args": {
|
||||
"CommandName": "Update",
|
||||
"CommandArgument": "Save",
|
||||
"Path": "ag2/a4",
|
||||
"LastCommandName": "Edit",
|
||||
"Values": [
|
||||
{
|
||||
"Name": "ShippingAddress",
|
||||
"NewValue": "' . $address->street_one . ' ' . $address->street_two . ' '. $address->district->name.' '. $address->postcode.' '.$address->state->name.' '.$address->country->name.'",
|
||||
"Modified": true,
|
||||
"ReadOnly": false,
|
||||
"Error": null
|
||||
},
|
||||
{
|
||||
"Name": "Attn",
|
||||
"NewValue": "'.$reference.'",
|
||||
"Modified": true,
|
||||
"ReadOnly": false,
|
||||
"Error": null
|
||||
},
|
||||
{
|
||||
"Name": "Tel",
|
||||
"NewValue": "'.$phone.'",
|
||||
"Modified": true,
|
||||
"ReadOnly": false,
|
||||
"Error": null
|
||||
},
|
||||
{
|
||||
"Name": "Status",
|
||||
"NewValue": "' . $status . '",
|
||||
"Modified": true,
|
||||
"ReadOnly": false,
|
||||
"Error": null
|
||||
},
|
||||
{
|
||||
"Name": "Doremarks",
|
||||
"NewValue": "'. $remark .'",
|
||||
"Modified": true,
|
||||
"ReadOnly": false,
|
||||
"Error": null
|
||||
},
|
||||
{
|
||||
"Name": "DoID",
|
||||
"OldValue": '.$row[0].',
|
||||
"NewValue": '.$row[0].',
|
||||
"Modified": false,
|
||||
"ReadOnly": true,
|
||||
"Error": null
|
||||
}
|
||||
],
|
||||
"Controller": "Do"
|
||||
}
|
||||
}'), '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (\Exception $exception){
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use App\Classes\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateDoFromYDPortalProcessor
|
||||
{
|
||||
/** @var FetchesDataFromYDPortal */
|
||||
private $fetchesDataFRomYDPortal;
|
||||
|
||||
/** @var FetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/**
|
||||
* FetchDeliveryListFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
*/
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, FetchesAddress $fetchesAddress)
|
||||
{
|
||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $address
|
||||
* @return void
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function execute($address) {
|
||||
try {
|
||||
$order = $address->owner()->orderBy('id', 'desc')->first();
|
||||
$packing_lists = $order->packingLists()
|
||||
->where('type', PackingListType::SHIPPING_PACKING_LIST)
|
||||
->where('status', '!=', ApprovalStatus::SUSPENDED)
|
||||
->orderBy('id', 'desc')->get();
|
||||
|
||||
|
||||
foreach ($packing_lists as $key => $row) {
|
||||
if ($row->status === ApprovalStatus::SUSPENDED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$contact = $address->contacts()->first();
|
||||
$remark = $address->remarks()->first();
|
||||
|
||||
$phone = $contact ? $contact->phone : null;
|
||||
$reference = $contact ? $contact->reference : null;
|
||||
$remark = $remark ? $remark->content : 'URGENT!!! PLEASE CALL BEFORE ONE DAY DELIVERY.';
|
||||
|
||||
$this->fetchesDataFRomYDPortal->clientRequest(
|
||||
'http://www.yd-wl.com/api/UpdateOrderAddress.ashx',
|
||||
'POST',
|
||||
[
|
||||
'expressno' => $row->reference,
|
||||
'customers_name' => $reference,
|
||||
'cellphone' => $phone,
|
||||
'postcode' => $address->postcode,
|
||||
'streetAddress' => $address->street_one . ' ' . $address->street_two . ' '. $address->district->name.' '. $address->post_code.' '.$address->state->name.' '.$address->country->name.' '.$address->postcode.' || '.$remark
|
||||
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new InternalServerErrorException('failed to approve address due to an error related to YD portal');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Models\Remark;
|
||||
use App\Models\Order;
|
||||
|
||||
class CreatesOrderRemark extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param RemarkObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Order $order, RemarkObject $object) {
|
||||
$model = new Remark();
|
||||
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->content = $object->getContent();
|
||||
|
||||
return $this->handler($order->remarks(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class FetchesDataFromYDPortal
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $method
|
||||
* @param $body
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function clientRequest(string $url, string $method, $body){
|
||||
|
||||
$client = new \GuzzleHttp\Client();
|
||||
|
||||
$body['apicode'] = env('YD_API_CODE');
|
||||
|
||||
$request = $client->requestAsync($method, $url, ['query' => $body]);
|
||||
|
||||
return $request->wait();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ResponseInterface $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function getResponseBody(ResponseInterface $request){
|
||||
$content = $request->getBody()->getContents();
|
||||
$content = str_replace("\r",'', $content);
|
||||
$content = str_replace("\n",'', $content);
|
||||
return json_decode($content);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Order;
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
|
||||
class UpdateOrderReference extends AbstractUpdateRecord
|
||||
{
|
||||
public function execute(Order $model, string $reference)
|
||||
{
|
||||
$model->reference = $reference;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingListOwner;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesTransportStatus;
|
||||
use App\Classes\Modules\Unity\Services\CreatesContract;
|
||||
use App\Classes\Modules\Unity\Processors\ActivateContractProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingListContractReference;
|
||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignPackingListOrderLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Assign Packing List Order',
|
||||
'message' => 'You have successfully created a Packing List Order'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var UpdatesPackingListOwner */
|
||||
private $updatesPackingListOwner;
|
||||
|
||||
/** @var UpdatesTransportStatus */
|
||||
private $updatesTransportStatus;
|
||||
|
||||
/** @var CreatesContract */
|
||||
private $unityCreateContract;
|
||||
|
||||
/** @var ActivateContractProcessor */
|
||||
private $unityActivateContract;
|
||||
|
||||
/** @var CreateContractEntityProcessor */
|
||||
private $unityCreateContractEntity;
|
||||
|
||||
/** @var AssignContractEntityProcessor */
|
||||
private $unityAssignContractEntity;
|
||||
|
||||
/** @var UpdatesPackingListContractReference */
|
||||
private $updatesPackingListContractReference;
|
||||
|
||||
/** @var CreatesStep */
|
||||
private $createsStep;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param UpdatesPackingListOwner $updatesPackingListOwner
|
||||
* @param UpdatesTransportStatus $updatesTransportStatus
|
||||
* @param CreatesContract $unityCreateContract
|
||||
* @param ActivateContractProcessor $unityActivateContract
|
||||
* @param CreateContractEntityProcessor $unityCreateContractEntity
|
||||
* @param AssignContractEntityProcessor $unityAssignContractEntity
|
||||
* @param UpdatesPackingListContractReference $updatesPackingListContractReference
|
||||
* @param CreatesStep $createsStep
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, FetchesOrder $fetchesOrder, UpdatesPackingListOwner $updatesPackingListOwner, UpdatesTransportStatus $updatesTransportStatus, CreatesContract $unityCreateContract, ActivateContractProcessor $unityActivateContract, CreateContractEntityProcessor $unityCreateContractEntity, AssignContractEntityProcessor $unityAssignContractEntity, UpdatesPackingListContractReference $updatesPackingListContractReference, CreatesStep $createsStep)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->updatesPackingListOwner = $updatesPackingListOwner;
|
||||
$this->updatesTransportStatus = $updatesTransportStatus;
|
||||
|
||||
$this->unityCreateContract = $unityCreateContract;
|
||||
$this->unityActivateContract = $unityActivateContract;
|
||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
||||
|
||||
$this->updatesPackingListContractReference = $updatesPackingListContractReference;
|
||||
$this->createsStep = $createsStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$warehouse_packing_list = $this->fetchesPackingList->execute([
|
||||
'id' => $request->route('id'),
|
||||
'type' => PackingListType::WAREHOUSE_RECEIVE_LIST
|
||||
]);
|
||||
|
||||
$order = $this->fetchesOrder->execute(['reference' => $request->route('reference')]);
|
||||
|
||||
$warehouse_packing_list = $this->updatesPackingListOwner->execute($warehouse_packing_list, $order);
|
||||
|
||||
|
||||
$transport = $warehouse_packing_list->transports()->first();
|
||||
$transport = $this->updatesTransportStatus->execute($transport, ApprovalStatus::APPROVED);
|
||||
|
||||
$contract = $this->unityCreateContract->execute();
|
||||
$contractReference = $contract->hash_id;
|
||||
$contractObligations = $contract->contract_obligation_list;
|
||||
|
||||
$this->unityActivateContract->execute($contractReference);
|
||||
$supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
||||
|
||||
$supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
||||
|
||||
$importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
||||
|
||||
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||
|
||||
$packing_list = $this->fetchesPackingList->execute([
|
||||
'reference' => $warehouse_packing_list->reference,
|
||||
'type' => PackingListType::SHIPPING_PACKING_LIST
|
||||
]);
|
||||
|
||||
$warehouse_packing_list = $this->updatesPackingListOwner->execute($packing_list, $order);
|
||||
|
||||
$this->updatesPackingListContractReference->execute($packing_list, $contractReference);
|
||||
|
||||
foreach($contractObligations as $obligation) {
|
||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||
$this->createsStep->execute($packing_list, $stepObject);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($warehouse_packing_list));
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingListRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignPackingListRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Packing List Remark',
|
||||
'message' => 'You have successfully created a new Packing List Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesPackingListRemark */
|
||||
private $createsPackingListRemark;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesPackingListRemark $createsPackingListRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesPackingListRemark $createsPackingListRemark, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsPackingListRemark = $createsPackingListRemark;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject(
|
||||
$request->input('content'),
|
||||
$request->route('id')
|
||||
);
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$query = $this->createsPackingListRemark->execute($this->fetchesPackingList->execute(['id' => $request->route('id')]), $object);
|
||||
return $this->resourceResponse( new RemarkResource($query));
|
||||
}
|
||||
}
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainerRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignContainerRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order Remark',
|
||||
'message' => 'You have successfully created a new Order Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesContainerRemark */
|
||||
private $createsContainerRemark;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesContainerRemark $createsContainerRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesContainerRemark $createsContainerRemark, FetchesContainer $fetchesContainer)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsContainerRemark = $createsContainerRemark;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject(
|
||||
$request->input('content'),
|
||||
$request->route('id')
|
||||
);
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$query = $this->createsContainerRemark->execute($this->fetchesContainer->execute(['id' => $request->route('id')]), $object);
|
||||
return $this->resourceResponse( new RemarkResource($query));
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -20,8 +20,8 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Container Remark',
|
||||
'message' => 'You have successfully created a new Container Remark'
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->input('container_id')]);
|
||||
|
||||
$object = new RemarkObject($request->input('content'), auth()->user()->id);
|
||||
$object = new RemarkObject($request->input('content'), 1);
|
||||
|
||||
$this->createRemarkProcessor->execute($container, $object);
|
||||
|
||||
|
||||
+10
-5
@@ -45,16 +45,21 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchContainer->passes();
|
||||
try {
|
||||
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
$this->canFetchContainer->passes();
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanListPackingLists;
|
||||
use App\Http\Resources\PackingListNullOrderResource;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -50,11 +49,18 @@ class ListPackingListsLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListPackingLists->passes();
|
||||
try {
|
||||
|
||||
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters')));
|
||||
$this->canListPackingLists->passes();
|
||||
|
||||
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(PackingListResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
return $this->collectionResponse(PackingListResource::collection($query));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,17 +45,21 @@ class ListPackagesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListPackages->passes();
|
||||
try {
|
||||
|
||||
$query = $this->listsPackages->execute($this->listsPackages->deserializeFilters($request->input('filters')));
|
||||
$this->canListPackages->passes();
|
||||
|
||||
return $this->collectionResponse(PackageResource::collection($query));
|
||||
$query = $this->listsPackages->execute($this->listsPackages->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(PackageResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,11 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingListStatus;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanUpdatePackingList;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -38,48 +34,29 @@ class UpdatePackingListStatusLogic extends AbstractControllerLogic
|
||||
/** @var UpdatesPackingListStatus */
|
||||
private $updatesPackingListStatus;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/**
|
||||
* UpdatePackingListStatusLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param UpdatesPackingListStatus $updatesPackingListStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesPackingListStatus $updatesPackingListStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesPackingListStatus $updatesPackingListStatus)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->updatesPackingListStatus = $updatesPackingListStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\InternalServerErrorException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$packing_list = $this->updatesPackingListStatus->execute($packingList, $request->route('status'));
|
||||
$address = $packing_list->owner()->first()->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
$query = $this->updatesPackingListStatus->execute($packingList, $request->route('status'));
|
||||
|
||||
|
||||
// $appointee = $address->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
|
||||
$this->updateDoFromVTPortalProcessor->execute($address);
|
||||
$this->updateDoFromYDPortalProcessor->execute($address);
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||
return $this->resourceResponse(new PackingListResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class CreatePackageProcessor
|
||||
/**
|
||||
* @param PackageObject $object
|
||||
* @param PackingList $packingList
|
||||
* @return void
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
@@ -41,18 +41,7 @@ class CreatePackageProcessor
|
||||
|
||||
$this->canCreatePackage->passes($object);
|
||||
|
||||
$this->createsPackage->execute($object, $packingList);
|
||||
|
||||
/** @var PackingList $replica */
|
||||
$replica = $packingList->packingLists()->first();
|
||||
|
||||
if($replica) {
|
||||
$modificationValue = 1;
|
||||
$packageObject = new PackageObject($object->getType(), $object->getDescription(), $object->getWidth() + $modificationValue, $object->getHeight() + $modificationValue, $object->getLength() + $modificationValue, $object->getWeight(), $object->getQuantity(), $object->getStatus());
|
||||
$package = $this->createsPackage->execute($packageObject, $replica);
|
||||
}
|
||||
|
||||
return ;
|
||||
return $this->createsPackage->execute($object, $packingList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,6 @@ use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class CreatePackingListProcessor
|
||||
{
|
||||
@@ -45,17 +41,7 @@ class CreatePackingListProcessor
|
||||
public function execute(PackingListObject $object, Packable $packable){
|
||||
|
||||
$this->canCreatePackingList->passes($object);
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createsPackingList->execute($object, $packable);
|
||||
|
||||
$appointee_id = $packingList->owner_id == 1 ? 2037 : $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
|
||||
$type = $object->getType() === PackingListType::SHIPPING_PACKING_LIST ? PackingListType::SHIPPING_PACKING_LIST_REPLICA : PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA;
|
||||
/** create packing list replica */
|
||||
$object = new PackingListObject($object->getReference().'_01', $appointee_id, $type, ApprovalStatus::PENDING_SUBMISSION);
|
||||
$this->createsPackingList->execute($object, $packingList);
|
||||
|
||||
return $packingList;
|
||||
return $this->createsPackingList->execute($object, $packable);
|
||||
}
|
||||
|
||||
}
|
||||
-4
@@ -80,10 +80,6 @@ class FetchContainersStatusUpdateFromVTPortalProcessor
|
||||
|
||||
$containerDetails = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailsRequest);
|
||||
|
||||
if(!$containerDetails->Rows){
|
||||
continue;
|
||||
}
|
||||
|
||||
$containerDetails = $containerDetails->Rows[0];
|
||||
|
||||
if(!$eta = $containerDetails[3]){
|
||||
|
||||
@@ -66,10 +66,6 @@ class FetchDeliveryListFromVTPortalProcessor
|
||||
|
||||
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
||||
|
||||
if(!array_key_exists(0, $shippingPackingLists->Rows)){
|
||||
continue;
|
||||
}
|
||||
|
||||
$shippingPackingList = $shippingPackingLists->Rows[0];
|
||||
|
||||
if(!$shippingPackingList[9] && !$shippingPackingList[10]) {
|
||||
@@ -91,7 +87,6 @@ class FetchDeliveryListFromVTPortalProcessor
|
||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
} catch (GuzzleException $exception) {
|
||||
dd($exception);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -21,7 +21,6 @@ use App\Classes\Modules\Unity\Services\CreatesContract;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
@@ -142,6 +141,7 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
$containers = $this->fetchesDataFRomVTPortal->getResponseBody($containersRequest);
|
||||
|
||||
foreach ($containers->Rows as $container){
|
||||
|
||||
$filter = '["ContainerID:=%js%'.$container[11].'"]';
|
||||
$containerDetailRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
@@ -201,7 +201,7 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
$connection = $order->companyModule->connections()->first();
|
||||
$marking = $connection->invitee_reference;
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, $contractReference);
|
||||
$packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id, PackingListType::SHIPPING_PACKING_LIST, (int) filter_var($marking, FILTER_SANITIZE_NUMBER_INT) <= 1000 ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::SUSPENDED, $contractReference);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
@@ -212,6 +212,7 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
$this->createsStep->execute($packingList, $stepObject);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,402 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Unity\Processors\ActivateContractProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Services\CreatesContract;
|
||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\Container;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchOrderListsFromYdPortalProcessor
|
||||
{
|
||||
/** @var FetchesDataFromYDPortal */
|
||||
private $fetchesDataFRomYDPortal;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreateContainerProcessor */
|
||||
private $createContainerProcessor;
|
||||
|
||||
/** @var CreatesContract */
|
||||
private $unityCreateContract;
|
||||
|
||||
/** @var AssignContractEntityProcessor */
|
||||
private $unityAssignContractEntity;
|
||||
|
||||
/** @var CreateContractEntityProcessor */
|
||||
private $unityCreateContractEntity;
|
||||
|
||||
/** @var CreatesStep */
|
||||
private $createsStep;
|
||||
|
||||
/** @var ActivateContractProcessor */
|
||||
private $unityActivateContract;
|
||||
|
||||
/**
|
||||
* FetchOrderListsFromYdPortalProcessor constructor.
|
||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param CreatePackageProcessor $createPackageProcessor
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreateContainerProcessor $createContainerProcessor
|
||||
* @param CreatesContract $unityCreateContract
|
||||
* @param AssignContractEntityProcessor $unityAssignContractEntity
|
||||
* @param CreateContractEntityProcessor $unityCreateContractEntity
|
||||
* @param CreatesStep $createsStep
|
||||
* @param ActivateContractProcessor $unityActivateContract
|
||||
*/
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, FetchesOrder $fetchesOrder, UpdatesContractObligation $updatesContractObligations, CreatePackingListProcessor $createPackingListProcessor, CreatePackageProcessor $createPackageProcessor, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, FetchesContainer $fetchesContainer, FetchesPackingList $fetchesPackingList, FetchesCompanyModule $fetchesCompanyModule, CreateContainerProcessor $createContainerProcessor, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, CreatesStep $createsStep, ActivateContractProcessor $unityActivateContract)
|
||||
{
|
||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createContainerProcessor = $createContainerProcessor;
|
||||
$this->unityCreateContract = $unityCreateContract;
|
||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
||||
$this->createsStep = $createsStep;
|
||||
$this->unityActivateContract = $unityActivateContract;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @return void
|
||||
*/
|
||||
public function execute(?Carbon $start = null, ?Carbon $end = null)
|
||||
{
|
||||
try {
|
||||
$start = $start ? $start : Carbon::now()->subMonths(2);
|
||||
|
||||
$startLimit = Carbon::parse('01-12-2021');
|
||||
|
||||
if($start->isBefore($startLimit)){
|
||||
$start = $startLimit;
|
||||
}
|
||||
|
||||
$end = $end ? $end : Carbon::now();
|
||||
|
||||
$orderRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/GetOrderList.ashx', 'GET', [
|
||||
'begintime' => $start->timestamp,
|
||||
'endtime' => $end->timestamp,
|
||||
]);
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
||||
|
||||
foreach($rows->data as $row){
|
||||
|
||||
$containerReference = null;
|
||||
$loadingDate = null;
|
||||
$unstuffingDate = null;
|
||||
$deliveryDate = null;
|
||||
$etd = null;
|
||||
$eta = null;
|
||||
$delayDate = null;
|
||||
|
||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
||||
'trakingno' => $row->expressno
|
||||
]);
|
||||
|
||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
||||
|
||||
foreach (array_reverse($rows->data) as $trackingRow) {
|
||||
if ($trackingRow->tracking === '货物已送达仓库准备入库中') {
|
||||
$receiveDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if (strpos($trackingRow->tracking, '货物装柜完成。') !== false) {
|
||||
$tracking = explode(':', $trackingRow->tracking);
|
||||
$containerReference = explode('预计到港时间', $tracking[1])[0];
|
||||
$loadingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
$etd = Carbon::parse($tracking[2])->subDays(5);
|
||||
$eta = Carbon::parse($tracking[2]);
|
||||
}
|
||||
|
||||
if (strpos($trackingRow->tracking, '预计船时间为') !== false) {
|
||||
$tracking = explode('预计船时间为', $trackingRow->tracking);
|
||||
$delayDate = Carbon::parse(explode('日', $tracking[1])[0]);
|
||||
}
|
||||
|
||||
if (strpos($trackingRow->tracking, '预计开船为') !== false) {
|
||||
$tracking = explode('预计开船为', $trackingRow->tracking);
|
||||
$delayDate = Carbon::parse(explode('日', $tracking[1])[0]);
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
||||
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
|
||||
if ($trackingRow->tracking === '货物已派送完成') {
|
||||
$deliveryDate = Carbon::parse($trackingRow->trackingtime);
|
||||
}
|
||||
}
|
||||
|
||||
$customerno = preg_split('(-|\(|\)|\/)', $row->customerno);
|
||||
|
||||
$orderNumber = $customerno[array_key_last($customerno)];
|
||||
$allow_contract = true;
|
||||
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => substr($orderNumber, -9)]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
$order = $this->fetchesCompanyModule->execute(['id' => 1]);
|
||||
$allow_contract = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$packingListReference = $row->expressno;
|
||||
|
||||
try{
|
||||
$packingList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::SHIPPING_PACKING_LIST]);
|
||||
|
||||
$packingList->packages()->delete();
|
||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
$warehouseReceiveList = $this->fetchesPackingList->execute(['reference' => $row->expressno, 'type' => PackingListType::WAREHOUSE_RECEIVE_LIST]);
|
||||
$warehouseReceiveList->packages()->delete();
|
||||
$replica = $warehouseReceiveList->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
|
||||
if (!$allow_contract) {
|
||||
$appointee_id = 2037;
|
||||
} else {
|
||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
}
|
||||
|
||||
$warehouseReceiveObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::WAREHOUSE_RECEIVE_LIST, $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
|
||||
/** @var PackingList $warehouseReceiveList */
|
||||
$warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order);
|
||||
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $row->kuaidilist, Carbon::parse($receiveDate), Carbon::parse($receiveDate), $allow_contract ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
||||
$transport = $this->createsTransport->execute($transportObject, $warehouseReceiveList);
|
||||
|
||||
if ($allow_contract) {
|
||||
|
||||
$contract = $this->unityCreateContract->execute();
|
||||
|
||||
$contractReference = $contract->hash_id;
|
||||
$contractObligations = $contract->contract_obligation_list;
|
||||
|
||||
$this->unityActivateContract->execute($contractReference);
|
||||
|
||||
$supervisorHashId = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->unity_hash_id;
|
||||
|
||||
$supervisorContractEntity = $this->unityCreateContractEntity->execute($contractReference, $supervisorHashId);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->update(['entity_hash_id' => $supervisorContractEntity->hash_id, 'entity_signature' => $supervisorContractEntity->entity_signature_hash_id]);
|
||||
|
||||
$importerContractEntity = $this->unityCreateContractEntity->execute($contractReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->appointee->unity_hash_id);
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::IMPORTER)->first()->update(['entity_hash_id' => $importerContractEntity->hash_id, 'entity_signature' => $importerContractEntity->entity_signature_hash_id]);
|
||||
|
||||
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||
}
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $appointee_id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::SUSPENDED, !$allow_contract ? null : $contractReference);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
if ($allow_contract) {
|
||||
foreach ($contractObligations as $obligation) {
|
||||
$stepObject = new StepsObject($order->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->id, $obligation->reference, $obligation->sequence, $obligation->hash_id);
|
||||
$this->createsStep->execute($packingList, $stepObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($row->deliverysize as $package) {
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $package->width, (float) $package->height, (float) $package->length, 0, (float) $package->num, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
$weightCbm = (float) $row->weight / 500;
|
||||
$overWeightCbm = $weightCbm - $packingList->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity'));
|
||||
|
||||
if($overWeightCbm > 0){
|
||||
$measurement = round($overWeightCbm ** (1/3) * 100, 2);
|
||||
$packageObject = new PackageObject(PackageType::OVER_WEIGHT, 'Overweight CBM', (float) $measurement, (float) $measurement, (float) $measurement, 0, 1, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
if($order instanceof Order){
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
if(!in_array($marking, ['2192KAA', '2353GFE', '6866DTR', '153DSR', '1291NSC', '8288MIB'])){
|
||||
$this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/confirmsendorder.ashx', 'GET', [
|
||||
'expressno' => $row->expressno
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($containerReference) {
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerReference]);
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
if (!$allow_contract) {
|
||||
$appointee_id = 2037;
|
||||
}
|
||||
else {
|
||||
$appointee_id = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id;
|
||||
}
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $appointee_id]);
|
||||
|
||||
$containerObject = new ContainerObject($containerReference, '', '', ContainerTypes::FORTY_FEET_DRY_CONTAINER, $loadingDate, ApprovalStatus::PENDING_VERIFICATION);
|
||||
/** @var Container $container */
|
||||
$container = $this->createContainerProcessor->execute($containerObject, $originWarehouse);
|
||||
|
||||
$container->packingLists()->detach($packingList);
|
||||
$container->packingLists()->attach($packingList);
|
||||
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport){
|
||||
$transportObject = new TransportObject(TransportType::SEA, null, null, $etd, null, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $eta, ApprovalStatus::APPROVED));
|
||||
}
|
||||
}
|
||||
|
||||
if($delayDate){
|
||||
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport->schedules()->where('eta', '=', $delayDate)->first()) {
|
||||
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($unstuffingDate && $container->status !== ApprovalStatus::COMPLETED){
|
||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
$container->transports()->first()->update(['drop_date' => $unstuffingDate, 'status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
foreach($container->packingLists as $packingList){
|
||||
|
||||
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
}
|
||||
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){
|
||||
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
||||
$step->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($deliveryDate && !$packingList->transports){
|
||||
$packingList->status = ApprovalStatus::COMPLETED;
|
||||
$packingList->save();
|
||||
|
||||
$deliveryDate = Carbon::parse($deliveryDate);
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
||||
|
||||
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
echo 'successful';
|
||||
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
Log::debug($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+10
-14
@@ -50,38 +50,34 @@ class FetchPackingListFromVTPortalProcessor
|
||||
$query->where('status', '=', ApprovalStatus::COMPLETED);
|
||||
})->get();
|
||||
|
||||
DB::beginTransaction();
|
||||
foreach($packingLists as $packingList){
|
||||
try {
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]';
|
||||
|
||||
$shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
||||
if(count($shippingPackingLists->Rows)) {
|
||||
$packingList->packages()->delete();
|
||||
|
||||
$replica = $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
if($replica) $replica->packages()->delete();
|
||||
$packingList->packages()->delete();
|
||||
|
||||
foreach($shippingPackingLists->Rows as $shippingPackingList){
|
||||
if(!$shippingPackingList[22]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $shippingPackingList[19], $shippingPackingList[31], $shippingPackingList[30], $shippingPackingList[29], 0, $shippingPackingList[22], ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
foreach($shippingPackingLists->Rows as $shippingPackingList){
|
||||
if(!$shippingPackingList[22]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $shippingPackingList[19], $shippingPackingList[31], $shippingPackingList[30], $shippingPackingList[29], 0, $shippingPackingList[22], ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (GuzzleException $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return [];
|
||||
|
||||
|
||||
+6
-3
@@ -206,7 +206,10 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
|
||||
if(!$packingList) {
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $tracking, Carbon::parse($receiveDate), Carbon::parse($receiveDate), ApprovalStatus::APPROVED);
|
||||
|
||||
|
||||
$this->createsTransport->execute($transportObject, $packingList);
|
||||
}
|
||||
|
||||
@@ -217,14 +220,14 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject(Carbon::parse($receiveDate), Carbon::parse($receiveDate), ApprovalStatus::APPROVED));
|
||||
|
||||
/** @var PackingList $replica */
|
||||
$replica = $packingList->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA)->first();
|
||||
$packingList->packages()->delete();
|
||||
if($replica) $replica->packages()->delete();
|
||||
|
||||
$packageObject = new PackageObject(PackageType::CARTON, $description, $measurement, $measurement, $measurement, 0, $quantity, ApprovalStatus::APPROVED);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (\Exception $exception){
|
||||
Log::error($exception->getMessage());
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services\Containers;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Models\Remark;
|
||||
use App\Models\Container;
|
||||
|
||||
class CreatesContainerRemark extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param RemarkObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Container $container, RemarkObject $object) {
|
||||
$model = new Remark();
|
||||
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->content = $object->getContent();
|
||||
|
||||
return $this->handler($container->remarks(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Interfaces\Packable;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class CreatesNullOrderPackingList extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param PackingListObject $object
|
||||
* @param Packable $packable
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingListObject $object) {
|
||||
$model = new PackingList();
|
||||
|
||||
$model->reference = $object->getReference();
|
||||
$model->claimant_id = $object->getClaimantId();
|
||||
$model->type = $object->getType();
|
||||
$model->status = $object->getStatus();
|
||||
$model->reference_contract = $object->getContractReference();
|
||||
$model->owner_type = 'App\Models\Order';
|
||||
$model->owner_id = 1;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ class CreatesPackingList extends AbstractUpdateRelationshipRecord
|
||||
$model->claimant_id = $object->getClaimantId();
|
||||
$model->type = $object->getType();
|
||||
$model->status = $object->getStatus();
|
||||
$model->reference_contract = $object->getContractReference();
|
||||
|
||||
return $this->handler($packable->packingLists(), $model);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user