You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\AdminSupplier\Extensions\Grid;use App\Common\OrderStatus;use App\Models\Order;use Dcat\Admin\Admin;use Dcat\Admin\Grid\RowAction;use Illuminate\Support\Facades\DB;
/** * 改变订单状态 * Class ChangeOrderStatus * @package App\AdminAgent\Extensions\Grid */class ChangeOrderStatus extends RowAction{ protected $title = '设为 [线下]已付款';
protected function html() { $this->appendHtmlAttribute('class', 'btn btn-sm btn-success'); $this->defaultHtmlAttribute('href', 'javascript:;');
return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>"; }
public function handle() { try { $order = Order::query()->whereHas('orderProductItem', function ($query) { $query->where(['supplier_id' => Admin::user()->id, 'order_id' => $this->getKey()]); })->firstWhere(['id' => $this->getKey(), 'status' => OrderStatus::OFFLINE_UNPAID]); if (!$order) { return $this->response()->error("订单不存在或已处理过了")->refresh(); } $order->status = OrderStatus::OFFLINE_PAID; $order->verify_code = uniqid(); //生成核销码
$order->save();
return $this->response()->success("操作成功,已设置为“线下已付款”")->refresh(); } catch (\Exception $e) { return $this->response()->error($e->getMessage()); } }
public function confirm() { return ['确定要设置为已付款吗?', '']; }}
|