AuctionProduct.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 AuctionProduct extends BaseModel
  16. {
  17. use ModelTrait;
  18. protected $pk = 'id';
  19. protected $name = 'auction_product';
  20. protected $autoWriteTimestamp = true;
  21. public static function list($where, $id = 0)
  22. {
  23. $model = self::alias('a')
  24. ->field('a.*,u.nickname, au.name as au_name')
  25. ->order('a.id DESC')
  26. ->where('off', 0)
  27. ->leftJoin('auction au', 'a.auction_id = au.id')
  28. ->leftJoin('user u', 'a.uid = u.uid');
  29. if ($id){
  30. $model->where('a.auction_id', $id);
  31. }
  32. if (trim(($where['store_name'])) != ''){
  33. $model->where('a.id|a.name|u.nickname', 'like','%'.$where['store_name'].'%');
  34. }
  35. if ( trim($where['is_show']) != ''){
  36. $where['is_show'] = $where['is_show'] == 2? 0: 1;
  37. $model->where('a.is_show', '=',$where['is_show']);
  38. }
  39. if (trim($where['auction_id'])) $model->where('a.auction_id', '=',$where['auction_id']);
  40. $data['count'] = $model->count();
  41. if ($where['page'] && $where['limit']){
  42. $model->page($where['page'], $where['limit']);
  43. }else{
  44. $model->page(20, 1);
  45. }
  46. $data['data'] = $model->select()->toArray();
  47. return $data;
  48. }
  49. }