* @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 Auction extends BaseModel { use ModelTrait; protected $pk = 'id'; protected $name = 'auction'; public static function list($where) { $model = self::alias('a') ->field('a.*') ->order('id DESC'); $model->where(['a.delete_time' => 0]); if ($where['auction'])$model->where('a.id|a.name' , 'like', '%'.$where['auction'],'%'); $data['count'] = $model->count(); if ($where['page'] && $where['limit']){ $model->page($where['page'], $where['limit']); }else{ $model->page(20, 1); } $list = $model->select()->toArray(); $day = strtotime(date('Y-m-d')); $tomorrow = strtotime(date('Y-m-d', strtotime('+1 day'))); foreach ($list as $k => $v){ $list[$k]['b_count'] = AuctionBooking::where([['create_time', '>=', $day], ['create_time', '<=', $tomorrow], ['auction_id', '=', $list[$k]['id']]])->count(); // $list[$k]['u_count'] = AuctionBooking::alias('a') // ->leftJoin('user u', 'a.uid = u.uid') // ->whereOr('u.is_new', 1) // ->whereOr([['green_time', '>=', $day], ['green_time', '<=', $tomorrow]]) // ->where([['date', '>=', $day], ['date', '<=', $tomorrow], ['a.auction_id', '=', $list[$k]['id']]])->count(); } $data['data'] = $list; return $data; } }