FinanceWithdrawResponse.php 961 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Modules\ManageApi\Responses;
  3. use Illuminate\Contracts\Support\Responsable;
  4. class FinanceWithdrawResponse implements Responsable
  5. {
  6. /**
  7. * 录入的数据.
  8. *
  9. * @var mixed
  10. */
  11. private $data = null;
  12. /**
  13. * 提现统计数据
  14. *
  15. * @var array|mixed
  16. */
  17. private $recTotal = [];
  18. public function __construct($data = null, $witTotal = [])
  19. {
  20. $this->data = $data;
  21. $this->witTotal = $witTotal;
  22. }
  23. public function toResponse(
  24. $request = null
  25. ) {
  26. if (!$this->data->isEmpty()) {
  27. foreach ($this->data as &$v) {
  28. $v->agent_name = $v->agent->username ?? '';
  29. $v->commission_ratio = $v->agent->commission_ratio ?? '';
  30. unset($v->agent);
  31. }
  32. }
  33. $result = $this->data->toArray();
  34. $result['wit_total'] = $this->recTotal;
  35. return json_success($result);
  36. }
  37. }