Auction.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.*, gu.name')
  24. ->order('a.id DESC')
  25. ->leftJoin('auction_gu gu', 'a.auction_gu_id = gu.id');
  26. $model->where(['a.delete_time' => 0]);
  27. if ($where['auction'])$model->where('a.id|a.nickname' , 'like', '%'.$where['auction'],'%');
  28. if ($where['auction_id'])$model->where('gu.id' , $where['auction_id']);
  29. if ($where['page'] && $where['limit']){
  30. $model->page($where['page'], $where['limit']);
  31. }else{
  32. $model->page(20, 1);
  33. }
  34. if ($where['uid']){
  35. $auctionGu = AuctionGu::where('uid', $where['uid'])->column('id');
  36. $model->where('a.auction_gu_id', 'in', $auctionGu);
  37. }
  38. $data['count'] = $model->count();
  39. $list = $model->select()->toArray();
  40. $day = strtotime(date('Y-m-d'));
  41. $tomorrow = strtotime(date('Y-m-d', strtotime('+1 day')));
  42. foreach ($list as $k => $v){
  43. $list[$k]['b_count'] = AuctionBooking::where([['create_time', '>=', $day], ['create_time', '<=', $tomorrow], ['auction_id', '=', $list[$k]['id']]])->count();
  44. // $list[$k]['u_count'] = AuctionBooking::alias('a')
  45. // ->leftJoin('user u', 'a.uid = u.uid')
  46. // ->whereOr('u.is_new', 1)
  47. // ->whereOr([['green_time', '>=', $day], ['green_time', '<=', $tomorrow]])
  48. // ->where([['date', '>=', $day], ['date', '<=', $tomorrow], ['a.auction_id', '=', $list[$k]['id']]])->count();
  49. }
  50. $data['data'] = $list;
  51. return $data;
  52. }
  53. }