getSettings('wechat.oa'); if ($wechatOA['enabled'] == 0) return; $params = $task->item_info; $userId = $task->item_info['user']['id']; $subscribeRepo = new WeChatSubscribeRepo(); $subscribe = $subscribeRepo->findByUserId($userId); if ($subscribe && $subscribe->deleted == 0) { $notice = new WeChatAccountLoginNotice(); return $notice->handle($subscribe, $params); } } public function createTask(UserModel $user) { $wechatOA = $this->getSettings('wechat.oa'); if ($wechatOA['enabled'] == 0) return; $task = new TaskModel(); $loginIp = $this->getClientIp(); $loginRegion = kg_ip2region($loginIp); $itemInfo = [ 'user' => [ 'id' => $user->id, 'name' => $user->name, ], 'login_ip' => $loginIp, 'login_region' => $loginRegion, 'login_time' => time(), ]; $task->item_id = $user->id; $task->item_info = $itemInfo; $task->item_type = TaskModel::TYPE_NOTICE_ACCOUNT_LOGIN; $task->priority = TaskModel::PRIORITY_LOW; $task->status = TaskModel::STATUS_PENDING; $task->max_try_count = 1; $task->create(); } public function wechatNoticeEnabled() { $oa = $this->getSettings('wechat.oa'); if ($oa['enabled'] == 0) return false; $template = json_decode($oa['notice_template'], true); return $template['account_login']['enabled'] == 1; } }