6
0
Fork 0

优化批零订单数据结构

release
李静 2022-02-23 16:20:29 +08:00
parent f6214506ef
commit d29b2dc1b1
2 changed files with 5 additions and 4 deletions

View File

@ -21,7 +21,7 @@ class OrderResource extends JsonResource
'total_amount' => $this->total_amount,
'created_at' => $this->created_at->toDateTimeString(),
'status' => $this->status,
'pay_way' => (string) $this->pay_way?->getDealerOrderLabel(),
'pay_way' => (string) $this->pay_way?->label(),
'pay_info' => $this->getConsignorPayInfo(),
'pay_image'=> $this->pay_image,
'is_consignor' => $request->user()->id == $this->consignor_id, //是否发货人身份

View File

@ -24,13 +24,14 @@ enum PayWay: string {
};
}
public function getDealerOrderLabel()
public function label()
{
return match ($this) {
static::Offline => 'offline',
static::Balance => 'balance',
static::Wallet => 'wallet',
static::WxpayH5 => 'wxpay',
default => 'unknown',
static::WxpayApp, static::WxpayH5, static::WxpayJs, static::WxpayMp => 'wxpay',
static::AlipayApp => 'alipay',
};
}