shish преди 6 години
родител
ревизия
35f8d9c357

+ 23 - 0
app/client/controllers/GoodsController.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace client\controllers;
+
+use biz\goods\services\CategoryService;
+use biz\goods\services\GoodsCategoryService;
+use biz\goods\services\GoodsService;
+use Yii;
+use yii\web\Controller;
+use common\components\util;
+
+class GoodsController extends BaseController
+{
+	
+	//获取商品详情 shish 2019.12.3
+	public function actionGetDetail()
+	{
+		$id = Yii::$app->request->get('id', 0);
+		$info = GoodsService::getGoodsInfo($id);
+		util::success($info);
+	}
+
+}

+ 2 - 13
biz/goods/classes/GoodsCategoryClass.php

@@ -8,18 +8,7 @@ use biz\base\classes\BaseClass;
 
 class GoodsCategoryClass extends BaseClass
 {
-	
+
 	public static $baseFile = '\biz\goods\models\GoodsCategory';
-	
-	//组装商品基本信息 shish 2019.12.2
-	public static function groupGoodsBaseInfo($list)
-	{
-		foreach ($list as $key => $val) {
-			//大中小图片转化
-			$val = business::formatGoodsImg($val);
-			$list[$key] = $val;
-		}
-		return $list;
-	}
-	
+
 }

+ 22 - 10
biz/goods/classes/GoodsClass.php

@@ -1,6 +1,8 @@
 <?php
 
 namespace biz\goods\classes;
+
+use common\components\business;
 use Yii;
 use biz\base\classes\BaseClass;
 
@@ -9,20 +11,30 @@ class GoodsClass extends BaseClass
 
 	public static $baseFile = '\biz\goods\models\Goods';
 
-	//获取商品列表完全信息 shish 2019.12.2
-	public static function getGoodsInfoList($list)
+	//获取商品详情 shish 2019.12.3
+	public static function getGoodsInfo($id)
 	{
-	
+		$info = self::getById($id);
+		if (empty($info)) {
+			return [];
+		}
+		$list = self::groupGoodsBaseInfo([$info]);
+		return current($list);
 	}
 	
-	public static function groupByInfoList($list)
+	//组装商品基本信息 shish 2019.12.2
+	public static function groupGoodsBaseInfo($list)
 	{
-	
-	}
-	
-	public static function getInfo($id)
-	{
-	
+		foreach ($list as $key => $val) {
+			//大中小图片转化
+			$val = business::formatGoodsImg($val);
+			$val['commonIntro'] = '配送相应说明';
+			//免费配送范围
+			$val['freeSendDist'] = 5;
+			$list[$key] = $val;
+			//涨价
+		}
+		return $list;
 	}
 
 }

+ 3 - 2
biz/goods/services/GoodsCategoryService.php

@@ -4,6 +4,7 @@ namespace biz\goods\services;
 
 use biz\base\services\BaseService;
 use biz\goods\classes\GoodsCategoryClass;
+use biz\goods\classes\GoodsClass;
 use Yii;
 use linslin\yii2\curl;
 
@@ -22,7 +23,7 @@ class GoodsCategoryService extends BaseService
 		}
 		$ids = array_column($list, 'gId');
 		$list = GoodsService::getAllByCondition(['id' => ['in', $ids]], 'inTurn DESC', 'goodsName,shopImg,price,sold');
-		$data['list'] = GoodsCategoryClass::groupGoodsBaseInfo($list);
+		$data['list'] = GoodsClass::groupGoodsBaseInfo($list);
 		return $data;
 	}
 	
@@ -47,7 +48,7 @@ class GoodsCategoryService extends BaseService
 		}
 		//查出商品信息
 		$goodsInfoList = GoodsService::getAllByCondition(['id' => ['in', $goodsList]], 'inTurn DESC', 'goodsName,shopImg,price,sold,id', 'id');
-		$goodsInfoList = GoodsCategoryClass::groupGoodsBaseInfo($goodsInfoList);
+		$goodsInfoList = GoodsClass::groupGoodsBaseInfo($goodsInfoList);
 		
 		//每个分类取的商品数
 		$getNum = [6, 2, 4];

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

@@ -4,16 +4,23 @@ namespace biz\goods\services;
 
 use biz\base\services\BaseService;
 
+use biz\goods\classes\GoodsClass;
 use Yii;
 use linslin\yii2\curl;
 
 class GoodsService extends BaseService
 {
-    public static $baseFile = '\biz\goods\classes\GoodsClass';
+	public static $baseFile = '\biz\goods\classes\GoodsClass';
 
-    public static function getGoodsList($where)
-    {
-        return self::getList('*', $where, 'updateTime DESC');
-    }
+	public static function getGoodsList($where)
+	{
+		return self::getList('*', $where, 'updateTime DESC');
+	}
 
+	//获取商品完整详情 shish 2019.12.3
+	public static function getGoodsInfo($id)
+	{
+		return GoodsClass::getGoodsInfo($id);
+	}
+	
 }

+ 4 - 0
sql.txt

@@ -1,3 +1,7 @@
+2019.12.3 shish
+ALTER TABLE xhGoods ADD sendType TINYINT NOT NULL DEFAULT 0 COMMENT '配送方式 0需要配送 1到店自提' AFTER sendArea;
+ALTER TABLE xhGoods ADD freightType TINYINT NOT NULL DEFAULT 0 COMMENT '运费计算方式,0按距离计算 1免运费' AFTER sendType;
+
 2019.12.2 19:18
 DROP TABLE IF EXISTS `xhCategoryRelate`;
 ALTER TABLE xhCategory ADD indexShow TINYINT NOT NULL DEFAULT 0 COMMENT '首页上显示 0不显示 1显示' AFTER categoryName;