43 lines
1.7 KiB
PHP
43 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Resources\Dealer;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class DealerEarningResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$purchaseSubsidyLogs = $this->getPurchaseSubsidyLogs();
|
|
return [
|
|
'id' => $this->id,
|
|
'type' => $this->earningable_type_text,
|
|
'created_at' => $this->created_at->toDateTimeString(),
|
|
'settle_at' => $this->settle_at?->toDateTimeString(),
|
|
'total_amount' => $this->total_amount,
|
|
'fee_rate' => $this->fee_rate,
|
|
'fee' => $this->fee,
|
|
'total_earnings'=> $this->total_earnings,
|
|
'status' => $this->status_format,
|
|
'status_name' => $this->status_name,
|
|
'remark' => $this->remark,
|
|
'pay_way' => $this->pay_way ?? '',
|
|
'pay_info' => $this->getPayInfo(),
|
|
'pay_image' => $this->pay_image,
|
|
'pay_at' => $this->pay_at?->toDateTimeString(),
|
|
'is_payer' => $this->payer_id ? ($this->payer_id == $request->user()->id) : false,
|
|
'purchase_subsidy_logs' => $purchaseSubsidyLogs ? DealerEarningSubsidyLogResource::collection($purchaseSubsidyLogs) : null,
|
|
'beneficiary' => $this->user ? [
|
|
'nickname' => $this->user->userInfo?->nickname ?? '',
|
|
'phone'=>$this->user->phone ?? '',
|
|
] : null,
|
|
];
|
|
}
|
|
}
|