TaskController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Http\Controllers\User;
  3. use App\Exceptions\AlertException;
  4. use App\Http\Controllers\Controller;
  5. use App\Http\Controllers\Core\Auth;
  6. use App\Services\User\TaskService;
  7. /**
  8. * 用户任务
  9. * Class TaskController
  10. * @package App\Http\Controllers\User
  11. */
  12. class TaskController extends Controller
  13. {
  14. /**
  15. * 完成任务
  16. * @param int $type
  17. * @return array
  18. * @throws AlertException
  19. */
  20. public function wcTask(int $type)
  21. {
  22. $uid = Auth::auth();
  23. if (!in_array($type, [1, 2, 3, 4, 5, 6, 7])) {
  24. throw new AlertException('参数错误');
  25. }
  26. $ts = new TaskService();
  27. $ts->task($uid, $type);
  28. return response([
  29. 'code' => 200,
  30. 'message' => 'success'
  31. ]);
  32. }
  33. /**
  34. * 获取新年小花红包
  35. */
  36. public function getYearFlower()
  37. {
  38. $uid = Auth::auth();
  39. $taskService = new TaskService();
  40. $flower = $taskService->getYearFlower($uid);
  41. return array(
  42. 'code' => 200,
  43. 'message' => 'success',
  44. 'data' => [
  45. 'red_flower' => $flower
  46. ]
  47. );
  48. }
  49. }