mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
406 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fbb61f74b4 | |||
| 9398e981fe | |||
| 0f0e99af35 | |||
| da1c653570 | |||
| f86f129949 | |||
| ec24033209 | |||
| e3dd8440df | |||
| 7647dc0e23 | |||
| 3bfb67b55a | |||
| a26368b728 | |||
| a1a9ffa0aa | |||
| c3050445e1 | |||
| 3620e4c4b5 | |||
| 3dafe41c33 | |||
| e28cc43b18 | |||
| 80873a14e2 | |||
| 799936fd8b | |||
| c6d4a6ffae | |||
| bc5a8bce47 | |||
| 2c03e68242 | |||
| 857004a6a5 | |||
| f155186718 | |||
| 35b2d526ed | |||
| 7e7290acc5 | |||
| 5256d5b2f9 | |||
| e8c33e46c4 | |||
| 5afd37652c | |||
| aeb0dfb025 | |||
| 1a591c0404 | |||
| 22c07b19ad | |||
| 9d2dceab2e | |||
| d00be021bc | |||
| 45103f37fd | |||
| 047f58b391 | |||
| 42883b3723 | |||
| 634d4b8b7d | |||
| 6255936cd1 | |||
| ac1fc3103b | |||
| cf6bebcde2 | |||
| a6fc5dd1a5 | |||
| fa88ffca49 | |||
| 2b6a2810e5 | |||
| c67ee25654 | |||
| f1cde19261 | |||
| b7e5475014 | |||
| a75c05fdae | |||
| 3327b8a4f5 | |||
| 604413d978 | |||
| a25feacf53 | |||
| 1090de9060 | |||
| 1c721f7f10 | |||
| 4813c54e6d | |||
| b79ecdc6a9 | |||
| 7fa70becde | |||
| 57a0ea535a | |||
| f84415ce89 | |||
| 0b79ff5521 | |||
| d0f209b006 | |||
| 8cec7b436f | |||
| d2468769df | |||
| 884f4b33d1 | |||
| c15f67e304 | |||
| f5ea06e3fe | |||
| b0a2ab08c9 | |||
| feec49318b | |||
| 9977d516e1 | |||
| c9131b3c3d | |||
| 2675fd8704 | |||
| 02c6825c4a | |||
| 908e0a49f9 | |||
| 9252134cc4 | |||
| cf03a032e5 | |||
| 2cb8f9f407 | |||
| ef1759379e | |||
| ad9b983325 | |||
| fc36a193e9 | |||
| 86d26edb72 | |||
| 052218b621 | |||
| da52ddd3ac | |||
| 6cfed45ffe | |||
| a048a79ca8 | |||
| e7afc0bc10 | |||
| 999c29411f | |||
| c5183ac0a7 | |||
| 896a101fad | |||
| 0d6df7ec0c | |||
| dd38f41f47 | |||
| 062b2fb908 | |||
| 7c027ef62f | |||
| 6137012a35 | |||
| c79f4cfdab | |||
| 073f89be12 | |||
| 3752d71b4f | |||
| b82f3b9f45 | |||
| 3f73848c18 | |||
| 63aae14b28 | |||
| aae9f160e6 | |||
| ba61f7f3ab | |||
| 4a3b3344e7 | |||
| ae42e1e03b | |||
| 8ba5f95690 | |||
| 04117754db | |||
| 821a39e5ff | |||
| 05cb3dd35e | |||
| 70cc67a559 | |||
| 149376e4b5 | |||
| d5dd880d9e | |||
| fa628e81ac | |||
| 51a6569cf0 | |||
| 886f091f6a | |||
| b22b4c374a | |||
| 2b065cb4a8 | |||
| bcf7ae4098 | |||
| b355df27db | |||
| c33649fda2 | |||
| 4615843e17 | |||
| 40f51a0f60 | |||
| 2c3dff7e77 | |||
| 8178cda2b4 | |||
| 04215916f5 | |||
| 5b5bf1bb06 | |||
| 3d7090758d | |||
| e546825520 | |||
| 25f9db99c7 | |||
| 04f248e88d | |||
| 70e53c197c | |||
| 642731b680 | |||
| 7bd3ae056d | |||
| e58805a023 | |||
| fdce49ea82 | |||
| 90a0c4ddf5 | |||
| f963b012ec | |||
| d8289599c9 | |||
| 7965398c5a | |||
| a1b5737935 | |||
| 72400f2ab2 | |||
| 6badfadd2d | |||
| b9a65005e6 | |||
| 190ed6c5f9 | |||
| 7c96f3039a | |||
| fbb7d31726 | |||
| 3d1fb48cfb | |||
| f2e944cc0b | |||
| 44d7507cbd | |||
| 0a32d64e8d | |||
| f1edf72fb8 | |||
| c85248bc0f | |||
| 1aad4de653 | |||
| ae031078bc | |||
| d5d2a13e31 | |||
| 6809bfc693 | |||
| a21465992f | |||
| f844f5d879 | |||
| 959e5dc970 | |||
| 149469598e | |||
| fce976ff6b | |||
| 4b0e1b4b78 | |||
| e6f13fd3d0 | |||
| f6af7c5f4f | |||
| 6ea51d56c1 | |||
| b36313e24c | |||
| f2422ea45c | |||
| d26c90136b | |||
| c10e78ad51 | |||
| 8a40ea35ee | |||
| 19d0802d0e | |||
| 95bd1ca6af | |||
| e6c42ef55c | |||
| a9c914b41c | |||
| c00239c959 | |||
| b4844874bb | |||
| 1b3c63e05d | |||
| c3b0e55271 | |||
| 9463bc9478 | |||
| e4c8c021ec | |||
| 46891669f1 | |||
| c281beb87a | |||
| 500917fbba | |||
| 9af8dd0d0e | |||
| 2895acc8fc | |||
| 33cd2cef7d | |||
| d2485eaae7 | |||
| 0a5aa9843d | |||
| 0dbdeba0d2 | |||
| fbd108e8e8 | |||
| 52ec457b52 | |||
| f159bf7982 | |||
| 5386700762 | |||
| 5aefef5366 | |||
| 0d53a61f18 | |||
| 943ec5f7f7 | |||
| 6d0e7dd51d | |||
| 647103f387 | |||
| 9340d4360e | |||
| ebbe2c7863 | |||
| 73dbb41044 | |||
| 3dfceeaf37 | |||
| 509f14c790 | |||
| 33a8d370c5 | |||
| ad4b8a821c | |||
| 6c276b59b1 | |||
| b57a511bb6 | |||
| 8314820204 | |||
| a2cc1e5e4f | |||
| 17fb297942 | |||
| b12da6ff44 | |||
| cf78e92c5f | |||
| 7db7553dca | |||
| fa1871d712 | |||
| 16b35b34b3 | |||
| 33f152ae9c | |||
| 93c9412298 | |||
| c74e2927ad | |||
| 95f52b3a62 | |||
| 24a286a5a2 | |||
| bbc247d67e | |||
| 019073afc5 | |||
| feb04e8498 | |||
| 557d85ef8d | |||
| 1e5df1d64b | |||
| 186d6f71c6 | |||
| 2f11666539 | |||
| 87e9dbe3ec | |||
| 626ba6bbf4 | |||
| 8b5ac008d3 | |||
| ccd7d91076 | |||
| 7bde77036d | |||
| bf7443887c | |||
| 933f39d280 | |||
| 463d342441 | |||
| 27e856bc4d | |||
| 8f381b42f3 | |||
| 1af45e5132 | |||
| 6c5bbf842e | |||
| 96d701bc80 | |||
| 9221bd094c | |||
| c76271d8ab | |||
| 26a0bc186e | |||
| 2305ddb39d | |||
| c66273874d | |||
| 9ef636c5d5 | |||
| 9b9292546b | |||
| 2974fe4e9a | |||
| e93da67ec1 | |||
| 7c14b74dd1 | |||
| b9b05dfdbe | |||
| e5e00bb9ac | |||
| c6e222caf2 | |||
| 973ab58818 | |||
| 592e8c489b | |||
| ee77fd236a | |||
| 2ae879fd51 | |||
| ee87443ca4 | |||
| 31105cfcef | |||
| 5d34201579 | |||
| 8e9db507f6 | |||
| 943f5ce64e | |||
| 2c3ea9e3f1 | |||
| f385407804 | |||
| a69ecc2825 | |||
| d13aad9566 | |||
| 579200fd61 | |||
| 37d06798aa | |||
| 09a3654e2f | |||
| 1c5fbec0b9 | |||
| c8820ad39e | |||
| 4122ac4153 | |||
| 6959370b7a | |||
| d7b4e716d8 | |||
| d7f3b656f7 | |||
| 3b20e240ee | |||
| aa39adaeb8 | |||
| f0ebd20c5e | |||
| 0b3ae1f8df | |||
| 27684a2940 | |||
| ed637739cc | |||
| a0531e344c | |||
| 9073d86859 | |||
| ce20a941cd | |||
| b98ab2749a | |||
| 5363034649 | |||
| e83ed7a339 | |||
| 09f598ffe5 | |||
| 9719f1da77 | |||
| 0c63a9e7ca | |||
| 7d332f01e5 | |||
| 24ea9d381e | |||
| 9aec13da74 | |||
| 16573e9e00 | |||
| 8039446db5 | |||
| a8e26c4dd6 | |||
| 65493e6c90 | |||
| 36018f48b4 | |||
| bf07a92873 | |||
| fd8d9bd0db | |||
| 5b105caf0b | |||
| 1c5d814790 | |||
| c7b4b75982 | |||
| fbfe68c1c2 | |||
| 06b1258b55 | |||
| b668708bd5 | |||
| 13719d56a4 | |||
| 26b4f012a8 | |||
| ad2d54cf0e | |||
| e84f9d8bef | |||
| d7e2366fed | |||
| f7c6873316 | |||
| b8a145cb5c | |||
| b5076a6f9d | |||
| 2f6055c577 | |||
| 05ee6b3e98 | |||
| 4626eb937e | |||
| 2be9a3dcfe | |||
| 1f05c4b56f | |||
| a3ecda8f8e | |||
| 174992cc65 | |||
| 3e23fa6809 | |||
| 41554be892 | |||
| a7c6c29c25 | |||
| 31c0b315b0 | |||
| 465c111bf1 | |||
| 0884bcf47a | |||
| 64f108163a | |||
| e80dbf4b49 | |||
| a203c5bf12 | |||
| 18b19fd90a | |||
| 2d1ec679eb | |||
| e43f7e2880 | |||
| 335a9f845e | |||
| a5c652ef91 | |||
| 00c9fbfdca | |||
| 69180ef937 | |||
| bcffe4ef3e | |||
| b9794c8ff3 | |||
| 47f00e135b | |||
| f0c5ea8617 | |||
| 688832445a | |||
| f064ef2eff | |||
| c652d8df1a | |||
| fa5f129af0 | |||
| 06ac4c4e62 | |||
| b57f56dd8f | |||
| 1939f64cdf | |||
| 1ba5282244 | |||
| 1c9fba7f19 | |||
| 512cca3445 | |||
| 54211a5b72 | |||
| ade8b0fe4f | |||
| 3d46895328 | |||
| 9970277411 | |||
| d77c0b1c06 | |||
| ea08d1d998 | |||
| d6915bc22f | |||
| b4215a5bde | |||
| ac3e6fba20 | |||
| ee30ebb05d | |||
| f21eb73f4a | |||
| aa26fb97a0 | |||
| 502b702a0a | |||
| e426550c73 | |||
| fab262a959 | |||
| e9b8815f08 | |||
| 8dab2a09ff | |||
| a4b2e02ec3 | |||
| 97adb6b03d | |||
| a531361514 | |||
| b24fbc36f9 | |||
| 600a154714 | |||
| 0a4753579c | |||
| 5c021a4e2e | |||
| 0045fc22e6 | |||
| 77e3641be9 | |||
| 536833fd93 | |||
| f6115c4012 | |||
| 5e416f1760 | |||
| d23b59b8e9 | |||
| 9a047faece | |||
| c6865bb5f6 | |||
| cdaa395824 | |||
| c96a2b71d1 | |||
| 102905df06 | |||
| 7f8a4af3fe | |||
| a2f4e1f3fd | |||
| 1933030e9a | |||
| 50cbafce25 | |||
| 91c8424dc5 | |||
| 6009e82994 | |||
| 7d67e13b9e | |||
| 0554cc895f | |||
| b9ab2e9f36 | |||
| 51d999e3c8 | |||
| b049c95ca2 | |||
| 3ee8afc4a4 | |||
| 1edcb296f3 | |||
| 51f1b3adcb | |||
| 8e05c287b8 | |||
| 050dc8ac7b | |||
| 842fc52b4e | |||
| 7008a01b11 | |||
| afcb1277f1 | |||
| 2d49f4aabf | |||
| 2095c18871 | |||
| e0405bca1e | |||
| 6fb5d66631 | |||
| 5a043e89a0 | |||
| 3c20386875 |
@@ -51,3 +51,5 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
+2
-1
@@ -24,4 +24,5 @@ db/*
|
||||
docker-compose.yml
|
||||
package-lock.json
|
||||
public/*
|
||||
/public/*
|
||||
/public/*
|
||||
storage/framework/laravel-excel/*
|
||||
|
||||
@@ -43,4 +43,4 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CreatedAfter implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('created_at', '>', Carbon::parse($value));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class HasPendingDelivery implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $value ? $builder->whereHas('packingLists', function (Builder $query) use($value) {
|
||||
$query->whereDoesntHave('transports');
|
||||
}) : $builder->whereDoesntHave('packingLists', function (Builder $query) use($value) {
|
||||
$query->whereDoesntHave('transports');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PackingListStatus implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('packing_lists.status', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PackingListType implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('packing_lists.type', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class Reference implements Filter
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('Reference', '=', $value);
|
||||
return $builder->where('reference', '=', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ReferenceLike implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('reference', 'LIKE', '%'.$value.'%');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class WithArrivalDate implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->leftJoin('transport_arrangements', function ($join) {
|
||||
$join->on('packing_lists.id', '=', 'transport_arrangements.owner_id')->where('transport_arrangements.owner_type', 'App\Models\PackingList');
|
||||
})->addSelect(['packing_lists.*', DB::raw('transport_arrangements.drop_date as arrival_date')]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithConfirmedOrders implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('parcels');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithOwner implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->with('owner');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithPackingLists implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->with('packingLists');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithoutConfirmedOrders implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDoesntHave('parcels');
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Packable
|
||||
{
|
||||
|
||||
public function packingLists(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Remarkable
|
||||
{
|
||||
|
||||
public function remarks(): morphMany;
|
||||
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class CurlContainerListJob implements ShouldQueue
|
||||
$last_two_month = Carbon::now()->subMonth(2)->format('Y-m-d');
|
||||
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', [\GuzzleHttp\RequestOptions::JSON => json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":' . $this->page . ',"PageSize":10,"PageOffset":0,"SortExpression":"CreatedOn DESC","GroupExpression":"","Filter":["LoadedTime:<=%js%\"' . $last_two_month . 'T00:00:00.000\"\u0000"],"ContextKey":"view1","FilterIsExternal":false,"LookupContextFieldName":null,"LookupContextController":null,"LookupContextView":null,"LookupContext":null,"Inserting":false,"LastCommandName":null,"ExternalFilter":[],"DoesNotRequireData":false,"LastView":"grid1","Tag":null,"RequiresFirstLetters":false,"ViewType":"Grid","SupportsCaching":true,"SystemFilter":null,"RequiresRowCount":true,"QuickFindHint":null,"RequiresPivot":false,"PivotDefinitions":null,"RequiresMetaData":true}}')]);
|
||||
$res = $client->post('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', [\GuzzleHttp\RequestOptions::JSON => json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":' . $this->page . ',"PageSize":10,"PageOffset":0,"SortExpression":"CreatedOn DESC","GroupExpression":"","Filter":["LoadedTime:<=%js%\"' . $last_two_month . 'T00:00:00.000\"\u0000"],"ContextKey":"view1","FilterIsExternal":false,"LookupContextFieldName":null,"LookupContextController":null,"LookupContextView":null,"LookupContext":null,"Inserting":false,"LastCommandName":null,"ExternalFilter":[],"DoesNotRequireData":false,"LastView":"grid1","Tag":null,"RequiresFirstLetters":false,"ViewType":"Grid","SupportsCaching":true,"SystemFilter":null,"RequiresRowCount":true,"QuickFindHint":null,"RequiresPivot":false,"PivotDefinitions":null,"RequiresMetaData":true}}')]);
|
||||
|
||||
$data = json_decode($res->getBody()->getContents());
|
||||
|
||||
@@ -63,7 +63,7 @@ class CurlContainerListJob implements ShouldQueue
|
||||
{
|
||||
// get latest cookies
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
$r = $client->request('GET', 'https://portalvt.azurewebsites.net');
|
||||
$r = $client->request('GET', 'http://portal.vtnation.com.my');
|
||||
$call_cookie = $client->getConfig('cookies');
|
||||
$call_cookie = $call_cookie->toArray();
|
||||
$latest_cookie = [];
|
||||
@@ -79,7 +79,7 @@ class CurlContainerListJob implements ShouldQueue
|
||||
'Cookie' => $latest_cookie,
|
||||
];
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login', [\GuzzleHttp\RequestOptions::JSON => [
|
||||
$res = $client->post('http://portal.vtnation.com.my/Services/DataControllerService.asmx/Login', [\GuzzleHttp\RequestOptions::JSON => [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
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;
|
||||
|
||||
class CreateInvitedCustomerLogic 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 CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var AssignEmployeeProcessor */
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/** @var AuthenticationProcessor */
|
||||
private $authenticationProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CreateInvitedCustomerLogic constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param AuthenticationProcessor $authenticationProcessor
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateContactProcessor $createContactProcessor, FetchesCompany $fetchesCompany, AssignEmployeeProcessor $assignEmployeeProcessor, AuthenticationProcessor $authenticationProcessor)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->authenticationProcessor = $authenticationProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 Company $company */
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $company->companyModules()->first();
|
||||
|
||||
if($companyModule->employees()->exists()){
|
||||
throw new AccessForbiddenException('This company\'s account has been claimed by another user already!');
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->createUserProcessor->execute($request, RoleTypes::USER, !App::environment(['production']) ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
$contactObject = new ContactObject($request->input('name'), $request->input('phone'), $request->input('contact_email'), $request->input('wechat_id'));
|
||||
|
||||
$this->createContactProcessor->execute($contactObject, $company);
|
||||
|
||||
$Object = new EmploymentObject($companyModule, $user);
|
||||
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
|
||||
return $this->response($this->authenticationProcessor->execute($request));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Accounts\Processors\CrossAuthenticationProcessor;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CrossAuthenticateUserLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Cross Authentication',
|
||||
'message' => 'You have successfully logged in to your account'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CrossAuthenticationProcessor */
|
||||
private $crossAuthenticationProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CrossAuthenticateUserLogic constructor.
|
||||
* @param CrossAuthenticationProcessor $authenticationProcessor
|
||||
*/
|
||||
public function __construct(CrossAuthenticationProcessor $crossAuthenticationProcessor)
|
||||
{
|
||||
$this->crossAuthenticationProcessor = $crossAuthenticationProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
return $this->response($this->crossAuthenticationProcessor->execute($request));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,6 @@ class LogoutUserLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function __construct(InvalidatesAuthenticationToken $invalidatesAuthenticationToken)
|
||||
{
|
||||
logger("logout user logic");
|
||||
$this->invalidatesAuthenticationToken = $invalidatesAuthenticationToken;
|
||||
}
|
||||
|
||||
@@ -37,7 +36,6 @@ class LogoutUserLogic extends AbstractControllerLogic
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
|
||||
logger("logout");
|
||||
$this->invalidatesAuthenticationToken->execute();
|
||||
|
||||
return $this->response();
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class CrossAuthenticationCredentialsObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $access_token;
|
||||
|
||||
/** @var string */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* CrossAuthenticationCredentialsObject constructor.
|
||||
* @param string $access_token
|
||||
* @param string $platform
|
||||
*/
|
||||
public function __construct(string $access_token, int $platform)
|
||||
{
|
||||
$this->access_token = $access_token;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessToken(): string
|
||||
{
|
||||
return $this->access_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPlatform(): int
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Models\User;
|
||||
|
||||
class UserSocialAccountObject implements DataTransferObject
|
||||
{
|
||||
/** @var String */
|
||||
private $app_id;
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/** @var integer */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* UserSocialAccountObject constructor.
|
||||
* @param String $token
|
||||
* @param String $app_id
|
||||
*/
|
||||
public function __construct(String $app_id, User $user, int $platform)
|
||||
{
|
||||
$this->app_id = $app_id;
|
||||
$this->user = $user;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAppId(): String
|
||||
{
|
||||
return $this->app_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPlatform(): int
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Processors;
|
||||
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserSocialAccountObject;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\CrossAuthenticatesUser;
|
||||
use App\Classes\Modules\Accounts\Services\AuthenticationRedirect;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationToken;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanCrossAuthenticateUser;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||
use App\Classes\General\Services\GeneratesInitials;
|
||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesUserSocialAccount;
|
||||
|
||||
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 Illuminate\Http\Request;
|
||||
use App\Models\UserSocialAccount;
|
||||
|
||||
class CrossAuthenticationProcessor
|
||||
{
|
||||
|
||||
/** @var CanCrossAuthenticateUser */
|
||||
private $canCrossAuthenticateUser;
|
||||
|
||||
/** @var CrossAuthenticatesUser */
|
||||
private $authenticatesUser;
|
||||
|
||||
/** @var GeneratesAuthenticationToken */
|
||||
private $generatesAuthenticationToken;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/** @var AuthenticationRedirect */
|
||||
private $authenticationRedirect;
|
||||
|
||||
/** @var CreateUserProcessor */
|
||||
private $createUserProcessor;
|
||||
|
||||
/** @var CreateCompanyProcessor */
|
||||
private $createCompanyProcessor;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateCompanyModuleProcessor */
|
||||
private $createCompanyModuleProcessor;
|
||||
|
||||
/** @var CreatesCompanyConnection */
|
||||
private $createsCompanyConnection;
|
||||
|
||||
/** @var ApprovesCompanyConnection */
|
||||
private $approvesCompanyConnection;
|
||||
|
||||
/** @var AssignEmployeeProcessor */
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/** @var UploadIdentityDocumentProcessor */
|
||||
private $uploadIdentityDocumentProcessor;
|
||||
|
||||
/** @var CreatesUserSocialAccount */
|
||||
private $createsUserSocialAccount;
|
||||
|
||||
/**
|
||||
* CrossAuthenticationProcessor constructor.
|
||||
* @param CanCrossAuthenticateUser $canCrossAuthenticateUser
|
||||
* @param CrossAuthenticatesUser $crossAuthenticatesUser
|
||||
* @param GeneratesAuthenticationToken $generatesAuthenticationToken
|
||||
* @param FetchesUser $fetchesUser
|
||||
* @param AuthenticationRedirect $authenticationRedirect
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
* @param CreateCompanyProcessor $createCompanyProcessor
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreateCompanyModuleProcessor $createCompanyModuleProcessor
|
||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
||||
* @param ApprovesCompanyConnection $approvesCompanyConnection
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor
|
||||
* @param CreatesUserSocialAccount $createsUserSocialAccount
|
||||
*/
|
||||
public function __construct(
|
||||
CanCrossAuthenticateUser $canCrossAuthenticateUser,
|
||||
CrossAuthenticatesUser $crossAuthenticatesUser,
|
||||
GeneratesAuthenticationToken $generatesAuthenticationToken,
|
||||
FetchesUser $fetchesUser,
|
||||
AuthenticationRedirect $authenticationRedirect,
|
||||
CreateUserProcessor $createUserProcessor,
|
||||
CreateCompanyProcessor $createCompanyProcessor,
|
||||
CreateContactProcessor $createContactProcessor,
|
||||
CreateCompanyModuleProcessor $createCompanyModuleProcessor,
|
||||
CreatesCompanyConnection $createsCompanyConnection,
|
||||
ApprovesCompanyConnection $approvesCompanyConnection,
|
||||
AssignEmployeeProcessor $assignEmployeeProcessor,
|
||||
UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor,
|
||||
CreatesUserSocialAccount $createsUserSocialAccount
|
||||
)
|
||||
{
|
||||
$this->canCrossAuthenticateUser = $canCrossAuthenticateUser;
|
||||
$this->crossAuthenticatesUser = $crossAuthenticatesUser;
|
||||
$this->generatesAuthenticationToken = $generatesAuthenticationToken;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
$this->authenticationRedirect = $authenticationRedirect;
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->approvesCompanyConnection = $approvesCompanyConnection;
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->uploadIdentityDocumentProcessor = $uploadIdentityDocumentProcessor;
|
||||
$this->createsUserSocialAccount = $createsUserSocialAccount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request): array {
|
||||
|
||||
$object = new CrossAuthenticationCredentialsObject($request->input('access_token'), $request->input('platform'));
|
||||
|
||||
$this->canCrossAuthenticateUser->passes($object);
|
||||
|
||||
$cross = $this->crossAuthenticatesUser->execute($object);
|
||||
|
||||
$user_social_account = UserSocialAccount::where('app_id', $cross->token->user->id)->first();
|
||||
if (!$user_social_account) {
|
||||
|
||||
$request->request->add([
|
||||
'name' => $cross->token->user->name,
|
||||
'email' => $cross->token->user->email,
|
||||
'password' => 'pass123',
|
||||
'password_confirmation' => 'pass123',
|
||||
]);
|
||||
|
||||
$user = $this->createUserProcessor->execute(
|
||||
$request,
|
||||
RoleTypes::USER,
|
||||
env('APP_ENV') != 'production' ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION
|
||||
);
|
||||
|
||||
$company = $this->createCompanyProcessor->execute(
|
||||
$cross->payload->data->name,
|
||||
CompanyType::COMPANY_BUSINESS,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
$contactObject = new ContactObject(
|
||||
$cross->payload->data->contact->reference,
|
||||
$cross->payload->data->contact->phone,
|
||||
$cross->payload->data->contact->email,
|
||||
$cross->payload->data->contact->wechat_id
|
||||
);
|
||||
$contact = $this->createContactProcessor->execute($contactObject, $company);
|
||||
|
||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::IMPORTER);
|
||||
|
||||
$connectionObject = new CompanyConnectionObject(
|
||||
$companyModule, 'CIEF',
|
||||
mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate()
|
||||
);
|
||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
|
||||
$this->approvesCompanyConnection->execute($connection);
|
||||
|
||||
$object = new EmploymentObject($companyModule, $user);
|
||||
$this->assignEmployeeProcessor->execute($object);
|
||||
|
||||
$request->request->add([
|
||||
'files' => [$cross->document->src],
|
||||
'identification_no' => $cross->payload->data->identification->reference,
|
||||
]);
|
||||
|
||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
|
||||
$object = new UserSocialAccountObject(
|
||||
$cross->token->user->id,
|
||||
$user,
|
||||
$request->input('platform')
|
||||
);
|
||||
$this->createsUserSocialAccount->execute($object);
|
||||
}
|
||||
else {
|
||||
$user = $user_social_account->user()->first();
|
||||
}
|
||||
|
||||
return ['access_token' => $this->generatesAuthenticationToken->execute($user), 'redirect_url' => $this->authenticationRedirect->url($user)];
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -56,4 +56,4 @@ class GenerateEmailVerificationAttemptProcessor
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserSocialAccountObject;
|
||||
use App\Models\UserSocialAccount;
|
||||
|
||||
class CreatesUserSocialAccount extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param UserSocialAccountObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(UserSocialAccountObject $object) {
|
||||
$model = new UserSocialAccount();
|
||||
$model->user_id = $object->getUser()->id;
|
||||
$model->app_id = $object->getAppId();
|
||||
$model->platform = $object->getPlatform();
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\AccessUnauthorisedException;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
|
||||
use App\Classes\ValueObjects\Constants\PlatformType;
|
||||
|
||||
class CrossAuthenticatesUser
|
||||
{
|
||||
|
||||
/**
|
||||
* @param CrossAuthenticationCredentialsObject $object
|
||||
* @return false|string
|
||||
* @throws AccessUnauthorisedException
|
||||
*/
|
||||
|
||||
public function execute(CrossAuthenticationCredentialsObject $object){
|
||||
|
||||
if ($object->getPlatform() == PlatformType::EXCHANGE) {
|
||||
|
||||
$token = $object->getAccessToken();
|
||||
|
||||
$tokenParts = explode(".", $token);
|
||||
$tokenPayload = base64_decode($tokenParts[1]);
|
||||
$jwtPayload = json_decode($tokenPayload);
|
||||
|
||||
$response = Http::withToken($object->getAccessToken())->get(env('EXCHANGE_URL') . 'api/v1/company/' . $jwtPayload->user->company_id . '/show')->object();
|
||||
|
||||
$response_document = Http::withToken($object->getAccessToken())->get(env('EXCHANGE_URL') . 'api/v1/storage/' . $response->payload->data->identification->files[0]->file->file_info[0]->original->file . '/fetch')->object();
|
||||
$response->token = $jwtPayload;
|
||||
$response->document = $response_document->payload;
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\UserSocialAccount;
|
||||
|
||||
class FetchesUserSocialAccount extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var UserSocialAccount */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesUser constructor.
|
||||
* @param UserSocialAccount $repository
|
||||
*/
|
||||
public function __construct(UserSocialAccount $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\AuthenticationCredentialsObject;
|
||||
use App\Classes\Modules\Accounts\Standards\Validators\UserCrossAuthenticationValidation;
|
||||
|
||||
class CanCrossAuthenticateUser extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var UserCrossAuthenticationValidation */
|
||||
private $userCrossAuthenticationValidation;
|
||||
|
||||
/**
|
||||
* CanCrossAuthenticateUser constructor.
|
||||
* @param UserCrossAuthenticationValidation $userCrossAuthenticationValidation
|
||||
*/
|
||||
public function __construct(UserCrossAuthenticationValidation $userCrossAuthenticationValidation)
|
||||
{
|
||||
$this->userCrossAuthenticationValidation = $userCrossAuthenticationValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AuthenticationCredentialsObject $object
|
||||
* @return bool
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->userCrossAuthenticationValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AuthenticationCredentialsObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
|
||||
|
||||
class UserCrossAuthenticationValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param CrossAuthenticationCredentialsObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'access_token' => $object->getAccesstoken(),
|
||||
'platform' => $object->getPlatform()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'access_token' => 'required',
|
||||
'platform' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Classes\Modules\Addresses\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
class AddressObject implements DataTransferObject
|
||||
{
|
||||
@@ -38,7 +39,7 @@ class AddressObject implements DataTransferObject
|
||||
* @param int $postCode
|
||||
* @param null|string $reference
|
||||
*/
|
||||
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode, ?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->streetTwo = $streetTwo;
|
||||
@@ -47,6 +48,7 @@ class AddressObject implements DataTransferObject
|
||||
$this->districtId = $districtId;
|
||||
$this->postCode = $postCode;
|
||||
$this->reference = $reference;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,5 +107,13 @@ class AddressObject implements DataTransferObject
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use App\Classes\Modules\Addresses\Services\CleansOldAddress;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Models\OldAddress;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CreateAddressFromOldAddressProcessor
|
||||
@@ -44,8 +45,8 @@ class CreateAddressFromOldAddressProcessor
|
||||
}
|
||||
|
||||
|
||||
if($address = $addressable->addresses()->where('street_one', $object->getStreetOne())->first()){
|
||||
return $address;
|
||||
if(!$addressable instanceof Order && $address = $addressable->addresses()->where('street_one', $object->getStreetOne())->first()) {
|
||||
return $address;
|
||||
}
|
||||
|
||||
return $this->createsAddress->execute($addressable, $object);
|
||||
|
||||
@@ -28,6 +28,7 @@ class CreatesAddress extends AbstractUpdateRelationshipRecord
|
||||
$model->state_id = $object->getStateId();
|
||||
$model->district_id = $object->getDistrictId();
|
||||
$model->postcode = $object->getPostCode();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($addressable->addresses(), $model);
|
||||
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\AssignConnectionSegmentProcessor;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyConnection;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Assign Company Connection To Connection Segment',
|
||||
'message' => 'You have successfully assigned Company Connection to Connection segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var FetchesCompanyConnection */
|
||||
private $fetchesCompanyConnection;
|
||||
|
||||
/** @var AssignConnectionSegmentProcessor */
|
||||
private $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||
|
||||
/**
|
||||
* AssignCompanyToSegmentLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
||||
* @param AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesCompanyConnection = $fetchesCompanyConnection;
|
||||
$this->assignCompanyConnectionToConnectionSegmentProcessor = $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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->route('id')]);
|
||||
|
||||
$companyConnection = $this->fetchesCompanyConnection->execute(['id' => $request->route('company_connection_id')]);
|
||||
|
||||
$this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company));
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\RemovesCompanyConnectionFromConnectionSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemoveCompanyConnectionFromConnectionSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Detach Company Connection From Connection Segment',
|
||||
'message' => 'You have successfully detached Company Connection from Connection segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var FetchesCompanyConnection */
|
||||
private $fetchesCompanyConnection;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var RemovesCompanyConnectionFromConnectionSegment */
|
||||
private $removesCompanyConnectionFromConnectionSegment;
|
||||
|
||||
/**
|
||||
* RemoveCompanyFromSegmentLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param RemovesCompanyConnectionFromConnectionSegment $removesCompanyConnectionFromConnectionSegment
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, FetchesSegment $fetchesSegment, RemovesCompanyConnectionFromConnectionSegment $removesCompanyConnectionFromConnectionSegment)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesCompanyConnection = $fetchesCompanyConnection;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->removesCompanyConnectionFromConnectionSegment = $removesCompanyConnectionFromConnectionSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$companyConnection = $this->fetchesCompanyConnection->execute(['id' => $request->route('company_connection_id')]);
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('segment_id')]);
|
||||
|
||||
$this->removesCompanyConnectionFromConnectionSegment->execute($companyConnection, $segment);
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\AssignsCompanyConnectionToConnectionSegment;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanAssignSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\CompanyConnection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AssignConnectionSegmentProcessor
|
||||
{
|
||||
|
||||
/** @var CanAssignSegment */
|
||||
private $canAssignSegment;
|
||||
|
||||
/** @var AssignsCompanyConnectionToConnectionSegment */
|
||||
private $assignsCompanyConnectionToConnectionSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/**
|
||||
* AssignCompanyToSegmentProcessor constructor.
|
||||
* @param CanAssignSegment $canAssignSegment
|
||||
* @param AssignsCompanyConnectionToConnectionSegment $assignsCompanyConnectionToConnectionSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(CanAssignSegment $canAssignSegment, AssignsCompanyConnectionToConnectionSegment $assignsCompanyConnectionToConnectionSegment, FetchesSegment $fetchesSegment)
|
||||
{
|
||||
$this->canAssignSegment = $canAssignSegment;
|
||||
$this->assignsCompanyConnectionToConnectionSegment = $assignsCompanyConnectionToConnectionSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CompanyConnection $companyConnection
|
||||
* @param int|null $segmentId
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(CompanyConnection $companyConnection, ?int $segmentId = SegmentConstants::STANDARD_SEGMENT): Model {
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $segmentId]);
|
||||
|
||||
$this->canAssignSegment->passes();
|
||||
|
||||
return $this->assignsCompanyConnectionToConnectionSegment->execute($companyConnection, $segment);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class AssignsCompanyConnectionToConnectionSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param CompanyConnection $companyConnection
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyConnection $companyConnection, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$companyConnection->segments()->attach($segment);
|
||||
|
||||
return $companyConnection;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\CompanyConnection;
|
||||
|
||||
class FetchesCompanyConnection extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var CompanyConnection */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesCompanyConnection constructor.
|
||||
* @param CompanyConnection $repository
|
||||
*/
|
||||
public function __construct(CompanyConnection $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class RemovesCompanyConnectionFromConnectionSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param CompanyConnection $companyConnection
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyConnection $companyConnection, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$companyConnection->segments()->detach($segment);
|
||||
|
||||
return $companyConnection;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class ApproveChangeOrderAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Change Order Address Approval',
|
||||
'message' => 'You have successfully change the order address'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ApproveChangeOrderAddressProcessor */
|
||||
private $approveChangeOrderAddressProcessor;
|
||||
|
||||
/**
|
||||
* ApproveChangeOrderAddressLogic constructor.
|
||||
* @param ApproveChangeOrderAddressProcessor $approveChangeOrderAddressProcessor
|
||||
*/
|
||||
|
||||
public function __construct(ApproveChangeOrderAddressProcessor $approveChangeOrderAddressProcessor)
|
||||
{
|
||||
$this->approveChangeOrderAddressProcessor = $approveChangeOrderAddressProcessor;
|
||||
}
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$address = $this->approveChangeOrderAddressProcessor->execute($request);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\CreatesOrderRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignOrderRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order Remark',
|
||||
'message' => 'You have successfully created a new Order Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesOrderRemark */
|
||||
private $createsOrderRemark;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesOrderRemark $createsOrderRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesOrderRemark $createsOrderRemark, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsOrderRemark = $createsOrderRemark;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject(
|
||||
$request->input('content'),
|
||||
$request->route('id')
|
||||
);
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$query = $this->createsOrderRemark->execute($this->fetchesOrder->execute(['id' => $request->route('id')]), $object);
|
||||
return $this->resourceResponse( new RemarkResource($query));
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -63,6 +64,13 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||
|
||||
if($originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU){
|
||||
$marking = $company->companyModules()->importers()->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
if(in_array($marking, ['2192KAA', '2353GFE', '6866DTR', '1905JYW', '1291NSC', '8288MIB'])){
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::YD_GUANG_ZHOU]);
|
||||
}
|
||||
}
|
||||
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackageProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\GeneratesPackingListReferenceNumber;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
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\Http\Resources\PackingListResource;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateShippingPackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created PackingList',
|
||||
'message' => 'You have successfully created a new PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var GeneratesPackingListReferenceNumber */
|
||||
private $generatesPackingListReferenceNumber;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CreatePackingListLogic constructor.
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(
|
||||
CreatePackingListProcessor $createPackingListProcessor,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule,
|
||||
CreatePackageProcessor $createPackageProcessor,
|
||||
GeneratesPackingListReferenceNumber $generatesPackingListReferenceNumber,
|
||||
FetchesOrder $fetchesOrder
|
||||
)
|
||||
{
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->generatesPackingListReferenceNumber = $generatesPackingListReferenceNumber;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->input('order_id')]);
|
||||
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id,
|
||||
PackingListType::SHIPPING_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$packages = $request->input('packages');
|
||||
|
||||
foreach ($packages as $key => $row) {
|
||||
$packageObject = new PackageObject(
|
||||
$row['type'],
|
||||
$row['description'],
|
||||
$row['width'],
|
||||
$row['height'],
|
||||
$row['length'],
|
||||
$row['weight'],
|
||||
$row['quantity'],
|
||||
ApprovalStatus::APPROVED,
|
||||
$row['reference'],
|
||||
);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packingList));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackageProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\GeneratesPackingListReferenceNumber;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
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\Http\Resources\PackingListResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateWarehousePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Warehouse PackingList',
|
||||
'message' => 'You have successfully created a new Warehouse PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var GeneratesPackingListReferenceNumber */
|
||||
private $generatesPackingListReferenceNumber;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatePackageProcessor */
|
||||
private $createPackageProcessor;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CreatePackingListLogic constructor.
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(
|
||||
CreatePackingListProcessor $createPackingListProcessor,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule,
|
||||
CreatePackageProcessor $createPackageProcessor,
|
||||
GeneratesPackingListReferenceNumber $generatesPackingListReferenceNumber,
|
||||
FetchesOrder $fetchesOrder
|
||||
)
|
||||
{
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->createPackageProcessor = $createPackageProcessor;
|
||||
$this->generatesPackingListReferenceNumber = $generatesPackingListReferenceNumber;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->input('order_id')]);
|
||||
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
$order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id,
|
||||
PackingListType::WAREHOUSE_RECEIVE_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, $request->input('tracking'), Carbon::parse($request->input('receive_date')), Carbon::parse($request->input('receive_date')), ApprovalStatus::APPROVED);
|
||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
||||
|
||||
$scheduleObject = new ScheduleObject(Carbon::parse($request->input('receive_date')), Carbon::parse($request->input('receive_date')), ApprovalStatus::APPROVED);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
$packages = $request->input('packages');
|
||||
|
||||
foreach ($packages as $key => $row) {
|
||||
$packageObject = new PackageObject(
|
||||
$row['type'],
|
||||
$row['description'],
|
||||
$row['width'],
|
||||
$row['height'],
|
||||
$row['length'],
|
||||
$row['weight'],
|
||||
$row['quantity'],
|
||||
ApprovalStatus::APPROVED,
|
||||
$row['reference'],
|
||||
);
|
||||
$this->createPackageProcessor->execute($packageObject, $packingList);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packingList));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class FetchOrderLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canFetchOrder->passes();
|
||||
|
||||
$query = $this->fetchesOrder->execute(['reference' => $request->route('id'), 'with_parcels' => true]);
|
||||
$query = $this->fetchesOrder->execute(['reference' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
return $this->resourceResponse(new OrderResource($query));
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Processors\RequestChangeOrderAddressProcessor;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class RequestChangeOrderAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Request To Change Order Address',
|
||||
'message' => 'You have successfully request to change order address'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var RequestChangeOrderAddressProcessor */
|
||||
private $requestChangeOrderAddressProcessor;
|
||||
|
||||
/**
|
||||
* RequestChangeOrderAddressLogic constructor.
|
||||
* @param RequestChangeOrderAddressProcessor $requestChangeOrderAddressProcessor
|
||||
*/
|
||||
|
||||
public function __construct(RequestChangeOrderAddressProcessor $requestChangeOrderAddressProcessor)
|
||||
{
|
||||
$this->requestChangeOrderAddressProcessor = $requestChangeOrderAddressProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$order = $this->requestChangeOrderAddressProcessor->execute($request);
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesCBM;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesBaseRate;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesSegmentRate;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesStateRate;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesWarehouseRate;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateShippingCostTransactionProcessor;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ShippingCostLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Order Shipping Cost',
|
||||
'message' => 'Order shipping cost calculation done'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CalculateCBM */
|
||||
private $calculateCBM;
|
||||
|
||||
/** @var CalculatesBaseRate */
|
||||
private $calculateBaseRate;
|
||||
|
||||
/** @var CalculatesSegmentRate */
|
||||
private $calculateSegmentRate;
|
||||
|
||||
/** @var CalculatesStateRate */
|
||||
private $calculateStateRate;
|
||||
|
||||
/** @var CalculatesWarehouse */
|
||||
private $calculateWarehouseRate;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var ShippingCostTransactionProcessor */
|
||||
private $shippingCostTransactionProcessor;
|
||||
|
||||
/**
|
||||
* ShippingCostLogic constructor.
|
||||
* @param CalculateCBM $calculateCBM
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(FetchesOrder $fetchesOrder, CalculatesCBM $calculateCBM, CalculatesBaseRate $calculateBaseRate, CalculatesSegmentRate $calculateSegmentRate, CalculatesStateRate $calculateStateRate, CalculatesWarehouseRate $calculateWarehouseRate, CreateShippingCostTransactionProcessor $shippingCostTransactionProcessor)
|
||||
{
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->calculateCBM = $calculateCBM;
|
||||
$this->calculatesBaseRate = $calculateBaseRate;
|
||||
$this->calculatesSegmentRate = $calculateSegmentRate;
|
||||
$this->calculatesStateRate = $calculateStateRate;
|
||||
$this->calculateWarehouseRate = $calculateWarehouseRate;
|
||||
$this->shippingCostTransactionProcessor = $shippingCostTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$order = $this->fetchesOrder->getRepository()->where(['id' => $request->route('id')])->first();
|
||||
|
||||
$baseRate = $this->calculatesBaseRate->execute($order);
|
||||
$segmentRate = $this->calculatesSegmentRate->execute($order, SegmentConstants::STANDARD_SEGMENT) + $this->calculatesSegmentRate->execute($order, SegmentConstants::CUSTOM_SEGMENT);
|
||||
$stateRate = $this->calculatesStateRate->execute($order, false) + $this->calculatesStateRate->execute($order, true);
|
||||
$warehouseRate = $this->calculateWarehouseRate->execute($order);
|
||||
|
||||
$totalShippingCost = 0;
|
||||
$totalCBM = 0;
|
||||
$quantity = 0;
|
||||
foreach($order->parcels as $parcel){
|
||||
$cbm = $this->calculateCBM->execute($order, $parcel);
|
||||
|
||||
if($cbm > 0){
|
||||
$totalCBM += $cbm;
|
||||
$quantity ++;
|
||||
$totalShippingCost += (($segmentRate + $stateRate + $warehouseRate) * $cbm);
|
||||
}
|
||||
}
|
||||
|
||||
$this->shippingCostTransactionProcessor->execute($order, $quantity, round($totalCBM,2), round($totalShippingCost,2));
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanApproveChangeOrderAddress;
|
||||
use App\Classes\Modules\Orders\Services\UpdatesOrdersAddress;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApproveChangeOrderAddressProcessor
|
||||
{
|
||||
/** @var CanApproveChangeOrderAddress */
|
||||
private $canApproveChangeOrderAddress;
|
||||
|
||||
/** @var FetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/** @var UpdatesOrdersAddress */
|
||||
private $updatesOrdersAddress;
|
||||
|
||||
/**
|
||||
* ApproveChangeOrderAddressProcessor constructor.
|
||||
* @param CanApproveChangeOrderAddress $canApproveChangeOrderAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param UpdatesOrdersAddress $updatesOrdersAddress
|
||||
*/
|
||||
public function __construct(CanApproveChangeOrderAddress $canApproveChangeOrderAddress, FetchesAddress $fetchesAddress, UpdatesOrdersAddress $updatesOrdersAddress)
|
||||
{
|
||||
$this->canApproveChangeOrderAddress = $canApproveChangeOrderAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->updatesOrdersAddress = $updatesOrdersAddress;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
|
||||
$status = (int) $request->route('status');
|
||||
|
||||
$this->canApproveChangeOrderAddress->passes();
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||
|
||||
if($status === ApprovalStatus::APPROVED){
|
||||
$address->owner->addresses()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
}
|
||||
|
||||
$this->updatesOrdersAddress->execute($address, $status);
|
||||
|
||||
return $address;
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class CreateOrderRolesProcessor
|
||||
$importer = $order->companyModule;
|
||||
|
||||
/** @var CompanyModule $destinationWarehouse */
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::DESTINATION_WAREHOUSE[$address->state_id ]]);
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::YD_GUANG_ZHOU ? WarehouseReferences::YD_DESTINATION_WAREHOUSE : WarehouseReferences::VT_DESTINATION_WAREHOUSE[$address->state_id]]);
|
||||
|
||||
/** @var CompanyModule $freightForwarder */
|
||||
$freightForwarder = $originWarehouse->company->companyModules()->freightForwarders()->first();
|
||||
@@ -79,32 +79,10 @@ class CreateOrderRolesProcessor
|
||||
$roleObject = new OrderRoleObject($order, $destinationWarehouse, OrderRoleTypes::DESTINATION_WAREHOUSE);
|
||||
$this->createsOrderRole->execute($roleObject);
|
||||
|
||||
|
||||
$roleObject = new OrderRoleObject($order, $freightForwarder, OrderRoleTypes::LAST_MILE_DELIVERY_DRIVER);
|
||||
$this->createsOrderRole->execute($roleObject);
|
||||
|
||||
return true;
|
||||
|
||||
$companies = $this->fetchesCompany->getRepository()->whereIn('id',[1, $request->get('warehouse_id')])->get();
|
||||
|
||||
$cief_company = $companies[0]->id == 1 ? $companies[0] : $companies[1];
|
||||
$warehouse_company = $companies[0]->id != 1 ? $companies[0] : $companies[1];
|
||||
|
||||
$cief_company_module = $cief_company->companyModule()->first();
|
||||
$contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$cief_company_module->unity_hash_id]);
|
||||
$contractEntities[0]->{"company_module_id"} = $cief_company_module->id;
|
||||
|
||||
$warehouse_company_module = $warehouse_company->companyModule()->first();
|
||||
$contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$warehouse_company_module->unity_hash_id]);
|
||||
$contractEntities[1]->{"company_module_id"} = $warehouse_company_module->id;
|
||||
|
||||
foreach($contractEntities as $entity){
|
||||
$order_role_object = new OrderRoleObject($orderId, $entity->company_module_id, $entity->hash_id, $entity->entity_signature_hash_id);
|
||||
|
||||
$this->canCreateOrderRole->passes($order_role_object);
|
||||
|
||||
$this->createsOrderRole->execute($order_role_object);
|
||||
}
|
||||
|
||||
return $contractEntities;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanChangeOrderAddress;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\DeletesAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RequestChangeOrderAddressProcessor
|
||||
{
|
||||
/** @var CanChangeOrderAddress */
|
||||
private $canChangeOrderAddress;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var FetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var DeletesAddress */
|
||||
private $deletesAddress;
|
||||
|
||||
/**
|
||||
* ChangeOrderAddressProcessor constructor.
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param DeletesAddress $deletesAddress
|
||||
*/
|
||||
public function __construct(CanChangeOrderAddress $canChangeOrderAddress, FetchesOrder $fetchesOrder, CreatesAddress $createsAddress, FetchesAddress $fetchesAddress, DeletesAddress $deletesAddress)
|
||||
{
|
||||
|
||||
$this->canChangeOrderAddress = $canChangeOrderAddress;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->deletesAddress = $deletesAddress;
|
||||
}
|
||||
|
||||
|
||||
public function execute(Request $request)
|
||||
{
|
||||
|
||||
$this->canChangeOrderAddress->passes();
|
||||
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->get('order_id')]);
|
||||
foreach ($order->addressesPendingVerification as $address) {
|
||||
$this->deletesAddress->execute($address);
|
||||
}
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->get('address_id')]);
|
||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, $address->reference, ApprovalStatus::PENDING_VERIFICATION);
|
||||
$this->createsAddress->execute($order, $addressObject);
|
||||
|
||||
return $order;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesBaseRate
|
||||
{
|
||||
|
||||
public function execute(Order $order){
|
||||
return 300;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use App\Models\Package;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesCBM
|
||||
{
|
||||
|
||||
public function execute(Order $order, Package $parcel){
|
||||
return $parcel->length * $parcel->width * $parcel->height;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesSegmentRate
|
||||
{
|
||||
|
||||
public function execute(Order $order, int $segmentRates){
|
||||
return ($segmentRates == SegmentConstants::STANDARD_SEGMENT) ? 300 : (
|
||||
(($segmentRates == SegmentConstants::CUSTOM_SEGMENT) ? -20 : 0)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesStateRate
|
||||
{
|
||||
|
||||
public function execute(Order $order, $isOutskirt=false){
|
||||
return ($isOutskirt) ? 20 : 40;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesWarehouseRate
|
||||
{
|
||||
|
||||
public function execute(Order $order){
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Models\Remark;
|
||||
use App\Models\Order;
|
||||
|
||||
class CreatesOrderRemark extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param RemarkObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Order $order, RemarkObject $object) {
|
||||
$model = new Remark();
|
||||
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->content = $object->getContent();
|
||||
|
||||
return $this->handler($order->remarks(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class FetchesDataFromVTPortal
|
||||
$latest_cookie = [];
|
||||
$cookieRequest = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
|
||||
$cookieRequest->get('https://portalvt.azurewebsites.net');
|
||||
$cookieRequest->get('http://portal.vtnation.com.my');
|
||||
foreach ($cookieRequest->getConfig('cookies')->toArray() as $key => $row) {
|
||||
$latest_cookie[] = $row['Name'] . '=' . $row['Value'];
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class FetchesDataFromVTPortal
|
||||
|
||||
|
||||
/** @var $loginRequest */
|
||||
$loginRequest = $this->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login', 'POST', [
|
||||
$loginRequest = $this->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/Login', 'POST', [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Address;
|
||||
|
||||
class UpdatesOrdersAddress extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Address $address
|
||||
* @param int $type
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Address $address, int $type)
|
||||
{
|
||||
$address->status = $type;
|
||||
return $this->handler($address);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Orders\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
|
||||
class CanApproveChangeOrderAddress extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Orders\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
|
||||
class CanChangeOrderAddress extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingListRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignPackingListRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Packing List Remark',
|
||||
'message' => 'You have successfully created a new Packing List Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesPackingListRemark */
|
||||
private $createsPackingListRemark;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesPackingListRemark $createsPackingListRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesPackingListRemark $createsPackingListRemark, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsPackingListRemark = $createsPackingListRemark;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject(
|
||||
$request->input('content'),
|
||||
$request->route('id')
|
||||
);
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$query = $this->createsPackingListRemark->execute($this->fetchesPackingList->execute(['id' => $request->route('id')]), $object);
|
||||
return $this->resourceResponse( new RemarkResource($query));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingListStatus;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CompletePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated PackingList',
|
||||
'message' => 'You have successfully updated the PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesPackingListStatus */
|
||||
private $updatesPackingListStatus;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* CompletePackingListLogic constructor.
|
||||
* @param CanUpdatePackingList $canUpdatePackingList
|
||||
* @param UpdatesPackingListStatus $updatesPackingListStatus
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
*/
|
||||
public function __construct(UpdatesPackingListStatus $updatesPackingListStatus, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->updatesPackingListStatus = $updatesPackingListStatus;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesPackingListStatus->execute($packing_list, ApprovalStatus::COMPLETED);
|
||||
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||
}
|
||||
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainerRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignContainerRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order Remark',
|
||||
'message' => 'You have successfully created a new Order Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesContainerRemark */
|
||||
private $createsContainerRemark;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesContainerRemark $createsContainerRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesContainerRemark $createsContainerRemark, FetchesContainer $fetchesContainer)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsContainerRemark = $createsContainerRemark;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject(
|
||||
$request->input('content'),
|
||||
$request->route('id')
|
||||
);
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$query = $this->createsContainerRemark->execute($this->fetchesContainer->execute(['id' => $request->route('id')]), $object);
|
||||
return $this->resourceResponse( new RemarkResource($query));
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignPackingListContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Assign Packing List Container',
|
||||
'message' => 'You have successfully assign Packing List to Container'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* DeleteContainerControllersLogic constructor.
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
*/
|
||||
public function __construct(FetchesContainer $fetchesContainer, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$packing_list = $request->input('packing_list_id');
|
||||
|
||||
foreach ($packing_list as $key => $row) {
|
||||
$packing_list_item = $this->fetchesPackingList->execute(['id' => $row]);
|
||||
$container->packingLists()->attach($packing_list_item);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainerStatus;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CompleteContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesContainerStatus */
|
||||
private $updatesContainerStatus;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/**
|
||||
* CompleteContainerLogic constructor.
|
||||
* @param CanUpdateContainer $canUpdateContainer
|
||||
* @param UpdatesContainerStatus $updatesContainerStatus
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
*/
|
||||
public function __construct(UpdatesContainerStatus $updatesContainerStatus, FetchesContainer $fetchesContainer)
|
||||
{
|
||||
$this->updatesContainerStatus = $updatesContainerStatus;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesContainerStatus->execute($container, ApprovalStatus::COMPLETED);
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
}
|
||||
+18
-7
@@ -4,10 +4,12 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanCreateContainer;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -21,8 +23,8 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created PackingList',
|
||||
'message' => 'You have successfully created a new PackingList'
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -32,13 +34,17 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsContainer;
|
||||
|
||||
public function __construct(CanCreateContainer $canCreateContainer, FetchesPackingList $fetchesPackingList, CreatesContainer $createsContainer)
|
||||
public function __construct(CanCreateContainer $canCreateContainer, FetchesPackingList $fetchesPackingList, FetchesCompanyModule $fetchesCompanyModule, CreatesContainer $createsContainer)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsContainer = $createsContainer;
|
||||
}
|
||||
|
||||
@@ -51,15 +57,20 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$object = new ContainerObject($request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference'));
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('container_type'),
|
||||
$request->input('loading_date'),
|
||||
$request->input('status')
|
||||
);
|
||||
|
||||
$this->canCreateContainer->passes($object);
|
||||
|
||||
$query = $this->createsContainer->execute($object);
|
||||
$query = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* CreateContainerRemarkLogic constructor.
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
*/
|
||||
public function __construct(FetchesContainer $fetchesContainer, CreateRemarkProcessor $createRemarkProcessor)
|
||||
{
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new RemarkObject($request->input('content'), auth()->user()->id);
|
||||
|
||||
$this->createRemarkProcessor->execute($container, $object);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanCreateContainer;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateContainer */
|
||||
private $canCreateContainer;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsContainer;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
public function __construct(
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsContainer = $createsContainer;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('container_type'),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
|
||||
$this->canCreateContainer->passes($object);
|
||||
|
||||
$container = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
$transportObject = new TransportObject(
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -53,7 +53,7 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canFetchContainer->passes();
|
||||
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListContainers */
|
||||
private $canListContainers;
|
||||
|
||||
/** @var ListsContainers */
|
||||
private $listsContainers;
|
||||
|
||||
private $fetchInboundCustomCleared;
|
||||
|
||||
/**
|
||||
* ListContainersLogic constructor.
|
||||
* @param CanListContainers $canListContainers
|
||||
* @param ListsContainers $listsContainers
|
||||
*/
|
||||
public function __construct(CanListContainers $canListContainers, ListsContainers $listsContainers, FetchInboundCustomClearedProcessor $fetchInboundCustomCleared)
|
||||
{
|
||||
$this->canListContainers = $canListContainers;
|
||||
$this->listsContainers = $listsContainers;
|
||||
$this->fetchInboundCustomCleared = $fetchInboundCustomCleared;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->fetchInboundCustomCleared->execute();
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
}
|
||||
+6
-10
@@ -45,21 +45,17 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$this->canListContainers->passes();
|
||||
|
||||
$this->canListContainers->passes();
|
||||
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
|
||||
|
||||
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Schedules\Services\UpdatesScheduleStatus;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Reschedule Container',
|
||||
'message' => 'You have successfully Reschedule Container'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var UpdatesScheduleStatus */
|
||||
private $updatesScheduleStatus;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/**
|
||||
* DeleteContainerControllersLogic constructor.
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
*/
|
||||
public function __construct(FetchesContainer $fetchesContainer, UpdatesScheduleStatus $updatesScheduleStatus, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->updatesScheduleStatus = $updatesScheduleStatus;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
$old_sechedule = $transport->schedules()->first();
|
||||
|
||||
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+12
-3
@@ -52,14 +52,23 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new ContainerObject( $container->packing_list_id , $request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference'));
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('loading_date'),
|
||||
$container->status,
|
||||
);
|
||||
|
||||
$this->canUpdateContainer->passes($object);
|
||||
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Dispatch Date Container',
|
||||
'message' => 'You have successfully updated the Dispatch Date Container'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesDispatchDateTransport */
|
||||
private $updatesDispatchDateTransport;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/**
|
||||
* UpdateDispatchDateContainerLogic constructor.
|
||||
* @param CanUpdateContainer $canUpdateContainer
|
||||
* @param UpdatesDispatchDateTransport $updatesDispatchDateTransport
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
*/
|
||||
public function __construct(UpdatesDispatchDateTransport $updatesDispatchDateTransport, FetchesContainer $fetchesContainer)
|
||||
{
|
||||
$this->updatesDispatchDateTransport = $updatesDispatchDateTransport;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Drop Date Container',
|
||||
'message' => 'You have successfully updated the Drop Date Container'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesDropDateTransport */
|
||||
private $updatesDropDateTransport;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/**
|
||||
* UpdateDropDateContainerLogic constructor.
|
||||
* @param CanUpdateContainer $canUpdateContainer
|
||||
* @param UpdatesDropDateTransport $updatesDropDateTransport
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
*/
|
||||
public function __construct(UpdatesDropDateTransport $updatesDropDateTransport, FetchesContainer $fetchesContainer)
|
||||
{
|
||||
$this->updatesDropDateTransport = $updatesDropDateTransport;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
use App\Classes\Modules\PackingLists\Services\GeneratesPackingListReferenceNumber;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
|
||||
use App\Http\Resources\DeliverPackingListResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Deliver PackingList',
|
||||
'message' => 'You have successfully created a new Deliver PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var GeneratesPackingListReferenceNumber */
|
||||
private $generatesPackingListReferenceNumber;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* CreateDeliverPackingListLogic constructor.
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
*/
|
||||
public function __construct(CreatePackingListProcessor $createPackingListProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesPackingListReferenceNumber $generatesPackingListReferenceNumber, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesPackingListReferenceNumber = $generatesPackingListReferenceNumber;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
$packing_list_id = $request->input('packing_list_id');
|
||||
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
$deliverPackingList = $this->createPackingListProcessor->execute($packingListObject, $company_module);
|
||||
|
||||
foreach ($packing_list_id as $key => $row) {
|
||||
$this->fetchesPackingList->execute(['id' => $row]);
|
||||
}
|
||||
|
||||
$deliverPackingList->packing_list_owner()->sync($packing_list_id);
|
||||
|
||||
return $this->resourceResponse(new DeliverPackingListResource($deliverPackingList));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -13,6 +14,9 @@ use App\Classes\Modules\PackingLists\Services\CreatesPackingListPackage;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingList;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanCreatePackingListPackage;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -34,13 +38,18 @@ class CreatePackingListLogic extends AbstractControllerLogic
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CreatePackingListLogic constructor.
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(CreatePackingListProcessor $createPackingListProcessor)
|
||||
public function __construct(CreatePackingListProcessor $createPackingListProcessor, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,11 +59,13 @@ class CreatePackingListLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$object = new PackingListObject($request->input('reference_number'), ApprovalStatus::PENDING_SUBMISSION);
|
||||
$order = $this->fetchesOrder->execute(['reference' => $request->input('reference_number')]);
|
||||
|
||||
$query = $this->createPackingListProcessor->execute($object);
|
||||
$packingListObject = new PackingListObject($request->input('reference_number'), $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->id, PackingListType::WAREHOUSE_RECEIVE_LIST, ApprovalStatus::PENDING_SUBMISSION);
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($query));
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packingList));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
|
||||
class CreatePackageLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -61,11 +62,10 @@ class CreatePackageLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->input('order_id')]);
|
||||
|
||||
$object = new PackageObject(
|
||||
null,
|
||||
$request->input('type'),
|
||||
$request->input('description'),
|
||||
$request->input('width'),
|
||||
@@ -77,7 +77,7 @@ class CreatePackageLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canCreatePackage->passes($object);
|
||||
|
||||
$query = $this->createsPackage->execute($object);
|
||||
$query = $this->createsPackage->execute($object, $order->packingLists()->first());
|
||||
|
||||
return $this->resourceResponse(new PackageResource($query));
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Packages\Services\FetchesPackage;
|
||||
use App\Classes\Modules\Packages\Standards\Rules\CanFetchPackage;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanFetchPackage;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Packages\Services\ListsPackages;
|
||||
use App\Classes\Modules\Packages\Standards\Rules\CanListPackages;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\ListsPackages;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanListPackages;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\SwitchesPackagePackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SwitchPackagePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Switched Package Packing List',
|
||||
'message' => 'You have successfully switched the Package Packing List'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var SwitchesPackagePackingList */
|
||||
private $switchesPackagePackingList;
|
||||
|
||||
/** @var FetchesPackage */
|
||||
private $fetchesPackage;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* UpdatePackageLogic constructor.
|
||||
* @param SwitchesPackagePackingList $switchesPackagePackingList
|
||||
* @param FetchesPackage $fetchesPackage
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
*/
|
||||
public function __construct(SwitchesPackagePackingList $switchesPackagePackingList, FetchesPackage $fetchesPackage, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->switchesPackagePackingList = $switchesPackagePackingList;
|
||||
$this->fetchesPackage = $fetchesPackage;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$package = $this->fetchesPackage->execute(['id' => $request->route('id')]);
|
||||
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
||||
|
||||
$query = $this->switchesPackagePackingList->execute($package, $packing_list);
|
||||
|
||||
return $this->resourceResponse(new PackageResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,10 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Packages\Services\UpdatesPackage;
|
||||
use App\Classes\Modules\Packages\Services\FetchesPackage;
|
||||
use App\Classes\Modules\Packages\Standards\Rules\CanUpdatePackage;
|
||||
use App\Classes\Modules\Packages\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\UpdatesPackage;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanUpdatePackage;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -60,8 +60,6 @@ class UpdatePackageLogic extends AbstractControllerLogic
|
||||
$package = $this->fetchesPackage->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new PackageObject(
|
||||
$package->order_id,
|
||||
null,
|
||||
$request->input('type'),
|
||||
$request->input('description'),
|
||||
$request->input('width'),
|
||||
@@ -69,7 +67,9 @@ class UpdatePackageLogic extends AbstractControllerLogic
|
||||
$request->input('length'),
|
||||
$request->input('weight'),
|
||||
$request->input('quantity'),
|
||||
$request->input('status'));
|
||||
$request->input('status'),
|
||||
$package->reference
|
||||
);
|
||||
|
||||
$this->canUpdatePackage->passes($object);
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Schedules\Services\UpdatesScheduleStatus;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ReschedulePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Reschedule Packing List',
|
||||
'message' => 'You have successfully Reschedule Packing List'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var UpdatesScheduleStatus */
|
||||
private $updatesScheduleStatus;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/**
|
||||
* DeleteContainerControllersLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesScheduleStatus $updatesScheduleStatus, CreatesSchedule $createsSchedule)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->updatesScheduleStatus = $updatesScheduleStatus;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$transport = $packing_list->transports()->first();
|
||||
|
||||
$old_sechedule = $transport->schedules()->first();
|
||||
|
||||
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('eta')),
|
||||
Carbon::parse($request->input('etd')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateDispatchDatePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Dispatch Date Packing List',
|
||||
'message' => 'You have successfully updated the Dispatch Date Packing List'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesDispatchDateTransport */
|
||||
private $updatesDispatchDateTransport;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* UpdateDispatchDatePackingListLogic constructor.
|
||||
* @param CanUpdateContainer $canUpdateContainer
|
||||
* @param UpdatesDispatchDateTransport $updatesDispatchDateTransport
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
*/
|
||||
public function __construct(UpdatesDispatchDateTransport $updatesDispatchDateTransport, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->updatesDispatchDateTransport = $updatesDispatchDateTransport;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
$transport = $packing_list->transports()->first();
|
||||
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
|
||||
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UpdateDropDatePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Drop Date Packing List',
|
||||
'message' => 'You have successfully updated the Drop Date Packing List'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var UpdatesDropDateTransport */
|
||||
private $updatesDropDateTransport;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* UpdateDispatchDatePackingListLogic constructor.
|
||||
* @param CanUpdateContainer $canUpdateContainer
|
||||
* @param UpdatesDropDateTransport $updatesDropDateTransport
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
*/
|
||||
public function __construct(UpdatesDropDateTransport $updatesDropDateTransport, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->updatesDropDateTransport = $updatesDropDateTransport;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
$transport = $packing_list->transports()->first();
|
||||
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
|
||||
return $this->resourceResponse(new PackingListResource($packing_list));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class UpdatePackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new PackingListObject($packingList->reference, $request->input('status'));
|
||||
$object = new PackingListObject($packingList->reference, $packingList->claimant_id, $packingList->type, $request->input('status'));
|
||||
|
||||
$this->canUpdatePackingList->passes($object);
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingListStatus;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanUpdatePackingList;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdatePackingListStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated PackingList Status',
|
||||
'message' => 'You have successfully updated the PackingList status'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var UpdatesPackingListStatus */
|
||||
private $updatesPackingListStatus;
|
||||
|
||||
/**
|
||||
* UpdatePackingListStatusLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param UpdatesPackingListStatus $updatesPackingListStatus
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesPackingListStatus $updatesPackingListStatus)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->updatesPackingListStatus = $updatesPackingListStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->updatesPackingListStatus->execute($packingList, $request->route('status'));
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Classes\Modules\PackingLists\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ContainerObject implements DataTransferObject
|
||||
{
|
||||
@@ -14,11 +15,14 @@ class ContainerObject implements DataTransferObject
|
||||
private $containerNumber;
|
||||
|
||||
/** @var string */
|
||||
private $sealNumber;
|
||||
private $sealReference;
|
||||
|
||||
/** @var int */
|
||||
private $containerType;
|
||||
|
||||
/** @var Carbon */
|
||||
private $loadingDate;
|
||||
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
@@ -26,16 +30,18 @@ class ContainerObject implements DataTransferObject
|
||||
* ContainerObject constructor.
|
||||
* @param string $reference
|
||||
* @param string $containerNumber
|
||||
* @param string $sealNumber
|
||||
* @param string $sealReference
|
||||
* @param int $containerType
|
||||
* @param Carbon $loadingDate
|
||||
* @param int $status
|
||||
*/
|
||||
public function __construct(string $reference, string $containerNumber, string $sealNumber, int $containerType, int $status)
|
||||
public function __construct(string $reference, string $containerNumber, string $sealReference, int $containerType, Carbon $loadingDate, int $status)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
$this->containerNumber = $containerNumber;
|
||||
$this->sealNumber = $sealNumber;
|
||||
$this->sealReference = $sealReference;
|
||||
$this->containerType = $containerType;
|
||||
$this->loadingDate = $loadingDate;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
@@ -58,9 +64,9 @@ class ContainerObject implements DataTransferObject
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSealNumber(): string
|
||||
public function getSealReference(): string
|
||||
{
|
||||
return $this->sealNumber;
|
||||
return $this->sealReference;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,6 +77,14 @@ class ContainerObject implements DataTransferObject
|
||||
return $this->containerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getLoadingDate(): Carbon
|
||||
{
|
||||
return $this->loadingDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@@ -79,4 +93,5 @@ class ContainerObject implements DataTransferObject
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class PackingListObject implements DataTransferObject
|
||||
* @param int $status
|
||||
* @param null|string $contractReference
|
||||
*/
|
||||
public function __construct(string $reference, int $claimantId, int $type, int $status, ?string $contractReference = null)
|
||||
public function __construct(string $reference, ?int $claimantId, int $type, int $status, ?string $contractReference = null)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
$this->claimantId = $claimantId;
|
||||
@@ -50,7 +50,7 @@ class PackingListObject implements DataTransferObject
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getClaimantId(): int
|
||||
public function getClaimantId(): ?int
|
||||
{
|
||||
return $this->claimantId;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class CreatePackingListProcessor
|
||||
|
||||
|
||||
/**
|
||||
* CreatePackingListLogic constructor.
|
||||
* CreatePackingListProcessor constructor.
|
||||
* @param CanCreatePackingList $canCreatePackingList
|
||||
* @param CreatesPackingList $createsPackingList
|
||||
*/
|
||||
|
||||
+17
-10
@@ -65,7 +65,6 @@ class FetchContainersStatusUpdateFromVTPortalProcessor
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
@@ -77,7 +76,7 @@ class FetchContainersStatusUpdateFromVTPortalProcessor
|
||||
try {
|
||||
$filter = '["RefNo:=%js%\"'.$container->reference.'\"\u0000"]';
|
||||
|
||||
$containerDetailsRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
$containerDetailsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$containerDetails = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailsRequest);
|
||||
|
||||
@@ -89,6 +88,8 @@ class FetchContainersStatusUpdateFromVTPortalProcessor
|
||||
|
||||
$eta = Carbon::parse($eta);
|
||||
|
||||
$etd = Carbon::parse($eta)->subDays(5);
|
||||
|
||||
$delayDate = $containerDetails[6];
|
||||
|
||||
$containerStatus = $containerDetails[9];
|
||||
@@ -98,31 +99,37 @@ class FetchContainersStatusUpdateFromVTPortalProcessor
|
||||
$transport = $container->transports()->first();
|
||||
|
||||
if(!$transport){
|
||||
$transportObject = new TransportObject(TransportType::SEA, null, null, $eta, null, ApprovalStatus::APPROVED);
|
||||
$transportObject = new TransportObject(TransportType::SEA, null, null, $etd, null, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($eta->subDays(5), $eta, ApprovalStatus::APPROVED));
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $eta, ApprovalStatus::APPROVED));
|
||||
}
|
||||
|
||||
if($delayDate){
|
||||
|
||||
$delayDate = Carbon::parse($delayDate);
|
||||
$transport = $container->transports()->first();
|
||||
$schedule = $transport->schedules()->where('eta', '=', $delayDate)->first();
|
||||
$etd = $delayDate->subDays(5);
|
||||
if(!$schedule){
|
||||
$etd = $schedule->etd;
|
||||
|
||||
if(!$transport->schedules()->where('eta', '=', $delayDate)->first()) {
|
||||
$etd = $transport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->etd;
|
||||
$transport->schedules()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
||||
}
|
||||
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($etd, $delayDate, ApprovalStatus::APPROVED));
|
||||
}
|
||||
|
||||
if($containerStatus === 'Unstuffing'){
|
||||
$container->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
$container->transports()->first()->update(['drop_date' => Carbon::parse($unstuffingDate)->subDay(), 'status' => ApprovalStatus::COMPLETED]);
|
||||
$container->packingLists()->update(['status' => ApprovalStatus::APPROVED]);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
foreach($container->packingLists as $packingList){
|
||||
|
||||
if($packingList->status === ApprovalStatus::PENDING_VERIFICATION){
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
}
|
||||
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
foreach($packingList->steps()->where('reference', '!=', 'DELIVERY')->get() as $step){
|
||||
$this->updatesContractObligations->execute($signature, $step->obligation_hash_id);
|
||||
|
||||
+25
-22
@@ -3,8 +3,6 @@
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
@@ -12,7 +10,6 @@ use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\PackingList;
|
||||
@@ -58,37 +55,43 @@ class FetchDeliveryListFromVTPortalProcessor
|
||||
public function execute(){
|
||||
|
||||
try {
|
||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->where('status', '=', ApprovalStatus::APPROVED)->get();
|
||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::SUSPENDED])->get();
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
foreach($packingLists as $packingList){
|
||||
try {
|
||||
$filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]';
|
||||
|
||||
$shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
$shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
||||
|
||||
foreach($shippingPackingLists->Rows as $shippingPackingList){
|
||||
if(!$shippingPackingList[9] && !$shippingPackingList[10]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$deliveryDate = Carbon::parse($shippingPackingList[9] ? $shippingPackingList[9]:$shippingPackingList[10]);
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
||||
|
||||
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
|
||||
if(!array_key_exists(0, $shippingPackingLists->Rows)){
|
||||
continue;
|
||||
}
|
||||
|
||||
$shippingPackingList = $shippingPackingLists->Rows[0];
|
||||
|
||||
if(!$shippingPackingList[9] && !$shippingPackingList[10]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$packingList->status = ApprovalStatus::COMPLETED;
|
||||
$packingList->save();
|
||||
|
||||
$deliveryDate = Carbon::parse($shippingPackingList[9] ? $shippingPackingList[9]:$shippingPackingList[10]);
|
||||
$transportObject = new TransportObject(TransportType::LAND, null, null, $deliveryDate, $deliveryDate, ApprovalStatus::APPROVED);
|
||||
/** @var Transport $transport */
|
||||
$transport = $this->createsTransport->execute($transportObject, $packingList);
|
||||
$this->createsSchedule->execute($transport, new ScheduleObject($deliveryDate, $deliveryDate, ApprovalStatus::APPROVED));
|
||||
|
||||
$deliveryStep = $packingList->steps()->where('reference', '=', 'LAST_MILE_DELIVERY')->first();
|
||||
$signature = $packingList->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::SUPERVISOR)->first()->appointee->entity_sigiture;
|
||||
$this->updatesContractObligations->execute($signature, $deliveryStep->obligation_hash_id);
|
||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
} catch (GuzzleException $exception) {
|
||||
dd($exception);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
use App\Classes\Modules\Unity\Services\UpdatesContractObligation;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transport;
|
||||
use App\Models\Container;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchInboundCustomClearedProcessor
|
||||
{
|
||||
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var CreatesTransport */
|
||||
private $createsTransport;
|
||||
|
||||
/** @var CreatesSchedule */
|
||||
private $createsSchedule;
|
||||
|
||||
/** @var UpdatesContractObligation */
|
||||
private $updatesContractObligations;
|
||||
|
||||
/**
|
||||
* FetchDeliveryListFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param CreatesTransport $createsTransport
|
||||
* @param CreatesSchedule $createsSchedule
|
||||
* @param UpdatesContractObligation $updatesContractObligations
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, CreatesTransport $createsTransport, CreatesSchedule $createsSchedule, UpdatesContractObligation $updatesContractObligations)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->createsTransport = $createsTransport;
|
||||
$this->createsSchedule = $createsSchedule;
|
||||
$this->updatesContractObligations = $updatesContractObligations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
$packingLists = PackingList::query()->with(['steps' => function ($query) {
|
||||
$query->where('steps.status', '<>', 3);
|
||||
}])
|
||||
->where('type', PackingListType::SHIPPING_PACKING_LIST)
|
||||
->whereHas('containers', function($query) {
|
||||
return $query->whereHas('transports', function($query){
|
||||
return $query->where('type', '=', TransportType::SEA)->where('status', '=', ApprovalStatus::COMPLETED)->whereHas('schedules', function($query){
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
});
|
||||
});
|
||||
})->whereDoesntHave('transports', function($query){
|
||||
return $query->where('type', '=', TransportType::LAND)->where('status', '=', ApprovalStatus::APPROVED)->whereHas('schedules', function($query){
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
});
|
||||
})->get();
|
||||
|
||||
return $packingLists ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+8
-6
@@ -6,7 +6,6 @@ use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingList\Processors\GenerateShippingOrderStepsProcessor;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
@@ -126,7 +125,7 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$start = $start ? $start : Carbon::now()->subMonth();
|
||||
$start = $start ? $start : Carbon::now()->subDays(10);
|
||||
|
||||
$startLimit = Carbon::parse('11-08-2021');
|
||||
|
||||
@@ -137,18 +136,18 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
$end = $end ? $end : Carbon::now();
|
||||
$filter = '["LoadedTime:$between$%js%\"'.$start->format('Y-m-d').'T00:00:00.000\"$and$%js%\"'.$end->format('Y-m-d').'T00:00:00.000\"\u0000"]';
|
||||
|
||||
$containersRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
$containersRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"LoadedTime asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$containers = $this->fetchesDataFRomVTPortal->getResponseBody($containersRequest);
|
||||
|
||||
foreach ($containers->Rows as $container){
|
||||
|
||||
$filter = '["ContainerID:=%js%'.$container[11].'"]';
|
||||
$containerDetailRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
$containerDetailRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$containerDetail = $this->fetchesDataFRomVTPortal->getResponseBody($containerDetailRequest);
|
||||
|
||||
$containerObject = new ContainerObject($container[0], str_replace(' ', '', $container[24]), str_replace(' ', '', $container[15]), ContainerTypes::FORTY_FEET_DRY_CONTAINER, ApprovalStatus::PENDING_VERIFICATION);
|
||||
$containerObject = new ContainerObject($container[0], str_replace(' ', '', $container[24]), str_replace(' ', '', $container[15]), ContainerTypes::FORTY_FEET_DRY_CONTAINER, Carbon::parse($container[5]), ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['reference' => $containerObject->getReference()]);
|
||||
@@ -199,7 +198,10 @@ class FetchLoadedContainersFromVTPortalProcessor
|
||||
|
||||
$this->unityAssignContractEntity->execute($supervisorContractEntity->hash_id, $contractObligations);
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::PENDING_VERIFICATION, $contractReference);
|
||||
$connection = $order->companyModule->connections()->first();
|
||||
$marking = $connection->invitee_reference;
|
||||
|
||||
$packingListObject = new PackingListObject($packingListReference, $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id, PackingListType::SHIPPING_PACKING_LIST, (int) filter_var($marking, FILTER_SANITIZE_NUMBER_INT) <= 1000 ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::SUSPENDED, $contractReference);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
+4
-2
@@ -46,7 +46,9 @@ class FetchPackingListFromVTPortalProcessor
|
||||
*/
|
||||
public function execute(){
|
||||
|
||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->where('status', '=', ApprovalStatus::PENDING_VERIFICATION)->get();
|
||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])->whereDoesntHave('containers', function($query){
|
||||
$query->where('status', '=', ApprovalStatus::COMPLETED);
|
||||
})->get();
|
||||
|
||||
foreach($packingLists as $packingList){
|
||||
|
||||
@@ -55,7 +57,7 @@ class FetchPackingListFromVTPortalProcessor
|
||||
|
||||
$filter = '["PoNumber:=%js%\"'.$packingList->reference.'\"\u0000"]';
|
||||
|
||||
$shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
$shippingPackingListsRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"VPodetailparcel","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"CreatedOn asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\PackingList;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchPackingListProcessor
|
||||
{
|
||||
|
||||
/** @var ListsPackingLists */
|
||||
private $listsPackingLists;
|
||||
|
||||
/**
|
||||
* FetchPackingListFromVTPortalProcessor constructor.
|
||||
* @param ListsPackingLists $listsPackingLists
|
||||
*/
|
||||
public function __construct(ListsPackingLists $listsPackingLists)
|
||||
{
|
||||
$this->listsPackingLists = $listsPackingLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute($params){
|
||||
|
||||
$packingLists = PackingList::where('type', '=', PackingListType::SHIPPING_PACKING_LIST)
|
||||
->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::SUSPENDED])
|
||||
->whereDoesntHave('containers', function($query){
|
||||
$query->where('status', '=', ApprovalStatus::COMPLETED);
|
||||
})->orderBy('created_at','desc')->where('owner_id',$params['orderId'])->get();
|
||||
|
||||
//dd($packingLists);
|
||||
$packingListsArray=[];
|
||||
foreach($packingLists as $packingList){
|
||||
|
||||
$address = $packingList->owner->addresses()->first();
|
||||
$packingList->fulladdress = $address->street_one.', '.$address->street_two.', '.$address->district->name.', '.$address->post_code.' '.$address->state->name.', '.$address->country->name;
|
||||
|
||||
$container = $packingList->containers()->first();
|
||||
$packingList->container_reference = $container->reference;
|
||||
$packingList->container_number = $container->container_number;
|
||||
|
||||
$packingListsArray[]=$packingList;
|
||||
|
||||
}
|
||||
|
||||
return $packingListsArray;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+15
-5
@@ -125,13 +125,15 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
}
|
||||
|
||||
$end = $end ? $end : Carbon::now();
|
||||
|
||||
$filter = '["ParcelDate:$between$%js%\"'.$start->format('Y-m-d').'T00:00:00.000\"$and$%js%\"'.$end->format('Y-m-d').'T00:00:00.000\"\u0000"]';
|
||||
|
||||
$warehouseListRequest = $this->fetchesDataFRomVTPortal->clientRequest('https://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"WarehouseList","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ModifiedOn DESC","Filter":'.$filter.'}}'), '');
|
||||
$warehouseListRequest = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"WarehouseList","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"SortExpression":"ParcelDate asc","Filter":'.$filter.'}}'), '');
|
||||
|
||||
$response = $this->fetchesDataFRomVTPortal->getResponseBody($warehouseListRequest);
|
||||
|
||||
foreach ($response->Rows as $parcel){
|
||||
|
||||
$marking = explode('/', explode('CIEF/', $parcel[5])[1]);
|
||||
|
||||
if(!array_key_exists(1, $marking)){
|
||||
@@ -144,6 +146,7 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$order = $this->fetchesOrder->execute(['reference' => $orderNumber]);
|
||||
} catch (ResourceNotFoundException $exception) {
|
||||
@@ -154,13 +157,16 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
continue;
|
||||
}
|
||||
|
||||
$customerMarking = str_replace(' ', '', str_replace('/', '', str_replace('CIEF/', '', $oldOrder->company->marking)));
|
||||
|
||||
$customerMarking = str_replace('/', '', str_replace(' ', '', explode('CIEF/', $oldOrder->company->marking)[1]));
|
||||
|
||||
$companyModule = CompanyModule::whereHas('inviters', function($query) use ($customerMarking) {
|
||||
return $query->where('invitee_reference', '=', $customerMarking);
|
||||
})->first();
|
||||
|
||||
if(!$companyModule) {
|
||||
|
||||
if(!$companyModule){
|
||||
log::error('unknown customer: '.$customerMarking);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -180,6 +186,10 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $warehouseId === 11 ? 3 : 4]);
|
||||
|
||||
$order = $this->createOrderProcessor->execute($companyModule->company, $originWarehouse, $address, $orderNumber);
|
||||
|
||||
$order->created_at = Carbon::parse($parcel[1]);
|
||||
$order->save();
|
||||
|
||||
}
|
||||
|
||||
$packingListReference = $parcel[17];
|
||||
@@ -217,13 +227,13 @@ class FetchWarehouseReceiveListFromVTPortalProcessor
|
||||
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
} catch (\Exception $exception){
|
||||
Log::error($exception->getMessage());
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services;
|
||||
|
||||
use App\Models\Order;
|
||||
|
||||
class ChecksIfPackingListReferenceNumberExists
|
||||
{
|
||||
|
||||
private $repository;
|
||||
|
||||
public function __construct(Order $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function execute(string $reference_number): bool {
|
||||
return $this->repository->where('reference', $reference_number)->exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,8 @@ class CreatesContainer extends AbstractUpdateRelationshipRecord
|
||||
$model->reference = $object->getReference();
|
||||
$model->container_number = $object->getContainerNumber();
|
||||
$model->container_type = $object->getContainerType();
|
||||
$model->seal_reference = $object->getSealNumber();
|
||||
$model->seal_reference = $object->getSealReference();
|
||||
$model->loading_date = $object->getLoadingDate();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($owner->containers(), $model);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services\Containers;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Models\Remark;
|
||||
use App\Models\Container;
|
||||
|
||||
class CreatesContainerRemark extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param RemarkObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Container $container, RemarkObject $object) {
|
||||
$model = new Remark();
|
||||
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->content = $object->getContent();
|
||||
|
||||
return $this->handler($container->remarks(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class UpdatesContainer extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Container $model, ContainerObject $object) {
|
||||
|
||||
$model->container_reference = $object->getContainerReference();
|
||||
$model->reference = $object->getReference();
|
||||
$model->container_type = $object->getContainerType();
|
||||
$model->seal_reference = $object->getSealReference();
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user