//InfoLogService::setInfoLog(__FILE__, __LINE__, 'upload_' . $fl . '.json' , 'info_id_25_1');
file_put_contents(self::OUT_DIR . '/upload_' . $fl . '.json', PHP_EOL . $request);
- LogService::apiErrorLog(json_encode(["error_id" => 145, "error" => $result["request_id"]], JSON_UNESCAPED_UNICODE));
+
try {
if (!empty($result['error'])) {
$requestId = DataHelper::getRequestId();
}
$type_price = "Розничная цена";
- LogService::apiErrorLog(json_encode(["error_id" => 145, "error" => $requestId], JSON_UNESCAPED_UNICODE));
+
if (!empty($requestId)) {
$apiCron = ApiCron::find()->select(['json_post'])->where(['request_id' => $requestId])->one();
if ($apiCron) {
$jsn = json_decode($apiCron->json_post, true, 512, JSON_UNESCAPED_UNICODE);
- $start_time = $jsn["checks"]["start_time"] ?? date('Y-m-d 00:00:00', time() - 3 * 86400);
- LogService::apiErrorLog(json_encode(["error_id" => 144, "error" => $start_time], JSON_UNESCAPED_UNICODE));
- $end_time = $jsn["checks"]["end_time"] ?? date('Y-m-d 00:00:00', time());
- LogService::apiErrorLog(json_encode(["error_id" => 144, "error" => $end_time], JSON_UNESCAPED_UNICODE));
+ $start_time = $jsn["checks"]["start_time"] ?? date('Y-m-d 00:00:00', time() - 3 * 86400);
+ $end_time = $jsn["checks"]["end_time"] ?? date('Y-m-d 00:00:00', time());
$checks_dell = $jsn["checks_dell"] ?? "";
$type_price = $jsn["prices"]["type_price"] ?? "Розничная цена";
}
if (!empty($result['checks']) && count($result['checks']) < 1000) {
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
foreach ($result["checks"] as $arr) {
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
$check_id = $arr["id"];
if ($arr["seller_id"] == '00000000-0000-0000-0000-000000000000') {
$arr["seller_id"] = "NULL";
}
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
$pay_arr = self::getPayArr($arr["payments"]);
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
$store_id = ClientHelper::getExportId($arr["store_id"], "city_store", 1);
// $admin_id = ClientHelper::getExportId($arr["seller_id"], "admin", 1);
$exportImportTable = ExportImportTable::find()->select(['entity_id'])->where(['entity' => 'admin'])
$exportImportTableIds = ArrayHelper::getColumn($exportImportTable, 'entity_id');
$admin = Admin::find()->where(['in', 'id', $exportImportTableIds])->andWhere(['>', 'group_id', 0])->one();
$admin_id = $admin->id ?? 0;
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
//удаляем чеки и товары в чеках
$saleUpdate = SalesUpdate::find()->where(['id' => $arr["id"]])->one();
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
if ($saleUpdate) {
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
$saleUpdate->delete();
}
// SalesProductsUpdate::deleteAll(['check_id' => $arr["id"]]);
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
- LogService::apiErrorLog(json_encode(["error_id" => 125, "error" => $update], JSON_UNESCAPED_UNICODE));
+
+
if ($update) {
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
$sales = Sales::find()->where(['id' => $arr["id"]])->one();
if ($sales) {
$sales->delete();
SalesItems::deleteAll(['check_id' => $arr["id"]]);
SalesProducts::deleteAll(['check_id' => $arr["id"]]);
}
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
// проверяем стутс чека - вносим только Архивные и пробитые
// if (!empty($arr["status"])) {
// $salesUpdate = new SalesUpdate;
// }
// }
// }
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
if ($update) {
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
$sales2 = new Sales;
$sales2->phone = $arr["client_phone"] ?? 0;
$sales2->id = $arr["id"];
$sales2->delivery_date = date('Y-m-d', strtotime($arr['delivery_date'] ?? ''));
$sales2->pickup = $arr['pickup'] ?? false;
$sales2->save();
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
if ($sales2->getErrors()) {
LogService::apiErrorLog(json_encode(["error_id" => 21, "error" => $sales2->getErrors()], JSON_UNESCAPED_UNICODE));
}
}
}
}
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
} elseif (!empty($result['checks'])) {
- LogService::apiErrorLog(json_encode(["error_id" => 121, "error" => __LINE__], JSON_UNESCAPED_UNICODE));
+
file_put_contents(self::OUT_DIR . '/error_upload.txt',
PHP_EOL . "elseif", FILE_APPEND);
$dataArrayValues = self::getSalesDate($result["checks"], $update);