47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Commands;
|
|
|
|
use App\Component\Models\Client;
|
|
use App\Component\Models\ExchangeOrders;
|
|
use App\Component\Models\ShiftOnlineOrders;
|
|
use App\Console\Commands\HRCCommand;
|
|
use App\Console\Commands\HRCCommandInterface;
|
|
|
|
class GETClientOrders extends HRCCommand implements HRCCommandInterface
|
|
{
|
|
protected $signature = 'getclientorders';
|
|
|
|
public function command($input, $output = null)
|
|
{
|
|
if (isset($input['id'])) {
|
|
$client = Client::where('id', $input['id'])->first();
|
|
$client_guid = $client['user_code'];
|
|
$exchange_orders = ExchangeOrders::select('code', 'opened', 'closed', 'order_sum', 'sale_sum')
|
|
->where('client_code', $client_guid)
|
|
->where('is_returned', 0)
|
|
->where('is_deleted', 0)
|
|
->orderByDesc('closed')
|
|
->get()
|
|
->toArray();
|
|
$online_orders = ShiftOnlineOrders::select('code', 'opened', 'closed', 'order_sum', 'sale_sum')
|
|
->where('client_code', $client_guid)
|
|
->where('is_returned', 0)
|
|
->where('is_deleted', 0)
|
|
->orderByDesc('closed')
|
|
->get()
|
|
->toArray();
|
|
$orders = array_merge($online_orders, $exchange_orders);
|
|
return [
|
|
'status' => 'success',
|
|
'orders' => $orders,
|
|
'count' => count($orders)
|
|
];
|
|
} else {
|
|
return [
|
|
'status' => 'error',
|
|
'more' => 'Проверьте введенные данные',
|
|
];
|
|
}
|
|
}
|
|
} |