chenx преди 2 години
родител
ревизия
ee3b0a4b8a
променени са 1 файла, в които са добавени 28 реда и са изтрити 9 реда
  1. 28
    9
      application/crontab/controller/Crontab.php

+ 28
- 9
application/crontab/controller/Crontab.php Целия файл

@@ -7,15 +7,34 @@ class Crontab

public static function task()
{
$Zd_model = new \app\admin\model\Zd();
$day = $Zd_model->where('name', 'waters')->value('info');
$day = (int)$day;
if (!empty($day)) {
//查询数据库
$Customer_model = new \app\admin\model\Customer();
//跟进时间大于公海设置时间
$result = $Customer_model->where('is_starmark', 0)->where('( ' . $_SERVER['REQUEST_TIME'] . ' - followup_time) / ')->field('followup_time')->select();

try {
$Zd_model = new \app\admin\model\Zd();
$day = $Zd_model->where('name', 'waters')->value('info');
$day = (int)$day;
if (!empty($day)) {
//查询数据库
$Customer_model = new \app\admin\model\Customer();
//跟进时间大于公海设置时间
$result = $Customer_model->where('is_starmark', 0)->whereBetween('followup_setting', [strtotime('2020-01-01'), strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')))])->field('followup_setting,id')->select();//->where('(( ' . $_SERVER['REQUEST_TIME'] . ' - followup_time) / 86400)')
$now = strtotime(date('Y-m-d'));
$Customer_model->startTrans();
foreach ($result as $k => $v) {
$followup_setting = $now - $v['followup_setting'];
$followup_setting = $followup_setting / 86400;
if ($followup_setting >= $day) {
$Customer_model->where('id', $v['id'])->update(['status' => -1]);
}
}
$Customer_model->commit();
}
} catch (\Exception $e) {
if (isset($Customer_model)) {
$Customer_model->rollback();
}
} catch (\Throwable $e) {
if (isset($Customer_model)) {
$Customer_model->rollback();
}
}
}


Loading…
Отказ
Запис