6
0
Fork 0

添加云仓单标记已发货状态

release
vine_liutk 2022-04-21 15:10:29 +08:00
parent 9c48f1bb91
commit ccaa77947a
4 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,67 @@
<?php
namespace App\Admin\Actions\Grid;
use App\Enums\DealerDeliveryBillStatus;
use App\Models\DealerDeliveryBill;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Throwable;
class DealerDeliveryShipping extends RowAction
{
public function title()
{
if ($this->title) {
return $this->title;
}
return '<i class="feather icon-package grid-action-icon"></i> 确认发货 &nbsp;&nbsp;';
}
/**
* @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 ['确认当前云仓单已发货?', '确认后将无法逆操作'];
}
}

View File

@ -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('<a style="cursor: pointer;" target="_blank" href="'.admin_route('dealer_delivery_bills.show', [$actions->row]).'"><i class="feather icon-eye"></i> 显示 &nbsp;&nbsp;</a>');
}
if ($actions->row->isPaid()) {
$actions->append(new DealerDeliveryShipping());
}
});
$grid->filter(function (Grid\Filter $filter) {

View File

@ -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 => '已取消',
];
}

View File

@ -76,4 +76,9 @@ class DealerDeliveryBill extends Model
{
return $this->status === DealerDeliveryBillStatus::Pending;
}
public function isPaid()
{
return $this->status === DealerDeliveryBillStatus::Paid;
}
}