| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace App\Module\Fund\Dto;
- class FundDto
- {
- /**
- * @var int 用户ID
- */
- public int $userId;
- /**
- * @var int 资金类型ID
- */
- public int $fundId;
- /**
- * @var float 金额
- */
- public float $amount;
- /**
- * @var string|null 备注
- */
- public ?string $remark;
- /**
- * @var int|null 操作类型
- */
- public ?int $type;
- /**
- * @param array $data
- */
- public function __construct(array $data)
- {
- $this->userId = $data['user_id'] ?? 0;
- $this->fundId = $data['fund_id'] ?? 0;
- $this->amount = $data['amount'] ?? 0.00;
- $this->remark = $data['remark'] ?? null;
- $this->type = $data['type'] ?? null;
- }
- /**
- * 转换为数组
- */
- public function toArray(): array
- {
- return [
- 'user_id' => $this->userId,
- 'fund_id' => $this->fundId,
- 'amount' => $this->amount,
- 'remark' => $this->remark,
- 'type' => $this->type,
- ];
- }
- }
|