v.2.24
1. POSTBonus in/out 2. POSTPresale in/out 3. Переработана форма гостя
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class ClientGroup extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getclientgroup';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
if (ClientsGroup::where('code', '0')->count() == 0) {
|
||||
$group = new ClientsGroup;
|
||||
$group->code = '0';
|
||||
$group->name = 'Без группы';
|
||||
$group->save();
|
||||
}
|
||||
$client_groups = ClientsGroup::orderBy('code')->get();
|
||||
foreach ($client_groups as $client_group) {
|
||||
$out[] = array('id' => $client_group['id'], 'name' => $client_group['name']);
|
||||
}
|
||||
$terminal = Terminal::where('soft', '=', 1)->where('is_active', '=', 1)->where('work_code', '=', 1)->first();
|
||||
$dir = __DIR__ . "/../../../Exchange/" . $terminal['key'] . "/";
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0755, 'w+');
|
||||
}
|
||||
|
||||
$files = glob($dir . "*.*");
|
||||
if (count($files) > 0) {
|
||||
usort($files, function ($a, $b) {
|
||||
return filemtime($a) < filemtime($b);
|
||||
});
|
||||
|
||||
foreach ($files as $plk2) {
|
||||
$file_array[] = str_replace($dir, '', $plk2);
|
||||
}
|
||||
$filename = $file_array['0'];
|
||||
$file = date("d.m.Y H:i:s", filemtime(__DIR__ . "/../../../Exchange/" . $terminal['key'] . "/" . $file_array['0']));
|
||||
} else {
|
||||
$file_array = '';
|
||||
$filename = '';
|
||||
$file = '';
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'groups' => $out,
|
||||
'terminalKey' => $terminal['key'],
|
||||
'files' => $files,
|
||||
'filename' => $filename,
|
||||
'filedate' => $file,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Component\Models\ClientsPhone;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Clients extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getclients';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
if (ClientsGroup::where('code', '0')->count() == 0) {
|
||||
$group = new ClientsGroup([
|
||||
'code' => '0',
|
||||
'name' => 'Без группы',
|
||||
]);
|
||||
$group->save();
|
||||
}
|
||||
$countPerPage = 25;
|
||||
$offset = ($input['page'] - 1) * $countPerPage;
|
||||
if ($input['group_id'] == 0) {
|
||||
$group = ClientsGroup::where('code', '=', $input['group_id'])->first();
|
||||
} else {
|
||||
$group = ClientsGroup::where('id', '=', $input['group_id'])->first();
|
||||
}
|
||||
$clients = Client::where('group_id', '=', $group['code'])->skip($offset)->take($countPerPage)->get();
|
||||
$total = Client::where('group_id', '=', $group['code'])->count();
|
||||
if ($total == NULL) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'clients' => array(),
|
||||
'total' => 0,
|
||||
'size' => $countPerPage,
|
||||
'pages' => 1,
|
||||
'currentGroup' => $group['id'],
|
||||
];
|
||||
} else {
|
||||
|
||||
foreach ($clients as $client) {
|
||||
$phone = ClientsPhone::where('client_guid', '=', $client['user_code'])->first();
|
||||
$out[] = array('id' => $client['id'], 'name' => $client['name'], 'phone' => $phone['phone']);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'clients' => $out,
|
||||
'total' => $total,
|
||||
'size' => $countPerPage,
|
||||
'pages' => ceil($total / $countPerPage),
|
||||
'currentGroup' => $group['id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ use App\Component\Models\Tasks;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Bot extends HRCCommand implements HRCCommandInterface
|
||||
class GETBot extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'getbot';
|
||||
|
||||
@@ -7,7 +7,7 @@ use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class ClientFile extends HRCCommand implements HRCCommandInterface {
|
||||
class GETClientFile extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getclientfile';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
58
commands/GETClientInfo.php
Normal file
58
commands/GETClientInfo.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsBonus;
|
||||
use App\Component\Models\ClientsPresale;
|
||||
use App\Component\Models\ExchangeOrders;
|
||||
use App\Component\Models\ShiftOnlineOrders;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class GETClientInfo extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'getclientinfo';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
if (isset($input['id'])) {
|
||||
$client = Client::where('id', $input['id'])->first();
|
||||
$client_guid = $client['user_code'];
|
||||
$phone = Client::getPhone($client_guid);
|
||||
$address = Client::getAddress($client_guid);
|
||||
$email = Client::getEmail($client_guid);
|
||||
$presale = ClientsPresale::getPresale($client_guid);
|
||||
$bonus = ClientsBonus::getBonus($client_guid);
|
||||
$orders_count_exchange = ExchangeOrders::where('client_code', $client_guid)->where('is_returned', 0)->where('is_deleted', 0)->count();
|
||||
$orders_count_current = ShiftOnlineOrders::where('client_code', $client_guid)->where('is_returned', 0)->where('is_deleted', 0)->count();
|
||||
$orders_sum_exchange = ExchangeOrders::where('client_code', $client_guid)->where('is_returned', 0)->where('is_deleted', 0)->sum('full_sum');
|
||||
$orders_sum_current = ShiftOnlineOrders::where('client_code', $client_guid)->where('is_returned', 0)->where('is_deleted', 0)->sum('full_sum');
|
||||
$orders_count = $orders_count_exchange + $orders_count_current;
|
||||
$orders_sum = $orders_sum_exchange + $orders_sum_current;
|
||||
$result = array(
|
||||
'id' => $client['id'],
|
||||
'name' => $client['name'],
|
||||
'info' => array(
|
||||
'phone' => $phone,
|
||||
'email' => $email,
|
||||
'address' => $address,
|
||||
'order_count' => $orders_count,
|
||||
'order_sum' => $orders_sum,
|
||||
'presale' => $presale,
|
||||
'bonus' => intval($bonus),
|
||||
)
|
||||
);
|
||||
return [
|
||||
'status' => 'success',
|
||||
'client' => $result,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'error',
|
||||
'more' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
51
commands/GETClientLog.php
Normal file
51
commands/GETClientLog.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsActions;
|
||||
use App\Component\Models\ClientsPresale;
|
||||
use App\Component\Models\ExchangeOrders;
|
||||
use App\Component\Models\ShiftOnlineOrders;
|
||||
use App\Component\Models\Staff;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class GETClientLog extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'getclientlog';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
if (isset($input['id'])) {
|
||||
$client = Client::where('id', $input['id'])->first();
|
||||
$client_guid = $client['user_code'];
|
||||
$logs = ClientsActions::where('user_id', $client_guid)->orderByDesc('created')->get();
|
||||
$info = [];
|
||||
foreach ($logs as $log) {
|
||||
$info[] = array(
|
||||
'action' => $log['action'],
|
||||
'value' => round($log['action_value'], 2),
|
||||
'who' => Staff::getName($log['who']),
|
||||
'time' => $log['created'],
|
||||
'type' => $log['action_type']
|
||||
);
|
||||
}
|
||||
$result = array(
|
||||
'id' => $client['id'],
|
||||
'name' => $client['name'],
|
||||
'info' => $info
|
||||
);
|
||||
return [
|
||||
'status' => 'success',
|
||||
'client' => $result,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'error',
|
||||
'more' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
34
commands/GETClientOrderInfo.php
Normal file
34
commands/GETClientOrderInfo.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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 GETClientOrderInfo extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'getclientorderinfo';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
$order_id = $input['order_id'];
|
||||
$opened = urldecode($input['opened']);
|
||||
$closed = urldecode($input['closed']);
|
||||
$shift = ShiftOnlineOrders::orderBy('opened', 'asc')->first();
|
||||
if ($shift['opened'] > $opened) {
|
||||
$order = ExchangeOrders::where('opened', $opened)->where('closed', $closed)->where('code', $order_id)->first();
|
||||
$shift_id = $order['shift_id'];
|
||||
$info = ExchangeOrders::getInfo($order_id, $shift_id);
|
||||
} else {
|
||||
$info = ShiftOnlineOrders::getInfo($order_id);
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'info' => $info[0],
|
||||
];
|
||||
}
|
||||
}
|
||||
54
commands/GETClientOrders.php
Normal file
54
commands/GETClientOrders.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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::where('client_code', $client_guid)->where('is_returned', 0)->where('is_deleted', 0)->orderByDesc('closed')->get();
|
||||
$online_orders = ShiftOnlineOrders::where('client_code', $client_guid)->where('is_returned', 0)->where('is_deleted', 0)->orderByDesc('closed')->get();
|
||||
$orders = [];
|
||||
foreach ($online_orders as $online_order) {
|
||||
$orders[] = array(
|
||||
'id' => $online_order['code'],
|
||||
'opened' => $online_order['opened'],
|
||||
'closed' => $online_order['closed'],
|
||||
'sum' => $online_order['order_sum'],
|
||||
'discount' => $online_order['sale_sum'],
|
||||
'shift_id' => 0
|
||||
);
|
||||
}
|
||||
foreach ($exchange_orders as $exchange_order) {
|
||||
$orders[] = array(
|
||||
'id' => $exchange_order['code'],
|
||||
'opened' => $exchange_order['opened'],
|
||||
'closed' => $exchange_order['closed'],
|
||||
'sum' => $exchange_order['order_sum'],
|
||||
'discount' => $exchange_order['sale_sum'],
|
||||
'shift_id' => $exchange_order['shift_id']
|
||||
);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'orders' => $orders,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'error',
|
||||
'more' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
166
commands/GETClients.php
Normal file
166
commands/GETClients.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsAddress;
|
||||
use App\Component\Models\ClientsBarcode;
|
||||
use App\Component\Models\ClientsBonus;
|
||||
use App\Component\Models\ClientsEmail;
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Component\Models\ClientsPhone;
|
||||
use App\Component\Models\ClientsPresale;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class GETClients extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'getclients';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
if (isset($input['type']) && $input['type'] == 'loyalty') {
|
||||
$last_update = Carbon::createFromTimestampUTC($input['last_update'])->timezone('Europe/Minsk');
|
||||
$phones = ClientsPhone::where('updated_at', '>=', $last_update)->get();
|
||||
$addresses = ClientsAddress::where('updated_at', '>=', $last_update)->get();
|
||||
$barcodes = ClientsBarcode::where('updated_at', '>=', $last_update)->get();
|
||||
$emails = ClientsEmail::where('updated_at', '>=', $last_update)->get();
|
||||
$presales = ClientsPresale::where('updated_at', '>=', $last_update)->get();
|
||||
$bonuses = ClientsBonus::where('updated_at', '>=', $last_update)->get();
|
||||
$clients = Client::where('updated_at', '>=', $last_update)->get();
|
||||
$info = [];
|
||||
foreach ($phones as $phone) {
|
||||
$info[] = $phone['client_guid'];
|
||||
}
|
||||
foreach ($addresses as $address) {
|
||||
$info[] = $address['client_guid'];
|
||||
}
|
||||
foreach ($barcodes as $barcode) {
|
||||
$info[] = $barcode['client_guid'];
|
||||
}
|
||||
foreach ($emails as $email) {
|
||||
$info[] = $email['client_guid'];
|
||||
}
|
||||
foreach ($presales as $presale) {
|
||||
$info[] = $presale['client_guid'];
|
||||
}
|
||||
foreach ($bonuses as $bonus) {
|
||||
$info[] = $bonus['client_guid'];
|
||||
}
|
||||
foreach ($clients as $client) {
|
||||
$info[] = $client['user_code'];
|
||||
}
|
||||
$guides = array_values(array_unique($info));
|
||||
$email = $phone = $client = [];
|
||||
foreach ($guides as $guid) {
|
||||
$email_address = Client::getEmail($guid);
|
||||
$phone_number = Client::getPhone($guid);
|
||||
$client_info = Client::where('user_code', $guid)->first();
|
||||
$email[] = array(
|
||||
'email' => $email_address
|
||||
);
|
||||
$phone[] = array(
|
||||
'phone' => $phone_number
|
||||
);
|
||||
$badge[] = array(
|
||||
'name' => 'Test',
|
||||
'code' => 1
|
||||
);
|
||||
$bonus_dishes[] = array(
|
||||
'code' => ''
|
||||
);
|
||||
if (ClientsBonus::getBonus($guid) > 0) {
|
||||
$bonus_info[] = array(
|
||||
'amount' => ClientsBonus::getBonus($guid),
|
||||
'dishes' => $bonus_dishes
|
||||
);
|
||||
} else {
|
||||
$bonus_info[] = array(
|
||||
'amount' => ClientsBonus::getBonus($guid)
|
||||
);
|
||||
}
|
||||
|
||||
$group_info = ClientsGroup::where('code', $client_info['group_id'])->first();
|
||||
$client[] = array(
|
||||
'id' => $client_info['id'],
|
||||
'name' => $client_info['name'],
|
||||
'guid' => $guid,
|
||||
'presale' => ClientsPresale::getPresale($guid),
|
||||
'bonuses' => $bonus_info,
|
||||
'barcode' => Client::getBarcode($guid),
|
||||
'group_id' => $client_info['group_id'],
|
||||
'emails' => $email,
|
||||
'phones' => $phone,
|
||||
'badges' => $badge
|
||||
);
|
||||
$groups[] = $group_info['code'];
|
||||
$email = $phone = $badge = $bonus_dishes = $bonus_info = [];
|
||||
}
|
||||
$groups_guides = array_values(array_unique($groups));
|
||||
foreach ($groups_guides as $group) {
|
||||
$group_info = ClientsGroup::where('code', $group)->first();
|
||||
$groups_info[] = array(
|
||||
'id' => $group_info['id'],
|
||||
'name' => $group_info['name'],
|
||||
'guid' => $group_info['code'],
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'clients' => $client,
|
||||
'groups' => $groups_info,
|
||||
];
|
||||
}
|
||||
if (ClientsGroup::where('code', '0')->count() == 0) {
|
||||
$group = new ClientsGroup([
|
||||
'code' => '0',
|
||||
'name' => 'Без группы',
|
||||
]);
|
||||
$group->save();
|
||||
}
|
||||
$countPerPage = 25;
|
||||
$offset = ($input['page'] - 1) * $countPerPage;
|
||||
if ($input['group_id'] == 0) {
|
||||
$group = ClientsGroup::where('code', '=', $input['group_id'])->first();
|
||||
} else {
|
||||
$group = ClientsGroup::where('id', '=', $input['group_id'])->first();
|
||||
}
|
||||
$clients = Client::where('group_id', '=', $group['code'])->skip($offset)->take($countPerPage)->get();
|
||||
$total = Client::where('group_id', '=', $group['code'])->count();
|
||||
if ($total == NULL) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'clients' => array(),
|
||||
'total' => 0,
|
||||
'size' => $countPerPage,
|
||||
'pages' => 1,
|
||||
'currentGroup' => $group['id'],
|
||||
];
|
||||
} else {
|
||||
|
||||
foreach ($clients as $client) {
|
||||
$phone = Client::getPhone($client['user_code']);
|
||||
$email = Client::getEmail($client['user_code']);
|
||||
$address = Client::getAddress($client['user_code']);
|
||||
$out[] = array(
|
||||
'id' => $client['id'],
|
||||
'name' => $client['name'],
|
||||
'phone' => $phone,
|
||||
'email' => $email,
|
||||
'address' => $address,
|
||||
);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'clients' => $out,
|
||||
'total' => $total,
|
||||
'size' => $countPerPage,
|
||||
'pages' => ceil($total / $countPerPage),
|
||||
'currentGroup' => $group['id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,8 @@ class GETDiscountItems extends HRCCommand implements HRCCommandInterface {
|
||||
} else {
|
||||
$discount = 0;
|
||||
}
|
||||
$dish = Dishes::where('code', $item['dish_code'])->where('is_history', 0)->first();
|
||||
if (!isset($dish)) {
|
||||
$dish = Dishes::where('legacy_code', $item['dish_code'])->where('is_history', 0)->first();
|
||||
}
|
||||
$items[] = array('name' => $dish['name'], 'discount' => round($discount, 0), 'count' => $item['count'], 'sale_price' => $salePrice, 'sum' => round($realPrice, 2));
|
||||
$dish = Dishes::getName($item['menu_code']);
|
||||
$items[] = array('name' => $dish, 'discount' => round($discount, 0), 'count' => $item['count'], 'sale_price' => $salePrice, 'sum' => round($realPrice, 2));
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Equipment extends HRCCommand implements HRCCommandInterface {
|
||||
class GETEquipment extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getequipment';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
@@ -6,7 +6,7 @@ use App\Component\Models\User;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class HelloWorld extends HRCCommand implements HRCCommandInterface {
|
||||
class GETHelloWorld extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'gethello';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
@@ -6,7 +6,7 @@ use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Import extends HRCCommand implements HRCCommandInterface {
|
||||
class GETImport extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getimport';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
@@ -9,93 +9,92 @@ use App\Component\Models\Staff;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class GETOnlineStaff extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getonlinestaff';
|
||||
class GETOnlineStaff extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'getonlinestaff';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
function staffName($data) {
|
||||
$staff_name = Staff::where('code', $data)->where('is_history', 0)->first();
|
||||
if ($staff_name) {
|
||||
$staff_name = $staff_name['name'];
|
||||
} else {
|
||||
$staff_name = Staff::where('code', $data)->where('is_history', 1)->first();
|
||||
if ($staff_name) {
|
||||
$staff_name = $staff_name['name'];
|
||||
} else {
|
||||
$staff_name = 'Связанный персонал не найден';
|
||||
}
|
||||
}
|
||||
return $staff_name;
|
||||
}
|
||||
if ($input['method'] == 'dashboard') {
|
||||
$staff_data = [];
|
||||
$staffs = ShiftOnlineOrders::select('who_open')
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('order_sum', '>', 0)
|
||||
->groupBy('who_open')
|
||||
->get();
|
||||
foreach ($staffs as $key => $staff) {
|
||||
$count = ShiftOnlineOrders::where('who_open', $staff['who_open'])
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('order_sum', '>', 0)
|
||||
->count();
|
||||
$name = staffName($staff['who_open']);
|
||||
$code = $staff['who_open'];
|
||||
$sum = ShiftOnlineOrders::where('who_open', $staff['who_open'])
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('order_sum', '>', 0)
|
||||
->sum('order_sum');
|
||||
$staff_data[] = array('name' => $name, 'code' => $code + 0, 'orders_count' => $count + 0, 'orders_sum' => $sum + 0);
|
||||
}
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
if ($input['method'] == 'dashboard') {
|
||||
$staff_data = [];
|
||||
$staffs = ShiftOnlineOrders::select('who_open')
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('order_sum', '>', 0)
|
||||
->groupBy('who_open')
|
||||
->get();
|
||||
foreach ($staffs as $staff) {
|
||||
$count = ShiftOnlineOrders::where('who_open', $staff['who_open'])
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('order_sum', '>', 0)
|
||||
->count();
|
||||
$name = Staff::getName($staff['who_open']);
|
||||
$code = $staff['who_open'];
|
||||
$sum = ShiftOnlineOrders::where('who_open', $staff['who_open'])
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('order_sum', '>', 0)
|
||||
->sum('order_sum');
|
||||
$staff_data[] = array(
|
||||
'name' => $name,
|
||||
'code' => $code + 0,
|
||||
'orders_count' => $count + 0,
|
||||
'orders_sum' => $sum + 0
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'staff' => $staff_data,
|
||||
];
|
||||
}
|
||||
if ($input['method'] == 'items') {
|
||||
if (isset($input['order'])) {
|
||||
$orderId = $input['order'] + 0;
|
||||
$items = [];
|
||||
$order = ShiftOnlineOrders::where('code', $orderId)->first();
|
||||
$who_open = staffName($order['who_open']);
|
||||
if ($order['who_close'] == 0) {
|
||||
$who_close = '-';
|
||||
} else {
|
||||
$who_close = staffName($order['who_close']);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'staff' => $staff_data,
|
||||
];
|
||||
}
|
||||
if ($input['method'] == 'items') {
|
||||
if (isset($input['order'])) {
|
||||
$orderId = $input['order'] + 0;
|
||||
$items = [];
|
||||
$order = ShiftOnlineOrders::where('code', $orderId)->first();
|
||||
$who_open = Staff::getName($order['who_open']);
|
||||
if ($order['who_close'] == 0) {
|
||||
$who_close = '-';
|
||||
} else {
|
||||
$who_close = Staff::getName($order['who_close']);
|
||||
}
|
||||
|
||||
$onlineItems = ShiftOnlineItems::where('order_code', $order['code'])->where('modificator_code', 0)->get();
|
||||
foreach ($onlineItems as $key => $item) {
|
||||
$realPrice = $item['real_price'] * $item['count'] * $item['cof'];
|
||||
$salePrice = $item['sale_price'] * $item['count'];
|
||||
if ($realPrice > 0) {
|
||||
$discount = $salePrice / $realPrice;
|
||||
$discount = (1 - $discount) * 100;
|
||||
} else {
|
||||
$discount = 0;
|
||||
}
|
||||
$dish = Dishes::where('code', $item['dish_code'])->where('is_history', 0)->first();
|
||||
$items[] = array('name' => $dish['name'], 'discount' => round($discount, 0), 'count' => $item['count'], 'sale_price' => $salePrice, 'sum' => round($realPrice, 2));
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'who_open' => $who_open,
|
||||
'who_close' => $who_close,
|
||||
'title' => 'Подробнее о заказе №' . $order['code'],
|
||||
'total' => $order['order_sum'],
|
||||
'items' => $items,
|
||||
];
|
||||
}
|
||||
$onlineItems = ShiftOnlineItems::where('order_code', $order['code'])->where('modificator_code', 0)->get();
|
||||
foreach ($onlineItems as $item) {
|
||||
$realPrice = $item['real_price'] * $item['count'] * $item['cof'];
|
||||
$salePrice = $item['sale_price'] * $item['count'];
|
||||
if ($realPrice > 0) {
|
||||
$discount = $salePrice / $realPrice;
|
||||
$discount = (1 - $discount) * 100;
|
||||
} else {
|
||||
$discount = 0;
|
||||
}
|
||||
$dish_name = Dishes::getName($item['menu_code']);
|
||||
$items[] = array(
|
||||
'name' => $dish_name,
|
||||
'discount' => round($discount, 0),
|
||||
'count' => $item['count'],
|
||||
'sale_price' => $salePrice,
|
||||
'sum' => round($realPrice, 2)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'who_open' => $who_open,
|
||||
'who_close' => $who_close,
|
||||
'title' => 'Подробнее о заказе №' . $order['code'],
|
||||
'total' => $order['order_sum'],
|
||||
'items' => $items,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsAddress;
|
||||
use App\Component\Models\ClientsPhone;
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\Modifier;
|
||||
use App\Component\Models\OrderItems;
|
||||
use App\Component\Models\Orders;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Component\Models\Report;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class OutOrders extends HRCCommand implements HRCCommandInterface {
|
||||
class GETOutOrders extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getoutorders';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
@@ -8,7 +8,7 @@ use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class TopDishes extends HRCCommand implements HRCCommandInterface {
|
||||
class GETTopDishes extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'gettopdishes';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
@@ -9,7 +9,7 @@ use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class TopDishesNewYear extends HRCCommand implements HRCCommandInterface {
|
||||
class GETTopDishesNewYear extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'gettopdishesnewyear';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
34
commands/POSTBonus.php
Normal file
34
commands/POSTBonus.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\ClientsBonus;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class POSTBonus extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'postbonus';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
$client_guid = $input['client_id'];
|
||||
$bonus_amount = $input['amount'];
|
||||
$staff_id = $input['who'];
|
||||
$bonus_time = $input['date_transaction'];
|
||||
ClientsBonus::bonusReg($client_guid, $bonus_amount);
|
||||
ClientsBonus::bonusLog($client_guid, $bonus_amount, $bonus_time, $staff_id);
|
||||
if ($bonus_amount > 0) {
|
||||
$message = 'Начислено ' . $bonus_amount . ' бонусов';
|
||||
} else {
|
||||
$message = 'Списано ' . abs($bonus_amount) . ' бонусов';
|
||||
}
|
||||
$bonus_result = ClientsBonus::getBonus($client_guid);
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => $message,
|
||||
'result' => $bonus_result
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ use App\Component\Models\ClientsGroup;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class CreateBarcode extends HRCCommand implements HRCCommandInterface {
|
||||
class POSTCreateBarcode extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postcreatebarcode';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
@@ -11,7 +11,7 @@ use App\Component\Models\ClientsPhone;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class CreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postcreateclient';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
@@ -6,7 +6,7 @@ use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Fiscals extends HRCCommand implements HRCCommandInterface {
|
||||
class POSTFiscals extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postfiscals';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
33
commands/POSTPresale.php
Normal file
33
commands/POSTPresale.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\ClientsPresale;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class POSTPresale extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'postpresale';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
$client_guid = $input['client_id'];
|
||||
$presale_amount = $input['amount'];
|
||||
$staff_id = $input['who'];
|
||||
$presale_time = $input['date_transaction'];
|
||||
ClientsPresale::presaleReg($client_guid, $presale_amount);
|
||||
ClientsPresale::presaleLog($client_guid, $presale_amount, $presale_time, $staff_id);
|
||||
if ($presale_amount > 0) {
|
||||
$message = 'Внесен аванс на сумму ' . $presale_amount . ' BYN';
|
||||
} else {
|
||||
$message = 'Зачтен аванс на сумму ' . abs($presale_amount) . ' BYN';
|
||||
}
|
||||
$presale_result = ClientsPresale::getPresale($client_guid);
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => $message,
|
||||
'result' => $presale_result
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class Printers extends HRCCommand implements HRCCommandInterface {
|
||||
class POSTPrinters extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postprinters';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
Reference in New Issue
Block a user