AuctionProduct.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/02
  6. */
  7. namespace app\models\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. /**
  22. * 竞拍商品列表
  23. * @param $data
  24. * @param $uid
  25. * @return array
  26. * @throws \think\db\exception\DataNotFoundException
  27. * @throws \think\db\exception\DbException
  28. * @throws \think\db\exception\ModelNotFoundException
  29. */
  30. public static function list($data, $uid){
  31. $model = self::where('is_show', 1)->where('auction_id', $data['id'])->order('sort DESC,id DESC');
  32. if ($data['user']){
  33. $model->where('uid', $uid); // 获取用户拥有商品
  34. }
  35. $list = $model->select()->toArray();
  36. if (!$data['user']){
  37. if ($list){
  38. foreach ($list as $k => $v) {
  39. $order = AuctionOrder::where('product_id', $v['id'])->whereBetweenTime('create_time', date('Y-m-d H:i:s', strtotime(date('Y-m-d'))), date('Y-m-d H:i:s', strtotime('+1 day')))->find();
  40. if ($order){
  41. $list[$k]['status'] = 2;// 已被购买
  42. $list[$k]['str'] = '已卖完';
  43. }else{
  44. $list[$k]['status'] = 1;// 能购买
  45. $list[$k]['str'] = '购买';
  46. }
  47. }
  48. }
  49. }
  50. return $list;
  51. }
  52. }