--- /dev/null
+<?php
+
+namespace app\api2\controllers;
+
+
+use app\controllers\BaseController;
+use Exception;
+use Yii;
+use yii\helpers\Json;
+use yii_app\records\ApiCronBuh;
+
+class DataBuhController extends BaseController
+{
+ public function actionRequest() {
+ \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
+
+ $request = \Yii::$app->request->getRawBody();
+
+ try {
+ $result = Json::decode($request);
+ } catch (\Exception $ex) {
+ return $this->asJson(['error' => ['code' => 400, 'message' => 'Json body invalid']]);
+ }
+
+ $result['ver'] = $result['ver'] ?? '';
+
+
+ if (empty($result['ver']) || round($result['ver'], 2) < 1.1) {
+ return $this->asJson(["error_id" => 1, "error" => "minimal version is 1.1"]);
+ }
+
+ $json = '';
+
+ try {
+ $apiCronTest = ApiCronBuh::find()
+ ->where(['status' => 0])
+ ->orderBy(['date' => SORT_ASC])
+ ->one();
+ if ($apiCronTest) {
+ $json = $apiCronTest->json_post;
+
+ $apiCronTest->status = 1;
+ $apiCronTest->date_up = date("Y-m-d H:i:s");
+
+ $validate = $apiCronTest->validate();
+ if ($validate) {
+ $apiCronTest->save();
+ }
+ }
+ } catch (Exception $e) {
+
+ }
+
+ return $this->asJson(json_decode($json, true));
+ }
+
+
+ public function actionUpload() {
+ set_time_limit(600);
+ Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
+
+ $request = Yii::$app->request->getRawBody();
+
+ try {
+ $result = Json::decode($request);
+ } catch (Exception $ex) {
+ return $this->asJson(['error' => ['code' => 400, 'message' => 'Json body invalid']]);
+ }
+
+ $requestId = '';
+ if (!empty($result["request_id"])) {
+ $requestId = $result["request_id"];
+ }
+
+ try {
+
+ $apiCronTest = new ApiCronBuh();
+ $apiCronTest->date = date("Y-m-d H:i:s");
+ $apiCronTest->date_up = date("Y-m-d H:i:s");
+ $apiCronTest->status = 2;
+ $apiCronTest->json_post = $request;
+ $apiCronTest->request_id = $requestId;
+ $validate = $apiCronTest->validate();
+ if ($validate) {
+ $apiCronTest->save();
+ }
+
+ } catch (Exception $e) {
+
+ }
+
+ return $this->asJson(['response' => true]);
+ }
+
+}
\ No newline at end of file
+++ /dev/null
-<?php
-
-namespace app\api2\controllers;
-
-use app\controllers\BaseController;
-use Exception;
-use Yii;
-use yii\helpers\Json;
-use yii_app\records\ApiCronBuhTest;
-
-class DataBuhTestController extends BaseController
-{
- public function actionRequest() {
- \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
-
- $request = \Yii::$app->request->getRawBody();
-
- try {
- $result = Json::decode($request);
- } catch (\Exception $ex) {
- return $this->asJson(['error' => ['code' => 400, 'message' => 'Json body invalid']]);
- }
-
- $result['ver'] = $result['ver'] ?? '';
-
-
- if (empty($result['ver']) || round($result['ver'], 2) < 1.1) {
- return $this->asJson(["error_id" => 1, "error" => "minimal version is 1.1"]);
- }
-
- $json = '';
-
- try {
- $apiCronTest = ApiCronBuhTest::find()
- ->where(['status' => 0])
- ->andWhere(['direct_id' => 1])
- ->orderBy(['date' => SORT_ASC])
- ->one();
- if ($apiCronTest) {
- $json = $apiCronTest->json_post;
-
- $apiCronTest->status = 1;
- $apiCronTest->date_up = date("Y-m-d H:i:s");
-
- $validate = $apiCronTest->validate();
- if ($validate) {
- $apiCronTest->save();
- }
- }
- } catch (Exception $e) {
-
- }
-
- return $this->asJson(json_decode($json, true));
- }
-
-
- public function actionUpload() {
- set_time_limit(600);
- Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
-
- $request = Yii::$app->request->getRawBody();
-
- try {
- $result = Json::decode($request);
- } catch (Exception $ex) {
- return $this->asJson(['error' => ['code' => 400, 'message' => 'Json body invalid']]);
- }
-
- $requestId = '';
- if (!empty($result["request_id"])) {
- $requestId = $result["request_id"];
- }
-
- try {
-
-
- $apiCronTest = new ApiCronBuhTest();
- $apiCronTest->date = date("Y-m-d H:i:s");
- $apiCronTest->date_up = date("Y-m-d H:i:s");
- $apiCronTest->status = 2;
- $apiCronTest->json_post = $request;
- $apiCronTest->request_id = $requestId;
- $apiCronTest->direct_id = 2;
- $validate = $apiCronTest->validate();
- if ($validate) {
- $apiCronTest->save();
- }
-
- } catch (Exception $e) {
-
- }
-
- return $this->asJson(['response' => true]);
- }
-
-}
\ No newline at end of file
--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles the creation of table `{{%api_cron_buh_test}}`.
+ */
+class m240805_071431_create_api_cron_buh_table extends Migration
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $this->createTable('{{%erp24.api_cron_buh}}', [
+ 'id' => $this->primaryKey(),
+ 'date' => $this->dateTime()->notNull(),
+ 'date_up' => $this->dateTime()->notNull(),
+ 'status' => $this->integer()->notNull()->defaultValue(0)->comment('Статус'),
+ 'json_post' => $this->text()->null()->comment('Тело запроса'),
+ 'request_id' => $this->string(36)->notNull()->comment('id запроса'),
+ ]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $this->dropTable('{{%erp24.api_cron_buh}}');
+ }
+}
+++ /dev/null
-<?php
-
-use yii\db\Migration;
-
-/**
- * Handles the creation of table `{{%api_cron_buh_test}}`.
- */
-class m240805_071431_create_api_cron_buh_test_table extends Migration
-{
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $this->createTable('{{%api_cron_buh_test}}', [
- 'id' => $this->primaryKey(),
- 'date' => $this->dateTime()->notNull(),
- 'date_up' => $this->dateTime()->notNull(),
- 'status' => $this->integer()->notNull()->defaultValue(0)->comment('Статус'),
- 'json_post' => $this->text()->null()->comment('Тело запроса'),
- 'request_id' => $this->string(36)->notNull()->comment('id запроса'),
- ]);
- }
-
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- $this->dropTable('{{%api_cron_buh_test}}');
- }
-}
--- /dev/null
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "api_cron_buh_test".
+ *
+ * @property int $id ID
+ * @property string $date
+ * @property string $date_up
+ * @property int $status Статус
+ * @property string|null $json_post Тело запроса
+ * @property string $request_id id запроса
+ */
+class ApiCronBuh extends \yii\db\ActiveRecord
+{
+ /**
+ * {@inheritdoc}
+ */
+ public static function tableName()
+ {
+ return 'api_cron_buh_test';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function rules()
+ {
+ return [
+ [['date', 'date_up', 'request_id'], 'required'],
+ [['date', 'date_up'], 'safe'],
+ [['status'], 'integer'],
+ [['json_post'], 'string'],
+ [['request_id'], 'string', 'max' => 36],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'id' => 'ID',
+ 'date' => 'Date',
+ 'date_up' => 'Date Up',
+ 'status' => 'Status',
+ 'json_post' => 'Json Post',
+ 'request_id' => 'Request ID',
+ ];
+ }
+}
+++ /dev/null
-<?php
-
-namespace yii_app\records;
-
-use Yii;
-
-/**
- * This is the model class for table "api_cron_buh_test".
- *
- * @property int $id ID
- * @property string $date
- * @property string $date_up
- * @property int $status Статус
- * @property string|null $json_post Тело запроса
- * @property string $request_id id запроса
- */
-class ApiCronBuhTest extends \yii\db\ActiveRecord
-{
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'api_cron_buh_test';
- }
-
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['date', 'date_up', 'request_id'], 'required'],
- [['date', 'date_up'], 'safe'],
- [['status'], 'integer'],
- [['json_post'], 'string'],
- [['request_id'], 'string', 'max' => 36],
- ];
- }
-
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'date' => 'Date',
- 'date_up' => 'Date Up',
- 'status' => 'Status',
- 'json_post' => 'Json Post',
- 'request_id' => 'Request ID',
- ];
- }
-}