unknown 1 день назад
Родитель
Сommit
f4d8cb579f
1 измененных файлов с 11 добавлено и 4 удалено
  1. 11 4
      application/api/controller/WorkOrderProcess.php

+ 11 - 4
application/api/controller/WorkOrderProcess.php

@@ -547,19 +547,26 @@ class WorkOrderProcess extends Api
                 ->whereNull('del_rq')
                 ->update($data);
             if ($updateResult === false) {
-                throw new \Exception('更新工艺失败');
+                $dbError = Db::getError();
+                $detail = is_array($dbError) && !empty($dbError) ? json_encode($dbError, JSON_UNESCAPED_UNICODE) : '';
+                throw new \Exception('更新工艺失败' . ($detail !== '' ? ':' . $detail : ''));
             }
             if ($updateResult === 0) {
                 throw new \Exception('未找到可更新的工艺');
             }
             $logResult = Db::name('work_order_operation_log')->insertAll($logList);
-            if ($logResult === false) {
-                throw new \Exception('写入操作日志失败');
+            if ($logResult === false || $logResult === 0) {
+                $dbError = Db::getError();
+                $detail = is_array($dbError) && !empty($dbError) ? json_encode($dbError, JSON_UNESCAPED_UNICODE) : '';
+                throw new \Exception('写入操作日志失败' . ($detail !== '' ? ':' . $detail : ''));
             }
             Db::commit();
+        } catch (\think\exception\HttpResponseException $e) {
+            throw $e;
         } catch (\Exception $e) {
             Db::rollback();
-            $this->error('更新失败');
+            $msg = trim($e->getMessage());
+            $this->error('更新失败:' . ($msg !== '' ? $msg : '未知错误'));
         }
         $this->success('更新成功');
     }