后台用户管理界面
This commit is contained in:
103
app/user/controller/User.php
Normal file
103
app/user/controller/User.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace app\user\controller;
|
||||
|
||||
use app\user\model\User as UserModel;
|
||||
use app\user\model\Manager as ManagerModel;
|
||||
use fastphp\base\Controller;
|
||||
|
||||
class User extends Controller
|
||||
{
|
||||
//获取列表
|
||||
public function getList ()
|
||||
{
|
||||
$page = 0;
|
||||
if (isset($_GET['PageIndex'])) {
|
||||
$page = ($_GET['PageIndex'] - 1) * 50;
|
||||
}
|
||||
$user_model = new UserModel;
|
||||
$user_list = $user_model->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);
|
||||
}
|
||||
}
|
||||
10
app/user/model/Manager.php
Normal file
10
app/user/model/Manager.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\user\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class manager extends Model
|
||||
{
|
||||
protected $table = 'manager';
|
||||
}
|
||||
22
app/user/model/User.php
Normal file
22
app/user/model/User.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\user\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
protected $table = 'user';
|
||||
|
||||
//获取客户经理相关信息
|
||||
public function getManagerList($where = [],$fields = '*', $group = [], $order = '')
|
||||
{
|
||||
return $this->field($fields)->where($where)->group($group)->order($order)->fetchAll();
|
||||
}
|
||||
|
||||
//用户是否存在
|
||||
public function isExit($where = '', $fields = '*')
|
||||
{
|
||||
return $this->field($fields)->where($where)->fetch();
|
||||
}
|
||||
}
|
||||
@@ -183,4 +183,16 @@ function linkcurl($url,$method,$params=false,$header=false){
|
||||
curl_close( $ch );
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//将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;
|
||||
}
|
||||
Reference in New Issue
Block a user