mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
WIP Unity Order APIs
This commit is contained in:
@@ -28,7 +28,7 @@ class ConfirmOrderProcessor
|
||||
|
||||
public function execute(int $orderId, array $contract_obligation_list = []){
|
||||
|
||||
$order_object = new OrderObject(0,'','',0,0, '',$orderId);
|
||||
$order_object = new OrderObject(0,'','',0,0, '',$orderId,0,0);
|
||||
|
||||
$this->canConfirmOrder->passes($order_object);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Classes\ValueObjects\Constants\OrderStatus;
|
||||
use App\Classes\ValueObjects\Constants\OrderSteps;
|
||||
use App\Classes\ValueObjects\Constants\OrderType;
|
||||
use App\Classes\Modules\Unity\Processors\CreateContractProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\CreateContractEntityProcessor;
|
||||
use App\Classes\Modules\Unity\Processors\AssignContractEntityProcessor;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -28,7 +29,9 @@ class CreateOrderProcessor
|
||||
|
||||
private $unityAssignContractEntity;
|
||||
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreateOrderStepsProcessor $createOrderStepsProcessor, ConfirmOrderProcessor $confirmOrderProcessor, CreateContractProcessor $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity)
|
||||
private $unityCreateContractEntity;
|
||||
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreateOrderStepsProcessor $createOrderStepsProcessor, ConfirmOrderProcessor $confirmOrderProcessor, CreateContractProcessor $unityCreateContract, CreateContractEntityProcessor $unityCreateContractEntity, AssignContractEntityProcessor $unityAssignContractEntity)
|
||||
{
|
||||
$this->canCreateOrder = $canCreateOrder;
|
||||
$this->createsOrder = $createsOrder;
|
||||
@@ -36,6 +39,7 @@ class CreateOrderProcessor
|
||||
$this->createOrderStepsProcessor = $createOrderStepsProcessor;
|
||||
$this->unityCreateContract = $unityCreateContract;
|
||||
$this->unityAssignContractEntity = $unityAssignContractEntity;
|
||||
$this->unityCreateContractEntity = $unityCreateContractEntity;
|
||||
}
|
||||
|
||||
public function execute(Request $request){
|
||||
@@ -48,11 +52,13 @@ class CreateOrderProcessor
|
||||
$contract_reference_no = $contract->hash_id;
|
||||
$contract_obligation_list = $contract->contract_obligation_list;
|
||||
|
||||
//Call Unity to assign contract entity to obligation
|
||||
$r = $this->unityAssignContractEntity->execute($request, $contract_obligation_list);
|
||||
//$e = $this->unityCreateContractEntity->execute($request, $contract_reference_no, $contract_obligation_list);
|
||||
|
||||
echo('??');
|
||||
dd($r);
|
||||
//Call Unity to assign contract entity to obligation
|
||||
//$r = $this->unityAssignContractEntity->execute($request, $contract_obligation_list);
|
||||
|
||||
//echo('??');
|
||||
//dd($e);
|
||||
|
||||
$order_object = new OrderObject($request->get('company_module_id'), $contract_reference_no, '', OrderType::SHARED_CONTAINER, OrderStatus::PROCESSING, OrderSteps::PROCESSING, 0, $request->get('address_id'), $request->get('warehouse_id'));
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class UpdatesOrderCurrentStepProcessor
|
||||
|
||||
public function execute(int $orderId, string $currentStep){
|
||||
|
||||
$order_object = new OrderObject(0, '', '', 0, 0, $currentStep, $orderId);
|
||||
$order_object = new OrderObject(0, '', '', 0, 0, $currentStep, $orderId,0,0);
|
||||
|
||||
$this->canUpdateCurrentStep->passes($order_object);
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Unity\Processors;
|
||||
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Modules\Unity\Services\CreatesContractEntity;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContractEntityProcessor
|
||||
{
|
||||
private $createsContractEntity;
|
||||
|
||||
private $fetchesCompany;
|
||||
|
||||
public function __construct(CreatesContractEntity $createsContractEntity, FetchesCompany $fetchesCompany)
|
||||
{
|
||||
$this->createsContractEntity = $createsContractEntity;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
}
|
||||
|
||||
public function execute(Request $request, string $new_contract_id, array $obligations){
|
||||
|
||||
$entity_hash_ids = [];
|
||||
|
||||
$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];
|
||||
|
||||
$entity_hash_ids[] = $cief_company->companyModule()->first()->unity_hash_id;
|
||||
$entity_hash_ids[] = $warehouse_company->companyModule()->first()->unity_hash_id;
|
||||
|
||||
return $this->createsContractEntity->execute($new_contract_id, $entity_hash_ids);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Unity\Services;
|
||||
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Modules\Unity\Services\GetAccessToken;
|
||||
|
||||
class CreatesContractEntity
|
||||
{
|
||||
private $getAccessToken;
|
||||
|
||||
private $createContractEntityEndpoint;
|
||||
|
||||
private $contract_hash_id;
|
||||
|
||||
public function __construct(GetAccessToken $getAccessToken)
|
||||
{
|
||||
$this->createContractEntityEndpoint = Config::get('unity.url').Config::get('unity.endpoint.create_contract_entity');
|
||||
$this->getAccessToken = $getAccessToken;
|
||||
$this->contract_hash_id = Config::get('unity.contract_template_hash_id');
|
||||
}
|
||||
|
||||
public function execute(string $new_contract_id, array $entity_hash_ids){
|
||||
|
||||
$accesToken=$this->getAccessToken->execute();
|
||||
|
||||
$response = Http::withToken($accesToken)->post($this->createContractEntityEndpoint,['contract_id'=>[$new_contract_id],'entity_id'=>$entity_hash_ids])->object();
|
||||
|
||||
echo($new_contract_id.'<br/>');
|
||||
|
||||
echo($this->createContractEntityEndpoint);
|
||||
dd($response );
|
||||
return (isset($response->data)) ? $response->data : null;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user