0) { $timeRemindin = $timeStart - $remindin; if ($timeRemindin <= Base::time() && Base::time() <= $timeStart) { // 签到打卡提醒 $this->remind('in'); } } if ($remindexceed > 0) { $timeRemindexceed = $timeStart + $remindexceed; if ($timeRemindexceed <= Base::time() && Base::time() <= $timeRemindexceed + 300) { // 签到缺卡提醒 $this->remind('exceed'); } } } public function end() { } private function remind($type) { if (Cache::get("CheckinRemindTask:remind-" . $type) == date("Ymd")) { return; } Cache::put("CheckinRemindTask:remind-" . $type, date("Ymd"), Carbon::now()->addDay()); // $botUser = User::botGetOrCreate('check-in'); if (!$botUser) { return; } // 提醒对象:在职且3天内有签到过的成员 User::whereNull('disable_at')->chunk(100, function ($users) use ($type, $botUser) { /** @var User $user */ foreach ($users as $user) { if (UserCheckinRecord::whereUserid($user->userid)->whereDate(date("Y-m-d"))->exists()) { continue; // 已打卡 } if (!UserCheckinRecord::whereUserid($user->userid)->where('created_at', '>', Carbon::now()->subDays(3))->exists()) { continue; // 3天内没有打卡 } $dialog = WebSocketDialog::checkUserDialog($botUser, $user->userid); if ($dialog) { if ($type === 'exceed') { $text = "
缺卡提醒:上班时间到了,你还没有打卡哦~
"; } else { $text = "打卡提醒:快到上班时间了,别忘了打卡哦~
"; } WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid); } } }); } }