|
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Http; |
|
|
use Illuminate\Support\Facades\Log; |
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
|
|
|
|
use App\Models\Supplier; |
|
|
use App\Models\Supplier; |
|
|
|
|
|
use App\Models\Order; |
|
|
|
|
|
|
|
|
class Supply extends Controller |
|
|
class Supply extends Controller |
|
|
{ |
|
|
{ |
|
@@ -60,4 +61,67 @@ class Supply extends Controller |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function fulfill($order) { |
|
|
|
|
|
if (gettype($order) == 'integer') { |
|
|
|
|
|
$order = Order::find($order); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Supply::orderPrimary($order); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function fulfillAny($order) { |
|
|
|
|
|
if (gettype($order) == 'integer') { |
|
|
|
|
|
$order = Order::find($order); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (Supply::orderPrimary($order)) { |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function orderPrimary($order) { |
|
|
|
|
|
if (gettype($order) == 'integer') { |
|
|
|
|
|
$order = Order::find($order); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$primary = $order->service->primary; |
|
|
|
|
|
|
|
|
|
|
|
switch ($primary->supplier) { |
|
|
|
|
|
case 'smmkings': |
|
|
|
|
|
return Supply::orderSmmkings($order, $primary); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'smmworld': |
|
|
|
|
|
return Supply::orderSmmworld($order, $primary); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function orderSmmkings($order, $supplier) { |
|
|
|
|
|
if ($supplier->supplier != 'smmkings') { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$response = Http::post(config("services.smmkings.link"), ['key' => |
|
|
|
|
|
config("services.smmkings.key"), 'action' => 'add', |
|
|
|
|
|
'service' => $supplier->supplier_id, 'link' => |
|
|
|
|
|
$order->url, 'quantity' => $order->quantity])->json(); |
|
|
|
|
|
|
|
|
|
|
|
return $response; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function orderSmmworld($order, $supplier) { |
|
|
|
|
|
if ($supplier->supplier != 'smmworld') { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$response = Http::post(config("services.smmworld.link"), ['key' => |
|
|
|
|
|
config("services.smmworld.key"), 'action' => 'add', |
|
|
|
|
|
'service' => $supplier->supplier_id, 'link' => $order->url, 'quantity' => |
|
|
|
|
|
$order->quantity])->json(); |
|
|
|
|
|
|
|
|
|
|
|
return $response; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |