65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: sunny
|
|
* Date: 2019/2/11
|
|
* Time: 4:19 PM
|
|
*/
|
|
|
|
namespace App\Api\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
|
class OrdersListResource extends JsonResource
|
|
{
|
|
/**
|
|
* 小程序,我的订单列表返回的数据项目
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'orderid' => $this->orderid,
|
|
'typeText' => $this->when($this->item_type, function () {
|
|
switch ($this->item_type) {
|
|
case 'GOODS':
|
|
$type = '商品订单';
|
|
break;
|
|
case 'ACTIVITY_GIFT':
|
|
$type = '活动赠品';
|
|
break;
|
|
case 'VIP_GIFT':
|
|
$type = '会员赠品';
|
|
break;
|
|
case 'FULL_GIFT':
|
|
$type = '满仓赠品';
|
|
break;
|
|
}
|
|
return $type;
|
|
}),
|
|
'stateText' => $this->state_text,
|
|
'goodsList' => OrderGoodsListResource::collection($this->details),
|
|
'total' => number_format($this->total, 2),
|
|
'amount' => number_format($this->amount, 2),
|
|
'score' => number_format($this->score, 2),
|
|
'actual_price' => number_format($this->total - $this->score, 2),
|
|
'freight' => number_format($this->freight, 2),
|
|
'handleOption' => [
|
|
'pay' => $this->canPay(),
|
|
'singin' => $this->canSingin(),
|
|
'cancel' => $this->canCancel(),
|
|
'track' => isset($this->express->company) && isset($this->express->number),//物流跟踪
|
|
],
|
|
'express' =>[
|
|
'name'=>$this->express->name,
|
|
'mobile'=>$this->express->mobile,
|
|
'address'=>$this->express->address,
|
|
],
|
|
'created_at' => (string) $this->created_at,
|
|
];
|
|
}
|
|
} |