lizhen_gitee 8 mesiacov pred
rodič
commit
c5ebdfcaf3

+ 1 - 2
application/api/controller/worker/Baseconfig.php

@@ -16,8 +16,7 @@ class Baseconfig extends Apiw
     public function index(){
 
         $config = [
-            'kefu_user_ids'            => config('site.kefu_user_ids'),//在线客服人员
-            
+
         ];
 
         $this->success('success',$config);

+ 10 - 211
application/api/controller/worker/User.php

@@ -15,189 +15,9 @@ use app\common\library\Wechat;
  */
 class User extends Apiw
 {
-    protected $noNeedLogin = ['mobilelogin','wechatlogin','bindmobile'];
+    protected $noNeedLogin = ['login'];
     protected $noNeedRight = '*';
 
-    /**
-     * 手机验证码登录
-     *
-     * @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\Worker::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','');
-        if(!$code){
-            $this->error();
-        }
-        //微信
-        $wechat = new Wechat();
-        $wxuserinfo = $wechat->getAccessToken($code);
-
-        if(!$wxuserinfo){
-            $this->error('openid获取失败');
-        }
-        if(!is_array($wxuserinfo) || !isset($wxuserinfo['openid'])){
-            $this->error('openid获取失败');
-        }
-
-        $openid = $wxuserinfo['openid'];
-
-        //检查用户
-        $user = Db::name('worker')->where('wechat_openid',$openid)->find();
-        if ($user) {
-            if ($user['status'] == -1) {
-                $this->error('账户已注销');
-            }
-            if ($user['status'] != 1) {
-                $this->error(__('Account is locked'));
-            }
-            //如果已经有账号则直接登录
-            $ret = $this->auth->direct($user['id']);
-
-            if ($ret) {
-                $userInfo = $this->auth->getUserinfo_simple();
-                $userInfo['is_register'] = 0;
-                $userInfo['code'] = $code;
-                $this->success(__('Logged in successful'), $userInfo);
-            } else {
-                $this->error($this->auth->getError());
-            }
-
-        } else {
-            //记录code和openid,绑定手机号的时候更新openid
-            $wechatCodeData = [
-                'code' => $code,
-                'openid' => $openid,
-                'createtime' => time(),
-            ];
-            $wechatCode = Db::name('wechat_code')->where(['openid'=>$openid])->find();
-            if (empty($wechatCode)) {
-                Db::name('wechat_code')->insertGetId($wechatCodeData);
-            } else {
-                Db::name('wechat_code')->where(['openid'=>$openid])->update($wechatCodeData);
-            }
-
-            //直接返回
-            $userInfo = [];
-            $userInfo['is_register'] = 1;
-            $userInfo['code'] = $code;
-            $this->success('获取信息成功', $userInfo);
-        }
-
-    }
-
-    /**
-     * 微信注册来的,绑定手机号
-     *
-     * @ApiMethod (POST)
-     * @param string $mobile   手机号
-     * @param string $captcha 验证码
-     */
-    public function bindmobile()
-    {
-        $mobile  = input('mobile');
-        $captcha = input('captcha');
-        $code    = input('code');
-
-        if (!$mobile || !$captcha || !$code) {
-            $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'));
-        }
-
-        $wechatCodeWhere['code'] = $code;
-        $wechatCode = Db::name('wechat_code')->where($wechatCodeWhere)->find();
-        if (empty($wechatCode)) {
-            $this->error('请先微信登录');
-        }
-
-        //检查appid绑定的用户
-        $user = Db::name('worker')->where('wechat_openid',$wechatCode['openid'])->find();
-        if ($user) {
-            if ($user['status'] == -1) {
-                $this->error('账户已注销');
-            }
-            if ($user['status'] != 1) {
-                $this->error(__('Account is locked'));
-            }
-            //如果已经有账号则直接登录
-            $ret = $this->auth->direct($user['id']);
-            $this->success(__('Logged in successful'), $this->auth->getUserinfo_simple());
-        }
-
-        //新的openid用户
-        $where = [];
-        $where['mobile'] = $mobile;
-        $userData = Db::name('worker')->where($where)->find();//老用户
-        if (!empty($userData)) {
-            if ($userData['status'] == -1) {
-                $this->error('账户已注销');
-            }
-            if ($userData['status'] != 1) {
-                $this->error(__('Account is locked'));
-            }
-
-            if (empty($userData['wechat_openid'])) {
-                Db::name('worker')->where('id',$userData['id'])->update(['wechat_openid' => $wechatCode['openid']]);//老用户更新openid
-            } else {
-                if ($userData['wechat_openid'] != $wechatCode['openid']) {
-                    $this->error('该手机号已被其他用户绑定');
-                }
-            }
-            $ret = $this->auth->direct($userData['id']);
-        } else {
-            $extend = [
-                'wechat_openid' => $wechatCode['openid'],
-            ];
-            $ret = $this->auth->register('', '','', $mobile, $extend);
-        }
-        if (!$ret) {
-            $this->error($this->auth->getError());
-        }
-
-        $this->success(__('Logged in successful'), $this->auth->getUserinfo_simple());
-
-    }
 
 
     //用户详细资料
@@ -332,36 +152,7 @@ class User extends Apiw
 
         $this->success();
     }
-    //问诊设置
-    public function profile_wenzhen()
-    {
-        $field_array = [
-            'typing_switch',
-            'video_switch',
-            'typing_price',
-            'video_price',
-            'notice_switch',
-            'jolt_switch',
-        ];
 
-        $data = [];
-        foreach($field_array as $key => $field){
-
-            if(!input('?'.$field)){
-                continue;
-            }
-
-            $newone = input($field);
-
-            $data[$field] = $newone;
-        }
-        if(empty($data)){
-            $this->success();
-        }
-        $update_rs = Db::name('doctor_info')->where('doctor_id',$this->auth->id)->update($data);
-
-        $this->success();
-    }
 
     //假注销
     public function cancleUser(){
@@ -381,7 +172,6 @@ class User extends Apiw
         $this->success('注销成功');
     }
 
-//////////////////////////////////////////////////////
 
 
     //员工手机+密码登录
@@ -412,6 +202,15 @@ class User extends Apiw
     public function changepwd(){
         $newpassword = input('newpassword');
         $oldpassword = input('oldpassword','');
+        $captcha     = input('captcha','');
+
+        if (!$captcha) {
+            $this->error(__('Invalid parameters'));
+        }
+
+        if (!Sms::check($this->auth->mobile, $captcha, 'mobilelogin')) {
+            $this->error(__('Captcha is incorrect'));
+        }
 
         if (!$newpassword) {
             $this->error('请输入新密码');

+ 11 - 56
application/common/library/Authworker.php

@@ -109,15 +109,12 @@ class Authworker
                 $this->setError('Account is locked');
                 return false;
             }
-
-
-
             $this->_user = $user;
             $this->_logined = true;
             $this->_token = $token;
 
             //初始化成功的事件
-//            Hook::listen("company_init_successed", $this->_user);
+            Hook::listen("company_init_successed", $this->_user);
 
             return true;
         } else {
@@ -255,7 +252,7 @@ class Authworker
      * @param string $password 密码
      * @return boolean
      */
-    /*public function login($account, $password)
+    public function login($account, $password)
     {
         $field = 'mobile';
         $user = Worker::get([$field => $account]);
@@ -275,7 +272,7 @@ class Authworker
 
         //直接登录员工
         return $this->direct($user->id);
-    }*/
+    }
 
     /**
      * 退出
@@ -316,9 +313,9 @@ class Authworker
             try {
                 $salt = Random::alnum();
                 $newpassword = $this->getEncryptPassword($newpassword, $salt);
-                $this->_user->save(['loginfailure' => 0, 'password' => $newpassword, 'salt' => $salt]);
+                $this->_user->save(['password' => $newpassword]);
 
-                Token::delete($this->_token);
+                Tokenworker::delete($this->_token);
                 //修改密码成功的事件
                 Hook::listen("user_changepwd_successed", $this->_user);
                 Db::commit();
@@ -349,20 +346,12 @@ class Authworker
                 $ip = request()->ip();
                 $time = time();
 
-                //判断连续登录和最大连续登录
-                /*if ($user->logintime < \fast\Date::unixtime('day')) {
-                    $user->successions = $user->logintime < \fast\Date::unixtime('day', -1) ? 1 : $user->successions + 1;
-                    $user->maxsuccessions = max($user->successions, $user->maxsuccessions);
-                }*/
-
-//                $user->prevtime = $user->logintime;
+                $user->prevtime = $user->logintime;
                 //记录本次登录的IP和时间
-//                $user->loginip = $ip;
-//                $user->logintime = $time;
-                //重置登录失败次数
-//                $user->loginfailure = 0;
+                $user->loginip = $ip;
+                $user->logintime = $time;
 
-//                $user->save();
+                $user->save();
 
                 $this->_user = $user;
 
@@ -413,11 +402,7 @@ class Authworker
 
         //是否完成用户资料
         $data = $this->_user->toArray();
-        if(empty($data['idcard'])){
-            $userinfo['finish_profile'] = 0;
-        }else{
-            $userinfo['finish_profile'] = 1;
-        }
+
 
         return $userinfo;
     }
@@ -434,39 +419,8 @@ class Authworker
 
         //追加
         $userinfo['avatar'] = one_domain_image($userinfo['avatar']);
-        $userinfo['keshi_name'] = Db::name('keshi')->where('id',$userinfo['keshi_id'])->value('name');
-        $userinfo['level_name'] = Db::name('worker_level')->where('id',$userinfo['level_id'])->value('name');
 
-        //info
-        $userinfo['worker_info'] = Db::name('worker_info')->where('worker_id',$this->id)->find();
-
-        $userinfo['wallet'] = Db::name('worker_wallet')->where('worker_id',$this->id)->find();
-
-        //是否完成用户资料
-        if(empty($data['idcard'])){
-            $userinfo['finish_profile'] = 0;
-        }else{
-            $userinfo['finish_profile'] = 1;
-        }
-
-        //待接图文订单
-        $where = [
-            'worker_id'=>$this->id,
-            'ordertype'=>1,
-            'status'=>10,
-        ];
-        $userinfo['wenzhen_text_noaccept_num'] = Db::name('wenzhen_order')->where($where)->count();
-
-        //待接视频订单
-        $where = [
-            'worker_id'=>$this->id,
-            'ordertype'=>2,
-            'status'=>10,
-        ];
-        $userinfo['wenzhen_video_noaccept_num'] = Db::name('wenzhen_order')->where($where)->count();
 
-        //待接订单
-        $userinfo['wenzhen_noaccept_num'] = $userinfo['wenzhen_text_noaccept_num'] + $userinfo['wenzhen_video_noaccept_num'];
 
 
         return $userinfo;
@@ -520,6 +474,7 @@ class Authworker
      */
     public function getEncryptPassword($password, $salt = '')
     {
+        return $password;
         return md5(md5($password) . $salt);
     }
 

+ 14 - 0
application/extra/site.php

@@ -28,6 +28,8 @@ return array (
     'user' => '会员配置',
     'example' => '示例分组',
     'website' => '全站基础配置',
+    'workerandroid' => '安卓版本',
+    'workerios' => 'IOS版本',
   ),
   'mail_type' => '1',
   'mail_smtp_host' => 'smtp.qq.com',
@@ -44,4 +46,16 @@ return array (
   ),
   'apisite_switch' => '1',
   'apisite_notice' => '全站维护中',
+  'worker_android_update_num' => '1',
+  'worker_android_update_version' => '1.0.0',
+  'worker_android_download_url' => 'http://baidu.com',
+  'worker_android_update_force' => '0',
+  'worker_android_update_title' => '界是你没有挽过的船新版本',
+  'worker_android_update_info' => '我是一条描述',
+  'worker_ios_update_num' => '1',
+  'worker_ios_update_version' => '1.0.0',
+  'worker_ios_download_url' => 'http://apple.com',
+  'worker_ios_update_force' => '0',
+  'worker_ios_update_title' => '新的版本',
+  'worker_ios_update_info' => '界是你没有挽过的船新版本',
 );