Ver código fonte

修改调研选题:添加调研选题、修改调研选题

FengR 1 dia atrás
pai
commit
473ae9fb08
1 arquivos alterados com 8 adições e 4 exclusões
  1. 8 4
      app/JsonRpc/NewsService.php

+ 8 - 4
app/JsonRpc/NewsService.php

@@ -9240,7 +9240,9 @@ class NewsService implements NewsServiceInterface
         Db::rollBack();
         return Result::error('添加失败');
       }
-      $users = json_decode($users_id ?? '[]',true);
+      if(!empty($users_id) && is_string($users_id)){
+        $users = json_decode($users_id ?? '[]',true);
+      }
       $users_type4 = User::where('type_id', 4)->pluck('id');
       $type4_num = array_intersect($users, $users_type4->toArray());
       if(count($users) != count($type4_num)){
@@ -9248,7 +9250,7 @@ class NewsService implements NewsServiceInterface
         return Result::error('请选择调研员!');
       }
       // return Result::success($users);
-      if(!empty($users)){
+      if(!empty($users) && is_array($users)){
         // 去重:确保同一 retopic_id + user_id 组合唯一
         $users = array_values(array_unique($users));
         // 组装关联数据
@@ -9336,7 +9338,9 @@ class NewsService implements NewsServiceInterface
         Db::rollBack();
         return Result::error('编辑调研选题失败!');
       }
-      $users = json_decode($users_id ?? '[]',true);
+      if(!empty($users_id) && is_string($users_id)){
+        $users = json_decode($users_id ?? '[]',true);
+      }
       // return Result::success($users);
       $retopic_users = RetopicUser::where('retopic_id', $id)->pluck('user_id')->toArray();
       if(!empty($retopic_users)){
@@ -9346,7 +9350,7 @@ class NewsService implements NewsServiceInterface
           return Result::error('编辑同行人员失败!');
         }
       }
-      if(!empty($users)){
+      if(!empty($users) && is_array($users)){
         // 去重:确保同一 retopic_id + user_id 组合唯一
         $users = array_values(array_unique($users));
         // 组装关联数据