*/
class CreateChecks extends \yii\db\ActiveRecord
{
+ const STATUS_CHECK_CREATED_ERP = 0;
+ const STATUS_CHECK_CREATED_1C = 1;
+ const STATUS_CHECK_ERROR_1C = 8;
/**
* {@inheritdoc}
*/
->select(['id'])
->where(['articule' => $item->offer_id])
->one();
-
- $items[] = [
- 'product_id' => $productsId->id ?? '',
- 'quantity' => $item->count,
- 'price' => $item->price,
- 'seller_id' => $marketplaceOrder->seller_id,
- 'marketplace_order_id' => $marketplaceOrder->marketplace_order_id,
- ];
+ if ($productsId && $productsId->id) {
+ $items[] = [
+ 'product_id' => $productsId->id,
+ 'quantity' => $item->count,
+ 'price' => $item->price,
+ 'seller_id' => $marketplaceOrder->seller_id,
+ 'marketplace_order_id' => $marketplaceOrder->marketplace_order_id,
+ ];
+ }
}
$createChecks->items = Json::encode($items);
// } catch (Exception $e) {
// file_put_contents(self::OUT_DIR . '/log_created_check_error.txt', PHP_EOL . date("d.m.Y H:i:s",time()). $e->getMessage(), FILE_APPEND);
// }
-
+ CreateChecks::updateAll([
+ 'status' => CreateChecks::STATUS_CHECK_ERROR_1C,
+ 'guid' => $arr2["id"],
+ 'date_up' => date('Y-m-d H:i:s'),
+ ], ['check_id' => $arr2["id"]]);
+ LogService::apiErrorLog(json_encode(["error_id" => 31, "error" => 'ОШИБКА В 1С - СОЗДАНИЕ ЧЕКА ЗАКАЗА id=' . $arr2["id"]], JSON_UNESCAPED_UNICODE));
$txt = date("d.m.Y H:i:s", time()) . " $idp СОЗДАНИЕ ЧЕКА ОШИБКА id=" . $arr2["id"] . " " . $arr2["error"];
file_put_contents(self::OUT_DIR . '/log_created_check_error.txt', PHP_EOL . $txt, FILE_APPEND);
} else { // Если ошибок нет
// }
// Обновляем данные в очереди на создание чеков
CreateChecks::updateAll([
- 'status' => 1,
+ 'status' => CreateChecks::STATUS_CHECK_CREATED_1C,
'guid' => $arr2["id"],
'date_up' => date('Y-m-d H:i:s'),
'name' => $arr2["name"],
use kartik\grid\GridView;
use yii\web\YiiAsset;
+use yii_app\records\CreateChecks;
use yii_app\records\MarketplaceOrders;
use yii\helpers\Html;
use yii\helpers\Url;
}
$check = $model->check;
- if ($check->status == 0) {
+ if ($check->status == CreateChecks::STATUS_CHECK_CREATED_ERP) {
return 'Создан в ERP';
}
- if ($check->status == 1) {
- return $check->name
- ? 'Создан в 1С'
- : 'Отправлен в 1С';
+ if ($check->status == CreateChecks::STATUS_CHECK_CREATED_1C) {
+ return 'Создан в 1С';
+ }
+
+ if ($check->status == CreateChecks::STATUS_CHECK_ERROR_1C) {
+ return 'Ошибка создания в 1С';
}
return '-';