]> gitweb.erp-flowers.ru Git - yii-erp24/.git/commitdiff
add cron/1c-check-1day during moving api1 to yii
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 28 Dec 2023 08:52:00 +0000 (11:52 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 28 Dec 2023 08:52:00 +0000 (11:52 +0300)
erp24/api1/actions/cron/OneCCheckOneDayAction.php [new file with mode: 0644]
erp24/api1/controllers/CronController.php

diff --git a/erp24/api1/actions/cron/OneCCheckOneDayAction.php b/erp24/api1/actions/cron/OneCCheckOneDayAction.php
new file mode 100644 (file)
index 0000000..545428c
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace app\actions\cron;
+
+use Yii;
+use yii\base\Action;
+use yii\db\Expression;
+
+class OneCCheckOneDayAction extends Action
+{
+    public function run() {
+
+        include_once(dirname(__DIR__, 3) . "/startup.php");
+        include_once(dirname(__DIR__, 3) . "/inc/db.php");
+
+        // api.bazacvetov24.ru/cron/1c.php?token_cloud=iC04295J9HyD2H3GJF3btky
+        if($_GET["token_cloud"]!="iC04295J9HyD2H3GJF3btky") exit();
+
+        $req_id=time();
+        $json_post='{"request_id": "'.$req_id.'" ,"checks":{"start_time":"'.date("Y-m-d",time()-86400).' 00:00:00","end_time":"'.date("Y-m-d H:i:s",time()).'"}}';
+
+        Yii::$app->db->createCommand()->insert('api_cron', [
+            'id' => 0,
+            'date' => new Expression('NOW()'),
+            'date_up' => new Expression('NOW()'),
+            'status' => 0,
+            'json_post' => $json_post,
+            'request_id' => $req_id
+        ])->execute();
+
+        return $this->controller->asJson(['response' => $req_id]);
+    }
+}
\ No newline at end of file
index 09880cc79bb65e0b3d246df47102a9af13990f5c..e1ecd4f3d0f3b52a0d8dce04f841c2f05913e948 100644 (file)
@@ -19,6 +19,7 @@ class CronController extends BaseController
             'export-catalog' => \app\actions\cron\ExportCatalogAction::class,
             'cloudpayments-region' => \app\actions\cron\CloudpaymentsRegionAction::class,
             'bonus-users-sale-update' => \app\actions\cron\BonusUsersSaleUpdateAction::class,
+            '1c-check-1day' => \app\actions\cron\OneCCheckOneDayAction::class,
         ];
     }
 }