shishao-home 6 лет назад
Родитель
Сommit
81a3bdda8f
2 измененных файлов с 60 добавлено и 21 удалено
  1. 55 0
      app/business/controllers/GoodsController.php
  2. 5 21
      biz/goods/services/GoodsService.php

+ 55 - 0
app/business/controllers/GoodsController.php

@@ -0,0 +1,55 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: admin
+ * Date: 2019/12/1
+ * Time: 13:55
+ */
+
+namespace business\controllers;
+
+use Yii;
+use common\components\util;
+use biz\goods\services\GoodsService;
+
+
+class GoodsController extends BaseController
+{
+    //index,view,create,update,delete,options
+    public $enableCsrfValidation = false;
+
+    public function actionList()
+    {
+        $where = null;
+        $list = GoodsService::getGoodsList($where);
+        util::success($list);
+    }
+
+    public function actionCreate()
+    {
+        $data = Yii::$app->request->get();
+        GoodsService::add($data);
+    }
+
+    public function actionView()
+    {
+        $id = Yii::$app->request->get('id');
+        $good = GoodsService::getById($id);
+        util::success($good);
+    }
+
+    public function actionUpdate()
+    {
+        $data = Yii::$app->request->get();
+        $id = $data['id'];
+        $re = GoodsService::updateById($id, $data);
+        util::success($re);
+    }
+
+    public function actionDelete()
+    {
+        $id = Yii::$app->request->get('id');
+        $good = GoodsService::deleteById($id);
+        //util::success($good);
+    }
+}

+ 5 - 21
biz/goods/services/GoodsService.php

@@ -9,27 +9,11 @@ use linslin\yii2\curl;
 
 class GoodsService extends BaseService
 {
-	
-	public static $baseFile = '\biz\goods\classes\GoodsClass';
-	
-	//取商家商品分类的商品,json有分页
-	public static function getJsonListByCategory($categoryId)
-	{
-		$select = '*';
-		$merchantId = Yii::$app->params['merchantId'];
-		$where = ['merchantId' => $merchantId, 'categoryId' => $categoryId];
-		$order = 'inTurn desc';
-		return self::getList($select, $where, $order);
-	}
-	
-	/**
-	 * 获取商品详情,会统计商品的浏览量,非网页访问不能调用此方法
-	 * @author shish <shish@zhhinc.com>
-	 * @time 2019.9.6
-	 */
-	public static function getDetail()
-	{
+    public static $baseFile = '\biz\goods\classes\GoodsClass';
 
-	}
+    public static function getGoodsList($where)
+    {
+        return self::getList('*', $where, 'updateTime DESC');
+    }
 
 }