Browse Source

获取商品列表

shish 4 years ago
parent
commit
e5c28c917b

+ 1 - 56
app-ghs/controllers/ChatController.php

@@ -69,62 +69,7 @@ class ChatController extends BaseController
 		$id = 'merchantConsole_' . $this->sjId;
 		Gateway::bindUid($clientId, $id);
 	}
-	
-	//发消息给客户 ssh 2019.12.28
-	public function actionSend()
-	{
-		$post = Yii::$app->request->post();
-		$type = isset($post['type']) ? $post['type'] : 'text';
-		$userId = isset($post['userId']) ? $post['userId'] : 0;
-		$user = UserService::getById($userId);
-		UserService::valid($user, $this->sjId);
-		$arr = [];
-		$arr['type'] = $type;
-		$arr['source'] = 'merchant';
-		$arr['time'] = '12:51';
-		switch ($type) {
-			case 'text':
-				//文字
-				$content = $post['content'];
-				$arr['content'] = $content;
-				break;
-			case 'img':
-				//图片
-				$shortUrl = $post['shortUrl'];
-				$return = business::formatUploadImg($shortUrl);
-				$arr['url'] = $return['url'];
-				$arr['smallUrl'] = $return['smallUrl'];
-				break;
-			case 'link':
-				//常用链接
-				$id = $post['linkId'];
-				$respond = MerchantService::getCommonUrl($id);
-				$arr['name'] = $respond['name'];
-				$arr['img'] = $respond['img'];
-				$arr['url'] = $respond['url'];
-				break;
-			case 'goods':
-				//商品
-				$id = $post['goodsId'];
-				$info = GoodsService::getGoodsInfo($id);
-				GoodsService::valid($info, $this->sjId);
-				$arr['name'] = $info['name'];
-				$arr['img'] = isset($info['smallImgList'][0]) ? $info['smallImgList'][0] : '';
-				$arr['price'] = isset($info['price']) ? $info['price'] : 300;
-				break;
-		}
-		$data[] = $arr;
-		//放入缓存
-		ChatService::saveMessage($data, $userId);
-		$online = Gateway::getClientIdByUid($userId);
-		if ($online) {
-			//直接发送
-			Gateway::sendToUid($userId, json_encode($data));
-			util::success($data);
-		}
-		util::success($data);
-	}
-	
+
 	//最近联系人 ssh 2019.12.29
 	public function actionRecentlyUser()
 	{

+ 0 - 8
app-ghs/controllers/GoodsController.php

@@ -44,14 +44,6 @@ class GoodsController extends BaseController
         util::success($data);
     }
 
-    //获取商品详情 ssh 2019.12.7
-    public function actionDetail()
-    {
-        $id = Yii::$app->request->get('id');
-        $goods = GoodsService::getGoodsInfo($id);
-        util::success($goods);
-    }
-
     //更新商品 ssh 2019.12.7
     public function actionUpdate()
     {

+ 2 - 1
app-hd/controllers/ChatController.php

@@ -2,6 +2,7 @@
 
 namespace hd\controllers;
 
+use bizHd\goods\classes\GoodsClass;
 use bizHd\goods\services\GoodsService;
 use biz\sj\services\MerchantService;
 use bizHd\message\services\ChatService;
@@ -106,7 +107,7 @@ class ChatController extends BaseController
 			case 'goods':
 				//商品
 				$id = $post['goodsId'];
-				$info = GoodsService::getGoodsInfo($id);
+				$info = GoodsClass::getGoodsInfo($id);
 				GoodsService::valid($info, $this->sjId);
 				$arr['name'] = $info['name'];
 				$arr['img'] = isset($info['smallImgList'][0]) ? $info['smallImgList'][0] : '';

+ 2 - 2
app-hd/controllers/GoodsController.php

@@ -49,7 +49,7 @@ class GoodsController extends BaseController
     public function actionDetail()
     {
         $id = Yii::$app->request->get('id');
-        $goods = GoodsService::getGoodsInfo($id);
+        $goods = GoodsClass::getGoodsInfo($id);
         GoodsClass::valid($goods, $this->sjId);
         util::success($goods);
     }
@@ -159,7 +159,7 @@ class GoodsController extends BaseController
     public function actionMallDetail()
     {
         $id = Yii::$app->request->get('id', 0);
-        $info = GoodsService::getGoodsInfo($id);
+        $info = GoodsClass::getGoodsInfo($id);
         GoodsService::valid($info, $this->sjId);
         $setting = GoodsSettingService::getByCondition(['sjId' => $this->sjId]);
         $commonIntro = isset($setting['goodsIntroduce']) ? $setting['goodsIntroduce'] : '';

+ 2 - 0
app-mall/controllers/GoodsController.php

@@ -2,6 +2,7 @@
 
 namespace mall\controllers;
 
+use bizMall\goods\classes\GoodsClass;
 use bizMall\goods\services\CategoryService;
 use bizMall\goods\services\GoodsCategoryService;
 use bizMall\goods\services\GoodsService;
@@ -17,6 +18,7 @@ class GoodsController extends BaseController
 	public function actionDetail()
 	{
 		$id = Yii::$app->request->get('id', 0);
+
 		$info = GoodsService::getGoodsInfo($id);
 		GoodsService::valid($info, $this->sjId);
 		$setting = GoodsSettingService::getByCondition(['sjId' => $this->sjId]);

+ 9 - 12
biz-hd/goods/classes/GoodsClass.php

@@ -4,7 +4,6 @@ namespace bizHd\goods\classes;
 
 use biz\goods\models\Goods;
 use bizHd\goods\services\GoodsCategoryService;
-use biz\sj\services\MerchantService;
 use bizHd\work\classes\WorkItemClass;
 use common\components\business;
 use common\components\imgUtil;
@@ -27,33 +26,25 @@ class GoodsClass extends BaseClass
         if (empty($info)) {
             return [];
         }
-
-        $list = self::groupGoodsBaseInfo([$info]);
+        $list = self::groupGoodsBaseInfo([$info], true);
         $info = current($list);
         return $info;
     }
 
     //组装商品基本信息 ssh 2019.12.2
-    public static function groupGoodsBaseInfo($list)
+    public static function groupGoodsBaseInfo($list, $getItem = false)
     {
-
-        //注意这里涉及商家节日涨价的问题,不要去取不同商家的商品,确有必要另外起方法!!!!!!
-
+        //注意这里涉及商家节日涨价的问题,不要去取不同商家的商品,确有必要另外起方法!!!!!!!!!!
         $currentData = current($list);
-        $sjId = $currentData['sjId'];
         $mainId = $currentData['mainId'] ?? 0;
         $rise = GoodsSettingClass::getRise($mainId);
-
         $sjHasCategory = CategoryClass::getCategory($mainId);
-
         foreach ($list as $key => $val) {
             $id = $val['id'];
             //大中小图片转化
             $val = business::formatGoodsImg($val);
             //免费配送范围
             $val['freeSendDist'] = 5;
-            //多款式
-            $val['goodsStyleList'] = isset($val['goodsStyle']) && $val['goodsStyle'] == 1 ? array_values(GoodsStyleClass::getStyleList($id)) : [];
             $val['createDate'] = date("Y-m-d", strtotime($val['createTime']));
             //节日涨价
             if (!empty($rise)) {
@@ -77,6 +68,12 @@ class GoodsClass extends BaseClass
             }
             $val['belongCategory'] = $belongCategory;
             $val['cover'] = isset($val['smallImgList'][0]) ? $val['smallImgList'][0] : imgUtil::groupImg('');
+
+            if ($getItem) {
+                $itemList = GoodsItemClass::getAllByCondition(['goodsId' => $id], null, '*');
+                $val['goodsItem'] = $itemList;
+            }
+
             $list[$key] = $val;
         }
         return $list;