use yii_app\records\Admin;
use yii_app\records\AdminGroup;
use yii_app\records\AdminPayroll;
+use yii_app\records\ApiCron;
use yii_app\records\Autoplannogramma;
use yii_app\records\BonusLevels;
use yii_app\records\CityStore;
public function actionOneC()
{
$req_id = time();
- $json_post = '{"request_id": "' . $req_id . '" ,"incomings":{"start_time":"' . date("Y-m-d", time() - 86400) . ' 00:00:00","end_time":"' . date("Y-m-d", time()) . ' 23:59:59"},"checks":{"start_time":"' . date("Y-m-d", time() - 24400) . ' 00:00:00","end_time":"' . date("Y-m-d", time()) . ' 23:59:59"},
-"write_offs":{"start_time":"' . date("Y-m-d", time() - 86400 * 7) . ' 00:00:00","end_time":"' . date("Y-m-d", time()) . ' 23:59:59"}}';
+ $jsonString = '", "incomings":{"start_time":"' . date("Y-m-d", time() - 86400) . ' 00:00:00","end_time":"' . date("Y-m-d", time()) . ' 23:59:59"},';
+ $jsonString .= ' "checks":{"start_time":"' . date("Y-m-d", time() - 24400) . ' 00:00:00","end_time":"' . date("Y-m-d", time()) . ' 23:59:59"},';
+ $jsonString .= ' "write_offs":{"start_time":"' . date("Y-m-d", time() - 86400 * 7) . ' 00:00:00","end_time":"' . date("Y-m-d", time()) . ' 23:59:59"}}';
- $this->setApiCron($req_id, $json_post);
+ if(!CronController::checkApiCronTask($jsonString)) {
+ $json_post = '{"request_id": "' . $req_id . $jsonString;
+ $this->setApiCron($req_id, $json_post);
+ }
return 'ok';
}
public function actionOneCSellers()
{
$req_id = time();
- $json_post = '{"request_id": "' . $req_id . '","nomenclature":true,"sellers":true, "balances":true, "payment_types":true}';
+ $jsonString = '", "nomenclature":true, "sellers":true, "balances":true, "payment_types":true}';
- $this->setApiCron($req_id, $json_post);
+ if(!CronController::checkApiCronTask($jsonString)) {
+ $json_post = '{"request_id": "' . $req_id . $jsonString;
+ $this->setApiCron($req_id, $json_post);
+ }
return 'ok';
}
public function actionOneCPrice()
{
$req_id = time();
- $json_post = '{"request_id": "' . $req_id . '","nomenclature":true,"sellers":true, "prices":{"type_price":"Розничная Маг на Московск"}, "balances":true, "payment_types":true}';
+ $jsonString = '", "nomenclature":true, "sellers":true, "prices":{"type_price":"Розничная Маг на Московск"}, "balances":true, "payment_types":true}';
- $this->setApiCron($req_id, $json_post);
+ if (!CronController::checkApiCronTask($jsonString)) {
+ $json_post = '{"request_id": "' . $req_id . $jsonString;
+ $this->setApiCron($req_id, $json_post);
+ }
return 'ok';
}
public function actionOneCBalances()
{
$req_id = time();
- $json_post = '{"request_id": "' . $req_id . '","balances":true}';
+ $jsonString = '", "balances":true}';
- $this->setApiCron($req_id, $json_post);
+ if (!CronController::checkApiCronTask($jsonString)) {
+ $json_post = '{"request_id": "' . $req_id . $jsonString;
+ $this->setApiCron($req_id, $json_post);
+ }
return 'ok';
}
public function actionMarketplaceOrdersOneCCron()
{
$req_id = time();
+ $jsonString = '"marketplace_orders":{"start_time":"' . date("Y-m-d", time() - 86400 * 2) . ' 00:00:00","end_time":"' . date("Y-m-d", time()) . ' 23:59:59"}';
- //заказы за 2 дня назад прогружаем
- $json_post = '{"request_id": "' . $req_id . '", "marketplace_orders":{"start_time":"' . date("Y-m-d", time() - 86400 * 2) . ' 00:00:00","end_time":"' . date("Y-m-d", time()) . ' 23:59:59"}}';
-
- $this->setApiCron($req_id, $json_post);
+ if (!CronController::checkApiCronTask($jsonString)) {
+ //заказы за 2 дня назад прогружаем
+ $json_post = '{"request_id": "' . $req_id . '", ' . $jsonString . '}';
+ $this->setApiCron($req_id, $json_post);
+ }
return 'ok';
}
public function actionOneCCronAnalysts()
{
$req_id = time();
+ $jsonString = '", "analysts_business_operations": true}';
- //Аналитика хозяйственных операций
- $json_post = '{"request_id": "' . $req_id . '", "analysts_business_operations": true}';
-
- $this->setApiCron($req_id, $json_post);
+ if (!CronController::checkApiCronTask($jsonString)) {
+ //Аналитика хозяйственных операций
+ $json_post = '{"request_id": "' . $req_id . $jsonString;
+ $this->setApiCron($req_id, $json_post);
+ }
return 'ok';
}
return $today < $target;
}
+ public static function checkApiCronTask(string $jsonString) {
+ $apiCron = ApiCron::find()
+ ->where(['status' => 0])
+ ->andWhere(['ilike', 'json_post', $jsonString])
+ ->orderBy(['date' => SORT_ASC])
+ ->exists();
+
+ return $apiCron;
+ }
+
}