From: Aleksey Filippov Date: Fri, 13 Feb 2026 05:50:04 +0000 (+0300) Subject: Фиксирование плашки смена открыть закрыть на первой странице.Доработка логирования. X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=375df4a935760a2500d8d05e5ddceea4a729ff59;p=erp24_rep%2Fyii-erp24%2F.git Фиксирование плашки смена открыть закрыть на первой странице.Доработка логирования. --- diff --git a/erp24/api2/controllers/StoreController.php b/erp24/api2/controllers/StoreController.php index 620068db..7bd03f6f 100644 --- a/erp24/api2/controllers/StoreController.php +++ b/erp24/api2/controllers/StoreController.php @@ -254,12 +254,23 @@ class StoreController extends BaseController { $__API_PARAMS = ['id', 'store_id', 'seller_id', 'created_at', 'summ', 'status_id', 'products_json']; // comment, check_id + $missingParams = []; foreach ($__API_PARAMS as $paramName) { if (!isset($result[$paramName])) { - LogService::apiErrorLog(json_encode(["error_id" => 1, "error" => "$paramName is required"], JSON_UNESCAPED_UNICODE)); - return $this->asJson(["error_id" => 1, "error" => "$paramName is required"]); + $missingParams[] = $paramName; } } + if (!empty($missingParams)) { + $errorPayload = [ + "error_id" => 1, + "error" => "Отсутствуют обязательные поля: " . implode(', ', $missingParams), + "missing_params" => $missingParams, + "received_params" => array_keys($result), + "assembly_id" => $result['id'] ?? 'unknown', + ]; + LogService::apiErrorLog(json_encode($errorPayload, JSON_UNESCAPED_UNICODE)); + return $this->asJson($errorPayload); + } $assemble = Assemblies::findOne(['guid' => $result['id']]); if (!$assemble) { @@ -333,11 +344,15 @@ class StoreController extends BaseController { } } - $assemble->save(); - - if ($assemble->getErrors()) { - LogService::apiErrorLog(json_encode(["error_id" => 3, "error" => $assemble->getErrors()], JSON_UNESCAPED_UNICODE)); - return $this->asJson(["error_id" => 3, "error" => $assemble->getErrors()]); + if (!$assemble->save()) { + $errorPayload = [ + "error_id" => 3, + "error" => $assemble->getErrors(), + "assembly_id" => $result['id'], + "status_id" => $result['status_id'], + ]; + LogService::apiErrorLog(json_encode($errorPayload, JSON_UNESCAPED_UNICODE)); + return $this->asJson($errorPayload); } return $this->asJson(['response' => true]); diff --git a/erp24/services/UploadService.php b/erp24/services/UploadService.php index fbdf9bd3..f125c86b 100644 --- a/erp24/services/UploadService.php +++ b/erp24/services/UploadService.php @@ -1225,41 +1225,55 @@ class UploadService { // } if ($update) { - - $sales2 = new Sales; - $sales2->phone = $arr["client_phone"] ?? 0; - $sales2->id = $arr["id"]; - $sales2->store_id = $store_id; - $sales2->store_id_1c = $arr["store_id"]; - $sales2->seller_id = $arr["seller_id"]; - $sales2->admin_id = $admin_id; - $sales2->operation = $arr["type"]; - $sales2->number = $arr["number"]; - $sales2->date = $arr["date"]; - $sales2->summ = $arr["summ"]; - $sales2->status = $arr["status"]; - $sales2->sales_check = $arr["sales_check"] ?? ''; - $sales2->payments = json_encode($arr["payments"], JSON_UNESCAPED_UNICODE); - $sales2->pay_arr = implode(",", $pay_arr); - $sales2->order_id = trim($arr["order_id"] ?? ''); - $sales2->terminal = $arr["terminal"] ?? ''; - $sales2->terminal_id = $arr["terminal_id"] ?? ''; - $sales2->date_up = date('Y-m-d H:i:s'); - $sales2->skidka = $arr["discount"] ?? '0'; - $sales2->delivery_date = date('Y-m-d', strtotime($arr['delivery_date'] ?? '')); - $sales2->pickup = $arr['pickup'] ?? false; - $sales2->marketplace_order_id = $arr["marketplace_order_id"] ?? null; - $sales2->marketplace_name = $arr["marketplace_name"] ?? null; - $sales2->save(); - - // ✅ Проверка результата - if ($sales2->getErrors()) { - LogService::apiErrorLog([ - "error_id" => 21, - "error" => $sales2->getErrors(), - "check_id" => $arr["id"] - ]); - continue; // ← ПРОПУСТИТЬ создание товаров! + + try { + $sales2 = new Sales; + $sales2->phone = $arr["client_phone"] ?? 0; + $sales2->id = $arr["id"]; + $sales2->store_id = $store_id; + $sales2->store_id_1c = $arr["store_id"]; + $sales2->seller_id = $arr["seller_id"]; + $sales2->admin_id = $admin_id; + $sales2->operation = $arr["type"]; + $sales2->number = $arr["number"]; + $sales2->date = $arr["date"]; + $sales2->summ = $arr["summ"]; + $sales2->status = $arr["status"]; + $sales2->sales_check = $arr["sales_check"] ?? ''; + $sales2->payments = json_encode($arr["payments"], JSON_UNESCAPED_UNICODE); + $sales2->pay_arr = implode(",", $pay_arr); + $sales2->order_id = trim($arr["order_id"] ?? ''); + $sales2->terminal = $arr["terminal"] ?? ''; + $sales2->terminal_id = $arr["terminal_id"] ?? ''; + $sales2->date_up = date('Y-m-d H:i:s'); + $sales2->skidka = $arr["discount"] ?? '0'; + $sales2->delivery_date = date('Y-m-d', strtotime($arr['delivery_date'] ?? '')); + $sales2->pickup = $arr['pickup'] ?? false; + $sales2->marketplace_order_id = $arr["marketplace_order_id"] ?? null; + $sales2->marketplace_name = $arr["marketplace_name"] ?? null; + + if (!$sales2->save()) { + LogService::apiErrorLog(json_encode([ + "error_id" => 21, + "error" => "Ошибка валидации Sales", + "validation_errors" => $sales2->getErrors(), + "check_id" => $arr["id"], + "check_number" => $arr["number"] ?? '', + "marketplace" => $arr["marketplace_name"] ?? null, + ], JSON_UNESCAPED_UNICODE)); + continue; + } + } catch (\Exception $e) { + LogService::apiErrorLog(json_encode([ + "error_id" => 21.1, + "error" => "Исключение при сохранении Sales: " . $e->getMessage(), + "check_id" => $arr["id"], + "check_number" => $arr["number"] ?? '', + "marketplace" => $arr["marketplace_name"] ?? null, + "exception_class" => get_class($e), + ], JSON_UNESCAPED_UNICODE)); + Yii::error("Sales save exception для чека {$arr['id']}: " . $e->getMessage()); + continue; } // Обновляем данные в очереди на создание чеков diff --git a/erp24/views/site/index.php b/erp24/views/site/index.php index ddb85190..2e4c02a9 100644 --- a/erp24/views/site/index.php +++ b/erp24/views/site/index.php @@ -53,7 +53,22 @@ $this->title = 'Добро пожаловать в систему!'; ?>
+ +
">
@@ -69,9 +84,6 @@ $this->title = 'Добро пожаловать в систему!';
-