Task.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\controller\admin;
  3. use app\extra\basic\Base;
  4. use app\extra\tools\XcJob;
  5. use app\middleware\AuthMiddleware;
  6. use LinFly\Annotation\Route\Controller;
  7. use LinFly\Annotation\Route\Middleware;
  8. use LinFly\Annotation\Route\Route;
  9. use support\Request;
  10. use support\Response;
  11. #[Controller(prefix: "/api/task"),Middleware(AuthMiddleware::class)]
  12. class Task extends Base
  13. {
  14. /**
  15. * 获取星川任务详情
  16. * @param Request $request
  17. * @return Response
  18. */
  19. #[Route(path: "job",methods: "get")]
  20. public function getJobDetail(Request $request): Response
  21. {
  22. try {
  23. $param = $this->_valid([
  24. "job_id.require" => trans("empty.require")
  25. ]);
  26. if (!is_array($param)) return error($param);
  27. $data = (new XcJob)->token()->getJobDetail($param['job_id']);
  28. if ($data['base_resp']['status_code'] <> 0) return error("获取任务失败");
  29. $task = [
  30. "expiration_time_end" => date("Y-m-d H:i:s",$data['object_field_info']['object_basic_info']['expiration_time_end']),
  31. "title" => $data['object_field_info']['object_basic_info']['object_name']??'',
  32. "product_cover_url" => $data['object_field_info']['object_product_info']['product_cover_url']??'',
  33. "product_name" => $data['object_field_info']['object_product_info']['product_name']??'',
  34. "product_id" => $data['object_field_info']['object_product_info']['external_product_id']??'',
  35. "auto" => 2,
  36. "job_id" => $param['job_id'],
  37. "category" => "douyin",
  38. "category_detail" => $data['object_field_info']['object_product_info']['category_detail']['second_cname']??'',
  39. "product_selling_point" => $data['object_field_info']['object_product_info']['product_selling_point_detail']??'',
  40. "target_audience" => $data['object_field_info']['object_product_info']['target_audience_desc']??'',
  41. "content" => $data['object_field_info']['object_requirement_info']['author_preference']?nl2br($data['object_field_info']['object_requirement_info']['author_preference']):'',
  42. "total_budget" => $data['object_field_info']['object_project_info']['total_budget_fen']?format_money_bit($data['object_field_info']['object_project_info']['total_budget_fen']/100):'',
  43. ];
  44. return success("ok",$task);
  45. } catch (\Throwable $throwable) {
  46. return error($throwable->getMessage());
  47. }
  48. }
  49. }