v.2.22
Редактор карты зала Электронные заказы Отчет по удалениям
This commit is contained in:
@@ -18,42 +18,43 @@ class GETOrder extends HRCCommand implements HRCCommandInterface {
|
||||
|
||||
if (isset($input['task'])) {
|
||||
if ($input['task'] == 'single' && isset($input['order_id'])) {
|
||||
$order = Orders::where('id', '=', $input['order_id'])->first();
|
||||
$order = Orders::where('id', intval($input['order_id']))->first();
|
||||
|
||||
if (isset($order->client_id) && $order->client_id !== null && $order->client_id !== '') {
|
||||
$client = Client::where('user_code', '=', $order->client_id)->first();
|
||||
$client = $client->name;
|
||||
$client_phone = ClientsPhone::where('client_guid', '=', $order->client_id)->first();
|
||||
$client_phone = $client_phone->phone;
|
||||
$client_address = ClientsAddress::where('client_guid', '=', $order->client_id)->first();
|
||||
$client_address = $client_address->address;
|
||||
if (isset($order['client_id']) && $order['client_id'] !== null && $order['client_id'] !== '') {
|
||||
$client = Client::where('user_code', $order['client_id'])->first();
|
||||
$client = $client['name'];
|
||||
$client_phone = ClientsPhone::where('client_guid', $order['client_id'])->first();
|
||||
$client_phone = $client_phone['phone'];
|
||||
$client_address = ClientsAddress::where('client_guid', $order['client_id'])->first();
|
||||
$client_address = $client_address['address'];
|
||||
} else {
|
||||
$client = '';
|
||||
$client_phone = '';
|
||||
$client_address = '';
|
||||
}
|
||||
|
||||
$orderItems = OrderItems::where('order_id', '=', $order->id)->whereNull('modifier_id')->get();
|
||||
$orderItems = OrderItems::where('order_id', $order['id'])->whereNull('modifier_id')->get();
|
||||
if (isset($orderItems)) {
|
||||
foreach ($orderItems as $key => $item) {
|
||||
$itemName = Dishes::where('code', '=', $item->item_id)->first();
|
||||
$itemName = $itemName->name;
|
||||
$itemModifiers = OrderItems::where('order_id', '=', $order->id)->where('parent_id', '=', $item->id)->whereNotNull('modifier_id')->get();
|
||||
$itemName = Dishes::getName($item['item_id']);
|
||||
$is_real = Dishes::isReal($item['item_id']);
|
||||
$itemModifiers = OrderItems::where('order_id', $order['id'])->where('parent_id', $item['id'])->whereNotNull('modifier_id')->get();
|
||||
if (isset($itemModifiers)) {
|
||||
foreach ($itemModifiers as $key => $itemModifier) {
|
||||
$modifier = Modifier::where('code', '=', $itemModifier->modifier_id)->first();
|
||||
if ($modifier->dish_code == 0 && $modifier->unit_id == 0) {
|
||||
$modOut[] = array('id' => $modifier->code, 'name' => $modifier->name, 'price' => '*');
|
||||
$modifier = Modifier::where('code', $itemModifier['modifier_id'])->first();
|
||||
if ($modifier['dish_code'] == 0 && $modifier['unit_id'] == 0) {
|
||||
$modOut[] = array('id' => $modifier['code'], 'name' => $modifier['name'], 'price' => '*');
|
||||
}
|
||||
}
|
||||
}
|
||||
$output[] = array('id' => $item->id,
|
||||
$output[] = array('id' => $item['id'],
|
||||
'num' => $key + 1,
|
||||
'order_id' => $item->order_id,
|
||||
'item_id' => $item->item_id,
|
||||
'order_id' => $item['order_id'],
|
||||
'item_id' => $item['item_id'],
|
||||
'item_name' => $itemName,
|
||||
'item_count' => $item->item_count,
|
||||
'item_price' => $item->item_price,
|
||||
'item_count' => round($item['item_count'], 3),
|
||||
'item_price' => round($item['item_price'], 2),
|
||||
'is_real' => $is_real,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -62,27 +63,41 @@ class GETOrder extends HRCCommand implements HRCCommandInterface {
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Заказ №' . $order->id,
|
||||
'message' => 'Заказ №' . $order['id'],
|
||||
'order' => $order,
|
||||
'orderItems' => $output,
|
||||
'client_name' => $client,
|
||||
'client_phone' => $client_phone,
|
||||
'client_address' => $client_address,
|
||||
'totalCount' => $order->total_count,
|
||||
'totalPrice' => $order->total_price,
|
||||
'totalCount' => $order['total_count'],
|
||||
'totalPrice' => round($order['total_price'], 2),
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'list') {
|
||||
$orders = Orders::all();
|
||||
foreach ($orders as $key => $order) {
|
||||
$client = Client::where('user_code', '=', $order->client_id)->first();
|
||||
$client_phone = ClientsPhone::where('client_guid', '=', $order->client_id)->first();
|
||||
$client_address = ClientsAddress::where('client_guid', '=', $order->client_id)->first();
|
||||
$client = Client::where('user_code', $order['client_id'])->first();
|
||||
$client_phone = ClientsPhone::where('client_guid', $order['client_id'])->first();
|
||||
$client_address = ClientsAddress::where('client_guid', $order['client_id'])->first();
|
||||
if (isset($client)) {
|
||||
$output[] = array('id' => $order->id, 'client_name' => $client->name, 'client_phone' => $client_phone->phone, 'client_address' => $client_address->address, 'total_count' => $order->total_count, 'total_price' => $order->total_price, 'is_send' => $order->is_send);
|
||||
$output[] = array('id' => $order['id'],
|
||||
'client_name' => $client['name'],
|
||||
'client_phone' => $client_phone['phone'],
|
||||
'client_address' => $client_address['address'],
|
||||
'total_count' => $order['total_count'],
|
||||
'total_price' => $order['total_price'],
|
||||
'is_send' => $order['is_send']
|
||||
);
|
||||
} else {
|
||||
$output[] = array('id' => $order->id, 'client_name' => '', 'client_phone' => '', 'client_address' => '', 'total_count' => $order->total_count, 'total_price' => $order->total_price, 'is_send' => $order->is_send);
|
||||
$output[] = array('id' => $order['id'],
|
||||
'client_name' => '',
|
||||
'client_phone' => '',
|
||||
'client_address' => '',
|
||||
'total_count' => $order['total_count'],
|
||||
'total_price' => $order['total_price'],
|
||||
'is_send' => $order['is_send']
|
||||
);
|
||||
}
|
||||
}
|
||||
return [
|
||||
@@ -98,12 +113,16 @@ class GETOrder extends HRCCommand implements HRCCommandInterface {
|
||||
$clients = ClientsPhone::where('phone', '=', $phone)->get();
|
||||
if (isset($clients)) {
|
||||
foreach ($clients as $key => $client) {
|
||||
$client_name = Client::where('user_code', '=', $client->client_guid)->first();
|
||||
$client_name = $client_name->name;
|
||||
$client_address = ClientsAddress::where('client_guid', '=', $client->client_guid)->first();
|
||||
$client_phone = $client->phone;
|
||||
$client_guid = $client->client_guid;
|
||||
$output[] = array('guid' => $client_guid, 'name' => $client_name, 'phone' => $client_phone, 'address' => $client_address->address);
|
||||
$client_name = Client::where('user_code', $client['client_guid'])->first();
|
||||
$client_name = $client_name['name'];
|
||||
$client_address = ClientsAddress::where('client_guid', $client['client_guid'])->first();
|
||||
$client_phone = $client['phone'];
|
||||
$client_guid = $client['client_guid'];
|
||||
$output[] = array('guid' => $client_guid,
|
||||
'name' => $client_name,
|
||||
'phone' => $client_phone,
|
||||
'address' => $client_address['address']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user