<?php

namespace app\common\model;

use think\Model;

class User extends Model
{
    public $page_info;

    /**
     * 用户列表
     * @access public
     * @author csdeshang
     * @param array $condition 条件
     * @param string $field 字段
     * @param number $page 分页
     * @param string $order 排序
     * @return array
     */
    public function getUserList($condition = array(), $field = '*', $page = 0, $order = 'user_addTime desc')
    {
        if ($page) {
            $user_list = db('user')
                ->alias('a')
                ->join('userinfo b','b.user_id = a.user_id')
                ->where($condition)
                ->order($order)
                ->paginate($page, false, ['query' => request()->param()]);
            $this->page_info = $user_list;
            return $user_list->items();
        } else {
            return db('user')->where($condition)->order($order)->select();
        }
    }

    /**
     * 取单个用户
     */
    public function getMemberInfo($condition, $field = '*')
    {
        return db('member')->field($field)->where($condition)->find();
    }

}
