示例#1
0
 private function register($type, $attrType, $openId, $nickname, $cover, $otherData)
 {
     // 添加基础信息
     $base = new UserBase();
     $base->user_account = '';
     $base->user_password = '';
     $base->user_nickname = $nickname;
     /* if($cover!=''){
       	$base->user_cover = $this->getConfig()->defaultCover; //'default.png';
        } */
     //$config=$this->Config()->aliyun->oss;
     $img = file_get_contents($cover);
     file_put_contents('img/1.jpg', $img);
     $oss = new OSS('dUBfr1wNHjgMnJsd', '1U6ZSbOKhGBffxsopuMIKN6xCpSzUe', 'oss-cn-beijing.aliyuncs.com');
     $options = array();
     $object_name = time() . rand(10000, 99999);
     $file_path = "user-cover/" . date("Y/m/d") . "/" . $object_name . ".jpg";
     $response = $oss->upload_file_by_file('meelier', $file_path, 'img/1.jpg');
     unlink('img/1.jpg');
     $url = $response->header['_info']['url'];
     $url = str_replace("http://oss-cn-beijing.aliyuncs.com/meelier/", "", $url);
     if ($attrType == 101) {
         $base->user_cover = json_decode($otherData)->headimgurl ?: $url;
     } else {
         $base->user_cover = $url;
     }
     // $base->user_cover=$this->getConfig()->defaultCover;
     if (!$base->save()) {
         $this->databaseErrorLog($base);
         return false;
     }
     $userId = $base->user_id;
     // 保存第三方登录信息
     $attr = new UserAttribute();
     $attr->user_id = $userId;
     $attr->attr_type = 100;
     $attr->attr_key = $type;
     $attr->attr_value_json = $openId;
     if (!$attr->save()) {
         $this->databaseErrorLog($attr);
         return false;
     }
     $attr2 = new UserAttribute();
     $attr2->user_id = $userId;
     $attr2->attr_type = $attrType;
     $attr2->attr_key = $openId;
     $attr2->attr_value_json = $otherData;
     if (!$attr2->save()) {
         $this->databaseErrorLog($attr2);
         return false;
     }
     return $userId;
 }
示例#2
0
 /**
  * 设置成专家信息
  * @date: 2016-1-6 
  * @author: futao
  */
 public function setExpertinfoAction()
 {
     $req = $this->request;
     if (!$req->isPost()) {
         $userId = $req->getQuery('userid', null, 0);
         if (!$userId) {
             echo "用户不存在";
             return;
         }
         $tagList = BeautyParlorTagInfo::find("tag_state = 1 and parent_id !=0");
         $this->view->setVar("userId", $userId);
         $this->view->setVar("tagList", $tagList);
         $this->view->pick('user/setexpertinfo');
         return;
     }
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     //$response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数问题!');
     /* $response->sendResult(1);
       	return $response; */
     $experience = $req->getPost("experience", null, '');
     //从业经验
     $userId = $req->getPost("userId", null, '');
     $field = $req->getPost("field", null, '');
     //擅长领域
     $experttitle = $req->getPost("experttitle", null, '');
     //专家头衔
     //验证数据
     if ($field == "" || !is_array($field)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '擅长领域必填!');
         return $response;
     }
     if ($userId == "") {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数错误!');
         return $response;
     }
     $userInfo = UserBase::findFirst($userId);
     if (!$userInfo) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数错误!');
         return $response;
     }
     $data = ['experience' => $experience, 'experttitle' => $experttitle, 'field' => $field];
     $datajson = json_encode($data);
     $userAttr = new UserAttribute();
     $userAttr->attr_value_json = $datajson;
     $userAttr->user_id = $userId;
     $userAttr->attr_type = 103;
     $userAttr->attr_state = 1;
     $userAttr->attr_key = time();
     $userAttrId = $userAttr->save();
     if (!$userAttrId) {
         $response->sendError(ResponseResultStatus::ERROR, '设置失败!');
         return $response;
     }
     $userInfo->user_expert = 1;
     if ($userInfo->save()) {
         $response->sendResult(1);
     } else {
         $response->sendError(ResponseResultStatus::ERROR, '设置失败!');
     }
     return $response;
 }