CirculationDto.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Module\Point\Dto;
  3. /**
  4. * 积分流转DTO类
  5. *
  6. * 用于传输积分流转相关数据
  7. */
  8. class CirculationDto
  9. {
  10. public int $circulation_id;
  11. public int $user_id;
  12. public int $from_point_id;
  13. public int $to_point_id;
  14. public int $amount;
  15. public string $remark;
  16. public function __construct(array $data = [])
  17. {
  18. $this->circulation_id = $data['circulation_id'] ?? 0;
  19. $this->user_id = $data['user_id'] ?? 0;
  20. $this->from_point_id = $data['from_point_id'] ?? 0;
  21. $this->to_point_id = $data['to_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. 'circulation_id' => $this->circulation_id,
  34. 'user_id' => $this->user_id,
  35. 'from_point_id' => $this->from_point_id,
  36. 'to_point_id' => $this->to_point_id,
  37. 'amount' => $this->amount,
  38. 'remark' => $this->remark,
  39. ];
  40. }
  41. }