TransferDto.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Module\Fund\Dto;
  3. /**
  4. *
  5. * 转账Dto
  6. *
  7. */
  8. class TransferDto
  9. {
  10. /**
  11. * @var int 转出用户ID
  12. */
  13. public int $fromUserId;
  14. /**
  15. * @var int 转入用户ID
  16. */
  17. public int $toUserId;
  18. /**
  19. * @var int 资金类型ID
  20. */
  21. public int $fundId;
  22. /**
  23. * @var float 金额
  24. */
  25. public float $amount;
  26. /**
  27. * @var string|null 备注
  28. */
  29. public ?string $remark;
  30. /**
  31. * @param array $data
  32. */
  33. public function __construct(array $data =[])
  34. {
  35. $this->fromUserId = $data['from_user_id'] ?? 0;
  36. $this->toUserId = $data['to_user_id'] ?? 0;
  37. $this->fundId = $data['fund_id'] ?? 0;
  38. $this->amount = $data['amount'] ?? 0.00;
  39. $this->remark = $data['remark'] ?? null;
  40. }
  41. /**
  42. * 转换为数组
  43. */
  44. public function toArray(): array
  45. {
  46. return [
  47. 'from_user_id' => $this->fromUserId,
  48. 'to_user_id' => $this->toUserId,
  49. 'fund_id' => $this->fundId,
  50. 'amount' => $this->amount,
  51. 'remark' => $this->remark,
  52. ];
  53. }
  54. }