From 95ebc75d5f40a6c103f5085076005d2a9850d7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Sat, 18 Dec 2021 15:32:44 +0800 Subject: [PATCH] Update --- app/Admin/Controllers/OrderController.php | 2 +- app/Constants/OrderStatus.php | 14 +++++++------- app/Models/Order.php | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/Admin/Controllers/OrderController.php b/app/Admin/Controllers/OrderController.php index 3dfe1d9e..d056721c 100644 --- a/app/Admin/Controllers/OrderController.php +++ b/app/Admin/Controllers/OrderController.php @@ -257,7 +257,7 @@ class OrderController extends AdminController $packagesBox = Box::make('发货包裹', $packageGrid); //显示发货动作 $order = OrderModel::findOrFail($id); - if ($order->isPaid() || $order->isShipping()) { + if ($order->isWaitShipping() || $order->isShipping()) { $packagesBox->tool(new OrderCreatePackage(null, $id)); } diff --git a/app/Constants/OrderStatus.php b/app/Constants/OrderStatus.php index 40144680..8d10077e 100644 --- a/app/Constants/OrderStatus.php +++ b/app/Constants/OrderStatus.php @@ -4,11 +4,11 @@ namespace App\Constants; class OrderStatus { - public const UNKNOWN = -1; // 未知 - public const PENDING = 0; // 待付款 - public const PAID = 1; // 已付款/待发货 - public const SHIPPING = 2; // 发货中 - public const SHIPPED = 3; // 已发货/待收货 - public const COMPLETED = 9; // 已完成 - public const CANCELLED = 10; // 已取消 + public const UNKNOWN = -1; // 未知 + public const PENDING = 0; // 待付款 + public const WAIT_SHIPPING = 1; // 待发货 + public const SHIPPING = 2; // 发货中 + public const SHIPPED = 3; // 已发货/待收货 + public const COMPLETED = 9; // 已完成 + public const CANCELLED = 10; // 已取消 } diff --git a/app/Models/Order.php b/app/Models/Order.php index e67cbbdf..c30f792f 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -121,11 +121,21 @@ class Order extends Model } /** - * 确认此订单是否是待发货 + * 确认此订单是否已付款 * * @return bool */ public function isPaid(): bool + { + return $this->status === static::STATUS_PAID; + } + + /** + * 确认此订单是否是待发货 + * + * @return bool + */ + public function isWaitShipping(): bool { return $this->status === static::STATUS_PAID && $this->shipping_state === static::SHIPPING_STATE_PENDING; @@ -263,9 +273,9 @@ class Order extends Model return OrderStatus::PENDING; } - // 已付款(待发货) - if ($this->isPaid()) { - return OrderStatus::PAID; + // 待发货 + if ($this->isWaitShipping()) { + return OrderStatus::WAIT_SHIPPING; } // 发货中