kphcdr hace 1 año
padre
commit
4de607c6f6
Se han modificado 1 ficheros con 10 adiciones y 2 borrados
  1. 10 2
      app/Modules/Mini/Services/PageService.php

+ 10 - 2
app/Modules/Mini/Services/PageService.php

@@ -129,7 +129,11 @@ class PageService extends BaseService
         $gidArr = GoodsCategoryMap::where("category_id", $cidArr)->get(['goods_id'])->pluck("goods_id")->unique()->toArray();
         $attrMap = [];
         if ($attrs = Arr::get($params, "attrs", [])) {
-            $attrMap = json_decode($attrs, true);
+            if (is_array($attrs)) {
+                $attrMap = $attrs;
+            } else {
+                $attrMap = json_decode($attrs, true);
+            }
         }
         $p = Goods::where("status", Goods::STATUS_OK)->when($params['keyword'], function (Builder $query) use ($params) {
             $query->where("name", "like", "%" . $params['keyword'] . "%");
@@ -163,7 +167,11 @@ class PageService extends BaseService
     {
         $attrMap = [];
         if ($attrs = Arr::get($params, "attrs", [])) {
-            $attrMap = json_decode($attrs, true);
+            if (is_array($attrs)) {
+                $attrMap = $attrs;
+            } else {
+                $attrMap = json_decode($attrs, true);
+            }
         }
         $pageSize = Arr::get($params, "page_size", 10);
         $p = Goods::where("status", Goods::STATUS_OK)->when($attrMap, function (Builder $query) use ($attrMap) {