| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- namespace App\Module\UrsPromotion\Dtos;
- use App\Module\UrsPromotion\Models\UrsTalentConfig;
- use UCore\Dto\BaseDto;
- /**
- * URS达人等级配置数据传输对象
- *
- * 用于在服务层返回URS达人等级配置信息,避免直接暴露模型对象
- */
- class UrsTalentConfigDto extends BaseDto
- {
- /**
- * @var int 配置ID
- */
- public int $id;
- /**
- * @var int 等级
- */
- public int $level;
- /**
- * @var string 等级名称
- */
- public string $name;
- /**
- * @var int 所需直推人数
- */
- public int $directCountRequired;
- /**
- * @var int 所需团队总人数
- */
- public int $promotionCountRequired;
- /**
- * @var string|null 等级图标
- */
- public ?string $icon;
- /**
- * @var string|null 等级描述
- */
- public ?string $description;
- /**
- * @var int 排序权重
- */
- public int $sortOrder;
- /**
- * @var int 状态
- */
- public int $status;
- /**
- * @var int 直推奖励组ID
- */
- public int $promotionDirectGroup;
- /**
- * @var int 间推奖励组ID
- */
- public int $promotionIndirectGroup;
- /**
- * @var int 三推奖励组ID
- */
- public int $promotionThirdGroup;
- /**
- * @var float 直推分成比例
- */
- public float $plantingDirectRate;
- /**
- * @var float 间推分成比例
- */
- public float $plantingIndirectRate;
- /**
- * @var float 三推分成比例
- */
- public float $plantingThirdRate;
- /**
- * @var string 创建时间
- */
- public string $createdAt;
- /**
- * @var string 更新时间
- */
- public string $updatedAt;
- /**
- * 从模型创建DTO
- *
- * @param UrsTalentConfig $model URS达人等级配置模型
- * @return self
- */
- public static function fromModel(UrsTalentConfig $model): self
- {
- $dto = new self();
- $dto->id = $model->id;
- $dto->level = $model->level;
- $dto->name = $model->name;
- $dto->directCountRequired = $model->direct_count_required;
- $dto->promotionCountRequired = $model->promotion_count_required;
- $dto->icon = $model->icon;
- $dto->description = $model->description;
- $dto->sortOrder = $model->sort_order;
- $dto->status = $model->status;
- $dto->promotionDirectGroup = $model->promotion_direct_group;
- $dto->promotionIndirectGroup = $model->promotion_indirect_group;
- $dto->promotionThirdGroup = $model->promotion_third_group;
- $dto->plantingDirectRate = (float)$model->planting_direct_rate;
- $dto->plantingIndirectRate = (float)$model->planting_indirect_rate;
- $dto->plantingThirdRate = (float)$model->planting_third_rate;
- $dto->createdAt = $model->created_at ? $model->created_at->toDateTimeString() : '';
- $dto->updatedAt = $model->updated_at ? $model->updated_at->toDateTimeString() : '';
- return $dto;
- }
- }
|