Quellcode durchsuchen

用户修改,关系,等修改

lizhen_gitee vor 2 Monaten
Ursprung
Commit
761df85245

+ 127 - 0
application/api/controller/Relation.php

@@ -0,0 +1,127 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 关系
+ */
+class Relation extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    //发布一种新关系
+    public function addone(){
+        $relationname = input('relationname','','trim');
+        $price        = input('price',0,'intval');
+
+        if(empty($relationname) || empty($price)){
+            $this->error();
+        }
+
+        $data = [
+            'uid' => $this->auth->id,
+            'relationname' => $relationname,
+            'price' => $price,
+            'createtime' => time(),
+        ];
+
+        $id = Db::name('user_relation')->insertGetId($data);
+
+        $this->success('添加成功',$id);
+
+    }
+
+    //关系墙,列表
+    public function lists(){
+        $userid = input('uid',0,'intval');
+        $userid = $userid ? $userid : $this->auth->id;
+
+        //此用户创建的
+        $list = Db::name('user_relation')->alias('r')
+            ->field('r.id,r.relationname,r.price,r.to_uid,user.username,user.nickname,user.avatar,user.id as user_id')
+            ->join('user','r.to_uid = user.id','LEFT')
+            ->where('r.uid',$userid)
+            ->order('id desc')
+            ->select();
+        $list = list_domain_image($list,['avatar']);
+
+        //别人的关系,此用户加入
+       /* $list2 = Db::name('user_relation')->alias('r')
+            ->field('r.id,r.relationname,r.price,r.to_uid,user.username,user.nickname,user.avatar,user.id as user_id')
+            ->join('user','r.uid = user.id','LEFT')
+            ->where('r.to_uid',$userid)
+            ->order('id desc')
+            ->select();
+        $list = list_domain_image($list,['avatar']);
+
+        $list = array_merge($list,$list2);*/
+
+        $this->success(1,$list);
+    }
+
+    //绑定关系
+    public function joinin(){
+        $id = input('id',0);
+
+        Db::startTrans();
+
+        $info = Db::name('user_relation')->where('id',$id)->lock(true)->find();
+        //检查
+        if(empty($info)){
+            Db::rollback();
+            $this->error('不存在的关系');
+        }
+        //检查
+        if($info['to_uid'] > 0){
+            Db::rollback();
+            $this->error('该关系已被他人绑定');
+        }
+        //检查
+        if($info['uid'] == $this->auth->id){
+            Db::rollback();
+            $this->error('不能绑定自己发布的关系');
+        }
+
+        //更新
+        $update = [
+            'to_uid' => $this->auth->id,
+            'updatetime' => time(),
+        ];
+        $rs = Db::name('user_relation')->where('id',$id)->update($update);
+        if($rs === false){
+            Db::rollback();
+            $this->error('操作失败');
+        }
+
+        //扣钱
+        if($info['price'] > 0){
+            $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,0,'gold',$info['price'],71,'绑定关系消费','user_relation',$id);
+            if($rs_wallet['status'] === false){
+                Db::rollback();
+                $this->error($rs_wallet['msg']);
+            }
+
+            //给发布关系的人钱
+            $bili = config('site.money_to_gold');
+
+            $money = bcdiv($info['price'],$bili,2);
+            if($money > 0){
+                $rs_wallet = model('wallet')->lockChangeAccountRemain($info['uid'],0,'money',$money,72,'发布关系被绑定','user_relation',$id);
+                if($rs_wallet['status'] === false){
+                    Db::rollback();
+                    $this->error($rs_wallet['msg']);
+                }
+            }
+
+        }
+
+        Db::commit();
+        $this->success('绑定成功');
+    }
+
+
+
+}

+ 2 - 4
application/api/controller/Usercenter.php

@@ -18,7 +18,6 @@ class Usercenter extends Api
         'id',
         'username',
         'nickname',
-        //'truename',//
 
         'email',
         'mobile',
@@ -47,8 +46,6 @@ class Usercenter extends Api
         'wages',
 
         'hometown_cityid',
-//        'wechat_account',
-//        'secretvideo_status',
 
         'character',
         'constellation',
@@ -62,7 +59,8 @@ class Usercenter extends Api
         'greet_voice',
         'greet_chat',
         'is_kefu',
-        'is_hideaddress', 'is_recommend','is_cohabit', 'live', 'is_house', 'car', 'chest', 'waist'
+        'is_hideaddress',
+        'is_recommend','is_cohabit', 'live', 'is_house', 'car', 'chest', 'waist'
     ];
 
 

+ 2 - 2
application/api/controller/Userlike.php

@@ -27,7 +27,7 @@ class Userlike extends Api
     }
 
     //解锁喜欢我的人
-    public function unlock_like_me(){
+    /*public function unlock_like_me(){
         $gold = intval(config('site.unlock_like_me'));
         if($gold > 0){
 
@@ -50,7 +50,7 @@ class Userlike extends Api
             $this->success('操作成功');
         }
         $this->success('操作成功');
-    }
+    }*/
 
     //我喜欢的人列表
     public function my_like_list(){

+ 12 - 14
application/common/library/Auth.php

@@ -28,10 +28,9 @@ class Auth
     protected $options = [];
     protected $allowFields = [
         'id',
-        'gh_id',
         'username',
         'nickname',
-        //'truename',//
+
         'introcode',
         'intro_uid',
 
@@ -46,7 +45,6 @@ class Auth
         'bio',
         'audio_bio',
 
-        //'alipay_account',//
         'idcard_status',
         'is_active',
 
@@ -64,10 +62,7 @@ class Auth
 
         'hometown_cityid',
         'hide_is_finishinfo',
-//        'level',
         'wechat_openid',
-//        'wechat_account',
-//        'secretvideo_status',
 
         'character',
         'constellation',
@@ -78,8 +73,10 @@ class Auth
         'voice_price',
         'video_price',
 
-        'greet_voice','is_kefu',
-        'greet_chat', 'is_recommend', 'is_cohabit', 'live', 'is_house', 'car', 'chest', 'waist'
+        'greet_voice',
+        'greet_chat',
+        'is_kefu',
+        'is_recommend', 'is_cohabit', 'live', 'is_house', 'car', 'chest', 'waist'
     ];
 
     public function __construct($options = [])
@@ -748,8 +745,6 @@ class Auth
         //签到天数
         $userinfo['sign_times'] = $check = Db::name('user_sign')->where('uid',$this->id)->order('id desc')->value('times');
 
-        //附上变量解锁喜欢我列表
-        $userinfo['unlock_like_me'] = config('site.unlock_like_me');
         //我的未读消息数量
         $userinfo['unread_message_num'] = Db::name('message')->where(['user_id'=>$this->id,'status'=>0])->count('id');
         //是否绑定微信
@@ -757,12 +752,12 @@ class Auth
         //资料完成度
         $userinfo['info_completion'] = 5;
         if ($userinfo['gender'] != -1) {
-            $userinfo['info_completion'] = 10;
+            $userinfo['info_completion'] = 10;  //性别加5分
         }
         $field_array = ['avatar','nickname',/*'gender',*/'birthday','constellation','bio','audio_bio','photo_images','hometown_cityid','job','education','wages','character','stature','weight','height','marital',/*'is_appointment',*/'hobby','tag'];
         foreach ($field_array as &$v) {
             if ($userinfo[$v]) {
-                $userinfo['info_completion'] += 5;
+                $userinfo['info_completion'] += 5; //每一样加五分
             }
         }
         unset($userinfo['wechat_openid']);
@@ -803,9 +798,12 @@ class Auth
         //动态数量
         $userinfo['dongtai_num'] = Db::name('topic_dongtai')->where(['user_id' => $this->id, 'is_hidden' => 0, 'type' => ['in', [1, 2]], 'status' => 0, 'auit_status' => 1])->count();
 
-        //积分数量
+        //收益
         $userinfo['money'] = model('wallet')->getWallet($this->id,'money');
-        
+
+        //金币
+        $userinfo['gold'] = model('wallet')->getWallet($this->id,'gold');
+
         return $userinfo;
     }
 

+ 2 - 0
application/extra/wallet.php

@@ -47,6 +47,8 @@ return [
         65 => '邀请人充值奖励',//money增加
         68 => '邀请人收益奖励',//money增加
 
+        71 => '绑定关系',//gold减少
+        72 => '被绑定关系',//money增加
 
         81 => '开通守护',//gold减少
         82 => '被守护收益', //money增加