management integration start
This commit is contained in:
parent
f10bc1e2fe
commit
195ab2c022
|
|
@ -70,3 +70,5 @@ LINKEDIN_CALLBACK_URL=https://yourhost.com/customer/social-login/linkedin/callba
|
||||||
GITHUB_CLIENT_ID=
|
GITHUB_CLIENT_ID=
|
||||||
GITHUB_CLIENT_SECRET=
|
GITHUB_CLIENT_SECRET=
|
||||||
GITHUB_CALLBACK_URL=https://yourhost.com/customer/social-login/github/callback
|
GITHUB_CALLBACK_URL=https://yourhost.com/customer/social-login/github/callback
|
||||||
|
INTEGRATION_SECRET=
|
||||||
|
HTTP_MANAGER_ADDRESS=
|
||||||
|
|
@ -93,4 +93,8 @@ class IntegrationController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateOrderStatus(){
|
||||||
|
Log::info(request()->input());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -136,6 +136,7 @@ Route::group(['prefix' => 'api'], function () {
|
||||||
Route::put('upload',[IntegrationController::class,'bulk_upload']);
|
Route::put('upload',[IntegrationController::class,'bulk_upload']);
|
||||||
Route::put('create',[IntegrationController::class,'create']);
|
Route::put('create',[IntegrationController::class,'create']);
|
||||||
Route::put('update',[IntegrationController::class,'update']);
|
Route::put('update',[IntegrationController::class,'update']);
|
||||||
|
Route::post('order',[IntegrationController::class,'updateOrderStatus']);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Sarga\Admin\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class CustomerResource extends JsonResource
|
||||||
|
{
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'fullname' => $this->name,
|
||||||
|
'phone' => $this->phone,
|
||||||
|
'token' => env('INTEGRATION_SECRET')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Sarga\Admin\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class OrderItemResource extends JsonResource
|
||||||
|
{
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'app_order_id' => $this->order_id,
|
||||||
|
'ty_item_number',
|
||||||
|
'quantity' => $this->qty_order_id,
|
||||||
|
'price' => $this->total,
|
||||||
|
'order_date' => $this->created_at,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Sarga\Admin\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class OrderResource extends JsonResource
|
||||||
|
{
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'customer_phone' => $this->customer()->phone,
|
||||||
|
'items' => OrderItemResource::collection($this->items),
|
||||||
|
'token' => env('INTEGRATION_SECRET')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Sarga\Admin\Listeners;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Sarga\Admin\Http\Resources\CustomerResource;
|
||||||
|
use Webkul\Customer\Models\Customer as CustomerModel;
|
||||||
|
|
||||||
|
class Customer implements ShouldQueue
|
||||||
|
{
|
||||||
|
public $delay = 60;
|
||||||
|
public $queue = 'redis';
|
||||||
|
|
||||||
|
public function register(CustomerModel $customer){
|
||||||
|
|
||||||
|
try{
|
||||||
|
Http::post(env('HTTP_MANAGER_ADDRESS','https://panel.sargagroup.cf/api').'/customer',CustomerResource::make($customer));
|
||||||
|
|
||||||
|
}catch(\Exception $e){
|
||||||
|
Log::error($e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Sarga\Admin\src\Listeners;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Sarga\Admin\Http\Resources\OrderResource;
|
||||||
|
use Webkul\Sales\Models\Order as OrderModel;
|
||||||
|
|
||||||
|
class Order implements ShouldQueue
|
||||||
|
{
|
||||||
|
public $delay = 60;
|
||||||
|
public $queue = 'redis';
|
||||||
|
|
||||||
|
public function newOrder(OrderModel $order){
|
||||||
|
try {
|
||||||
|
Http::post(env('HTTP_MANAGER_ADDRESS','https://panel.sargagroup.cf/api').'/orders',
|
||||||
|
OrderResource::make($order));
|
||||||
|
}catch(Exception $ex){
|
||||||
|
Log::error($ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,6 +16,8 @@ class EventServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
public function boot(){
|
public function boot(){
|
||||||
|
Event::listen('customer.registration.after', [Sarga\Admin\Listeners\Customer::class,'register']);
|
||||||
|
Event::listen('checkout.order.save.after', 'Webkul\Marketplace\Listeners\Order@afterPlaceOrder');
|
||||||
// Event::listen('bagisto.admin.catalog.category.create_form_accordian.general.after', function($viewRenderEventManager) {
|
// Event::listen('bagisto.admin.catalog.category.create_form_accordian.general.after', function($viewRenderEventManager) {
|
||||||
// $viewRenderEventManager->addTemplate('sarga_admin::catalog.categories.scrap.create');
|
// $viewRenderEventManager->addTemplate('sarga_admin::catalog.categories.scrap.create');
|
||||||
// });
|
// });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue