Active.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\api\model\plus\bargain;
  3. use app\common\model\plus\bargain\Active as ActiveModel;
  4. /**
  5. * 砍价模型
  6. */
  7. class Active extends ActiveModel
  8. {
  9. /**
  10. *列表
  11. */
  12. public function bargainList($param = null)
  13. {
  14. return $this->where('is_delete', '=', 0)->select();
  15. }
  16. /**
  17. * 获取砍价活动详情
  18. */
  19. public function getDetail($activeId)
  20. {
  21. $model = static::detail($activeId, 'product.sku');
  22. if (empty($model) || $model['is_delete'] == true || $model['status'] == false) {
  23. $this->error = '很抱歉,该砍价商品不存在或已下架';
  24. return false;
  25. }
  26. return $model;
  27. }
  28. /**
  29. * 取最近要结束的一条记录
  30. */
  31. public static function getActive()
  32. {
  33. return (new static())->where('start_time', '<', time())
  34. ->where('end_time', '>', time())
  35. ->where('status', '=', 1)
  36. ->where('is_delete', '=', 0)
  37. ->order(['sort' => 'asc', 'create_time' => 'asc'])
  38. ->find();
  39. }
  40. /**
  41. * 获取砍价商品列表
  42. */
  43. public function activityList()
  44. {
  45. return $this->where('start_time', '<=', time())
  46. ->where('end_time', '>=', time())
  47. ->where('status', '=', 1)
  48. ->where('is_delete', '=', 0)
  49. ->order(['sort' => 'asc', 'create_time' => 'asc'])
  50. ->select();
  51. }
  52. }