Commit 2dd85350 authored by hujun's avatar hujun

通过手机号搜索推荐人

parent 62d37372
...@@ -52,7 +52,8 @@ class Member extends Basic{ ...@@ -52,7 +52,8 @@ class Member extends Basic{
} }
if (!empty($params['invite'])) { if (!empty($params['invite'])) {
$where['phone'] = $params['invite']; $where['user_phone'] = ['like', $params['invite'].'%'];
$where['invite'] = 1;
} }
if (!empty($params['id'])) { if (!empty($params['id'])) {
...@@ -60,7 +61,7 @@ class Member extends Basic{ ...@@ -60,7 +61,7 @@ class Member extends Basic{
} }
$fields = 'a.id,a.user_nick,a.user_phone,a.user_pic,a.create_time,a.user_pswd,a.referrer_id,a.referrer_source'; $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['list'] = $this->user->getUserAgent($pageNo, $pageSize, 'a.id DESC', $fields, $where);
$data['total'] = $this->user->getUserAgentTotal($where); $data['total'] = $this->user->getUserAgentTotal($where);
return $this->response($data['status'], $data['msg'], $data); return $this->response($data['status'], $data['msg'], $data);
} }
......
...@@ -47,12 +47,16 @@ class Users extends Model ...@@ -47,12 +47,16 @@ class Users extends Model
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getUserAgent($pageNo = 1, $pageSize = 15, $order_ = 'a.id desc', $fields = '*', $params = '') { public function getUserAgent($pageNo = 1, $pageSize = 15, $order_ = 'a.id desc', $fields = '*', $params = '') {
$data = array(); $data = array();
if ($params['phone']) { if ($params['invite']) {
unset($params['invite']);
$id = $this->field('id')->where('user_phone','LIKE',$params['user_phone']['1'].'%')->find();
unset($params['user_phone']);
$result = $this->field($fields) $result = $this->field($fields)
->alias('a') ->alias('a')
->join('agents b','a.referrer_id=b.id','left')
->where($params) ->where($params)
->where('referrer_id','=',$id->id)
->order($order_) ->order($order_)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
...@@ -97,10 +101,13 @@ class Users extends Model ...@@ -97,10 +101,13 @@ class Users extends Model
* @return mixed * @return mixed
*/ */
public function getUserAgentTotal($params) { public function getUserAgentTotal($params) {
if ($params['phone']) { if ($params['invite']) {
unset($params['invite']);
$id = $this->field('id')->where('user_phone','LIKE',$params['user_phone']['1'].'%')->find();
unset($params['user_phone']);
$result = $this->alias('a') $result = $this->alias('a')
->join('agents b','a.referrer_id=b.id','left')
->where($params) ->where($params)
->where('referrer_id','=',$id->id)
->count(); ->count();
} else { } else {
$result = $this->alias('a') $result = $this->alias('a')
......
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