shish 10 mesi fa
parent
commit
d80b7e938d

+ 3 - 30
app-mall/controllers/CategoryController.php

@@ -55,37 +55,10 @@ class CategoryController extends BaseController
         $get = Yii::$app->request->get();
         $shop = $this->shop;
         $custom = $this->custom;
-        $data = GoodsCategoryClass::getGoodsList($get, $shop, $custom);
+        $params = [];
+        //调用花店端的方法,后面再分离
+        $data = GoodsCategoryClass::getGoodsList($get, $shop, $custom, $params);
         util::success($data);
     }
 
-
-    //无价格商品列表
-    public function actionNonPriceGoodsList()
-    {
-        $user = $this->user;
-        if (empty($user)) {
-            util::success(['list' => []]);
-        }
-
-        $where = [];
-        $goodsCond = [];
-        $get = Yii::$app->request->get();
-        $categoryId = isset($get['categoryId']) ? intval($get['categoryId']) : 0;
-        if ($categoryId != 0) {
-            $where['cId'] = $categoryId;
-        }
-        $where['mainId'] = $this->mainId;
-        //$where['delStatus'] = 0;//只获取非删除状态
-        //$where['status'] = 1;//上下架状态为1(正常)
-
-        $searchText = $get['searchText'] ?? '';
-        if (!empty($searchText)) {
-            $where['name'] = ['like', $searchText];
-        }
-        $goodsCond['priceType'] = 0;//限定查询的是无价格商品
-
-        $data = GoodsCategoryService::getGoodsList($where, $goodsCond);
-        util::success($data);
-    }
 }

+ 0 - 59
app-mall/controllers/ChatController.php

@@ -41,65 +41,6 @@ class ChatController extends BaseController
         util::success(['merchant' => $this->sj->attributes, 'user' => $this->user]);
     }
 
-    //发消息给老板 ssh 2019.12.28
-    public function actionSend()
-    {
-        $post = Yii::$app->request->post();
-        $type = isset($post['type']) ? $post['type'] : 'text';
-        $arr = [];
-        $arr['type'] = $type;
-        $arr['source'] = 'user';
-        $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->mainId);
-                $arr['name'] = $info['name'];
-                $arr['img'] = isset($info['smallImgList'][0]) ? $info['smallImgList'][0] : '';
-                $arr['price'] = isset($info['price']) ? $info['price'] : 300;
-                break;
-        }
-        $data[] = $arr;
-
-        $id = 'merchantChat_' . $this->sjId;
-        $chatOnline = Gateway::getClientIdByUid($id);
-        if ($chatOnline) {
-            //直接发送
-            Gateway::sendToUid($id, json_encode($data));
-            util::success($data);
-        }
-        //有打开后台但没打开聊天框,通知有新消息
-        $consoleId = 'merchantConsole_' . $this->sjId;
-        $consoleOnline = Gateway::getClientIdByUid($consoleId);
-        if ($consoleOnline) {
-            $data = ['type' => 'newMessage', 'status' => 1];
-            Gateway::sendToUid($consoleId, json_encode($data));
-        }
-        util::success($data);
-    }
-
     //关闭当前链接
     public function actionClose()
     {

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

@@ -19,8 +19,18 @@ class GoodsController extends BaseController
     {
         $id = Yii::$app->request->get('id', 0);
         $categoryId = intval(Yii::$app->request->get('categoryId'));
-        $info = GoodsClass::getGoodsInfo($id);
-        GoodsService::valid($info, $this->mainId);
+        $custom = $this->custom;
+        if (empty($custom)) {
+            util::fail('用户信息缺失');
+        }
+        $shop = $this->shop;
+        $params = [];
+        $info = GoodsClass::getGoodsInfo($id, $shop, $custom, $params);
+
+        if ($info['mainId'] != $this->mainId) {
+            util::fail('不是你的商品');
+        }
+
         $setting = GoodsSettingClass::getByCondition(['mainId' => $this->mainId]);
         $intro = $setting['goodsIntroduce'] ?? '';
         $info['commonIntro'] = $intro;

+ 0 - 24
app-mall/controllers/MainController.php

@@ -10,28 +10,4 @@ use common\components\util;
 class MainController extends BaseController
 {
 
-    //首页 ssh 2019.12.2
-    public function actionIndex()
-    {
-        $where = ['mainId' => $this->mainId, 'type' => 0, 'status' => 1, 'delStatus' => 0];
-        $adRespond = AdService::getAdList($where);
-        $ad = [];
-        if (isset($adRespond['list']) && !empty($adRespond['list'])) {
-            foreach ($adRespond['list'] as $single) {
-                $ad[] = ['adImg' => $single['adImgUrl'], 'url' => ''];
-            }
-        }
-        $shop = $this->shop;
-        $category = CategoryService::getTopThreeCategory($this->mainId);
-        $categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category, $shop) : [];
-        $sj = isset($this->sj) ? $this->sj->attributes : [];
-        $data = [
-            'ad' => $ad,
-            'category' => $categoryList,
-            'columnStyle' => rand(1, 2),
-            'sj' => $sj
-        ];
-        util::success($data);
-    }
-
 }

+ 4 - 57
biz-mall/goods/classes/GoodsClass.php

@@ -17,68 +17,15 @@ class GoodsClass extends BaseClass
     public static $baseFile = '\bizMall\goods\models\Goods';
 
     //获取商品完整详情,包括商品的分类 ssh 2019.12.3
-    public static function getGoodsInfo($id)
+    public static function getGoodsInfo($id, $shop, $custom, $params)
     {
         $info = self::getById($id);
         if (empty($info)) {
             return [];
         }
-        $list = self::groupGoodsBaseInfo([$info]);
-        $info = current($list);
-        $category = GoodsCategoryService::getGoodsHasCategoryIds($id);
-        $info['categoryIdList'] = $category;
-        return $info;
-    }
-
-    /**
-     * 组装商品基本信息
-     * @param $list
-     * @param array $sortIds
-     * @return mixed
-     */
-    public static function groupGoodsBaseInfo($list, $sortIds = [])
-    {
-        if (empty($list)) {
-            return [];
-        }
-        $arrNotEmpty = is_array($sortIds) && !empty($sortIds);
-
-        foreach ($list as $key => $val) {
-            $id = $val['id'];
-            //大中小图片转化
-            $val = business::formatGoodsImg($val);
-            //免费配送范围
-            $val['freeSendDist'] = 5;
-            //多款式
-            $val['goodsStyleList'] = [];
-            $val['createDate'] = date("Y-m-d", strtotime($val['createTime']));
-
-
-
-            $shortCover = $val['cover'] ?? '';
-            $val['cover'] = imgUtil::groupImg($shortCover);
-            $val['shortCover'] = $shortCover;
-            $val['smallCover'] = $val['cover'] . "?x-oss-process=image/resize,m_fill,h_130,w_130";
-            $val['bigCover'] = $val['cover'] . "?x-oss-process=image/resize,m_fill,h_700,w_700";
-
-            if ($arrNotEmpty) {
-                $sortIndex = array_search($id, $sortIds);
-                // $newList[$sortIndex] = $val;
-                $val['sortWeight'] = $sortIndex !== false ? $sortIndex : count($sortIds);
-            }
-
-            $list[$key] = $val;
-        }
-
-        if ($arrNotEmpty) {
-            usort($list, function($a, $b) {
-                return $a['sortWeight'] - $b['sortWeight'];
-            });
-            //return $newList;
-            // return array_values($newList);
-        }
-
-        return $list;
+        //暂时先用花店端的方法,后面再分离
+        $list = \bizHd\goods\classes\GoodsClass::groupGoodsBaseInfo([$info], $shop, $custom, $params);
+        return current($list);
     }
 
     public static function addGoods($data)

+ 0 - 83
biz-mall/goods/services/GoodsCategoryService.php

@@ -4,95 +4,12 @@ namespace bizMall\goods\services;
 
 use bizMall\base\services\BaseService;
 use bizMall\goods\classes\GoodsCategoryClass;
-use bizMall\goods\classes\GoodsClass;
-
 
 class GoodsCategoryService extends BaseService
 {
 
     public static $baseFile = '\bizMall\goods\classes\GoodsCategoryClass';
 
-    /**
-     * 查询一个分类下的商品,有分页
-     * @param array $where
-     * @param array $goodsCondition
-     * @return mixed
-     */
-    public static function getGoodsList($where, $goodsCondition = [])
-    {
-        $data = GoodsCategoryClass::getList('*', $where, 'inTurn DESC');
-        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
-        if (empty($list)) {
-            return $data;
-        }
-        $ids = array_column($list, 'gId');
-        $goodsWhere = ['id' => ['in', $ids]];
-        if (count($goodsCondition) > 0) {
-            $goodsWhere = array_merge($goodsWhere, $goodsCondition);
-        }
-        $list = GoodsService::getAllByCondition($goodsWhere, null, '*');
-        $data['list'] = GoodsClass::groupGoodsBaseInfo($list, $ids);
-        return $data;
-    }
-
-    //查询指定分类下的商品,没有分页,首页使用 ssh 2019.12.2
-    public static function getAppointCategoryList($category, $shop)
-    {
-        $ids = array_column($category, 'id');
-
-        //每个分类取的商品数
-        $getNum = [6, 2, 4];
-        $showRowNum = [2, 1, 2];
-
-        $stockModel = $shop->stockModel ?? 0;
-        if ($stockModel == 0) {
-            //管到扎的,可以查看所有上架的商品
-            $where = ['cId' => ['in', $ids], 'status' => 1];
-        } else {
-            //管到支的,查看所有上架并且花材数量设置好的商品
-            $where = ['cId' => ['in', $ids], 'status' => 1, 'setItemNum' => 1];
-        }
-
-        //取出分类下的商品id
-        $list = GoodsCategoryClass::getAllByCondition($where, 'inTurn DESC,addTime DESC', '*');
-        if (empty($list)) {
-            foreach ($category as $key => $val) {
-                $category[$key]['goodsInfoList'] = [];
-                $category[$key]['showRow'] = $showRowNum[$key] ?? 2;
-            }
-            return $category;
-        }
-        $goodsList = [];
-        $categoryGoods = [];
-        foreach ($list as $val) {
-            $goodsList[] = $val['gId'];
-            $cId = $val['cId'];
-            $categoryGoods[$cId][] = $val['gId'];
-        }
-        //查出商品信息
-        $goodsInfoList = GoodsService::getAllByCondition(['id' => ['in', $goodsList]], 'inTurn DESC', '*', 'id');
-        $goodsInfoList = GoodsClass::groupGoodsBaseInfo($goodsInfoList);
-
-        foreach ($category as $key => $val) {
-            $id = $val['id'];
-            //当前分类下有哪些商品id,并组合商品信息
-            $categoryGoodsIdList = $categoryGoods[$id] ?? [];
-            $info = [];
-            if (!empty($categoryGoodsIdList)) {
-                $currentGetNum = $getNum[$key] ?? 2;
-                $categoryGoodsIdList = array_slice($categoryGoodsIdList, 0, $currentGetNum);
-                foreach ($categoryGoodsIdList as $currentGoodsId) {
-                    if (isset($goodsInfoList[$currentGoodsId])) {
-                        $info[] = $goodsInfoList[$currentGoodsId];
-                    }
-                }
-            }
-            $category[$key]['goodsInfoList'] = $info;
-            $category[$key]['showRow'] = $showRowNum[$key] ?? 2;
-        }
-        return $category;
-    }
-
     //获取商品所属的分类id  ssh 201917
     public static function getGoodsHasCategoryIds($goodsId)
     {

+ 0 - 28
biz-mall/goods/services/GoodsService.php

@@ -16,34 +16,6 @@ class GoodsService extends BaseService
 
     public static $baseFile = '\bizMall\goods\classes\GoodsClass';
 
-    //后台列表 ssh 2019.12.7
-    public static function getGoodsList($where)
-    {
-        if (isset($where['cId'])) {
-            $data = GoodsCategoryClass::getList('*', $where, 'inTurn DESC', 'goods');
-            $list = [];
-            if (isset($data['list']) && !empty($data['list'])) {
-                foreach ($data['list'] as $val) {
-                    $list[] = $val['goods'];
-                }
-            }
-        } else {
-            $data = GoodsClass::getList('*', $where, 'inTurn DESC,updateTime DESC');
-            $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
-        }
-        if (empty($list)) {
-            return $data;
-        }
-        $data['list'] = GoodsClass::groupGoodsBaseInfo($list);
-        return $data;
-    }
-
-    //获取商品完整详情,包括分类 ssh 2019.12.3
-    public static function getGoodsInfo($id)
-    {
-        return GoodsClass::getGoodsInfo($id);
-    }
-
     //删除商品 ssh 2019.12.7
     public static function deleteGoods($goods)
     {