mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-26 07:54:04 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b3a296f2eb | |||
| 5a723c5fd1 | |||
| 6e9a27024b | |||
| e2e8f69f90 | |||
| e5c28faba7 | |||
| 4b81666cf2 | |||
| 4a2fb8e9e4 | |||
| ea772c3916 | |||
| f8d65d05da |
+2
-2
@@ -4,7 +4,7 @@ namespace App\Classes\General\Eloquent\Filters;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
class TypeIn implements Filter
|
class OwnerId implements Filter
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,7 +14,7 @@ class TypeIn implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
return $builder->whereIn('type', $value);
|
return $builder->where('owner_id', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,7 +15,6 @@ use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
|||||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
|
||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
||||||
@@ -77,9 +76,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
/** @var GenerateEmailVerificationAttemptProcessor */
|
/** @var GenerateEmailVerificationAttemptProcessor */
|
||||||
private $generateEmailVerificationAttemptProcessor;
|
private $generateEmailVerificationAttemptProcessor;
|
||||||
|
|
||||||
/** @var FetchesCompanyModule */
|
|
||||||
private $fetchesCompanyModule;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateCustomerLogic constructor.
|
* CreateCustomerLogic constructor.
|
||||||
* @param CreateUserProcessor $createUserProcessor
|
* @param CreateUserProcessor $createUserProcessor
|
||||||
@@ -92,9 +88,8 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
* @param UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor
|
* @param UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor
|
||||||
* @param AuthenticationProcessor $authenticationProcessor
|
* @param AuthenticationProcessor $authenticationProcessor
|
||||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
|
||||||
*/
|
*/
|
||||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule)
|
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor)
|
||||||
{
|
{
|
||||||
$this->createUserProcessor = $createUserProcessor;
|
$this->createUserProcessor = $createUserProcessor;
|
||||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||||
@@ -106,7 +101,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
$this->uploadIdentityDocumentProcessor = $uploadIdentityDocumentProcessor;
|
$this->uploadIdentityDocumentProcessor = $uploadIdentityDocumentProcessor;
|
||||||
$this->authenticationProcessor = $authenticationProcessor;
|
$this->authenticationProcessor = $authenticationProcessor;
|
||||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,9 +126,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
/** @var CompanyModule $companyModule */
|
/** @var CompanyModule $companyModule */
|
||||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::IMPORTER);
|
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::IMPORTER);
|
||||||
|
|
||||||
$inviter = $this->fetchesCompanyModule->execute(['reference'=>'CIEF']);
|
$connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate());
|
||||||
|
|
||||||
$connectionObject = new CompanyConnectionObject($companyModule, $inviter, mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate(), 'CIEF');
|
|
||||||
|
|
||||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\ValueObjects\Constants\Notifications;
|
use App\Classes\ValueObjects\Constants\Notifications;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class GeneratePasswordResetLogic extends AbstractControllerLogic
|
class GeneratePasswordResetLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Classes\Modules\Accounts\Services;
|
namespace App\Classes\Modules\Accounts\Services;
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -12,11 +11,6 @@ class AuthenticationRedirect
|
|||||||
public function url(User $user){
|
public function url(User $user){
|
||||||
|
|
||||||
if($user->type === RoleTypes::USER){
|
if($user->type === RoleTypes::USER){
|
||||||
|
|
||||||
if (in_array($user->companyModule()->first()->type, [BusinessType::ONLINE_SELLER, BusinessType::LAST_MILE_DELIVERY_AGENT])) {
|
|
||||||
return route('last_mile_delivery.dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
return route('dashboard');
|
return route('dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,11 +68,7 @@ class GeneratesAuthenticationToken {
|
|||||||
$companyModule = $user->companyModule()->first();
|
$companyModule = $user->companyModule()->first();
|
||||||
|
|
||||||
$claims = array_merge($claims, [
|
$claims = array_merge($claims, [
|
||||||
'company_id' => $companyModule->company_id,
|
'company_id' => $companyModule->company_id
|
||||||
'company_module_id' => $companyModule->id,
|
|
||||||
'company_module_type' => $companyModule->type,
|
|
||||||
'company_name' => $companyModule->name,
|
|
||||||
'company_marking' => $companyModule->type !== 8 ? $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference : 'HWT',
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
@@ -83,7 +82,7 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||||
|
|
||||||
$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'), $request->input('type'), ApprovalStatus::APPROVED, $request->input('reference'));
|
$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'), $request->input('reference'));
|
||||||
|
|
||||||
$this->canCreateAddress->passes($object);
|
$this->canCreateAddress->passes($object);
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -81,7 +79,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
{
|
{
|
||||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||||
|
|
||||||
$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'), AddressType::DELIVERY, ApprovalStatus::APPROVED, $request->input('reference'));
|
$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'), $request->input('reference'));
|
||||||
|
|
||||||
$this->canUpdateAddress->passes($object);
|
$this->canUpdateAddress->passes($object);
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,6 @@ class AddressObject implements DataTransferObject
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
private $postCode;
|
private $postCode;
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
private $type;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
private $status;
|
|
||||||
|
|
||||||
/** @var string|null */
|
/** @var string|null */
|
||||||
private $reference;
|
private $reference;
|
||||||
|
|
||||||
@@ -43,11 +37,9 @@ class AddressObject implements DataTransferObject
|
|||||||
* @param int $stateId
|
* @param int $stateId
|
||||||
* @param int $districtId
|
* @param int $districtId
|
||||||
* @param int $postCode
|
* @param int $postCode
|
||||||
* @param int $type
|
|
||||||
* @param int $status
|
|
||||||
* @param null|string $reference
|
* @param null|string $reference
|
||||||
*/
|
*/
|
||||||
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode, int $type, int $status, ?string $reference = null)
|
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode, ?string $reference = null, ?int $status = ApprovalStatus::APPROVED)
|
||||||
{
|
{
|
||||||
$this->streetOne = $streetOne;
|
$this->streetOne = $streetOne;
|
||||||
$this->streetTwo = $streetTwo;
|
$this->streetTwo = $streetTwo;
|
||||||
@@ -55,9 +47,8 @@ class AddressObject implements DataTransferObject
|
|||||||
$this->stateId = $stateId;
|
$this->stateId = $stateId;
|
||||||
$this->districtId = $districtId;
|
$this->districtId = $districtId;
|
||||||
$this->postCode = $postCode;
|
$this->postCode = $postCode;
|
||||||
$this->type = $type;
|
|
||||||
$this->status = $status;
|
|
||||||
$this->reference = $reference;
|
$this->reference = $reference;
|
||||||
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,11 +100,11 @@ class AddressObject implements DataTransferObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
public function getType(): int
|
public function getReference(): ?string
|
||||||
{
|
{
|
||||||
return $this->type;
|
return $this->reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,13 +115,5 @@ class AddressObject implements DataTransferObject
|
|||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return null|string
|
|
||||||
*/
|
|
||||||
public function getReference(): ?string
|
|
||||||
{
|
|
||||||
return $this->reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,8 +10,6 @@ namespace App\Classes\Modules\Addresses\Services;
|
|||||||
|
|
||||||
|
|
||||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Models\District;
|
use App\Models\District;
|
||||||
use App\Models\OldAddress;
|
use App\Models\OldAddress;
|
||||||
|
|
||||||
@@ -33,7 +31,7 @@ class CleansOldAddress
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AddressObject($this->cleanAddress($address->street_one, $district, $address->post_code), $this->cleanAddress($address->street_two, $district, $address->post_code), $district->country_id, $district->state_id, $district->id, $address->post_code, AddressType::DELIVERY, ApprovalStatus::APPROVED, 'Delivery Address');
|
return new AddressObject($this->cleanAddress($address->street_one, $district, $address->post_code), $this->cleanAddress($address->street_two, $district, $address->post_code), $district->country_id, $district->state_id, $district->id, $address->post_code, 'Delivery Address');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class CreatesAddress extends AbstractUpdateRelationshipRecord
|
|||||||
$model->district_id = $object->getDistrictId();
|
$model->district_id = $object->getDistrictId();
|
||||||
$model->postcode = $object->getPostCode();
|
$model->postcode = $object->getPostCode();
|
||||||
$model->status = $object->getStatus();
|
$model->status = $object->getStatus();
|
||||||
$model->type = $object->getType();
|
|
||||||
|
|
||||||
return $this->handler($addressable->addresses(), $model);
|
return $this->handler($addressable->addresses(), $model);
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
class CallbackBillplzLogic
|
class CallbackBillplzLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/** @var GetBillplzBill */
|
/** @var GetBillplzBill */
|
||||||
private $getBillplzBill;
|
private $getBillplzBill;
|
||||||
|
|
||||||
@@ -45,11 +47,12 @@ class CallbackBillplzLogic
|
|||||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||||
*/
|
*/
|
||||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
|
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWalletBalance $updatesWalletBalance)
|
||||||
{
|
{
|
||||||
$this->getBillplzBill = $getBillplzBill;
|
$this->getBillplzBill = $getBillplzBill;
|
||||||
$this->fetchesTransaction = $fetchesTransaction;
|
$this->fetchesTransaction = $fetchesTransaction;
|
||||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||||
|
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -81,11 +84,22 @@ class CallbackBillplzLogic
|
|||||||
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
$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));
|
$token = Auth::fromUser(User::find(1));
|
||||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||||
|
|
||||||
$marking = $transaction->owner()->first()->owner()->first();
|
$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]);
|
||||||
|
|
||||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $marking->reference, 'transaction' => $transaction, 'status' => $status]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+18
-1
@@ -14,6 +14,8 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||||
|
|
||||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
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 App\Models\Document;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -50,6 +52,9 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
|||||||
/** @var UpdatesOrdersStatus */
|
/** @var UpdatesOrdersStatus */
|
||||||
private $updatesOrdersStatus;
|
private $updatesOrdersStatus;
|
||||||
|
|
||||||
|
/** @var CreateNotificationProcessor */
|
||||||
|
private $createNotificationProcessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ApproveIdentificationDocumentLogic constructor.
|
* ApproveIdentificationDocumentLogic constructor.
|
||||||
* @param CanApproveDocument $canApproveDocument
|
* @param CanApproveDocument $canApproveDocument
|
||||||
@@ -58,8 +63,9 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
|||||||
* @param FetchesDocument $fetchesDocument
|
* @param FetchesDocument $fetchesDocument
|
||||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||||
* @param UpdatesOrdersStatus $updatesOrdersStatus
|
* @param UpdatesOrdersStatus $updatesOrdersStatus
|
||||||
|
* @param CreateNotificationProcessor $createNotificationProcessor
|
||||||
*/
|
*/
|
||||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus)
|
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor)
|
||||||
{
|
{
|
||||||
$this->canApproveDocument = $canApproveDocument;
|
$this->canApproveDocument = $canApproveDocument;
|
||||||
$this->approvesDocument = $approvesDocument;
|
$this->approvesDocument = $approvesDocument;
|
||||||
@@ -67,6 +73,7 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
|||||||
$this->fetchesDocument = $fetchesDocument;
|
$this->fetchesDocument = $fetchesDocument;
|
||||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||||
$this->updatesOrdersStatus = $updatesOrdersStatus;
|
$this->updatesOrdersStatus = $updatesOrdersStatus;
|
||||||
|
$this->createNotificationProcessor = $createNotificationProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,6 +97,16 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->updatesCompanyStatus->execute($document->owner, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED);
|
$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'){
|
if($status === 'approve'){
|
||||||
$orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
$orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ class CompanyConnectionObject implements DataTransferObject
|
|||||||
/** @var CompanyModule */
|
/** @var CompanyModule */
|
||||||
private $invitee;
|
private $invitee;
|
||||||
|
|
||||||
/** @var CompanyModule */
|
|
||||||
private $inviter;
|
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $inviterReference;
|
private $inviterReference;
|
||||||
|
|
||||||
@@ -23,14 +20,12 @@ class CompanyConnectionObject implements DataTransferObject
|
|||||||
/**
|
/**
|
||||||
* CompanyConnectionObject constructor.
|
* CompanyConnectionObject constructor.
|
||||||
* @param CompanyModule $invitee
|
* @param CompanyModule $invitee
|
||||||
* @param CompanyModule $inviter
|
|
||||||
* @param string $inviterReference
|
* @param string $inviterReference
|
||||||
* @param string $inviteeReference
|
* @param string $inviteeReference
|
||||||
*/
|
*/
|
||||||
public function __construct(CompanyModule $invitee, CompanyModule $inviter, string $inviteeReference, string $inviterReference)
|
public function __construct(CompanyModule $invitee, string $inviterReference, string $inviteeReference)
|
||||||
{
|
{
|
||||||
$this->invitee = $invitee;
|
$this->invitee = $invitee;
|
||||||
$this->inviter = $inviter;
|
|
||||||
$this->inviterReference = $inviterReference;
|
$this->inviterReference = $inviterReference;
|
||||||
$this->inviteeReference = $inviteeReference;
|
$this->inviteeReference = $inviteeReference;
|
||||||
}
|
}
|
||||||
@@ -43,14 +38,6 @@ class CompanyConnectionObject implements DataTransferObject
|
|||||||
return $this->invitee;
|
return $this->invitee;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return CompanyModule
|
|
||||||
*/
|
|
||||||
public function getInviter(): CompanyModule
|
|
||||||
{
|
|
||||||
return $this->inviter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ class CreatesCompanyConnection extends AbstractUpdateRecord
|
|||||||
public function execute(CompanyConnectionObject $object)
|
public function execute(CompanyConnectionObject $object)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$companyModule = $this->fetchesCompany->execute(['id', 1])->companyModules()->first();
|
||||||
|
|
||||||
$connection = new CompanyConnection();
|
$connection = new CompanyConnection();
|
||||||
$connection->inviter_id = $object->getInviter()->id;
|
$connection->inviter_id = $companyModule->id;
|
||||||
$connection->invitee_id = $object->getInvitee()->id;
|
$connection->invitee_id = $object->getInvitee()->id;
|
||||||
$connection->inviter_reference = $object->getInviterReference();
|
$connection->inviter_reference = $object->getInviterReference();
|
||||||
$connection->invitee_reference = $object->getInviteeReference();
|
$connection->invitee_reference = $object->getInviteeReference();
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Delivery\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Orders\Services\CancelsOrder;
|
|
||||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
|
||||||
use App\Http\Resources\DeliveryOrderResource;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CancelDeliveryOrderLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'title' => 'Cancelled Order',
|
|
||||||
'message' => 'You have successfully cancelled an order'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var CancelsOrder */
|
|
||||||
private $cancelsOrder;
|
|
||||||
|
|
||||||
/** @var FetchesOrder */
|
|
||||||
private $fetchesOrder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CancelDeliveryOrderLogic constructor.
|
|
||||||
* @param CancelsOrder $cancelsOrder
|
|
||||||
* @param FetchesOrder $fetchesOrder
|
|
||||||
*/
|
|
||||||
public function __construct(CancelsOrder $cancelsOrder, FetchesOrder $fetchesOrder)
|
|
||||||
{
|
|
||||||
$this->cancelsOrder = $cancelsOrder;
|
|
||||||
$this->fetchesOrder = $fetchesOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function logic(Request $request): JsonResponse
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var Order $order */
|
|
||||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
|
||||||
|
|
||||||
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Delivery\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Services\GeneratesInitials;
|
|
||||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
|
||||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
|
||||||
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
|
||||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
|
||||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
|
||||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
|
||||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
|
||||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
|
||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|
||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
|
||||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
|
||||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
||||||
|
|
||||||
use App\Models\Company;
|
|
||||||
use App\Models\CompanyModule;
|
|
||||||
use App\Models\User;
|
|
||||||
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\App;
|
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CreateDeliveryCustomerLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'title' => 'Created User',
|
|
||||||
'message' => 'You have successfully created a new User'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var CreateUserProcessor */
|
|
||||||
private $createUserProcessor;
|
|
||||||
|
|
||||||
/** @var CreateCompanyProcessor */
|
|
||||||
private $createCompanyProcessor;
|
|
||||||
|
|
||||||
/** @var CreateCompanyModuleProcessor */
|
|
||||||
private $createCompanyModuleProcessor;
|
|
||||||
|
|
||||||
/** @var CreateContactProcessor */
|
|
||||||
private $createContactProcessor;
|
|
||||||
|
|
||||||
/** @var CreatesCompanyConnection */
|
|
||||||
private $createsCompanyConnection;
|
|
||||||
|
|
||||||
/** @var ApprovesCompanyConnection */
|
|
||||||
private $approvesCompanyConnection;
|
|
||||||
|
|
||||||
/** @var AssignEmployeeProcessor */
|
|
||||||
private $assignEmployeeProcessor;
|
|
||||||
|
|
||||||
/** @var UploadIdentityDocumentProcessor */
|
|
||||||
private $uploadIdentityDocumentProcessor;
|
|
||||||
|
|
||||||
/** @var AuthenticationProcessor */
|
|
||||||
private $authenticationProcessor;
|
|
||||||
|
|
||||||
/** @var GenerateEmailVerificationAttemptProcessor */
|
|
||||||
private $generateEmailVerificationAttemptProcessor;
|
|
||||||
|
|
||||||
/** @var FetchesCompanyModule */
|
|
||||||
private $fetchesCompanyModule;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreateDeliveryCustomerLogic constructor.
|
|
||||||
* @param CreateUserProcessor $createUserProcessor
|
|
||||||
* @param CreateCompanyProcessor $createCompanyProcessor
|
|
||||||
* @param CreateCompanyModuleProcessor $createCompanyModuleProcessor
|
|
||||||
* @param CreateContactProcessor $createContactProcessor
|
|
||||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
|
||||||
* @param ApprovesCompanyConnection $approvesCompanyConnection
|
|
||||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
|
||||||
* @param UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor
|
|
||||||
* @param AuthenticationProcessor $authenticationProcessor
|
|
||||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
|
||||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
|
||||||
*/
|
|
||||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule)
|
|
||||||
{
|
|
||||||
$this->createUserProcessor = $createUserProcessor;
|
|
||||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
|
||||||
$this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
|
|
||||||
$this->createContactProcessor = $createContactProcessor;
|
|
||||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
|
||||||
$this->approvesCompanyConnection = $approvesCompanyConnection;
|
|
||||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
|
||||||
$this->uploadIdentityDocumentProcessor = $uploadIdentityDocumentProcessor;
|
|
||||||
$this->authenticationProcessor = $authenticationProcessor;
|
|
||||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
|
||||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
||||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
||||||
*/
|
|
||||||
public function logic(Request $request): JsonResponse
|
|
||||||
{
|
|
||||||
/** @var User $user */
|
|
||||||
$user = $this->createUserProcessor->execute($request, RoleTypes::USER, !App::environment(['production']) ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION);
|
|
||||||
|
|
||||||
/** @var Company $company */
|
|
||||||
$company = $this->createCompanyProcessor->execute($request->input('name'), CompanyType::PERSONAL_BUSINESS, ApprovalStatus::PENDING_SUBMISSION);
|
|
||||||
|
|
||||||
$contactObject = new ContactObject($request->input('name'), $request->input('phone'), $request->input('contact_email'), $request->input('wechat_id'));
|
|
||||||
|
|
||||||
$this->createContactProcessor->execute($contactObject, $company);
|
|
||||||
|
|
||||||
/** @var CompanyModule $companyModule */
|
|
||||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::ONLINE_SELLER);
|
|
||||||
|
|
||||||
$inviter = $this->fetchesCompanyModule->execute(['reference'=>'HWT']);
|
|
||||||
|
|
||||||
$connectionObject = new CompanyConnectionObject($companyModule, $inviter, mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate(), 'HWT');
|
|
||||||
|
|
||||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
|
||||||
|
|
||||||
$this->approvesCompanyConnection->execute($connection);
|
|
||||||
|
|
||||||
$Object = new EmploymentObject($companyModule, $user);
|
|
||||||
|
|
||||||
$this->assignEmployeeProcessor->execute($Object);
|
|
||||||
|
|
||||||
return $this->response($this->authenticationProcessor->execute($request));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Delivery\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
|
||||||
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\Contacts\DataTransferObjects\ContactObject;
|
|
||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
|
||||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
|
||||||
use App\Classes\Modules\Orders\Services\CreatesOrder;
|
|
||||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
|
||||||
use App\Classes\Modules\Orders\Standards\Rules\CanCreateOrder;
|
|
||||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
|
||||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
|
||||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingList;
|
|
||||||
use App\Classes\Modules\PackingLists\Services\Packages\CreatesPackage;
|
|
||||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
|
||||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderType;
|
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
|
||||||
use App\Http\Resources\DeliveryOrderResource;
|
|
||||||
use App\Models\Address;
|
|
||||||
use App\Models\CompanyModule;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CreateDeliveryOrderLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'title' => 'Created Order',
|
|
||||||
'message' => 'You have successfully created a new Order'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var FetchesCompany */
|
|
||||||
private $fetchesCompany;
|
|
||||||
|
|
||||||
/** @var fetchesAddress */
|
|
||||||
private $fetchesAddress;
|
|
||||||
|
|
||||||
/** @var CanCreateOrder */
|
|
||||||
private $canCreateOrder;
|
|
||||||
|
|
||||||
/** @var CreatesOrder */
|
|
||||||
private $createsOrder;
|
|
||||||
|
|
||||||
/** @var CreatesAddress */
|
|
||||||
private $createAddress;
|
|
||||||
|
|
||||||
/** @var CreateContactProcessor */
|
|
||||||
private $createContactProcessor;
|
|
||||||
|
|
||||||
/** @var CreateRemarkProcessor */
|
|
||||||
private $createRemarkProcessor;
|
|
||||||
|
|
||||||
/** @var GeneratesOrderNumber */
|
|
||||||
private $generatesOrderNumber;
|
|
||||||
|
|
||||||
/** @var CreatesPackingList */
|
|
||||||
private $createsPackingList;
|
|
||||||
|
|
||||||
/** @var CreatesPackage */
|
|
||||||
private $createsPackage;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreateDeliveryOrderLogic constructor.
|
|
||||||
* @param FetchesCompany $fetchesCompany
|
|
||||||
* @param FetchesAddress $fetchesAddress
|
|
||||||
* @param CanCreateOrder $canCreateOrder
|
|
||||||
* @param CreatesOrder $createsOrder
|
|
||||||
* @param CreatesAddress $createAddress
|
|
||||||
* @param CreateContactProcessor $createContactProcessor
|
|
||||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
|
||||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
|
||||||
* @param CreatesPackingList $createsPackingList
|
|
||||||
* @param CreatesPackage $createPackage
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreatesAddress $createAddress, CreateContactProcessor $createContactProcessor, CreateRemarkProcessor $createRemarkProcessor, GeneratesOrderNumber $generatesOrderNumber, CreatesPackingList $createsPackingList, CreatesPackage $createsPackage)
|
|
||||||
{
|
|
||||||
$this->fetchesCompany = $fetchesCompany;
|
|
||||||
$this->fetchesAddress = $fetchesAddress;
|
|
||||||
$this->canCreateOrder = $canCreateOrder;
|
|
||||||
$this->createsOrder = $createsOrder;
|
|
||||||
$this->createAddress = $createAddress;
|
|
||||||
$this->createContactProcessor = $createContactProcessor;
|
|
||||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
|
||||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
|
||||||
$this->createsPackingList = $createsPackingList;
|
|
||||||
$this->createsPackage = $createsPackage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
{
|
|
||||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
|
||||||
|
|
||||||
$senderAddress = $this->fetchesAddress->execute(['id' => $request->input('sender_address_id')]);
|
|
||||||
$deliveryAddress = $this->fetchesAddress->execute(['id' => $request->input('delivery_address_id')]);
|
|
||||||
|
|
||||||
/** @var CompanyModule $companyModule */
|
|
||||||
$companyModule = $company->companyModules()->where('type', BusinessType::ONLINE_SELLER)->first();
|
|
||||||
|
|
||||||
$orderObject = new OrderObject($this->generatesOrderNumber->execute('168M', 7), OrderType::LAST_MILE_DELIVERY, ApprovalStatus::APPROVED);
|
|
||||||
|
|
||||||
$this->canCreateOrder->passes($orderObject);
|
|
||||||
|
|
||||||
/** @var Order $order */
|
|
||||||
$order = $this->createsOrder->execute($companyModule, $orderObject);
|
|
||||||
|
|
||||||
$senderAddressObject = new AddressObject($senderAddress->street_one, $senderAddress->street_two, $senderAddress->country_id, $senderAddress->state_id, $senderAddress->district_id, $senderAddress->postcode, $senderAddress->type, ApprovalStatus::APPROVED, $senderAddress->reference);
|
|
||||||
$deliveryAddressObject = new AddressObject($deliveryAddress->street_one, $deliveryAddress->street_two, $deliveryAddress->country_id, $deliveryAddress->state_id, $deliveryAddress->district_id, $deliveryAddress->postcode, $deliveryAddress->type, ApprovalStatus::APPROVED, $deliveryAddress->reference);
|
|
||||||
|
|
||||||
/** @var Address $orderSenderAddress */
|
|
||||||
$orderSenderAddress = $this->createAddress->execute($order, $senderAddressObject);
|
|
||||||
/** @var Address $orderDeliveryAddress */
|
|
||||||
$orderDeliveryAddress = $this->createAddress->execute($order, $deliveryAddressObject);
|
|
||||||
|
|
||||||
$senderContact = $senderAddress->contacts()->first();
|
|
||||||
$deliveryContact = $deliveryAddress->contacts()->first();
|
|
||||||
|
|
||||||
$contactObject = new ContactObject($senderContact->reference, $senderContact->phone, '','');
|
|
||||||
$this->createContactProcessor->execute($contactObject, $orderSenderAddress);
|
|
||||||
|
|
||||||
$contactObject = new ContactObject($deliveryContact->reference, $deliveryContact->phone, '','');
|
|
||||||
$this->createContactProcessor->execute($contactObject, $orderDeliveryAddress);
|
|
||||||
|
|
||||||
$senderRemark = $senderAddress->remarks()->first();
|
|
||||||
$deliveryRemark = $deliveryAddress->remarks()->first();
|
|
||||||
|
|
||||||
if ($senderRemark){
|
|
||||||
$remarkObject = new RemarkObject($senderRemark->content, Auth()->user()->id);
|
|
||||||
|
|
||||||
if($remarkObject->getContent()){
|
|
||||||
$this->createRemarkProcessor->execute($orderSenderAddress, $remarkObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($deliveryRemark){
|
|
||||||
$remarkObject = new RemarkObject($deliveryRemark->content, Auth()->user()->id);
|
|
||||||
|
|
||||||
if($remarkObject->getContent()){
|
|
||||||
$this->createRemarkProcessor->execute($orderDeliveryAddress, $remarkObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$packingListObject = new PackingListObject($order->reference, $companyModule->id, PackingListType::DELIVERY_PACKING_LIST, ApprovalStatus::PENDING_VERIFICATION);
|
|
||||||
|
|
||||||
/** @var PackingList $packingList */
|
|
||||||
$packingList = $this->createsPackingList->execute($packingListObject, $order);
|
|
||||||
|
|
||||||
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
|
||||||
$this->createsPackage->execute($packageObject, $packingList);
|
|
||||||
|
|
||||||
return $this->resourceResponse(new DeliveryOrderResource($order));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Delivery\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Orders\Services\ListsOrders;
|
|
||||||
use App\Classes\Modules\Orders\Standards\Rules\CanListOrders;
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderType;
|
|
||||||
use App\Http\Resources\DeliveryOrderResource;
|
|
||||||
use App\Http\Resources\OrderResource;
|
|
||||||
use ErrorException;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class ListOrdersLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Retrieved Orders',
|
|
||||||
'message' => 'You have successfully retrieved a list of Orders'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var CanListOrders */
|
|
||||||
private $canListOrders;
|
|
||||||
|
|
||||||
/** @var ListsOrders */
|
|
||||||
private $listsOrders;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ListOrdersLogic constructor.
|
|
||||||
* @param CanListOrders $canListOrders
|
|
||||||
* @param ListsOrders $listsOrders
|
|
||||||
*/
|
|
||||||
public function __construct(CanListOrders $canListOrders, ListsOrders $listsOrders)
|
|
||||||
{
|
|
||||||
$this->canListOrders = $canListOrders;
|
|
||||||
$this->listsOrders = $listsOrders;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
$this->canListOrders->passes();
|
|
||||||
|
|
||||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
|
||||||
|
|
||||||
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\Services;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
||||||
|
|
||||||
class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromCollection
|
|
||||||
{
|
|
||||||
|
|
||||||
use Exportable;
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'ORDER NUMBER',
|
|
||||||
'Marking',
|
|
||||||
'Warehouse',
|
|
||||||
'Cbm',
|
|
||||||
'Description',
|
|
||||||
'quantity',
|
|
||||||
'Received Date',
|
|
||||||
'Remarks'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Support\Collection|mixed
|
|
||||||
*/
|
|
||||||
public function collection()
|
|
||||||
{
|
|
||||||
$returnArray = collect();
|
|
||||||
|
|
||||||
$packingLists = PackingList::where('type', '=', 1)->where('status', '=', 2)->get();
|
|
||||||
$exceptionUsers = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]);
|
|
||||||
|
|
||||||
foreach($packingLists as $packingList){
|
|
||||||
$packages = !$packingList->packingLists()->exists() || $exceptionUsers ? $packingList->packages : $packingList->packingLists->first()->packages;
|
|
||||||
foreach ($packages as $package) {
|
|
||||||
$returnArray->push($package);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $returnArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ReturnArray $returnArray
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function map($package): array
|
|
||||||
{
|
|
||||||
$packingList = $package->packingList;
|
|
||||||
$order = $packingList->owner;
|
|
||||||
|
|
||||||
$connection = $order->companyModule()->first()->inviters()->withPivot('invitee_reference')->first();
|
|
||||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
|
||||||
|
|
||||||
$warehouse = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee;
|
|
||||||
|
|
||||||
$cbm = (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
|
||||||
|
|
||||||
$arrival_date = $packingList->transports()->first()->drop_date->format('d-m-Y');
|
|
||||||
|
|
||||||
return [
|
|
||||||
$packingList->owner->reference,
|
|
||||||
$marking,
|
|
||||||
$warehouse->reference,
|
|
||||||
$cbm,
|
|
||||||
$package->description,
|
|
||||||
$package->quantity,
|
|
||||||
$arrival_date,
|
|
||||||
''
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\Services;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderType;
|
|
||||||
use App\Classes\ValueObjects\Constants\PackageType;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
||||||
|
|
||||||
class ExportsDeliveryOrders implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, WithTitle
|
|
||||||
{
|
|
||||||
use Exportable;
|
|
||||||
|
|
||||||
private $request;
|
|
||||||
|
|
||||||
public function __construct(Request $request)
|
|
||||||
{
|
|
||||||
$this->request = $request;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'Types_Of_Services',
|
|
||||||
'Service_Type',
|
|
||||||
'Sender_Name',
|
|
||||||
'Sender_Company_Name',
|
|
||||||
'Sender_Building_Unit',
|
|
||||||
'Sender_Address',
|
|
||||||
'Sender_Address_2',
|
|
||||||
'Sender_Postal_Code',
|
|
||||||
'Sender_Phone_Number',
|
|
||||||
'Delivery_Name',
|
|
||||||
'Delivery Company Name',
|
|
||||||
'Delivery_Building_Unit',
|
|
||||||
'Delivery_Address',
|
|
||||||
'Delivery_Address_2',
|
|
||||||
'Delivery_Postal_Code',
|
|
||||||
'Delivery_Phone_Number',
|
|
||||||
'Shipment_Type',
|
|
||||||
'Mode',
|
|
||||||
'Pickup_Address_Type',
|
|
||||||
'Reference_Number',
|
|
||||||
'Quantity',
|
|
||||||
'Weight',
|
|
||||||
'Length',
|
|
||||||
'Width',
|
|
||||||
'Height',
|
|
||||||
'COD_Amount',
|
|
||||||
'DO_Numbers'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Support\Collection|mixed
|
|
||||||
*/
|
|
||||||
public function query()
|
|
||||||
{
|
|
||||||
$selectedIds = array_map(function($value){
|
|
||||||
return ['id' => $value];
|
|
||||||
}, json_decode($this->request->input('ids')));
|
|
||||||
|
|
||||||
return Order::where('type', OrderType::LAST_MILE_DELIVERY)->whereIn('id', $selectedIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function title(): string
|
|
||||||
{
|
|
||||||
return 'bulk-shipment';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Order $order
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function map($order): array
|
|
||||||
{
|
|
||||||
$senderAddress = $order->addresses()->where('type', AddressType::PICK_UP)->first();
|
|
||||||
$deliveryAddress = $order->addresses()->where('type', AddressType::DELIVERY)->first();
|
|
||||||
$package = $order->packingLists()->first()->packages()->first();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'Domestic Shipment',
|
|
||||||
'ST00000020',
|
|
||||||
$senderAddress->contacts()->first()->reference,
|
|
||||||
$senderAddress->reference ? $senderAddress->reference : $order->companyModule->name,
|
|
||||||
$senderAddress->street_one,
|
|
||||||
$senderAddress->street_two.' '.$senderAddress->district->name.' '.$senderAddress->postcode.' '.$senderAddress->state->name.' '.$senderAddress->country->name,
|
|
||||||
'',
|
|
||||||
$senderAddress->postcode,
|
|
||||||
$senderAddress->contacts()->first()->phone,
|
|
||||||
$deliveryAddress->contacts()->first()->reference,
|
|
||||||
$deliveryAddress->reference,
|
|
||||||
$deliveryAddress->street_one,
|
|
||||||
$deliveryAddress->street_two.' '.$deliveryAddress->district->name.' '.$deliveryAddress->postcode.' '.$deliveryAddress->state->name.' '.$deliveryAddress->country->name,
|
|
||||||
'',
|
|
||||||
$deliveryAddress->postcode,
|
|
||||||
$deliveryAddress->contacts()->first()->phone,
|
|
||||||
$package->type === PackageType::CARTON ? 'Package' : ($package->type === PackageType::PALLET ? 'Pallet' : 'Documents'),
|
|
||||||
'Pick Up',
|
|
||||||
'Default',
|
|
||||||
$order->reference,
|
|
||||||
$package->quantity,
|
|
||||||
$package->weight * $package->quantity,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
'',
|
|
||||||
''
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\Services;
|
|
||||||
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
||||||
|
|
||||||
class ExportsDeliveryValidValues implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, WithTitle, FromCollection
|
|
||||||
{
|
|
||||||
use Exportable;
|
|
||||||
|
|
||||||
private $request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExportsDeliveryValidValues constructor.
|
|
||||||
* @param Request $request
|
|
||||||
*/
|
|
||||||
public function __construct(Request $request)
|
|
||||||
{
|
|
||||||
$this->request = $request;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'Types_Of_Services',
|
|
||||||
'Service_Type',
|
|
||||||
'Mode',
|
|
||||||
'Flag',
|
|
||||||
'Pickup Address'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Support\Collection|mixed
|
|
||||||
*/
|
|
||||||
public function collection()
|
|
||||||
{
|
|
||||||
$returnArray = collect();
|
|
||||||
|
|
||||||
$returnArray->push(['Domestic Shipment', 'Package', 'Pick Up', 'Yes', 'Default']);
|
|
||||||
$returnArray->push(['', 'Documents', 'Lodge In / Walk In', 'No', 'Sender']);
|
|
||||||
$returnArray->push(['', 'Pallet', '', '', '']);
|
|
||||||
|
|
||||||
return $returnArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function title(): string
|
|
||||||
{
|
|
||||||
return 'valid-values';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ReturnArray $returnArray
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function map($returnArray): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
$returnArray[0],
|
|
||||||
$returnArray[1],
|
|
||||||
$returnArray[2],
|
|
||||||
$returnArray[3],
|
|
||||||
$returnArray[4],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\Services;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsDeliveryOrders;
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsDeliveryValidValues;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
|
||||||
|
|
||||||
class ExportsMultipleDeliveryOrders implements WithMultipleSheets
|
|
||||||
{
|
|
||||||
use Exportable;
|
|
||||||
|
|
||||||
protected $request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExportsMultipleDeliveryOrders constructor.
|
|
||||||
* @param Request $request
|
|
||||||
*/
|
|
||||||
public function __construct(Request $request)
|
|
||||||
{
|
|
||||||
$this->request = $request;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function sheets(): array
|
|
||||||
{
|
|
||||||
$sheets = [];
|
|
||||||
$sheets[] = new ExportsDeliveryOrders($this->request);
|
|
||||||
$sheets[] = new ExportsDeliveryValidValues($this->request);
|
|
||||||
|
|
||||||
return $sheets;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\Services;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class ExportsOnHoldPackingList implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
|
||||||
{
|
|
||||||
|
|
||||||
use Exportable;
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'Container Ref.',
|
|
||||||
'ETA',
|
|
||||||
'Unstuffing',
|
|
||||||
'Marking',
|
|
||||||
'Order Number'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Support\Collection|mixed
|
|
||||||
*/
|
|
||||||
public function query()
|
|
||||||
{
|
|
||||||
return PackingList::where('type', '=', 2)->whereIn('status', [4, 5])->whereHas('containers');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param PackingList $packingList
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function map($packingList): array
|
|
||||||
{
|
|
||||||
$container = $packingList->containers()->first();
|
|
||||||
$ContainerTransport = $container->transports()->first();
|
|
||||||
$order = $packingList->owner;
|
|
||||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
|
||||||
|
|
||||||
return [
|
|
||||||
$container->reference,
|
|
||||||
$ContainerTransport ? $ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta : 'n/a',
|
|
||||||
$ContainerTransport ? $ContainerTransport->drop_date : 'n/a',
|
|
||||||
$marking,
|
|
||||||
$order->reference,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Exports\Services;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class ExportsPendingArrangementDeliveryList implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
|
||||||
{
|
|
||||||
|
|
||||||
use Exportable;
|
|
||||||
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'Container Ref.',
|
|
||||||
'ETA',
|
|
||||||
'Unstuffing',
|
|
||||||
'Marking',
|
|
||||||
'Order Number',
|
|
||||||
'status',
|
|
||||||
'Delay Days / delivery date',
|
|
||||||
'Quantity',
|
|
||||||
'State',
|
|
||||||
'Postcode',
|
|
||||||
'Address',
|
|
||||||
'PIC',
|
|
||||||
'Phone',
|
|
||||||
'Remark'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Support\Collection|mixed
|
|
||||||
*/
|
|
||||||
public function query()
|
|
||||||
{
|
|
||||||
return PackingList::where('type', '=', 2)->whereHas('containers', function ($query){
|
|
||||||
$query->where('containers.status', ApprovalStatus::COMPLETED);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param PackingList $packingList
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function map($packingList): array
|
|
||||||
{
|
|
||||||
$container = $packingList->containers()->first();
|
|
||||||
$ContainerTransport = $container->transports()->first();
|
|
||||||
$order = $packingList->owner;
|
|
||||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
|
||||||
$address = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
|
||||||
$contacts = $address->contacts->first() ? $address->contacts->first(): '';
|
|
||||||
$originalPackingList = $packingList->owner instanceof PackingList ? $packingList->owner : $packingList;
|
|
||||||
$transport = $originalPackingList->containers()->first()->transports()->first();
|
|
||||||
$deliveryTransport = $originalPackingList->transports()->first();
|
|
||||||
|
|
||||||
return [
|
|
||||||
$container->reference,
|
|
||||||
$ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta,
|
|
||||||
$ContainerTransport->drop_date,
|
|
||||||
$marking,
|
|
||||||
$order->reference,
|
|
||||||
$deliveryTransport ? (Carbon::parse($deliveryTransport->schedules()->first()->eta) < Carbon::now() ? 'Delivered' : 'Pending Delivery') : 'Pending Arrangement',
|
|
||||||
$deliveryTransport ? $deliveryTransport->schedules()->first()->eta : ($transport ? Carbon::now()->diffInDays($transport->drop_date, false) . ' Days' : ''),
|
|
||||||
$packingList->packages()->sum('quantity'),
|
|
||||||
$address->state->name,
|
|
||||||
$address->postcode,
|
|
||||||
$address->street_one.', '.$address->street_two.' '.$address->district->name.' '.$address->postcode.' '.$address->state->name.' '.$address->country->name,
|
|
||||||
$address->remarks->first() ? $address->remarks->first()->content: '',
|
|
||||||
$contacts ? $contacts ->reference : '',
|
|
||||||
$contacts ? $contacts ->phone : '',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?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));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -67,7 +67,7 @@ class CreateOrderLogic extends AbstractControllerLogic
|
|||||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||||
|
|
||||||
if(!in_array($company->companyModules()->importers()->first()->id, WarehouseReferences::YD_EXEMPT_LIST)){
|
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_2 : WarehouseReferences::YD_YIWU]);
|
$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])) {
|
if($originWarehouse->reference === WarehouseReferences::YD_YIWU && in_array($address->state_id, [5, 13, 14])) {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ namespace App\Classes\Modules\Orders\ControllersLogic;
|
|||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Orders\Services\ListsOrders;
|
use App\Classes\Modules\Orders\Services\ListsOrders;
|
||||||
use App\Classes\Modules\Orders\Standards\Rules\CanListOrders;
|
use App\Classes\Modules\Orders\Standards\Rules\CanListOrders;
|
||||||
use App\Classes\ValueObjects\Constants\OrderType;
|
|
||||||
use App\Http\Resources\OrderResource;
|
use App\Http\Resources\OrderResource;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -45,7 +44,7 @@ class ListOrdersLogic extends AbstractControllerLogic
|
|||||||
{
|
{
|
||||||
$this->canListOrders->passes();
|
$this->canListOrders->passes();
|
||||||
|
|
||||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::SHARED_CONTAINER, OrderType::DEDICATED_CONTAINER]]));
|
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true]));
|
||||||
|
|
||||||
return $this->collectionResponse(OrderResource::collection($query));
|
return $this->collectionResponse(OrderResource::collection($query));
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|||||||
class OrderObject implements DataTransferObject
|
class OrderObject implements DataTransferObject
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var string */
|
/** @var int */
|
||||||
private $reference;
|
private $reference;
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
@@ -20,11 +20,11 @@ class OrderObject implements DataTransferObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* OrderObject constructor.
|
* OrderObject constructor.
|
||||||
* @param string $reference
|
* @param int $reference
|
||||||
* @param int $type
|
* @param int $type
|
||||||
* @param int|null $status
|
* @param int|null $status
|
||||||
*/
|
*/
|
||||||
public function __construct(string $reference, int $type, ?int $status)
|
public function __construct(int $reference, int $type, ?int $status = ApprovalStatus::PENDING_VERIFICATION)
|
||||||
{
|
{
|
||||||
$this->reference = $reference;
|
$this->reference = $reference;
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
@@ -32,9 +32,9 @@ class OrderObject implements DataTransferObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getReference(): string
|
public function getReference(): int
|
||||||
{
|
{
|
||||||
return $this->reference;
|
return $this->reference;
|
||||||
}
|
}
|
||||||
@@ -48,13 +48,12 @@ class OrderObject implements DataTransferObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int|null
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getStatus(): ?int
|
public function getStatus(): int
|
||||||
{
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Classes\Modules\Orders\Standards\Rules\CanApproveChangeOrderAddress;
|
|||||||
use App\Classes\Modules\Orders\Services\UpdatesOrdersAddress;
|
use App\Classes\Modules\Orders\Services\UpdatesOrdersAddress;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class ApproveChangeOrderAddressProcessor
|
class ApproveChangeOrderAddressProcessor
|
||||||
@@ -66,11 +65,7 @@ class ApproveChangeOrderAddressProcessor
|
|||||||
$address->owner->addresses()->update(['status' => ApprovalStatus::EXPIRED]);
|
$address->owner->addresses()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||||
|
|
||||||
$appointee = $address->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
$appointee = $address->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||||
if($appointee === 2) {
|
$appointee === 2 ? $this->updateDoFromVTPortalProcessor->execute($address) : $this->updateDoFromYDPortalProcessor->execute($address);
|
||||||
foreach($address->owner->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST) as $packingList){
|
|
||||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class CreateOrderProcessor
|
|||||||
/** @var Order $order */
|
/** @var Order $order */
|
||||||
$order = $this->createsOrder->execute($importer, $orderObject);
|
$order = $this->createsOrder->execute($importer, $orderObject);
|
||||||
|
|
||||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, $address->type, ApprovalStatus::APPROVED, $address->reference);
|
$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 */
|
/** @var Address $order_address */
|
||||||
$order_address = $this->createAddress->execute($order, $addressObject);
|
$order_address = $this->createAddress->execute($order, $addressObject);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
|||||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||||
use App\Classes\Modules\Addresses\Services\DeletesAddress;
|
use App\Classes\Modules\Addresses\Services\DeletesAddress;
|
||||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||||
@@ -77,7 +76,7 @@ class RequestChangeOrderAddressProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
$address = $this->fetchesAddress->execute(['id' => $request->get('address_id')]);
|
$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, AddressType::DELIVERY, ApprovalStatus::PENDING_VERIFICATION, $address->reference);
|
$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);
|
$order_address = $this->createsAddress->execute($order, $addressObject);
|
||||||
|
|
||||||
$contact = $address->contacts()->first();
|
$contact = $address->contacts()->first();
|
||||||
|
|||||||
@@ -6,9 +6,23 @@ use App\Classes\Exceptions\InternalServerErrorException;
|
|||||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
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\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\PackingList;
|
||||||
|
use App\Models\Transport;
|
||||||
|
use Carbon\Carbon;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class UpdateDoFromVTPortalProcessor
|
class UpdateDoFromVTPortalProcessor
|
||||||
{
|
{
|
||||||
/** @var FetchesDataFromVTPortal */
|
/** @var FetchesDataFromVTPortal */
|
||||||
@@ -29,20 +43,19 @@ class UpdateDoFromVTPortalProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PackingList $packing_list
|
* @param $address
|
||||||
* @return array
|
* @return array
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
* @throws InternalServerErrorException
|
|
||||||
*/
|
*/
|
||||||
public function execute(PackingList $packing_list) {
|
public function execute($address) {
|
||||||
|
|
||||||
if(!app()->environment(['production'])){
|
if(!app()->environment(['production'])){
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$address= $packing_list->owner->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
$order = $address->owner()->orderBy('id', 'desc')->first();
|
||||||
$order = $packing_list->owner;
|
$packing_list = $order->packingLists()->orderBy('id', 'desc')->first();
|
||||||
|
|
||||||
if ($packing_list) {
|
if ($packing_list) {
|
||||||
$contact = $address->contacts()->first();
|
$contact = $address->contacts()->first();
|
||||||
@@ -54,7 +67,7 @@ class UpdateDoFromVTPortalProcessor
|
|||||||
|
|
||||||
$status = 'On Hold';
|
$status = 'On Hold';
|
||||||
|
|
||||||
if (in_array($packing_list->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
if (in_array($packing_list->status, [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||||
$status = 'Release';
|
$status = 'Release';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +77,6 @@ class UpdateDoFromVTPortalProcessor
|
|||||||
|
|
||||||
if ($vt_do) {
|
if ($vt_do) {
|
||||||
foreach ($vt_do->Rows as $key => $row) {
|
foreach ($vt_do->Rows as $key => $row) {
|
||||||
if($row[4] !== $packing_list->containers()->first()->reference) continue;
|
|
||||||
$vt_do_update = $this->fetchesDataFRomVTPortal->clientRequest(
|
$vt_do_update = $this->fetchesDataFRomVTPortal->clientRequest(
|
||||||
'http://portal.vtnation.com.my/Services/DataControllerService.asmx/Execute',
|
'http://portal.vtnation.com.my/Services/DataControllerService.asmx/Execute',
|
||||||
'POST',
|
'POST',
|
||||||
@@ -129,7 +141,7 @@ class UpdateDoFromVTPortalProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Exception $exception){
|
} catch (\Exception $exception){
|
||||||
throw new InternalServerErrorException('failed to approve address due to an error related to VT portal: '.$exception->getMessage());
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
|||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||||
use App\Models\PackingList;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class UpdateDoFromYDPortalProcessor
|
class UpdateDoFromYDPortalProcessor
|
||||||
@@ -31,34 +30,36 @@ class UpdateDoFromYDPortalProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PackingList $packingList
|
* @param $address
|
||||||
* @return void
|
* @return void
|
||||||
* @throws InternalServerErrorException
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function execute(PackingList $packingList) {
|
public function execute($address) {
|
||||||
if(!app()->environment(['production'])){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$address = $packingList->owner->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
$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();
|
||||||
|
|
||||||
if (!in_array($packingList->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$contact = $address->contacts()->first();
|
foreach ($packing_lists as $key => $row) {
|
||||||
$remark = $address->remarks()->first();
|
if ($row->status === ApprovalStatus::SUSPENDED) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$phone = $contact ? $contact->phone : null;
|
$contact = $address->contacts()->first();
|
||||||
$reference = $contact ? $contact->reference : null;
|
$remark = $address->remarks()->first();
|
||||||
$remark = $remark ? $remark->content : 'URGENT!!! PLEASE CALL BEFORE ONE DAY DELIVERY.';
|
|
||||||
|
|
||||||
$this->fetchesDataFRomYDPortal->clientRequest(
|
$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',
|
'http://www.yd-wl.com/api/UpdateOrderAddress.ashx',
|
||||||
'POST',
|
'POST',
|
||||||
[
|
[
|
||||||
'expressno' => $packingList->reference,
|
'expressno' => $row->reference,
|
||||||
'customers_name' => $reference,
|
'customers_name' => $reference,
|
||||||
'cellphone' => $phone,
|
'cellphone' => $phone,
|
||||||
'postcode' => $address->postcode,
|
'postcode' => $address->postcode,
|
||||||
@@ -67,6 +68,8 @@ class UpdateDoFromYDPortalProcessor
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} catch (\Exception $exception){
|
} catch (\Exception $exception){
|
||||||
throw new InternalServerErrorException('failed to approve address due to an error related to YD portal');
|
throw new InternalServerErrorException('failed to approve address due to an error related to YD portal');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class ChecksIfOrderNumberExists
|
|||||||
$this->repository = $repository;
|
$this->repository = $repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(string $orderNumber): bool {
|
public function execute(int $orderNumber): bool {
|
||||||
return $this->repository->where('reference', $orderNumber)->exists();
|
return $this->repository->where('reference', $orderNumber)->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,11 @@ class GeneratesOrderNumber
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param null|string $prefix
|
* @return int
|
||||||
* @param int|null $length
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function execute(?string $prefix = '', ?int $length = 9): string {
|
public function execute(): int {
|
||||||
|
|
||||||
$reference = $prefix.rand((int)('1'.str_repeat(0, $length - 2).'1'), (int) str_repeat(9, $length));
|
$reference = rand(100000001, 999999999);
|
||||||
return !$this->checkIfOrderNumberExists->execute($reference) ? $reference : self::execute();
|
return !$this->checkIfOrderNumberExists->execute($reference) ? $reference : self::execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||||
use App\Http\Resources\PackingListResource;
|
use App\Http\Resources\PackingListResource;
|
||||||
use App\Models\PackingList;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -71,16 +70,16 @@ class UpdatePackingListStatusLogic extends AbstractControllerLogic
|
|||||||
{
|
{
|
||||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
$packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
/** @var PackingList $packingList */
|
$packing_list = $this->updatesPackingListStatus->execute($packingList, $request->route('status'));
|
||||||
$packingList = $this->updatesPackingListStatus->execute($packingList, $request->route('status'));
|
$address = $packing_list->owner()->first()->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||||
|
|
||||||
|
|
||||||
// $appointee = $address->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
// $appointee = $address->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||||
|
|
||||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
$this->updateDoFromVTPortalProcessor->execute($address);
|
||||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
$this->updateDoFromYDPortalProcessor->execute($address);
|
||||||
|
|
||||||
return $this->resourceResponse(new PackingListResource($packingList));
|
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ namespace App\Classes\Modules\PackingLists\Processors;
|
|||||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||||
use App\Classes\Modules\PackingLists\Services\Packages\CreatesPackage;
|
use App\Classes\Modules\PackingLists\Services\Packages\CreatesPackage;
|
||||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanCreatePackage;
|
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanCreatePackage;
|
||||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\PackingList;
|
use App\Models\PackingList;
|
||||||
|
|
||||||
class CreatePackageProcessor
|
class CreatePackageProcessor
|
||||||
@@ -50,11 +48,6 @@ class CreatePackageProcessor
|
|||||||
|
|
||||||
if($replica) {
|
if($replica) {
|
||||||
$modificationValue = 1;
|
$modificationValue = 1;
|
||||||
|
|
||||||
if($replica->owner->owner instanceof Order){
|
|
||||||
$modificationValue = in_array( $replica->owner->owner->companyModule->id, WarehouseReferences::REPLICA_WHITE_LIST) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$packageObject = new PackageObject($object->getType(), $object->getDescription(), $object->getWidth() + $modificationValue, $object->getHeight() + $modificationValue, $object->getLength() + $modificationValue, $object->getWeight(), $object->getQuantity(), $object->getStatus());
|
$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);
|
$package = $this->createsPackage->execute($packageObject, $replica);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\PackingList;
|
use App\Models\PackingList;
|
||||||
use function PHPUnit\Framework\isInstanceOf;
|
|
||||||
|
|
||||||
class CreatePackingListProcessor
|
class CreatePackingListProcessor
|
||||||
{
|
{
|
||||||
@@ -54,7 +51,6 @@ class CreatePackingListProcessor
|
|||||||
$appointee_id = $packingList->owner_id == 1 ? 2037 : $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
$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;
|
$type = $object->getType() === PackingListType::SHIPPING_PACKING_LIST ? PackingListType::SHIPPING_PACKING_LIST_REPLICA : PackingListType::WAREHOUSE_RECEIVE_LIST_REPLICA;
|
||||||
|
|
||||||
/** create packing list replica */
|
/** create packing list replica */
|
||||||
$object = new PackingListObject($object->getReference().'_01', $appointee_id, $type, ApprovalStatus::PENDING_SUBMISSION);
|
$object = new PackingListObject($object->getReference().'_01', $appointee_id, $type, ApprovalStatus::PENDING_SUBMISSION);
|
||||||
$this->createsPackingList->execute($object, $packingList);
|
$this->createsPackingList->execute($object, $packingList);
|
||||||
|
|||||||
+6
-2
@@ -158,9 +158,13 @@ class FetchLoadedContainersFromVTPortalProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach($containerDetail->Rows as $packingList){
|
foreach($containerDetail->Rows as $packingList){
|
||||||
$marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $packingList[13]));
|
$marking = explode('/', explode('CIEF/', $packingList[13])[1]);
|
||||||
|
|
||||||
$orderNumber = $marking[array_key_last($marking)];
|
if(!array_key_exists(1, $marking)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$orderNumber = $marking[1];
|
||||||
|
|
||||||
if(!$packingList[22]){
|
if(!$packingList[22]){
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
+10
-44
@@ -36,7 +36,6 @@ use App\Models\Transport;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class FetchOrderListsFromYdPortalProcessor
|
class FetchOrderListsFromYdPortalProcessor
|
||||||
{
|
{
|
||||||
@@ -154,6 +153,7 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($orderRequest);
|
||||||
|
|
||||||
foreach($rows->data as $row){
|
foreach($rows->data as $row){
|
||||||
|
|
||||||
$containerReference = null;
|
$containerReference = null;
|
||||||
$loadingDate = null;
|
$loadingDate = null;
|
||||||
$unstuffingDate = null;
|
$unstuffingDate = null;
|
||||||
@@ -168,11 +168,6 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
|
|
||||||
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
$rows = $this->fetchesDataFRomYDPortal->getResponseBody($trackingRequest);
|
||||||
|
|
||||||
if(!$rows){
|
|
||||||
Log::debug($row->expressno);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (array_reverse($rows->data) as $trackingRow) {
|
foreach (array_reverse($rows->data) as $trackingRow) {
|
||||||
if ($trackingRow->tracking === '货物已送达仓库准备入库中') {
|
if ($trackingRow->tracking === '货物已送达仓库准备入库中') {
|
||||||
$receiveDate = Carbon::parse($trackingRow->trackingtime);
|
$receiveDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
@@ -186,43 +181,21 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
$eta = Carbon::parse($tracking[2]);
|
$eta = Carbon::parse($tracking[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rescheduleETD = strpos($trackingRow->remark, '开') || strpos($trackingRow->remark, '到港');
|
if (strpos($trackingRow->tracking, '预计船时间为') !== false) {
|
||||||
$rescheduleETA = strpos($trackingRow->remark, '到港');
|
$tracking = explode('预计船时间为', $trackingRow->tracking);
|
||||||
if (($rescheduleETD !== false || $rescheduleETA !== false) && strpos($trackingRow->tracking, '货物装柜完成。') === false) {
|
$delayDate = Carbon::parse(explode('日', $tracking[1])[0]);
|
||||||
preg_match_all('/([0-9]+.{3})/', $trackingRow->remark, $matches);
|
|
||||||
$dates = collect();
|
|
||||||
|
|
||||||
foreach($matches[0] as $date){
|
|
||||||
try {
|
|
||||||
$dates->push(Carbon::parse(str_replace('.', '/', $date).Carbon::now()->format('Y')));
|
|
||||||
} catch (\Exception $exception) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$rescheduleDate = $dates->sortDesc()->first();
|
|
||||||
if(!$delayDate || $rescheduleDate > $delayDate){
|
|
||||||
/** @var Carbon $delayDate */
|
|
||||||
$delayDate = $rescheduleDate;
|
|
||||||
|
|
||||||
if($rescheduleETA === false && $delayDate) {
|
|
||||||
$delayDate = $delayDate->addDays('5');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($trackingRow->tracking === '已开船') {
|
if (strpos($trackingRow->tracking, '预计开船为') !== false) {
|
||||||
$delayDate = Carbon::parse($trackingRow->trackingtime)->addDays('5');
|
$tracking = explode('预计开船为', $trackingRow->tracking);
|
||||||
|
$delayDate = Carbon::parse(explode('日', $tracking[1])[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
if ($trackingRow->tracking === '货物已进目的港仓库') {
|
||||||
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
$unstuffingDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Str::contains($trackingRow->tracking, ['派送中'])) {
|
if ($trackingRow->tracking === '货物已派送完成') {
|
||||||
$deliveryDate = Carbon::parse($trackingRow->trackingtime);
|
$deliveryDate = Carbon::parse($trackingRow->trackingtime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,13 +288,6 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!count($row->deliverysize)){
|
|
||||||
$measurement = round(((float) $row->volume / (float) $row->goodcount) ** (1/3) * 100, 2);
|
|
||||||
$packageObject = new PackageObject(PackageType::CARTON, $row->goodname, (float) $measurement, (float) $measurement, (float) $measurement, 0, (float) $row->goodcount, ApprovalStatus::APPROVED);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $warehouseReceiveList);
|
|
||||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
|
||||||
}
|
|
||||||
|
|
||||||
$weightCbm = (float) $row->weight / 500;
|
$weightCbm = (float) $row->weight / 500;
|
||||||
$overWeightCbm = $weightCbm - $packingList->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity'));
|
$overWeightCbm = $weightCbm - $packingList->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity'));
|
||||||
|
|
||||||
@@ -378,7 +344,7 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
|
|
||||||
$transport = $container->transports()->first();
|
$transport = $container->transports()->first();
|
||||||
|
|
||||||
if(!$transport->schedules()->whereDate('eta', '>=', $delayDate)->first()) {
|
if(!$transport->schedules()->where('eta', '=', $delayDate)->first()) {
|
||||||
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
||||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
||||||
@@ -407,7 +373,7 @@ class FetchOrderListsFromYdPortalProcessor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($deliveryDate && !$packingList->transports()->exists()){
|
if($deliveryDate && !$packingList->transports){
|
||||||
$packingList->status = ApprovalStatus::COMPLETED;
|
$packingList->status = ApprovalStatus::COMPLETED;
|
||||||
$packingList->save();
|
$packingList->save();
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -134,13 +134,19 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
|||||||
|
|
||||||
foreach ($response->Rows as $parcel){
|
foreach ($response->Rows as $parcel){
|
||||||
|
|
||||||
$marking = preg_split('(-|\(|\)|\/)', str_replace("/YW","", $parcel[5]));
|
$marking = explode('/', explode('CIEF/', $parcel[5])[1]);
|
||||||
$orderNumber = $marking[array_key_last($marking)];
|
|
||||||
|
if(!array_key_exists(1, $marking)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$orderNumber = $marking[1];
|
||||||
|
|
||||||
if(!$parcel[9]){
|
if(!$parcel[9]){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||||
} catch (ResourceNotFoundException $exception) {
|
} catch (ResourceNotFoundException $exception) {
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
|
||||||
use App\Classes\Modules\Segments\Services\UpdatesBasePriceConstantByDates;
|
|
||||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
|
||||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
|
||||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
|
||||||
use App\Classes\Modules\Segments\Standards\Rules\CanCreateConstant;
|
|
||||||
use App\Classes\Modules\Segments\Standards\Rules\CanUpdateConstant;
|
|
||||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
||||||
use App\Http\Resources\ConstantResource;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CreateBasePriceLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Create Base Price',
|
|
||||||
'message' => 'You have successfully created a Base Price'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var CanUpdateConstant */
|
|
||||||
private $canUpdateConstant;
|
|
||||||
|
|
||||||
/** @var UpdatesConstant */
|
|
||||||
private $updatesConstant;
|
|
||||||
|
|
||||||
/** @var FetchesSegment */
|
|
||||||
private $fetchesSegment;
|
|
||||||
|
|
||||||
/** @var FetchesConstant */
|
|
||||||
private $fetchesConstant;
|
|
||||||
|
|
||||||
/** @var CanCreateConstant */
|
|
||||||
private $canCreateConstant;
|
|
||||||
|
|
||||||
/** @var CreatesConstant */
|
|
||||||
private $createsConstant;
|
|
||||||
|
|
||||||
|
|
||||||
/** @var UpdatesBasePriceConstantByDates */
|
|
||||||
private $updatesBasePriceConstantByDates;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdateConstantLogic constructor.
|
|
||||||
* @param CanUpdateConstant $canUpdateConstant
|
|
||||||
* @param UpdatesConstant $updatesConstant
|
|
||||||
* @param FetchesSegment $fetchesSegment
|
|
||||||
* @param FetchesConstant $fetchesConstant
|
|
||||||
* @param CanCreateConstant $canCreateConstant
|
|
||||||
* @param CreatesConstant $createsConstant
|
|
||||||
* @param UpdatesBasePriceConstantByDates $updatesBasePriceConstantByDates
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
CanUpdateConstant $canUpdateConstant,
|
|
||||||
UpdatesConstant $updatesConstant,
|
|
||||||
FetchesSegment $fetchesSegment,
|
|
||||||
FetchesConstant $fetchesConstant,
|
|
||||||
CanCreateConstant $canCreateConstant,
|
|
||||||
CreatesConstant $createsConstant,
|
|
||||||
UpdatesBasePriceConstantByDates $updatesBasePriceConstantByDates
|
|
||||||
)
|
|
||||||
{
|
|
||||||
$this->canUpdateConstant = $canUpdateConstant;
|
|
||||||
$this->updatesConstant = $updatesConstant;
|
|
||||||
$this->fetchesSegment = $fetchesSegment;
|
|
||||||
$this->fetchesConstant = $fetchesConstant;
|
|
||||||
$this->canCreateConstant = $canCreateConstant;
|
|
||||||
$this->createsConstant = $createsConstant;
|
|
||||||
$this->updatesBasePriceConstantByDates = $updatesBasePriceConstantByDates;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
{
|
|
||||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => SegmentConstants::BASE_PRICE]);
|
|
||||||
|
|
||||||
} catch (ResourceNotFoundException $exception){
|
|
||||||
|
|
||||||
$constantObject = [];
|
|
||||||
|
|
||||||
$object = new ConstantObject(
|
|
||||||
SegmentConstants::BASE_PRICE,
|
|
||||||
$constantObject
|
|
||||||
);
|
|
||||||
|
|
||||||
$constant = $this->createsConstant->execute($segment, $object);
|
|
||||||
}
|
|
||||||
|
|
||||||
$constantValue = $this->updatesBasePriceConstantByDates->execute($constant->value, $request->input('dateFrom'), $request->input('dateTo'), $request->input('rate'));
|
|
||||||
|
|
||||||
$object = new ConstantObject(SegmentConstants::BASE_PRICE, $constantValue);
|
|
||||||
|
|
||||||
$this->canUpdateConstant->passes($object);
|
|
||||||
|
|
||||||
$constant = $this->updatesConstant->execute($constant, $object);
|
|
||||||
|
|
||||||
return $this->resourceResponse(new ConstantResource($constant));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
||||||
use App\Http\Resources\ConstantResource;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Carbon\CarbonPeriod;
|
|
||||||
|
|
||||||
class FetchBasePriceLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Retrieved Base Price',
|
|
||||||
'message' => 'You have successfully retrieved the Base Price'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** @var FetchesConstant */
|
|
||||||
private $fetchesConstant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FetchConstantLogic constructor.
|
|
||||||
* @param FetchesConstant $fetchesConstant
|
|
||||||
*/
|
|
||||||
public function __construct(FetchesConstant $fetchesConstant)
|
|
||||||
{
|
|
||||||
$this->fetchesConstant = $fetchesConstant;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
|
|
||||||
$constant = $this->fetchesConstant->execute(['segment_id' => $request->route('id'), 'reference' => SegmentConstants::BASE_PRICE]);
|
|
||||||
|
|
||||||
$constantObject = (array) $constant->value;
|
|
||||||
|
|
||||||
if ($request->input('dateFrom') !== null && $request->input('dateTo') !== null) {
|
|
||||||
|
|
||||||
$period = CarbonPeriod::create($request->input('dateFrom'), $request->input('dateTo'));
|
|
||||||
|
|
||||||
$returnObject = [];
|
|
||||||
|
|
||||||
foreach ($period as $date) {
|
|
||||||
array_key_exists($date->format('Y-m-d'), $constantObject) === true ? $returnObject[$date->format('Y-m-d')] = $constantObject[$date->format('Y-m-d')] : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$constant->value = json_encode($returnObject);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->resourceResponse(new ConstantResource($constant));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,9 +5,7 @@ namespace App\Classes\Modules\Segments\ControllersLogic;
|
|||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
|
||||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||||
use App\Classes\Modules\Segments\Services\CreatesSegment;
|
|
||||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||||
use App\Classes\Modules\Segments\Standards\Rules\CanCreateConstant;
|
use App\Classes\Modules\Segments\Standards\Rules\CanCreateConstant;
|
||||||
@@ -17,7 +15,6 @@ use App\Http\Resources\ConstantResource;
|
|||||||
use App\Models\SegmentConstant;
|
use App\Models\SegmentConstant;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Classes\Modules\Segments\Services\UpdatesConstantValue;
|
|
||||||
|
|
||||||
class UpdateConstantLogic extends AbstractControllerLogic
|
class UpdateConstantLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -50,11 +47,6 @@ class UpdateConstantLogic extends AbstractControllerLogic
|
|||||||
/** @var CreatesConstant */
|
/** @var CreatesConstant */
|
||||||
private $createsConstant;
|
private $createsConstant;
|
||||||
|
|
||||||
/** @var CreatesSegment */
|
|
||||||
private $createsSegment;
|
|
||||||
|
|
||||||
/** @var UpdatesConstantValue */
|
|
||||||
private $updatesConstantValue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateConstantLogic constructor.
|
* UpdateConstantLogic constructor.
|
||||||
@@ -64,19 +56,8 @@ class UpdateConstantLogic extends AbstractControllerLogic
|
|||||||
* @param FetchesConstant $fetchesConstant
|
* @param FetchesConstant $fetchesConstant
|
||||||
* @param CanCreateConstant $canCreateConstant
|
* @param CanCreateConstant $canCreateConstant
|
||||||
* @param CreatesConstant $createsConstant
|
* @param CreatesConstant $createsConstant
|
||||||
* @param UpdatesConstantValueByState $updatesConstantValueByState
|
|
||||||
* @param CreatesSegment $createsSegment
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(CanUpdateConstant $canUpdateConstant, UpdatesConstant $updatesConstant, FetchesSegment $fetchesSegment, FetchesConstant $fetchesConstant, CanCreateConstant $canCreateConstant, CreatesConstant $createsConstant)
|
||||||
CanUpdateConstant $canUpdateConstant,
|
|
||||||
UpdatesConstant $updatesConstant,
|
|
||||||
FetchesSegment $fetchesSegment,
|
|
||||||
FetchesConstant $fetchesConstant,
|
|
||||||
CanCreateConstant $canCreateConstant,
|
|
||||||
CreatesConstant $createsConstant,
|
|
||||||
UpdatesConstantValue $updatesConstantValue,
|
|
||||||
CreatesSegment $createsSegment
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
$this->canUpdateConstant = $canUpdateConstant;
|
$this->canUpdateConstant = $canUpdateConstant;
|
||||||
$this->updatesConstant = $updatesConstant;
|
$this->updatesConstant = $updatesConstant;
|
||||||
@@ -84,8 +65,6 @@ class UpdateConstantLogic extends AbstractControllerLogic
|
|||||||
$this->fetchesConstant = $fetchesConstant;
|
$this->fetchesConstant = $fetchesConstant;
|
||||||
$this->canCreateConstant = $canCreateConstant;
|
$this->canCreateConstant = $canCreateConstant;
|
||||||
$this->createsConstant = $createsConstant;
|
$this->createsConstant = $createsConstant;
|
||||||
$this->updatesConstantValue = $updatesConstantValue;
|
|
||||||
$this->createsSegment = $createsSegment;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
@@ -96,33 +75,28 @@ class UpdateConstantLogic extends AbstractControllerLogic
|
|||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$object = new ConstantObject($request->input('name'), $request->input('reference'), $request->input('detail'));
|
||||||
|
|
||||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]);
|
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $object->getReference()]);
|
||||||
|
|
||||||
$constantValue = $this->updatesConstantValue->execute($constant->value, $request->input('id'), $request->input('rate'));
|
|
||||||
|
|
||||||
$object = new ConstantObject($request->input('reference'), $constantValue);
|
|
||||||
|
|
||||||
$this->canUpdateConstant->passes($object);
|
$this->canUpdateConstant->passes($object);
|
||||||
|
|
||||||
|
/** @var SegmentConstant $constant */
|
||||||
|
$constant = $this->updatesConstant->execute($constant, $object);
|
||||||
|
|
||||||
} catch (ResourceNotFoundException $exception){
|
} catch (ResourceNotFoundException $exception){
|
||||||
|
|
||||||
$constantObject = [];
|
$this->canCreateConstant->passes($object);
|
||||||
|
|
||||||
$constantObject[$request->input('id')] = $request->input('rate');
|
|
||||||
|
|
||||||
$object = new ConstantObject(
|
|
||||||
$request->input('reference'),
|
|
||||||
$constantObject
|
|
||||||
);
|
|
||||||
|
|
||||||
|
/** @var SegmentConstant $constant */
|
||||||
$constant = $this->createsConstant->execute($segment, $object);
|
$constant = $this->createsConstant->execute($segment, $object);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$constant = $this->updatesConstant->execute($constant, $object);
|
|
||||||
|
|
||||||
return $this->resourceResponse(new ConstantResource($constant));
|
return $this->resourceResponse(new ConstantResource($constant));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,131 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use App\Http\Resources\ConstantResource;
|
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
||||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
|
||||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
|
||||||
use App\Classes\Modules\Segments\Standards\Rules\CanUpdateConstant;
|
|
||||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
|
||||||
use App\Classes\Modules\Segments\Services\AddItemToConstantValueArray;
|
|
||||||
use App\Classes\Modules\Segments\Services\RemoveItemFromConstantValueArray;
|
|
||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
|
||||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
|
||||||
|
|
||||||
class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Updated Segment Constant',
|
|
||||||
'message' => 'You have successfully updated the Segment Constant'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var CanUpdateConstant */
|
|
||||||
private $canUpdateConstant;
|
|
||||||
|
|
||||||
/** @var UpdatesConstant */
|
|
||||||
private $updatesConstant;
|
|
||||||
|
|
||||||
/** @var FetchesSegment */
|
|
||||||
private $fetchesSegment;
|
|
||||||
|
|
||||||
/** @var FetchesConstant */
|
|
||||||
private $fetchesConstant;
|
|
||||||
|
|
||||||
/** @var AddItemToConstantValueArray */
|
|
||||||
private $addItemToConstantValueArray;
|
|
||||||
|
|
||||||
/** @var RemoveItemFromConstantValueArray */
|
|
||||||
private $removeItemFromConstantValueArray;
|
|
||||||
|
|
||||||
/** @var CreatesConstant */
|
|
||||||
private $createsConstant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdateConstantLogic constructor.
|
|
||||||
* @param CanUpdateConstant $canUpdateConstant
|
|
||||||
* @param UpdatesConstant $updatesConstant
|
|
||||||
* @param FetchesSegment $fetchesSegment
|
|
||||||
* @param FetchesConstant $fetchesConstant
|
|
||||||
* @param AddItemToConstantValueArray $addItemToConstantValueArray
|
|
||||||
* @param CreatesConstant $createsConstant
|
|
||||||
* @param RemoveItemFromConstantValueArray $removeItemFromConstantValueArray
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
CanUpdateConstant $canUpdateConstant,
|
|
||||||
UpdatesConstant $updatesConstant,
|
|
||||||
FetchesSegment $fetchesSegment,
|
|
||||||
FetchesConstant $fetchesConstant,
|
|
||||||
AddItemToConstantValueArray $addItemToConstantValueArray,
|
|
||||||
RemoveItemFromConstantValueArray $removeItemFromConstantValueArray,
|
|
||||||
CreatesConstant $createsConstant
|
|
||||||
)
|
|
||||||
{
|
|
||||||
$this->canUpdateConstant = $canUpdateConstant;
|
|
||||||
$this->updatesConstant = $updatesConstant;
|
|
||||||
$this->fetchesSegment = $fetchesSegment;
|
|
||||||
$this->fetchesConstant = $fetchesConstant;
|
|
||||||
$this->addItemToConstantValueArray = $addItemToConstantValueArray;
|
|
||||||
$this->removeItemFromConstantValueArray = $removeItemFromConstantValueArray;
|
|
||||||
$this->createsConstant = $createsConstant;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
{
|
|
||||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]);
|
|
||||||
|
|
||||||
$constantValue = $this->addItemToConstantValueArray->execute($constant->value, $request->input('postcode'));
|
|
||||||
|
|
||||||
$object = new ConstantObject($request->input('reference'), $constantValue);
|
|
||||||
|
|
||||||
} catch (ResourceNotFoundException $exception){
|
|
||||||
|
|
||||||
$constantObject = [$request->input('postcode')];
|
|
||||||
|
|
||||||
$object = new ConstantObject(
|
|
||||||
$request->input('reference'),
|
|
||||||
$constantObject
|
|
||||||
);
|
|
||||||
|
|
||||||
$constant = $this->createsConstant->execute($segment, $object);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// check if postcode exist in the opposite constant, and delete it
|
|
||||||
$oppositeConstant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference') == SegmentConstants::CENTER_POSTCODE ? SegmentConstants::OUTSTATION_POSTCODE : SegmentConstants::CENTER_POSTCODE]);
|
|
||||||
|
|
||||||
$oppositeConstantValue = $this->removeItemFromConstantValueArray->execute($oppositeConstant->value, $request->input('postcode'));
|
|
||||||
|
|
||||||
$oppositeObject = new ConstantObject($request->input('reference') == SegmentConstants::CENTER_POSTCODE ? SegmentConstants::OUTSTATION_POSTCODE : SegmentConstants::CENTER_POSTCODE, $oppositeConstantValue);
|
|
||||||
|
|
||||||
$this->updatesConstant->execute($oppositeConstant, $oppositeObject);
|
|
||||||
|
|
||||||
} catch (ResourceNotFoundException $exception){
|
|
||||||
// if opposite constant does not exist, do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
$constant = $this->updatesConstant->execute($constant, $object);
|
|
||||||
|
|
||||||
return $this->resourceResponse(new ConstantResource($constant));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -7,22 +7,34 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
|||||||
class ConstantObject implements DataTransferObject
|
class ConstantObject implements DataTransferObject
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
private $name;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $reference;
|
private $reference;
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
private $value;
|
private $detail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConstantObject constructor.
|
* ConstantObject constructor.
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $reference
|
* @param string $reference
|
||||||
* @param array $value
|
* @param array $detail
|
||||||
*/
|
*/
|
||||||
public function __construct(string $reference, array $value)
|
public function __construct(string $name, string $reference, array $detail)
|
||||||
{
|
{
|
||||||
|
$this->name = $name;
|
||||||
$this->reference = $reference;
|
$this->reference = $reference;
|
||||||
$this->value = $value;
|
$this->detail = $detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName(): string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,9 +48,9 @@ class ConstantObject implements DataTransferObject
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getValue(): array
|
public function getDetail(): array
|
||||||
{
|
{
|
||||||
return $this->value;
|
return $this->detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Segments\Services;
|
|
||||||
|
|
||||||
class AddItemToConstantValueArray
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $array
|
|
||||||
* @param $item
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function execute($array, $item): array {
|
|
||||||
$array[] = $item;
|
|
||||||
sort($array);
|
|
||||||
return $array;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -27,11 +27,11 @@ class ConvertsConstantDetailsToResource
|
|||||||
|
|
||||||
public function execute(SegmentConstant $constant){
|
public function execute(SegmentConstant $constant){
|
||||||
|
|
||||||
// if($constant->reference === SegmentConstants::SUPPLIER_CURRENCIES) {
|
if($constant->reference === SegmentConstants::SUPPLIER_CURRENCIES) {
|
||||||
// return property_exists($constant->detail, 'id') ? new CurrencyResource($this->fetchesCurrency->execute(['id' => $constant->detail->id])) : '';
|
return property_exists($constant->detail, 'id') ? new CurrencyResource($this->fetchesCurrency->execute(['id' => $constant->detail->id])) : '';
|
||||||
// }
|
}
|
||||||
|
|
||||||
return $constant->value;
|
return $constant->detail;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ class CreatesConstant extends AbstractUpdateRelationshipRecord
|
|||||||
public function execute(Segment $segment, ConstantObject $object)
|
public function execute(Segment $segment, ConstantObject $object)
|
||||||
{
|
{
|
||||||
$model = new SegmentConstant();
|
$model = new SegmentConstant();
|
||||||
|
$model->name = $object->getName();
|
||||||
$model->reference = $object->getReference();
|
$model->reference = $object->getReference();
|
||||||
$model->value = json_encode($object->getValue());
|
$model->detail = json_encode($object->getDetail());
|
||||||
|
|
||||||
return $this->handler($segment->constants(), $model);
|
return $this->handler($segment->constants(), $model);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Segments\Services;
|
|
||||||
|
|
||||||
class RemoveItemFromConstantValueArray
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $array
|
|
||||||
* @param $item
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function execute($array, $item): array {
|
|
||||||
foreach($array as $key => $value){
|
|
||||||
if($array[$key] == $item){
|
|
||||||
unset($array[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return array_values($array);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Segments\Services;
|
|
||||||
|
|
||||||
use Carbon\CarbonPeriod;
|
|
||||||
|
|
||||||
class UpdatesBasePriceConstantByDates
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $json
|
|
||||||
* @param int $status_id
|
|
||||||
* @param Array $rate
|
|
||||||
* @return Array
|
|
||||||
*/
|
|
||||||
public function execute($json, String $date_from, String $date_to, String $rate) {
|
|
||||||
|
|
||||||
$objectArray = (array) $json;
|
|
||||||
|
|
||||||
$period = CarbonPeriod::create($date_from, $date_to);
|
|
||||||
|
|
||||||
foreach ($period as $date) {
|
|
||||||
$objectArray[$date->format('Y-m-d')] = $rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $objectArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -17,8 +17,9 @@ class UpdatesConstant extends AbstractUpdateRecord
|
|||||||
*/
|
*/
|
||||||
public function execute(SegmentConstant $model, ConstantObject $object)
|
public function execute(SegmentConstant $model, ConstantObject $object)
|
||||||
{
|
{
|
||||||
|
$model->name = $object->getName();
|
||||||
$model->reference = $object->getReference();
|
$model->reference = $object->getReference();
|
||||||
$model->value = json_encode($object->getValue());
|
$model->detail = json_encode($object->getDetail());
|
||||||
|
|
||||||
return $this->handler($model);
|
return $this->handler($model);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Segments\Services;
|
|
||||||
|
|
||||||
class UpdatesConstantValue
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $json
|
|
||||||
* @param int $status_id
|
|
||||||
* @param Array $rate
|
|
||||||
* @return Array
|
|
||||||
*/
|
|
||||||
public function execute($json, int $state_id, Array $rate) {
|
|
||||||
|
|
||||||
$objectArray = (array) $json;
|
|
||||||
|
|
||||||
$objectArray[$state_id] = $rate;
|
|
||||||
|
|
||||||
return $objectArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -15,8 +15,9 @@ class ConstantValidation extends AbstractValidation
|
|||||||
protected function data($object): array {
|
protected function data($object): array {
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
'name' => $object->getName(),
|
||||||
'reference' => $object->getReference(),
|
'reference' => $object->getReference(),
|
||||||
'value' => $object->getValue()
|
'detail' => $object->getDetail()
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@@ -27,8 +28,9 @@ class ConstantValidation extends AbstractValidation
|
|||||||
*/
|
*/
|
||||||
protected function rules(): array {
|
protected function rules(): array {
|
||||||
return [
|
return [
|
||||||
|
'name' => 'required',
|
||||||
'reference' => 'required',
|
'reference' => 'required',
|
||||||
'value' => 'required'
|
'detail' => 'required'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-30
@@ -20,11 +20,7 @@ use App\Classes\ValueObjects\Constants\TransactionType;
|
|||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||||
use App\Classes\ValueObjects\Constants\PackageType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionDetailType;
|
|
||||||
|
|
||||||
use App\Models\Document;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
@@ -90,11 +86,7 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
{
|
{
|
||||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
$packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
||||||
|
|
||||||
$cbm = $packing_list->packages->where('type', '!=', PackageType::OVER_WEIGHT)->sum(function($package) {
|
$cbm = $packing_list->packages->sum(function($package) {
|
||||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
|
||||||
});
|
|
||||||
|
|
||||||
$over_weight_cbm = $packing_list->packages->where('type', PackageType::OVER_WEIGHT)->sum(function($package) {
|
|
||||||
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
return ($package->width / 100) * ($package->height / 100) *($package->length / 100) * ($package->quantity);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -151,7 +143,7 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
$price_cbm = $base_price + $warehouse_rate + $state_rate;
|
$price_cbm = $base_price + $warehouse_rate + $state_rate;
|
||||||
$total_cbm = $price_cbm * ($cbm + $over_weight_cbm);
|
$total_cbm = $price_cbm * $cbm;
|
||||||
|
|
||||||
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
$billNumber = $this->generatesTransactionBillNumber->execute('SHIP-');
|
||||||
|
|
||||||
@@ -173,28 +165,16 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
ApprovalStatus::PENDING_SUBMISSION
|
ApprovalStatus::PENDING_SUBMISSION
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @var Transaction $invoice_transaction */
|
|
||||||
$invoice_transaction = $this->createsTransaction->execute($packing_list, $object);
|
$invoice_transaction = $this->createsTransaction->execute($packing_list, $object);
|
||||||
|
|
||||||
$object_detail = new TransactionDetailObject(
|
$object_detail = new TransactionDetailObject(
|
||||||
'SHIPPING_FEE',
|
$invoice_transaction->bill_no,
|
||||||
TransactionDetailType::SHIPPING_FEE,
|
$invoice_transaction->bill_no,
|
||||||
$cbm,
|
1,
|
||||||
$price_cbm
|
$invoice_transaction->amount,
|
||||||
|
$invoice_transaction->amount
|
||||||
);
|
);
|
||||||
|
$transaction_detail = $this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
|
||||||
|
|
||||||
if ($over_weight_cbm > 0) {
|
|
||||||
$object_detail = new TransactionDetailObject(
|
|
||||||
'OVER_WEIGHT_CHARGES',
|
|
||||||
TransactionDetailType::OVER_WEIGHT_CHARGES,
|
|
||||||
$over_weight_cbm,
|
|
||||||
$price_cbm
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->createsTransactionDetail->execute($invoice_transaction, $object_detail);
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoice', ['invoice_transaction' => $invoice_transaction]);
|
||||||
|
|
||||||
@@ -205,12 +185,11 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic
|
|||||||
ApprovalStatus::COMPLETED,
|
ApprovalStatus::COMPLETED,
|
||||||
'shipping_invoice'
|
'shipping_invoice'
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @var Document $document */
|
/** @var Document $document */
|
||||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
||||||
|
|
||||||
$this->createsFile->execute($document, $document_object);
|
$this->createsFile->execute($document, $document_object);
|
||||||
|
|
||||||
|
// dd('yess');
|
||||||
return $this->response([]);
|
return $this->response([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class TransactionDetailObject implements DataTransferObject
|
|||||||
/** @var string|null */
|
/** @var string|null */
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
/** @var float|null */
|
/** @var int|null */
|
||||||
private $quantity;
|
private $quantity;
|
||||||
|
|
||||||
/** @var float|null */
|
/** @var float|null */
|
||||||
@@ -22,10 +22,10 @@ class TransactionDetailObject implements DataTransferObject
|
|||||||
* TransactionDetailObject constructor.
|
* TransactionDetailObject constructor.
|
||||||
* @param string $reference
|
* @param string $reference
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param float $quantity
|
* @param int $quantity
|
||||||
* @param float $price
|
* @param float $price
|
||||||
*/
|
*/
|
||||||
public function __construct(?string $reference, ?string $name , ?float $quantity, ?float $price)
|
public function __construct(?string $reference, ?string $name , ?int $quantity, ?float $price)
|
||||||
{
|
{
|
||||||
$this->reference = $reference;
|
$this->reference = $reference;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
@@ -50,9 +50,9 @@ class TransactionDetailObject implements DataTransferObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return float
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getQuantity(): ?float
|
public function getQuantity(): ?int
|
||||||
{
|
{
|
||||||
return $this->quantity;
|
return $this->quantity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,4 @@ final class AddressType {
|
|||||||
|
|
||||||
public const DELIVERY = 2;
|
public const DELIVERY = 2;
|
||||||
|
|
||||||
public const PICK_UP = 3;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,4 @@ final class BusinessType {
|
|||||||
|
|
||||||
public const CURRENCY_VENDOR = 6;
|
public const CURRENCY_VENDOR = 6;
|
||||||
|
|
||||||
public const ONLINE_SELLER = 7;
|
|
||||||
|
|
||||||
public const LAST_MILE_DELIVERY_AGENT = 8;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,4 @@ final class OrderType {
|
|||||||
|
|
||||||
public const DEDICATED_CONTAINER = 1;
|
public const DEDICATED_CONTAINER = 1;
|
||||||
|
|
||||||
public const LAST_MILE_DELIVERY = 2;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,4 @@ final class PackageType {
|
|||||||
|
|
||||||
public const OVER_WEIGHT = 2;
|
public const OVER_WEIGHT = 2;
|
||||||
|
|
||||||
public const DOCUMENT = 3;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\ValueObjects\Constants;
|
|
||||||
|
|
||||||
final class TransactionDetailType {
|
|
||||||
|
|
||||||
public const SHIPPING_FEE = 'Shipping Fee';
|
|
||||||
|
|
||||||
public const OVER_WEIGHT_CHARGES = 'Over weight charges';
|
|
||||||
}
|
|
||||||
@@ -8,8 +8,6 @@ final class WarehouseReferences {
|
|||||||
|
|
||||||
public const YD_GUANG_ZHOU = 'GZ-V02';
|
public const YD_GUANG_ZHOU = 'GZ-V02';
|
||||||
|
|
||||||
public const YD_GUANG_ZHOU_2 = 'GZ-V03';
|
|
||||||
|
|
||||||
public const VT_YIWU = 'YW-V01';
|
public const VT_YIWU = 'YW-V01';
|
||||||
|
|
||||||
public const YD_YIWU = 'YW-V02';
|
public const YD_YIWU = 'YW-V02';
|
||||||
@@ -45,8 +43,6 @@ final class WarehouseReferences {
|
|||||||
|
|
||||||
public const YD_EXEMPT_LIST = [230, 294, 320, 652, 1248, 1726];
|
public const YD_EXEMPT_LIST = [230, 294, 320, 652, 1248, 1726];
|
||||||
|
|
||||||
public const REPLICA_WHITE_LIST = [502];
|
|
||||||
|
|
||||||
//2376 qce
|
//2376 qce
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Delivery;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Delivery\ControllersLogic\CancelDeliveryOrderLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CancelDeliveryOrderController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param CancelOrderLogic $logic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function cancel(Request $request, CancelDeliveryOrderLogic $logic): JsonResponse
|
|
||||||
{
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Delivery;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Delivery\ControllersLogic\CreateDeliveryCustomerLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CreateDeliveryCustomerController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param CreateDeliveryCustomerLogic $createDeliveryCustomerLogic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function create(Request $request, CreateDeliveryCustomerLogic $createDeliveryCustomerLogic): JsonResponse
|
|
||||||
{
|
|
||||||
return $createDeliveryCustomerLogic->execute($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Delivery;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Delivery\ControllersLogic\CreateDeliveryOrderLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CreateDeliveryOrderController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param CreateDeliveryOrderLogic $createDeliveryOrderLogic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function create(Request $request, CreateDeliveryOrderLogic $createDeliveryOrderLogic): JsonResponse
|
|
||||||
{
|
|
||||||
return $createDeliveryOrderLogic->execute($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Delivery;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsCustomers;
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsMultipleDeliveryOrders;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Maatwebsite\Excel\Excel;
|
|
||||||
|
|
||||||
class ExportDeliveryOrdersToExcelController
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExportCustomersToExcelController constructor.
|
|
||||||
* @param Request $request
|
|
||||||
*/
|
|
||||||
public function __construct(Request $request)
|
|
||||||
{
|
|
||||||
$token = Auth::fromUser(User::find(1));
|
|
||||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function lineClear(Request $request){
|
|
||||||
$exportsTransactions = new ExportsMultipleDeliveryOrders($request);
|
|
||||||
$response = $exportsTransactions->download('line-clear-export.xlsx', Excel::XLSX, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
|
||||||
ob_end_clean();
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Delivery;
|
|
||||||
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Classes\Modules\Delivery\ControllersLogic\ListOrdersLogic;
|
|
||||||
|
|
||||||
|
|
||||||
class ListOrdersController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param ListOrdersLogic $logic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function list(Request $request, ListOrdersLogic $logic) : JsonResponse {
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Exports;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsArrivedParcel;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Maatwebsite\Excel\Excel;
|
|
||||||
|
|
||||||
class ExportArrivedParcelController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* ExportArrivedParcelController constructor.
|
|
||||||
* @param Request $request
|
|
||||||
*/
|
|
||||||
public function __construct(Request $request)
|
|
||||||
{
|
|
||||||
$token = Auth::fromUser(User::find(1));
|
|
||||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function export(Request $request) {
|
|
||||||
$exportsPendingArrangementDeliveryList = new ExportsArrivedParcel($request);
|
|
||||||
$response = $exportsPendingArrangementDeliveryList->download('arrived-parcel.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
|
||||||
ob_end_clean();
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Exports;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsOnHoldPackingList;
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsPendingArrangementDeliveryList;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Maatwebsite\Excel\Excel;
|
|
||||||
|
|
||||||
class ExportPendingArrangementPackingListController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* ExportPendingArrangementPackingListController constructor.
|
|
||||||
* @param Request $request
|
|
||||||
*/
|
|
||||||
public function __construct(Request $request)
|
|
||||||
{
|
|
||||||
$token = Auth::fromUser(User::find(1));
|
|
||||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function export(Request $request) {
|
|
||||||
$exportsPendingArrangementDeliveryList = new ExportsPendingArrangementDeliveryList($request);
|
|
||||||
$response = $exportsPendingArrangementDeliveryList->download('packing-list-delivery.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
|
||||||
ob_end_clean();
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onHold(Request $request) {
|
|
||||||
$exportsPendingArrangementDeliveryList = new ExportsOnHoldPackingList($request);
|
|
||||||
$response = $exportsPendingArrangementDeliveryList->download('packing-list-on-hold.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
|
||||||
ob_end_clean();
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Notifications;
|
||||||
|
|
||||||
|
use App\Classes\Modules\Notifications\ControllersLogic\ListNotificationsLogic;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ListNotificationsController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @param ListNotificationsLogic $logic
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function list(Request $request, ListNotificationsLogic $logic): JsonResponse {
|
||||||
|
return $logic->execute($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ class DownloadOrderQrPdfController
|
|||||||
$warehousePrefix = '';
|
$warehousePrefix = '';
|
||||||
$deliveryPrefix = '';
|
$deliveryPrefix = '';
|
||||||
$customerMarking = '';
|
$customerMarking = '';
|
||||||
$remark = $warehouse->remarks()->first();
|
$remark = $warehouse->remarks()->first()->content;
|
||||||
|
|
||||||
if($warehouse->reference === WarehouseReferences::VT_GUANG_ZHOU || $warehouse->reference === WarehouseReferences::VT_YIWU) {
|
if($warehouse->reference === WarehouseReferences::VT_GUANG_ZHOU || $warehouse->reference === WarehouseReferences::VT_YIWU) {
|
||||||
$customerMarking = $order->companyModule->connections()->first()->invitee_reference.'/';
|
$customerMarking = $order->companyModule->connections()->first()->invitee_reference.'/';
|
||||||
@@ -41,14 +41,14 @@ class DownloadOrderQrPdfController
|
|||||||
$warehousePrefix = 'YW/';
|
$warehousePrefix = 'YW/';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(in_array($warehouse->reference,[WarehouseReferences::YD_GUANG_ZHOU, WarehouseReferences::YD_GUANG_ZHOU_2])){
|
if($warehouse->reference === WarehouseReferences::YD_GUANG_ZHOU){
|
||||||
$warehousePrefix = 'YD/';
|
$warehousePrefix = 'YD/';
|
||||||
|
|
||||||
if(strtolower($deliveryAddress->state->name) === 'sabah' || strtolower($deliveryAddress->state->name) === 'labuan' || in_array(strtolower($deliveryAddress->district->name), ['limbang', 'lawas'])) {
|
if(strtolower($deliveryAddress->state->name) === 'sabah' || strtolower($deliveryAddress->state->name) === 'labuan') {
|
||||||
$warehousePrefix = 'KK/';
|
$warehousePrefix = 'KK/';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strtolower($deliveryAddress->state->name) === 'sarawak' && !in_array(strtolower($deliveryAddress->district->name), ['limbang', 'lawas'])) {
|
if(strtolower($deliveryAddress->state->name) === 'sarawak') {
|
||||||
$warehousePrefix = 'KU/';
|
$warehousePrefix = 'KU/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ class DownloadOrderQrPdfController
|
|||||||
'delivery_address' => $deliveryAddress,
|
'delivery_address' => $deliveryAddress,
|
||||||
'warehouse_address' => $warehouseAddress,
|
'warehouse_address' => $warehouseAddress,
|
||||||
'warehouse_contacts' => $warehouseContacts,
|
'warehouse_contacts' => $warehouseContacts,
|
||||||
'remark' => $remark ? $remark->content : ''
|
'remark' => $remark
|
||||||
];
|
];
|
||||||
|
|
||||||
$pdf = LaravelMpdf::loadView('pdfs.qr', $data, [], [
|
$pdf = LaravelMpdf::loadView('pdfs.qr', $data, [], [
|
||||||
|
|||||||
@@ -200,62 +200,4 @@ class MonthlyReportController
|
|||||||
})->sum('quantity'),
|
})->sum('quantity'),
|
||||||
]]))->handler();
|
]]))->handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customerActivityReport(Request $request): JsonResponse {
|
|
||||||
|
|
||||||
$active_start = $request->input('active_start');
|
|
||||||
$active_end = $request->input('active_end');
|
|
||||||
$inactive_start = $request->input('inactive_start');
|
|
||||||
$inactive_end = $request->input('inactive_end');
|
|
||||||
$minCbm = $request->input('cbm');
|
|
||||||
$minOrders = $request->input('minOrders');
|
|
||||||
|
|
||||||
$activeCompanies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) {
|
|
||||||
return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
|
|
||||||
return $query->where('drop_date', '>=', \Carbon\Carbon::parse($inactive_start))->where('drop_date', '<=', \Carbon\Carbon::parse($inactive_end)->addDay());
|
|
||||||
});
|
|
||||||
})->pluck('id');
|
|
||||||
|
|
||||||
$companies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) {
|
|
||||||
return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
|
||||||
return $query->whereDate('drop_date', '>=', \Carbon\Carbon::parse($active_start))->whereDate('drop_date', '<=', \Carbon\Carbon::parse($active_end)->addDay());
|
|
||||||
});
|
|
||||||
})->whereNotIn('id', $activeCompanies)->get();
|
|
||||||
|
|
||||||
$customerActivityData = [];
|
|
||||||
$counter = 1;
|
|
||||||
|
|
||||||
foreach ($companies as $key => $company){
|
|
||||||
$connection = $company->inviters()->withPivot('invitee_reference')->first();
|
|
||||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
|
||||||
$packingList = $company->orderPackingLists()->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->get();
|
|
||||||
$totalCbm = $packingList->flatMap(function ($packingList) {
|
|
||||||
return $packingList->packages;
|
|
||||||
})->sum(function($package){
|
|
||||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($minCbm != 'null' && $totalCbm < $minCbm) { continue; }
|
|
||||||
|
|
||||||
if ($minOrders != 'null' && $packingList->count() < $minOrders) { continue; }
|
|
||||||
|
|
||||||
array_push($customerActivityData, array(
|
|
||||||
'key' => $counter,
|
|
||||||
'marking' => $marking,
|
|
||||||
'packingListCount'=> $packingList->count(),
|
|
||||||
'totalCbm'=> $totalCbm,
|
|
||||||
));
|
|
||||||
$counter ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (new ApiResponseObject('fetch service report Successful',
|
|
||||||
'',
|
|
||||||
HttpStatus::OK_WITH_MESSAGE, ['data' => [
|
|
||||||
'active_start' => Carbon::parse($active_start)->format('d/m/Y'),
|
|
||||||
'active_end' => Carbon::parse($active_end)->format('d/m/Y'),
|
|
||||||
'inactive_start' => Carbon::parse($inactive_start)->format('d/m/Y'),
|
|
||||||
'inactive_end' => Carbon::parse($inactive_end)->format('d/m/Y'),
|
|
||||||
'customerActivityData' => $customerActivityData,
|
|
||||||
]]))->handler();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Segments;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Segments\ControllersLogic\CreateBasePriceLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class CreateBasePriceController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param CreateBasePriceLogic $logic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function create(Request $request, CreateBasePriceLogic $logic): JsonResponse {
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Segments;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Segments\ControllersLogic\FetchBasePriceLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class FetchBasePriceController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param FetchSegmentLogic $logic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function fetch(Request $request, FetchBasePriceLogic $logic): JsonResponse {
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Segments;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Segments\ControllersLogic\UpdateConstantPostcodeLogic;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class UpdateConstantPostcodeController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @param UpdateConstantPostcodeLogic $logic
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function update(Request $request, UpdateConstantPostcodeLogic $logic): JsonResponse {
|
|
||||||
return $logic->execute($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,8 +5,6 @@ namespace App\Http\Resources;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use App\Models\SegmentConstant;
|
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
||||||
|
|
||||||
class AddressResource extends JsonResource
|
class AddressResource extends JsonResource
|
||||||
{
|
{
|
||||||
@@ -19,14 +17,6 @@ class AddressResource extends JsonResource
|
|||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$centerPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::CENTER_POSTCODE)->get();
|
|
||||||
$centerPostcodeConstant = $centerPostcodeConstantObject->isEmpty() ? [] : (array)$centerPostcodeConstantObject->first()->value;
|
|
||||||
$postcodeArea = in_array($this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : '';
|
|
||||||
|
|
||||||
$outstationPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::OUTSTATION_POSTCODE)->get();
|
|
||||||
$outstationPostcodeConstant = $outstationPostcodeConstantObject->isEmpty() ? [] : (array)$outstationPostcodeConstantObject->first()->value;
|
|
||||||
in_array($this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : '';
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'reference' => $this->reference,
|
'reference' => $this->reference,
|
||||||
@@ -35,7 +25,6 @@ class AddressResource extends JsonResource
|
|||||||
'district' => $this->district,
|
'district' => $this->district,
|
||||||
'state' => $this->state,
|
'state' => $this->state,
|
||||||
'post_code' => $this->postcode,
|
'post_code' => $this->postcode,
|
||||||
'post_code_area' => $postcodeArea,
|
|
||||||
'country' => $this->country,
|
'country' => $this->country,
|
||||||
'default' => (int) $this->default,
|
'default' => (int) $this->default,
|
||||||
'status' => (int) $this->status,
|
'status' => (int) $this->status,
|
||||||
|
|||||||
@@ -32,9 +32,6 @@ class CompanyModuleResource extends JsonResource
|
|||||||
$connection = $this->inviters()->withPivot('invitee_reference')->first();
|
$connection = $this->inviters()->withPivot('invitee_reference')->first();
|
||||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
||||||
|
|
||||||
$segmentConstantObject = SegmentConstant::where('reference', SegmentConstants::WAREHOUSE_RATE)->get();
|
|
||||||
$segmentConstant = $segmentConstantObject->isEmpty() ? [] : (array)$segmentConstantObject->first()->value;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
@@ -43,8 +40,7 @@ class CompanyModuleResource extends JsonResource
|
|||||||
'address' => new AddressResource($defaultAddress),
|
'address' => new AddressResource($defaultAddress),
|
||||||
'company' => new CompanyResource($this->whenLoaded('company')),
|
'company' => new CompanyResource($this->whenLoaded('company')),
|
||||||
'remarks' => RemarkResource::collection($this->remarks),
|
'remarks' => RemarkResource::collection($this->remarks),
|
||||||
'marking' => $marking,
|
'marking' => $marking
|
||||||
'warehouseCharges' => array_key_exists($this->id, $segmentConstant) ? $segmentConstant[$this->id] : null,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class CompanyResource extends JsonResource
|
|||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
$companyModule = $this->companyModules()->first();
|
$companyModule = $this->companyModules()->where('type', '=', BusinessType::IMPORTER)->first();
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'hash_id' => Crypt::encryptString($this->id),
|
'hash_id' => Crypt::encryptString($this->id),
|
||||||
@@ -30,8 +30,8 @@ class CompanyResource extends JsonResource
|
|||||||
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
|
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
|
||||||
'employee' => new UserResource($companyModule->employees()->first()),
|
'employee' => new UserResource($companyModule->employees()->first()),
|
||||||
'company_module' => new CompanyModuleResource($companyModule),
|
'company_module' => new CompanyModuleResource($companyModule),
|
||||||
'last_order' => $companyModule->type === 7 ? new DeliveryOrderResource($companyModule->orders()->orderBy('id', 'DESC')->first()) : new OrderResource($companyModule->orders()->orderBy('id', 'DESC')->first()),
|
'last_order' => new OrderResource($companyModule ? $companyModule->orders()->orderBy('id', 'DESC')->first(): null),
|
||||||
'order_count' => $companyModule->orders()->count(),
|
'order_count' => $this->orders()->count(),
|
||||||
'identification' => new DocumentResource($this->documents->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->first()),
|
'identification' => new DocumentResource($this->documents->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->first()),
|
||||||
'created_at' => $this->created_at->format('d-m-Y')
|
'created_at' => $this->created_at->format('d-m-Y')
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ class ConstantResource extends JsonResource
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
'reference' => $this->reference,
|
'reference' => $this->reference,
|
||||||
'value' => (App()->make(ConvertsConstantDetailsToResource::class))->execute($this->resource)
|
'detail' => (App()->make(ConvertsConstantDetailsToResource::class))->execute($this->resource)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
|
|
||||||
class DeliveryOrderResource extends JsonResource
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => $this->id,
|
|
||||||
'reference' => $this->reference,
|
|
||||||
'type' => (int) $this->type,
|
|
||||||
'status' => (int) $this->status,
|
|
||||||
'company_module' => new CompanyModuleResource($this->companyModule),
|
|
||||||
'sender_address' => new AddressResource($this->addresses()->where('status', '=', ApprovalStatus::APPROVED)->where('type', AddressType::PICK_UP)->first()),
|
|
||||||
'delivery_address' => new AddressResource($this->addresses()->where('status', '=', ApprovalStatus::APPROVED)->where('type', AddressType::DELIVERY)->first()),
|
|
||||||
'packingList' => new DeliveryPackingListResource($this->packingLists()->first()),
|
|
||||||
'remarks' => RemarkResource::collection($this->remarks),
|
|
||||||
'created_at' => $this->created_at->format('d-m-Y')
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
|
|
||||||
class DeliveryPackingListResource extends JsonResource
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
|
||||||
$package = $this->packages()->first();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'id' => $this->id,
|
|
||||||
'claimant_id' => $this->claimant_id,
|
|
||||||
'reference' => $this->reference,
|
|
||||||
'status' => $this->status,
|
|
||||||
'transport' => new TransportResource($this->transports()->first()),
|
|
||||||
'type' => $package->type,
|
|
||||||
'description' => $package->description,
|
|
||||||
'weight' => (float) $package->weight,
|
|
||||||
'quantity' => (float) $package->quantity,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,7 +20,6 @@ class DistrictResource extends JsonResource
|
|||||||
'state' => $this->state,
|
'state' => $this->state,
|
||||||
'country' => $this->country,
|
'country' => $this->country,
|
||||||
'postcode' => $this->postcode,
|
'postcode' => $this->postcode,
|
||||||
'postcodeArray' => PostcodeResource::collection(json_decode($this->postcode)),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||||
|
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
|
||||||
|
class NotificationResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'title' => $this->title,
|
||||||
|
'description' => $this->description,
|
||||||
|
'long_ago' => $this->created_at->diffForHumans(),
|
||||||
|
'created_at' => $this->created_at->format('d-m-Y')
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
|
||||||
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
use App\Models\SegmentConstant;
|
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
||||||
|
|
||||||
|
|
||||||
class PostcodeResource extends JsonResource
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
|
||||||
$centerPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::CENTER_POSTCODE)->get();
|
|
||||||
$centerPostcodeConstant = $centerPostcodeConstantObject->isEmpty() ? [] : (array)$centerPostcodeConstantObject->first()->value;
|
|
||||||
$postcodeArea = in_array($this->resource, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : '';
|
|
||||||
|
|
||||||
$outstationPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::OUTSTATION_POSTCODE)->get();
|
|
||||||
$outstationPostcodeConstant = $outstationPostcodeConstantObject->isEmpty() ? [] : (array)$outstationPostcodeConstantObject->first()->value;
|
|
||||||
in_array($this->resource, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : '';
|
|
||||||
|
|
||||||
return [
|
|
||||||
'postcode' => $this->resource,
|
|
||||||
'postcodeArea' => $postcodeArea,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
use App\Models\SegmentConstant;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
||||||
|
|
||||||
class StateResource extends JsonResource
|
class StateResource extends JsonResource
|
||||||
{
|
{
|
||||||
@@ -15,15 +14,10 @@ class StateResource extends JsonResource
|
|||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$segmentConstantObject = SegmentConstant::where('reference', SegmentConstants::STATE_RATE)->get();
|
|
||||||
$segmentConstant = $segmentConstantObject->isEmpty() ? [] : (array)$segmentConstantObject->first()->value;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'country' => $this->country,
|
'country' => $this->country,
|
||||||
'stateCharges' => array_key_exists($this->id, $segmentConstant) ? $segmentConstant[$this->id] : null,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class TransportResource extends JsonResource
|
class TransportResource extends JsonResource
|
||||||
@@ -16,7 +15,6 @@ class TransportResource extends JsonResource
|
|||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
$currentSchedule = $this->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first();
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
@@ -25,10 +23,8 @@ class TransportResource extends JsonResource
|
|||||||
'dispatch_date' => $this->dispatch_date ? $this->dispatch_date->format('d-m-Y') : $this->dispatch_date,
|
'dispatch_date' => $this->dispatch_date ? $this->dispatch_date->format('d-m-Y') : $this->dispatch_date,
|
||||||
'drop_date' => $this->drop_date ? $this->drop_date->format('d-m-Y') : $this->drop_date,
|
'drop_date' => $this->drop_date ? $this->drop_date->format('d-m-Y') : $this->drop_date,
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'current_schedule' => new ScheduleResource($currentSchedule),
|
'current_schedule' => new ScheduleResource($this->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()),
|
||||||
'schedule_history' => ScheduleResource::collection($this->schedules()->where('status', '=', ApprovalStatus::EXPIRED)->get()),
|
'schedule_history' => ScheduleResource::collection($this->schedules()->where('status', '=', ApprovalStatus::EXPIRED)->get())
|
||||||
'dropped_days' => Carbon::now()->diffInDays($this->drop_date, false),
|
|
||||||
'schedule_complete' => $currentSchedule ? $currentSchedule->eta <= Carbon::now() : false
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use App\Classes\General\Interfaces\Steppable;
|
|
||||||
use App\Classes\General\Interfaces\Transportable;
|
|
||||||
use App\Classes\General\Interfaces\Packable;
|
|
||||||
use App\Classes\General\Interfaces\Transactionable;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
|
||||||
|
|
||||||
class Addon extends AbstractModel
|
|
||||||
{
|
|
||||||
use SoftDeletes;
|
|
||||||
|
|
||||||
protected $table = 'addons';
|
|
||||||
|
|
||||||
protected $fillable = ['status'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
|
||||||
*/
|
|
||||||
public function owner(): morphTo
|
|
||||||
{
|
|
||||||
return $this->morphTo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -58,14 +58,6 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
|
|||||||
return $this->morphMany(PackingList::class, 'owner');
|
return $this->morphMany(PackingList::class, 'owner');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MorphMany
|
|
||||||
*/
|
|
||||||
public function addons(): morphMany
|
|
||||||
{
|
|
||||||
return $this->morphMany(Addon::class, 'owner');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return MorphMany
|
* @return MorphMany
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -36,14 +36,6 @@ class PackingList extends AbstractModel implements Transportable, Steppable, Pac
|
|||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MorphMany
|
|
||||||
*/
|
|
||||||
public function addons(): morphMany
|
|
||||||
{
|
|
||||||
return $this->morphMany(Addon::class, 'owner');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function containers(): BelongsToMany
|
public function containers(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->BelongsToMany(Container::class, ContainerPackingList::class);
|
return $this->BelongsToMany(Container::class, ContainerPackingList::class);
|
||||||
|
|||||||
+1
-3
@@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
|
|
||||||
use Spatie\Permission\Traits\HasRoles;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
||||||
|
|
||||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
@@ -25,9 +24,8 @@ class User extends AbstractModel implements
|
|||||||
AuthorizableContract,
|
AuthorizableContract,
|
||||||
CanResetPasswordContract
|
CanResetPasswordContract
|
||||||
{
|
{
|
||||||
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, SoftDeletes;
|
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
|
||||||
|
|
||||||
protected $dates = ['deleted_at'];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the identifier that will be stored in the subject claim of the JWT.
|
* Get the identifier that will be stored in the subject claim of the JWT.
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class CreateTransactionDetailsTable extends Migration
|
|||||||
$table->foreignId('transaction_id')->unsigned();
|
$table->foreignId('transaction_id')->unsigned();
|
||||||
$table->string('reference');
|
$table->string('reference');
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->decimal('quantity', 25, 5)->default(0.00);
|
$table->integer('quantity')->default(0);
|
||||||
$table->decimal('price', 25, 5)->default(0.00);
|
$table->decimal('price', 25, 5)->default(0.00);
|
||||||
$table->decimal('amount', 25, 5)->default(0.00);
|
$table->decimal('amount', 25, 5)->default(0.00);
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class AddDeletedAtToUsersTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::table('users', function (Blueprint $table) {
|
|
||||||
$table->softDeletes();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('users', function (Blueprint $table) {
|
|
||||||
//
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class CreateAddonsTables extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::table('addons', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->morphs('owner');
|
|
||||||
$table->string('reference',200);
|
|
||||||
$table->integer('type')->default(0);
|
|
||||||
$table->integer('quantity')->default(1);
|
|
||||||
$table->integer('status')->default(0);
|
|
||||||
$table->softDeletes();
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('order_addons');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,7 +16,6 @@ use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
|||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||||
@@ -113,7 +112,7 @@ class CompaniesTableSeeder extends Seeder
|
|||||||
/** @var CompanyModule $companyModule */
|
/** @var CompanyModule $companyModule */
|
||||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::FREIGHT_FORWARDER);
|
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::FREIGHT_FORWARDER);
|
||||||
|
|
||||||
$address = new AddressObject('Malaysian Global Innovation & Creativity Center Level 1 CWS', 'Block 3730,Persiaran APEC', 1, 15, 402, 63000, AddressType::BILLING, ApprovalStatus::APPROVED);
|
$address = new AddressObject('Malaysian Global Innovation & Creativity Center Level 1 CWS', 'Block 3730,Persiaran APEC', 1, 15, 402, 63000);
|
||||||
$this->createsAddress->execute($companyModule, $address);
|
$this->createsAddress->execute($companyModule, $address);
|
||||||
|
|
||||||
$contact = new ContactObject('Office Number', '0182909252', '', '');
|
$contact = new ContactObject('Office Number', '0182909252', '', '');
|
||||||
@@ -132,22 +131,22 @@ class CompaniesTableSeeder extends Seeder
|
|||||||
|
|
||||||
if ($name === 'Guangzhou'){
|
if ($name === 'Guangzhou'){
|
||||||
$companyModule->update(['name' => $name, 'reference' => 'GZ-V01']);
|
$companyModule->update(['name' => $name, 'reference' => 'GZ-V01']);
|
||||||
$address = new AddressObject('白云区,大朗南路 白云湖大道自编13号 7号仓库', '高德地图导航:广州市世通行', 2, 35, 633, 510450, AddressType::DELIVERY, ApprovalStatus::APPROVED);
|
$address = new AddressObject('白云区,大朗南路 白云湖大道自编13号 7号仓库', '高德地图导航:广州市世通行', 2, 35, 633, 510450);
|
||||||
$contact = new ContactObject('杨维民', '13600055019', '', '');
|
$contact = new ContactObject('杨维民', '13600055019', '', '');
|
||||||
} elseif ($name === 'Yiwu') {
|
} elseif ($name === 'Yiwu') {
|
||||||
$companyModule->update(['name' => $name, 'reference' => 'YW-V01']);
|
$companyModule->update(['name' => $name, 'reference' => 'YW-V01']);
|
||||||
$address = new AddressObject('义乌市诚信大道义乌港A区2楼194号', '', 2, 27, 532, 322000, AddressType::DELIVERY, ApprovalStatus::APPROVED);
|
$address = new AddressObject('义乌市诚信大道义乌港A区2楼194号', '', 2, 27, 532, 322000);
|
||||||
$contact = new ContactObject('小曾', '13575982901', '', '');
|
$contact = new ContactObject('小曾', '13575982901', '', '');
|
||||||
} elseif ($name === 'Klang') {
|
} elseif ($name === 'Klang') {
|
||||||
$companyModule->update(['name' => $name, 'reference' => 'KL-V01']);
|
$companyModule->update(['name' => $name, 'reference' => 'KL-V01']);
|
||||||
$address = new AddressObject('LOT 1357 A, JALAN TANJUNG SHAWAL', 'KAMPUNG SUNGAI PINANG', 1, 15, 412, 41400, AddressType::DELIVERY, ApprovalStatus::APPROVED);
|
$address = new AddressObject('LOT 1357 A, JALAN TANJUNG SHAWAL', 'KAMPUNG SUNGAI PINANG', 1, 15, 412, 41400);
|
||||||
$contact = new ContactObject('Mr. Yang', '0162237680', '', '');
|
$contact = new ContactObject('Mr. Yang', '0162237680', '', '');
|
||||||
} elseif ($name === 'Sabah') {
|
} elseif ($name === 'Sabah') {
|
||||||
$companyModule->update(['name' => $name, 'reference' => 'SB-V01']);
|
$companyModule->update(['name' => $name, 'reference' => 'SB-V01']);
|
||||||
$address = new AddressObject('Warehouse A & B, No. 2, Lorong Kacang Tanah 1', 'Jalan Kolombong, Kolombong', 1, 13, 316, 88450, AddressType::DELIVERY, ApprovalStatus::APPROVED);
|
$address = new AddressObject('Warehouse A & B, No. 2, Lorong Kacang Tanah 1', 'Jalan Kolombong, Kolombong', 1, 13, 316, 88450);
|
||||||
} elseif ($name === 'Sarawak') {
|
} elseif ($name === 'Sarawak') {
|
||||||
$companyModule->update(['name' => $name, 'reference' => 'SRW-V01']);
|
$companyModule->update(['name' => $name, 'reference' => 'SRW-V01']);
|
||||||
$address = new AddressObject('OPPOSITE HT POLE 51, LT 664 JALAN SUNGAI SALIM', '', 1, 14, 381, 96000, AddressType::DELIVERY, ApprovalStatus::APPROVED);
|
$address = new AddressObject('OPPOSITE HT POLE 51, LT 664 JALAN SUNGAI SALIM', '', 1, 14, 381, 96000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -162,7 +161,7 @@ class CompaniesTableSeeder extends Seeder
|
|||||||
/** @var CompanyModule $companyModule */
|
/** @var CompanyModule $companyModule */
|
||||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, $businessType);
|
$companyModule = $this->createCompanyModuleProcessor->execute($company, $businessType);
|
||||||
|
|
||||||
$address = new AddressObject('2, Jalan TSB 6, Taman Industri Sungai Buloh', '', 1, 15, 419, 47000, AddressType::BILLING, ApprovalStatus::APPROVED);
|
$address = new AddressObject('2, Jalan TSB 6, Taman Industri Sungai Buloh', '', 1, 15, 419, 47000);
|
||||||
$this->createsAddress->execute($companyModule, $address);
|
$this->createsAddress->execute($companyModule, $address);
|
||||||
|
|
||||||
$contact = new ContactObject('Office Number', '036148 8108', '', '');
|
$contact = new ContactObject('Office Number', '036148 8108', '', '');
|
||||||
|
|||||||
@@ -1,147 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Database\Seeders;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Accounts\DataTransferObjects\RegistrationObject;
|
|
||||||
use App\Classes\Modules\Accounts\Services\CreatesUser;
|
|
||||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
|
||||||
use App\Classes\Modules\Addresses\Processors\CreateAddressFromOldAddressProcessor;
|
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
|
||||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
|
||||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
|
||||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
|
||||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
|
||||||
use App\Classes\Modules\Companies\Services\CreatesCompany;
|
|
||||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
|
||||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
|
||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|
||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
|
||||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
||||||
use App\Models\CompanyModule;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Database\Seeder;
|
|
||||||
|
|
||||||
use App\Models\Company;
|
|
||||||
|
|
||||||
class LastMileDeliveryTableSeeder extends Seeder
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var CreateCompanyProcessor */
|
|
||||||
private $createCompanyProcessor;
|
|
||||||
|
|
||||||
/** @var UpdatesCompanyStatus*/
|
|
||||||
private $updatesCompanyStatus;
|
|
||||||
|
|
||||||
/** @var CreateCompanyModuleProcessor */
|
|
||||||
private $createCompanyModuleProcessor;
|
|
||||||
|
|
||||||
/** @var CreateContactProcessor */
|
|
||||||
private $createContactProcessor;
|
|
||||||
|
|
||||||
/** @var CreatesCompanyConnection */
|
|
||||||
private $createsCompanyConnection;
|
|
||||||
|
|
||||||
/** @var ApprovesCompanyConnection */
|
|
||||||
private $approvesCompanyConnection;
|
|
||||||
|
|
||||||
/** @var CreateAddressFromOldAddressProcessor */
|
|
||||||
private $createAddressFromOldAddressProcessor;
|
|
||||||
|
|
||||||
/** @var CreatesAddress */
|
|
||||||
private $createsAddress;
|
|
||||||
|
|
||||||
/** @var CreatesCompany */
|
|
||||||
private $createsCompany;
|
|
||||||
|
|
||||||
/** @var CreatesContact */
|
|
||||||
private $createsContact;
|
|
||||||
|
|
||||||
/** @var CreatesUser */
|
|
||||||
private $createsUser;
|
|
||||||
|
|
||||||
/** @var AssignEmployeeProcessor */
|
|
||||||
private $assignEmployeeProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LastMileDeliveryTableSeeder constructor.
|
|
||||||
* @param CreateCompanyProcessor $createCompanyProcessor
|
|
||||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
|
||||||
* @param CreateCompanyModuleProcessor $createCompanyModuleProcessor
|
|
||||||
* @param CreateContactProcessor $createContactProcessor
|
|
||||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
|
||||||
* @param ApprovesCompanyConnection $approvesCompanyConnection
|
|
||||||
* @param CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor
|
|
||||||
* @param CreatesAddress $createsAddress
|
|
||||||
* @param CreatesCompany $createsCompany
|
|
||||||
* @param CreatesContact $createsContact
|
|
||||||
* @param CreatesUser $createsUser
|
|
||||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
|
||||||
*/
|
|
||||||
public function __construct(CreateCompanyProcessor $createCompanyProcessor, UpdatesCompanyStatus $updatesCompanyStatus, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, CreateAddressFromOldAddressProcessor $createAddressFromOldAddressProcessor, CreatesAddress $createsAddress, CreatesCompany $createsCompany, CreatesContact $createsContact, CreatesUser $createsUser, AssignEmployeeProcessor $assignEmployeeProcessor)
|
|
||||||
{
|
|
||||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
|
||||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
|
||||||
$this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
|
|
||||||
$this->createContactProcessor = $createContactProcessor;
|
|
||||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
|
||||||
$this->approvesCompanyConnection = $approvesCompanyConnection;
|
|
||||||
$this->createAddressFromOldAddressProcessor = $createAddressFromOldAddressProcessor;
|
|
||||||
$this->createsAddress = $createsAddress;
|
|
||||||
$this->createsCompany = $createsCompany;
|
|
||||||
$this->createsContact = $createsContact;
|
|
||||||
$this->createsUser = $createsUser;
|
|
||||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the database seeds.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
||||||
*/
|
|
||||||
public function run()
|
|
||||||
{
|
|
||||||
|
|
||||||
$companies = [
|
|
||||||
new CompanyObject('Last Mile Delivery', 'HWT', CompanyType::COMPANY_BUSINESS, ApprovalStatus::APPROVED),
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($companies as $companyObject) {
|
|
||||||
|
|
||||||
/** @var Company $company */
|
|
||||||
$company = $this->createsCompany->execute($companyObject);
|
|
||||||
|
|
||||||
/** @var CompanyModule $companyModule */
|
|
||||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::LAST_MILE_DELIVERY_AGENT);
|
|
||||||
|
|
||||||
$address = new AddressObject('B-39-13, Menara Simfoni, Jalan Simfoni 2, Balakong', 'Block 3730,Persiaran APEC', 1, 15, 432, 43300, AddressType::BILLING, ApprovalStatus::APPROVED);
|
|
||||||
$this->createsAddress->execute($companyModule, $address);
|
|
||||||
|
|
||||||
$contact = new ContactObject('Office Number', '01155543194', '', '');
|
|
||||||
$this->createsContact->execute($companyModule, $contact);
|
|
||||||
|
|
||||||
$user_object = new RegistrationObject('CQ', 'hywavetech168@gmail.com', 'FIzxqcZFFob7btVLEfWC', 'FIzxqcZFFob7btVLEfWC', RoleTypes::USER, ApprovalStatus::APPROVED);
|
|
||||||
|
|
||||||
/** @var User $user */
|
|
||||||
$user = $this->createsUser->execute($user_object);
|
|
||||||
|
|
||||||
$Object = new EmploymentObject($companyModule, $user);
|
|
||||||
$this->assignEmployeeProcessor->execute($Object);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,6 @@ use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
|||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||||
@@ -105,10 +104,10 @@ class ModernWarehouseTableSeeder extends Seeder
|
|||||||
|
|
||||||
/** @var CompanyModule $companyModule */
|
/** @var CompanyModule $companyModule */
|
||||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::WAREHOUSE);
|
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::WAREHOUSE);
|
||||||
$companyModule->update(['name' => 'Guangzhou', 'reference' => 'GZ-V02']);
|
$companyModule->update(['name' => 'Yiwu', 'reference' => 'YW-V02']);
|
||||||
|
|
||||||
$address = new AddressObject('广东省 广州市 白云区 江高镇松岗街七横63号', '', 2, 35, 633, 510450, AddressType::BILLING, ApprovalStatus::APPROVED);
|
$address = new AddressObject('义乌市 后宅街道 起航路233号百汇科创园园区里面', '(进口处进来第一个路口左转至出口处右手边国际物流仓库)', 2, 27, 532, 322000);
|
||||||
$contact = new ContactObject('郑先生', '13719211997', '', '');
|
$contact = new ContactObject('韩成名', '18058489899 / 18058929899', '', '');
|
||||||
|
|
||||||
$this->createsAddress->execute($companyModule, $address);
|
$this->createsAddress->execute($companyModule, $address);
|
||||||
$this->createsContact->execute($companyModule, $contact);
|
$this->createsContact->execute($companyModule, $contact);
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 50 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user