Task.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\store\controller\apps\bargain;
  3. use app\store\controller\Controller;
  4. use app\store\model\bargain\Task as TaskModel;
  5. use app\store\model\bargain\TaskHelp as TaskHelpModel;
  6. /**
  7. * 砍价任务管理
  8. * Class Task
  9. * @package app\store\controller\apps\bargain
  10. */
  11. class Task extends Controller
  12. {
  13. /**
  14. * 砍价任务列表
  15. * @param string $search
  16. * @return mixed
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\ModelNotFoundException
  19. * @throws \think\exception\DbException
  20. */
  21. public function index($search = '')
  22. {
  23. $model = new TaskModel;
  24. $list = $model->getList($search);
  25. return $this->fetch('index', compact('list'));
  26. }
  27. /**
  28. * 砍价榜
  29. * @param $task_id
  30. * @return mixed
  31. * @throws \think\exception\DbException
  32. */
  33. public function help($task_id)
  34. {
  35. $model = new TaskHelpModel;
  36. $list = $model->getList($task_id);
  37. return $this->fetch('help', compact('list'));
  38. }
  39. /**
  40. * 删除砍价任务
  41. * @param $task_id
  42. * @return array
  43. * @throws \think\exception\DbException
  44. */
  45. public function delete($task_id)
  46. {
  47. // 砍价活动详情
  48. $model = TaskModel::detail($task_id);
  49. if (!$model->setDelete()) {
  50. return $this->renderError($model->getError() ?: '删除失败');
  51. }
  52. return $this->renderSuccess('删除成功');
  53. }
  54. }