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; // $item->warn = 1; // $item->update(); // $user = User::first()->where('id', $item->user_id); // Log::info('send',['open_id'=>$item['open_id'],'url'=>$url]); // // FeishuController::send('xinyouhe','ou_e33bb3017ada6c4781398a68e55a4696', '跟进提醒', '您有新的跟进提醒', $url); // FeishuController::send($user->sign,$feishuUser->open_id, '跟进提醒', '您有新的跟进提醒', $url); // } // } $where = [ ['follow_next', '<=', time() + 3600], ['follow_next', '>', time()], ['warn', '<', 1] ]; $customer = Customer::where($where)->get(); foreach ($customer as $item) { $feishuUser = FeishuUser::where(['user_id' => $item->user_id])->first(); if ($feishuUser) { // 获取凭证 $certificate = config('feishu.'.$feishuUser->sign); // 使用parse_url解析URL $parsedUrl = parse_url($certificate['rUrl']); // 获取域名和端口 $host = $parsedUrl['host']; $port = isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : ''; $url = 'http://'. $host .$port. '/pages/customer/detile?id='.$item->id; $item->warn = 1; $item->update(); Log::info('send',['open_id'=>$item['open_id'],'url'=>$url]); FeishuController::send($feishuUser->sign, $feishuUser->open_id, '跟进提醒', '您有新的跟进提醒', $url); } } Log::info('send follow start',[time()]); }); // 每小时执行一次 new Crontab('0 10 * * * *', function(){ echo date('Y-m-d H:i:s') . "\n"; Log::info('send high seas start',[time()]); $where = [ ['deleted_at', '<=', time() - 3600], ['user_id', '<>', 0], ]; $customer = Customer::where($where)->onlyTrashed()->get(); foreach ($customer as $item) { $item->update(['user_id' => 0]); CustomerHis::create([ 'customer_id' => $item->_id, 'user_his' => $item->user_id, 'user_id' => 0, ]); } Log::info('send high seas start',[time()]); }); } }