<?php

/**
 *
 * @author: xaboy<365615158@qq.com>
 * @day: 2017/11/02
 */

namespace app\admin\model\auction;

use crmeb\traits\ModelTrait;
use crmeb\basic\BaseModel;

/**
 * 预约 Model
 * Class WechatNews
 * @package app\admin\model\wechat
 */
class AuctionBooking extends BaseModel
{

    use ModelTrait;

    protected $pk = 'id';

    protected $name = 'auction_booking';
    protected $autoWriteTimestamp = true;


    public static function list($where)
    {
        $model = self::where('a.delete_time', 0)
            ->alias('a')
            ->order('a.id', 'desc')
            ->field('a.*, au.nickname as name, u.account, u.nickname')
            ->leftJoin('auction au', 'a.auction_id = au.id')
            ->leftJoin('user u', 'a.uid = u.uid');



        if (trim($where['store_name']) != '') $model->where('a.id|u.account|u.nickname', 'like', '%'.$where['store_name'].'%');
        if (trim($where['auction_id']) != '') $model->where('a.auction_id', $where['auction_id']);
        if (trim($where['data']) != '') $model = self::getModelTime($where, $model,  'create_time');

        if ($where['page'] && $where['limit']){
            $model->page($where['page'], $where['limit']);
        }else{
            $model->page(20, 1);
        }

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

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

    }





}