Task.php 1.6 KB

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