TaskRewardClaimedEvent.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Module\Task\Events;
  3. /**
  4. * 任务奖励领取事件
  5. *
  6. * 当用户领取任务奖励时触发此事件
  7. */
  8. class TaskRewardClaimedEvent
  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 array
  32. */
  33. public array $rewards;
  34. /**
  35. * 领取时间
  36. *
  37. * @var string
  38. */
  39. public string $claimedAt;
  40. /**
  41. * 奖励是否成功发放
  42. *
  43. * @var bool
  44. */
  45. public bool $isSuccess;
  46. /**
  47. * 创建一个新的事件实例
  48. *
  49. * @param int $userId 用户ID
  50. * @param int $taskId 任务ID
  51. * @param string $taskName 任务名称
  52. * @param array $rewards 实际发放的奖励
  53. * @param string $claimedAt 领取时间
  54. * @param bool $isSuccess 奖励是否成功发放
  55. */
  56. public function __construct(
  57. int $userId,
  58. int $taskId,
  59. string $taskName,
  60. array $rewards,
  61. string $claimedAt,
  62. bool $isSuccess
  63. ) {
  64. $this->userId = $userId;
  65. $this->taskId = $taskId;
  66. $this->taskName = $taskName;
  67. $this->rewards = $rewards;
  68. $this->claimedAt = $claimedAt;
  69. $this->isSuccess = $isSuccess;
  70. }
  71. }