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.
69 lines
1.8 KiB
69 lines
1.8 KiB
<?php
|
|
namespace App\Admin\Extensions;
|
|
|
|
use App\Admin\Common\Rpc;
|
|
use App\Models\ImsCjdcOrderMain;
|
|
use Dcat\Admin\Grid\Displayers\Modal;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Dcat\Admin\Layout\Content;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class OrderStateHandle extends RowAction
|
|
{
|
|
|
|
protected $model;
|
|
protected $state;
|
|
protected $title;
|
|
protected $content;
|
|
public function __construct($title=null,$state=null)
|
|
{
|
|
parent::__construct($title);
|
|
$this->state = $state;
|
|
}
|
|
|
|
/**
|
|
* 处理请求
|
|
*
|
|
* @param Request $request
|
|
*
|
|
* @return \Dcat\Admin\Actions\Response
|
|
*/
|
|
public function handle(Request $request)
|
|
{
|
|
// 获取当前行ID
|
|
$id = $this->getKey();
|
|
$orderMain = new ImsCjdcOrderMain();
|
|
$state = $request->get('state');
|
|
$res = $orderMain->modifyState($id,$state);
|
|
if ($res&&$state==4){
|
|
$order = $orderMain::where('id',$id)->first();
|
|
//记录分账流水
|
|
$result = json_decode(Rpc::separateAccounts($id,$order->user_id));
|
|
if ($result->result){
|
|
return $this->response()->success('操作成功')->refresh();
|
|
}else{
|
|
Log::error('订单完成时分账接口调用失败',$result);
|
|
return $this->response()->error('操作失败')->refresh();
|
|
}
|
|
}
|
|
if ($res==true){
|
|
return $this->response()->success('操作成功')->refresh();
|
|
}else{
|
|
return $this->response()->error('操作失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 设置要POST到接口的数据
|
|
*
|
|
* @return array
|
|
*/
|
|
public function parameters()
|
|
{
|
|
return [
|
|
'state' => $this->state,
|
|
];
|
|
}
|
|
|
|
}
|