diff --git a/app/user/controller/User.php b/app/user/controller/User.php new file mode 100644 index 0000000..a1578d3 --- /dev/null +++ b/app/user/controller/User.php @@ -0,0 +1,103 @@ +getListPage([], '*', 'id desc', "$page,50"); + + foreach ($user_list as &$info){ + $info['Password'] = ''; + if(empty($info['id_code'])){ + $info['is_verify'] = '未认证'; + } else { + $info['id_code'] = substr($info['id_code'], 0, 6) . '***'; + $info['is_verify'] = $info['is_verify']?'认证成功':'认证失败'; + } + + } + $data = [ + 'Code' => 10000, + 'Data' => $user_list, + 'Message' => '', + 'TotalCount' => 10000, + ]; + echo json_encode($data); + } + + //添加会员 + public function addUser() + { + $data = json_decode(file_get_contents("php://input"), true); + $data['LoginCode'] = trim($data['LoginCode']); + + if(empty($data['LoginCode'])){ + $info = [ + 'Code' => 10003, + 'Data' => '', + 'Message' => '账号为空', + ]; + echo json_encode($info); + die; + } + + $data['TenantId'] = 0; + $data['Enabled'] = 1; + $data['UpdateTime'] = date('Y-m-d H:i:s',time()); + $data['CreateTime'] = date('Y-m-d H:i:s',time()); + $data['CreateType'] = 1; + $data['ProductAccountCount'] = 0; + $data['ExpiredProductAccountCount'] = 0; + $data['RestAmount'] = 0; + $data['ConsumeAmount'] = 0; + $data['DeleteTag'] = 0; + $data['UseTestCount'] = 0; + $data['LastLoginDate'] = date('Y-m-d H:i:s',time()); + $data['Password'] = empty($data['Password'])?cToMd5('1234'):cToMd5(trim($data['Password'])); + + $user_model = new UserModel; + $manager_list = $user_model->getManagerList([],'ManagerId,ManagerName,count(1) as num',['ManagerId'],'num asc'); + $data['ManagerId'] = $manager_list[0]['ManagerId']; + $data['ManagerName'] = $manager_list[0]['ManagerName']; + + $has_user = $user_model->isExit("LoginCode='".$data['LoginCode']."' or Phone='".$data['Phone']."' or TaoBao='".$data['Phone']."'"); + if ($has_user){ + $info = [ + 'Code' => 10007, + 'Data' => '', + 'Message' => '该账号或者手机号被注册了', + ]; + echo json_encode($info); + die; + } + + if ($user_model->add($data)) { + $info = [ + 'Code' => 10000, + 'Data' => '', + 'Message' => '', + ]; + echo json_encode($info); + die; + } + die; + } + + //设置测试数 + public function testCount() + { + $data = json_decode(file_get_contents("php://input"), true); + } +} diff --git a/app/user/model/Manager.php b/app/user/model/Manager.php new file mode 100644 index 0000000..d38b722 --- /dev/null +++ b/app/user/model/Manager.php @@ -0,0 +1,10 @@ +field($fields)->where($where)->group($group)->order($order)->fetchAll(); + } + + //用户是否存在 + public function isExit($where = '', $fields = '*') + { + return $this->field($fields)->where($where)->fetch(); + } +} \ No newline at end of file diff --git a/fastphp/func/common.php b/fastphp/func/common.php index 9449bcc..ec2f18a 100644 --- a/fastphp/func/common.php +++ b/fastphp/func/common.php @@ -183,4 +183,16 @@ function linkcurl($url,$method,$params=false,$header=false){ curl_close( $ch ); return $response; } - \ No newline at end of file + + +//将utf-8字符串转换成字节 +function cToMd5($str){ + $md5hex=md5($str); + $len=strlen($md5hex)/2; + $md5raw=""; + for($i=0;$i<$len;$i++) { + $md5raw=$md5raw . chr(hexdec(substr($md5hex,$i*2,2))); + } + $keyMd5=base64_encode($md5raw); + return $keyMd5; +} \ No newline at end of file