UrsTalentConfigDto.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. namespace App\Module\UrsPromotion\Dtos;
  3. use App\Module\UrsPromotion\Models\UrsTalentConfig;
  4. use UCore\Dto\BaseDto;
  5. /**
  6. * URS达人等级配置数据传输对象
  7. *
  8. * 用于在服务层返回URS达人等级配置信息,避免直接暴露模型对象
  9. */
  10. class UrsTalentConfigDto extends BaseDto
  11. {
  12. /**
  13. * @var int 配置ID
  14. */
  15. public int $id;
  16. /**
  17. * @var int 等级
  18. */
  19. public int $level;
  20. /**
  21. * @var string 等级名称
  22. */
  23. public string $name;
  24. /**
  25. * @var int 所需直推人数
  26. */
  27. public int $directCountRequired;
  28. /**
  29. * @var int 所需团队总人数
  30. */
  31. public int $promotionCountRequired;
  32. /**
  33. * @var string|null 等级图标
  34. */
  35. public ?string $icon;
  36. /**
  37. * @var string|null 等级描述
  38. */
  39. public ?string $description;
  40. /**
  41. * @var int 排序权重
  42. */
  43. public int $sortOrder;
  44. /**
  45. * @var int 状态
  46. */
  47. public int $status;
  48. /**
  49. * @var int 直推奖励组ID
  50. */
  51. public int $promotionDirectGroup;
  52. /**
  53. * @var int 间推奖励组ID
  54. */
  55. public int $promotionIndirectGroup;
  56. /**
  57. * @var int 三推奖励组ID
  58. */
  59. public int $promotionThirdGroup;
  60. /**
  61. * @var float 直推分成比例
  62. */
  63. public float $plantingDirectRate;
  64. /**
  65. * @var float 间推分成比例
  66. */
  67. public float $plantingIndirectRate;
  68. /**
  69. * @var float 三推分成比例
  70. */
  71. public float $plantingThirdRate;
  72. /**
  73. * @var string 创建时间
  74. */
  75. public string $createdAt;
  76. /**
  77. * @var string 更新时间
  78. */
  79. public string $updatedAt;
  80. /**
  81. * 从模型创建DTO
  82. *
  83. * @param UrsTalentConfig $model URS达人等级配置模型
  84. * @return self
  85. */
  86. public static function fromModel(UrsTalentConfig $model): self
  87. {
  88. $dto = new self();
  89. $dto->id = $model->id;
  90. $dto->level = $model->level;
  91. $dto->name = $model->name;
  92. $dto->directCountRequired = $model->direct_count_required;
  93. $dto->promotionCountRequired = $model->promotion_count_required;
  94. $dto->icon = $model->icon;
  95. $dto->description = $model->description;
  96. $dto->sortOrder = $model->sort_order;
  97. $dto->status = $model->status;
  98. $dto->promotionDirectGroup = $model->promotion_direct_group;
  99. $dto->promotionIndirectGroup = $model->promotion_indirect_group;
  100. $dto->promotionThirdGroup = $model->promotion_third_group;
  101. $dto->plantingDirectRate = (float)$model->planting_direct_rate;
  102. $dto->plantingIndirectRate = (float)$model->planting_indirect_rate;
  103. $dto->plantingThirdRate = (float)$model->planting_third_rate;
  104. $dto->createdAt = $model->created_at ? $model->created_at->toDateTimeString() : '';
  105. $dto->updatedAt = $model->updated_at ? $model->updated_at->toDateTimeString() : '';
  106. return $dto;
  107. }
  108. }