moonsflyer il y a 5 mois
Parent
commit
2692d59286
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      app/common/service/ThemeService.php

+ 6 - 1
app/common/service/ThemeService.php

@@ -740,7 +740,12 @@ class ThemeService
                 ->select()->toarray();
 
             $key_Arr = array_keys($goodsLists);
-            $gc_key =  array_rand($key_Arr,4);
+            if(count($goodsLists)>4){
+                $gc_key =  array_rand($key_Arr,4);
+            }else{
+                $gc_key = $key_Arr;
+            }
+
             foreach ($goodsLists as $k=>$v){
                 foreach($gc_key as $gk=>$gv){
                     if($k==$gk){