AuctionProduct.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. if ($v['is_admin'] == 2){
  52. $time = AuctionTime::where('product_id', $v['id'])->find();
  53. if ($time){
  54. $data['data'][$k]['time'] = date('Y-m-d', $time['add_time']);
  55. }else{
  56. $data['data'][$k]['time'] = '未上架';
  57. }
  58. }else{
  59. $data['data'][$k]['time'] = date('Y-m-d', time());
  60. }
  61. }
  62. return $data;
  63. }
  64. }