From f6214506ef382ed186d23540d7c1e2aaacabb679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Wed, 23 Feb 2022 16:17:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=B9=E9=9B=B6=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Http/Resources/Dealer/OrderResource.php | 2 +- app/Enums/PayWay.php | 12 +++++++++++- app/Models/DealerOrder.php | 16 ++++++++-------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/Endpoint/Api/Http/Resources/Dealer/OrderResource.php b/app/Endpoint/Api/Http/Resources/Dealer/OrderResource.php index 992d508a..22a01316 100644 --- a/app/Endpoint/Api/Http/Resources/Dealer/OrderResource.php +++ b/app/Endpoint/Api/Http/Resources/Dealer/OrderResource.php @@ -21,7 +21,7 @@ class OrderResource extends JsonResource 'total_amount' => $this->total_amount, 'created_at' => $this->created_at->toDateTimeString(), 'status' => $this->status, - 'pay_way' => $this->pay_way ?? '', + 'pay_way' => (string) $this->pay_way?->getDealerOrderLabel(), 'pay_info' => $this->getConsignorPayInfo(), 'pay_image'=> $this->pay_image, 'is_consignor' => $request->user()->id == $this->consignor_id, //是否发货人身份 diff --git a/app/Enums/PayWay.php b/app/Enums/PayWay.php index d0c85a2e..9c62a073 100644 --- a/app/Enums/PayWay.php +++ b/app/Enums/PayWay.php @@ -19,11 +19,21 @@ enum PayWay: string { return match ($this) { static::Offline => '#5b69bc', static::Wallet => '#ff8acc', - static::WxpayH5 => '#21b978', + static::WxpayApp, static::WxpayH5, static::WxpayJs, static::WxpayMp => '#21b978', default => '#ea5455', }; } + public function getDealerOrderLabel() + { + return match ($this) { + static::Offline => 'offline', + static::Wallet => 'wallet', + static::WxpayH5 => 'wxpay', + default => 'unknown', + }; + } + public function getDealerOrderText() { return match ($this) { diff --git a/app/Models/DealerOrder.php b/app/Models/DealerOrder.php index 1d8c8243..4d22d0fc 100644 --- a/app/Models/DealerOrder.php +++ b/app/Models/DealerOrder.php @@ -165,6 +165,14 @@ class DealerOrder extends Model return $this->hasMany(DealerOrderRefuseLog::class, 'order_id'); } + /** + * 属于此订单的支付记录 + */ + public function payLogs() + { + return $this->morphMany(PayLog::class, 'payable'); + } + public function isUser($userId) { return $this->user_id == $userId; @@ -308,12 +316,4 @@ class DealerOrder extends Model } return $payInfo ?: null; } - - /** - * 属于此订单的支付记录 - */ - public function payLogs() - { - return $this->morphMany(PayLog::class, 'payable'); - } }