Browse Source

首页修改等,删除无用代码

lizhen_gitee 2 months ago
parent
commit
49e5f44600

+ 1 - 1
application/api/controller/Banner.php

@@ -24,7 +24,7 @@ class Banner extends Api
             $where['type'] = $type;
         }
 
-        $list = Db::name('banner')->field('id, title, image, url')->where($where)->order('weigh', 'desc')->select();
+        $list = Db::name('banner')->field('id, title, image')->where($where)->order('weigh', 'desc')->select();
         $list = list_domain_image($list, ['image']);
 
         $this->success(1, $list);

+ 0 - 122
application/api/controller/Demo.php

@@ -22,37 +22,6 @@ class Demo extends Api
     // 无需鉴权的接口,*表示全部
     protected $noNeedRight = ['test2'];
 
-    //移动云短信
-    public function yidong_sms(){
-        $mobile = '18560505277';
-        $code = '1234';
-        $content = '您的短信验证码是'.$code.',本验证码五分钟内有效,请勿泄露';
-        $url = 'https://112.35.10.201:28888/sms/submit';
-        $data = [
-            'ecName' => '江苏达富居家养老健康管理有限公司',
-            'apId' => 'dafuhttps',
-            'secretKey' => '&YY4vrJb',
-            'mobiles' => $mobile,
-            'content' => $content,
-            'sign' => 'YV61594FE',
-            'addSerial' => '',
-        ];
-
-        $mac = md5(join('',$data));
-        $data['mac'] = $mac;
-        unset($data['secretKey']);
-
-        $header = ["Content-Type:application/json;charset=UTF-8"];
-        $rs = curl_post($url,base64_encode(json_encode($data)),$header);
-dump($rs);
-        $rs = json_decode($rs,true);
-        if(isset($rs['success']) && $rs['success'] == true){
-            return true;
-        }
-
-        return false;
-    }
-
     /**
      * 测试方法
      *
@@ -166,96 +135,5 @@ dump($rs);
     }
 
 
-    //腾讯云拍照识别商品
-    //{"Response":{"Products":[{"Name":"按摩椅","Parents":"家用电器-个护健康","Confidence":99,"XMin":107,"YMin":59,"XMax":447,"YMax":366}],"RequestId":"187745fc-0497-441e-88f5-f3f17d854016"}}
-    public function search_by_image($image = 'https://jiankangyijia-1304634122.cos.ap-nanjing.myqcloud.com/uploads/20240504/5cbfbb7880323f05839d82afe1500569.png'){
-        $tencent_yun = config('tencent_yun');
-        $secret_id   = $tencent_yun['secret_id'];
-        $secret_key  = $tencent_yun['secret_key'];
-
-        $token       = "";
-        $service     = "tiia";
-        $host        = "tiia.tencentcloudapi.com";
-        $req_region  = "ap-beijing";
-        $version     = "2019-05-29";
-        $action      = "DetectProduct";
-        $payload     = json_encode(['ImageUrl' => localpath_to_netpath($image)]);
-        $endpoint    = "https://tiia.tencentcloudapi.com";
-        $algorithm   = "TC3-HMAC-SHA256";
-        $timestamp   = time();
-        $date        = gmdate("Y-m-d", $timestamp);
-
-// ************* 步骤 1:拼接规范请求串 *************
-        $http_request_method = "POST";
-        $canonical_uri = "/";
-        $canonical_querystring = "";
-        $ct = "application/json; charset=utf-8";
-        $canonical_headers = "content-type:".$ct."\nhost:".$host."\nx-tc-action:".strtolower($action)."\n";
-        $signed_headers = "content-type;host;x-tc-action";
-        $hashed_request_payload = hash("sha256", $payload);
-        $canonical_request = "$http_request_method\n$canonical_uri\n$canonical_querystring\n$canonical_headers\n$signed_headers\n$hashed_request_payload";
-
-// ************* 步骤 2:拼接待签名字符串 *************
-        $credential_scope = "$date/$service/tc3_request";
-        $hashed_canonical_request = hash("sha256", $canonical_request);
-        $string_to_sign = "$algorithm\n$timestamp\n$credential_scope\n$hashed_canonical_request";
-
-// ************* 步骤 3:计算签名 *************
-        $secret_date    = hash_hmac("sha256", $date, "TC3".$secret_key, true);
-        $secret_service = hash_hmac("sha256", $service, $secret_date, true);
-        $secret_signing = hash_hmac("sha256", "tc3_request", $secret_service, true);
-        $signature      = hash_hmac("sha256", $string_to_sign, $secret_signing);
-
-// ************* 步骤 4:拼接 Authorization *************
-        $authorization = "$algorithm Credential=$secret_id/$credential_scope, SignedHeaders=$signed_headers, Signature=$signature";
-
-// ************* 步骤 5:构造并发起请求 *************
-        $headers = [
-            "Authorization"  => $authorization,
-            "Content-Type"   => "application/json; charset=utf-8",
-            "Host"           => $host,
-            "X-TC-Action"    => $action,
-            "X-TC-Timestamp" => $timestamp,
-            "X-TC-Version"   => $version
-        ];
-        if ($req_region) {
-            $headers["X-TC-Region"] = $req_region;
-        }
-        if ($token) {
-            $headers["X-TC-Token"] = $token;
-        }
-        $headers = array_map(function ($k, $v) { return "$k: $v"; }, array_keys($headers), $headers);
-
-        try {
-            $timeOut = 3;
-            $ch = curl_init();
-            curl_setopt($ch, CURLOPT_URL, $endpoint);
-            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
-            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
-            curl_setopt($ch, CURLOPT_TIMEOUT, $timeOut);
-            curl_setopt($ch, CURLOPT_HEADER, 0);
-            curl_setopt($ch, CURLOPT_POST, 1);
-            curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
-            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
-            $response = curl_exec($ch);
-            curl_close($ch);
-
-            //return $response;
-            $response = json_decode($response,true);
-            if(is_array($response) && isset($response['Response']['Products'][0]['Name'])){
-                $searchname = $response['Response']['Products'][0]['Name'];
-                if(!empty($searchname)){
-                    return $searchname;
-                }
-            }
-            return '';
-        } catch (Exception $err) {
-            //echo $err->getMessage();
-            return '';
-        }
-
-    }
-
 
 }

+ 9 - 175
application/api/controller/Index.php

@@ -14,193 +14,27 @@ class Index extends Api
 
     /**
      * 首页
-     *
      */
     public function index()
     {
-        $this->success('请求成功');
-    }
-
-    //科室列表
-    public function keshi_list(){
-        $list = Db::name('keshi')->where('is_show',1)->order('weigh','desc')->select();
-        $this->success(1,$list);
-    }
 
-    //职称列表
-    public function level_list(){
-        $list = Db::name('doctor_level')->select();
-        $this->success(1,$list);
-    }
+        //一行标签
+        $tag = Db::name('index_server')->order('id desc')->select();
+        $tag = list_domain_image($tag,['image']);
 
-    //医生列表
-    //首页推荐,搜索
-    public function doctor_list(){
+        //多个头条
+        $sys = Db::name('message_sys')->order('id desc')->select();
 
-        $where = [
-            'd.status' => 1,
-            'd.doctor_status' => 1,
+        $result = [
+            'tag' => $tag,
+            'sys' => $sys,
         ];
 
-        //问诊模式,1=图文问诊,21=视频问诊排班模式,2=视频问诊即时模式
-        $type = input('type',0);
-        if($type == 1){
-            $where['info.typing_switch'] = 1;
-        }
-        if($type == 21){
-            $where['info.video_switch'] = 1;
-            $where['info.video_model']  = 1;
-        }
-        if($type == 22){
-            $where['info.video_switch'] = 1;
-            $where['info.video_model']  = 2;
-            $where['d.job_status']  = 1; //上班中
-        }
-
-        //科室id
-        $keshi_id = input('keshi_id',0);
-        if($keshi_id){
-            $where['d.keshi_id'] = $keshi_id;
-        }
-        //职称id
-        $level_id = input('level_id',0);
-        if($level_id){
-            $where['d.level_id'] = $level_id;
-        }
-        //关注
-        $folllow = input('follow',0);
-        if($folllow){
-            $my_follow_ids = controller('Userfollow')->my_follow_uids();
-            $where['d.id'] = ['IN',$my_follow_ids];
-        }
-        //搜索
-        $keyword = input('keyword','');
-        if(!empty($keyword)){
-            $where['d.nickname|d.goodat|keshi.name'] = ['LIKE','%'.$keyword.'%'];
-
-            if($this->auth->isLogin()){
-                Db::name('user_search')->insertGetId(['user_id'=>$this->auth->id,'keyword'=>$keyword]);
-            }
-        }
-
-        //dump($where);
+        $this->success(1, $result);
 
-        $field = [
-            'd.id','d.nickname','d.avatar','d.keshi_id','d.level_id','d.hospital','d.goodat','d.ordernum',
-            'keshi.name as keshi_name',
-            'level.name as level_name','level.name_en as level_name_en',
-            'info.typing_switch','info.video_switch','info.typing_price','info.video_price','info.video_model'
-        ];
-        $list = Db::name('doctor')->alias('d')
-            ->field($field)
-            ->join('doctor_level level','d.level_id = level.id','LEFT')
-            ->join('keshi','d.keshi_id = keshi.id','LEFT')
-            ->join('doctor_info info','d.id = info.doctor_id','LEFT')
-            ->where($where)->order('d.ordernum desc')->autopage()->select();
-        $list = list_domain_image($list,['avatar']);
-
-        $this->success(1,$list);
     }
 
-    //医生详情
-    public function doctor_info(){
-        $id = input('id',0);
-
-        $field = [
-            'd.id','d.nickname','d.avatar','d.keshi_id','d.level_id','d.hospital','d.goodat','d.ordernum','d.info','d.job_status',
-            'keshi.name as keshi_name',
-            'level.name as level_name',
-            'info.typing_switch','info.video_switch','info.typing_price','info.video_price','info.video_model',
-        ];
-        $info = Db::name('doctor')->alias('d')
-            ->field($field)
-            ->join('doctor_level level','d.level_id = level.id','LEFT')
-            ->join('keshi','d.keshi_id = keshi.id','LEFT')
-            ->join('doctor_info info','d.id = info.doctor_id','LEFT')
-            ->where('d.id',$id)->find();
-        $info = info_domain_image($info,['avatar']);
-
-        //是否关注
-        $info['is_follw'] = $this->is_follow($this->auth->id,$id);
-
-        //图文说明
-        $info['wenzhen_typing_serverrule'] = config('site.wenzhen_typing_serverrule');
-        //视频说明
-        $info['wenzhen_video_serverrule'] = config('site.wenzhen_video_serverrule');
 
-        //没上班,文字接诊 停掉
-        if($info['typing_switch'] == 1 && $info['job_status'] == 0){
-            $info['typing_switch'] = 2;
-        }
-        //没上班,即时视频 停掉
-        if($info['video_switch'] == 1 && $info['video_model'] == 2 && $info['job_status'] == 0){
-            $info['video_switch'] = 2;
-        }
-        //视频问诊,排班模式,如果没排班 停掉
-        if($info['video_switch'] == 1 && $info['video_model'] == 1){
-            $paiban_list = $this->doctor_paiban($id,true);
-            if(empty($paiban_list)){
-                $info['video_switch'] = 2;//表示没有排班了,或已经约满
-            }
-        }
-
-        $this->success(1,$info);
-    }
-
-    //医生排班
-    public function doctor_paiban($this_doctor_id = 0,$return = false){
-        $doctor_id = input('doctor_id',$this_doctor_id);
-        if(!$doctor_id){
-            $this->error();
-        }
-
-        //测试临时屏蔽
-//        $list = Db::name('doctor_paiban')->where('doctor_id',$doctor_id)->where('active',1)->where('activetime','gt',time()+7200)->order('activetime asc')->select();
-        $list = Db::name('doctor_paiban')->where('doctor_id',$doctor_id)->where('active',1)->where('activetime','gt',time())->order('activetime asc')->select();
-
-        $newlist = [];
-        if(!empty($list)){
-
-            //预约到此刻后面的订单
-            $need_unset = [];
-            $map = [
-                'doctor_id' => $doctor_id,
-                'ordertype' => 2,
-                'status'    => ['IN','10,20,25,30'],//有效订单
-                'book_time'=> ['gt',time()],
-                'video_model' => 1, //预约模式
-            ];
-            $order_booked = Db::name('wenzhen_order')->where($map)->group('book_time')->column('book_time,count(id) as count_number');
-            if(!empty($order_booked)){
-                foreach($order_booked as $bk => $bv){
-                    if($bv >= 4){
-                        $need_unset[] = $bk;
-                    }
-                }
-            }
-
-            //重组时间数据
-            foreach($list as $key => $val){
-                //排除接满4单的
-                if(in_array($val['activetime'],$need_unset)){
-                    continue;
-                }
-
-                $date = date('Y-m-d',$val['activetime']);
-                if(!isset($newlist[$date])){
-                    $newlist[$date] = [];
-                }
-
-                $newlist[$date][] = date('H:i',$val['activetime']);
-            }
-        }
-
-        if($return == true){
-            return $newlist;
-        }
-
-        $this->success(1,$newlist);
-    }
 
 
 }

+ 0 - 113
application/api/controller/Notify.php

@@ -98,119 +98,6 @@ class Notify extends Api
         return true;
     }
 
-    //问诊订单 异步回调对外方法
-    public function wenzhen_notify_base(){
-
-        //验签
-        $paytype = input('paytype','wechat');
-        $notify_file = $this->notify_log_start($paytype);
-        $pay = Service::checkNotify($paytype);
-        if (!$pay) {
-            echo '签名错误';
-            exit;
-        }
-
-        //验证,拿订单号等信息
-        $data = $pay->verify();
-        $out_trade_no = $data['out_trade_no'];
-        //订单查询
-        $info = Db::name('pay_order')->where('out_trade_no',$out_trade_no)->find();
-
-        if(empty($info)){
-            return $pay->success()->send();
-            exit;
-        }
-
-        if($info['order_status'] != 0)
-        {
-            return $pay->success()->send();
-            exit;
-        }
-        //你可以在此编写订单逻辑
-        $rs = $this->wenzhen_notify_do($out_trade_no);
-        if($rs === false){
-            //不论结果都应返回success
-            return $pay->success()->send();
-            exit;
-        }else{
-            //不论结果都应返回success
-            return $pay->success()->send();
-            exit;
-        }
-
-        //默认
-        return $pay->success()->send();
-        exit;
-    }
-
-    //问诊订单 逻辑
-    private function wenzhen_notify_do($out_trade_no){
-
-        Db::startTrans();
-        $orderInfo = Db::name('pay_order')->where(['out_trade_no' => $out_trade_no])->lock(true)->find();
-        if (empty($orderInfo)) {
-            Db::rollback();
-            return false;
-        }
-
-        if($orderInfo['order_status'] != 0){
-            Db::rollback();
-            return false;
-        }
-
-        $nowtime = time();
-
-        //逻辑开始
-        $wenzhen_order = Db::name('wenzhen_order')->where('id',$orderInfo['table_id'])->lock(true)->find();
-        if($wenzhen_order['status'] != 0 && $wenzhen_order['status'] != 3 ){
-            Db::rollback();
-            return false;
-        }
-        $order_update = [
-            'pay_out_trade_no' => $out_trade_no,
-            'pay_type' => $orderInfo['pay_type'],
-            'pay_time' => $nowtime,
-            'status'   => 10,
-
-            'cancel_time'   => 0,
-            'cancel_reason' => '',
-            'finish_time'   => 0,
-        ];
-        $update_rs = Db::name('wenzhen_order')->where('id',$orderInfo['table_id'])->update($order_update);
-        if($update_rs===false)
-        {
-            Db::rollback();
-            return false;
-        }
-        //逻辑结束
-
-        //状态
-        $ros = Db::name('pay_order')->where(['out_trade_no' => $out_trade_no])->update(['order_status'=>1,'notifytime'=>$nowtime]);
-        if($ros === false) {
-            Db::rollback();
-            return false;
-        }
-
-        //默认提交
-        Db::commit();
-
-
-        //发送im消息给医生
-        if($wenzhen_order['order_type'] == 1){
-            $tenim = new Tenim();
-            $message = [
-                'businessID' => 'order_status',
-                'name' => '待接单',
-                'status' => '10',
-                'id' => $wenzhen_order['id'],
-                'content' => '已通知医生尽快接诊,超时未接诊的将自动取消订单并退款',
-            ];
-            $rs = $tenim->sendCustomMessageToUser('user'.$wenzhen_order['user_id'],'doctor'.$wenzhen_order['doctor_id'],$message);
-        }
-
-
-        return true;
-    }
 
 ////////////////////////////////////////////////////////////////////////
     //充值VIP 异步回调对外方法

+ 2 - 321
application/api/controller/User.php

@@ -16,70 +16,16 @@ use app\common\library\Wechat;
  */
 class User extends Api
 {
-    protected $noNeedLogin = ['login', 'mobilelogin', 'tvuser_login', 'wechatlogin', 'bindmobile','register', 'resetpwd', 'changeemail', 'changemobile', 'third'];
+    protected $noNeedLogin = ['wechatlogin', 'bindmobile'];
     protected $noNeedRight = '*';
 
     public function _initialize()
     {
         parent::_initialize();
 
-        if (!Config::get('fastadmin.usercenter')) {
-            $this->error(__('User center already closed'));
-        }
-
-    }
-
-    /**
-     * 会员中心
-     */
-    public function index()
-    {
-        $this->success('', ['welcome' => $this->auth->nickname]);
     }
 
 
-
-    /**
-     * 手机验证码登录
-     *
-     * @ApiMethod (POST)
-     * @param string $mobile  手机号
-     * @param string $captcha 验证码
-     */
-    public function mobilelogin()
-    {
-        $mobile = input('mobile');
-        $captcha = input('captcha');
-        if (!$mobile || !$captcha) {
-            $this->error(__('Invalid parameters'));
-        }
-        if (!Validate::regex($mobile, "^1\d{10}$")) {
-            $this->error(__('Mobile is incorrect'));
-        }
-        if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $user = \app\common\model\User::getByMobile($mobile);
-        if ($user) {
-            if ($user->status == -1) {
-                $this->error('账号已注销');
-            }
-            if ($user->status != 1) {
-                $this->error(__('Account is locked'));
-            }
-            //如果已经有账号则直接登录
-            $ret = $this->auth->direct($user->id);
-        } else {
-            $ret = $this->auth->register('', '', '', $mobile, []);
-        }
-        if ($ret) {
-            Sms::flush($mobile, 'mobilelogin');
-            $this->success(__('Logged in successful'), $this->auth->getUserinfo_simple());
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
-
     //微信登录,预先假注册
     public function wechatlogin(){
         $code = input('code','');
@@ -213,48 +159,7 @@ class User extends Api
 
     }
 
-    //电视用户登录。
-    public function tvuser_login(){
-        $tv_userid   = input('tv_userid','');
-        $tv_mobile   = input('tv_mobile','');
-        $tv_signtime = input('tv_signtime','');
-        $tv_sign     = input('tv_sign','');
-        if(empty($tv_userid) || empty($tv_mobile) || empty($tv_signtime) || empty($tv_sign)){
-            $this->error('登录参数缺失');
-        }
 
-        //验签
-        $salt = 'be7bcf1499b0fec801406f6aafbd04c4';
-        $get_sign = md5(md5($tv_userid) . $tv_signtime . $salt);
-        if($tv_sign != $get_sign){
-            $this->error('验签失败');
-        }
-        if(time() - $tv_signtime > 300){
-            $this->error('验签过期');
-        }
-
-        //找到用户
-        $user = Db::name('user')->where('comefrom',2)->where('tv_userid',$tv_userid)->find();
-        if ($user) {
-            /*if ($user['status'] == -1) {
-                $this->error('账号已注销');
-            }
-            if ($user['status'] != 1) {
-                $this->error(__('Account is locked'));
-            }*/
-            //如果已经有账号则直接登录
-            $ret = $this->auth->direct($user['id']);
-        } else {
-            $extend = ['tv_mobile'=>$tv_mobile];
-            $ret = $this->auth->tv_register($tv_userid,$extend);
-        }
-
-        if ($ret) {
-            $this->success(__('Logged in successful'), $this->auth->getUserinfo_simple());
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
 
     //用户详细资料
     public function userInfo(){
@@ -288,7 +193,7 @@ class User extends Api
     public function profile()
     {
         $field_array = [
-            'avatar','nickname','gender','tuijian_switch'
+            'avatar','nickname'
         ];
 
         $data = [];
@@ -308,19 +213,10 @@ class User extends Api
                 $newone = input('avatar', '', 'trim,strip_tags,htmlspecialchars');
             }
 
-            if($field == 'nickname'){
-                $newone = Keyworld::sensitive($newone);
-            }
-
 
             $data[$field] = $newone;
         }
 
-        //
-        if(isset($data['birthday'])){
-            $data['birthday'] = strtotime($data['birthday']);
-        }
-
         if(empty($data)){
             $this->success();
         }
@@ -390,220 +286,5 @@ class User extends Api
         $this->success('注销成功');
     }
 
-    //绑定盒子手机号
-    public function bind_tv(){
-        $tv_mobile = input('tv_mobile','');
-        if(empty($tv_mobile)){
-            $this->error();
-        }
-
-        //跨数据库查询
-        $tv_user = Db::connect('database_tv')->name('hu_user')->where('mobile',$tv_mobile)->find();
-        if(empty($tv_user)){
-            $this->error('没有找到该终端用户');
-        }
-
-        $update = [
-            'tv_userid'=>$tv_user['id'],
-            'tv_mobile'=>$tv_user['mobile'],
-        ];
-        $rs = Db::name('user')->where('id',$this->auth->id)->update($update);
-        if($rs === false){
-            $this->error('绑定失败');
-        }
-
-        $this->success('绑定成功');
-    }
 
-    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-    /**
-     * 修改邮箱
-     *
-     * @ApiMethod (POST)
-     * @param string $email   邮箱
-     * @param string $captcha 验证码
-     */
-    public function changeemail()
-    {
-        $user = $this->auth->getUser();
-        $email = input('email');
-        $captcha = input('captcha');
-        if (!$email || !$captcha) {
-            $this->error(__('Invalid parameters'));
-        }
-        if (!Validate::is($email, "email")) {
-            $this->error(__('Email is incorrect'));
-        }
-        if (\app\common\model\User::where('email', $email)->where('id', '<>', $user->id)->find()) {
-            $this->error(__('Email already exists'));
-        }
-        $result = Ems::check($email, $captcha, 'changeemail');
-        if (!$result) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $verification = $user->verification;
-        $verification->email = 1;
-        $user->verification = $verification;
-        $user->email = $email;
-        $user->save();
-
-        Ems::flush($email, 'changeemail');
-        $this->success();
-    }
-
-
-
-    /**
-     * 第三方登录
-     *
-     * @ApiMethod (POST)
-     * @param string $platform 平台名称
-     * @param string $code     Code码
-     */
-    public function third()
-    {
-        $url = url('user/index');
-        $platform = input("platform");
-        $code = input("code");
-        $config = get_addon_config('third');
-        if (!$config || !isset($config[$platform])) {
-            $this->error(__('Invalid parameters'));
-        }
-        $app = new \addons\third\library\Application($config);
-        //通过code换access_token和绑定会员
-        $result = $app->{$platform}->getUserInfo(['code' => $code]);
-        if ($result) {
-            $loginret = \addons\third\library\Service::connect($platform, $result);
-            if ($loginret) {
-                $data = [
-                    'userinfo'  => $this->auth->getUserinfo(),
-                    'thirdinfo' => $result
-                ];
-                $this->success(__('Logged in successful'), $data);
-            }
-        }
-        $this->error(__('Operation failed'), $url);
-    }
-
-    /**
-     * 重置密码
-     *
-     * @ApiMethod (POST)
-     * @param string $mobile      手机号
-     * @param string $newpassword 新密码
-     * @param string $captcha     验证码
-     */
-    public function resetpwd()
-    {
-        $type = input("type", "mobile");
-        $mobile = input("mobile");
-        $email = input("email");
-        $newpassword = input("newpassword");
-        $captcha = input("captcha");
-        if (!$newpassword || !$captcha) {
-            $this->error(__('Invalid parameters'));
-        }
-        //验证Token
-        if (!Validate::make()->check(['newpassword' => $newpassword], ['newpassword' => 'require|regex:\S{6,30}'])) {
-            $this->error(__('Password must be 6 to 30 characters'));
-        }
-        if ($type == 'mobile') {
-            if (!Validate::regex($mobile, "^1\d{10}$")) {
-                $this->error(__('Mobile is incorrect'));
-            }
-            $user = \app\common\model\User::getByMobile($mobile);
-            if (!$user) {
-                $this->error(__('User not found'));
-            }
-            $ret = Sms::check($mobile, $captcha, 'resetpwd');
-            if (!$ret) {
-                $this->error(__('Captcha is incorrect'));
-            }
-            Sms::flush($mobile, 'resetpwd');
-        } else {
-            if (!Validate::is($email, "email")) {
-                $this->error(__('Email is incorrect'));
-            }
-            $user = \app\common\model\User::getByEmail($email);
-            if (!$user) {
-                $this->error(__('User not found'));
-            }
-            $ret = Ems::check($email, $captcha, 'resetpwd');
-            if (!$ret) {
-                $this->error(__('Captcha is incorrect'));
-            }
-            Ems::flush($email, 'resetpwd');
-        }
-        //模拟一次登录
-        $this->auth->direct($user->id);
-        $ret = $this->auth->changepwd($newpassword, '', true);
-        if ($ret) {
-            $this->success(__('Reset password successful'));
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
-
-    /**
-     * 会员登录
-     *
-     * @ApiMethod (POST)
-     * @param string $account  账号
-     * @param string $password 密码
-     */
-    public function login()
-    {
-        $account = input('account');
-        $password = input('password');
-        if (!$account || !$password) {
-            $this->error(__('Invalid parameters'));
-        }
-        $ret = $this->auth->login($account, $password);
-        if ($ret) {
-            $data = ['userinfo' => $this->auth->getUserinfo()];
-            $this->success(__('Logged in successful'), $data);
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
-
-    /**
-     * 注册会员
-     *
-     * @ApiMethod (POST)
-     * @param string $username 用户名
-     * @param string $password 密码
-     * @param string $email    邮箱
-     * @param string $mobile   手机号
-     * @param string $code     验证码
-     */
-    public function register()
-    {
-        $username = input('username');
-        $password = input('password');
-        $email = input('email');
-        $mobile = input('mobile');
-        $code = input('code');
-        if (!$username || !$password) {
-            $this->error(__('Invalid parameters'));
-        }
-        if ($email && !Validate::is($email, "email")) {
-            $this->error(__('Email is incorrect'));
-        }
-        if ($mobile && !Validate::regex($mobile, "^1\d{10}$")) {
-            $this->error(__('Mobile is incorrect'));
-        }
-        $ret = Sms::check($mobile, $code, 'register');
-        if (!$ret) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $ret = $this->auth->register($username, $password, $email, $mobile, []);
-        if ($ret) {
-            $data = ['userinfo' => $this->auth->getUserinfo()];
-            $this->success(__('Sign up successful'), $data);
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
 }

+ 2 - 107
application/common/library/Auth.php

@@ -26,7 +26,7 @@ class Auth
     //默认配置
     protected $config = [];
     protected $options = [];
-    protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'gender', 'createtime' ,'idcard_status','tv_mobile','tuijian_switch'];
+    protected $allowFields = ['id', 'nickname', 'mobile', 'avatar'];
 
     public function __construct($options = [])
     {
@@ -239,91 +239,7 @@ class Auth
         }
         return true;
     }
-    public function tv_register($tv_userid = '',$extend = [])
-    {
-        if(empty($tv_userid)){
-            $this->setError('盒子用户id必填');
-            return false;
-        }
-
-        if ($tv_userid) {
-            $check_user = Db::name('user')->where('comefrom',2)->where('tv_userid',$tv_userid)->find();
-            if($check_user){
-                $this->setError('tv user already exist');
-                return false;
-            }
-        }
-
-        $ip = request()->ip();
-        $time = time();
-
-        $data = [
-            'tv_userid' => $tv_userid,
-            'nickname'  => '电视用户',
-            'comefrom'  => 2,
-            'avatar'    => config('site.user_default_avatar'),
-        ];
-        $params = array_merge($data, [
-            'jointime'  => $time,
-            'joinip'    => $ip,
-            'logintime' => $time,
-            'loginip'   => $ip,
-            'prevtime'  => $time,
-            'status'    => 1
-        ]);
-        $params = array_merge($params, $extend);
-        //账号注册时需要开启事务,避免出现垃圾数据
-        Db::startTrans();
-        try {
-            $user = User::create($params, true);
-
-            $this->_user = User::get($user->id);
-            $this->_user->username = 'u' . (10000 + $user->id);
-            $this->_user->save();
-
-            //设置Token
-            $this->_token = Random::uuid();
-            Token::set($this->_token, $user->id, $this->keeptime);
-
-            //设置登录状态
-            $this->_logined = true;
 
-            //注册钱包
-            $wallet_id = Db::name('user_wallet')->insertGetId(['user_id'=>$user->id]);
-            if(!$wallet_id){
-                $this->setError('注册用户失败');
-                Db::rollback();
-                return false;
-            }
-
-            //[环信]注册用户。忽略失败
-            /*$easemob = new Easemob();
-            $rs = $easemob->user_create('user'.$user->id);
-            if($rs === false){
-                $this->setError('注册用户失败');
-                Db::rollback();
-                return false;
-            }*/
-
-            //腾讯im注册用户
-            $tenim = new Tenim();
-            $rs = $tenim->register('user'.$user->id,$params['nickname'],'');
-            if($rs !== true){
-                $this->setError($rs);
-                Db::rollback();
-                return false;
-            }
-
-            //注册成功的事件
-            Hook::listen("user_register_successed", $this->_user, $data);
-            Db::commit();
-        } catch (Exception $e) {
-            $this->setError($e->getMessage());
-            Db::rollback();
-            return false;
-        }
-        return true;
-    }
 
     /**
      * 用户登录
@@ -527,33 +443,12 @@ class Auth
 
         $userinfo['avatar'] = localpath_to_netpath($userinfo['avatar']);
 
-        //实名信息
-        $userinfo['realname'] = '';
-        $realname = Db::name('user_idconfirm')->where('user_id',$this->id)->where('status',1)->value('realname');
-        if(!empty($realname)){
-            $userinfo['realname'] = $realname;
-        }
-
-        //待审核好友申请
-        $userinfo['friend_apply_number'] = Db::name('friend_apply')->where('to_user_id',$this->id)->where('status',0)->count();
+        $userinfo['wallet'] = model('wallet')->getWallet($this->id);
 
         return $userinfo;
     }
 
-    /**
-     * 获取会员基本信息
-     */
-    public function getUserinfo_tv()
-    {
-        $data = $this->_user->toArray();
-        $allowFields = $this->getAllowFields();
-        $userinfo = array_intersect_key($data, array_flip($allowFields));
-        $userinfo = array_merge($userinfo, Token::get($this->_token));
-
-        $userinfo['avatar'] = localpath_to_netpath($userinfo['avatar']);
 
-        return $userinfo;
-    }
 
     /**
      * 获取会员组别规则列表