4 changed files with 67 additions and 103 deletions
-
7app/AdminSupplier/Controllers/OrderController.php
-
5app/AdminSupplier/Extensions/Grid/IndustryOrderAudit.php
-
60app/AdminSupplier/Extensions/Grid/VerificationOrder.php
-
98app/Http/Controllers/Api/TestController.php
@ -0,0 +1,60 @@ |
|||||
|
<?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 ['确定要核销该订单吗?', '']; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue