/** * 关注用户与取消用户关注 * @param [user_id] [要搜索的标签索引值] * @param [key] [要搜索的标签索引值] */ public function eye() { parent::require_login(); $params = parent::get_params('POST', array('user_id', 'type')); extract($params); if ($this->me['id'] == $user_id) { parent::finish(false, "您无法关注自己!"); } if (!$this->user_model->is_exist(array("id" => $user_id))) { parent::finish(false, "您尝试着关注不存的用户,所以您无法关注他"); } $target_user = $this->user_model->get(array("id" => $user_id)); if ($type == 'true') { ModelFactory::User()->Integral($this->me['id'], CONSTFILE::USER_ACTION_USER_WATCH_INTEGRAL_VALUE, true, 'Integral', CONSTFILE::CHANGE_LOG_COUNT_TYPE_CLICK_USER_WATCH); ModelFactory::User()->coin($this->me['id'], CONSTFILE::USER_ACTION_USER_WATCH_SILVER_VALUE, true, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_CLICK_USER_WATCH); $follow_users = parent::add_json($this->me['follow_users'], $user_id); } else { ModelFactory::User()->coin($this->me['id'], CONSTFILE::USER_ACTION_USER_WATCH_SILVER_VALUE, false, 'silver_coin', CONSTFILE::CHANGE_LOG_COUNT_TYPE_CLICK_USER_WATCH); ModelFactory::User()->Integral($this->me['id'], CONSTFILE::USER_ACTION_USER_WATCH_INTEGRAL_VALUE, false, 'Integral', CONSTFILE::CHANGE_LOG_COUNT_TYPE_CLICK_USER_WATCH); $follow_users = parent::remove_json_v($this->me['follow_users'], $user_id); } if (!$this->user_model->edit($this->me['id'], array("follow_users" => $follow_users))) { parent::finish(false, "服务器异常!"); } if ($type == 'false') { $this->user_model->edit($user_id, array("follower_count" => $target_user['follower_count'] - 1)); } else { $this->user_model->edit($user_id, array("follower_count" => $target_user['follower_count'] + 1)); $this->news_model->create(array('target' => $user_id, 'from_id' => $this->me['id'], 'type' => '500')); } parent::finish(true); }