select(); foreach ($datas as $data) { $item = []; $watch = Redis::get('CRM:USER:ONLINE:WATCH:'.$data->id); if (empty($data->start_work_time)){ $item['start_work_time'] = $nowTime; } if (($nowTime - $watch) > 0 && ($nowTime - $watch) <= 6*60){ $item['end_work_time'] = $nowTime; } Log::warning('watchIsWork',['data'=>$item]); if (!empty($item)){ try { Admins::where('id', $data->id)->update($item); } catch (DbException $e) { Log::error('watchIsWork',['error'=>$e]); continue; } } } echo "========watchIsWork end======\n"; return; } }