mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-29 01:14:04 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 834ea52a4f |
+1
-12
@@ -39,7 +39,7 @@ MAIL_FROM_NAME="${APP_NAME}"
|
|||||||
AWS_ACCESS_KEY_ID=
|
AWS_ACCESS_KEY_ID=
|
||||||
AWS_SECRET_ACCESS_KEY=
|
AWS_SECRET_ACCESS_KEY=
|
||||||
AWS_DEFAULT_REGION=us-east-1
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
AWS_BUCKET=shipping-portal-localhost
|
AWS_BUCKET=
|
||||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
PUSHER_APP_ID=
|
PUSHER_APP_ID=
|
||||||
@@ -55,14 +55,3 @@ EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
|||||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||||
|
|
||||||
YD_API_CODE=''
|
YD_API_CODE=''
|
||||||
|
|
||||||
PERFEXCRM_BASE_URL=""
|
|
||||||
PERFEXCRM_API_KEY=""
|
|
||||||
PERFEXCRM_IS_ENABLED="false"
|
|
||||||
|
|
||||||
VAPOR_ENV=local
|
|
||||||
LARAVEL_VAPOR_ENABLED=false
|
|
||||||
COMMANDS_V2_ENABLED=false
|
|
||||||
|
|
||||||
STORAGE_FEE_LAUNCH_DATE="2023-12-11 00:00:00"
|
|
||||||
SST_START_DATE="2024-04-01 00:00:00"
|
|
||||||
|
|||||||
+1
-4
@@ -21,11 +21,8 @@ gox.iml
|
|||||||
rebuild_docker.sh
|
rebuild_docker.sh
|
||||||
docker/*
|
docker/*
|
||||||
db/*
|
db/*
|
||||||
|
docker-compose.yml
|
||||||
package-lock.json
|
package-lock.json
|
||||||
public/*
|
public/*
|
||||||
/public/*
|
/public/*
|
||||||
storage/framework/laravel-excel/*
|
storage/framework/laravel-excel/*
|
||||||
.vapor/
|
|
||||||
.env.production
|
|
||||||
.env.staging
|
|
||||||
.env.development
|
|
||||||
|
|||||||
Vendored
-118
@@ -1,118 +0,0 @@
|
|||||||
// Webhook + Gitlab git pull + Vapor
|
|
||||||
|
|
||||||
// def payload = readJSON text: "${payload}"
|
|
||||||
// String userName = payload.user_name
|
|
||||||
// String userEmail = payload.user_email
|
|
||||||
// String httpUrl = payload.project.http_url
|
|
||||||
|
|
||||||
|
|
||||||
pipeline {
|
|
||||||
agent {
|
|
||||||
docker {
|
|
||||||
args '--group-add 992 -v /var/run/docker.sock:/var/run/docker.sock'
|
|
||||||
image '303644228504.dkr.ecr.ap-southeast-1.amazonaws.com/jenkins-pipeline-agent:latest'
|
|
||||||
registryCredentialsId "ecr:ap-southeast-1:aws-ec2-instance-iam-role"
|
|
||||||
registryUrl "https://303644228504.dkr.ecr.ap-southeast-1.amazonaws.com"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
environment {
|
|
||||||
HOME = '.'
|
|
||||||
}
|
|
||||||
stages {
|
|
||||||
stage('Download source code from Git') {
|
|
||||||
steps {
|
|
||||||
script{
|
|
||||||
currentBuild.description = 'Step 1 of 6 Completed'
|
|
||||||
println("GIT GIT_BRANCH: " + GIT_BRANCH)
|
|
||||||
switch(GIT_BRANCH) {
|
|
||||||
case "vapor/production":
|
|
||||||
case "vapor/staging":
|
|
||||||
case "vapor/development":
|
|
||||||
git(
|
|
||||||
url: 'https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git',
|
|
||||||
credentialsId: 'gitlab-jenkins-localhost',
|
|
||||||
branch: GIT_BRANCH
|
|
||||||
)
|
|
||||||
break
|
|
||||||
case "origin/dillon/34-jenkins-vapor":
|
|
||||||
git(
|
|
||||||
url: 'https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git',
|
|
||||||
credentialsId: 'gitlab-jenkins-localhost',
|
|
||||||
branch: 'dillon/34-jenkins-vapor'
|
|
||||||
)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
currentBuild.description = 'Step 2 of 6 Completed'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Install') {
|
|
||||||
steps {
|
|
||||||
sh 'composer update'
|
|
||||||
script{
|
|
||||||
currentBuild.description = 'Step 3 of 6 Completed'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Tests') {
|
|
||||||
steps {
|
|
||||||
//sh 'vendor/bin/phpunit tests/Unit'
|
|
||||||
script{
|
|
||||||
currentBuild.description = 'Step 4 of 6 Completed'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Deploy') {
|
|
||||||
steps {
|
|
||||||
script{
|
|
||||||
String gitCommitMessage = getCommitMessage()
|
|
||||||
println("GIT CommitMessage: " + gitCommitMessage)
|
|
||||||
println("GIT GIT_BRANCH: " + GIT_BRANCH)
|
|
||||||
switch(GIT_BRANCH) {
|
|
||||||
case "vapor/production":
|
|
||||||
sh "vendor/bin/vapor deploy production --message='${gitCommitMessage}'"
|
|
||||||
break
|
|
||||||
case "vapor/staging":
|
|
||||||
sh "vendor/bin/vapor deploy staging --message='${gitCommitMessage}'"
|
|
||||||
break
|
|
||||||
case "vapor/development":
|
|
||||||
sh "vendor/bin/vapor deploy development --message='${gitCommitMessage}'"
|
|
||||||
break
|
|
||||||
case "origin/dillon/34-jenkins-vapor":
|
|
||||||
sh "vendor/bin/vapor deploy development --message='${gitCommitMessage}'"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
currentBuild.description = 'Step 5 of 6 Completed'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Cleanup') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
try {
|
|
||||||
sh 'docker image prune -a -f'
|
|
||||||
} catch (Exception e) {
|
|
||||||
echo "Error during cleanup: ${e.message}"
|
|
||||||
}
|
|
||||||
currentBuild.description = 'Step 6 of 6 Completed'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonCPS
|
|
||||||
String getCommitMessage(){
|
|
||||||
commitMessage = " "
|
|
||||||
for ( changeLogSet in currentBuild.changeSets){
|
|
||||||
for (entry in changeLogSet.getItems()){
|
|
||||||
commitMessage = entry.msg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
commitMessage = commitMessage.replace("'", "`")
|
|
||||||
return commitMessage
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Exceptions;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
final class ConnectionErrorException extends ServiceApiException {
|
|
||||||
public function __construct(?string $message = null, ?string $exceptionMessage = null, ?string $payload = null, ?string $exceptionTrace = null) {
|
|
||||||
Log::error($message. ": ". $exceptionMessage);
|
|
||||||
if($payload){
|
|
||||||
Log::error('Payload: '.$payload);
|
|
||||||
}
|
|
||||||
if($exceptionTrace){
|
|
||||||
Log::error($exceptionTrace);
|
|
||||||
}
|
|
||||||
parent::__construct($message ?? 'A connection error has occurred. Please check application logs for more information.',
|
|
||||||
HttpStatus::SERVER_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Exceptions;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
||||||
|
|
||||||
final class JobResourceNotFoundException extends ServiceApiException {
|
|
||||||
public function __construct(?string $message = null) {
|
|
||||||
parent::__construct($message ?? 'Unable to find the requested resource', HttpStatus::RESOURCE_NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\Classes\General;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
|
||||||
|
|
||||||
class AWSS3Helper
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $exportFileName
|
|
||||||
* @param Exportable $exportableObject
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
static function S3Exportable($exportFileName, $exportableObject){
|
|
||||||
//Step 1: Upload to S3
|
|
||||||
$filePathForS3 = 'temp/' . $exportFileName;
|
|
||||||
$exportableObject->store($filePathForS3, 's3');
|
|
||||||
|
|
||||||
//Step 2: Return temporary URL from S3
|
|
||||||
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
|
|
||||||
$filePathForS3,
|
|
||||||
Carbon::now()->addMinutes(10)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $temporaryUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $exportFileName
|
|
||||||
* @param string|resource $contents
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
static function S3PDF($exportFileName, $contents){
|
|
||||||
//Step 1: Upload to S3
|
|
||||||
$filePathForS3 = 'temp/' . $exportFileName;
|
|
||||||
Storage::disk('s3')->put($filePathForS3, $contents);
|
|
||||||
|
|
||||||
//Step 2: Return temporary URL from S3
|
|
||||||
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
|
|
||||||
$filePathForS3,
|
|
||||||
Carbon::now()->addMinutes(10)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $temporaryUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Abstracts;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\ErrorException;
|
|
||||||
use App\Classes\Exceptions\InternalServerErrorException;
|
|
||||||
use App\Classes\ValueObjects\Constants\Notifications;
|
|
||||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
||||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
|
||||||
use ErrorException as GeneralExceptions;
|
|
||||||
use TypeError;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
abstract class Abstract2ControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
abstract protected function notification(): array;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getNotificationTitle():string {
|
|
||||||
return $this->notification()['title'] ? $this->notification()['title']: Notifications::UNDEFINED['title'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getNotificationMessage():string {
|
|
||||||
return $this->notification()['message'] ? $this->notification()['message']: Notifications::UNDEFINED['message'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return BinaryFileResponse
|
|
||||||
* @throws ErrorException
|
|
||||||
*/
|
|
||||||
abstract protected function logic(Request $request) : BinaryFileResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return BinaryFileResponse
|
|
||||||
*/
|
|
||||||
public function execute(Request $request) : BinaryFileResponse {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
DB::beginTransaction();
|
|
||||||
|
|
||||||
$response = $this->logic($request);
|
|
||||||
|
|
||||||
DB::commit();
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
|
|
||||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
|
||||||
abort(404, $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array|null $data
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function response(?array $data = []) : JsonResponse {
|
|
||||||
|
|
||||||
return (new ApiResponseObject($this->getNotificationTitle().' Successful',
|
|
||||||
$this->getNotificationMessage(),
|
|
||||||
HttpStatus::OK_WITH_MESSAGE, $data))->handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param JsonResource $resource
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function resourceResponse(JsonResource $resource){
|
|
||||||
return $this->response(['data' => $resource]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ResourceCollection $collection
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function collectionResponse(ResourceCollection $collection){
|
|
||||||
return $this->response(json_decode($collection->response()->getContent(), true));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -15,9 +15,6 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use App\Classes\Exceptions\JobResourceNotFoundException;
|
|
||||||
use App\Classes\General\LogHelper;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
abstract class AbstractControllerLogic
|
abstract class AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -65,19 +62,6 @@ abstract class AbstractControllerLogic
|
|||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||||
if ($exception instanceof JobResourceNotFoundException) {
|
|
||||||
LogHelper::channel('vue_polling')->info(sprintf(
|
|
||||||
"Uncaught exception '%s' with message '%s' in %s:%d",
|
|
||||||
get_class($exception),
|
|
||||||
$exception->getMessage(),
|
|
||||||
$exception->getTrace()[0]['file'],
|
|
||||||
$exception->getTrace()[0]['line']
|
|
||||||
));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Log::error($exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
|||||||
abstract class AbstractRule
|
abstract class AbstractRule
|
||||||
{
|
{
|
||||||
|
|
||||||
abstract protected function authorized($object): bool;
|
abstract protected function authorized(): bool;
|
||||||
|
|
||||||
abstract protected function validators($object): bool;
|
abstract protected function validators($object): bool;
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ abstract class AbstractRule
|
|||||||
*/
|
*/
|
||||||
public function passes(?DataTransferObject $object = null): bool {
|
public function passes(?DataTransferObject $object = null): bool {
|
||||||
try {
|
try {
|
||||||
if(!$this->authorized($object)){
|
if(!$this->authorized()){
|
||||||
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validators($object);
|
$this->validators($object);
|
||||||
@@ -36,11 +36,11 @@ abstract class AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch(AccessForbiddenException $exception){
|
} catch(AccessForbiddenException $exception){
|
||||||
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
||||||
} catch(\Exception $exception){
|
} catch(\Exception $exception){
|
||||||
throw new RequestValidationException($exception->getMessage());
|
throw new RequestValidationException($exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,6 @@ namespace App\Classes\General\Eloquent;
|
|||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Classes\Exceptions\JobResourceNotFoundException;
|
|
||||||
|
|
||||||
|
|
||||||
abstract class AbstractFetchRecord extends AbstractGetRecord
|
abstract class AbstractFetchRecord extends AbstractGetRecord
|
||||||
{
|
{
|
||||||
@@ -28,18 +26,12 @@ abstract class AbstractFetchRecord extends AbstractGetRecord
|
|||||||
* @return Model
|
* @return Model
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getResults(Builder $query, array $param = []): Model {
|
public function getResults(Builder $query): Model {
|
||||||
if(!$query->exists()){
|
if(!$query->exists()){
|
||||||
$table = $query->getModel()->getTable();
|
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
||||||
if($table ==='job_results'){
|
|
||||||
throw new JobResourceNotFoundException('Unable to find any job based on the criteria provided');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->first();
|
return $query->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -50,9 +50,9 @@ abstract class AbstractGetRecord
|
|||||||
* @param array $filters
|
* @param array $filters
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handler(array $filters, array $params = []){
|
public function handler(array $filters){
|
||||||
$this->filters = collect($filters);
|
$this->filters = collect($filters);
|
||||||
return $this->getResults($this->applyFiltersToQuery(), $params);
|
return $this->getResults($this->applyFiltersToQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,6 +65,6 @@ abstract class AbstractGetRecord
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
abstract function getResults(Builder $query, array $params = []);
|
abstract function getResults(Builder $query);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,10 +16,11 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function execute(array $filters = [], array $param = []){
|
public function execute(array $filters = []){
|
||||||
|
|
||||||
try{
|
try{
|
||||||
return $this->handler($filters, $param);
|
|
||||||
|
return $this->handler($filters);
|
||||||
|
|
||||||
} catch (QueryException $exception){
|
} catch (QueryException $exception){
|
||||||
throw new MalformedRequestException('Unable to fetch the list of records due to unexpected error');
|
throw new MalformedRequestException('Unable to fetch the list of records due to unexpected error');
|
||||||
@@ -31,7 +32,7 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getResults(Builder $query, array $param = []) {
|
public function getResults(Builder $query) {
|
||||||
$filters = $this->getDecorationFilters();
|
$filters = $this->getDecorationFilters();
|
||||||
|
|
||||||
if($filters->has('order_by')){
|
if($filters->has('order_by')){
|
||||||
@@ -43,12 +44,8 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
//dd($query->toSql());
|
//dd($query->toSql());
|
||||||
if(!empty($param)){
|
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
||||||
return $filters->has('per_page') ? $query->paginate($filters->get('per_page'), ['*'], 'page', $param['page']) : $query->get(); //page data from query parameters e.g ?page=1
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class AmountExceed implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('amount', '>', $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class AmountShort implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('amount', '<', $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class BillNo implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('bill_no', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CompanySegmentsIn implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('companyModules', function ($module) use ($value) {
|
|
||||||
$module->whereHas('connections', function ($connection) use ($value) {
|
|
||||||
$connection->whereHas('connectionSegments', function ($segment) use ($value) {
|
|
||||||
$segment->whereIn('segment_id', $value);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CreatedAfterOrEqual implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
$table = $builder->getModel()->getTable();
|
|
||||||
$startDate = Carbon::createFromFormat('d-m-Y', $value)->startOfDay();
|
|
||||||
return $builder->where("{$table}.created_at", '>=', $startDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CreatedBefore implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('created_at', '<', Carbon::parse($value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CreatedBeforeOrEqual implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
$table = $builder->getModel()->getTable();
|
|
||||||
$endDate = Carbon::createFromFormat('d-m-Y', $value)->endOfDay();
|
|
||||||
return $builder->where("{$table}.created_at", '<=', $endDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class DoesNotHaveGroups implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereDoesntHave('groups');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class DoesNotHavePaymentStatusIn implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
|
||||||
$query->where('type', TransactionType::PAYMENT)->whereIn('status', $value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,7 @@ class DoesNotHaveTransactionType implements Filter
|
|||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
||||||
$query->where('type', $value)->whereIn('status', [0,1,2,3,5]);
|
$query->where('type', $value);
|
||||||
})->whereHas('containers', function ($query){
|
})->whereHas('containers', function ($query){
|
||||||
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class EmailLike implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('email', 'LIKE', '%'.$value.'%');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -17,4 +17,4 @@ class HasInvoiceStatusIn implements Filter
|
|||||||
$query->where('type', 1)->whereIn('status', $value);
|
$query->where('type', 1)->whereIn('status', $value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class HasQuestionnaireGroupIn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('question.questionnaire', function (Builder $query) use ($value) {
|
|
||||||
$query->whereIn('group', $value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class HavePaymentStatusNotIn implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('transactions', function (Builder $query) use($value) {
|
|
||||||
$query->where('type', TransactionType::PAYMENT)->whereNotIn('status', $value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class IdNext implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('id', '>', $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class JobId implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('job_id', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class MarkingIn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('companyModules', function ($module) use ($value) {
|
|
||||||
$module->whereHas('connections', function ($connection) use ($value) {
|
|
||||||
$connection->whereIn('invitee_reference', $value);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class NextMainQuestion implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('next_main_question', $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class OrderByIdDesc implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->orderBy('id', 'desc');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class OrderByUpdatedAtDesc implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->orderBy('updated_at', 'desc');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use App\Models\Order;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class OrderMarkingIn implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('owner', function($query) use ($value) {
|
|
||||||
$query->where('reference', 'LIKE', '%' . $value . '%');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,8 +14,7 @@ class OwnerId implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
$table = $builder->getModel()->getTable();
|
return $builder->where('owner_id', $value);
|
||||||
return $builder->where("{$table}.owner_id", $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class OwnerType implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
$table = $builder->getModel()->getTable();
|
|
||||||
return $builder->where("{$table}.owner_type", $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class PackingListLimitOneByTypeOrderedByInvoiceDate implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->select('packing_lists.*')->join('transactions', function($join){
|
|
||||||
$join->on('transactions.owner_id', '=', 'packing_lists.id');
|
|
||||||
$join->where('transactions.owner_type', '=', PackingList::class);
|
|
||||||
$join->where('transactions.status', '=', ApprovalStatus::APPROVED);
|
|
||||||
$join->whereRaw('(transactions.type <> 16 OR transactions.id = (
|
|
||||||
SELECT id FROM transactions WHERE owner_id = packing_lists.id AND type = 16 LIMIT 1
|
|
||||||
))');
|
|
||||||
})->orderBy('transactions.updated_at', 'DESC');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class PaymentMethod implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('payment_method', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class PaymentMethodNotIn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereNotIn('payment_method', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class PostcodeLike implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('postcode', 'LIKE', '%'.$value.'%');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class QuestionId implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('question_id', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class QuestionNumber implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('question_number', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class QuestionnaireSetId implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('questionnaire_set_id', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class Receiver implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('receiver', '=', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class RequestSignature implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('request_signature', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class ResultNotNull implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereNotNull('result');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class ShortUrl implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('short_url', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -14,8 +14,7 @@ class StatusIn implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
$table = $builder->getModel()->getTable();
|
return $builder->whereIn('status', $value);
|
||||||
return $builder->whereIn("{$table}.status", $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class UserId implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('user_id', $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class WithAgingColumn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
$today = Carbon::now();
|
|
||||||
return $builder->select('packing_lists.*')
|
|
||||||
->addSelect(DB::raw("DATEDIFF('$today', transactions.updated_at) as days_over_duedate"))
|
|
||||||
->addSelect(DB::raw("CASE
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) <= 0 THEN 0
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) > 0 AND DATEDIFF('$today', transactions.updated_at) <= 30 THEN 1
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) > 30 AND DATEDIFF('$today', transactions.updated_at) <= 60 THEN 2
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) > 60 AND DATEDIFF('$today', transactions.updated_at) <= 90 THEN 3
|
|
||||||
ELSE 4
|
|
||||||
END AS due_date_number"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class WithContainersPackages implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
// Log::info('WithContainersPackages: '.$value);
|
|
||||||
// return $builder->with(['containers', 'packages']);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class WithOrderReferenceLike implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->join('transactions as t2', 't2.payment_reference', '=', 'transactions.bill_no')
|
|
||||||
->join('transactions as t3', 't3.id', '=', 't2.owner_id')
|
|
||||||
->join('packing_lists', 'packing_lists.id', '=', 't3.owner_id')
|
|
||||||
->join('orders', function ($join) use ($value) {
|
|
||||||
$join->on('orders.id', '=', 'packing_lists.owner_id')
|
|
||||||
->where('orders.reference', 'LIKE', '%'.$value.'%');
|
|
||||||
})
|
|
||||||
->addSelect(['transactions.*', 't2.id as paymentTransactionId', 't3.id as invoiceTransactionId', 'packing_lists.id as packingListId', 'orders.reference as orderReference']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class WithTrashed implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->withTrashed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,6 @@ namespace App\Classes\General;
|
|||||||
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class ExcelHandel
|
class ExcelHandel
|
||||||
{
|
{
|
||||||
@@ -69,23 +67,9 @@ class ExcelHandel
|
|||||||
public static function generateExcel($path = '', $exceldata = '', $filename = '', $extension = '')
|
public static function generateExcel($path = '', $exceldata = '', $filename = '', $extension = '')
|
||||||
{
|
{
|
||||||
$file_info = [];
|
$file_info = [];
|
||||||
$filesystemDriver = Storage::getDefaultDriver();
|
$file = \Storage::disk('public')->put('excels/' . $path . '/' . $filename . '.' . $extension, $exceldata);
|
||||||
if($filesystemDriver === 's3'){
|
$file_info['original']['file'] = storage_path('app/public/excels/' . $path . '/' . $filename . '.' . $extension);
|
||||||
$filePathForS3 = 'public/excels/' . $path . '/' . $filename . '.' . $extension;
|
|
||||||
Storage::disk('s3')->put($filePathForS3, $exceldata);
|
|
||||||
|
|
||||||
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
|
|
||||||
$filePathForS3,
|
|
||||||
Carbon::now()->addMinutes(10)
|
|
||||||
);
|
|
||||||
|
|
||||||
$file_info['original']['file'] = $temporaryUrl; //REMINDER: This is a path to AWS S3 URL (HTTPS) as a public anonymous user, NOT an internal system path
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$file = Storage::disk('public')->put('excels/' . $path . '/' . $filename . '.' . $extension, $exceldata);
|
|
||||||
$file_info['original']['file'] = storage_path('app/public/excels/' . $path . '/' . $filename . '.' . $extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $file_info;
|
return $file_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,4 +84,4 @@ class ExcelHandel
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Classes\General;
|
namespace App\Classes\General;
|
||||||
|
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class Helper
|
class Helper
|
||||||
{
|
{
|
||||||
@@ -25,36 +24,4 @@ class Helper
|
|||||||
return array_slice(get_class_methods($className), 1);
|
return array_slice(get_class_methods($className), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
}
|
||||||
* @param $log
|
|
||||||
*/
|
|
||||||
static function debugLogger($log){
|
|
||||||
if($log && isset($log['message'])){
|
|
||||||
$message = $log['message'];
|
|
||||||
$substring = 'No data were found';
|
|
||||||
if (isset($message)) {
|
|
||||||
if (strpos($message, $substring) !== false) {
|
|
||||||
// Log::info('Message exist');
|
|
||||||
} else {
|
|
||||||
Log::info($log['message']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ResourceCollection $collection
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
static function collectionResponse(ResourceCollection $collection){
|
|
||||||
return json_decode($collection->response()->getContent(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param null|string $json
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
static function deserializeFilters(?string $json): array {
|
|
||||||
return $json !== null ? collect(json_decode($json))->toArray() : [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class LogHelper
|
|
||||||
{
|
|
||||||
private String $channelName;
|
|
||||||
|
|
||||||
public static function channel($channelName): self
|
|
||||||
{
|
|
||||||
$logHelper = new self;
|
|
||||||
$logHelper->channelName = $channelName;
|
|
||||||
return $logHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function info($message)
|
|
||||||
{
|
|
||||||
$envVar = env('LARAVEL_VAPOR_ENABLED');
|
|
||||||
$isLocal = env('VAPOR_ENV') === 'local';
|
|
||||||
Log::info("LogHelper.info: {$message}, channelName: {$this->channelName}, envVar {$envVar}");
|
|
||||||
if ($envVar && !$isLocal) {
|
|
||||||
Log::channel($this->channelName.'_vapor')->info($message);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Log::channel($this->channelName)->info($message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function warning($message)
|
|
||||||
{
|
|
||||||
$envVar = env('LARAVEL_VAPOR_ENABLED');
|
|
||||||
$isLocal = env('VAPOR_ENV') === 'local';
|
|
||||||
Log::info("LogHelper.warning: {$message}, channelName: {$this->channelName}, envVar {$envVar}");
|
|
||||||
if ($envVar && !$isLocal) {
|
|
||||||
Log::channel($this->channelName . '_vapor')->warning($message);
|
|
||||||
} else {
|
|
||||||
Log::channel($this->channelName)->warning($message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function error($message)
|
|
||||||
{
|
|
||||||
$envVar = env('LARAVEL_VAPOR_ENABLED');
|
|
||||||
$isLocal = env('VAPOR_ENV') === 'local';
|
|
||||||
Log::info("LogHelper.error: {$message}, channelName: {$this->channelName}, envVar {$envVar}");
|
|
||||||
if ($envVar && !$isLocal) {
|
|
||||||
Log::channel($this->channelName . '_vapor')->error($message);
|
|
||||||
} else {
|
|
||||||
Log::channel($this->channelName)->error($message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class UrlHelper {
|
|
||||||
public static function getRouteParametersFromUrl($url) {
|
|
||||||
$parsedUrl = parse_url($url);
|
|
||||||
$path = $parsedUrl['path'];
|
|
||||||
|
|
||||||
$routes = Route::getRoutes();
|
|
||||||
|
|
||||||
foreach ($routes as $route) {
|
|
||||||
$request = Request::create($path, 'GET');
|
|
||||||
$route->bind($request);
|
|
||||||
if ($route->matches($request)) {
|
|
||||||
return $route->parameters();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\ApproveShippingInvoiceTransactionProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Exception;
|
|
||||||
|
|
||||||
class ApproveInvoiceV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Approve Invoice Command.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$invoices = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::PENDING_SUBMISSION)->get();
|
|
||||||
|
|
||||||
foreach ($invoices as $invoice) {
|
|
||||||
$packingList = $invoice->owner;
|
|
||||||
$order = $packingList->owner;
|
|
||||||
|
|
||||||
try {
|
|
||||||
(App()->make(ApproveShippingInvoiceTransactionProcessor::class))->execute($packingList);
|
|
||||||
Log::info('Invoice Approved for reference ' . $order->reference . '.');
|
|
||||||
} catch (Exception $exception) {
|
|
||||||
Log::info('Failed to Approve invoice for reference ' . $order->reference . '. Exception: ' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Approve Invoice Command. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
|
|
||||||
class AuditBillplzInvoiceV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Audit Billplz Invoice.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
$transactions = Transaction::where('type', TransactionType::SHIPPING_INVOICE)->where('status', ApprovalStatus::COMPLETED)->whereHas('transactions', function($query){
|
|
||||||
return $query->where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->where('status', ApprovalStatus::REJECTED);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$totalTransactions = count($transactions);
|
|
||||||
$counter = 1;
|
|
||||||
$totalAmount = 0;
|
|
||||||
foreach ($transactions as $transaction){
|
|
||||||
$payment_transaction = $transaction->transactions->sortByDesc('created_at')->first();
|
|
||||||
|
|
||||||
if ($payment_transaction->status === ApprovalStatus::REJECTED) {
|
|
||||||
Log::info($counter . ' of ' . $totalTransactions . '. Order Marking: '. $payment_transaction->owner->owner->owner->reference . '. Transaction Id: '. $payment_transaction->id . '. Invoice Id: '. $transaction->id . ' - Date: '.$payment_transaction->created_at->format('d-m-Y').' - Amount: '. $payment_transaction->amount);
|
|
||||||
|
|
||||||
$totalAmount += $transaction->amount;
|
|
||||||
|
|
||||||
$counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Audit Billplz Invoice. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class AuditBillplzPaymentV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Audit Billplz Payment.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::APPROVED])->get();
|
|
||||||
$totalTransactions = count($transactions);
|
|
||||||
$counter = 1;
|
|
||||||
$totalAmount = 0;
|
|
||||||
foreach ($transactions as $transaction){
|
|
||||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
if($data['paid']){
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$totalAmount += $transaction->amount;
|
|
||||||
Log::info($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
Log::info("billplz error</br>");
|
|
||||||
}
|
|
||||||
$counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Audit Billplz Payment. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class AutoGenerateInvoiceV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Auto generate invoice.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$packingLists = (App()->make(ListsPackingLists::class))->execute(['does_not_have_transaction_type' => 1, 'type' => 2]);
|
|
||||||
|
|
||||||
if (count($packingLists)) {
|
|
||||||
|
|
||||||
foreach ($packingLists as $packingList) {
|
|
||||||
$order = $packingList->owner;
|
|
||||||
if (!($order instanceof Order)) {
|
|
||||||
Log::info('Failed to generate invoice for reference' . $order->reference . '. It is not an instance of Order.');
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$companyModule = $order->companyModule;
|
|
||||||
$billingAddress = $companyModule->addresses()->where('type', \App\Classes\ValueObjects\Constants\AddressType::BILLING)->first();
|
|
||||||
$deliveryAddress = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
|
||||||
|
|
||||||
$postCodes = \App\Models\SegmentConstant::whereIn('reference', ['CENTER_POSTCODE', 'OUTSTATION_POSTCODE'])->get()->pluck('value')->flatten();
|
|
||||||
|
|
||||||
if (!!$billingAddress && in_array($deliveryAddress->postcode, $postCodes->toArray())) {
|
|
||||||
try {
|
|
||||||
(App()->make(CreateInvoiceTransactionProcessor::class))->execute($packingList);
|
|
||||||
Log::info('Invoice generated for reference ' . $order->reference . '.');
|
|
||||||
} catch (Exception $exception) {
|
|
||||||
Log::info('Failed to generate invoice for reference ' . $order->reference . '. Exception: ' . $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Log::info('Failed to generate invoice for reference ' . $order->reference . '. Billing Address is not defined / Postcode area is not defined.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Auto generate invoice. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CheckDeletedInvoiceButPaidV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Check all deleted invoice but has completed payment.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
$totalAmount = 0;
|
|
||||||
|
|
||||||
$softDeletedTransactions = Transaction::onlyTrashed()->where('type', TransactionType::SHIPPING_INVOICE)->whereHas('transactions', function (Builder $query) {
|
|
||||||
$query->where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
foreach ($softDeletedTransactions as $invoice) {
|
|
||||||
$invoice_payments = $invoice->transactions()->payments()->get();
|
|
||||||
|
|
||||||
foreach($invoice_payments as $invoice_payment) {
|
|
||||||
|
|
||||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$invoice_payment->payment_reference);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
|
|
||||||
$orderReference = $invoice->owner->owner->reference ?? null;
|
|
||||||
|
|
||||||
if($data['paid']){
|
|
||||||
Log::info('Invoice id: ' . $invoice->id. '. Payment id: ' . $invoice_payment->id . '. Order: ' . $orderReference);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
Log::info("billplz error</br>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Check all deleted invoice but has completed payment. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\Transactions\Services\ListsGroups;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CheckStorageInvoicesGroupTransactionsV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Check all pending group payment with storage invoice is valid.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
|
|
||||||
$newfilters['order_by_updated_at_desc'] = true;
|
|
||||||
$newfilters['status_in'] = [0, 1];
|
|
||||||
$groups = (App()->make(ListsGroups::class))->execute($newfilters);
|
|
||||||
|
|
||||||
foreach ($groups as $group){
|
|
||||||
Log::info('CheckForStorageInvoiceByTransactions group: '.json_encode($group));
|
|
||||||
foreach ($group->groupTransactions as $groupTransaction) {
|
|
||||||
$invoice = $groupTransaction->transaction;
|
|
||||||
$packingList = $invoice->owner()->first();
|
|
||||||
if($packingList){
|
|
||||||
$order = $packingList->owner()->first();
|
|
||||||
if($order instanceof Order){
|
|
||||||
$storages = (App()->make(CheckStorageInvoiceTransactionProcessor::class))->executeOrder($order);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Check all pending group payment with storage invoice is valid. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\Orders\Services\ListsOrders;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderType;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CheckStorageInvoicesOrdersV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Check all orders for storage invoice.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$orders = (App()->make(ListsOrders::class))->execute(['with_parcels' => true, 'type_in' => [OrderType::SHARED_CONTAINER, OrderType::DEDICATED_CONTAINER]]);
|
|
||||||
|
|
||||||
$count = 0;
|
|
||||||
foreach ($orders as $order){
|
|
||||||
try{
|
|
||||||
$storages = (App()->make(CheckStorageInvoiceTransactionProcessor::class))->executeOrder($order);
|
|
||||||
$count = $count + 1;
|
|
||||||
Log::info('Order '.$count);
|
|
||||||
}
|
|
||||||
catch(\Exception $ex){
|
|
||||||
Log::info('Exception '.$ex->getMessage());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Check all orders for storage invoice. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class DummyJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Dummy.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Dummy. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Models\Group;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FixApprovedPaymentFailedGroupV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Fix all payment is approved or completed but group failed to be updated.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
// $this->outputArray = [];
|
|
||||||
|
|
||||||
$groups = Group::whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
|
||||||
->whereHas('payment', function ($query) {
|
|
||||||
$query->whereIn('status', [2, 3]);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
foreach ($groups as $group) {
|
|
||||||
$transaction = $group->payment;
|
|
||||||
|
|
||||||
$response = Http::withBasicAuth(config('billplz.api_key') . ':', '')->get(config('billplz.base_url') . '/api/v3/bills/' . $transaction->payment_reference);
|
|
||||||
|
|
||||||
dump($transaction->payment_reference);
|
|
||||||
|
|
||||||
if ($response->successful()) {
|
|
||||||
$data = $response->json();
|
|
||||||
if ($data['paid']) {
|
|
||||||
$status = ApprovalStatus::PENDING_VERIFICATION;
|
|
||||||
|
|
||||||
if ($data['state'] === 'paid') {
|
|
||||||
$status = ApprovalStatus::APPROVED;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info(Carbon::now() . ' : Fixing ' . $transaction->payment_reference);
|
|
||||||
(App()->make(CallbackBillplzProcessor::class))->execute($transaction, $status);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log::info("billplz error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
|
|
||||||
// if ($groups) {
|
|
||||||
// $this->info(Carbon::now() . ' : Done . ElapsedTime: ' . $elapsedTime);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Fix all payment is approved or completed but group failed to be updated. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
|
||||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
|
||||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
|
||||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FixBillplzFailedCallbackPaymentV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
protected $transactionId;
|
|
||||||
|
|
||||||
public function __construct(int $transactionId)
|
|
||||||
{
|
|
||||||
$this->transactionId = $transactionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Fix failled callback from billplz.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$transaction = Transaction::where('id', $this->transactionId)->first();
|
|
||||||
|
|
||||||
Log::info('Billplz Url: '.config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
|
||||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
if($data['paid']) {
|
|
||||||
$status = ApprovalStatus::PENDING_VERIFICATION;
|
|
||||||
|
|
||||||
if($data['state'] === 'paid') {
|
|
||||||
$status = ApprovalStatus::APPROVED;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info(Carbon::now() . ' : Fixing ' . $transaction->payment_reference);
|
|
||||||
(App()->make(CallbackBillplzProcessor::class))->execute($transaction, $status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Log::info("billplz error");
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Fix failled callback from billplz. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Models\Container;
|
|
||||||
use App\Models\ContainerPackingList;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FixDuplicateContainerReferenceV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Fix Duplicate Container Reference.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
|
|
||||||
$duplicatedContainers = Container::select('reference', DB::raw('COUNT(reference) as count'))
|
|
||||||
->groupBy('reference')
|
|
||||||
->having('count', '>', 1)
|
|
||||||
->get();
|
|
||||||
|
|
||||||
foreach ($duplicatedContainers as $duplicatedContainer) {
|
|
||||||
$containers = Container::where('reference', $duplicatedContainer->reference)->get();
|
|
||||||
|
|
||||||
$containers = $containers->sortByDesc(function ($container) {
|
|
||||||
return $container->packingLists->count();
|
|
||||||
});
|
|
||||||
|
|
||||||
$firstContainer = $containers->shift();
|
|
||||||
|
|
||||||
foreach ($containers as $container) {
|
|
||||||
$firstContainer->packingLists()->syncWithoutDetaching($container->packingLists);
|
|
||||||
$container->packingLists()->detach();
|
|
||||||
Log::info('Deleted container ' . $container->id);
|
|
||||||
$container->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Fix Duplicate Container Reference. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
|
||||||
use App\Classes\Modules\Transactions\Processors\CreateStorageInvoiceDocTransactionFixProcessor;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FixGroupPaymentProblemV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Fix Group Payment Problem.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
/*
|
|
||||||
$group = $this->fetchesGroup->execute(['id' => 325]);
|
|
||||||
$this->info('FixGroupPaymentProblem group: '.json_encode($group));
|
|
||||||
if ($group) {
|
|
||||||
foreach ($group->groupTransactions as $groupTransaction) {
|
|
||||||
$invoice = $groupTransaction->transaction;
|
|
||||||
$this->info('FixGroupPaymentProblem group: '.json_encode($invoice));
|
|
||||||
$pL = $invoice->owner;
|
|
||||||
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$order = (App()->make(FetchesOrder::class))->execute(['reference' => '729251424']);
|
|
||||||
$packingLists = $order->destinationWarehousePackages;
|
|
||||||
|
|
||||||
foreach ($packingLists as $packingList){
|
|
||||||
(App()->make(CreateStorageInvoiceDocTransactionFixProcessor::class))->execute($packingList, true);
|
|
||||||
dd(json_encode($packingList));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Fix Group Payment Problem. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
|
||||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
|
||||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\FixInvoiceV2CommandObject;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\CompanyConnection;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FixInvoiceV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var FixInvoiceV2CommandObject*/
|
|
||||||
private $fixInvoiceV2CommandObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FixInvoiceV2CommandJob constructor.
|
|
||||||
* @param FixInvoiceV2CommandObject $fixInvoiceV2CommandObject
|
|
||||||
*/
|
|
||||||
public function __construct(FixInvoiceV2CommandObject $fixInvoiceV2CommandObject)
|
|
||||||
{
|
|
||||||
$this->fixInvoiceV2CommandObject = $fixInvoiceV2CommandObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Fix invoice.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$connection = CompanyConnection::where('invitee_reference', $this->fixInvoiceV2CommandObject->getMarking())->first();
|
|
||||||
$company_module_id = $connection->invitee->id;
|
|
||||||
|
|
||||||
$orders = Order::where('company_module_id', $company_module_id)->get();
|
|
||||||
|
|
||||||
foreach ($orders as $order){
|
|
||||||
$invoices = $order->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get();
|
|
||||||
foreach ($invoices as $invoice){
|
|
||||||
|
|
||||||
dump($invoice->id);
|
|
||||||
|
|
||||||
$invoice->documents()->delete();
|
|
||||||
|
|
||||||
$view = 'pages.pdfs.shipping_invoice';
|
|
||||||
$dateToCompare = Carbon::parse(env('SST_START_DATE', '2024-04-01 00:00:00'));
|
|
||||||
$shippingInvoiceTransactionCreatedDate = Carbon::parse($invoice->created_at);
|
|
||||||
if ($shippingInvoiceTransactionCreatedDate->isAfter($dateToCompare) && $invoice->tax > 0) {
|
|
||||||
$view = 'pages.pdfs.shipping_invoice_sst';
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction_invoice_pdf = LaravelMpdf::loadView($view, ['invoice_transaction' => $invoice]);
|
|
||||||
|
|
||||||
$document_object = new DocumentObject(
|
|
||||||
DocumentType::SHIPPING_INVOICE,
|
|
||||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
|
||||||
'',
|
|
||||||
ApprovalStatus::COMPLETED,
|
|
||||||
'shipping_invoice'
|
|
||||||
);
|
|
||||||
|
|
||||||
/** @var Document $document */
|
|
||||||
$document = (App()->make(CreatesDocument::class))->execute($invoice, $document_object);
|
|
||||||
|
|
||||||
(App()->make(CreatesFiles::class))->execute($document, $document_object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Fix invoice. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListsFromYdPortalProcessor;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FixMissingPackingListV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Fix Missing PackingList.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$start_date = '2024-05-05';
|
|
||||||
$end_date = '2024-05-05';
|
|
||||||
|
|
||||||
$start = $start_date ? Carbon::parse($start_date) : null;
|
|
||||||
$end = $end_date ? Carbon::parse($end_date) : null;
|
|
||||||
|
|
||||||
if (!$start || !$end) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute($start, $end);
|
|
||||||
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Fix Missing PackingList. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FixPackingListV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Fix PackingList.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$packingLists = PackingList::whereDoesntHave('packages')->get();
|
|
||||||
|
|
||||||
if ($packingLists->isNotEmpty()) {
|
|
||||||
|
|
||||||
$restoredPackagesCount = 0;
|
|
||||||
$restoredPackagesIds = [];
|
|
||||||
|
|
||||||
// Eager loading packages for all packing lists
|
|
||||||
$packingLists->load(['packages' => function ($query) {
|
|
||||||
$query->onlyTrashed();
|
|
||||||
}]);
|
|
||||||
|
|
||||||
foreach ($packingLists as $packingList) {
|
|
||||||
$deletedPackages = $packingList->packages->filter(function ($package) use ($restoredPackagesIds) {
|
|
||||||
// Filter out packages that have already been restored
|
|
||||||
return !in_array($package->id, $restoredPackagesIds);
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($deletedPackages->isNotEmpty()) {
|
|
||||||
$groupedPackages = $deletedPackages->groupBy(function ($item) {
|
|
||||||
return $item->only(['type', 'description', 'width', 'height', 'length', 'weight', 'quantity']);
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach ($groupedPackages as $group) {
|
|
||||||
$latestPackage = $group->sortByDesc('created_at')->first();
|
|
||||||
|
|
||||||
// Check if the package ID is already restored before attempting to restore it
|
|
||||||
if (!in_array($latestPackage->id, $restoredPackagesIds)) {
|
|
||||||
$latestPackage->restore();
|
|
||||||
Log::info('Package ID: ' . $latestPackage->id . ' has been restored');
|
|
||||||
$restoredPackagesCount++;
|
|
||||||
$restoredPackagesIds[] = $latestPackage->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info('Restored Packages Count: ' . $restoredPackagesCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Fix PackingList. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\File;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
|
|
||||||
class HouseKeepingS3FilesV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Housekeeping temporary files in S3 Bucket.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$s3 = Storage::disk('s3');
|
|
||||||
$directories = [
|
|
||||||
'temp',
|
|
||||||
];
|
|
||||||
foreach ($directories as $directory) {
|
|
||||||
$startInner = Carbon::now();
|
|
||||||
Log::info(Carbon::now() . ' [HouseKeepingS3FilesV2] Start cleaning - ' . $directory);
|
|
||||||
|
|
||||||
$objects = $s3->allFiles($directory);
|
|
||||||
|
|
||||||
foreach ($objects as $object) {
|
|
||||||
$s3->delete($object);
|
|
||||||
Log::info('[HouseKeepingS3FilesV2] Deleted object: ' . $object);
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info('[HouseKeepingS3FilesV2] All files have been deleted.');
|
|
||||||
|
|
||||||
$endInner = Carbon::now();
|
|
||||||
$elapsedTime = $startInner->diff($endInner)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ' [HouseKeepingS3FilesV2] Process ended. ElapsedTime: ' . $elapsedTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Housekeeping temporary files in S3 Bucket. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Accounts\Services\ExpiresEmailVerificationAttempt;
|
|
||||||
use App\Models\UserEmailVerification;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class NewUserRegistrationExpireCheckV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - New user email verification expiration check.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$attempts = UserEmailVerification::active()->twoDaysOld()->get();
|
|
||||||
|
|
||||||
Log::info('NewUser Carbon now()->subHours(48): '. Carbon::now()->subHours(48));
|
|
||||||
Log::info('NewUser Attempts count: '.count($attempts));
|
|
||||||
|
|
||||||
foreach ($attempts as $attempt){
|
|
||||||
(new ExpiresEmailVerificationAttempt())->execute($attempt);
|
|
||||||
Log::info('NewUser Expired: '.$attempt->id.', '.$attempt->created_at);
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - New user email verification expiration check. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzDataPatchProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class OneTimeTransactionFixBillplzFailedCbV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - One time fix failled callback from billplz for transaction with id 17310 cron ended.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
//Transaction fix with this one time fix command: 15205, 16803, 17310
|
|
||||||
//This transaction, 16803 has approve payment but not its owner, shipping invoice
|
|
||||||
$transaction = Transaction::whereIn('id', [17310])->first();
|
|
||||||
Log::info(Carbon::now() . ' : One time fix failled callback from billplz for transaction with id 17310 cron started.');
|
|
||||||
|
|
||||||
if($transaction && $transaction->id == 17310){
|
|
||||||
|
|
||||||
Log::info(Carbon::now() . ' : 17310.');
|
|
||||||
$status = ApprovalStatus::APPROVED;
|
|
||||||
// $this->callbackBillplzProcessor->execute($transaction, $status);
|
|
||||||
(App()->make(CallbackBillplzDataPatchProcessor::class))->execute($transaction, $status);
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - One time fix failled callback from billplz for transaction with id 17310 cron ended. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Accounts\Services\ExpiresPasswordReset;
|
|
||||||
use App\Models\PasswordReset;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class PasswordResetTokenExpirationV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Password reset token expiration check.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$attempts = PasswordReset::active()->oneDayOld()->get();
|
|
||||||
|
|
||||||
Log::info('PasswordReset Carbon now()->subHours(24): '. Carbon::now()->subHours(24));
|
|
||||||
Log::info('PasswordReset Attempts count: '.count($attempts));
|
|
||||||
|
|
||||||
foreach ($attempts as $attempt){
|
|
||||||
(new ExpiresPasswordReset())->execute($attempt);
|
|
||||||
Log::info('PasswordReset Expired: '.$attempt->id.', '.$attempt->created_at);
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Password reset token expiration check. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Notifications\ShipmentDepartureEmail;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\Container;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class SendContainerDepartureEmailV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Send Container Departure Email.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$containers = Container::whereHas('transports', function ($transport){
|
|
||||||
return $transport->whereDate('dispatch_date', '=', Carbon::today());
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
foreach ($containers as $container){
|
|
||||||
foreach ($container->packingLists as $packingList){
|
|
||||||
if(!($packingList->owner instanceof Order)) continue;
|
|
||||||
$user = $packingList->owner->companyModule->employees()->first();
|
|
||||||
if(app()->environment(['production'])) {
|
|
||||||
$user->notify(new ShipmentDepartureEmail($user, $packingList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Send Container Departure Email. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Notifications\PermitsReminderEmail;
|
|
||||||
use App\Models\PermitsReminder;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class SendPermitsReminderEmailsV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Send Permits Reminders Email.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$currentDateTime = now();
|
|
||||||
$startRange = $currentDateTime->subDays(3)->startOfDay();
|
|
||||||
$endRange = $currentDateTime->copy()->addDays(6)->endOfDay();
|
|
||||||
|
|
||||||
$reminders = PermitsReminder::whereDate('reminder_date', '>=', $startRange)
|
|
||||||
->whereDate('reminder_date', '<=', $endRange)
|
|
||||||
->orWhere('reminder_date', '<', now())
|
|
||||||
->pluck('model');
|
|
||||||
|
|
||||||
if ($reminders->isEmpty()) {
|
|
||||||
Log::info('No reminders expiring within the specified range.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info($this->getTimeStamp() . 'Reminders: ' . $reminders->toJson());
|
|
||||||
|
|
||||||
$users = User::whereIn('email', $this->getEmailList())->get();
|
|
||||||
|
|
||||||
foreach ($users as $user) {
|
|
||||||
Log::info($this->getTimeStamp() . 'Reminder email sent to ' . $user->email);
|
|
||||||
if (app()->environment('production')) {
|
|
||||||
$user->notify(new PermitsReminderEmail($user, $reminders));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Send Permits Reminders Email. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTimeStamp()
|
|
||||||
{
|
|
||||||
return '[' . Carbon::now()->format('Y-m-d H:i:s') . '] - ';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getEmailList(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
// 'edmond.wuiming2021@gmail.com',
|
|
||||||
'anithagurl96@gmail.com'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\ShowBillplzPaymentStatusV2CommandObject;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class ShowBillplzPaymentStatusV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
/** @var ShowBillplzPaymentStatusV2CommandObject*/
|
|
||||||
private $showBillplzPaymentStatusV2CommandObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ShowBillplzPaymentStatusV2CommandJob constructor.
|
|
||||||
* @param ShowBillplzPaymentStatusV2CommandObject $showBillplzPaymentStatusV2CommandObject
|
|
||||||
*/
|
|
||||||
public function __construct(ShowBillplzPaymentStatusV2CommandObject $showBillplzPaymentStatusV2CommandObject)
|
|
||||||
{
|
|
||||||
$this->showBillplzPaymentStatusV2CommandObject = $showBillplzPaymentStatusV2CommandObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Show Billplz payment status.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
$billplz_id = $this->showBillplzPaymentStatusV2CommandObject->getBillplzId();
|
|
||||||
$billplz_id = explode(",", $billplz_id);
|
|
||||||
|
|
||||||
foreach ($billplz_id as $payment) {
|
|
||||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$payment);
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
dump($data);
|
|
||||||
}else{
|
|
||||||
Log::info("billplz error</br>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Show Billplz payment status. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class ShowFailediBllplzCallbackV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Show all failled callback from billplz.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
|
|
||||||
$transactions = Transaction::whereIn('type', [TransactionType::PAYMENT, TransactionType::TOP_UP, TransactionType::GROUP_PAYMENT])->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
|
||||||
$totalTransactions = count($transactions);
|
|
||||||
|
|
||||||
if ($totalTransactions) {
|
|
||||||
Log::info(Carbon::now() . ' totalTransactions : ' . $totalTransactions);
|
|
||||||
}
|
|
||||||
|
|
||||||
$counter = 1;
|
|
||||||
$totalAmount = 0;
|
|
||||||
foreach ($transactions as $transaction){
|
|
||||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
if($data['paid']){
|
|
||||||
dump($transaction->payment_reference);
|
|
||||||
dump($transaction->id);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
Log::info("billplz error</br>");
|
|
||||||
}
|
|
||||||
$counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if ($totalTransactions) {
|
|
||||||
// Log::info(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Show all failled callback from billplz. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class ShowFixBillplzFailedCallbackPaymentV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Show Billplz Failled Callback.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
// $this->outputArray = [];
|
|
||||||
|
|
||||||
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
|
|
||||||
|
|
||||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
|
||||||
$totalTransactions = count($transactions);
|
|
||||||
$counter = 1;
|
|
||||||
$totalAmount = 0;
|
|
||||||
foreach ($transactions as $transaction){
|
|
||||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference);
|
|
||||||
|
|
||||||
if($response->successful()){
|
|
||||||
$data = $response->json();
|
|
||||||
if($data['paid']){
|
|
||||||
$totalAmount += $transaction->amount;
|
|
||||||
$invoiceStatus = null;
|
|
||||||
|
|
||||||
switch($transaction->owner->status) {
|
|
||||||
case 3:
|
|
||||||
$invoiceStatus = 'Payment Completed';
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
$invoiceStatus = 'Dispute in progress';
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
$invoiceStatus = 'Cancelled Invoice';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$invoiceStatus = 'Pending Payment';
|
|
||||||
}
|
|
||||||
|
|
||||||
$order = $transaction->owner->owner->owner;
|
|
||||||
|
|
||||||
if(!$order instanceof Order) {
|
|
||||||
Log::info("Error transaction id:" . $transaction->id . 'Type: ' . get_class($order));
|
|
||||||
} else {
|
|
||||||
Log::info($counter . ' of ' . $totalTransactions . '. Order: '. $order->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount . '. Status: ' . $approvalStatusArray[$transaction->status] . '. Invoice Status: ' . $invoiceStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// $totalAmount += $transaction->amount;
|
|
||||||
// $this->appendToOutput($counter . ' of ' . $totalTransactions . '. Order: '. $transaction->owner->owner->owner->reference . ' - Date: '.$transaction->owner->created_at->format('d-m-Y').' - Amount: '. $transaction->amount);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
Log::info("billplz error</br>");
|
|
||||||
}
|
|
||||||
$counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Show Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
|
||||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
|
||||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class SuccessUpdatePaymentStatusV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Success Updated Payment Status.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
// ini_set('memory_limit', '-1');
|
|
||||||
// $this->outputArray = [];
|
|
||||||
|
|
||||||
$approvalStatusArray = ApprovalStatus::APPROVAL_STATUS_ID;
|
|
||||||
|
|
||||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)
|
|
||||||
->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)
|
|
||||||
->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
|
|
||||||
->get();
|
|
||||||
|
|
||||||
foreach ($transactions as $payment) {
|
|
||||||
$invoice = $payment->owner ?? null;
|
|
||||||
if (!$invoice) {
|
|
||||||
Log::info('Payment has no owner. Payment ID: ' . $payment->id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$packingList = $invoice->owner ?? null;
|
|
||||||
if (!$packingList) {
|
|
||||||
Log::info('Invoice has no owner. Invoice ID: ' . $invoice->id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$order = $packingList->owner;
|
|
||||||
if (!$invoice) {
|
|
||||||
Log::info('PackingList has no owner. PackingList ID: ' . $packingList->id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($invoice->status == ApprovalStatus::APPROVED) {
|
|
||||||
|
|
||||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
|
||||||
|
|
||||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
|
||||||
(App()->make(UpdatesTransactionStatus::class))->execute($invoice, ApprovalStatus::COMPLETED);
|
|
||||||
|
|
||||||
$packingList->status = ApprovalStatus::APPROVED;
|
|
||||||
$packingList->save();
|
|
||||||
|
|
||||||
if(app()->environment('production')){
|
|
||||||
(App()->make(UpdateDoFromVTPortalProcessor::class))->execute($packingList);
|
|
||||||
(App()->make(UpdateDoFromYDPortalProcessor::class))->execute($packingList);
|
|
||||||
}
|
|
||||||
|
|
||||||
dump('Updated invoice ' . $invoice->id . '. Order: '. $order->reference);
|
|
||||||
} else {
|
|
||||||
Log::info('Failed Update invoice ' . $invoice->id . ' because payment not enough. Invoice Amount: ' . $invoice->amount . ' . Paid Amount: ' . $totalPaidAmount . ' . Order: '. $order->reference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Success Updated Payment Status. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Models\Container;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Classes\Notifications\ShipmentDepartureEmail;
|
|
||||||
|
|
||||||
class TestAttachingS3FileAndSendEmailV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Test to attach a file from S3 bucket and trigger an email send.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
$containers = Container::whereHas('transports', function ($transport){
|
|
||||||
return $transport->whereDate('dispatch_date', '<', Carbon::today())->whereDate('dispatch_date', '>', Carbon::now()->subdays(30));
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
Log::info("[TESTING] total containers: " . count($containers));
|
|
||||||
|
|
||||||
$sent = false;
|
|
||||||
foreach ($containers as $container){
|
|
||||||
if($sent){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
foreach ($container->packingLists as $packingList){
|
|
||||||
if($sent){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!($packingList->owner instanceof Order)) continue;
|
|
||||||
$user = $packingList->owner->companyModule->employees()->first();
|
|
||||||
$user = User::where('email', 'dillonngoweijoon@gmail.com')->first();
|
|
||||||
|
|
||||||
Log::info("[TESTING] user: " . json_encode($user));
|
|
||||||
Log::info("[TESTING] packingList: " . json_encode($packingList));
|
|
||||||
|
|
||||||
$user->notify(new ShipmentDepartureEmail($user, $packingList));
|
|
||||||
$sent = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Test to attach a file from S3 bucket and trigger an email send. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Classes\Modules\Exports\Services\ExportsNullDebtors;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
|
||||||
use App\Models\Company;
|
|
||||||
|
|
||||||
class TestExportExcelToS3BucketV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Test Export Excel File to S3 Bucket.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
Log::info('company 0');
|
|
||||||
|
|
||||||
$company = Company::where(function($query){
|
|
||||||
$query->whereNull('debtor')->orWhere('debtor', '');
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
Log::info('company 1: ' . json_encode($company));
|
|
||||||
|
|
||||||
$company = Company::where(function($query){
|
|
||||||
$query->whereNull('debtor')->orWhere('debtor', '');
|
|
||||||
})->whereHas('companyModules', function($query){
|
|
||||||
$query->where('type', BusinessType::IMPORTER);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
Log::info('company 2: ' . json_encode($company));
|
|
||||||
|
|
||||||
$company = Company::where(function($query){
|
|
||||||
$query->whereNull('debtor')->orWhere('debtor', '');
|
|
||||||
})->whereHas('companyModules', function($query){
|
|
||||||
$query->where('type', BusinessType::IMPORTER);
|
|
||||||
})->whereHas('parcels', function ($query) {
|
|
||||||
$query->where('packages.status', ApprovalStatus::APPROVED);
|
|
||||||
|
|
||||||
})
|
|
||||||
->with(['companyModules', 'parcels'])
|
|
||||||
->get();
|
|
||||||
|
|
||||||
Log::info('company 3: ' . json_encode($company));
|
|
||||||
|
|
||||||
$company = Company::where(function($query){
|
|
||||||
$query->whereNull('debtor')->orWhere('debtor', '');
|
|
||||||
})->whereHas('companyModules', function($query){
|
|
||||||
$query->where('type', BusinessType::IMPORTER);
|
|
||||||
})->whereHas('parcels')->where('status', ApprovalStatus::APPROVED)->get();
|
|
||||||
|
|
||||||
Log::info('company 4: ' . json_encode($company));
|
|
||||||
|
|
||||||
$export = new ExportsNullDebtors();
|
|
||||||
$filesystemDriver = Storage::getDefaultDriver();
|
|
||||||
|
|
||||||
if ($filesystemDriver === 's3') {
|
|
||||||
$filePathForS3 = 'temp/nullDebtor.xlsx'; //documents/exports
|
|
||||||
$excelFile = $export->store($filePathForS3, 's3');
|
|
||||||
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
|
|
||||||
$filePathForS3,
|
|
||||||
Carbon::now()->addMinutes(10)
|
|
||||||
);
|
|
||||||
Log::info('temporaryUrl: ' . $temporaryUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Test Export Excel File to S3 Bucket. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\TestFetchPackingListsFromYdPortalProcessor;
|
|
||||||
|
|
||||||
class TestReadDataFromYDAPIV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info(Carbon::now() . ': Start job - Test to read data from YD API.');
|
|
||||||
$start = new Carbon();
|
|
||||||
|
|
||||||
(App()->make(TestFetchPackingListsFromYdPortalProcessor::class))->execute();
|
|
||||||
|
|
||||||
$end = new Carbon();
|
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
||||||
Log::info(Carbon::now() . ': End job - Test to read data from YD API. ElapsedTime: ' . $elapsedTime . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchContainersFromYdPortalV2Processor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersUpdatesFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchDeliveryUpdatesFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchContainersFromYdPortalV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
protected $packingList;
|
|
||||||
|
|
||||||
public function __construct(PackingList $packingList)
|
|
||||||
{
|
|
||||||
$this->packingList = $packingList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info('Processing FetchContainersFromYdPortalV2CommandJob');
|
|
||||||
$processor = app(FetchContainersFromYdPortalV2Processor::class);
|
|
||||||
$processor->execute($this->packingList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchContainersUpdatesFromYdPortalV2Processor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchDeliveryUpdatesFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
|
||||||
use App\Models\Container;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchContainersUpdatesFromYdPortalV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
protected $container;
|
|
||||||
|
|
||||||
public function __construct(Container $container)
|
|
||||||
{
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info('Processing FetchContainersUpdatesFromYdPortalV2CommandJob');
|
|
||||||
$processor = app(FetchContainersUpdatesFromYdPortalV2Processor::class);
|
|
||||||
$processor->execute($this->container);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersUpdatesFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchDeliveryUpdatesFromYdPortalV2Processor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchDeliveryUpdatesFromYdPortalV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
protected $packingListId;
|
|
||||||
|
|
||||||
public function __construct(int $packingListId)
|
|
||||||
{
|
|
||||||
$this->packingListId = $packingListId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info('Processing FetchDeliveryUpdatesFromYdPortalV2CommandJob');
|
|
||||||
$processor = app(FetchDeliveryUpdatesFromYdPortalV2Processor::class);
|
|
||||||
$processor->execute($this->packingListId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchOrderListsFromYdPortalV2Processor;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchOrderListsFromYdPortalV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
protected $startDate;
|
|
||||||
protected $endDate;
|
|
||||||
|
|
||||||
public function __construct(?Carbon $startDate, ?Carbon $endDate)
|
|
||||||
{
|
|
||||||
$this->startDate = $startDate;
|
|
||||||
$this->endDate = $endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info('Processing FetchOrderListsFromYdPortalV2CommandJob for start date: ' . $this->startDate. ', and end date: ' . $this->endDate);
|
|
||||||
$processor = app(FetchOrderListsFromYdPortalV2Processor::class);
|
|
||||||
$processor->execute($this->startDate, $this->endDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs\Commands\V2\YD;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\V2\FetchPackingListsFromYdPortalV2Processor;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchPackingListsFromYdPortalV2CommandJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
protected $startDate;
|
|
||||||
protected $endDate;
|
|
||||||
|
|
||||||
public function __construct(?Carbon $startDate, ?Carbon $endDate)
|
|
||||||
{
|
|
||||||
$this->startDate = $startDate;
|
|
||||||
$this->endDate = $endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info('Processing FetchPackingListsFromYdPortalV2CommandJob for start date: ' . $this->startDate. ', and end date: ' . $this->endDate);
|
|
||||||
$processor = app(FetchPackingListsFromYdPortalV2Processor::class);
|
|
||||||
$processor->execute($this->startDate, $this->endDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMLead;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
|
||||||
|
|
||||||
class CreatePerfexCRMCustomer implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var CreateLeadPerfexCRMObject */
|
|
||||||
private $createLeadPerfexCRMObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreatePerfexCRMCustomer constructor.
|
|
||||||
* @param CreateLeadPerfexCRMObject $createLeadPerfexCRMObject
|
|
||||||
*/
|
|
||||||
public function __construct(CreateLeadPerfexCRMObject $createLeadPerfexCRMObject)
|
|
||||||
{
|
|
||||||
$this->createLeadPerfexCRMObject = $createLeadPerfexCRMObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$lead = (App()->make(FetchesPerfexCRMLead::class))->execute($this->createLeadPerfexCRMObject->getEmail());
|
|
||||||
if(!is_null($lead)){
|
|
||||||
(App()->make(UpdatesPerfexCRMLead::class))->execute($lead, $this->createLeadPerfexCRMObject->getCompanyReference());
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
(App()->make(CreatePerfexCRMLeadProcessor::class))->execute($this->createLeadPerfexCRMObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
|
|
||||||
class CreatePerfexCRMInvoice implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var Transaction $transaction*/
|
|
||||||
private $transaction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreatePerfexCRMInvoice constructor.
|
|
||||||
* @param Transaction $transaction
|
|
||||||
*/
|
|
||||||
public function __construct(Transaction $transaction)
|
|
||||||
{
|
|
||||||
$this->transaction = $transaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
(App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($this->transaction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMTaskProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
class CreatePerfexCRMSingleTask implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var FetchesPerfexCRMLead */
|
|
||||||
private $fetchesPerfexCRMLead;
|
|
||||||
|
|
||||||
/** @var CreateTaskPerfexCRMObject */
|
|
||||||
private $createTaskPerfexCRMObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreatePerfexCRMSingleTask constructor.
|
|
||||||
* @param CreateTaskPerfexCRMObject $createTaskPerfexCRMObject
|
|
||||||
*/
|
|
||||||
public function __construct(CreateTaskPerfexCRMObject $createTaskPerfexCRMObject)
|
|
||||||
{
|
|
||||||
$this->createTaskPerfexCRMObject = $createTaskPerfexCRMObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$lead = (App()->make(FetchesPerfexCRMLead::class))->execute($this->createTaskPerfexCRMObject->getEmail());
|
|
||||||
if(!is_null($lead))
|
|
||||||
{
|
|
||||||
$this->createTaskPerfexCRMObject->setLeadId($lead->id);
|
|
||||||
(App()->make(CreatePerfexCRMTaskProcessor::class))->execute($this->createTaskPerfexCRMObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,18 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Classes\Jobs;
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchContainersUpdatesFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchDeliveryUpdatesFromYdPortalProcessor;
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\FetchPackingListsFromYdPortalProcessor;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
@@ -30,17 +25,8 @@ class FetchOrdersFromYDPortalJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
Log::info('FetchOrdersFromYDPortalJob starts');
|
|
||||||
Log::info('FetchPackingListsFromYdPortalProcessor starts');
|
(App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute();
|
|
||||||
Log::info('FetchContainersFromYdPortalProcessor starts');
|
|
||||||
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
|
||||||
Log::info('FetchContainersUpdatesFromYdPortalProcessor starts');
|
|
||||||
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
|
||||||
Log::info('FetchDeliveryUpdatesFromYdPortalProcessor starts');
|
|
||||||
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
|
||||||
Log::info('FetchOrdersFromYDPortalJob ends');
|
|
||||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\ListPackingListsJobProcessor;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\JobSubmissionObject;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
class ListPackingListsJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public $timeout = 900;
|
|
||||||
|
|
||||||
/** @var JobSubmissionObject */
|
|
||||||
private $jobSubmissionObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ListPackingListsJob constructor.
|
|
||||||
* @param JobSubmissionObject $JobSubmissionObject
|
|
||||||
*/
|
|
||||||
public function __construct(JobSubmissionObject $jobSubmissionObject)
|
|
||||||
{
|
|
||||||
$this->jobSubmissionObject = $jobSubmissionObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$rawPayload = $this->job->payload();
|
|
||||||
if(isset($rawPayload['data']['commandName'])){
|
|
||||||
$this->jobSubmissionObject->setJobCommandName($rawPayload['data']['commandName']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($rawPayload['data']['command'])){
|
|
||||||
$this->jobSubmissionObject->setJobCommand($rawPayload['data']['command']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = (App()->make(ListPackingListsJobProcessor::class))->execute($this->jobSubmissionObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\Reports\Processors\MonthlyReportJobProcessor;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\JobSubmissionObject;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
class MonthlyReportJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public $timeout = 900;
|
|
||||||
|
|
||||||
/** @var JobSubmissionObject */
|
|
||||||
private $jobSubmissionObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MonthlyReportJob constructor.
|
|
||||||
* @param JobSubmissionObject $jobSubmissionObject
|
|
||||||
*/
|
|
||||||
public function __construct(JobSubmissionObject $jobSubmissionObject)
|
|
||||||
{
|
|
||||||
$this->jobSubmissionObject = $jobSubmissionObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$rawPayload = $this->job->payload();
|
|
||||||
if(isset($rawPayload['data']['commandName'])){
|
|
||||||
$this->jobSubmissionObject->setJobCommandName($rawPayload['data']['commandName']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($rawPayload['data']['command'])){
|
|
||||||
$this->jobSubmissionObject->setJobCommand($rawPayload['data']['command']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = (App()->make(MonthlyReportJobProcessor::class))->execute($this->jobSubmissionObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\FetchPerfexCRMInvoiceProcessor;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
|
|
||||||
|
|
||||||
|
|
||||||
class UpdatePerfexCRM implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var UpdatePerfexCRMObject */
|
|
||||||
private $updatePerfexCRMObject;
|
|
||||||
|
|
||||||
/** @var */
|
|
||||||
private $transaction;
|
|
||||||
|
|
||||||
/** @var bool|null */
|
|
||||||
private $shouldCreateInvoice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdatePerfexCRM constructor.
|
|
||||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
|
||||||
* @param Transaction $transaction
|
|
||||||
* @param bool|null $shouldCreateInvoice
|
|
||||||
*/
|
|
||||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, ?bool $shouldCreateInvoice = false)
|
|
||||||
{
|
|
||||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
|
||||||
$this->transaction = $transaction;
|
|
||||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//To use invoice as a reference to decide whether more tasks should be created
|
|
||||||
$this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice());
|
|
||||||
|
|
||||||
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
|
||||||
if($this->transaction != null && $this->shouldCreateInvoice){
|
|
||||||
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
|
||||||
$this->updatePerfexCRMObject->getContactEmail(),
|
|
||||||
$result->projectId,
|
|
||||||
$this->transaction,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceOject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getInvoiceIdOrCreateInvoice(){
|
|
||||||
if($this->transaction != null){
|
|
||||||
$fetchPerfexCRMInvoiceObject = new FetchPerfexCRMInvoiceObject(
|
|
||||||
$this->updatePerfexCRMObject->getContactEmail(),
|
|
||||||
$this->transaction
|
|
||||||
);
|
|
||||||
$invoiceId = (App()->make(FetchPerfexCRMInvoiceProcessor::class))->execute($fetchPerfexCRMInvoiceObject);
|
|
||||||
return $invoiceId;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoicePayment;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMCustomer;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMInvoice;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\Classes\General\Helper;
|
|
||||||
use App\Classes\General\LogHelper;
|
|
||||||
|
|
||||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var UpdatePerfexCRMInvoiceObject */
|
|
||||||
private $updatePerfexCRMInvoiceObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreatePerfexCRMSingleTask constructor.
|
|
||||||
* @param UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject
|
|
||||||
*/
|
|
||||||
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
|
||||||
{
|
|
||||||
$this->updatePerfexCRMInvoiceObject = $updatePerfexCRMInvoiceObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//get the client id
|
|
||||||
$customer = (App()->make(FetchesPerfexCRMCustomer::class))->execute($this->updatePerfexCRMInvoiceObject->getEmail());
|
|
||||||
$transaction = $this->updatePerfexCRMInvoiceObject->getTransaction();
|
|
||||||
|
|
||||||
//get the invoice id
|
|
||||||
$invoiceId = 0;
|
|
||||||
$invoiceStatus = 0;
|
|
||||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
|
||||||
LogHelper::channel('perfex_crm')->info('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
|
||||||
|
|
||||||
if(is_null($invoice)){
|
|
||||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
|
||||||
if ($result) {
|
|
||||||
$invoiceId = $result->payload['id'];
|
|
||||||
} else {
|
|
||||||
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
|
||||||
LogHelper::channel('perfex_crm')->info('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$invoiceId = $invoice->id;
|
|
||||||
$invoiceStatus = $invoice->status;
|
|
||||||
|
|
||||||
//This only run when invoice already exist and the invoice does not have a PAID status
|
|
||||||
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
|
||||||
//update invoice
|
|
||||||
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//create invoice payment
|
|
||||||
if($invoiceId != 0 && $invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
|
||||||
|
|
||||||
$date = Carbon::parse($transaction->created_at)->format('Y-m-d');
|
|
||||||
|
|
||||||
$invoicePaymentPerfexCRMObject = new InvoicePaymentPerfexCRMObject(
|
|
||||||
$invoiceId,
|
|
||||||
"$transaction->amount",
|
|
||||||
$date,
|
|
||||||
1,
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
);
|
|
||||||
(App()->make(CreatesPerfexCRMInvoicePayment::class))->execute($invoicePaymentPerfexCRMObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delay($delay)
|
|
||||||
{
|
|
||||||
// Add delay in seconds to the job
|
|
||||||
$this->delay = $delay;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
|
|
||||||
class UpdatePerfexCRMPrelude implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var */
|
|
||||||
private $packingList;
|
|
||||||
|
|
||||||
/** @var */
|
|
||||||
private $transaction;
|
|
||||||
|
|
||||||
/** @var UpdatePerfexCRMObject */
|
|
||||||
private $updatePerfexCRMObject;
|
|
||||||
|
|
||||||
/** @var bool|null */
|
|
||||||
private $shouldCreateInvoice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdatePerfexCRMPrelude constructor.
|
|
||||||
* @param PackingList $packingList
|
|
||||||
* @param Transaction $transaction
|
|
||||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
|
||||||
* @param bool|null $shouldCreateInvoice
|
|
||||||
*/
|
|
||||||
public function __construct(?PackingList $packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
|
|
||||||
{
|
|
||||||
$this->packingList = $packingList;
|
|
||||||
$this->transaction = $transaction;
|
|
||||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
|
||||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info('UpdatePerfexCRMPrelude packingList: ' . json_encode($this->packingList));
|
|
||||||
|
|
||||||
if(env('APP_ENV') !== 'production'){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(is_null($this->packingList)){
|
|
||||||
$this->packingList = $this->transaction->owner->owner;
|
|
||||||
}
|
|
||||||
$amount = 0.00;
|
|
||||||
if(!is_null($this->transaction)){
|
|
||||||
$amount = $this->transaction->amount;
|
|
||||||
}
|
|
||||||
$data = [
|
|
||||||
'amount' => number_format($amount, 2, '.', ''),
|
|
||||||
'link_order' => config('app.url').'/order/show/'.$this->packingList->owner->reference,
|
|
||||||
'link_autocount_or' => 'https://docs.google.com/spreadsheets/d/1Q3rJBGQ9Bo04HZp5WR9zbLp7pIW2kfDYsabxG7JON-4/edit#gid=2013983170',
|
|
||||||
'link_perfex' => 'https://perfex.cief-malaysia.com/admin/projects/view/89',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
|
||||||
$this->updatePerfexCRMObject->setTasks($result);
|
|
||||||
UpdatePerfexCRM::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->shouldCreateInvoice);
|
|
||||||
}
|
|
||||||
|
|
||||||
function replacePlaceholders($template, $data, $prefix = '')
|
|
||||||
{
|
|
||||||
foreach ($template as $key => $value) {
|
|
||||||
foreach ($data as $dataKey => $dataValue) {
|
|
||||||
if (is_array($dataValue)) {
|
|
||||||
$template[$key] = $this->replacePlaceholders($template[$key], $dataValue, $dataKey);
|
|
||||||
} else {
|
|
||||||
if ($prefix != '') {
|
|
||||||
$template[$key] = str_replace('{' .$prefix. "." .$dataKey . '}', $dataValue, $template[$key]);
|
|
||||||
} else {
|
|
||||||
$template[$key] = str_replace('{' . $dataKey . '}', $dataValue, $template[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\ResourceConflictException;
|
|
||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
|
||||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Http\Resources\UserResource;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Database\QueryException;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class AdminAddNewMemberLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
public function notification(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'title' => 'Admin Updated Email',
|
|
||||||
'message' => 'Successfully updated email'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var AssignEmployeeProcessor
|
|
||||||
*/
|
|
||||||
private $assignEmployeeProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var GenerateEmailVerificationAttemptProcessor
|
|
||||||
*/
|
|
||||||
private $generateEmailVerificationAttemptProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AddNewMemberLogic constructor.
|
|
||||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
|
||||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
|
||||||
*/
|
|
||||||
public function __construct(AssignEmployeeProcessor $assignEmployeeProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor)
|
|
||||||
{
|
|
||||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
|
||||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
* @throws ResourceConflictException
|
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
||||||
*/
|
|
||||||
public function logic(Request $request): JsonResponse
|
|
||||||
{
|
|
||||||
Log::info($request->input('employeeId'));
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (!$authUser = User::find($request->input('employeeId'))) {
|
|
||||||
throw new ResourceNotFoundException('User not found.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = $authUser->replicate();
|
|
||||||
$user->email = $request->input('email');
|
|
||||||
$user->status = ApprovalStatus::PENDING_VERIFICATION;
|
|
||||||
$user->save();
|
|
||||||
|
|
||||||
} catch (QueryException $e) {
|
|
||||||
throw new ResourceConflictException('Email already exists.');
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info($request->input('email'));
|
|
||||||
|
|
||||||
if ($company = $authUser->companyModule()->first()) {
|
|
||||||
$this->assignEmployeeProcessor->execute(new EmploymentObject($company, $user));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->generateEmailVerificationAttemptProcessor->execute($user);
|
|
||||||
|
|
||||||
return $this->resourceResponse(new UserResource($user));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,27 +8,23 @@ use App\Classes\General\Services\GeneratesInitials;
|
|||||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
||||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||||
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
||||||
|
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
||||||
|
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
|
||||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
|
|
||||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
|
||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||||
|
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||||
|
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
|
|
||||||
use App\Classes\Jobs\CreatePerfexCRMCustomer;
|
|
||||||
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\CompanyModule;
|
use App\Models\CompanyModule;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@@ -36,8 +32,6 @@ use App\Models\User;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CreateCustomerLogic extends AbstractControllerLogic
|
class CreateCustomerLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -86,9 +80,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
/** @var FetchesCompanyModule */
|
/** @var FetchesCompanyModule */
|
||||||
private $fetchesCompanyModule;
|
private $fetchesCompanyModule;
|
||||||
|
|
||||||
/** @var CreatePerfexCRMLeadProcessor */
|
|
||||||
private $createPerfexCRMLeadProcessor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateCustomerLogic constructor.
|
* CreateCustomerLogic constructor.
|
||||||
* @param CreateUserProcessor $createUserProcessor
|
* @param CreateUserProcessor $createUserProcessor
|
||||||
@@ -102,9 +93,8 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
* @param AuthenticationProcessor $authenticationProcessor
|
* @param AuthenticationProcessor $authenticationProcessor
|
||||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||||
* @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor
|
|
||||||
*/
|
*/
|
||||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor)
|
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule)
|
||||||
{
|
{
|
||||||
$this->createUserProcessor = $createUserProcessor;
|
$this->createUserProcessor = $createUserProcessor;
|
||||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||||
@@ -117,7 +107,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
$this->authenticationProcessor = $authenticationProcessor;
|
$this->authenticationProcessor = $authenticationProcessor;
|
||||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||||
$this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,31 +146,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||||
|
|
||||||
if(config('perfexcrm.is_enabled') == 'true'){
|
|
||||||
// $this->createPerfexCRMLeadProcessor->execute($request);
|
|
||||||
$createLeadPerfexCRMObject = new CreateLeadPerfexCRMObject(
|
|
||||||
$request->input('name'),
|
|
||||||
$request->input('email'),
|
|
||||||
$request->input('phone'),
|
|
||||||
$request->input('type') === CompanyType::COMPANY_BUSINESS ? $request->input('company_name') : $request->input('name'),
|
|
||||||
$connection->invitee_reference
|
|
||||||
);
|
|
||||||
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(app()->environment(['production'])){
|
|
||||||
// call wac webhook
|
|
||||||
$url = config('wagWebhookUrl.account_registration_url');
|
|
||||||
$payload = [
|
|
||||||
'name' => $request->input('name'),
|
|
||||||
'email' => $request->input('email'),
|
|
||||||
'phone' => $request->input('phone'),
|
|
||||||
'portal' => 'izyim'
|
|
||||||
];
|
|
||||||
$response = Http::post($url, $payload);
|
|
||||||
Log::channel('wac_webhook')->info('Register Account: ' . json_encode($response));
|
|
||||||
}
|
|
||||||
|
|
||||||
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||||
|
|
||||||
return $this->response($this->authenticationProcessor->execute($request));
|
return $this->response($this->authenticationProcessor->execute($request));
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user