Обновлен перенос клиента из группы в группу
Обновлен метод восстановления смены
Добавлен метод загрузки меню 1с из облака
This commit is contained in:
miroman-afk
2022-07-25 23:26:44 +03:00
parent 9c3b633098
commit 1af2b267f5
14 changed files with 1848 additions and 309 deletions

View File

@@ -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) {