| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Module\Point\Dto;
- use App\Module\Point\Enums\LOG_TYPE;
- /**
- * 积分交易结果DTO类
- *
- * 用于传输积分交易结果相关数据
- */
- class TradeResultDto
- {
- public int $user_id;
- public int $point_id;
- public int $amount;
- public LOG_TYPE $log_type;
- public string $operate_id;
- public string $remark;
- public bool $success;
- public function __construct(array $data = [])
- {
- $this->user_id = $data['user_id'] ?? 0;
- $this->point_id = $data['point_id'] ?? 0;
- $this->amount = $data['amount'] ?? 0;
- $this->log_type = $data['log_type'] ?? LOG_TYPE::TEST;
- $this->operate_id = $data['operate_id'] ?? '';
- $this->remark = $data['remark'] ?? '';
- $this->success = $data['success'] ?? false;
- }
- /**
- * 转换为数组
- *
- * @return array
- */
- public function toArray(): array
- {
- return [
- 'user_id' => $this->user_id,
- 'point_id' => $this->point_id,
- 'amount' => $this->amount,
- 'log_type' => $this->log_type->value,
- 'operate_id' => $this->operate_id,
- 'remark' => $this->remark,
- 'success' => $this->success,
- ];
- }
- }
|