Files
crm-server/app/process/Task.php
T

41 lines
1.4 KiB
PHP
Raw Normal View History

2025-03-22 10:26:52 +08:00
<?php
namespace process;
use app\controller\FeishuController;
use app\model\Customer;
use app\model\FeishuUser;
use app\model\User;
use Webman\App;
use Workerman\Crontab\Crontab;
class Task
{
public function onWorkerStart()
{
// 每半小时执行一次
new Crontab('30/* * * * *', function () {
echo date('Y-m-d H:i:s') . "\n";
$customer = Customer::where(['follow_next', '<=', time() + 3600])
->where(['follow_next', '>', time()])
->where(['warn', '<', 1])
->get();
foreach ($customer as $item) {
$feishuUser = FeishuUser::where(['user_id' => $item->user_id])->first();
if ($feishuUser) {
// 获取凭证
$certificate = config($this->config);
// 使用parse_url解析URL
$parsedUrl = parse_url($certificate['rUrl']);
// 获取域名和端口
$host = $parsedUrl['host'];
$port = isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : '';
$url = $host .$port. '/pages/customer/detile?id='.$customer->id;
FeishuController::class->send($feishuUser->open_id, '跟进提醒', '您有新的跟进提醒', $url);
}
}
});
}
}