15954078560 пре 2 година
родитељ
комит
a036e192f7
2 измењених фајлова са 59 додато и 83 уклоњено
  1. 58 81
      application/api/controller/User.php
  2. 1 2
      application/common/library/Auth.php

+ 58 - 81
application/api/controller/User.php

@@ -1177,11 +1177,19 @@ class User extends Api
     //注册
     public function register()
     {
-        $mobile = $this->request->post('mobile', '', 'trim'); //手机号
-        $code = $this->request->post('code', '', 'trim'); //验证码
+        $realname = input('realname', '', 'trim'); //真实姓名
+        $height = input('height', 170, 'intval'); //身高
+        $weight = input('weight', 60, 'intval'); //体重
         $birthday = $this->request->post('birthday', '', 'strtotime'); //生日
-        $gender = $this->request->post('gender', 0, 'intval'); //性别:1=男,2=女
-        $invite_no = $this->request->post('invite_no', '', 'trim'); //邀请码
+        $province_id = input('province_id', 0, 'intval'); //省id
+        $city_id = input('city_id', 0, 'intval'); //市id
+        $area_id = input('area_id', 0, 'intval'); //区id
+        $mobile = $this->request->post('mobile', '', 'trim'); //手机号
+//        $code = $this->request->post('code', '', 'trim'); //验证码
+        $idcard = input('idcard', '', 'trim'); //身份证号
+        $excel_position = input('excel_position', '', 'trim'); //擅长位置
+//        $gender = $this->request->post('gender', 0, 'intval'); //性别:1=男,2=女
+//        $invite_no = $this->request->post('invite_no', '', 'trim'); //邀请码
         $openid = $this->request->post('openid', '', 'trim'); //微信openid
         $nickname = $this->request->post('nickname', '', 'trim'); //微信昵称
         $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars'); //微信头像
@@ -1190,6 +1198,21 @@ class User extends Api
         if ($openidcount) {
             $this->error('微信已经注册,请直接登录');
         }
+        if ($realname === '' || iconv_strlen($realname, 'utf-8') > 30) {
+            $this->error('真实姓名1-30位');
+        }
+        if ($height <= 0) {
+            $this->error('请选择正确身高');
+        }
+        if ($weight <= 0) {
+            $this->error('请选择正确体重');
+        }
+        if (!$birthday || $birthday >= time()) {
+            $this->error('请选择正确生日');
+        }
+        if (!$province_id || !$city_id || !$area_id) {
+            $this->error('请选择地区');
+        }
         if (!Validate::regex($mobile, "^1\d{10}$")) {
             $this->error(__('Mobile is incorrect'));
         }
@@ -1197,25 +1220,30 @@ class User extends Api
         if ($count) {
             $this->error('手机号已被注册');
         }
-        if (iconv_strlen($code, 'utf-8') != config('alisms.length')) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $ret = Sms::check($mobile, $code, 'register');
-        if (!$ret) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        if (!$birthday || $birthday >= time()) {
-            $this->error('请选择正确生日');
-        }
-        if (!in_array($gender, [1, 2])) {
-            $this->error('请选择性别');
+//        if (iconv_strlen($code, 'utf-8') != config('alisms.length')) {
+//            $this->error(__('Captcha is incorrect'));
+//        }
+//        $ret = Sms::check($mobile, $code, 'register');
+//        if (!$ret) {
+//            $this->error(__('Captcha is incorrect'));
+//        }
+
+//        if (!in_array($gender, [1, 2])) {
+//            $this->error('请选择性别');
+//        }
+//        if ($invite_no) {
+//            $invite_info = Db::name('user')->where(['invite_no' => $invite_no])->find();
+//            if (!$invite_info) {
+//                $this->error('邀请码不存在');
+//            }
+//        }
+        if (iconv_strlen($idcard, 'utf-8') != 18) {
+            $this->error('请输入正确身份证号');
         }
-        if ($invite_no) {
-            $invite_info = Db::name('user')->where(['invite_no' => $invite_no])->find();
-            if (!$invite_info) {
-                $this->error('邀请码不存在');
-            }
+        if ($excel_position === '' || iconv_strlen($excel_position, 'utf-8') > 30) {
+            $this->error('请选择擅长位置');
         }
+
         if (!$nickname || !$avatar) {
             $this->error('参数缺失');
         }
@@ -1237,12 +1265,20 @@ class User extends Api
             'loginip'   => $ip,
             'prevtime'  => $time,
             'createtime'    => $time,
-            'gender' => $gender,
+//            'gender' => $gender,
             'birthday' => $birthday,
             'openid' => $openid,
             'invite_no' => $this->myinvite(),
             'pre_user_id' => isset($invite_info) ? $invite_info['id'] : 0,
             'invite_time' => $time,
+            'realname' => $realname,
+            'height' => $height,
+            'weight' => $weight,
+            'province_id' => $province_id,
+            'city_id' => $city_id,
+            'area_id' => $area_id,
+            'idcard' => $idcard,
+            'excel_position' => $excel_position,
         ];
 
         //开启事务
@@ -1259,65 +1295,6 @@ class User extends Api
             Db::rollback();
             $this->error('注册失败');
         }
-        //给用户发放注册优惠券
-        $register_coupon = Db::name('coupon')->where(['purpose' => 1, 'status' => 1])->order('weigh desc, id desc')->find();
-        if ($register_coupon) {
-            $register_coupon_data = [
-                'user_id' => $rs,
-                'coupon_id' => $register_coupon['id'],
-                'title' => $register_coupon['title'],
-                'desc' => $register_coupon['desc'],
-                'type' => $register_coupon['type'],
-                'money' => $register_coupon['money'],
-                'minmoney' => $register_coupon['minmoney'],
-                'purpose' => $register_coupon['purpose'],
-                'starttime' => time(),
-                'endtime' => time() + $register_coupon['effectiveday'] * 86400,
-                'createtime' => time()
-            ];
-
-            $register_coupon_rs = Db::name('user_coupon')->insertGetId($register_coupon_data);
-            if (!$register_coupon_rs) {
-                Db::rollback();
-                $this->error('注册失败');
-            }
-        }
-        //查询是否需要给上级发放优惠券
-        if (isset($invite_info)) {
-            //查询上一次获得推广优惠券时间
-            $last_coupon = Db::name('user_coupon')->where(['user_id' => $invite_info['id'], 'purpose' => 2])->order('id', 'desc')->find();
-            $last_coupon_time = $last_coupon ? $last_coupon['createtime'] : 0;
-            //获取后台配置推广获得优惠券指定人数
-            $invitepersonnum = (int)config('site.invitepersonnum');
-            //查询最新推广任务
-            $invite_count = Db::name('user')->where(['pre_user_id' => $invite_info['id'], 'createtime' => ['gt', $last_coupon_time]])->count();
-            if ($invite_count >= $invitepersonnum && $invitepersonnum > 0) {
-                //每邀请10人发放一次优惠券
-                //查询推广优惠券
-                $invite_coupon = Db::name('coupon')->where(['purpose' => 2, 'status' => 1])->order('weigh desc, id desc')->find();
-                if ($invite_coupon) {
-                    $invite_coupon_data = [
-                        'user_id' => $invite_info['id'],
-                        'coupon_id' => $invite_coupon['id'],
-                        'title' => $invite_coupon['title'],
-                        'desc' => $invite_coupon['desc'],
-                        'type' => $invite_coupon['type'],
-                        'money' => $invite_coupon['money'],
-                        'minmoney' => $invite_coupon['minmoney'],
-                        'purpose' => $invite_coupon['purpose'],
-                        'starttime' => time(),
-                        'endtime' => time() + $invite_coupon['effectiveday'] * 86400,
-                        'createtime' => time()
-                    ];
-
-                    $invite_coupon_rs = Db::name('user_coupon')->insertGetId($invite_coupon_data);
-                    if (!$invite_coupon_rs) {
-                        Db::rollback();
-                        $this->error('注册失败');
-                    }
-                }
-            }
-        }
 
         Db::commit();
 

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

@@ -26,8 +26,7 @@ class Auth
     //默认配置
     protected $config = [];
     protected $options = [];
-    protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'money', 'realname', 'gender', 'birthday', 'idcard',
-        'passport', 'emergencycontact', 'contactmobile', 'outdoorduration', 'invite_no', 'maxlevel'];
+    protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'money', 'realname', 'height', 'weight', 'gender', 'birthday', 'idcard', 'province_id', 'city_id', 'area_id', 'excel_position', 'rank_id', 'total_num', 'win_num', 'lose_num', 'power_value', 'mvp_num', 'foul_num', 'block_num', 'help_num', 'backboard_num', 'score'];
 
     public function __construct($options = [])
     {