v.2.15
Order history
This commit is contained in:
54
commands/GETOrderHistory.php
Normal file
54
commands/GETOrderHistory.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\ActionTypes;
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\ShiftOnlineActions;
|
||||
use App\Component\Models\ShiftOnlineItems;
|
||||
use App\Component\Models\Staff;
|
||||
use App\Component\Models\Units;
|
||||
use App\Component\Models\UnitsList;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class GETOrderHistory extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getorderhistory';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
|
||||
if (isset($input['order_id'])) {
|
||||
$order = ShiftOnlineActions::where('order_code', $input['order_id'])->orderBy('time', 'asc')->get();
|
||||
foreach ($order as $key => $item) {
|
||||
$action_type = ActionTypes::where('type_id', $item['type_action'])->first();
|
||||
$action_name = $action_type['name'];
|
||||
$staff = Staff::where('code', $item['who'])->first();
|
||||
$staff_name = $staff['name'];
|
||||
if ($item['type_action'] == 45 || $item['type_action'] == 39) {
|
||||
$action_name = $item['value'];
|
||||
}
|
||||
if ($item['type_action'] == 46 || $item['type_action'] == 35) {
|
||||
$action_name = $action_name . ': ' . $item['value'];
|
||||
}
|
||||
if ($item['type_action'] == 2) {
|
||||
$shiftOnlineItem = ShiftOnlineItems::where('order_code', $item['order_code'])->where('dish_code', $item['more'])->first();
|
||||
$unitsList = UnitsList::where('id', $shiftOnlineItem['units_code'])->first();
|
||||
$units = Units::where('id', $unitsList['unit_id'])->first();
|
||||
$unit_name = $units['name'];
|
||||
$dish = Dishes::where('code', $item['more'])->first();
|
||||
$action_name = $action_name . ': ' . $dish['name'] . ' в количестве ' . $item['value'] . ' ' . $unit_name;
|
||||
}
|
||||
$order_info[] = array('id' => $key, 'action' => $action_name, 'who' => $staff_name, 'time' => $item['time'], 'workgroup' => $item['workgroup'], 'workcode' => $item['workcode']);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'actions' => $order_info,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user