v.2.21
Обновлен перенос клиента из группы в группу Обновлен метод восстановления смены Добавлен метод загрузки меню 1с из облака
This commit is contained in:
@@ -14,6 +14,58 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getdatareport';
|
||||
|
||||
public function command($input, $output = null) {
|
||||
|
||||
function validate_json($string)
|
||||
{
|
||||
// decode the JSON data
|
||||
$result = json_decode(utf8_encode($string), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
|
||||
// switch and check possible JSON errors
|
||||
switch (json_last_error()) {
|
||||
case JSON_ERROR_NONE:
|
||||
$error = ''; // JSON is valid // No error has occurred
|
||||
break;
|
||||
case JSON_ERROR_DEPTH:
|
||||
$error = 'The maximum stack depth has been exceeded.';
|
||||
break;
|
||||
case JSON_ERROR_STATE_MISMATCH:
|
||||
$error = 'Invalid or malformed JSON.';
|
||||
break;
|
||||
case JSON_ERROR_CTRL_CHAR:
|
||||
$error = 'Control character error, possibly incorrectly encoded.';
|
||||
break;
|
||||
case JSON_ERROR_SYNTAX:
|
||||
$error = 'Syntax error, malformed JSON.';
|
||||
break;
|
||||
// PHP >= 5.3.3
|
||||
case JSON_ERROR_UTF8:
|
||||
$error = 'Malformed UTF-8 characters, possibly incorrectly encoded.';
|
||||
break;
|
||||
// PHP >= 5.5.0
|
||||
case JSON_ERROR_RECURSION:
|
||||
$error = 'One or more recursive references in the value to be encoded.';
|
||||
break;
|
||||
// PHP >= 5.5.0
|
||||
case JSON_ERROR_INF_OR_NAN:
|
||||
$error = 'One or more NAN or INF values in the value to be encoded.';
|
||||
break;
|
||||
case JSON_ERROR_UNSUPPORTED_TYPE:
|
||||
$error = 'A value of a type that cannot be encoded was given.';
|
||||
break;
|
||||
default:
|
||||
$error = 'Unknown JSON error occured.';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($error !== '') {
|
||||
// throw the Exception or exit // or whatever :)
|
||||
return false;
|
||||
}
|
||||
|
||||
// everything is OK
|
||||
return true;
|
||||
}
|
||||
|
||||
function data_decode($data) {
|
||||
$alph = [
|
||||
"А", "Б", "В", "Г", "Д",
|
||||
@@ -103,7 +155,12 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface {
|
||||
if ($item_action['more']) {
|
||||
$merge_trigger = 1;
|
||||
$merge_items_before = $merge_items_after = $merge_items = $merge_order_item_before = $merge_order_item_after = $merged_items = [];
|
||||
$merge_order_items = json_decode(utf8_encode($item_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
if (validate_json($item['more'])) {
|
||||
$merge_order_items = json_decode(utf8_encode($item_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
} else {
|
||||
$merge_order_items = json_decode(utf8_encode(base64_decode($item_action['more'], TRUE)), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
}
|
||||
|
||||
$merge_order_items_before = $merge_order_items['before']['items'];
|
||||
$merge_order_items_after = $merge_order_items['after']['items'];
|
||||
foreach ($merge_order_items_before as $key => $merge_order_item_before) {
|
||||
@@ -168,13 +225,21 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface {
|
||||
foreach ($actions as $key => $action) {
|
||||
$value = $action['value'];
|
||||
$codeOrder = $action['order_code'];
|
||||
$moved_items = json_decode(utf8_encode($action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
if (validate_json($action['more'])) {
|
||||
$moved_items = json_decode(utf8_encode($action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
} else {
|
||||
$moved_items = json_decode(utf8_encode(base64_decode($action['more'], TRUE)), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
}
|
||||
$from_place = ExchangeActions::where('order_code', $codeOrder)->where('action_type', 45)->where('shift_id', $input['shift_id'])->first();
|
||||
$from_place = data_decode($from_place['value']);
|
||||
$to_place = ExchangeActions::where('order_code', $value)->where('action_type', 45)->where('shift_id', $input['shift_id'])->first();
|
||||
$to_place = data_decode($to_place['value']);
|
||||
$to_action = ExchangeActions::where('value', $codeOrder)->where('order_code', $value)->where('action_type', 34)->where('shift_id', $input['shift_id'])->first();
|
||||
$start_data = json_decode(utf8_encode($to_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
if (validate_json($to_action['more'])) {
|
||||
$start_data = json_decode(utf8_encode($to_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
} else {
|
||||
$start_data = json_decode(utf8_encode(base64_decode($to_action['more'], TRUE)), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
}
|
||||
$staff_name = staffName($action['who']);
|
||||
$time = date('d.m.Y H:i:s', strtotime($action['time']));
|
||||
$sliced_order_data[] = array('from_order' => $codeOrder, 'from_place' => $from_place, 'staff' => $staff_name, 'time' => $time, 'start_data' => $start_data, 'to_order' => $value, 'to_place' => $to_place, 'moved_items' => $moved_items);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,7 @@ use App\Component\Models\Units;
|
||||
use App\Component\Models\UnitsList;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class GETOrderHistory extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'getorderhistory';
|
||||
@@ -26,6 +27,57 @@ class GETOrderHistory extends HRCCommand implements HRCCommandInterface {
|
||||
$merge_trigger = 0;
|
||||
$move_trigger = 0;
|
||||
|
||||
function json_validate($string)
|
||||
{
|
||||
// decode the JSON data
|
||||
$result = json_decode(utf8_encode($string), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
|
||||
// switch and check possible JSON errors
|
||||
switch (json_last_error()) {
|
||||
case JSON_ERROR_NONE:
|
||||
$error = ''; // JSON is valid // No error has occurred
|
||||
break;
|
||||
case JSON_ERROR_DEPTH:
|
||||
$error = 'The maximum stack depth has been exceeded.';
|
||||
break;
|
||||
case JSON_ERROR_STATE_MISMATCH:
|
||||
$error = 'Invalid or malformed JSON.';
|
||||
break;
|
||||
case JSON_ERROR_CTRL_CHAR:
|
||||
$error = 'Control character error, possibly incorrectly encoded.';
|
||||
break;
|
||||
case JSON_ERROR_SYNTAX:
|
||||
$error = 'Syntax error, malformed JSON.';
|
||||
break;
|
||||
// PHP >= 5.3.3
|
||||
case JSON_ERROR_UTF8:
|
||||
$error = 'Malformed UTF-8 characters, possibly incorrectly encoded.';
|
||||
break;
|
||||
// PHP >= 5.5.0
|
||||
case JSON_ERROR_RECURSION:
|
||||
$error = 'One or more recursive references in the value to be encoded.';
|
||||
break;
|
||||
// PHP >= 5.5.0
|
||||
case JSON_ERROR_INF_OR_NAN:
|
||||
$error = 'One or more NAN or INF values in the value to be encoded.';
|
||||
break;
|
||||
case JSON_ERROR_UNSUPPORTED_TYPE:
|
||||
$error = 'A value of a type that cannot be encoded was given.';
|
||||
break;
|
||||
default:
|
||||
$error = 'Unknown JSON error occured.';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($error !== '') {
|
||||
// throw the Exception or exit // or whatever :)
|
||||
return false;
|
||||
}
|
||||
|
||||
// everything is OK
|
||||
return true;
|
||||
}
|
||||
|
||||
function dishName($data) {
|
||||
$dish_name = Dishes::where('code', $data)->where('is_history', 0)->first();
|
||||
if ($dish_name) {
|
||||
@@ -206,7 +258,12 @@ class GETOrderHistory extends HRCCommand implements HRCCommandInterface {
|
||||
$action_name = $action_name . ': ' . $item['value'];
|
||||
$slice_items = [];
|
||||
if ($item['more']) {
|
||||
$slice_order_items = json_decode(utf8_encode($item['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
if (json_validate($item['more'])) {
|
||||
$slice_order_items = json_decode(utf8_encode($item['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
} else {
|
||||
$slice_order_items = json_decode(utf8_encode(base64_decode($item['more'], TRUE)), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
}
|
||||
//$slice_order_items = json_decode(utf8_encode($item['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
$slice_order_items = $slice_order_items['items'];
|
||||
$slice_order = $item['value'];
|
||||
foreach ($slice_order_items as $key => $slice_order_item) {
|
||||
@@ -227,7 +284,12 @@ class GETOrderHistory extends HRCCommand implements HRCCommandInterface {
|
||||
foreach ($item_actions as $key => $item_action) {
|
||||
if ($item_action['more']) {
|
||||
$merge_items_before = $merge_items_after = $merge_items = $merge_order_item_before = $merge_order_item_after = $merged_items = [];
|
||||
$merge_order_items = json_decode(utf8_encode($item_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
if (json_validate($item['more'])) {
|
||||
$merge_order_items = json_decode(utf8_encode($item_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
} else {
|
||||
$merge_order_items = json_decode(utf8_encode(base64_decode($item_action['more'])), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
}
|
||||
//$merge_order_items = json_decode(utf8_encode($item_action['more']), true, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
$merge_order_items_before = $merge_order_items['before']['items'];
|
||||
$merge_order_items_after = $merge_order_items['after']['items'];
|
||||
foreach ($merge_order_items_before as $key => $merge_order_item_before) {
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Component\Models\ClientsGroup;
|
||||
use App\Component\Models\ClientsPhone;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class POSTClient extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postclient';
|
||||
@@ -18,18 +19,17 @@ class POSTClient extends HRCCommand implements HRCCommandInterface {
|
||||
|
||||
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::find($input['group_id']);
|
||||
$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 ($input['phone'] !== '') {
|
||||
if (substr($input['phone'], 0, 1) == '+') {
|
||||
if ($phone !== '' && $phone !== '+375 ( ) - -') {
|
||||
if (substr($phone, 0, 1) == '+') {
|
||||
$phoneData = urldecode($input['phone']);
|
||||
} else {
|
||||
$phoneData = urldecode($input['phone']);
|
||||
@@ -74,8 +74,7 @@ class POSTClient extends HRCCommand implements HRCCommandInterface {
|
||||
$clientBarcode->save();
|
||||
}
|
||||
|
||||
$client->save();
|
||||
$clientGroup->save();
|
||||
$client->save();
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
|
||||
@@ -15,7 +15,7 @@ class POSTClientGroup extends HRCCommand implements HRCCommandInterface {
|
||||
if (isset($input['task']) && isset($input['id'])) {
|
||||
if ($input['task'] == 'update') {
|
||||
$group = ClientsGroup::find($input['id']);
|
||||
$group->name = $input['name'];
|
||||
$group->name = urldecode($input['name']);
|
||||
$group->save();
|
||||
|
||||
return [
|
||||
|
||||
@@ -15,6 +15,7 @@ use App\Component\Models\Shifts;
|
||||
use App\Component\Models\TerminalUpdate;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class POSTRestoreShift extends HRCCommand implements HRCCommandInterface {
|
||||
protected $signature = 'postrestoreshift';
|
||||
@@ -37,45 +38,65 @@ class POSTRestoreShift extends HRCCommand implements HRCCommandInterface {
|
||||
}
|
||||
$shift_id = $input['shift_id'];
|
||||
$cache_dir = __DIR__ . "\\..\\..\\..\\Cache\\";
|
||||
dirDel($cache_dir);
|
||||
|
||||
|
||||
$nowTime = time();
|
||||
$update = true;
|
||||
$alph = [
|
||||
"А",
|
||||
"Б",
|
||||
"В",
|
||||
"Г",
|
||||
"Д",
|
||||
"Е",
|
||||
"Ё",
|
||||
"Ж",
|
||||
"З",
|
||||
"И",
|
||||
"Й",
|
||||
"К",
|
||||
"Л",
|
||||
"М",
|
||||
"Н",
|
||||
"О",
|
||||
"П",
|
||||
"Р",
|
||||
"С",
|
||||
"Т",
|
||||
"У",
|
||||
"Ф",
|
||||
"Х",
|
||||
"Ц",
|
||||
"Ч",
|
||||
"Ш",
|
||||
"Щ",
|
||||
"Ъ",
|
||||
"Ы",
|
||||
"Ь",
|
||||
"Э",
|
||||
"Ю",
|
||||
"Я",
|
||||
];
|
||||
|
||||
function decode_text($data) {
|
||||
$alph = [
|
||||
"А", "Б", "В", "Г", "Д",
|
||||
"Е", "Ё", "Ж", "З", "И",
|
||||
"Й", "К", "Л", "М", "Н",
|
||||
"О", "П", "Р", "С", "Т",
|
||||
"У", "Ф", "Х", "Ц", "Ч",
|
||||
"Ш", "Щ", "Ъ", "Ы", "Ь",
|
||||
"Э", "Ю", "Я",
|
||||
"а", "б", "в", "г", "д",
|
||||
"е", "ё", "ж", "з", "и",
|
||||
"й", "к", "л", "м", "н",
|
||||
"о", "п", "р", "с", "т",
|
||||
"у", "ф", "х", "ц", "ч",
|
||||
"ш", "щ", "ъ", "ы", "ь",
|
||||
"э", "ю", "я",
|
||||
];
|
||||
|
||||
foreach ($alph as $key => $letter) {
|
||||
$haystack = mb_convert_encoding($data, "CP1251", "UTF-8");
|
||||
$needle = $letter;
|
||||
$pos = strripos($haystack, $needle);
|
||||
if ($pos === false) {
|
||||
$after_conv = false;
|
||||
} else {
|
||||
$after_conv = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$after_conv) {
|
||||
foreach ($alph as $key => $letter) {
|
||||
$haystack = $data;
|
||||
$needle = $letter;
|
||||
$pos = strripos($haystack, $needle);
|
||||
if ($pos === false) {
|
||||
$before_conv = false;
|
||||
} else {
|
||||
$before_conv = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($after_conv) {
|
||||
$retval = mb_convert_encoding($data, "CP1251", "UTF-8");
|
||||
} elseif ($before_conv) {
|
||||
$retval = $data;
|
||||
} else {
|
||||
$retval = $data;
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
$exchange_shifts = ExchangeShifts::where('id', '=', $shift_id)->first();
|
||||
$exchange_orders = ExchangeOrders::where('shift_id', '=', $shift_id)->get();
|
||||
$exchange_items = ExchangeItems::where('shift_id', '=', $shift_id)->get();
|
||||
@@ -109,6 +130,7 @@ class POSTRestoreShift extends HRCCommand implements HRCCommandInterface {
|
||||
|
||||
//clear shift_online_orders
|
||||
ShiftOnlineOrders::truncate();
|
||||
Log::debug('ShiftOnlineOrders cleaned');
|
||||
foreach ($exchange_orders as $key => $exchange_order) {
|
||||
$shift_online_order = new ShiftOnlineOrders;
|
||||
$shift_online_order->cash = $exchange_order["cash"];
|
||||
@@ -141,45 +163,8 @@ class POSTRestoreShift extends HRCCommand implements HRCCommandInterface {
|
||||
$shift_online_order->opened = $exchange_order["opened"];
|
||||
$shift_online_order->order_sum = $exchange_order["order_sum"];
|
||||
$shift_online_order->params_code = $exchange_order["params_id"];
|
||||
|
||||
$place_name_bd = $exchange_order["place_name"];
|
||||
$place_name_d = mb_convert_encoding($place_name_bd, "CP1251", "UTF-8");
|
||||
|
||||
foreach ($alph as $key => $letter) {
|
||||
$haystack = $place_name_d;
|
||||
$needle = $letter;
|
||||
$pos = strripos($haystack, $needle);
|
||||
if ($pos === false) {
|
||||
$after_conv = false;
|
||||
} else {
|
||||
$after_conv = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$after_conv) {
|
||||
foreach ($alph as $key => $letter) {
|
||||
$haystack = $place_name_bd;
|
||||
$needle = $letter;
|
||||
$pos = strripos($haystack, $needle);
|
||||
if ($pos === false) {
|
||||
$before_conv = false;
|
||||
} else {
|
||||
$before_conv = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($after_conv) {
|
||||
$place_name_decoded = $place_name_d;
|
||||
} elseif ($before_conv) {
|
||||
$place_name_decoded = $place_name_bd;
|
||||
} else {
|
||||
$place_name_decoded = $place_name_bd;
|
||||
}
|
||||
|
||||
$shift_online_order->place_name = $place_name_decoded;
|
||||
$shift_online_order->place_name = mb_convert_encoding(decode_text($exchange_order["place_name"]), 'UTF-8', 'UTF-8');
|
||||
log::debug(decode_text($exchange_order["place_name"]));
|
||||
$shift_online_order->presale = $exchange_order["presale"];
|
||||
$shift_online_order->sale_sum = $exchange_order["sale_sum"];
|
||||
$shift_online_order->self = $exchange_order["self"];
|
||||
@@ -193,6 +178,7 @@ class POSTRestoreShift extends HRCCommand implements HRCCommandInterface {
|
||||
}
|
||||
|
||||
ShiftOnlineItems::truncate();
|
||||
Log::debug('ShiftOnlineItems cleaned');
|
||||
foreach ($exchange_items as $key => $exchange_item) {
|
||||
$shift_online_item = new ShiftOnlineItems;
|
||||
$shift_online_item->code = $exchange_item["code"];
|
||||
@@ -218,6 +204,7 @@ class POSTRestoreShift extends HRCCommand implements HRCCommandInterface {
|
||||
}
|
||||
|
||||
ShiftOnlineActions::truncate();
|
||||
Log::debug('ShiftOnlineActions cleaned');
|
||||
foreach ($exchange_actions as $key => $exchange_action) {
|
||||
$shift_online_action = new ShiftOnlineActions;
|
||||
$shift_online_action->type_action = $exchange_action["action_type"];
|
||||
@@ -235,6 +222,7 @@ class POSTRestoreShift extends HRCCommand implements HRCCommandInterface {
|
||||
}
|
||||
|
||||
ShiftOnlineDeleted::truncate();
|
||||
Log::debug('ShiftOnlineDeleted cleaned');
|
||||
foreach ($exchange_deleted as $key => $exchange_deleted_item) {
|
||||
$shift_online_deleted_item = new ShiftOnlineDeleted;
|
||||
$shift_online_deleted_item->code = $exchange_deleted_item["code"];
|
||||
@@ -253,6 +241,7 @@ class POSTRestoreShift extends HRCCommand implements HRCCommandInterface {
|
||||
$exc_time = time();
|
||||
$diff_time = $exc_time - $nowTime;
|
||||
$terminal_online = TerminalUpdate::where('method', 'online')->where('terminal_id', $exchange_shifts['terminal_id'])->first();
|
||||
dirDel($cache_dir);
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Данные автоматически синхронизируются с POS-системой ' . $terminal_online['next_at'],
|
||||
|
||||
Reference in New Issue
Block a user