thinkPHP6使用

$vo['pid'] = $vo['pid'] ?? input('pid', '0');
$this->type = ltrim(input('type', 'ta'), 't');
$query->equal('status,usertype')->dateBetween('login_at,create_at');
$query->like('username,nickname,contact_phone#phone,contact_mail#mail');
$query->dateBetween('create_at')->like('title,desc')->equal('status,utype');
$query->like('name,code_1|code_3#code')->equal('status')->dateBetween('create_at');
创建时间区间查询 create_at
模糊查询 title,desc
等于查询  status,utype
$query->timeBetween('enter_time')

查询条件,并且校验
$map = $this->_vali(['auth.require#id' => '权限ID不能为空!']);

查询添加拼接
$map = [];
$map[] = ['deleted', '=', 0];
$map[] = ['code', '=', $data['code']];
$map[] = ['type', '=', $data['type']];
if (isset($data['id'])) $map[] = ['id', '<>', $data['id']];

$map = ['username' => $data['username'], 'is_deleted' => 0];
$map = ['type' => $type, 'token' => md5(uniqid(strval(rand(100, 999))))];

$data['mark'] = str2arr($data['mark'] ?? '');
$data['code'] = CodeExtend::uniqidNumber(20, 'A');

 $this->usersTotal = DataUser::mk()->cache(true, 60)->count();

 $this->days = $this->app->cache->get('portals', []);

 $this->app->cache->set('portals', $this->days, 60);

 DataUser::mk()->field('count(1) count,vip_code level')->group('vip_code')->cursor()

SystemUser 
public function index()
{
	//接受URL中的type。  admin/user.html?page=1&limit=20&type=index&output=layui.table&_order_=desc&_field_=sort+desc id

    $this->type = input('get.type', 'index');

    // 创建快捷查询工具
    SystemUser::mQuery()->layTable(function () {
        $this->title = '系统用户管理';
        //$this->bases = SystemBase::items('身份权限');
    }, function (QueryHelper $query) {

        // 加载对应数据列表 intval($this->type === 'index') =1 否则等于0
        $query->where(['is_deleted' => 0, 'status' => intval($this->type === 'index')]);

        // 关联用户身份资料
        $query->with(['userinfo' => function (Relation $relation) {
            $relation->field('code,name,content');
        }]);

        // 数据列表搜索过滤
        $query->equal('status,usertype')->dateBetween('login_at,create_at');
        $query->like('username,nickname,contact_phone#phone,contact_mail#mail');
    });
}

/**
 * 关联身份权限 在model中定义的函数
 * @return HasOne
 */
public function userinfo(): HasOne
{
    return $this->hasOne(SystemBase::class, 'code', 'usertype')->where([
        'type' => '身份权限', 'status' => 1, 'deleted' => 0,
    ]);
}


public function index()
{
    SystemOplog::mQuery()->layTable(function () {
        $this->title = '系统日志管理';
        $columns = SystemOplog::mk()->column('action,username', 'id'); //效率不是很好
        $this->users = array_unique(array_column($columns, 'username'));
        $this->actions = array_unique(array_column($columns, 'action'));
    }, function (QueryHelper $query) {
        $query->dateBetween('create_at')->equal('username,action')->like('content,geoip,node');
    });
}

if (sysdata($this->skey, $data) !== false) {
    $this->success('内容保存成功!', 'javascript:history.back()');
} else {
    $this->error('内容保存失败,请稍候再试!');
}

//多表查询
public function index()
{
    $this->title = '用户提现管理';
    $this->transfer = UserTransferService::instance()->amount(0);
    // 创建查询对象
    $query = DataUserTransfer::mQuery()->order('id desc');
    // 用户条件搜索
    $db = DataUser::mQuery()->like('phone,username|nickname#nickname')->db();
    if ($db->getOptions('where')) $query->whereRaw("uuid in {$db->field('id')->buildSql()}");
    // 数据列表处理
    $query->equal('type,status')->dateBetween('create_at')->page();
}

/**
 * 得到某个列的数组
 * @access public
 * @param string|array $field 字段名 多个字段用逗号分隔
 * @param string       $key   索引
 * @return array
 */
public function column($field, string $key = ''): array
{
    $result = $this->connection->column($this, $field, $key);

    if (count($result) != count($result, 1)) {
        $this->resultSet($result, false);
    }

    return $result;
}


// 商品销量统计
$query = ShopOrder::mk()->alias('a')->field('b.goods_code,b.goods_spec,ifnull(sum(b.stock_sales),0) stock_sales');
$query->leftJoin('shop_order_item b', 'a.order_no=b.order_no')->where("b.goods_code='{$code}' and a.status>0 and a.deleted_status<1");
$salesList = $query->group('b.goods_code,b.goods_spec')->select()->toArray();

$query = ShopOrder::mk()->alias('a')->join('shop_order_item b', 'a.order_no=b.order_no');
$entry = $query->where("a.uuid={$uuid} and a.status>=4 and a.payment_status=1 and b.vip_entry>0")->count() ? 1 : 0;

$query = ShopOrderItem::mk()->where(['status' => 1, 'deleted' => 0]);
$items = $query->withoutField('id,uuid,status,deleted,create_at')->whereIn('order_no', $nobs)->select()->toArray();

$encode = md5(md5($this->password) . ($tkey = time()));
$option = ['headers' => ['Content-Type:application/json;charset=UTF-8']];
$request = json_encode(array_merge($data, ['username' => $this->username, 'password' => $encode, 'tKey' => $tkey]));
$result = json_decode(http_post("https://api.mix2.zthysms.com/{$url}", $request, $option), true);



$cache = $this->app->cache->get(md5("code-{$tplcode}-{$phone}"), []);
return is_array($cache) && isset($cache['code']) && $cache['code'] == $code;