<?php

namespace app\admin\model\auction;

use app\models\store\StoreProduct;
use crmeb\services\SystemConfigService;
use think\facade\Db;
use crmeb\traits\ModelTrait;
use crmeb\basic\BaseModel;

/**
 * TODO 场馆model
 * Class Article
 * @package app\models\article
 */
class AuctionGu extends BaseModel
{
    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $name = 'auction_gu';
    protected $autoWriteTimestamp = true;

    use ModelTrait;

    public static function list($where)
    {
        $model = self::alias('a')
            ->field('a.*, u.nickname')
            ->order('a.id DESC')
            ->leftJoin('user u', 'u.uid = a.uid');

        if ($where['uid']) $model->where('a.uid', $where['uid']);
        if ($where['null']) $model->where('a.status', '>', 5);

        if ($where['auction'])$model->where('a.id|a.name|u.nickname' , 'like', '%'.$where['auction'],'%');
        if ($where['page'] && $where['limit']){
            $model->page($where['page'], $where['limit']);
        }else{
            $model->page(20, 1);
        }

        $data['count'] = $model->count();
        $list = $model->select();

        $list = count($list) ? $list->toArray() : [];

        $data['data'] = $list;
        return $data;

    }

}