Commit e3905337 authored by clone's avatar clone

Merge remote-tracking branch 'remotes/origin/test'

parents d1cdc3f1 6aa9b1d2
......@@ -24,7 +24,15 @@ class Member extends Basic{
public function index() {
return view('member/users_list');
}
/**
* 用户列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUserList() {
$data['status'] = 200;
$data['msg'] = '';
......@@ -36,21 +44,22 @@ class Member extends Basic{
$where['status'] = 0;
if (!empty($params['name'])) {
$where['user_nick'] = ['like', '%'.$params['name'].'%'];
$where['a.user_nick'] = ['like', $params['name'].'%'];
}
if (!empty($params['phone'])) {
$where['user_phone'] = ['like', '%'.$params['phone'].'%'];
$where['user_phone'] = ['like', $params['phone'].'%'];
}
if (!empty($params['invite'])) {
$where['phone'] = ['like', '%'.$params['invite'].'%'];
$where['phone'] = $params['invite'];
}
if (!empty($params['id'])) {
$where['id'] = $params['id'];
$where['a.id'] = $params['id'];
}
$fields = 'id,user_nick,user_phone,user_pic,create_time,user_pswd,referrer_id';
$fields = 'a.id,a.user_nick,a.user_phone,a.user_pic,a.create_time,a.user_pswd,a.referrer_id,a.referrer_source';
$data['list'] = $this->user->getUserAgent($pageNo, $pageSize, '', $fields, $where);
$data['total'] = $this->user->getUserAgentTotal($where);
return $this->response($data['status'], $data['msg'], $data);
......
......@@ -10,6 +10,16 @@ class Users extends Model
// 设置当前模型对应的完整数据表名称
protected $table = 'u_users';
/**
* 查询用户
*
* @param $userId
* @param string $fields
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectUser($userId, $fields = 'id,user_phone')
{
$param["status"] = array( "eq", 0 );
......@@ -22,38 +32,62 @@ class Users extends Model
}
return $data;
}
/**
* 查询用户和经纪人
*
* @param type $pageNo
* @param type $pageSize
* @param type $order_
* @param type $fields
* @param type $params
* @return type
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $fields
* @param string $params
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUserAgent($pageNo = 1, $pageSize = 15, $order_ = 'a.id desc', $fields = '*', $params = '') {
$result = $this->field($fields)
$data = array();
if ($params['phone']) {
$result = $this->field($fields)
->alias('a')
->join('agents b','a.referrer_id=b.id','left')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
} else {
$result = $this->field($fields)->alias('a')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
$agents = new Agents();
foreach ($result as $k=>$v) {
$data[$k] = $v->getData();
if ($data[$k]['user_pic']) {
$data[$k]['user_pic'] = CURRENT_URL.'static/head_portrait/'.$data[$k]['user_pic'];
} else {
$data[$k]['user_pic'] = '';
}
$agent_data = $agents->field('realname,phone')->where('id',$data[$k]['referrer_id'])->find();
$data[$k]['realname'] = $agent_data['realname'];
$data[$k]['phone'] = $agent_data['phone'];
//判断来源
if ($data[$k]['referrer_source'] == 10) {
$user_data = $this->field('id,user_nick,user_phone')->where('id',$data[$k]['referrer_id'])->find();
$data[$k]['realname'] = $user_data->user_nick;
$data[$k]['phone'] = $user_data->user_phone;
} else {
$agent_data = $agents->field('realname,phone')->where('id',$data[$k]['referrer_id'])->find();
$data[$k]['realname'] = $agent_data->realname;
$data[$k]['phone'] = $agent_data->phone;
}
}
return $data;
return $data;
}
/**
......@@ -63,7 +97,16 @@ class Users extends Model
* @return mixed
*/
public function getUserAgentTotal($params) {
$result = $this->where($params)->count();
if ($params['phone']) {
$result = $this->alias('a')
->join('agents b','a.referrer_id=b.id','left')
->where($params)
->count();
} else {
$result = $this->alias('a')
->where($params)
->count();
}
return $result;
}
......
*
!.gitignore
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment