You've already forked guangan
审核详情
This commit is contained in:
@ -496,79 +496,7 @@ class Ticket extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进行审核
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*
|
||||
* @auth true
|
||||
* @menu true
|
||||
*/
|
||||
public function do_approve()
|
||||
{
|
||||
$data = $this->_vali([
|
||||
'id.require'=>'请指定工单ID!',
|
||||
'instance_id.require'=>'请指定当前审核ID!',
|
||||
'step_index.require'=>'请指定当前步骤!',
|
||||
'status.require'=>'请指定审核结果!',
|
||||
'content.default'=>'',
|
||||
]);
|
||||
$ticket = TicketTicket::query()->findOrEmpty($data['id']);
|
||||
if ($ticket->isEmpty()) {
|
||||
$this->error('工单不存在!');
|
||||
}
|
||||
$adminInfo = $this->request->session('user');
|
||||
$instance = ApprovalInstance::query()->with('steps')->findOrEmpty($data['instance_id']);
|
||||
if ($instance->isEmpty()) {
|
||||
$this->error('审核流程不存在!');
|
||||
}
|
||||
if ($instance->status == 1) {
|
||||
$this->error('工单已通过,请勿重复操作!');
|
||||
} else if ($instance->status == 2) {
|
||||
$this->error('工单已驳回,请勿重复操作!');
|
||||
}
|
||||
if ($instance->current_step != $data['step_index']) {
|
||||
$this->error('当前步骤不正确!');
|
||||
}
|
||||
if ($instance->current->approver_id != $adminInfo['id']) {
|
||||
$this->error('您不是当前审核人,请勿操作!');
|
||||
}
|
||||
ApprovalInstance::mk()->startTrans();
|
||||
try {
|
||||
$instance->current->status = $data['status'];
|
||||
$instance->current->content = $data['content'];
|
||||
$instance->current->save();
|
||||
if ($data['status'] == 2) {
|
||||
$instance->status = 2;
|
||||
} else {
|
||||
$instance->current_step++;
|
||||
if ($instance->current_step >= count($instance->steps)) {
|
||||
$instance->status = 1;
|
||||
$ticket->status = 0;
|
||||
$ticket->save();
|
||||
} else {
|
||||
$step = $instance->steps[$instance->current_step];
|
||||
if ($step['approver_type'] == 3) {
|
||||
$approve_data = $this->_vali([
|
||||
'approver_id.require' => '请指定审核人!',
|
||||
]);
|
||||
$step->approver_id = $approve_data['approver_id'];
|
||||
$step->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
$instance->save();
|
||||
ApprovalInstance::mk()->commit();
|
||||
} catch (HttpResponseException $e) {
|
||||
ApprovalInstance::mk()->rollback();
|
||||
throw $e;
|
||||
} catch (\Exception $e) {
|
||||
ApprovalInstance::mk()->rollback();
|
||||
// $this->error("审核失败");
|
||||
throw $e;
|
||||
}
|
||||
$this->success('审核成功!');
|
||||
}
|
||||
|
||||
|
||||
public function my() {
|
||||
$this->title = '待我审核';
|
||||
|
Reference in New Issue
Block a user