PointLogDto.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Module\Point\Dto;
  3. /**
  4. * 积分日志DTO类
  5. *
  6. * 用于传输积分日志相关数据
  7. */
  8. class PointLogDto
  9. {
  10. public int $id;
  11. public int $user_id;
  12. public int $point_id;
  13. public int $amount;
  14. public string $operate_id;
  15. public int $operate_type;
  16. public string $operate_type_name;
  17. public string $remark;
  18. public int $create_time;
  19. public string $create_ip;
  20. public int $later_balance;
  21. public int $before_balance;
  22. public bool $is_income;
  23. public bool $is_expense;
  24. public function __construct(array $data = [])
  25. {
  26. $this->id = $data['id'] ?? 0;
  27. $this->user_id = $data['user_id'] ?? 0;
  28. $this->point_id = $data['point_id'] ?? 0;
  29. $this->amount = $data['amount'] ?? 0;
  30. $this->operate_id = $data['operate_id'] ?? '';
  31. $this->operate_type = $data['operate_type'] ?? 0;
  32. $this->operate_type_name = $data['operate_type_name'] ?? '';
  33. $this->remark = $data['remark'] ?? '';
  34. $this->create_time = $data['create_time'] ?? 0;
  35. $this->create_ip = $data['create_ip'] ?? '';
  36. $this->later_balance = $data['later_balance'] ?? 0;
  37. $this->before_balance = $data['before_balance'] ?? 0;
  38. $this->is_income = $data['is_income'] ?? false;
  39. $this->is_expense = $data['is_expense'] ?? false;
  40. }
  41. /**
  42. * 转换为数组
  43. *
  44. * @return array
  45. */
  46. public function toArray(): array
  47. {
  48. return [
  49. 'id' => $this->id,
  50. 'user_id' => $this->user_id,
  51. 'point_id' => $this->point_id,
  52. 'amount' => $this->amount,
  53. 'operate_id' => $this->operate_id,
  54. 'operate_type' => $this->operate_type,
  55. 'operate_type_name' => $this->operate_type_name,
  56. 'remark' => $this->remark,
  57. 'create_time' => $this->create_time,
  58. 'create_ip' => $this->create_ip,
  59. 'later_balance' => $this->later_balance,
  60. 'before_balance' => $this->before_balance,
  61. 'is_income' => $this->is_income,
  62. 'is_expense' => $this->is_expense,
  63. ];
  64. }
  65. }