|
@@ -95,8 +95,6 @@ class User extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 手机验证码登录 + 注册
|
|
|
*
|
|
@@ -208,6 +206,157 @@ class User extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改会员个人信息
|
|
|
+ *
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string $avatar 头像地址
|
|
|
+ * @param string $username 用户名
|
|
|
+ * @param string $nickname 昵称
|
|
|
+ * @param string $bio 个人简介
|
|
|
+ */
|
|
|
+ public function profile()
|
|
|
+ {
|
|
|
+ $field_array = ['nickname','introcode','gender','birthday','height','weight','bio','audio_bio','avatar','photo_images','education','hobby','job','marital','tag','wages','hometown_cityid','hide_is_finishinfo','wechat_account','character','constellation','stature','is_appointment', 'greet_voice', 'greet_chat', 'is_cohabit', 'live', 'is_house', 'car', 'chest', 'waist'];
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ foreach($field_array as $key => $field){
|
|
|
+
|
|
|
+ if(!input('?'.$field)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $newone = input($field);
|
|
|
+
|
|
|
+ if($field == 'avatar'){
|
|
|
+ // if ($this->auth->real_status == 1) {
|
|
|
+ //$this->error('您已经真人认证不能修改头像~');
|
|
|
+ // die;
|
|
|
+ // }
|
|
|
+ $newone = input('avatar', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
+ }
|
|
|
+ if($field == 'photo_images'){
|
|
|
+ $newone = input('photo_images', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data[$field] = $newone;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($data['birthday'])){
|
|
|
+ $data['birthday'] = strtotime($data['birthday']);
|
|
|
+ }
|
|
|
+ if(isset($data['avatar'])){
|
|
|
+ //$data['real_status'] = -1; //或许应该改成0。性别不能改所以不需要
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($data['introcode'])){
|
|
|
+ if ($this->auth->intro_uid != 0) {
|
|
|
+ $this->error('邀请人不可修改~');
|
|
|
+ }
|
|
|
+
|
|
|
+ $intro_user = Db::name('user')->field('id, intro_uid')->where('introcode', $data['introcode'])->find();
|
|
|
+ if(!$intro_user){
|
|
|
+ $this->error('不存在的邀请人');
|
|
|
+ }
|
|
|
+ if ($intro_user['id'] == $this->auth->id) {
|
|
|
+ $this->error('不能填写自己邀请码');
|
|
|
+ }
|
|
|
+ if ($intro_user['intro_uid'] == $this->auth->id) {
|
|
|
+ $this->error('不能填写下级邀请码');
|
|
|
+ }
|
|
|
+ unset($data['introcode']);//别人的邀请码,不能改了自己的
|
|
|
+ $data['intro_uid'] = $intro_user['id'];
|
|
|
+ $data['invite_time'] = time();
|
|
|
+ }
|
|
|
+ //dump($data);
|
|
|
+ if(empty($data)){
|
|
|
+ $this->error('没有任何改变');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ $userData = Db::name('user')->field('avatar,gender,status')->where('id',$this->auth->id)->find();
|
|
|
+ if (isset($data['avatar']) && !empty($data['avatar']) && $userData['status'] == 2) {//隐藏
|
|
|
+ $boyAvatar = config('avatar_boy');
|
|
|
+ $girlAvatar = config('avatar_girl');
|
|
|
+ if ($userData['gender'] == 1 && $data['avatar'] != $boyAvatar) {
|
|
|
+ $data['status'] = 1;//更新为正常
|
|
|
+ } elseif ($userData['gender'] == 0 && $data['avatar'] != $girlAvatar) {
|
|
|
+ $data['status'] = 1;//更新为正常
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $update_rs = Db::name('user')->where('id',$this->auth->id)->update($data);
|
|
|
+ if($update_rs === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('修改资料失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ //给上级发放钻石
|
|
|
+ if(isset($data['intro_uid'])){
|
|
|
+ $intro_jewel = config('site.new_user_intro_jewel');
|
|
|
+ if($intro_jewel > 0){
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($data['intro_uid'], 0,'jewel',$intro_jewel,34,'邀请'.$this->auth->username.'注册奖励');
|
|
|
+ if($rs_wallet['status'] === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('邀请新人奖励赠送失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //tag任务赠送金币
|
|
|
+ //上传头像加5金币
|
|
|
+ if(isset($data['avatar'])){
|
|
|
+ $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,19);
|
|
|
+ if($task_rs === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('完成任务赠送奖励失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //上传生日 +5金币
|
|
|
+ if (isset($data['birthday'])) {
|
|
|
+ //完成设置生日 +5金币
|
|
|
+ $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,1);
|
|
|
+ if($task_rs === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('完成任务赠送奖励失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //上传个性签名 5金币
|
|
|
+ if(isset($data['audio_bio'])){
|
|
|
+ $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,2);
|
|
|
+ if($task_rs === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('完成任务赠送奖励失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //上传本人语音介绍 10金币
|
|
|
+ if(isset($data['audio_bio'])){
|
|
|
+ $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,21);
|
|
|
+ if($task_rs === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('完成任务赠送奖励失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //上传本人五张照片 10金币
|
|
|
+ if(isset($data['photo_images'])){
|
|
|
+ $photo_images_num = count(explode(',',$data['photo_images'])) + count(explode(',',$this->auth->photo_images));
|
|
|
+ if ($photo_images_num >= 5) {
|
|
|
+ $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id, 5);
|
|
|
+ if ($task_rs === false) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('完成任务赠送奖励失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+
|
|
|
+
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 手机验证码验证
|
|
@@ -752,161 +901,7 @@ class User extends Api
|
|
|
$this->success(__('Logout successful'));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 修改会员个人信息
|
|
|
- *
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param string $avatar 头像地址
|
|
|
- * @param string $username 用户名
|
|
|
- * @param string $nickname 昵称
|
|
|
- * @param string $bio 个人简介
|
|
|
- */
|
|
|
- public function profile()
|
|
|
- {
|
|
|
- $field_array = ['nickname','introcode',/*'gender',*/'birthday','height','weight','bio','audio_bio','avatar','photo_images','education_id','hobby_ids','job_id','marital_id','tag_ids','wages_id','hometown_cityid','hide_is_finishinfo','wechat_account','character_id','constellation_id','stature_id','is_appointment', 'greet_voice', 'greet_chat', 'is_cohabit', 'live_id', 'is_house', 'car_id', 'chest_id', 'waist'];
|
|
|
-
|
|
|
- $data = [];
|
|
|
- foreach($field_array as $key => $field){
|
|
|
-
|
|
|
- if(!input('?'.$field)){
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- $newone = input($field);
|
|
|
-
|
|
|
- if($field == 'avatar'){
|
|
|
- // if ($this->auth->real_status == 1) {
|
|
|
- //$this->error('您已经真人认证不能修改头像~');
|
|
|
- // die;
|
|
|
- // }
|
|
|
- $newone = input('avatar', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
- }
|
|
|
- if($field == 'photo_images'){
|
|
|
- $newone = input('photo_images', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
- }
|
|
|
-
|
|
|
- $data[$field] = $newone;
|
|
|
- }
|
|
|
-
|
|
|
- if(isset($data['birthday'])){
|
|
|
- $data['birthday'] = strtotime($data['birthday']);
|
|
|
- }
|
|
|
- if(isset($data['avatar'])){
|
|
|
- //$data['real_status'] = -1; //或许应该改成0。性别不能改所以不需要
|
|
|
- }
|
|
|
- if(isset($data['hobby_ids'])){
|
|
|
- $data['hobby_ids'] = implode(',',explode(',',$data['hobby_ids']));
|
|
|
- }
|
|
|
- if(isset($data['tag_ids'])){
|
|
|
- $data['tag_ids'] = implode(',',explode(',',$data['tag_ids']));
|
|
|
- }
|
|
|
- if(isset($data['introcode'])){
|
|
|
- if ($this->auth->intro_uid != 0) {
|
|
|
- $this->error('邀请人不可修改~');
|
|
|
- }
|
|
|
-
|
|
|
- $intro_user = Db::name('user')->field('id, intro_uid')->where('introcode', $data['introcode'])->find();
|
|
|
- if(!$intro_user){
|
|
|
- $this->error('不存在的邀请人');
|
|
|
- }
|
|
|
- if ($intro_user['id'] == $this->auth->id) {
|
|
|
- $this->error('不能填写自己邀请码');
|
|
|
- }
|
|
|
- if ($intro_user['intro_uid'] == $this->auth->id) {
|
|
|
- $this->error('不能填写下级邀请码');
|
|
|
- }
|
|
|
- unset($data['introcode']);//别人的邀请码,不能改了自己的
|
|
|
- $data['intro_uid'] = $intro_user['id'];
|
|
|
- $data['invite_time'] = time();
|
|
|
- }
|
|
|
- //dump($data);
|
|
|
- if(empty($data)){
|
|
|
- $this->error('没有任何改变');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- Db::startTrans();
|
|
|
- $userData = Db::name('user')->field('avatar,gender,status')->where('id',$this->auth->id)->find();
|
|
|
- if (isset($data['avatar']) && !empty($data['avatar']) && $userData['status'] == 2) {//隐藏
|
|
|
- $boyAvatar = config('avatar_boy');
|
|
|
- $girlAvatar = config('avatar_girl');
|
|
|
- if ($userData['gender'] == 1 && $data['avatar'] != $boyAvatar) {
|
|
|
- $data['status'] = 1;//更新为正常
|
|
|
- } elseif ($userData['gender'] == 0 && $data['avatar'] != $girlAvatar) {
|
|
|
- $data['status'] = 1;//更新为正常
|
|
|
- }
|
|
|
- }
|
|
|
- $update_rs = Db::name('user')->where('id',$this->auth->id)->update($data);
|
|
|
- if($update_rs === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error('修改资料失败');
|
|
|
- }
|
|
|
-
|
|
|
- //给上级发放钻石
|
|
|
- if(isset($data['intro_uid'])){
|
|
|
- $intro_jewel = config('site.new_user_intro_jewel');
|
|
|
- if($intro_jewel > 0){
|
|
|
- $rs_wallet = model('wallet')->lockChangeAccountRemain($data['intro_uid'], 0,'jewel',$intro_jewel,34,'邀请'.$this->auth->username.'注册奖励');
|
|
|
- if($rs_wallet['status'] === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error('邀请新人奖励赠送失败');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- //tag任务赠送金币
|
|
|
- //上传头像加5金币
|
|
|
- if(isset($data['avatar'])){
|
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,19);
|
|
|
- if($task_rs === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error('完成任务赠送奖励失败');
|
|
|
- }
|
|
|
- }
|
|
|
- //上传生日 +5金币
|
|
|
- if (isset($data['birthday'])) {
|
|
|
- //完成设置生日 +5金币
|
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,1);
|
|
|
- if($task_rs === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error('完成任务赠送奖励失败');
|
|
|
- }
|
|
|
- }
|
|
|
- //上传个性签名 5金币
|
|
|
- if(isset($data['audio_bio'])){
|
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,2);
|
|
|
- if($task_rs === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error('完成任务赠送奖励失败');
|
|
|
- }
|
|
|
- }
|
|
|
- //上传本人语音介绍 10金币
|
|
|
- if(isset($data['audio_bio'])){
|
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,21);
|
|
|
- if($task_rs === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error('完成任务赠送奖励失败');
|
|
|
- }
|
|
|
- }
|
|
|
- //上传本人五张照片 10金币
|
|
|
- if(isset($data['photo_images'])){
|
|
|
- $photo_images_num = count(explode(',',$data['photo_images'])) + count(explode(',',$this->auth->photo_images));
|
|
|
- if ($photo_images_num >= 5) {
|
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id, 5);
|
|
|
- if ($task_rs === false) {
|
|
|
- Db::rollback();
|
|
|
- $this->error('完成任务赠送奖励失败');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- Db::commit();
|
|
|
-
|
|
|
-
|
|
|
- $this->success();
|
|
|
- }
|
|
|
|
|
|
/*
|
|
|
* 修改用户的坐标
|