RewardGrantedEvent.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Module\Game\Events;
  3. use App\Module\Game\Dtos\RewardItemDto;
  4. use Illuminate\Broadcasting\InteractsWithSockets;
  5. use Illuminate\Foundation\Events\Dispatchable;
  6. use Illuminate\Queue\SerializesModels;
  7. /**
  8. * 奖励发放事件
  9. *
  10. * 当奖励成功发放给用户时触发
  11. */
  12. class RewardGrantedEvent
  13. {
  14. use Dispatchable, InteractsWithSockets, SerializesModels;
  15. /**
  16. * 用户ID
  17. *
  18. * @var int
  19. */
  20. public int $userId;
  21. /**
  22. * 奖励组ID
  23. *
  24. * @var int
  25. */
  26. public int $groupId;
  27. /**
  28. * 奖励组编码
  29. *
  30. * @var string
  31. */
  32. public string $groupCode;
  33. /**
  34. * 来源类型
  35. *
  36. * @var string
  37. */
  38. public string $sourceType;
  39. /**
  40. * 来源ID
  41. *
  42. * @var int
  43. */
  44. public int $sourceId;
  45. /**
  46. * 发放的奖励项
  47. *
  48. * @var RewardItemDto[]
  49. */
  50. public array $items;
  51. /**
  52. * 创建一个新的事件实例
  53. *
  54. * @param int $userId 用户ID
  55. * @param int $groupId 奖励组ID
  56. * @param string $groupCode 奖励组编码
  57. * @param string $sourceType 来源类型
  58. * @param int $sourceId 来源ID
  59. * @param RewardItemDto[] $items 发放的奖励项
  60. */
  61. public function __construct(int $userId, int $groupId, string $groupCode, string $sourceType, int $sourceId, array $items)
  62. {
  63. $this->userId = $userId;
  64. $this->groupId = $groupId;
  65. $this->groupCode = $groupCode;
  66. $this->sourceType = $sourceType;
  67. $this->sourceId = $sourceId;
  68. $this->items = $items;
  69. }
  70. }