12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- /**
- *
- * @author: xaboy<365615158@qq.com>
- * @day: 2017/11/02
- */
- namespace app\admin\model\auction;
- use app\models\auction\AuctionTime;
- use crmeb\traits\ModelTrait;
- use crmeb\basic\BaseModel;
- /**
- * 竞拍上坪 Model
- * Class WechatNews
- * @package app\admin\model\wechat
- */
- class AuctionProduct extends BaseModel
- {
- use ModelTrait;
- protected $pk = 'id';
- protected $name = 'auction_product';
- protected $autoWriteTimestamp = true;
- 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;
- }
- }
|