36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
||
|
||
namespace App\Commands;
|
||
|
||
use App\Component\Models\ShiftOnlineOrders;
|
||
use App\Console\Commands\HRCCommand;
|
||
use App\Console\Commands\HRCCommandInterface;
|
||
|
||
class GETMoreDiscount extends HRCCommand implements HRCCommandInterface {
|
||
protected $signature = 'getmorediscount';
|
||
|
||
public function command($input, $output = null) {
|
||
$amountWithoutDiscount = 0;
|
||
$totalSum = 0;
|
||
$orderInfo = [];
|
||
$orders = ShiftOnlineOrders::where('is_deleted', 0)
|
||
->where('is_returned', 0)
|
||
->where('sale_sum', '>', 0)
|
||
->get();
|
||
if ($orders) {
|
||
foreach ($orders as $key => $order) {
|
||
$orderInfo[] = array('number' => $order['code'], 'full_sum' => $order['full_sum'], 'sale_sum' => $order['sale_sum'], 'order_sum' => $order['order_sum']);
|
||
$amountWithoutDiscount = $amountWithoutDiscount + $order['full_sum'];
|
||
$totalSum = $totalSum + $order['order_sum'];
|
||
}
|
||
}
|
||
|
||
return [
|
||
'status' => 'success',
|
||
'title' => 'Подробнее о заказах со скидками',
|
||
'amount' => $amountWithoutDiscount,
|
||
'total_sum' => $totalSum,
|
||
'orders' => $orderInfo,
|
||
];
|
||
}
|
||
} |