params = $params; } /** * 遍历所有上级的每个对象的字段child_uids,重新更新child_uids内容. * * @return mixed|void */ public function handle() { $currUid = $this->params['uid']; $agentModel = new AgentModel(); $item = AgentModel::query()->where(['uid' => $currUid])->first(['id', 'uid', 'parent_uid', 'parent_uids']); $strParentUids = $item->parent_uids; $arrParentUids = !empty($strParentUids) ? explode(',', $strParentUids) : []; if (!empty($arrParentUids)) { foreach ($arrParentUids as $parentUid) { $tmpObj = AgentModel::query()->where(['uid' => $parentUid])->first(['id', 'uid', 'child_uids']); $arrChildUids = $agentModel->findAllChildUids($parentUid); $strChildUids = !empty($arrChildUids) ? implode(',', $arrChildUids) : ''; $tmpObj->child_uids = $strChildUids; $tmpObj->save(); } } } /** * 任务失败的处理过程. * @param null $exception */ public function fail($exception = null) { // 失败后的处理,比如发送通知. } /** * 通知. */ private function notify() { // Todo 发送通知. } }