AuctionProduct.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. $model->page($data['page'], $data['limit']);
  33. $list = $model->select()->toArray();
  34. if ($list){
  35. foreach ($list as $k => $v) {
  36. $order = AuctionOrder::where('product_id', $v['id'])->where('status', '>', 0)->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();
  37. if ($order){
  38. $list[$k]['status'] = 2;// 已被购买
  39. $list[$k]['str'] = '已卖完';
  40. }else{
  41. $list[$k]['status'] = 1;// 能购买
  42. $list[$k]['str'] = '购买';
  43. }
  44. }
  45. }
  46. return $list;
  47. }
  48. /**
  49. * 用户商品
  50. * @param $data
  51. * @param $uid
  52. * @return array
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. */
  57. public static function user_product($data, $uid){
  58. $model = self::where('is_show', 1)->where('uid', $uid)->order('sort DESC,id DESC');
  59. $model->page($data['page'], $data['limit']);
  60. $list = $model->select()->toArray();
  61. return $list;
  62. }
  63. }