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'); - } }