Commit f81cb015 authored by zhuwei's avatar zhuwei

bug

parent 4e889a49
...@@ -150,6 +150,7 @@ class User extends Basic ...@@ -150,6 +150,7 @@ class User extends Basic
{ {
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$params = $this->params; $params = $this->params;
$this->city='上海市';
/*$params = array( /*$params = array(
"user_id" => 3, "user_id" => 3,
"agent_id" => 9, "agent_id" => 9,
...@@ -165,13 +166,16 @@ class User extends Basic ...@@ -165,13 +166,16 @@ class User extends Basic
$where['city'] = trim($this->city); $where['city'] = trim($this->city);
if ($params['type'] == 'last'){ if ($params['type'] == 'last'){
$where['id'] = ['gt',$params['user_id']]; $where['id'] = ['gt',$params['user_id']];
$order = 'id asc';
}else{ }else{
$where['id'] = ['lt',$params['user_id']]; $where['id'] = ['lt',$params['user_id']];
$order = 'id desc';
} }
//dump($where); //dump($where);
$field = 'id,user_nick,agent_id,vip'; $field = 'id,user_nick,agent_id,vip';
$user = new Users(); $user = new Users();
$user_res = $user->getLastOrNextUserID($where,$field,$limit=1); $user_res = $user->getLastOrNextUserID($where,$field,$limit=1,$order);
if(!$user_res){ if(!$user_res){
return $this->response("200", "不符合条件0", []); return $this->response("200", "不符合条件0", []);
} }
...@@ -191,9 +195,10 @@ class User extends Basic ...@@ -191,9 +195,10 @@ class User extends Basic
$where = []; $where = [];
$where['city'] = trim($this->city); $where['city'] = trim($this->city);
$field = 'max(id) as max_id'; $field = 'max(id) as max_id';
$max_id = $user->getLastOrNextUserID($where,$field,$limit=''); $order = 'id asc';
$max_id = $user->getLastOrNextUserID($where,$field,$limit='',$order);
$field = 'MIN(id) as min_id'; $field = 'MIN(id) as min_id';
$min_id = $user->getLastOrNextUserID($where,$field,$limit=''); $min_id = $user->getLastOrNextUserID($where,$field,$limit='',$order);
return $this->response("200", "success!", [ return $this->response("200", "success!", [
'user_id'=>$user_res[0]['id'], 'user_id'=>$user_res[0]['id'],
'max_user_id'=>$max_id[0]['max_id'], 'max_user_id'=>$max_id[0]['max_id'],
......
...@@ -748,14 +748,14 @@ class Users extends Model ...@@ -748,14 +748,14 @@ class Users extends Model
} }
public function getLastOrNextUserID($where,$field,$limit) public function getLastOrNextUserID($where,$field,$limit,$order)
{ {
$return = Db::name($this->table) $return = Db::name($this->table)
->field($field) ->field($field)
->where($where) ->where($where)
->limit($limit) ->limit($limit)
->order('id asc') ->order($order)
->select(); ->select();
//dump($this->getLastSql()); //dump($this->getLastSql());
return $return; return $return;
......
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