Jason 1 éve
szülő
commit
da83bb4521

+ 8 - 8
application/admin/controller/Dashboard.php

@@ -3,7 +3,7 @@
 namespace app\admin\controller;
 
 use app\admin\model\Admin;
-use app\admin\model\User;
+use app\admin\model\Users;
 use app\common\controller\Backend;
 use app\common\model\Attachment;
 use fast\Date;
@@ -55,16 +55,16 @@ class Dashboard extends Backend
         }
         // prevtime
         $this->view->assign([
-            'totaluser'         => User::count(),
+            'totaluser'         => Users::count(),
             'totaladdon'        => $totaladdon,
             'totaladmin'        => Admin::count(),
             'totalcategory'     => \app\common\model\Category::count(),
-            'todayusersignup'   => User::whereTime('create_time', 'today')->count(),
-            'todayuserlogin'    => User::whereTime('create_time', 'today')->count(),
-            'sevendau'          => User::whereTime('create_time', '-7 days')->count(),
-            'thirtydau'         => User::whereTime('create_time', '-30 days')->count(),
-            'threednu'          => User::whereTime('create_time', '-3 days')->count(),
-            'sevendnu'          => User::whereTime('create_time', '-7 days')->count(),
+            'todayusersignup'   => Users::whereTime('create_time', 'today')->count(),
+            'todayuserlogin'    => Users::whereTime('create_time', 'today')->count(),
+            'sevendau'          => Users::whereTime('create_time', '-7 days')->count(),
+            'thirtydau'         => Users::whereTime('create_time', '-30 days')->count(),
+            'threednu'          => Users::whereTime('create_time', '-3 days')->count(),
+            'sevendnu'          => Users::whereTime('create_time', '-7 days')->count(),
             'dbtablenums'       => count($dbTableList),
             'dbsize'            => array_sum(array_map(function ($item) {
                 return $item['Data_length'] + $item['Index_length'];

+ 1 - 1
application/admin/controller/trade/MoneyLog.php

@@ -21,7 +21,7 @@ class MoneyLog extends Backend
     public function _initialize()
     {
         parent::_initialize();
-        $this->model = new \app\common\model\Moneylog;
+        $this->model = new \app\common\model\MoneyLog;
         $this->assignconfig('user_id', $this->request->param('ids/d', 0));
 
     }

+ 4 - 4
application/admin/controller/user/Team.php

@@ -4,7 +4,7 @@ namespace app\admin\controller\user;
 
 use think\Db;
 use Exception;
-use app\admin\model\UserPath;
+use app\admin\model\UsersPath;
 use think\exception\DbException;
 use think\exception\PDOException;
 use app\common\controller\Backend;
@@ -19,7 +19,7 @@ class Team extends Backend
 {
 
     /**
-     * @var \app\admin\model\UserPath
+     * @var \app\admin\model\UsersPath
      */
     protected $model = null;
  
@@ -29,7 +29,7 @@ class Team extends Backend
         $this->model = model('User');
         $user_id = $this->request->param('ids/d', 0);
         $this->assignconfig('user_id', $user_id);
-        $this->view->assign("typeList", UserPath::where('parent_id', $user_id)->order('distance', 'asc')->column('distance'));
+        $this->view->assign("typeList", UsersPath::where('parent_id', $user_id)->order('distance', 'asc')->column('distance'));
 
     }
 
@@ -121,7 +121,7 @@ class Team extends Backend
      */
     public function lockAll($ids = null)
     {
-        $rows = UserPath::where('parent_id', $ids)->column('distance');
+        $rows = UsersPath::where('parent_id', $ids)->column('distance');
         if (!$rows) {
             $this->error(__('No Results were found'));
         }

+ 16 - 13
application/admin/controller/user/User.php

@@ -5,8 +5,8 @@ namespace app\admin\controller\user;
 use think\Db;
 use Exception;
 use fast\Random;
-use app\admin\model\UserPath;
-use app\common\model\Moneylog;
+use app\admin\model\UsersPath;
+use app\common\model\MoneyLog;
 use think\exception\DbException;
 use think\exception\PDOException;
 use app\common\controller\Backend;
@@ -23,14 +23,14 @@ class User extends Backend
     protected $searchFields = 'id,mobile';
 
     /**
-     * @var \app\admin\model\User
+     * @var \app\admin\model\Users
      */
     protected $model = null;
 
     public function _initialize()
     {
         parent::_initialize();
-        $this->model = model('User');
+        $this->model = model('Users');
         $this->assign('statusList', $this->model->getStatusList());
         $this->assign('typeList', $this->model->getTypeList());
         
@@ -50,21 +50,24 @@ class User extends Backend
             }
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
 
-            $list = $this->model->alias('a')
-                ->join('users b','a.parent_id = b.id', 'LEFT')
-                ->where($where)->where('a.is_delete', 0)
+            $list = $this->model
+                ->where($where)
+                ->where('is_delete', 0)
                 ->order($sort, $order)
-                ->field('a.*,b.mobile as parent_name')
                 ->paginate($limit);
 
    
             $in  = model('MoneyIn');
             $out = model('MoneyOut');
-            $path= model('UserPath');
+            $path= model('UsersPath');
             foreach ($list as &$item) {
-                $item->agent = $this->model->where('id', '=',  
-                                $path->where('user_id', $item->id)->where('is_agent', 1)->order('distance', 'desc')->value('parent_id'))
-                             ->value('mobile');
+                $item->parent_name = $this->model::where('id', $item->parent_id)->value('mobile');
+
+                $item->agent = $this->model
+                    ->where('id', '=',
+                        $path->where('user_id', $item->id)->where('is_agent', 1)->order('distance', 'desc')->value('parent_id')
+                    )
+                    ->value('mobile');
                 $item->recharge = $in::where('status', 200)->where('user_id', $item->id)->sum('amount');
                 $item->withdraw = $out::where('status', 200)->where('user_id', $item->id)->sum('amount');
             }  
@@ -107,7 +110,7 @@ class User extends Backend
         try {
             $balance = build_amount_compute($params['type'], $params['amount'], $row->balance);
             //操作记录
-            Moneylog::create(['user_id'=> $params['id'], 
+            MoneyLog::create(['user_id'=> $params['id'],
                 'from_id'=> $this->auth->id,
                 'amount'=> $params['amount'],
                 'balance'=> $balance

+ 2 - 2
application/admin/model/User.php → application/admin/model/Users.php

@@ -6,7 +6,7 @@ use app\common\model\MoneyLog;
 use app\common\model\ScoreLog;
 use think\Model;
 
-class User extends Model
+class Users extends Model
 {
 
     // 表名
@@ -72,7 +72,7 @@ class User extends Model
 
     public function parent()
     {
-        return $this->hasOne('User','id','parent_id',[],'LEFT')->setEagerlyType(0);
+        return $this->hasOne('Users','id','parent_id',[],'LEFT')->setEagerlyType(0);
     }
 
 

+ 1 - 1
application/admin/model/UserPath.php → application/admin/model/UsersPath.php

@@ -5,7 +5,7 @@ namespace app\admin\model;
 use fast\Tree;
 use think\Model;
 
-class UserPath extends Model
+class UsersPath extends Model
 {
 
     // 表名

+ 3 - 3
application/api/controller/Ems.php

@@ -4,7 +4,7 @@ namespace app\api\controller;
 
 use app\common\controller\Api;
 use app\common\library\Ems as Emslib;
-use app\common\model\User;
+use app\common\model\Users;
 use think\Hook;
 
 /**
@@ -38,7 +38,7 @@ class Ems extends Api
             $this->error(__('发送频繁'));
         }
         if ($event) {
-            $userinfo = User::getByEmail($email);
+            $userinfo = Users::getByEmail($email);
             if ($event == 'register' && $userinfo) {
                 //已被注册
                 $this->error(__('已被注册'));
@@ -74,7 +74,7 @@ class Ems extends Api
         $captcha = $this->request->post("captcha");
 
         if ($event) {
-            $userinfo = User::getByEmail($email);
+            $userinfo = Users::getByEmail($email);
             if ($event == 'register' && $userinfo) {
                 //已被注册
                 $this->error(__('已被注册'));

+ 3 - 3
application/api/controller/Index.php

@@ -4,7 +4,7 @@ namespace app\api\controller;
 
 use app\common\controller\Api;
 use app\common\model\Config;
-use app\common\model\Moneylog;
+use app\common\model\MoneyLog;
 use app\common\model\News;
 
 /**
@@ -64,7 +64,7 @@ class Index extends Api
     {
         $user = $this->auth->getUser();
 
-        $info_list = (new \app\common\model\User())
+        $info_list = (new \app\common\model\Users())
             ->alias('u')
             ->join('users_path p', 'p.user_id = u.id')
             ->where('p.parent_id', $user['id'])
@@ -75,7 +75,7 @@ class Index extends Api
 //            $paginator[$k]['status_name'] = (new OrderModel())->getStatusNames($v['status']);
 //        }
         $res_data = $this->buildResp($info_list->total(), $info_list->currentPage(), $info_list->items());
-        $res_data['bonus_today'] = Moneylog::where('user_id', $user['id'])
+        $res_data['bonus_today'] = MoneyLog::where('user_id', $user['id'])
                                         ->where('create_time', '>=', strtotime('today'))
                                         ->where('action', 'in', [1,2])
                                         ->sum('amount');

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

@@ -5,7 +5,7 @@ namespace app\api\controller;
 use app\common\controller\Api;
 use app\common\model\MoneyIn;
 use app\common\model\MoneyOut;
-use app\common\model\User AS UserModel;
+use app\common\model\Users AS UserModel;
 use think\Db;
 use think\Exception;
 

+ 1 - 0
application/api/controller/Order.php

@@ -68,6 +68,7 @@ class Order extends Api
     public function get()
     {
         $user = $this->auth->getUser();
+        
 
         $data['order_no']   = 'sn45784545';
         $data['title']      = '商品标题111';

+ 3 - 3
application/api/controller/Sms.php

@@ -5,7 +5,7 @@ namespace app\api\controller;
 use app\common\controller\Api;
 use app\common\library\Sms as Smslib;
 use app\common\model\Sms AS SmsModel;
-use app\common\model\User;
+use app\common\model\Users;
 use think\Hook;
 use fast\Random;
 use Exception;
@@ -58,7 +58,7 @@ class Sms extends Api
             $this->error(__('发送频繁'));
         }
         if ($event) {
-            $userinfo = User::getByMobile($mobile);
+            $userinfo = Users::getByMobile($mobile);
             if ($event == 'register' && $userinfo) {
                 //已被注册
                 $this->error(__('已被注册'));
@@ -101,7 +101,7 @@ class Sms extends Api
         }
 
         if ($event == 'register') {
-            $userinfo = User::getByCodeAndMobile($country_code, $mobile);
+            $userinfo = Users::getByCodeAndMobile($country_code, $mobile);
             if (!empty($userinfo)) {
                 //已被注册
                 $this->error(__('已被注册'));

+ 11 - 10
application/api/controller/User.php

@@ -6,7 +6,7 @@ use app\common\controller\Api;
 use app\common\library\Ems;
 use app\common\library\Sms;
 use app\common\model\Order as OrderModel;
-use app\common\model\User as UserModel;
+use app\common\model\Users as UserModel;
 use fast\Random;
 use think\Cache;
 use think\Config;
@@ -194,7 +194,7 @@ class User extends Api
             $this->error(__('Captcha is incorrect'));
         }
 
-        $res = (new \app\common\model\User())
+        $res = (new \app\common\model\Users())
             ->where('id', $user['id'])
             ->update([
                 'fund_pwd' => md5($new_pwd)
@@ -216,8 +216,9 @@ class User extends Api
         $code           = $this->request->post('country_code');
         $mobile         = $this->request->post('mobile');
         $captcha        = $this->request->post('captcha');
+        $token          = $this->request->post('token');
 
-        if(!captcha_check($captcha)){
+        if(!captcha_check($captcha,$token)){
             $this->error(__('验证码错误'));
         };
 
@@ -318,7 +319,7 @@ class User extends Api
         if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
             $this->error(__('Captcha is incorrect'));
         }
-        $user = \app\common\model\User::getByMobile($mobile);
+        $user = \app\common\model\Users::getByMobile($mobile);
         if ($user) {
             if ($user->status != 'normal') {
                 $this->error(__('Account is locked'));
@@ -413,14 +414,14 @@ class User extends Api
         $bio = $this->request->post('bio');
         $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
         if ($username) {
-            $exists = \app\common\model\User::where('username', $username)->where('id', '<>', $this->auth->id)->find();
+            $exists = \app\common\model\Users::where('username', $username)->where('id', '<>', $this->auth->id)->find();
             if ($exists) {
                 $this->error(__('Username already exists'));
             }
             $user->username = $username;
         }
         if ($nickname) {
-            $exists = \app\common\model\User::where('nickname', $nickname)->where('id', '<>', $this->auth->id)->find();
+            $exists = \app\common\model\Users::where('nickname', $nickname)->where('id', '<>', $this->auth->id)->find();
             if ($exists) {
                 $this->error(__('Nickname already exists'));
             }
@@ -450,7 +451,7 @@ class User extends Api
         if (!Validate::is($email, "email")) {
             $this->error(__('Email is incorrect'));
         }
-        if (\app\common\model\User::where('email', $email)->where('id', '<>', $user->id)->find()) {
+        if (\app\common\model\Users::where('email', $email)->where('id', '<>', $user->id)->find()) {
             $this->error(__('Email already exists'));
         }
         $result = Ems::check($email, $captcha, 'changeemail');
@@ -485,7 +486,7 @@ class User extends Api
         if (!Validate::regex($mobile, "^1\d{10}$")) {
             $this->error(__('Mobile is incorrect'));
         }
-        if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
+        if (\app\common\model\Users::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
             $this->error(__('Mobile already exists'));
         }
         $result = Sms::check($mobile, $captcha, 'changemobile');
@@ -560,7 +561,7 @@ class User extends Api
             if (!Validate::regex($mobile, "^1\d{10}$")) {
                 $this->error(__('Mobile is incorrect'));
             }
-            $user = \app\common\model\User::getByMobile($mobile);
+            $user = \app\common\model\Users::getByMobile($mobile);
             if (!$user) {
                 $this->error(__('User not found'));
             }
@@ -573,7 +574,7 @@ class User extends Api
             if (!Validate::is($email, "email")) {
                 $this->error(__('Email is incorrect'));
             }
-            $user = \app\common\model\User::getByEmail($email);
+            $user = \app\common\model\Users::getByEmail($email);
             if (!$user) {
                 $this->error(__('User not found'));
             }

+ 58 - 9
application/api/controller/Validate.php

@@ -3,8 +3,9 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
-use app\common\model\User;
+use app\common\model\Users;
 use think\captcha\Captcha;
+use think\Request;
 
 /**
  * 验证接口
@@ -29,11 +30,59 @@ class Validate extends Api
      */
     public function get_captcha()
     {
-        $captcha = new Captcha();
+
+        $captcha = new Captcha(['codeSet' => '0123456789', 'length' => 4]);
+        $id = uniqid();
         return $captcha->entry();
 
-        return captcha_src();
+//        $id = uniqid();
+//        $src = $_SERVER['REQUEST_SCHEME'].'://'.$this->request->host() . captcha_src($id);
+//        ob_clean();    //清除缓冲区,防止出现“图像因其本身有错无法显示'的问题
+//        $type = getimagesize($src)['mime'];  //获取图片类型
+//        header("Content-Type:{$type}");
+//        $imgData = file_get_contents($src); //获取图片二进制流
+//        $base64String = 'data:' . $type . ';base64,' . base64_encode($imgData);
+//        $this->success('', ['id' => $id, 'img' => $base64String]);
+//
+//        $this->success('请求成功',$base64String);
+//
+//
+//        return Captcha_src(); // png图片
+
+        // 获取验证码的图片内容
+        $image = $captcha->entry();
+
+        // 转换为Base64
+        $base64Image = $this->imageToBase64($image);
+
+        dump($base64Image);
+        $this->success('', ['id' => $id, 'img' => $captcha->entry($id)]);
+        return $captcha->entry($id);
+        //return captcha_src();
     }
+
+    protected function imageToBase64($image)
+    {
+        // 确保已经安装GD库或者Imagick扩展
+        if (!function_exists('imagepng') && !function_exists('imagejpeg')) {
+            throw new \Exception('Need to install GD library or ImageMagick extension');
+        }
+
+        ob_start();
+        // 输出图片到输出缓冲区
+        imagepng($image) || imagejpeg($image);
+        $imageContent = ob_get_contents();
+        ob_end_clean();
+
+        // 将图片内容转为Base64
+        $base64Image = 'data:image/png;base64,' . base64_encode($imageContent);
+
+        // 释放图片资源
+        imagedestroy($image);
+
+        return $base64Image;
+    }
+
     /**
      * 检测邮箱
      *
@@ -45,7 +94,7 @@ class Validate extends Api
     {
         $email = $this->request->post('email');
         $id = (int)$this->request->post('id');
-        $count = User::where('email', '=', $email)->where('id', '<>', $id)->count();
+        $count = Users::where('email', '=', $email)->where('id', '<>', $id)->count();
         if ($count > 0) {
             $this->error(__('邮箱已经被占用'));
         }
@@ -63,7 +112,7 @@ class Validate extends Api
     {
         $username = $this->request->post('username');
         $id = (int)$this->request->post('id');
-        $count = User::where('username', '=', $username)->where('id', '<>', $id)->count();
+        $count = Users::where('username', '=', $username)->where('id', '<>', $id)->count();
         if ($count > 0) {
             $this->error(__('用户名已经被占用'));
         }
@@ -81,7 +130,7 @@ class Validate extends Api
     {
         $nickname = $this->request->post('nickname');
         $id = (int)$this->request->post('id');
-        $count = User::where('nickname', '=', $nickname)->where('id', '<>', $id)->count();
+        $count = Users::where('nickname', '=', $nickname)->where('id', '<>', $id)->count();
         if ($count > 0) {
             $this->error(__('昵称已经被占用'));
         }
@@ -99,7 +148,7 @@ class Validate extends Api
     {
         $mobile = $this->request->post('mobile');
         $id = (int)$this->request->post('id');
-        $count = User::where('mobile', '=', $mobile)->where('id', '<>', $id)->count();
+        $count = Users::where('mobile', '=', $mobile)->where('id', '<>', $id)->count();
         if ($count > 0) {
             $this->error(__('该手机号已经占用'));
         }
@@ -115,7 +164,7 @@ class Validate extends Api
     public function check_mobile_exist()
     {
         $mobile = $this->request->post('mobile');
-        $count = User::where('mobile', '=', $mobile)->count();
+        $count = Users::where('mobile', '=', $mobile)->count();
         if (!$count) {
             $this->error(__('手机号不存在'));
         }
@@ -131,7 +180,7 @@ class Validate extends Api
     public function check_email_exist()
     {
         $email = $this->request->post('email');
-        $count = User::where('email', '=', $email)->count();
+        $count = Users::where('email', '=', $email)->count();
         if (!$count) {
             $this->error(__('邮箱不存在'));
         }

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

@@ -2,7 +2,7 @@
 
 namespace app\common\library;
 
-use app\common\model\User;
+use app\common\model\Users;
 use app\common\model\UserRule;
 use app\common\model\Users;
 use fast\Random;
@@ -53,7 +53,7 @@ class Auth
 
     /**
      * 获取User模型
-     * @return User
+     * @return Users
      */
     public function getUser()
     {
@@ -100,7 +100,7 @@ class Auth
         }
         $user_id = intval($data['user_id']);
         if ($user_id > 0) {
-            $user = User::get($user_id);
+            $user = Users::get($user_id);
             if (!$user) {
                 $this->setError('Account not exist');
                 return false;
@@ -153,12 +153,12 @@ class Auth
 //            $this->setError('Email already exist');
 //            return false;
 //        }
-        if ($mobile && User::getByCodeAndMobile($code, $mobile)) {
+        if ($mobile && Users::getByCodeAndMobile($code, $mobile)) {
             $this->setError('Mobile already exist');
             return false;
         }
 
-        $parent_info = User::getByInvitationCode($invitation_code);
+        $parent_info = Users::getByInvitationCode($invitation_code);
         if(empty($parent_info)){
             $this->setError('邀请码有误');
             return false;
@@ -191,9 +191,9 @@ class Auth
         //账号注册时需要开启事务,避免出现垃圾数据
         Db::startTrans();
         try {
-            $user = User::create($params, true);
+            $user = Users::create($params, true);
 
-            $this->_user = User::get($user->id);
+            $this->_user = Users::get($user->id);
 
             //设置Token
             $this->_token = Random::uuid();
@@ -223,7 +223,7 @@ class Auth
     public function login($code, $account, $password)
     {
         //$field = Validate::is($account, 'email') ? 'email' : (Validate::regex($account, '/^1\d{10}$/') ? 'mobile' : 'username');
-        $user = User::where('code', $code)
+        $user = Users::where('code', $code)
                     ->where('mobile', $account)
                     ->find();
         if (!$user) {
@@ -308,7 +308,7 @@ class Auth
      */
     public function direct($user_id)
     {
-        $user = User::get($user_id);
+        $user = Users::get($user_id);
         if ($user) {
             Db::startTrans();
             try {
@@ -467,14 +467,14 @@ class Auth
      */
     public function delete($user_id)
     {
-        $user = User::get($user_id);
+        $user = Users::get($user_id);
         if (!$user) {
             return false;
         }
         Db::startTrans();
         try {
             // 删除会员
-            User::destroy($user_id);
+            Users::destroy($user_id);
             // 删除会员指定的所有Token
             Token::clear($user_id);
 
@@ -555,7 +555,7 @@ class Auth
                 $fields[] = 'id';
             }
             $ids = array_unique($ids);
-            $selectlist = User::where('id', 'in', $ids)->column($fields);
+            $selectlist = Users::where('id', 'in', $ids)->column($fields);
             foreach ($selectlist as $k => $v) {
                 $list[$v['id']] = $v;
             }

+ 1 - 1
application/common/model/MoneyIn.php

@@ -61,7 +61,7 @@ class MoneyIn extends Model
 
     public function users()
     {
-        return $this->hasOne('User','id','user_id',[],'LEFT')->setEagerlyType(0);
+        return $this->hasOne('Users','id','user_id',[],'LEFT')->setEagerlyType(0);
     }
 
     public function admins()

+ 3 - 8
application/common/model/Moneylog.php → application/common/model/MoneyLog.php

@@ -5,13 +5,8 @@ namespace app\common\model;
 use think\Model;
 
 
-class Moneylog extends Model
+class MoneyLog extends Model
 {
-
-    
-
-    
-
     // 表名
     protected $name = 'money_log';
     
@@ -32,12 +27,12 @@ class Moneylog extends Model
     //
     public function users()
     {
-        return $this->hasOne('User','id','user_id',[],'LEFT')->setEagerlyType(0);
+        return $this->hasOne('Users','id','user_id',[],'LEFT')->setEagerlyType(0);
     }
 
     public function fromuser()
     {
-        return $this->hasOne('User','id','from_id',[],'LEFT')->setEagerlyType(0);
+        return $this->hasOne('Users','id','from_id',[],'LEFT')->setEagerlyType(0);
     }
 
 

+ 1 - 1
application/common/model/MoneyOut.php

@@ -60,7 +60,7 @@ class MoneyOut extends Model
 
     public function users()
     {
-        return $this->hasOne('User','id','user_id',[],'LEFT')->setEagerlyType(0);
+        return $this->hasOne('Users','id','user_id',[],'LEFT')->setEagerlyType(0);
     }
 
     public function admins()

+ 1 - 1
application/common/model/Order.php

@@ -55,7 +55,7 @@ class Order extends Model
     //users
     public function users()
     {
-        return $this->hasOne('User','id','user_id',[],'LEFT')->setEagerlyType(0);
+        return $this->hasOne('Users','id','user_id',[],'LEFT')->setEagerlyType(0);
     }
 
     //操作列表

+ 0 - 228
application/common/model/User.php

@@ -1,228 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Db;
-use think\Model;
-
-/**
- * 会员模型
- */
-class User extends Model
-{
-    // 表名
-    protected $name = 'users';
-    // 开启自动写入时间戳字段
-    protected $autoWriteTimestamp = 'int';
-    // 定义时间戳字段名
-    protected $createTime = 'create_time';
-    protected $updateTime = false;
-    // 追加属性
-    protected $append = [
-    ];
-
-    /**
-     * @param $code     //国际区号
-     * @param $mobile   //手机号
-     * @return array
-     */
-    public static function getByCodeAndMobile($code, $mobile)
-    {
-        $info = self::where('code', $code)
-            ->where('mobile', $mobile)
-            ->find();
-        return $info;
-    }
-
-    /**
-     * 根据邀请码获取会员信息
-     * @param $invitation_code
-     * @return array|bool|\PDOStatement|string|Model|null
-     */
-    public static function getByInvitationCode($invitation_code)
-    {
-        $info = self::where('invitation_code', $invitation_code)
-            ->find();
-        return $info;
-    }
-
-    /**
-     * 获取代理信息
-     * @param $invitation_code
-     * @return array|null
-     */
-    public static function getAgentRechargeInfoByAgentId($agent_id)
-    {
-        $data['usdt']     = '';
-        $data['bank']     = [];
-        $data['agent_id'] = $agent_id;
-        $info = self::where('id', $agent_id)
-            ->where('is_agent', 1)
-            ->where('is_lock', 0)
-            ->where('is_delete', 0)
-            ->find();
-        if(empty($info)){
-            //没找到代理时,默认显示系统配置
-            if((new Config())->getValue('recharge_usdt_switch')){
-                $data['usdt'] = (new Config())->getValue('recharge_usdt_address');
-            }
-
-            if((new Config())->getValue('recharge_bank_switch')){
-                $data['bank']['bank_name']    = (new Config())->getValue('recharge_bank_name');
-                $data['bank']['bank_card']    = (new Config())->getValue('recharge_bank_card');
-                $data['bank']['account_name'] = (new Config())->getValue('recharge_account_name');
-            }
-            $data['agent_id'] = 0;
-            return $data;
-        }
-
-        if($info['agent_in_usdt']){
-            $data['usdt'] = $info['agent_usdt_address'];
-        }
-        if($info['agent_in_bank']){
-            $bank_info = $info['agent_bank_info'];
-            $data['bank']['bank_name'] = $bank_info['bank_name'];
-            $data['bank']['bank_card'] = $bank_info['bank_card'];
-            $data['bank']['real_name'] = $bank_info['real_name'];
-        }
-        if(empty($data['usdt']) && empty($data['bank'])){
-            return [];
-        }
-        return $data;
-    }
-    /**
-     * 获取代理信息
-     * @param $invitation_code
-     * @return array|null
-     */
-    public static function getAgentWithdrawInfoByAgentId($agent_id)
-    {
-        $data['agent_id'] = $agent_id;
-        $info = self::where('id', $agent_id)
-            ->where('is_agent', 1)
-            ->where('is_lock', 0)
-            ->where('is_delete', 0)
-            ->find();
-        if(empty($info)){
-            //没找到代理时,默认显示系统配置
-            $data['usdt'] = (new Config())->getValue('withdraw_usdt_switch');
-            $data['bank'] = (new Config())->getValue('withdraw_bank_switch');
-            $data['agent_id'] = 0;
-            return $data;
-        }
-
-        $data['usdt'] = $info['agent_out_usdt'];
-        $data['bank'] = $info['agent_out_bank'];
-
-        return $data;
-    }
-
-    /**
-     * 获取头像
-     * @param string $value
-     * @param array  $data
-     * @return string
-     */
-    public function getAvatarAttr($value, $data)
-    {
-        if (!$value) {
-            //如果不需要启用首字母头像,请使用
-            //$value = '/assets/img/avatar.png';
-            $value = letter_avatar($data['nickname']);
-        }
-        return $value;
-    }
-
-    /**
-     * 获取验证字段数组值
-     * @param string $value
-     * @param array  $data
-     * @return  object
-     */
-    public function getVerificationAttr($value, $data)
-    {
-        $value = array_filter((array)json_decode($value, true));
-        $value = array_merge(['email' => 0, 'mobile' => 0], $value);
-        return (object)$value;
-    }
-
-    /**
-     * 设置验证字段
-     * @param mixed $value
-     * @return string
-     */
-    public function setVerificationAttr($value)
-    {
-        $value = is_object($value) || is_array($value) ? json_encode($value) : $value;
-        return $value;
-    }
-
-    /**
-     * 变更会员余额
-     * @param int    $money   余额
-     * @param int    $user_id 会员ID
-     * @param string $memo    备注
-     */
-    public static function money($money, $user_id, $memo)
-    {
-        Db::startTrans();
-        try {
-            $user = self::lock(true)->find($user_id);
-            if ($user && $money != 0) {
-                $before = $user->money;
-                //$after = $user->money + $money;
-                $after = function_exists('bcadd') ? bcadd($user->money, $money, 2) : $user->money + $money;
-                //更新会员信息
-                $user->save(['money' => $after]);
-                //写入日志
-                MoneyLog::create(['user_id' => $user_id, 'money' => $money, 'before' => $before, 'after' => $after, 'memo' => $memo]);
-            }
-            Db::commit();
-        } catch (\Exception $e) {
-            Db::rollback();
-        }
-    }
-
-    /**
-     * 变更会员积分
-     * @param int    $score   积分
-     * @param int    $user_id 会员ID
-     * @param string $memo    备注
-     */
-    public static function score($score, $user_id, $memo)
-    {
-        Db::startTrans();
-        try {
-            $user = self::lock(true)->find($user_id);
-            if ($user && $score != 0) {
-                $before = $user->score;
-                $after = $user->score + $score;
-                $level = self::nextlevel($after);
-                //更新会员信息
-                $user->save(['score' => $after, 'level' => $level]);
-                //写入日志
-                ScoreLog::create(['user_id' => $user_id, 'score' => $score, 'before' => $before, 'after' => $after, 'memo' => $memo]);
-            }
-            Db::commit();
-        } catch (\Exception $e) {
-            Db::rollback();
-        }
-    }
-
-    /**
-     * 根据积分获取等级
-     * @param int $score 积分
-     * @return int
-     */
-    public static function nextlevel($score = 0)
-    {
-        $lv = array(1 => 0, 2 => 30, 3 => 100, 4 => 500, 5 => 1000, 6 => 2000, 7 => 3000, 8 => 5000, 9 => 8000, 10 => 10000);
-        $level = 1;
-        foreach ($lv as $key => $value) {
-            if ($score >= $value) {
-                $level = $key;
-            }
-        }
-        return $level;
-    }
-}

+ 95 - 0
application/common/model/Users-back.php

@@ -0,0 +1,95 @@
+<?php
+
+namespace app\common\model;
+
+use think\Db;
+use think\Model;
+
+/**
+ * 会员模型
+ */
+class Users extends Model
+{
+
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+
+    public static function getByCodeAndMobile($code, $mobile)
+    {
+        $info = self::where('code', $code)
+            ->where('mobile', $mobile)
+            ->find();
+        return $info;
+    }
+    /**
+     * 变更会员余额
+     * @param int    $money   余额
+     * @param int    $user_id 会员ID
+     * @param string $memo    备注
+     */
+    public static function money($money, $user_id, $memo)
+    {
+        Db::startTrans();
+        try {
+            $user = self::lock(true)->find($user_id);
+            if ($user && $money != 0) {
+                $before = $user->money;
+                //$after = $user->money + $money;
+                $after = function_exists('bcadd') ? bcadd($user->money, $money, 2) : $user->money + $money;
+                //更新会员信息
+                $user->save(['money' => $after]);
+                //写入日志
+                MoneyLog::create(['user_id' => $user_id, 'money' => $money, 'before' => $before, 'after' => $after, 'memo' => $memo]);
+            }
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+        }
+    }
+
+    /**
+     * 变更会员积分
+     * @param int    $score   积分
+     * @param int    $user_id 会员ID
+     * @param string $memo    备注
+     */
+    public static function score($score, $user_id, $memo)
+    {
+        Db::startTrans();
+        try {
+            $user = self::lock(true)->find($user_id);
+            if ($user && $score != 0) {
+                $before = $user->score;
+                $after = $user->score + $score;
+                $level = self::nextlevel($after);
+                //更新会员信息
+                $user->save(['score' => $after, 'level' => $level]);
+                //写入日志
+                ScoreLog::create(['user_id' => $user_id, 'score' => $score, 'before' => $before, 'after' => $after, 'memo' => $memo]);
+            }
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+        }
+    }
+
+    /**
+     * 根据积分获取等级
+     * @param int $score 积分
+     * @return int
+     */
+    public static function nextlevel($score = 0)
+    {
+        $lv = array(1 => 0, 2 => 30, 3 => 100, 4 => 500, 5 => 1000, 6 => 2000, 7 => 3000, 8 => 5000, 9 => 8000, 10 => 10000);
+        $level = 1;
+        foreach ($lv as $key => $value) {
+            if ($score >= $value) {
+                $level = $key;
+            }
+        }
+        return $level;
+    }
+}

+ 136 - 3
application/common/model/Users.php

@@ -10,13 +10,22 @@ use think\Model;
  */
 class Users extends Model
 {
-
+    // 表名
+    protected $name = 'users';
     // 开启自动写入时间戳字段
     protected $autoWriteTimestamp = 'int';
     // 定义时间戳字段名
-    protected $createTime = 'createtime';
-    protected $updateTime = 'updatetime';
+    protected $createTime = 'create_time';
+    protected $updateTime = false;
+    // 追加属性
+    protected $append = [
+    ];
 
+    /**
+     * @param $code     //国际区号
+     * @param $mobile   //手机号
+     * @return array
+     */
     public static function getByCodeAndMobile($code, $mobile)
     {
         $info = self::where('code', $code)
@@ -24,6 +33,130 @@ class Users extends Model
             ->find();
         return $info;
     }
+
+    /**
+     * 根据邀请码获取会员信息
+     * @param $invitation_code
+     * @return array|bool|\PDOStatement|string|Model|null
+     */
+    public static function getByInvitationCode($invitation_code)
+    {
+        $info = self::where('invitation_code', $invitation_code)
+            ->find();
+        return $info;
+    }
+
+    /**
+     * 获取代理信息
+     * @param $invitation_code
+     * @return array|null
+     */
+    public static function getAgentRechargeInfoByAgentId($agent_id)
+    {
+        $data['usdt']     = '';
+        $data['bank']     = [];
+        $data['agent_id'] = $agent_id;
+        $info = self::where('id', $agent_id)
+            ->where('is_agent', 1)
+            ->where('is_lock', 0)
+            ->where('is_delete', 0)
+            ->find();
+        if(empty($info)){
+            //没找到代理时,默认显示系统配置
+            if((new Config())->getValue('recharge_usdt_switch')){
+                $data['usdt'] = (new Config())->getValue('recharge_usdt_address');
+            }
+
+            if((new Config())->getValue('recharge_bank_switch')){
+                $data['bank']['bank_name']    = (new Config())->getValue('recharge_bank_name');
+                $data['bank']['bank_card']    = (new Config())->getValue('recharge_bank_card');
+                $data['bank']['account_name'] = (new Config())->getValue('recharge_account_name');
+            }
+            $data['agent_id'] = 0;
+            return $data;
+        }
+
+        if($info['agent_in_usdt']){
+            $data['usdt'] = $info['agent_usdt_address'];
+        }
+        if($info['agent_in_bank']){
+            $bank_info = $info['agent_bank_info'];
+            $data['bank']['bank_name'] = $bank_info['bank_name'];
+            $data['bank']['bank_card'] = $bank_info['bank_card'];
+            $data['bank']['real_name'] = $bank_info['real_name'];
+        }
+        if(empty($data['usdt']) && empty($data['bank'])){
+            return [];
+        }
+        return $data;
+    }
+    /**
+     * 获取代理信息
+     * @param $invitation_code
+     * @return array|null
+     */
+    public static function getAgentWithdrawInfoByAgentId($agent_id)
+    {
+        $data['agent_id'] = $agent_id;
+        $info = self::where('id', $agent_id)
+            ->where('is_agent', 1)
+            ->where('is_lock', 0)
+            ->where('is_delete', 0)
+            ->find();
+        if(empty($info)){
+            //没找到代理时,默认显示系统配置
+            $data['usdt'] = (new Config())->getValue('withdraw_usdt_switch');
+            $data['bank'] = (new Config())->getValue('withdraw_bank_switch');
+            $data['agent_id'] = 0;
+            return $data;
+        }
+
+        $data['usdt'] = $info['agent_out_usdt'];
+        $data['bank'] = $info['agent_out_bank'];
+
+        return $data;
+    }
+
+    /**
+     * 获取头像
+     * @param string $value
+     * @param array  $data
+     * @return string
+     */
+    public function getAvatarAttr($value, $data)
+    {
+        if (!$value) {
+            //如果不需要启用首字母头像,请使用
+            //$value = '/assets/img/avatar.png';
+            $value = letter_avatar($data['nickname']);
+        }
+        return $value;
+    }
+
+    /**
+     * 获取验证字段数组值
+     * @param string $value
+     * @param array  $data
+     * @return  object
+     */
+    public function getVerificationAttr($value, $data)
+    {
+        $value = array_filter((array)json_decode($value, true));
+        $value = array_merge(['email' => 0, 'mobile' => 0], $value);
+        return (object)$value;
+    }
+
+    /**
+     * 设置验证字段
+     * @param mixed $value
+     * @return string
+     */
+    public function setVerificationAttr($value)
+    {
+        $value = is_object($value) || is_array($value) ? json_encode($value) : $value;
+        return $value;
+    }
+
     /**
      * 变更会员余额
      * @param int    $money   余额

+ 2 - 1
composer.json

@@ -31,7 +31,8 @@
         "ext-pdo": "*",
         "ext-bcmath": "*",
         "txthinking/mailer": "^2.0",
-        "aliyuncs/oss-sdk-php": "^2.7"
+        "aliyuncs/oss-sdk-php": "^2.7",
+        "ext-gd": "*"
     },
     "config": {
         "preferred-install": "dist",

+ 2 - 2
public/assets/js/backend/user/user.js

@@ -20,8 +20,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             // 初始化表格
             table.bootstrapTable({
                 url: $.fn.bootstrapTable.defaults.extend.index_url,
-                pk: 'a.id',
-                sortName: 'a.id',
+                pk: 'id',
+                sortName: 'id',
                 columns: [
                     [
                         {checkbox: true},