2025-03-22 10:26:52 +08:00
|
|
|
<?php
|
|
|
|
|
|
2025-03-22 18:30:38 +08:00
|
|
|
namespace app\process;
|
2025-03-22 10:26:52 +08:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2025-03-22 18:30:38 +08:00
|
|
|
|
2025-03-22 10:26:52 +08:00
|
|
|
public function onWorkerStart()
|
|
|
|
|
{
|
|
|
|
|
// 每半小时执行一次
|
2025-03-22 18:30:38 +08:00
|
|
|
new Crontab('1/* * * * * *', function () {
|
2025-03-22 10:26:52 +08:00
|
|
|
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;
|
2025-03-22 18:30:38 +08:00
|
|
|
$item->warn = 1;
|
|
|
|
|
$item->update();
|
2025-03-22 10:26:52 +08:00
|
|
|
FeishuController::class->send($feishuUser->open_id, '跟进提醒', '您有新的跟进提醒', $url);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|