* @day: 2017/11/02 */ namespace app\admin\model\auction; use app\models\auction\AuctionTime; use crmeb\traits\ModelTrait; use crmeb\basic\BaseModel; use think\model\concern\SoftDelete; /** * 竞拍上坪 Model * Class WechatNews * @package app\admin\model\wechat */ class AuctionProduct extends BaseModel { use ModelTrait; use SoftDelete; protected $pk = 'id'; protected $name = 'auction_product'; protected $autoWriteTimestamp = true; protected $deleteTime = 'delete_time'; public static function list($where, $id = 0) { $model = self::alias('a') ->field('a.*,u.nickname, au.nickname as au_name') ->order('a.id DESC') ->leftJoin('auction au', 'a.auction_id = au.id') ->leftJoin('user u', 'a.uid = u.uid'); if (!empty($id)) { $model->where('a.auction_id', '=',$id); } if (trim($where['auction_id']) != '') { $model->where('a.auction_id', '=',$where['auction_id']); } if (trim(($where['store_name'])) != ''){ $model->where('a.id|a.name|u.nickname', 'like','%'.$where['store_name'].'%'); } if ( trim($where['is_show']) != ''){ $where['is_show'] = $where['is_show'] == 2? 0: 1; $model->where('a.is_show', '=',$where['is_show']); } $data['count'] = $model->count(); if ($where['page'] && $where['limit']){ $model->page($where['page'], $where['limit']); }else{ $model->page(20, 1); } $data['data'] = $model->select()->toArray(); foreach ($data['data'] as $k => $v) { if ($v['is_admin'] == 2){ $time = AuctionTime::where('product_id', $v['id'])->find(); if ($time){ $data['data'][$k]['time'] = date('Y-m-d', $time['add_time']); }else{ $data['data'][$k]['time'] = '未上架'; } }else{ $data['data'][$k]['time'] = date('Y-m-d', time()); } } return $data; } }