将订单标记2待付款
parent
4a3ac1cbee
commit
4b0de4d633
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\Grid;
|
||||||
|
|
||||||
|
use App\Enums\DealerOrderStatus;
|
||||||
|
use App\Exceptions\BizException;
|
||||||
|
use App\Models\DealerOrder;
|
||||||
|
use Dcat\Admin\Grid\RowAction;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class DealerOrderRefuse extends RowAction
|
||||||
|
{
|
||||||
|
public function title()
|
||||||
|
{
|
||||||
|
if ($this->title) {
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '<i class="feather icon-x-circle grid-action-icon"></i> 拒绝收款 ';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Model|Authenticatable|HasPermissions|null $user
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function authorize($user): bool
|
||||||
|
{
|
||||||
|
return $user->can('dcat.admin.dealer_orders.paid');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the action request.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function handle(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$order = DealerOrder::lockForUpdate()->findOrFail($this->getKey());
|
||||||
|
|
||||||
|
if (! $order->isPay()) {
|
||||||
|
throw new BizException('无法收款:订单状态异常,请刷新后再试');
|
||||||
|
}
|
||||||
|
|
||||||
|
$order->update([
|
||||||
|
'status' => DealerOrderStatus::Paying,
|
||||||
|
'pay_time' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
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 ['确认未收到此订单货款?', '确认后将无法逆操作'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ namespace App\Admin\Controllers;
|
||||||
use App\Admin\Actions\Grid\DealerOrderAllocate;
|
use App\Admin\Actions\Grid\DealerOrderAllocate;
|
||||||
use App\Admin\Actions\Grid\DealerOrderCancel;
|
use App\Admin\Actions\Grid\DealerOrderCancel;
|
||||||
use App\Admin\Actions\Grid\DealerOrderPaid;
|
use App\Admin\Actions\Grid\DealerOrderPaid;
|
||||||
|
use App\Admin\Actions\Grid\DealerOrderRefuse;
|
||||||
use App\Admin\Actions\Grid\DealerOrderShipping;
|
use App\Admin\Actions\Grid\DealerOrderShipping;
|
||||||
use App\Admin\Actions\Show\DealerOrderRemark;
|
use App\Admin\Actions\Show\DealerOrderRemark;
|
||||||
use App\Admin\Repositories\DealerOrder;
|
use App\Admin\Repositories\DealerOrder;
|
||||||
|
|
@ -90,6 +91,11 @@ class DealerOrderController extends AdminController
|
||||||
if ($actions->row->isPay() && Admin::user()->can('dcat.admin.dealer_orders.paid')) {
|
if ($actions->row->isPay() && Admin::user()->can('dcat.admin.dealer_orders.paid')) {
|
||||||
$actions->append(new DealerOrderPaid());
|
$actions->append(new DealerOrderPaid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($actions->row->isPay() && Admin::user()->can('dcat.admin.dealer_orders.refuse')) {
|
||||||
|
$actions->append(new DealerOrderRefuse());
|
||||||
|
}
|
||||||
|
|
||||||
if ($actions->row->isPaid() && Admin::user()->can('dcat.admin.dealer_orders.shipping')) {
|
if ($actions->row->isPaid() && Admin::user()->can('dcat.admin.dealer_orders.shipping')) {
|
||||||
$actions->append(new DealerOrderShipping());
|
$actions->append(new DealerOrderShipping());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -330,6 +330,7 @@ class AdminPermissionSeeder extends Seeder
|
||||||
'curd' => ['index', 'show'],
|
'curd' => ['index', 'show'],
|
||||||
'children' =>[
|
'children' =>[
|
||||||
'paid'=>['name' =>'确认收款'],
|
'paid'=>['name' =>'确认收款'],
|
||||||
|
'refuse'=>['name' =>'拒绝收款'],
|
||||||
'shipping'=>['name' =>'确认发货'],
|
'shipping'=>['name' =>'确认发货'],
|
||||||
'allocate'=>['name' =>'自动分配'],
|
'allocate'=>['name' =>'自动分配'],
|
||||||
'manager'=>['name' =>'系统订单'],
|
'manager'=>['name' =>'系统订单'],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue