Task.php 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\task\model\bargain;
  3. use app\common\model\bargain\Task as TaskModel;
  4. /**
  5. * 砍价任务模型
  6. * Class Task
  7. * @package app\api\model\bargain
  8. */
  9. class Task extends TaskModel
  10. {
  11. /**
  12. * 获取已过期但未结束的砍价任务
  13. * @return false|\PDOStatement|string|\think\Collection
  14. * @throws \think\db\exception\DataNotFoundException
  15. * @throws \think\db\exception\ModelNotFoundException
  16. * @throws \think\exception\DbException
  17. */
  18. public function getEndList()
  19. {
  20. return $this->where('end_time', '<=', time())
  21. ->where('status', '=', 1)
  22. ->where('is_delete', '=', 0)
  23. ->select();
  24. }
  25. /**
  26. * 将砍价任务标记为已结束(批量)
  27. * @param $taskIds
  28. * @return false|int
  29. */
  30. public function setIsEnd($taskIds)
  31. {
  32. return $this->isUpdate(true)->save([
  33. 'status' => 0
  34. ], ['task_id' => ['in', $taskIds]]);
  35. }
  36. }