From 612a64bf0331d86714272d2583927caf20f74cfd Mon Sep 17 00:00:00 2001 From: kaioken Date: Mon, 23 Dec 2024 14:58:00 -0400 Subject: [PATCH] feat: after order --- app/Console/Commands/KanvasVersionCommand.php | 50 +++++++++++++++++++ .../Orders/AppleInAppPurchaseMutation.php | 12 +++++ src/Domains/Workflow/Enums/WorkflowEnum.php | 1 + 3 files changed, 63 insertions(+) diff --git a/app/Console/Commands/KanvasVersionCommand.php b/app/Console/Commands/KanvasVersionCommand.php index b0cab0807..69799eee7 100644 --- a/app/Console/Commands/KanvasVersionCommand.php +++ b/app/Console/Commands/KanvasVersionCommand.php @@ -4,11 +4,22 @@ namespace App\Console\Commands; +use Baka\Traits\KanvasJobsTrait; use Illuminate\Console\Command; +use Kanvas\Apps\Models\Apps; +use Kanvas\Connectors\Credit700\DataTransferObject\CreditApplicant; +use Kanvas\Connectors\Credit700\Services\CreditScoreService; +use Kanvas\Connectors\Credit700\Support\Setup; use Kanvas\Enums\AppEnums; +use Kanvas\Guild\Leads\Models\Lead; +use Kanvas\Social\Channels\Models\Channel; +use Kanvas\Souk\Orders\Models\Order; +use Kanvas\SystemModules\Models\SystemModules; class KanvasVersionCommand extends Command { + use KanvasJobsTrait; + /** * The name and signature of the console command. * @@ -34,6 +45,45 @@ public function handle() $this->info('Kanvas Niche is running version : ' . AppEnums::VERSION->getValue()); $this->newLine(); + $app = Apps::getById(78); + $this->overwriteAppService($app); + + $order = Order::getById(768); + echo $order->get('message_id'); + + die(); + + $leadChannel = Channel::fromApp($app) + ->where('entity_id', 24076) + ->whereIn('entity_namespace', [Lead::class, SystemModules::getLegacyNamespace(Lead::class)]) + ->firstOrFail(); + + print_r($leadChannel); + die(); + + $setup700Credit = new Setup($app); + $setup700Credit->run(); + + $lead = Lead::getById(24076); + $people = $lead->people; + $address = $people->address()->first(); + + $creditApplication = new CreditApplicant( + 'Mcintyre S Benjamin', //$people->name, + '718 Jefferson ', //$address->address, + 'Fort Wayne', //$address->city, + 'AL', //$address->state, + '35080', //$address->zip, + '666271746', //fake()->ssn + ); + + $creditScoreAction = new CreditScoreService($app); + $creditScore = $creditScoreAction->getCreditScore($creditApplication, $lead->user); + + print_r($creditScore); + $lead->addFileFromUrl($creditScore['iframe_url_signed'], 'credit_score_report.pdf'); + die(); + return; } } diff --git a/app/GraphQL/Souk/Mutations/Orders/AppleInAppPurchaseMutation.php b/app/GraphQL/Souk/Mutations/Orders/AppleInAppPurchaseMutation.php index bc98200d2..db5becd28 100644 --- a/app/GraphQL/Souk/Mutations/Orders/AppleInAppPurchaseMutation.php +++ b/app/GraphQL/Souk/Mutations/Orders/AppleInAppPurchaseMutation.php @@ -12,6 +12,7 @@ use Kanvas\Exceptions\ModelNotFoundException; use Kanvas\Regions\Models\Regions; use Kanvas\Souk\Orders\Models\Order; +use Kanvas\Workflow\Enums\WorkflowEnum; class AppleInAppPurchaseMutation { @@ -48,6 +49,17 @@ public function create(mixed $root, array $request): Order $order->saveCustomFields(); } + /** + * @todo move this to the create order DTO + */ + $order->fireWorkflow( + WorkflowEnum::AFTER_CREATE_ORDER->value, + true, + [ + 'app' => $app, + ] + ); + return $order; } } diff --git a/src/Domains/Workflow/Enums/WorkflowEnum.php b/src/Domains/Workflow/Enums/WorkflowEnum.php index cf41a20bb..d8fcf5d8d 100644 --- a/src/Domains/Workflow/Enums/WorkflowEnum.php +++ b/src/Domains/Workflow/Enums/WorkflowEnum.php @@ -24,6 +24,7 @@ enum WorkflowEnum: string case SEARCH = 'search'; case AFTER_PRODUCT_IMPORT = 'after-product-import'; case SYNC_SHOPIFY = 'sync-shopify'; + case AFTER_CREATE_ORDER = 'after-create-order'; /** * Get the enum case by its value.