$matrixProductsIds = SalaryHelper::getMatrixProductsIds();
}
+ if (!empty($result['checks'])) {
+ foreach ($result["checks"] as $index => $arr) {
+ if (!isset($arr["marketplace_order_id"])) {
+ continue;
+ }
+ $marketplaceOrder = MarketplaceOrders::findOne(['guid' => $arr["marketplace_order_id"]]);
+ if (!empty($arr['error'])) {
+ $txt = date("d.m.Y H:i:s", time()) . " $index СОЗДАНИЕ ЧЕКА ОШИБКА id=" . $arr["id"] . " " . $arr["error"];
+ file_put_contents(self::OUT_DIR . '/log_check_error.txt', PHP_EOL . $txt, FILE_APPEND);
+ $marketplaceOrder->error_text = "ОШИБКА ЧЕКА" . $arr["id"] . "для заказа id=" . $marketplaceOrder->marketplace_order_id . " " . $arr["error"];
+ $marketplaceOrder->save();
+ if ($marketplaceOrder->getErrors()) {
+ Yii::error('Ошибка сохранения ошибки заказа ' . json_encode($marketplaceOrder->getErrors(), JSON_UNESCAPED_UNICODE));
+ LogService::apiErrorLog(json_encode(["error_id" => 17.2, "error" => $marketplaceOrder->getErrors()], JSON_UNESCAPED_UNICODE));
+ }
+ continue;
+ }
+ $check = CreateChecks::find()
+ ->where(['id' => $arr["check_id"]])
+ ->andWhere(['order_guid' => $arr["marketplace_order_id"]])
+ ->andWhere(['status' => 0])->one();
+ if(!$check) {
+ continue;
+ }
+ $check->status = 1;
+ $check->name = $arr["number"] . " от " . $arr["date"];
+ $check->guid = $arr["id"];
+ $check->date_up = date('Y-m-d H:i:s');
+ $check->held = 1;
+ $check->save();
+ if ($check->getErrors()) {
+ Yii::error('Ошибка обновления чека ' . json_encode($check->getErrors(), JSON_UNESCAPED_UNICODE));
+ LogService::apiErrorLog(json_encode(["error_id" => 17.3, "error" => $check->getErrors()], JSON_UNESCAPED_UNICODE));
+ }
+ }
+ }
+
if (!empty($result['checks']) && count($result['checks']) < 1000) {
foreach ($result["checks"] as $arr) {