]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-85 Реализовать обмен данных с 1С Бухгалтерия
authormarina <m.zozirova@gmail.com>
Tue, 13 Aug 2024 07:30:23 +0000 (10:30 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 13 Aug 2024 07:30:23 +0000 (10:30 +0300)
erp24/api2/controllers/DataBuhController.php

index df2ff81a0207b1f760ac48bd529db2417a186031..27525f7b52451748ae6a54a3bfb4d6ff9d7761b5 100644 (file)
@@ -10,6 +10,11 @@ use yii_app\records\ApiCronBuh;
 
 class DataBuhController extends BaseController
 {
+    const OUT_DIR =
+//        __DIR__ . "/../json";
+        "/var/www/erp24/api2/json";
+//          "/var/www/www-root/data/www/api.bazacvetov24.ru/data/json";
+
     public function actionRequest() {
         \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
 
@@ -58,7 +63,6 @@ class DataBuhController extends BaseController
     public function actionUpload() {
         set_time_limit(600);
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
-
         $request = Yii::$app->request->getRawBody();
 
         try {
@@ -67,6 +71,16 @@ class DataBuhController extends BaseController
             return $this->asJson(['error' => ['code' => 400, 'message' => 'Json body invalid']]);
         }
 
+        $result['ver'] = $result['ver'] ?? '';
+
+        file_put_contents(self::OUT_DIR . '/a1_request_buh.json', PHP_EOL . date('Y-m-d H:i:s') . ' ' . $result["ver"], FILE_APPEND | LOCK_EX);
+
+        if (empty($result['ver']) || round($result['ver'], 2) < 1.1) {
+            file_put_contents(self::OUT_DIR . '/request_exit_buh.json', PHP_EOL . $result["ver"], FILE_APPEND | LOCK_EX);
+
+            return $this->asJson(["error_id" => 1, "error" => "minimal version is 1.1"]);
+        }
+
         $requestId = '';
         if (!empty($result["request_id"])) {
             $requestId = $result["request_id"];