Auction.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/02
  6. */
  7. namespace app\admin\model\auction;
  8. use crmeb\traits\ModelTrait;
  9. use crmeb\basic\BaseModel;
  10. /**
  11. * 场馆 Model
  12. * Class WechatNews
  13. * @package app\admin\model\wechat
  14. */
  15. class Auction extends BaseModel
  16. {
  17. use ModelTrait;
  18. protected $pk = 'id';
  19. protected $name = 'auction';
  20. public static function list($where)
  21. {
  22. $model = self::alias('a')
  23. ->field('a.*')
  24. ->order('id DESC');
  25. $model->where(['a.delete_time' => 0]);
  26. if ($where['auction'])$model->where('a.id|a.name' , 'like', '%'.$where['auction'],'%');
  27. $data['count'] = $model->count();
  28. if ($where['page'] && $where['limit']){
  29. $model->page($where['page'], $where['limit']);
  30. }else{
  31. $model->page(20, 1);
  32. }
  33. $list = $model->select()->toArray();
  34. $day = strtotime(date('Y-m-d'));
  35. $tomorrow = strtotime(date('Y-m-d', strtotime('+1 day')));
  36. foreach ($list as $k => $v){
  37. $list[$k]['b_count'] = AuctionBooking::where([['create_time', '>=', $day], ['create_time', '<=', $tomorrow], ['auction_id', '=', $list[$k]['id']]])->count();
  38. // $list[$k]['u_count'] = AuctionBooking::alias('a')
  39. // ->leftJoin('user u', 'a.uid = u.uid')
  40. // ->whereOr('u.is_new', 1)
  41. // ->whereOr([['green_time', '>=', $day], ['green_time', '<=', $tomorrow]])
  42. // ->where([['date', '>=', $day], ['date', '<=', $tomorrow], ['a.auction_id', '=', $list[$k]['id']]])->count();
  43. }
  44. $data['data'] = $list;
  45. return $data;
  46. }
  47. }