UrsUserEnteredFarmEvent.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Module\UrsPromotion\Events;
  3. use Illuminate\Foundation\Events\Dispatchable;
  4. use Illuminate\Queue\SerializesModels;
  5. /**
  6. * URS用户进入农场事件
  7. *
  8. * 当URS用户首次进入农场时触发,用于处理相关的业务逻辑
  9. * 如推荐奖励补发、统计更新等
  10. */
  11. class UrsUserEnteredFarmEvent
  12. {
  13. use Dispatchable, SerializesModels;
  14. /**
  15. * URS用户ID
  16. *
  17. * @var int
  18. */
  19. public int $ursUserId;
  20. /**
  21. * 农场用户ID
  22. *
  23. * @var int
  24. */
  25. public int $farmUserId;
  26. /**
  27. * 用户凭证(userKey)
  28. *
  29. * @var string|null
  30. */
  31. public ?string $userKey;
  32. /**
  33. * 是否为首次进入农场
  34. *
  35. * @var bool
  36. */
  37. public bool $isFirstEntry;
  38. /**
  39. * 进入农场的时间
  40. *
  41. * @var \Carbon\Carbon
  42. */
  43. public \Carbon\Carbon $entryTime;
  44. /**
  45. * 创建事件实例
  46. *
  47. * @param int $ursUserId URS用户ID
  48. * @param int $farmUserId 农场用户ID
  49. * @param string|null $userKey 用户凭证
  50. * @param bool $isFirstEntry 是否为首次进入农场
  51. */
  52. public function __construct(int $ursUserId, int $farmUserId, ?string $userKey = null, bool $isFirstEntry = true)
  53. {
  54. $this->ursUserId = $ursUserId;
  55. $this->farmUserId = $farmUserId;
  56. $this->userKey = $userKey;
  57. $this->isFirstEntry = $isFirstEntry;
  58. $this->entryTime = now();
  59. }
  60. }