Files
fdesk/app/process/Task.php
T

41 lines
1.0 KiB
PHP

<?php
namespace app\process;
use app\crm\model\Customer;
use support\Log;
use Workerman\Crontab\Crontab;
class Task
{
public function onWorkerStart()
{
// 每半小时执行一次
new Crontab('0 */30 * * * *', function(){
echo date('Y-m-d H:i:s') . "\n";
Log::info('send follow start',[time()]);
$where = [
['follow_next', '<=', time() + 3600],
['follow_next', '>', time()],
['warn', '<', 1]
];
$customer = Customer::where($where)->get();
foreach ($customer as $item) {
$res =[
'id'=>$item->id,
'category'=>'crm',
'scene'=>'crm-person-follow-up',
'receive type'=>'person'
];
\Webman\RedisQueue\Redis::send("feishu-message",$res);
$item->warn = 1;
$item->save();
}
Log::info('send follow start',[time()]);
});
}
}