Ver Fonte

修改随机模板、验证关键词

FengR há 2 meses atrás
pai
commit
5b45fbd4be
1 ficheiros alterados com 28 adições e 8 exclusões
  1. 28 8
      app/JsonRpc/PublicRpcService.php

+ 28 - 8
app/JsonRpc/PublicRpcService.php

@@ -3418,7 +3418,7 @@ class PublicRpcService implements PublicRpcServiceInterface
             $two_sector_key = array_search(2,$re_sector);
             $three_sector_key = array_search(3,$re_sector);
             $all_cat_num = array_column($sectors,'cat_num');
-
+            $repeat_sector_key = [];
             // $rule_repeat['1'] = 1;
             // return $rule_repeat;
             // $three_sector_key = array_search(3,$re_sector);
@@ -3799,6 +3799,19 @@ class PublicRpcService implements PublicRpcServiceInterface
                         $canvas_data[$key]['content']['ad'] = $canvas_adinfo[$key];
                         //    $canvas_data[$key]['ad'] = array_combine($ad, $canvas_adinfo[$key]);
 
+                        //     // $Component['componentData'] = [];
+                    }
+                     if (isset($components['type_id']) && $components['type_id'] == 24) {
+                        $ad = $components['ad'][0];
+                        $ad['thumb'] = $image_info[$key]['component_imgurl'] ?? '';
+                        $template_data[$key]['ad'][0] = $ad;
+                        $template_data[$key]['ad'][1] = $ad;
+                        $canvas_adinfo[$key] = $ad;
+                        $canvas_data[$key]['content']['ad'][0] = $canvas_adinfo[$key];
+                        $canvas_data[$key]['content']['ad'][1] = $canvas_adinfo[$key];
+                        
+                        //    $canvas_data[$key]['ad'] = array_combine($ad, $canvas_adinfo[$key]);
+
                         //     // $Component['componentData'] = [];
                     }
             //         // var_dump('---------------------------',$components[$selectedComponentId]);
@@ -4295,28 +4308,35 @@ class PublicRpcService implements PublicRpcServiceInterface
         if(empty($data['keyword']) || $data['keyword'] == '' || $data['keyword'] == '[]'){
             return Result::success('关键词为空');
         }
-        $keyword = json_decode($data['keyword'],true);
+        $arr_keyword = json_decode($data['keyword'],true);
         // return Result::success(is_array($keyword));
         // $keyword_list = array_column($keyword,'keyword');
-        if(is_array($keyword) && count($keyword) != 1){
-            $keyword = array_map('trim', $keyword);
+        if(is_array($arr_keyword) && count($arr_keyword) != 1){
+            $keyword = array_map('trim', $arr_keyword);
             if(count($keyword) != count(array_unique($keyword))){
                 return Result::error('关键词不能重复!');
             }
-            if(($data['type'] == 'style' || $data['type'] == 'skin')){
-                $keyword = preg_replace('/,/', ', ', $keyword);
-            }
+            
         }
         // return Result::success(json_encode($keyword,JSON_UNESCAPED_UNICODE));
-        $keyword = json_encode($keyword, JSON_UNESCAPED_UNICODE);
+        // return Result::success(['template_keyword'=>$template_keyword,'keyword'=>$keyword]);
         if($data['type'] == 'style'){
             $template_class_keyword = TemplateClass::pluck('keyword')->toArray();
+            $keyword = json_encode($keyword, JSON_UNESCAPED_UNICODE);
+            if(is_array($arr_keyword) && count($arr_keyword) != 1){
+                $keyword = preg_replace('/,/', ', ', $keyword);
+                // return Result::success($keyword);
+            }
             if(in_array($keyword,$template_class_keyword)){
                 return Result::error('此风格关键词已存在!');
             }
         }
         if($data['type'] == 'skin'){
             $template_keyword = Template::pluck('template_keyword')->toArray();
+            $keyword = json_encode($keyword, JSON_UNESCAPED_UNICODE);
+            if(is_array($arr_keyword) && count($arr_keyword) != 1){
+                $keyword = preg_replace('/,/', ', ', $keyword);
+            }
             if(in_array($keyword,$template_keyword)){
                 return Result::error('此皮肤关键词已存在!');
             }