This commit is contained in:
2023-03-08 09:16:04 +08:00
commit e78454540f
1318 changed files with 210569 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace Modules\Mall\Http\Resources\Api\Order;
use Illuminate\Http\Resources\Json\JsonResource;
class RefundResource extends JsonResource
{
public function toArray($request): array
{
return [
'refund_id' => $this->id,
'refund_no' => $this->refund_no,
'order_no' => $this->order->order_no,
'state' => [
'state' => $this->state,
'text' => $this->status_text,
'remark' => $this->state_text,
],
'refund_total' => $this->refund_total,
'actual_total' => $this->actual_total,
'order' => [
'order_id' => $this->order->id,
'order_no' => $this->order->order_no,
'paid_at' => $this->order->paid_at ? $this->order->paid_at->toDateTimeString() : '',
'deliver_at' => $this->order->express->deliver_at ? $this->order->express->deliver_at->toDateTimeString() : '',
'receive_at' => $this->order->express->receive_at ? $this->order->express->receive_at->toDateTimeString() : '',
],
'items' => RefundItemsResource::collection($this->items),
'can' => collect($this->transitions())->map(function ($item) {
return $item->getName();
}),
'log' => new RefundLogResource($this->logs()->oldest()->first()),
'created_at' => $this->created_at->toDateTimeString(),
'updated_at' => $this->updated_at->toDateTimeString(),
];
}
}