3 changed files with 13 additions and 59 deletions
-
8app/AdminAgent/Controllers/OrderController.php
-
47app/AdminAgent/Extensions/Grid/ChangeOrderStatus.php
-
17app/AdminSupplier/Controllers/OrderController.php
@ -1,47 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\AdminAgent\Extensions\Grid; |
|
||||
use App\Common\OrderStatus; |
|
||||
use App\Models\Order; |
|
||||
use Dcat\Admin\Admin; |
|
||||
use Dcat\Admin\Grid\RowAction; |
|
||||
|
|
||||
/** |
|
||||
* 改变订单状态 |
|
||||
* 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::firstWhere(['id' => $this->getKey(), 'agent_id' => Admin::user()->id, '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 ['确定要设置为已付款吗?', '']; |
|
||||
} |
|
||||
} |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue