From ccaa77947a2db297577388956f57bf2e71a45448 Mon Sep 17 00:00:00 2001
From: vine_liutk <961510893@qq.com>
Date: Thu, 21 Apr 2022 15:10:29 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=91=E4=BB=93=E5=8D=95?=
=?UTF-8?q?=E6=A0=87=E8=AE=B0=E5=B7=B2=E5=8F=91=E8=B4=A7=E7=8A=B6=E6=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Actions/Grid/DealerDeliveryShipping.php | 67 +++++++++++++++++++
.../DealerDeliveryBillController.php | 5 ++
app/Enums/DealerDeliveryBillStatus.php | 3 +
app/Models/DealerDeliveryBill.php | 5 ++
4 files changed, 80 insertions(+)
create mode 100644 app/Admin/Actions/Grid/DealerDeliveryShipping.php
diff --git a/app/Admin/Actions/Grid/DealerDeliveryShipping.php b/app/Admin/Actions/Grid/DealerDeliveryShipping.php
new file mode 100644
index 00000000..93434970
--- /dev/null
+++ b/app/Admin/Actions/Grid/DealerDeliveryShipping.php
@@ -0,0 +1,67 @@
+title) {
+ return $this->title;
+ }
+ return ' 确认发货 ';
+ }
+
+ /**
+ * @param Model|Authenticatable|HasPermissions|null $user
+ *
+ * @return bool
+ */
+ protected function authorize($user): bool
+ {
+ return true;
+ return $user->can('dcat.admin.dealer_delivery_bills.shipping');
+ }
+
+ /**
+ * Handle the action request.
+ *
+ * @param Request $request
+ *
+ * @return Response
+ */
+ public function handle(Request $request)
+ {
+ $order = DealerDeliveryBill::findOrFail($this->getKey());
+ try {
+ DB::beginTransaction();
+
+ $order->update([
+ 'status' => DealerDeliveryBillStatus::Shippinged,
+ ]);
+
+ DB::commit();
+ } catch (Throwable $th) {
+ DB::rollBack();
+ report($th);
+ return $this->response()->error('操作失败,'.$th->getMessage())->refresh();
+ }
+
+ return $this->response()->success('操作成功')->refresh();
+ }
+
+ /**
+ * @return string|array|void
+ */
+ public function confirm()
+ {
+ return ['确认当前云仓单已发货?', '确认后将无法逆操作'];
+ }
+}
diff --git a/app/Admin/Controllers/DealerDeliveryBillController.php b/app/Admin/Controllers/DealerDeliveryBillController.php
index ec402590..3e2bea28 100644
--- a/app/Admin/Controllers/DealerDeliveryBillController.php
+++ b/app/Admin/Controllers/DealerDeliveryBillController.php
@@ -2,6 +2,7 @@
namespace App\Admin\Controllers;
+use App\Admin\Actions\Grid\DealerDeliveryShipping;
use App\Admin\Repositories\DealerDeliveryBill;
use App\Admin\Repositories\DealerDeliveryProduct;
use App\Enums\DealerDeliveryBillStatus;
@@ -51,6 +52,10 @@ class DealerDeliveryBillController extends AdminController
if (Admin::user()->can('dcat.admin.dealer_orders.show')) {
$actions->append(' 显示 ');
}
+
+ if ($actions->row->isPaid()) {
+ $actions->append(new DealerDeliveryShipping());
+ }
});
$grid->filter(function (Grid\Filter $filter) {
diff --git a/app/Enums/DealerDeliveryBillStatus.php b/app/Enums/DealerDeliveryBillStatus.php
index a042d81c..7c0ee7d3 100644
--- a/app/Enums/DealerDeliveryBillStatus.php
+++ b/app/Enums/DealerDeliveryBillStatus.php
@@ -5,6 +5,7 @@ namespace App\Enums;
enum DealerDeliveryBillStatus: int {
case Pending = 0; // 待付款
case Paid = 1; // 已付款
+ case Shippinged = 2; //已发货
case Cancelled = 10; // 已取消
public function text()
@@ -17,6 +18,7 @@ enum DealerDeliveryBillStatus: int {
return [
static::Pending->value => '#5b69bc',
static::Paid->value => '#21b978',
+ static::Shippinged->value => '#21b978',
static::Cancelled->value => '#b3b9bf',
];
}
@@ -26,6 +28,7 @@ enum DealerDeliveryBillStatus: int {
return [
static::Pending->value => '待付款',
static::Paid->value => '已付款',
+ static::Shippinged->value => '已发货',
static::Cancelled->value => '已取消',
];
}
diff --git a/app/Models/DealerDeliveryBill.php b/app/Models/DealerDeliveryBill.php
index 39e3c99c..2e5f012f 100644
--- a/app/Models/DealerDeliveryBill.php
+++ b/app/Models/DealerDeliveryBill.php
@@ -76,4 +76,9 @@ class DealerDeliveryBill extends Model
{
return $this->status === DealerDeliveryBillStatus::Pending;
}
+
+ public function isPaid()
+ {
+ return $this->status === DealerDeliveryBillStatus::Paid;
+ }
}