TransferResultDto.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Module\Point\Dto;
  3. /**
  4. * 积分转账结果DTO类
  5. *
  6. * 用于传输积分转账结果相关数据
  7. */
  8. class TransferResultDto
  9. {
  10. public int $transfer_id;
  11. public int $from_user_id;
  12. public int $to_user_id;
  13. public int $point_id;
  14. public int $amount;
  15. public string $remark;
  16. public function __construct(array $data = [])
  17. {
  18. $this->transfer_id = $data['transfer_id'] ?? 0;
  19. $this->from_user_id = $data['from_user_id'] ?? 0;
  20. $this->to_user_id = $data['to_user_id'] ?? 0;
  21. $this->point_id = $data['point_id'] ?? 0;
  22. $this->amount = $data['amount'] ?? 0;
  23. $this->remark = $data['remark'] ?? '';
  24. }
  25. /**
  26. * 转换为数组
  27. *
  28. * @return array
  29. */
  30. public function toArray(): array
  31. {
  32. return [
  33. 'transfer_id' => $this->transfer_id,
  34. 'from_user_id' => $this->from_user_id,
  35. 'to_user_id' => $this->to_user_id,
  36. 'point_id' => $this->point_id,
  37. 'amount' => $this->amount,
  38. 'remark' => $this->remark,
  39. ];
  40. }
  41. }