123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?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;
- 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;
- }
- }
|