Parcourir la source

Wesmiler 三勾多商户商城提交

wesmiler il y a 4 ans
Parent
commit
250b341000
2 fichiers modifiés avec 27 ajouts et 1 suppressions
  1. 18 0
      app/api/controller/product/Product.php
  2. 9 1
      app/common/model/product/Product.php

+ 18 - 0
app/api/controller/product/Product.php

@@ -36,6 +36,24 @@ class Product extends Controller
     }
     }
 
 
     /**
     /**
+     * 商品列表
+     */
+    public function listsByCate()
+    {
+        // 整理请求的参数
+        $param = array_merge($this->postData(), [
+            'product_status' => 10,
+            'audit_status' => 10,
+            'sku'=> true,
+        ]);
+
+        // 获取列表数据
+        $model = new ProductModel;
+        $list = $model->getList($param, $this->getUser(false));
+        return $this->renderSuccess('', compact('list'));
+    }
+
+    /**
      * 推荐产品
      * 推荐产品
      */
      */
     public function recommendProduct($location)
     public function recommendProduct($location)

+ 9 - 1
app/common/model/product/Product.php

@@ -199,7 +199,15 @@ class Product extends BaseModel
             ->where('supplier.is_recycle', '=', 0)
             ->where('supplier.is_recycle', '=', 0)
             ->where($filter)
             ->where($filter)
             ->order($sort)
             ->order($sort)
-            ->paginate($params);
+            ->paginate($params)
+            ->each(function($item, $k) use($param){
+                $sku = isset($param['sku'])? $param['sku'] : 0;
+                $specType = isset($item['spec_type'])? $item['spec_type'] : 0;
+                if($sku && $specType == 20){
+                    $specData = $this->getManySpecData($item['spec_rel'], $item['sku']);
+                    $item['spec_data'] = $specData;
+                }
+            });
         // 整理列表数据并返回
         // 整理列表数据并返回
         return $this->setProductListData($list, true);
         return $this->setProductListData($list, true);
     }
     }