From: fomichev Date: Thu, 26 Dec 2024 07:18:13 +0000 (+0300) Subject: Удаление существующих записей X-Git-Tag: 1.7~94^2~34 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=a28d2a06d4254af19cea7867b468f1e8ba01ef28;p=erp24_rep%2Fyii-erp24%2F.git Удаление существующих записей --- diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index 20831862..cd174d5f 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -265,7 +265,7 @@ class CronController extends Controller $dateToProcess = date('Y-m-d', strtotime("-$i days", strtotime($currentDate))); $startDate = date('Y-m-d', strtotime("+$step2 days", strtotime($dateToProcess))); - if ( + /* if ( SentKogort::find() ->where(['kogort_date' => $startDate, 'kogort_number' => SentKogort::KOGORT_NUMBERS['whatsapp']]) ->exists() @@ -275,7 +275,7 @@ class CronController extends Controller BaseConsole::FG_YELLOW ); continue; - } + }*/ $kogortPhones = Users::formKogortByDateAndType($startDate, 'whatsapp'); @@ -316,7 +316,7 @@ class CronController extends Controller $dateToProcess = date('Y-m-d', strtotime("-$i days", strtotime($currentDate))); $startDate = date('Y-m-d', strtotime("+$step3 days", strtotime($dateToProcess))); - if ( + /*if ( SentKogort::find() ->where(['kogort_date' => $startDate, 'kogort_number' => SentKogort::KOGORT_NUMBERS['call']]) ->exists() @@ -326,7 +326,7 @@ class CronController extends Controller BaseConsole::FG_YELLOW ); continue; - } + }*/ $kogortPhones = Users::formKogortByDateAndType($startDate, 'call'); diff --git a/erp24/records/Users.php b/erp24/records/Users.php index 9f9860c1..b0096fb1 100755 --- a/erp24/records/Users.php +++ b/erp24/records/Users.php @@ -571,6 +571,11 @@ class Users extends \yii\db\ActiveRecord ->where(['kogort_date' => $startDate, 'kogort_number' => $kogort_number]) ->column(); + if ($kogortPhones) { + SentKogort::deleteAll(['kogort_date' => $startDate, 'kogort_number' => $kogort_number]); + $kogortPhones =[]; + } + foreach ($phones as $phone) { if ($phone && !in_array($phone, $kogortPhones)) { $sentKogort = new SentKogort();