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.
60 lines
1.4 KiB
60 lines
1.4 KiB
<?php
|
|
|
|
namespace App\AdminSupplier\Extensions\Grid;
|
|
|
|
use App\Common\OrderStatus;
|
|
use App\Common\PayType;
|
|
use App\Http\Controllers\Api\VerificationController;
|
|
use App\Models\IndustryOrder;
|
|
use App\Models\Order;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* 订单核销
|
|
* Class AuditSupplier
|
|
* @package App\Admin\Extensions\Grid
|
|
*/
|
|
class VerificationOrder extends RowAction
|
|
{
|
|
protected $title = '核销';
|
|
|
|
protected function html()
|
|
{
|
|
$class = 'btn btn-sm btn-success';
|
|
$this->appendHtmlAttribute('class', $class);
|
|
$this->defaultHtmlAttribute('href', 'javascript:;');
|
|
|
|
return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>";
|
|
}
|
|
|
|
public function handle(Request $request)
|
|
{
|
|
$id = $this->getKey();
|
|
try {
|
|
$order = Order::whereIn('status', [OrderStatus::PAID, OrderStatus::PAID_RETAINAGE, OrderStatus::OFFLINE_PAID, OrderStatus::REFUSED_REFUND])
|
|
->find($id);
|
|
if (!$order) {
|
|
throw new \Exception('订单不存在或已经核销过了');
|
|
}
|
|
|
|
$order->status = OrderStatus::SUCCESS;
|
|
if ($order->save()) {
|
|
//分账
|
|
//线下订单不分账
|
|
if ($order->pay_type != PayType::OFFLINE) {
|
|
(new VerificationController)->fund($order);
|
|
}
|
|
}
|
|
|
|
return $this->response()->success('操作成功')->refresh();
|
|
} catch (\Exception $e) {
|
|
return $this->response()->error($e->getMessage())->refresh();
|
|
}
|
|
}
|
|
|
|
public function confirm()
|
|
{
|
|
return ['确定要核销该订单吗?', ''];
|
|
}
|
|
}
|