public function run() { if (false == $this->verifyUserAuth()) { return false; } $user_id = intval($this->getDataItem('user_id', 0)); $to_user_id = intval($this->getDataItem('to_user_id', 0)); $type = intval($this->getDataItem('type', 0)); if ($user_id == 0 || $to_user_id == 0 || $type == 0) { $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, 'URL参数不全'); return false; } if (!in_array($type, ['1', '2'])) { $this->errorLog(ResultStatus::POST_BODY_FORMAT_ERROR, 'type类型错误!'); return false; } $UserFollow = new UserFollow(); if ($UserFollow->is_follow($user_id, $to_user_id, $type)) { $this->setResult(['success' => 3, 'message' => '已经关注过了']); } else { // 未关注 if ($UserFollow->follow($user_id, $to_user_id, $type)) { if ($type == 2) { // 增加专家的粉丝数 (new \Apps\Common\Models\UserBase())->setExpertFollowCount($to_user_id, 1, true); } $this->setResult(['success' => 1, 'message' => '关注成功']); } else { $this->setResult(['success' => 2, 'message' => '关注失败']); } } }
public function run() { /*if(false == $this->verifyUserAuth()){ return false; }*/ $user_id = intval($this->getDataItem('user_id', 0)); $type = intval($this->getDataItem('type', 1)); // 关注类型(1=》专家,2=》美人儿(普通用户),3=》美容院) $page = intval($this->getDataItem('page', 1)); if ($user_id == 0) { return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, 'URL参数不全'); } if (!in_array($type, ['1', '2', '3'])) { return $this->errorLog(ResultStatus::POST_BODY_FORMAT_ERROR, 'type类型错误!'); } $limit = $this->getConfig()->limit; $offset = ($page - 1) * $limit; $UserFollow = new UserFollow(); if ($type == 3) { // 美容院(待加入) $this->setResult($this->getFavorites($user_id, $offset, $limit)); } elseif ($type == 2) { // 美人儿(普通用户) $this->setResult($UserFollow->getFollowList($user_id, $offset, $limit)); } else { // 专家 $this->setResult($UserFollow->getFollowExpertList($user_id, $offset, $limit)); } }
public function run() { $to_user_id = $this->getDataItem('user_id'); if (!(is_numeric($to_user_id) && $to_user_id > 0)) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '用户id不能为空.'); } /** * 验证用户权限 */ /*if(!empty($this->parameters->userToken) && $this->verifyUserAuth() && $this->getUserAuth()->userId == $userid){ return $this->errorLog(111, '请跳转我的问答.'); }*/ $field = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'bind_phone user_mobile', 'persional_sign', 'user_expert']; $info = UserBase::query()->columns($field)->where('user_id=' . $to_user_id)->execute()->getFirst()->toArray(); // 获取城市信息 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode(); $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']); $info['user_district'] = $city['FULL_NAME'] ?: ''; // 加入关注数和粉丝数 $UserFollow = new UserFollow(); $info['follow_count'] = $UserFollow->getFollowCount($to_user_id, 1); $info['fans_count'] = $UserFollow->getToFollowCount($to_user_id, 1); $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : ''; $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : ''; $this->verifyUserAuth(false); if ($user_id = $this->getUserAuth()->userId) { $info['is_follow'] = $UserFollow->is_follow($user_id, $to_user_id, 1) ? '1' : '0'; } else { $info['is_follow'] = '0'; } $this->setResult($info); }
public function run() { $account = $this->getDataItem('account'); // 验证电话号码格式 $password = $this->getDataItem('password'); $pushId = $this->getDataItem('push_id', ''); // push id $osType = $this->getDataItem('os_type'); // $account = '18723568682'; // $password = '******'; // 验证数据完整 if (empty($account) || empty($password)) { $this->message = '账户名和密码都不能为空!'; } else { if ($this->verifyAccount($account, $password)) { // 获取 user token if ($this->saveuserauth($this->apiAccessToken->id, $this->userInfo['user_id'])) { $this->success = 1; $this->message = '登录成功!'; $this->userToken = $this->getUserAuth()->userToken; $this->saveUserPushId($this->userInfo['user_id'], $pushId, $osType); $this->userInfo['user_mobile'] = $this->userInfo['bind_phone'] ?: $this->userInfo['user_account']; $this->userInfo['user_cover'] = $this->userInfo['user_cover'] ? PicUrl::UserCover($this->userInfo['user_cover'], $this->getDi()) : ''; $this->userInfo['persional_sign'] = $this->userInfo['persional_sign'] ? unserialize(base64_decode($this->userInfo['persional_sign'])) : ''; // 获取城市信息 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode(); $city = $SysAreaZipDistrictPhonecode->getOne($this->userInfo['user_district']); $this->userInfo['user_district'] = $city['FULL_NAME'] ?: ''; // 加入关注数和粉丝数 $UserFollow = new UserFollow(); $this->userInfo['follow_count'] = $UserFollow->getFollowCount($this->userInfo['user_id'], 1); $this->userInfo['fans_count'] = $UserFollow->getToFollowCount($this->userInfo['user_id'], 1); // 删除不要的字段 unset($this->userInfo['user_account'], $this->userInfo['user_password'], $this->userInfo['user_state'], $this->userInfo['user_addtime'], $this->userInfo['is_manage'], $this->userInfo['bind_phone']); } else { $this->message = '获取User Token异常!'; } } } if (!$this->userInfo) { // 登录失败依然保留字段 $this->userInfo = ["user_id" => "", "user_nickname" => "", "user_mobile" => "", "user_cover" => "", "user_gender" => "0", "user_birthday" => "", "user_realname" => "", "user_expert" => "", "user_district" => "", "user_money" => "", "user_money_virtual" => "", "persional_sign" => "", "follow_count" => 0, "fans_count" => 0]; } $info = ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message]; $info = array_merge($info, $this->userInfo); $this->setResult($info); }
public function run() { // 验证用户权限 if (!$this->verifyUserAuth()) { return false; } $field = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'bind_phone user_mobile', 'persional_sign', 'user_id', 'user_expert']; $info = UserBase::query()->columns($field)->where('user_id=' . $this->getUserAuth()->userId)->execute()->getFirst()->toArray(); // 获取城市信息 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode(); $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']); $info['user_district'] = $city['FULL_NAME'] ?: ''; $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : ''; $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : ''; // 加入关注数和粉丝数 $UserFollow = new UserFollow(); $info['follow_count'] = $UserFollow->getFollowCount($info['user_id'], 1); $info['fans_count'] = $UserFollow->getToFollowCount($info['user_id'], 1); $this->setResult($info); }
public function run() { if (false == $this->verifyUserAuth()) { return false; } $user_id = intval($this->getDataItem('user_id', 0)); $to_user_id = intval($this->getDataItem('to_user_id', 0)); $type = intval($this->getDataItem('type', 0)); if ($user_id == 0 || $to_user_id == 0 || $type == 0) { return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, 'URL参数不全'); } if (!in_array($type, ['1', '2'])) { return $this->errorLog(ResultStatus::POST_BODY_FORMAT_ERROR, 'type类型错误!'); } if ($user_id != $this->getUserAuth()->userId) { return $this->errorLog(ResultStatus::POST_BODY_FORMAT_ERROR, '不能取消他人的关注!'); } $UserFollow = new UserFollow(); if ($UserFollow->unFollow($user_id, $to_user_id, $type) && $type == 2) { // 减少专家的粉丝数 (new \Apps\Common\Models\UserBase())->setExpertFollowCount($to_user_id, 1, false); } $this->setResult(['success' => 1, 'message' => '取消关注成功']); }
public function run() { $user_id = intval($this->getDataItem('user_id', 0)); $page = intval($this->getDataItem('page', 1)); $limit = $this->getConfig()->limit; $offset = ($page - 1) * $limit; // $user_id = 12; $where = 'user_expert = 1 and user_state = 1'; if ($user_id > 0) { // 用户关注的专家列表 $followExpert = UserFollow::query()->where("user_id = {$user_id} and type = 2")->execute()->toArray(); $expert = ''; foreach ($followExpert as $val) { $expert .= $val['to_user_id'] . ','; } if ($expert && ($expert = trim($expert, ','))) { $where = "user_expert = 1 and user_state = 1 and user_id not in({$expert})"; } } $list = UserBase::query()->columns(['user_id', 'user_nickname', 'user_cover', 'expert_follow_count'])->where($where)->orderBy('expert_follow_count DESC')->limit($limit, $offset)->execute()->toArray(); foreach ($list as $k => $val) { $list[$k]['user_cover'] = PicUrl::ActivityCover($val['user_cover'], $this->getDi()); // 获取专家的扩展信息 if ($userAttribute = UserAttribute::findFirst('attr_type = 103 and attr_state = 1 and user_id = ' . $val['user_id'])) { $attr_value_json = $userAttribute->attr_value_json; } else { $attr_value_json = []; } $info = $attr_value_json ? json_decode($attr_value_json) : []; $list[$k]['experience'] = $info->experience ?: '0'; // 从业经验 $list[$k]['experttitle'] = $info->experttitle ?: ''; // 擅长领域 $list[$k]['field'] = $info->field ?: ''; // 专家头衔(array) } $this->setResult($list); }
public function run() { $type = $this->getDataItem('type'); $openId = $this->getDataItem('openid'); $nickname = $this->getDataItem('nickname'); $cover = $this->getDataItem('cover'); $otherData = $this->getDataItem('other_data'); $pushId = $this->getDataItem('push_id'); // push id $osType = $this->getDataItem('os_type'); // 验证数据完整性 if (empty($type) || empty($openId) || empty($nickname)) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "业务参数不全."); } if (!in_array($type, ['weixin', 'weibo'])) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "类型不支持."); } $attrType = 101; if ($type == 'weibo') { $attrType = 102; } // 判断用户是否已经注册了 $userId = $this->isRegister($attrType, $openId); if ($userId === false) { // 注册新账号 $userId = $this->register($type, $attrType, $openId, $nickname, $cover, $otherData); if ($userId === false) { return; } } $info = []; // 获取 user token if ($this->saveUserAuth($this->apiAccessToken->id, $userId)) { $this->success = 1; $this->userid = $userId; $this->message = '登录成功!'; $this->userToken = $this->getUserAuth()->userToken; $this->saveUserPushId($userId, $pushId, $osType); if ($model = UserBase::query()->where("user_id = {$userId}")->execute()->getFirst()) { $info = $model->toArray(); $info['user_mobile'] = $info['bind_phone'] ?: $info['user_account']; if ($info['user_cover'] == 'default.png' && $attrType == 101) { $info['user_cover'] = json_decode($otherData)->headimgurl; } else { $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : ''; } $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : ''; // 获取城市信息 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode(); $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']); $info['user_district'] = $city['FULL_NAME'] ?: ''; // 加入关注数和粉丝数 $UserFollow = new UserFollow(); $info['follow_count'] = $UserFollow->getFollowCount($info['user_id'], 1); $info['fans_count'] = $UserFollow->getToFollowCount($info['user_id'], 1); // 删除不要的字段 unset($info['user_account'], $info['user_password'], $info['user_state'], $info['user_addtime'], $info['is_manage']); } } else { $this->message = '获取User Token异常!'; } if (!$info) { $info = ["user_id" => "", "user_nickname" => "", "user_cover" => "", "user_gender" => "0", "user_birthday" => "", "user_realname" => "", "user_expert" => "", "user_district" => "", "user_money" => "", "user_money_virtual" => "", "persional_sign" => "", "follow_count" => 0, "fans_count" => 0]; } $info = array_merge($info, ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message, 'user_id' => $this->userid]); $this->setResult($info); }