AuctionProduct.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/02
  6. */
  7. namespace app\admin\model\auction;
  8. use app\models\auction\AuctionTime;
  9. use crmeb\traits\ModelTrait;
  10. use crmeb\basic\BaseModel;
  11. /**
  12. * 竞拍上坪 Model
  13. * Class WechatNews
  14. * @package app\admin\model\wechat
  15. */
  16. class AuctionProduct extends BaseModel
  17. {
  18. use ModelTrait;
  19. protected $pk = 'id';
  20. protected $name = 'auction_product';
  21. protected $autoWriteTimestamp = true;
  22. public static function list($where, $id = 0)
  23. {
  24. $model = self::alias('a')
  25. ->field('a.*,u.nickname, au.nickname as au_name')
  26. ->order('a.id DESC')
  27. ->leftJoin('auction au', 'a.auction_id = au.id')
  28. ->leftJoin('user u', 'a.uid = u.uid');
  29. if (!empty($id)) {
  30. $model->where('a.auction_id', '=',$id);
  31. }
  32. if (trim($where['auction_id']) != '') {
  33. $model->where('a.auction_id', '=',$where['auction_id']);
  34. }
  35. if (trim(($where['store_name'])) != ''){
  36. $model->where('a.id|a.name|u.nickname', 'like','%'.$where['store_name'].'%');
  37. }
  38. if ( trim($where['is_show']) != ''){
  39. $where['is_show'] = $where['is_show'] == 2? 0: 1;
  40. $model->where('a.is_show', '=',$where['is_show']);
  41. }
  42. $data['count'] = $model->count();
  43. if ($where['page'] && $where['limit']){
  44. $model->page($where['page'], $where['limit']);
  45. }else{
  46. $model->page(20, 1);
  47. }
  48. $data['data'] = $model->select()->toArray();
  49. foreach ($data['data'] as $k => $v)
  50. {
  51. $time = AuctionTime::where('product_id', $v['id'])->find();
  52. if ($time){
  53. $data['data'][$k]['time'] = date('Y-m-d', $time['add_time']);
  54. }else{
  55. $data['data'][$k]['time'] = '未上架';
  56. }
  57. }
  58. return $data;
  59. }
  60. }