Procházet zdrojové kódy

验证关键词、随机模板-修改选项卡广告混合通栏

FengR před 1 měsícem
rodič
revize
bc340dbf28
1 změnil soubory, kde provedl 12 přidání a 12 odebrání
  1. 12 12
      app/JsonRpc/PublicRpcService.php

+ 12 - 12
app/JsonRpc/PublicRpcService.php

@@ -3809,7 +3809,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                     }
                      if (isset($components['type_id']) && $components['type_id'] == 24) {
                         $ad = $components['ad'][0];
-                        $ad['thumb'] = $image_info[$key]['component_imgurl'] ?? '';
+                        // $ad['thumb'] = $image_info[$key]['component_imgurl'] ?? '';
                         $template_data[$key]['ad'][0] = $ad;
                         $template_data[$key]['ad'][1] = $ad;
                         $canvas_adinfo[$key] = $ad;
@@ -4314,10 +4314,12 @@ class PublicRpcService implements PublicRpcServiceInterface
         if(empty($data['keyword']) || $data['keyword'] == '' || $data['keyword'] == '[]'){
             return Result::success('关键词为空');
         }
-        $arr_keyword = json_decode($data['keyword'],true);
-        $keyword = array_map('trim', $arr_keyword);
-        if(count($keyword) != count(array_unique($keyword))){
-            return Result::error('关键词不能重复!');
+        $arr_keyword = json_decode(stripslashes($data['keyword']), true) ?: [];
+        if(is_array($arr_keyword) && count($arr_keyword) > 0){
+            $keyword = array_map('trim', $arr_keyword);
+            if(count($keyword) != count(array_unique($keyword))){
+                return Result::error('关键词不能重复!');
+            }
         }
         $where['id'] = $data['id'] ?? null;
         if($data['type'] == 'style'){
@@ -4345,17 +4347,15 @@ class PublicRpcService implements PublicRpcServiceInterface
                 $query->where('id','!=',$where['id']);
             })->pluck('component_keyword')->toArray();
         }
-        // return Result::success($arr_keyword);
         foreach($all_keywords as $key => $value){
-            // $value_keyword[$key] = $value;
             $value_keyword = json_decode($value ?? '[]',true);
-            $repeat_keywords = array_intersect($arr_keyword,$value_keyword);
-            if(count($repeat_keywords) == count($keyword) && count($repeat_keywords) == count($value_keyword)){
-                return Result::error('此'.$type.'关键词已存在!');
+            if(is_array($value_keyword) && count($value_keyword) > 0){
+                $repeat_keywords = array_intersect($arr_keyword,$value_keyword);
+                if(count($repeat_keywords) == count($keyword) && count($repeat_keywords) == count($value_keyword)){
+                    return Result::error('此'.$type.'关键词已存在!');
+                }
             }
         }
-        
-        
         return Result::success(['验证通过']);
     }
     /**