添加批零订单后台取消待确认订单操作
parent
98d49bfc2b
commit
3bf648bbe4
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Grid;
|
||||
|
||||
use App\Models\DealerOrder;
|
||||
use App\Services\Dealer\OrderService;
|
||||
use Dcat\Admin\Grid\RowAction;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Throwable;
|
||||
|
||||
class DealerOrderCancel extends RowAction
|
||||
{
|
||||
public function title()
|
||||
{
|
||||
if ($this->title) {
|
||||
return $this->title;
|
||||
}
|
||||
return '<i class="feather icon-trash grid-action-icon"></i> 取消订单 ';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model|Authenticatable|HasPermissions|null $user
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorize($user): bool
|
||||
{
|
||||
return $user->can('dcat.admin.dealer_orders.cancel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the action request.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$order = DealerOrder::findOrFail($this->getKey());
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
(new OrderService())->cancelOrder($order);
|
||||
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 ['确认取消当前订单?', '确认后将无法逆操作'];
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Grid\DealerOrderAllocate;
|
||||
use App\Admin\Actions\Grid\DealerOrderCancel;
|
||||
use App\Admin\Actions\Grid\DealerOrderPaid;
|
||||
use App\Admin\Actions\Grid\DealerOrderShipping;
|
||||
use App\Admin\Actions\Show\DealerOrderRemark;
|
||||
|
|
@ -74,18 +75,21 @@ class DealerOrderController extends AdminController
|
|||
$actions->append('<a style="cursor: pointer;" target="_blank" href="'.admin_route('dealer_orders.show', ['dealer_order'=>$actions->row]).'"><i class="feather icon-eye"></i> 显示 </a>');
|
||||
// $actions->disableView(false);
|
||||
}
|
||||
if (!(empty($actions->row->consignor) || $actions->row->consignor_id == 1) && $actions->row->status == DealerOrderStatus::Pending && Admin::user()->can('dcat.admin.dealer_orders.allocate')) {
|
||||
if (!(empty($actions->row->consignor) || $actions->row->consignor_id == 1) && $actions->row->isPending() && Admin::user()->can('dcat.admin.dealer_orders.allocate')) {
|
||||
$actions->append(new DealerOrderAllocate());
|
||||
}
|
||||
|
||||
if ((empty($actions->row->consignor) || $actions->row->consignor_id == 1)) {
|
||||
if ($actions->row->status == DealerOrderStatus::Confirming && Admin::user()->can('dcat.admin.dealer_orders.paid')) {
|
||||
if ($actions->row->isPay() && Admin::user()->can('dcat.admin.dealer_orders.paid')) {
|
||||
$actions->append(new DealerOrderPaid());
|
||||
}
|
||||
if ($actions->row->status == DealerOrderStatus::Paid && Admin::user()->can('dcat.admin.dealer_orders.shipping')) {
|
||||
if ($actions->row->isPaid() && Admin::user()->can('dcat.admin.dealer_orders.shipping')) {
|
||||
$actions->append(new DealerOrderShipping());
|
||||
}
|
||||
}
|
||||
if ($actions->row->isPending() && Admin::user()->can('dcat.admin.dealer_orders.cancel')) {
|
||||
$actions->append(new DealerOrderCancel());
|
||||
}
|
||||
});
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->panel();
|
||||
|
|
|
|||
Loading…
Reference in New Issue