|
@@ -2,9 +2,11 @@
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
+use App\Model\Record;
|
|
|
use App\Service\DingCallbackCrypto;
|
|
|
use App\Service\DingTalkCrypto;
|
|
|
use App\Service\DrbService;
|
|
|
+use App\Service\U8ServerService;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
@@ -88,16 +90,14 @@ class DingTalkController extends BaseController
|
|
|
case 'bpms_instance_change':
|
|
|
$processInstanceId = $event['processInstanceId'] ?? null;
|
|
|
$result = $event['result'] ?? null;
|
|
|
-// Log::info('审批实例变更', compact('processInstanceId','result'));
|
|
|
+ $type = $event['type'] ?? null; // start/finish/terminate/delete
|
|
|
|
|
|
- // 捕捉最后一个节点审核通过
|
|
|
- if ($result === 'agree') {
|
|
|
- // TODO: 执行你的业务逻辑,比如更新数据库、触发后续操作
|
|
|
- Log::info("最后一个节点审核通过,审批完成", compact('processInstanceId'));
|
|
|
- }elseif ($result === 'oppose' || $result === 'terminate' || $result == "refuse") {
|
|
|
- Log::info("审批流程被驳回或终止", compact('processInstanceId','result'));
|
|
|
- }
|
|
|
+ // 动作导致流程成功 或 流程终止
|
|
|
+ $this->settleData($type, $result, $processInstanceId);
|
|
|
+// Log::info('审批实例变更', compact('processInstanceId','result'));
|
|
|
|
|
|
+// Log::info("最后一个节点审核通过,审批完成", compact('processInstanceId'));
|
|
|
+// Log::info("审批流程被驳回或终止", compact('processInstanceId','result'));
|
|
|
break;
|
|
|
case 'bpms_task_change':
|
|
|
$processInstanceId = $event['processInstanceId'] ?? null;
|
|
@@ -105,12 +105,9 @@ class DingTalkController extends BaseController
|
|
|
$result = $event['result'] ?? null;
|
|
|
$approverUserId = $event['staffId'] ?? null;
|
|
|
|
|
|
-// Log::info('审批任务变更', compact('processInstanceId','taskId','result'));
|
|
|
-
|
|
|
// 捕获节点被驳回
|
|
|
if ($result === 'refuse') {
|
|
|
// Log::info("节点被驳回", compact('processInstanceId','taskId','approverUserId'));
|
|
|
- // TODO: 执行你的业务逻辑,比如通知申请人、更新状态
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -121,8 +118,59 @@ class DingTalkController extends BaseController
|
|
|
return response($res, 200)->header('Content-Type', 'application/json');
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
- Log::error('钉钉回调解密异常', ['msg' => $e->getMessage()]);
|
|
|
+ Log::channel('apiLog')->info('钉钉回调解密异常', ['msg' => $e->getMessage()]);
|
|
|
return response()->json(['errcode'=>1, 'errmsg'=>'解密失败']);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private function settleData($type, $result, $processInstanceId){
|
|
|
+ try {
|
|
|
+ $record = Record::where("del_time",0)
|
|
|
+ ->where('process_instance_id', $processInstanceId)
|
|
|
+ ->first();
|
|
|
+ if(empty($record)) return;
|
|
|
+
|
|
|
+ switch ($type) {
|
|
|
+// case 'start': // 审批实例开始
|
|
|
+// $record->del_time = 9; // 自定义标记,待审批
|
|
|
+// break;
|
|
|
+
|
|
|
+ case 'finish': // 审批正常结束(同意 / 拒绝)
|
|
|
+ if ($result === 'agree') {
|
|
|
+ $record->del_time = 2; // 成功
|
|
|
+ } elseif ($result === 'refuse') {
|
|
|
+ $record->del_time = 1; // 驳回
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'terminate': // 审批终止(发起人撤销)
|
|
|
+ $record->del_time = 1; // 终止
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'delete': // 审批实例删除
|
|
|
+ $record->del_time = 1; // 删除
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ $record->save();
|
|
|
+ } catch (\Throwable $exception) {
|
|
|
+ Log::channel('apiLog')->info('钉钉回调处理数据保存异常', ['msg' => $exception->getMessage()]);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $record = Record::where("del_time",0)
|
|
|
+ ->where('process_instance_id', $processInstanceId)
|
|
|
+ ->first();
|
|
|
+ if(empty($record)) return;
|
|
|
+
|
|
|
+ if ($result === 'agree') {
|
|
|
+ $record->del_time = 2; //成功
|
|
|
+ }elseif ($result == "refuse") {
|
|
|
+ $record->del_time = 1; //驳回
|
|
|
+ }
|
|
|
+ $record->save();
|
|
|
+ }catch (\Throwable $exception){
|
|
|
+ Log::channel('apiLog')->info('钉钉回调处理数据保存异常', ['msg' => $exception->getMessage()]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|