TaskCompletedEvent.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Module\Task\Events;
  3. /**
  4. * 任务完成事件
  5. *
  6. * 当用户完成任务时触发此事件
  7. */
  8. class TaskCompletedEvent
  9. {
  10. /**
  11. * 用户ID
  12. *
  13. * @var int
  14. */
  15. public int $userId;
  16. /**
  17. * 任务ID
  18. *
  19. * @var int
  20. */
  21. public int $taskId;
  22. /**
  23. * 任务名称
  24. *
  25. * @var string
  26. */
  27. public string $taskName;
  28. /**
  29. * 任务类型
  30. *
  31. * @var string
  32. */
  33. public string $taskType;
  34. /**
  35. * 完成时间
  36. *
  37. * @var string
  38. */
  39. public string $completedAt;
  40. /**
  41. * 任务奖励内容
  42. *
  43. * @var array
  44. */
  45. public array $rewards;
  46. /**
  47. * 创建一个新的事件实例
  48. *
  49. * @param int $userId 用户ID
  50. * @param int $taskId 任务ID
  51. * @param string $taskName 任务名称
  52. * @param string $taskType 任务类型
  53. * @param string $completedAt 完成时间
  54. * @param array $rewards 任务奖励内容
  55. */
  56. public function __construct(
  57. int $userId,
  58. int $taskId,
  59. string $taskName,
  60. string $taskType,
  61. string $completedAt,
  62. array $rewards
  63. ) {
  64. $this->userId = $userId;
  65. $this->taskId = $taskId;
  66. $this->taskName = $taskName;
  67. $this->taskType = $taskType;
  68. $this->completedAt = $completedAt;
  69. $this->rewards = $rewards;
  70. }
  71. }