v.2.27
Fixed reports
This commit is contained in:
@@ -4,7 +4,7 @@ namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\Folders;
|
||||
use App\Component\Models\OrderBot;
|
||||
use App\Component\Models\OrderBotStorage;
|
||||
use App\Component\Models\Settings;
|
||||
use App\Component\Models\Tasks;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
@@ -25,11 +25,11 @@ class GETBot extends HRCCommand implements HRCCommandInterface
|
||||
Folders::where('is_bot_export', '=', 0)
|
||||
->update(['is_bot_export' => 1]);
|
||||
}
|
||||
$ordersinfo = Tasks::where('method', 'orderinfo')
|
||||
$orders_info = Tasks::where('method', 'orderinfo')
|
||||
->get();
|
||||
$delete_params = ['closed', 'deleted'];
|
||||
foreach ($ordersinfo as $more) {
|
||||
$order = OrderBot::where('id', intval($more['more']))
|
||||
foreach ($orders_info as $more) {
|
||||
$order = OrderBotStorage::where('id', intval($more['more']))
|
||||
->whereIn('status', $delete_params)
|
||||
->get();
|
||||
foreach ($order as $value) {
|
||||
|
||||
30
commands/GETClearCache.php
Normal file
30
commands/GETClearCache.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Filesystem;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class GETClearCache extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'getclearcache';
|
||||
const cacheFolder = CORE_PATH . '/../../Cache/';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
$code = Filesystem::GetCode($input['token']);
|
||||
if (isset($input['folder'])) {
|
||||
Filesystem::ClearFolder(self::cacheFolder . $code . '/' . $input['folder']);
|
||||
return [
|
||||
'status' => 'success',
|
||||
];
|
||||
}
|
||||
if (!isset($input['folder'])) {
|
||||
Filesystem::ClearFolder(self::cacheFolder . $code . '/');
|
||||
return [
|
||||
'status' => 'success',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,22 @@ class GETClientInfo extends HRCCommand implements HRCCommandInterface
|
||||
$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;
|
||||
$barcode = Client::getBarcode($client_guid);
|
||||
if ($client['is_special_price'] == 0) {
|
||||
$special_price = false;
|
||||
} else {
|
||||
$special_price = true;
|
||||
}
|
||||
if ($client['is_employee'] == 0) {
|
||||
$employee = false;
|
||||
} else {
|
||||
$employee = true;
|
||||
}
|
||||
if ($client['is_block'] == 0) {
|
||||
$is_block = false;
|
||||
} else {
|
||||
$is_block = true;
|
||||
}
|
||||
$result = array(
|
||||
'id' => $client['id'],
|
||||
'name' => $client['name'],
|
||||
@@ -41,6 +57,10 @@ class GETClientInfo extends HRCCommand implements HRCCommandInterface
|
||||
'order_sum' => round($orders_sum, 2),
|
||||
'presale' => $presale,
|
||||
'bonus' => intval($bonus),
|
||||
'barcode' => $barcode,
|
||||
'special_price' => $special_price,
|
||||
'employee' => $employee,
|
||||
'is_block' => $is_block,
|
||||
)
|
||||
);
|
||||
return [
|
||||
|
||||
@@ -35,6 +35,7 @@ class GETClientOrders extends HRCCommand implements HRCCommandInterface
|
||||
return [
|
||||
'status' => 'success',
|
||||
'orders' => $orders,
|
||||
'count' => count($orders)
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
|
||||
@@ -3,17 +3,9 @@
|
||||
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
|
||||
{
|
||||
@@ -21,99 +13,6 @@ class GETClients extends HRCCommand implements HRCCommandInterface
|
||||
|
||||
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',
|
||||
@@ -145,12 +44,33 @@ class GETClients extends HRCCommand implements HRCCommandInterface
|
||||
$phone = Client::getPhone($client['user_code']);
|
||||
$email = Client::getEmail($client['user_code']);
|
||||
$address = Client::getAddress($client['user_code']);
|
||||
$barcode = Client::getBarcode($client['user_code']);
|
||||
if ($client['is_special_price'] == 0) {
|
||||
$special_price = false;
|
||||
} else {
|
||||
$special_price = true;
|
||||
}
|
||||
if ($client['is_employee'] == 0) {
|
||||
$employee = false;
|
||||
} else {
|
||||
$employee = true;
|
||||
}
|
||||
if ($client['is_block'] == 0) {
|
||||
$is_block = false;
|
||||
} else {
|
||||
$is_block = true;
|
||||
}
|
||||
$out[] = array(
|
||||
'id' => $client['id'],
|
||||
'name' => $client['name'],
|
||||
'phone' => $phone,
|
||||
'email' => $email,
|
||||
'address' => $address,
|
||||
'barcode' => $barcode,
|
||||
'special_price' => $special_price,
|
||||
'employee' => $employee,
|
||||
'is_block' => $is_block,
|
||||
|
||||
);
|
||||
}
|
||||
return [
|
||||
|
||||
95
commands/GETCompanyClients.php
Normal file
95
commands/GETCompanyClients.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?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 GETCompanyClients extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'getcompanyclients';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
$dt = Carbon::createFromTimestamp($input['last_update'])->subHours(3);
|
||||
$last_update = $dt->format('Y-m-d H:i:s');
|
||||
$clients = Client::select('id', 'name', 'user_code', 'group_id', 'last_change', 'updated_at')
|
||||
->where('updated_at', '>', $last_update)
|
||||
->get();
|
||||
if (count($clients) < 1) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'clients' => [],
|
||||
'groups' => [],
|
||||
];
|
||||
}
|
||||
foreach ($clients as $client) {
|
||||
$email_address = Client::getEmail($client['user_code']);
|
||||
$phone_number = Client::getPhone($client['user_code']);
|
||||
$email[] = array(
|
||||
'email' => $email_address
|
||||
);
|
||||
$phone[] = array(
|
||||
'phone' => $phone_number
|
||||
);
|
||||
$badge[] = array(
|
||||
'name' => 'Test',
|
||||
'code' => 1
|
||||
);
|
||||
$bonus_dishes[] = array(
|
||||
'code' => ''
|
||||
);
|
||||
if (ClientsBonus::getBonus($client['user_code']) > 0) {
|
||||
$bonus_info[] = array(
|
||||
'amount' => ClientsBonus::getBonus($client['user_code']),
|
||||
'dishes' => $bonus_dishes
|
||||
);
|
||||
} else {
|
||||
$bonus_info = array(
|
||||
'amount' => ClientsBonus::getBonus($client['user_code']),
|
||||
'dishes' => []
|
||||
);
|
||||
}
|
||||
$group_info = ClientsGroup::where('code', $client['group_id'])->first();
|
||||
$clients_info[] = array(
|
||||
'id' => $client['id'],
|
||||
'name' => $client['name'],
|
||||
'guid' => $client['user_code'],
|
||||
'presale' => ClientsPresale::getPresale($client['user_code']),
|
||||
'bonuses' => $bonus_info,
|
||||
'barcode' => Client::getBarcode($client['user_code']),
|
||||
'group_id' => ClientsGroup::getID($client['group_id']),
|
||||
'emails' => $email,
|
||||
'phones' => $phone,
|
||||
'badges' => []
|
||||
);
|
||||
$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' => $clients_info,
|
||||
'groups' => $groups_info,
|
||||
];
|
||||
}
|
||||
}
|
||||
256
commands/GETDashboard.php
Normal file
256
commands/GETDashboard.php
Normal file
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\Reasons;
|
||||
use App\Component\Models\ShiftOnlineActions;
|
||||
use App\Component\Models\ShiftOnlineDeleted;
|
||||
use App\Component\Models\ShiftOnlineOrders;
|
||||
use App\Component\Models\Shifts;
|
||||
use App\Component\Models\Staff;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class GETDashboard extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'getdashboard';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
if (isset($input['method'])) {
|
||||
if (isset($input['more'])) {
|
||||
$more = $input['more'];
|
||||
} else {
|
||||
$more = false;
|
||||
}
|
||||
if (isset($input['items'])) {
|
||||
if (isset($input['order_id'])) {
|
||||
$order_id = $input['order_id'];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Проверьте введенные данные'
|
||||
];
|
||||
}
|
||||
$items = $input['items'];
|
||||
} else {
|
||||
$items = false;
|
||||
}
|
||||
if (isset($input['type'])) {
|
||||
$type = $input['type'];
|
||||
} else {
|
||||
$type = false;
|
||||
}
|
||||
$method = $input['method'];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Проверьте введенные данные'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
if ($method == "deleted") {
|
||||
$count = ShiftOnlineDeleted::count();
|
||||
if ($count < 1) {
|
||||
$count = 0;
|
||||
}
|
||||
$sum = ShiftOnlineDeleted::selectRaw('SUM(count * sale_price) as sum')->first();
|
||||
if (isset($sum) && !is_null($sum['sum'])) {
|
||||
$sum = $sum['sum'];
|
||||
} else {
|
||||
$sum = 0;
|
||||
}
|
||||
if ($more) {
|
||||
$deleted_items = ShiftOnlineDeleted::select('order_code')
|
||||
->selectRaw('SUM(count * sale_price) as sum')
|
||||
->groupBy('order_code')
|
||||
->get();
|
||||
if ($count > 0) {
|
||||
foreach ($deleted_items as $deleted_item) {
|
||||
$order = ShiftOnlineOrders::select('opened', 'closed')
|
||||
->where('code', $deleted_item['order_code'])
|
||||
->first();
|
||||
$closed = $order['closed'];
|
||||
if ($closed == '0000-00-00 00:00:00') {
|
||||
$closed = '30.12.1899';
|
||||
}
|
||||
$orders[] = array(
|
||||
'number' => $deleted_item['order_code'],
|
||||
'opened' => $order['opened'],
|
||||
'closed' => $closed,
|
||||
'deleted_sum' => round($deleted_item['sum'], 2)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$orders = [];
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'title' => 'Подробнее об удаленных',
|
||||
'total_sum' => round($sum, 2),
|
||||
'total_count' => $count,
|
||||
'deleted_orders' => $orders
|
||||
];
|
||||
}
|
||||
if ($items) {
|
||||
$all_sum = $all_count = 0;
|
||||
$deleted_items = ShiftOnlineDeleted::where('order_code', $order_id)
|
||||
->get();
|
||||
if ($count > 0) {
|
||||
foreach ($deleted_items as $deleted_item) {
|
||||
$order = ShiftOnlineActions::where('order_code', $deleted_item['order_code'])
|
||||
->where('type_action', 5)
|
||||
->first();
|
||||
$out_items[] = array(
|
||||
'dish' => Dishes::getName($deleted_item['menu_code']),
|
||||
'time' => $order['time'],
|
||||
'reason' => Reasons::getName($order['reason']),
|
||||
'count' => $deleted_item['count'],
|
||||
'sale_price' => $deleted_item['count'] * $deleted_item['sale_price'],
|
||||
'who_deleted' => Staff::getName($order['who'])
|
||||
);
|
||||
$all_sum += $deleted_item['count'] * $deleted_item['sale_price'];
|
||||
$all_count += $deleted_item['count'];
|
||||
}
|
||||
} else {
|
||||
$out_items = [];
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'code' => $order_id,
|
||||
'all_sum' => round($all_sum, 2),
|
||||
'all_count' => round($all_count, 3),
|
||||
'items' => $out_items
|
||||
];
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'sum' => round($sum, 2),
|
||||
'count' => $count
|
||||
];
|
||||
}
|
||||
|
||||
if ($method == 'guests') {
|
||||
if ($type == 'median') {
|
||||
$data = [];
|
||||
$orders = ShiftOnlineOrders::where('is_waited', 1)
|
||||
->where('is_deleted', 0)
|
||||
->get();
|
||||
if (isset($orders)) {
|
||||
foreach ($orders as $order) {
|
||||
$originalTime = $order['opened'];
|
||||
$newTime = Carbon::createFromFormat('Y-m-d H:i:s', $originalTime)->format('d.m.Y H:i:s');
|
||||
$data[] = array(
|
||||
'time' => $newTime,
|
||||
'count' => $order['client_count']
|
||||
);
|
||||
}
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'data' => $data
|
||||
];
|
||||
}
|
||||
if ($type == 'more') {
|
||||
$clientsIDS = ShiftOnlineOrders::select('client_code')
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('who_open', '<>', 0)
|
||||
->where('client_code', '<>', '')
|
||||
->groupBy('client_code')
|
||||
->get();
|
||||
$clientsOrdersCount = ShiftOnlineOrders::select('client_code')
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('who_open', '<>', 0)
|
||||
->where('client_code', '<>', '')
|
||||
->groupBy('client_code')
|
||||
->count();
|
||||
if ($clientsOrdersCount > 0) {
|
||||
foreach ($clientsIDS as $clientsID) {
|
||||
$orders_info = ShiftOnlineOrders::where('client_code', $clientsID['client_code'])
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('who_open', '<>', 0)
|
||||
->get();
|
||||
|
||||
$clientName = Client::getName($clientsID['client_code']);
|
||||
$clientOrder[$clientName] = [];
|
||||
foreach ($orders_info as $order_info) {
|
||||
if ($order_info['closed'] == '0000-00-00 00:00:00') {
|
||||
$closed = false;
|
||||
} else {
|
||||
$closed = $order_info['closed'];
|
||||
}
|
||||
$order = array(
|
||||
'number' => $order_info['code'],
|
||||
'opened' => $order_info['opened'],
|
||||
'closed' => $closed,
|
||||
'sum' => $order_info['order_sum']
|
||||
);
|
||||
array_push($clientOrder[$clientName], $order);
|
||||
}
|
||||
}
|
||||
foreach ($clientOrder as $key => $oInfo) {
|
||||
$out[] = array(
|
||||
'name' => $key,
|
||||
'orders' => $oInfo
|
||||
);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'title' => 'Подробнее о заказах гостей',
|
||||
'clients' => $out
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'title' => 'Подробнее о заказах гостей',
|
||||
'clients' => []
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
$guests = $namedGuests = $totalSum = 0;
|
||||
$orders = ShiftOnlineOrders::where('is_waited', 1)
|
||||
->where('is_deleted', 0)
|
||||
->get();
|
||||
if (isset($orders)) {
|
||||
foreach ($orders as $order) {
|
||||
$guests += $order['client_count'];
|
||||
$totalSum += $order['order_sum'];
|
||||
if ($order['client_code'] != '') {
|
||||
$namedGuests += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'namedGuests' => $namedGuests,
|
||||
'guestsCount' => $guests,
|
||||
'totalSum' => round($totalSum, 2)
|
||||
];
|
||||
}
|
||||
|
||||
if ($method == 'info') {
|
||||
$response['status'] = 'success';
|
||||
$response['exists'] = 'false';
|
||||
$shifts = Shifts::first();
|
||||
if (isset($shifts)) {
|
||||
$response['exists'] = true;
|
||||
$response['opened'] = $shifts['opened'];
|
||||
$response['open'] = Staff::getName($shifts['who_open']);
|
||||
$response['z_number'] = $shifts['z_number'];
|
||||
if ($shifts['who_close'] > 0) {
|
||||
$response['closed'] = $shifts['closed'];
|
||||
$response['close'] = Staff::getName($shifts['who_close']);
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\User;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
class GETHelloWorld extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'gethello';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$users = User::all();
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'users' => $users,
|
||||
];
|
||||
}
|
||||
}
|
||||
39
commands/GETKeyInfo.php
Normal file
39
commands/GETKeyInfo.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Cache;
|
||||
use App\Console\Commands\HRCEncryptor;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class GETKeyInfo extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'getkeyinfo';
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
$cache = Cache::get(245817422, 'v1', $input);
|
||||
if ($cache) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'info' => $cache,
|
||||
'input' => $input
|
||||
];
|
||||
}
|
||||
$info_file = __DIR__ . "\\..\\..\\..\\info.ini";
|
||||
$key_file = __DIR__ . "\\..\\..\\..\\Key.key";
|
||||
$unn = parse_ini_file($info_file);
|
||||
$unn = intval($unn['unn']);
|
||||
$info = json_decode(HRCEncryptor::decrypt(file_get_contents($key_file), $unn), true);
|
||||
if (!$cache) {
|
||||
$cache = Cache::store(245817422, 'v1', $input, $info);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'info' => $cache,
|
||||
'input' => $input
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\ExchangeShifts;
|
||||
use App\Component\Models\OrderBot;
|
||||
use App\Component\Models\OrderBotStorage;
|
||||
use App\Component\Models\Report;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
@@ -19,7 +19,7 @@ class GETOutOrders extends HRCCommand implements HRCCommandInterface {
|
||||
$out = array('id' => $shift['id'], 'opened' => $shift['opened'], 'closed' => $shift['closed']);
|
||||
}
|
||||
}
|
||||
$orders = OrderBot::select('id', 'order', 'created_at')->where('created_at', '>', $out['opened'])->where('created_at', '<=', $out['closed'])->get();
|
||||
$orders = OrderBotStorage::select('id', 'order', 'created_at')->where('created_at', '>', $out['opened'])->where('created_at', '<=', $out['closed'])->get();
|
||||
$count_items = 0;
|
||||
if (is_array($orders) || is_object($orders)) {
|
||||
foreach ($orders as $order) {
|
||||
@@ -73,7 +73,7 @@ class GETOutOrders extends HRCCommand implements HRCCommandInterface {
|
||||
$end_t = strtotime($input['end_date']) - 1;
|
||||
$start = date('Y-m-d H:i:s', $start_t);
|
||||
$end = date('Y-m-d H:i:s', $end_t);
|
||||
$orders = OrderBot::select('id', 'order', 'created_at')->where('created_at', '>', $start)->where('created_at', '<=', $end)->get();
|
||||
$orders = OrderBotStorage::select('id', 'order', 'created_at')->where('created_at', '>', $start)->where('created_at', '<=', $end)->get();
|
||||
$count_items = 0;
|
||||
if (is_array($orders) || is_object($orders)) {
|
||||
foreach ($orders as $order) {
|
||||
|
||||
@@ -10,7 +10,7 @@ class GETReports extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getreports';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
$reports = Report::all();
|
||||
$reports = Report::select('id', 'name', 'report_type', 'start_date', 'end_date')->orderBy('id', 'desc')->get();
|
||||
if ($reports) {
|
||||
foreach ($reports as $key => $report) {
|
||||
$data[] = array(
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Settings;
|
||||
use App\Component\Commands\Methods\Cache;
|
||||
use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
|
||||
@@ -12,6 +14,34 @@ class GETSettings extends HRCCommand implements HRCCommandInterface
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
|
||||
if (isset($input['method'])) {
|
||||
$method = $input['method'];
|
||||
if ($method == 'terminals') {
|
||||
$out = [];
|
||||
$terminals = Terminal::get();
|
||||
foreach ($terminals as $terminal) {
|
||||
if ($terminal['is_active'] === 1) {
|
||||
$is_active = true;
|
||||
} else {
|
||||
$is_active = false;
|
||||
}
|
||||
|
||||
$out[] = array(
|
||||
'work_code' => $terminal['work_code'],
|
||||
'work_group' => $terminal['work_group'],
|
||||
'soft' => $terminal['soft'],
|
||||
'is_active' => $is_active,
|
||||
'key' => $terminal['key'],
|
||||
'last_activity' => $terminal['last_activity'],
|
||||
);
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'terminals' => $out,
|
||||
];
|
||||
}
|
||||
}
|
||||
if (isset($input['code'])) {
|
||||
$setting = Settings::where('code', $input['code'])
|
||||
->first();
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\OnlineItems;
|
||||
use App\Component\Models\ShiftOnlineItems;
|
||||
use App\Component\Models\ShiftOnlineOrders;
|
||||
use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
@@ -18,8 +19,21 @@ class GETTopDishes extends HRCCommand implements HRCCommandInterface {
|
||||
} else {
|
||||
$terminalKey = 0;
|
||||
}
|
||||
$info = OnlineItems::where('menu_code', '>', 0)->get()->unique('menu_code');
|
||||
$count = OnlineItems::where('menu_code', '>', 0)->count();
|
||||
$allOrders = ShiftOnlineOrders::select('code')
|
||||
->where('is_closed', 1)
|
||||
->where('is_returned', 0)
|
||||
->where('is_deleted', 0)
|
||||
->get();
|
||||
foreach ($allOrders as $order) {
|
||||
$orders[] = array($order['code']);
|
||||
}
|
||||
$info = ShiftOnlineItems::where('menu_code', '>', 0)
|
||||
->whereIn('order_code', $orders)
|
||||
->get()
|
||||
->unique('menu_code');
|
||||
$count = ShiftOnlineItems::where('menu_code', '>', 0)
|
||||
->whereIn('order_code', $orders)
|
||||
->count();
|
||||
if ($count > 0) {
|
||||
foreach ($info as $key => $value) {
|
||||
$out[] = $value;
|
||||
@@ -29,18 +43,22 @@ class GETTopDishes extends HRCCommand implements HRCCommandInterface {
|
||||
->where('legacy_code', '=', $item['dish_code'])
|
||||
->where('is_history', '=', 0)
|
||||
->first();
|
||||
$onlineDishInfo = OnlineItems::where('menu_code', '=', $item['menu_code'])
|
||||
$onlineDishInfo = ShiftOnlineItems::where('menu_code', '=', $item['menu_code'])
|
||||
->where('dish_code', '=', $item['dish_code'])
|
||||
->whereIn('order_code', $orders)
|
||||
->first();
|
||||
if ($dishInfo['name'] == '') {
|
||||
$dishHistInfo = Dishes::where('code', '=', $item['menu_code'])
|
||||
->where('legacy_code', '=', $item['dish_code'])
|
||||
->whereIn('order_code', $orders)
|
||||
->first();
|
||||
$dishName = $dishHistInfo['name'];
|
||||
} else {
|
||||
$dishName = $dishInfo['name'];
|
||||
}
|
||||
$dishCount = OnlineItems::where('menu_code', '=', $item['menu_code'])->sum('count');
|
||||
$dishCount = ShiftOnlineItems::where('menu_code', '=', $item['menu_code'])
|
||||
->whereIn('order_code', $orders)
|
||||
->sum('count');
|
||||
$dishSum = $onlineDishInfo['real_price'] * $dishCount;
|
||||
if ($dishSum > 0) {
|
||||
$dishTotalCost = round(($onlineDishInfo['special_price'] * $dishCount), 2);
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsBonus;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class POSTBonus extends HRCCommand implements HRCCommandInterface
|
||||
@@ -13,13 +15,17 @@ class POSTBonus extends HRCCommand implements HRCCommandInterface
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
$client_guid = $input['client_id'];
|
||||
$client_guid = $input['client_guid'];
|
||||
$bonus_amount = abs($input['amount']);
|
||||
$staff_id = $input['who'];
|
||||
$staff_id = $input['who_id'];
|
||||
$bonus_time = $input['date_transaction'];
|
||||
$type = $input['type'];
|
||||
ClientsBonus::bonusReg($client_guid, $bonus_amount, $type);
|
||||
ClientsBonus::bonusLog($client_guid, $bonus_amount, $bonus_time, $staff_id);
|
||||
$client = Client::where('user_code', $client_guid)->first();
|
||||
$client = Client::find($client['id']);
|
||||
$client->updated_at = Carbon::createFromTimestampUTC($bonus_time)->timezone('Europe/Minsk');
|
||||
$client->save();
|
||||
if ($type == 'in') {
|
||||
$message = 'Начислено ' . $bonus_amount . ' бонусов';
|
||||
} elseif ($type == 'out') {
|
||||
|
||||
@@ -12,119 +12,295 @@ use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class POSTClient extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postclient';
|
||||
class POSTClient extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
protected $signature = 'postclient';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
|
||||
if (isset($input['task']) && isset($input['id'])) {
|
||||
if ($input['task'] == 'update') {
|
||||
$phone = urldecode($input['phone']);
|
||||
$client = Client::find($input['id']);
|
||||
$client->name = urldecode($input['name']);
|
||||
$client->unloaded = 0;
|
||||
$clientGroup = ClientsGroup::where('id', $input['group_id'])->first();
|
||||
$client->group_id = urldecode($clientGroup['code']);
|
||||
$clientPhone = ClientsPhone::where('client_guid', $client->user_code)->first();
|
||||
if ($clientPhone) {
|
||||
$clientPhone = ClientsPhone::find($clientPhone['id']);
|
||||
if ($phone !== '' && $phone !== '+375 ( ) - -') {
|
||||
if (substr($phone, 0, 1) == '+') {
|
||||
$phoneData = urldecode($input['phone']);
|
||||
} else {
|
||||
$phoneData = urldecode($input['phone']);
|
||||
$clientPhone->phone = '+375 (' . substr($phoneData, 0, 2) . ') ' . substr($phoneData, 2, 3) . '-' . substr($phoneData, 5, 2) . '-' . substr($phoneData, 7, 2);
|
||||
}
|
||||
} else {
|
||||
$clientPhone->phone = '+375 ( ) - -';
|
||||
}
|
||||
$clientPhone->save();
|
||||
}
|
||||
if (isset($input['task'])) {
|
||||
if ($input['task'] == 'update') {
|
||||
log::debug($input);
|
||||
if (isset($input['id'])) {
|
||||
$id = $input['id'];
|
||||
} else if (isset($input['client_guid'])) {
|
||||
$fClient = Client::where('user_code', $input['client_guid'])->first();
|
||||
if (!isset($fClient)) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Клиент не найден',
|
||||
];
|
||||
}
|
||||
$id = $fClient['id'];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
if (isset($input['group_id']) && !isset($input['group_guid'])) {
|
||||
$group_id = $input['group_id'];
|
||||
} else if (isset($input['group_guid']) && !isset($input['group_id'])) {
|
||||
$fGroup = ClientsGroup::where('code', $input['group_guid'])->first();
|
||||
if (!isset($fGroup)) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Группа не найдена',
|
||||
];
|
||||
}
|
||||
$group_id = $fGroup['id'];
|
||||
} else if (isset($input['group_id']) && isset($input['group_guid'])) {
|
||||
$fGroup = ClientsGroup::where('code', $input['group_guid'])->first();
|
||||
if (!isset($fGroup)) {
|
||||
$fGroup = ClientsGroup::where('id', isset($input['group_id']))->first();
|
||||
if (!isset($fGroup)) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Группа не найдена',
|
||||
];
|
||||
}
|
||||
}
|
||||
$group_id = $fGroup['id'];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
$client = Client::find($id);
|
||||
$client->name = urldecode($input['name']);
|
||||
$client->unloaded = 0;
|
||||
$clientGroup = ClientsGroup::where('id', $group_id)->first();
|
||||
$client->group_id = $clientGroup['code'];
|
||||
|
||||
$clientEmail = ClientsEmail::where('client_guid', $client->user_code)->first();
|
||||
if ($clientEmail) {
|
||||
$clientEmail = ClientsEmail::find($clientEmail['id']);
|
||||
if ($input['email'] !== '') {
|
||||
$clientEmail->email = urldecode($input['email']);
|
||||
} else {
|
||||
$clientEmail->email = '';
|
||||
}
|
||||
$clientEmail->save();
|
||||
}
|
||||
if (isset($input['phone'])) {
|
||||
$phone = $input['phone'];
|
||||
Log::debug($phone);
|
||||
$clientPhone = ClientsPhone::where('client_guid', $client->user_code)->first();
|
||||
Log::debug($clientPhone);
|
||||
if (isset($clientPhone)) {
|
||||
$clientPhone = ClientsPhone::find($clientPhone['id']);
|
||||
if ($phone !== '' && $phone !== '+375 ( ) - -') {
|
||||
if (substr($phone, 0, 1) == '+') {
|
||||
$clientPhone->phone = '+375 (' . substr($phone, 4, 2) . ') ' . substr($phone, 6, 3) . '-' . substr($phone, 9, 2) . '-' . substr($phone, 11, 2);
|
||||
log::debug('UPD Substr true: ' . $phone);
|
||||
} else {
|
||||
log::debug('UPD Substr false: ' . $phone);
|
||||
$clientPhone->phone = '+375 (' . substr($phone, 0, 2) . ') ' . substr($phone, 2, 3) . '-' . substr($phone, 5, 2) . '-' . substr($phone, 7, 2);
|
||||
}
|
||||
} else {
|
||||
$clientPhone->phone = '+375 ( ) - -';
|
||||
}
|
||||
} else {
|
||||
$clientPhone = new ClientsPhone;
|
||||
if ($phone !== '' && $phone !== '+375 ( ) - -') {
|
||||
if (substr($phone, 0, 1) == '+') {
|
||||
$clientPhone->phone = '+375 (' . substr($phone, 4, 2) . ') ' . substr($phone, 6, 3) . '-' . substr($phone, 9, 2) . '-' . substr($phone, 11, 2);
|
||||
log::debug('CR Substr true: ' . $phone);
|
||||
} else {
|
||||
log::debug('CR Substr false: ' . $phone);
|
||||
$clientPhone->phone = '+375 (' . substr($phone, 0, 2) . ') ' . substr($phone, 2, 3) . '-' . substr($phone, 5, 2) . '-' . substr($phone, 7, 2);
|
||||
}
|
||||
} else {
|
||||
$clientPhone->phone = '+375 ( ) - -';
|
||||
}
|
||||
}
|
||||
$clientPhone->client_guid = $client->user_code;
|
||||
$clientPhone->save();
|
||||
}
|
||||
|
||||
$clientAddress = ClientsAddress::where('client_guid', $client->user_code)->first();
|
||||
if ($clientAddress) {
|
||||
$clientAddress = ClientsAddress::find($clientAddress['id']);
|
||||
if ($input['address'] !== '') {
|
||||
$clientAddress->address = urldecode($input['address']);
|
||||
} else {
|
||||
$clientAddress->address = '';
|
||||
}
|
||||
$clientAddress->save();
|
||||
}
|
||||
if (isset($input['email'])) {
|
||||
$clientEmail = ClientsEmail::where('client_guid', $client->user_code)->first();
|
||||
if ($clientEmail) {
|
||||
$clientEmail = ClientsEmail::find($clientEmail['id']);
|
||||
if (isset($input['email']) && $input['email'] !== '') {
|
||||
$clientEmail->email = urldecode($input['email']);
|
||||
} else {
|
||||
$clientEmail->email = '';
|
||||
}
|
||||
} else {
|
||||
$clientEmail = new ClientsEmail;
|
||||
$clientEmail->email = urldecode($input['email']);
|
||||
}
|
||||
$clientEmail->client_guid = $client->user_code;
|
||||
$clientEmail->save();
|
||||
} else {
|
||||
$clientEmail = '';
|
||||
}
|
||||
|
||||
$clientBarcode = ClientsBarcode::where('client_guid', $client->user_code)->first();
|
||||
if ($clientBarcode) {
|
||||
$clientBarcode = ClientsBarcode::find($clientBarcode['id']);
|
||||
if ($input['barcode'] !== '') {
|
||||
$clientBarcode->code_id = urldecode($input['barcode']);
|
||||
} else {
|
||||
$clientBarcode->code_id = '';
|
||||
}
|
||||
$clientBarcode->save();
|
||||
}
|
||||
if (isset($input['address'])) {
|
||||
$clientAddress = ClientsAddress::where('client_guid', $client->user_code)->first();
|
||||
if ($clientAddress) {
|
||||
$clientAddress = ClientsAddress::find($clientAddress['id']);
|
||||
if ($input['address'] !== '') {
|
||||
$clientAddress->address = urldecode($input['address']);
|
||||
} else {
|
||||
$clientAddress->address = '';
|
||||
}
|
||||
} else {
|
||||
$clientAddress = new ClientsAddress;
|
||||
$clientAddress->address = urldecode($input['address']);
|
||||
}
|
||||
$clientAddress->client_guid = $client->user_code;
|
||||
$clientAddress->save();
|
||||
}
|
||||
|
||||
$clientBarcodeStart = 0;
|
||||
$clientBarcodeEnd = 0;
|
||||
|
||||
if (isset($input['barcode'])) {
|
||||
if ($input['barcode'] !== '') {
|
||||
$client->barcode_type = 2;
|
||||
$client->barcode_start = $clientBarcodeStart = urldecode($input['barcode']);
|
||||
$client->barcode_end = $clientBarcodeEnd = urldecode($input['barcode']);
|
||||
} else {
|
||||
$client->barcode_type = 1;
|
||||
$client->barcode_start = $clientBarcodeStart;
|
||||
$client->barcode_end = $clientBarcodeEnd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($input['is_special_price']) && $input['is_special_price'] == 'true') {
|
||||
$specialPrice = 1;
|
||||
} else {
|
||||
$specialPrice = 0;
|
||||
}
|
||||
if (isset($input['is_employee']) && $input['is_employee'] == 'true') {
|
||||
$employee = 1;
|
||||
} else {
|
||||
$employee = 0;
|
||||
}
|
||||
$client->is_special_price = $specialPrice;
|
||||
$client->is_employee = $employee;
|
||||
$client->save();
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'client' => $client,
|
||||
'phone' => $clientPhone,
|
||||
'email' => $clientEmail,
|
||||
'address' => $clientAddress,
|
||||
'barcode' => $clientBarcode,
|
||||
'message' => 'Клиент обновлен',
|
||||
];
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'client' => $client,
|
||||
'phone' => $clientPhone,
|
||||
'email' => $clientEmail,
|
||||
'address' => $clientAddress,
|
||||
'barcode' => $clientBarcodeStart,
|
||||
'message' => 'Клиент обновлен',
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'delete') {
|
||||
$client = Client::find($input['id']);
|
||||
$clientGroup = ClientsGroup::where('code', $client->group_id)->first();
|
||||
$clientPhone = ClientsPhone::where('client_guid', $client->user_code)->first();
|
||||
$clientPhone = ClientsPhone::find($clientPhone['id']);
|
||||
$clientEmail = ClientsEmail::where('client_guid', $client->user_code)->first();
|
||||
$clientEmail = ClientsEmail::find($clientEmail['id']);
|
||||
$clientAddress = ClientsAddress::where('client_guid', $client->user_code)->first();
|
||||
$clientAddress = ClientsAddress::find($clientAddress['id']);
|
||||
$clientBarcode = ClientsBarcode::where('client_guid', $client->user_code)->first();
|
||||
$clientBarcode = ClientsBarcode::find($clientBarcode['id']);
|
||||
if ($clientPhone) {
|
||||
$clientPhone->delete();
|
||||
}
|
||||
if ($clientEmail) {
|
||||
$clientEmail->delete();
|
||||
}
|
||||
if ($clientAddress) {
|
||||
$clientAddress->delete();
|
||||
}
|
||||
if ($clientBarcode) {
|
||||
$clientBarcode->delete();
|
||||
}
|
||||
if ($client) {
|
||||
$client->delete();
|
||||
}
|
||||
if ($input['task'] == 'delete') {
|
||||
$client = Client::find($input['id']);
|
||||
$clientGroup = ClientsGroup::where('code', $client->group_id)->first();
|
||||
$clientPhone = ClientsPhone::where('client_guid', $client->user_code)->first();
|
||||
$clientPhone = ClientsPhone::find($clientPhone['id']);
|
||||
$clientEmail = ClientsEmail::where('client_guid', $client->user_code)->first();
|
||||
$clientEmail = ClientsEmail::find($clientEmail['id']);
|
||||
$clientAddress = ClientsAddress::where('client_guid', $client->user_code)->first();
|
||||
$clientAddress = ClientsAddress::find($clientAddress['id']);
|
||||
$clientBarcode = ClientsBarcode::where('client_guid', $client->user_code)->first();
|
||||
$clientBarcode = ClientsBarcode::find($clientBarcode['id']);
|
||||
if ($clientPhone) {
|
||||
$clientPhone->delete();
|
||||
}
|
||||
if ($clientEmail) {
|
||||
$clientEmail->delete();
|
||||
}
|
||||
if ($clientAddress) {
|
||||
$clientAddress->delete();
|
||||
}
|
||||
if ($clientBarcode) {
|
||||
$clientBarcode->delete();
|
||||
}
|
||||
if ($client) {
|
||||
$client->delete();
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Клиент удален',
|
||||
'currentGroup' => $clientGroup['id'],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Клиент удален',
|
||||
'currentGroup' => $clientGroup['id'],
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'lock') {
|
||||
if (isset($input['id'])) {
|
||||
$id = $input['id'];
|
||||
} else if (isset($input['client_guid'])) {
|
||||
$fClient = Client::where('user_code', $input['client_guid'])->first();
|
||||
if (!isset($fClient)) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Клиент не найден',
|
||||
];
|
||||
}
|
||||
$id = $fClient['id'];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
$client = Client::find($id);
|
||||
$clientGroup = ClientsGroup::where('code', $client->group_id)->first();
|
||||
$client->is_block = 1;
|
||||
$client->save();
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Клиент заблокирован',
|
||||
'currentGroup' => $clientGroup['id'],
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'unlock') {
|
||||
if (isset($input['id'])) {
|
||||
$id = $input['id'];
|
||||
} else if (isset($input['client_guid'])) {
|
||||
$fClient = Client::where('user_code', $input['client_guid'])->first();
|
||||
if (!isset($fClient)) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Клиент не найден',
|
||||
];
|
||||
}
|
||||
$id = $fClient['id'];
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
$client = Client::find($id);
|
||||
$clientGroup = ClientsGroup::where('code', $client->group_id)->first();
|
||||
$client->is_block = 0;
|
||||
$client->save();
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Клиент разблокирован',
|
||||
'currentGroup' => $clientGroup['id'],
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'search' && isset($input['name'])) {
|
||||
$client = Client::where('name', 'like', '%' . urldecode($input['name']) . '%')->get();
|
||||
if (count($client) > 0) {
|
||||
$message = 'Клиенты найдены!';
|
||||
} else {
|
||||
$message = 'Клиенты с именем ' . urldecode($input['name']) . ' не найдены!';
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => $message,
|
||||
'clients' => $client
|
||||
];
|
||||
}
|
||||
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'error_message' => 'Проверьте введенные данные',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,11 +30,26 @@ class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
}
|
||||
|
||||
$total = Client::where('name', '=', $input['name'])->count();
|
||||
if (isset($input['client_guid'])) {
|
||||
$check_guid = Client::where('user_code', $input['client_guid'])->count();
|
||||
if ($check_guid > 0) {
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Клиент уже существует'
|
||||
];
|
||||
}
|
||||
}
|
||||
$client_code = Client::max('code') + 1;
|
||||
if (isset($input['is_special_price']) && $input['is_special_price'] == 'true') {
|
||||
$specialPrice = 1;
|
||||
} else {
|
||||
$specialPrice = 0;
|
||||
}
|
||||
if (isset($input['is_employee']) && $input['is_employee'] == 'true') {
|
||||
$employee = 1;
|
||||
} else {
|
||||
$employee = 0;
|
||||
}
|
||||
$client = new Client;
|
||||
if ($total >= 1) {
|
||||
$total = $total + 1;
|
||||
@@ -42,10 +57,17 @@ class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
} else {
|
||||
$client->name = urldecode($input['name']);
|
||||
}
|
||||
$client->user_code = strtoupper(md5(time()));
|
||||
if (!isset($input['client_guid'])) {
|
||||
$client->user_code = strtoupper(md5(time()));
|
||||
} else {
|
||||
$client->user_code = $input['client_guid'];
|
||||
}
|
||||
|
||||
$client->code = $client_code;
|
||||
$client->group_id = $group['code'];
|
||||
$client->is_special_price = $specialPrice;
|
||||
|
||||
$client->is_employee = $employee;
|
||||
$client->last_change = date("Ymd");
|
||||
$clientEmail = new ClientsEmail;
|
||||
$clientEmail->email = urldecode($input['email']);
|
||||
$clientEmail->client_guid = $client->user_code;
|
||||
@@ -55,7 +77,7 @@ class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
$clientAddress->client_guid = $client->user_code;
|
||||
|
||||
$clientPhone = new ClientsPhone;
|
||||
if ($input['phone'] !== '') {
|
||||
if ($input['phone'] !== '' && isset($input['phone'])) {
|
||||
$phoneData = urldecode($input['phone']);
|
||||
$phone = '+375 (' . substr($phoneData, 0, 2) . ') ' . substr($phoneData, 2, 3) . '-' . substr($phoneData, 5, 2) . '-' . substr($phoneData, 7, 2);
|
||||
} else {
|
||||
@@ -65,7 +87,7 @@ class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
$clientPhone->client_guid = $client->user_code;
|
||||
|
||||
if (isset($input['barcode']) && $input['barcode'] > 0) {
|
||||
$client->barcode_type = 1;
|
||||
$client->barcode_type = 2;
|
||||
$clientBarcode = new ClientsBarcode;
|
||||
$clientBarcode->code_id = urldecode($input['barcode']);
|
||||
$clientBarcode->name = '';
|
||||
@@ -73,13 +95,15 @@ class POSTCreateClient extends HRCCommand implements HRCCommandInterface {
|
||||
$clientBarcode->value = urldecode($input['barcode']);
|
||||
$clientBarcode->block = 0;
|
||||
$clientBarcode->symptom_block = 0;
|
||||
$client->barcode_start = urldecode($input['barcode']);
|
||||
$client->barcode_end = urldecode($input['barcode']);
|
||||
$client->save();
|
||||
$clientPhone->save();
|
||||
$clientEmail->save();
|
||||
$clientAddress->save();
|
||||
$clientBarcode->save();
|
||||
} else {
|
||||
$client->barcode_type = 0;
|
||||
$client->barcode_type = 1;
|
||||
$client->save();
|
||||
$clientPhone->save();
|
||||
$clientEmail->save();
|
||||
|
||||
@@ -2,11 +2,16 @@
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Base;
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\OrderBot;
|
||||
use App\Component\Models\OrderBotStorage;
|
||||
use App\Component\Models\OrderItems;
|
||||
use App\Component\Models\Orders;
|
||||
use App\Component\Models\TerminalUpdate;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class POSTOrder extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postorder';
|
||||
@@ -97,6 +102,132 @@ class POSTOrder extends HRCCommand implements HRCCommandInterface {
|
||||
];
|
||||
}
|
||||
|
||||
if ($input['task'] == 'pay' && isset($input['info'])) {
|
||||
$test_json = Base::validate_json(urldecode($input['info']));
|
||||
if (!$test_json) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'Ошибка обработки JSON',
|
||||
];
|
||||
}
|
||||
$order_info = json_decode(urldecode($input['info']), true);
|
||||
|
||||
if (isset($order_info['order_id'])) {
|
||||
$order_id = intval($order_info['order_id']);
|
||||
$order = OrderBotStorage::where('id', $order_id)->first();
|
||||
if (!isset($order)) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'Заказ с данным ID не найден',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'Отсутствует ID заказа',
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($order_info['transaction_id'])) {
|
||||
$transaction_id = intval($order_info['transaction_id']);
|
||||
$order_data = json_decode(base64_decode($order['order']), true);
|
||||
if ($transaction_id != $order_data['id']) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'ID заказа не соответствует ID транзакции',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'Отсутствует ID транзакции',
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($order_info['time'])) {
|
||||
$pay_time = $order_info['time'];
|
||||
if ($pay_time < $order['created_at']) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'Время создания заказа больше чем время оплаты',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'Отсутствует время оплаты заказа',
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($order_info['amount'])) {
|
||||
$amount = floatval($order_info['amount']);
|
||||
if ($amount != floatval($order_data['price'])) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'Сумма оплаты не соответствует сумме заказа',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'Отсутствует сумма оплаты',
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($order_info['is_print'])) {
|
||||
$is_print = $order_info['is_print'];
|
||||
} else {
|
||||
$is_print = false;
|
||||
}
|
||||
|
||||
if (isset($order_info['is_closed'])) {
|
||||
$is_closed = $order_info['is_closed'];
|
||||
} else {
|
||||
$is_closed = false;
|
||||
}
|
||||
|
||||
if ($order['is_send'] === 0) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'Заказ ещё не отправлен',
|
||||
];
|
||||
} else {
|
||||
$pay_task = array(
|
||||
'order_id' => $order_id,
|
||||
'transaction_id' => $transaction_id,
|
||||
'time' => $pay_time,
|
||||
'amount' => $amount,
|
||||
'is_print' => $is_print,
|
||||
'is_closed' => $is_closed
|
||||
);
|
||||
$todayDate = Carbon::now('Europe/Minsk')->format('Y-m-d H:i:m');
|
||||
$bot_info = OrderBot::first();
|
||||
$terminal_id = $bot_info['terminal_id'];
|
||||
$check_order = TerminalUpdate::where('method', 'payorder')
|
||||
->where('more', base64_encode(json_encode($pay_task)))
|
||||
->count();
|
||||
if ($check_order > 0) {
|
||||
return [
|
||||
'status' => 'fail',
|
||||
'message' => 'Задача оплаты в обработке',
|
||||
];
|
||||
}
|
||||
$task = new TerminalUpdate;
|
||||
$task->terminal_id = $terminal_id;
|
||||
$task->next_at = $todayDate;
|
||||
$task->method = 'payorder';
|
||||
$task->period = 1;
|
||||
$task->is_cycle = 0;
|
||||
$task->more = base64_encode(json_encode($pay_task));
|
||||
$task->save();
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Информация об оплате отправлена',
|
||||
];
|
||||
}
|
||||
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsPresale;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class POSTPresale extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
@@ -12,18 +14,19 @@ class POSTPresale extends HRCCommand implements HRCCommandInterface
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
$client_guid = $input['client_id'];
|
||||
$client_guid = $input['client_guid'];
|
||||
$presale_amount = abs($input['amount']);
|
||||
$staff_id = $input['who'];
|
||||
$staff_id = $input['who_id'];
|
||||
$presale_time = $input['date_transaction'];
|
||||
$type = $input['type'];
|
||||
$action_type = intval($input['action_type']);
|
||||
$code_order = intval($input['code_order']);
|
||||
ClientsPresale::presaleReg($client_guid, $presale_amount, $type);
|
||||
ClientsPresale::presaleLog($client_guid, $presale_amount, $presale_time, $staff_id);
|
||||
if ($type == 'in') {
|
||||
$message = 'Внесен аванс на сумму ' . $presale_amount . ' BYN';
|
||||
} elseif ($type == 'out') {
|
||||
$message = 'Зачтен аванс на сумму ' . $presale_amount . ' BYN';
|
||||
}
|
||||
$message = ClientsPresale::presaleLog($client_guid, $presale_amount, $presale_time, $staff_id, $action_type, $code_order);
|
||||
$client = Client::where('user_code', $client_guid)->first();
|
||||
$client = Client::find($client['id']);
|
||||
$client->updated_at = Carbon::createFromTimestampUTC($presale_time)->timezone('Europe/Minsk');
|
||||
$client->save();
|
||||
$presale_result = ClientsPresale::getPresale($client_guid);
|
||||
return [
|
||||
'status' => 'success',
|
||||
|
||||
Reference in New Issue
Block a user