|
|
@@ -4,6 +4,7 @@ namespace biz\goods\services;
|
|
|
|
|
|
use biz\base\services\BaseService;
|
|
|
|
|
|
+use biz\goods\classes\GoodsCategoryClass;
|
|
|
use Yii;
|
|
|
use linslin\yii2\curl;
|
|
|
|
|
|
@@ -11,7 +12,7 @@ class GoodsCategoryService extends BaseService
|
|
|
{
|
|
|
|
|
|
public static $baseFile = '\biz\goods\classes\GoodsCategoryClass';
|
|
|
-
|
|
|
+
|
|
|
//分页取分类下的商品,包括商品明细 shish 2019.8.28
|
|
|
public static function getGoodsList($categoryId)
|
|
|
{
|
|
|
@@ -25,11 +26,7 @@ class GoodsCategoryService extends BaseService
|
|
|
$goodsList = [];
|
|
|
if (!empty($ids)) {
|
|
|
$goodsList = GoodsService::getByIds($ids);
|
|
|
- //$lazyShow 0 显示默认图 1显示原图
|
|
|
- $lazyShow = Yii::$app->params['page'] == 1 ? 1 : 0;
|
|
|
foreach ($goodsList as $key => $val) {
|
|
|
- //图片懒加载参数,看不见的页面显示默认图片
|
|
|
- $goodsList[$key]['lazyShow'] = $lazyShow;
|
|
|
//取出较小的封面图 shish 2019.8.3
|
|
|
$url = $val['cover'];
|
|
|
$pos = strrpos($url, '.');
|
|
|
@@ -42,14 +39,22 @@ class GoodsCategoryService extends BaseService
|
|
|
$return['list'] = $goodsList;
|
|
|
return $return;
|
|
|
}
|
|
|
-
|
|
|
- //取分类的名称和商品列表 shish 2019.7.9
|
|
|
- public static function getCategoryAndList($id)
|
|
|
+
|
|
|
+ //取出商家分类下的商品id
|
|
|
+ public static function getCategoryIdList()
|
|
|
{
|
|
|
- $category = CategoryRelateService::getById($id);
|
|
|
- Yii::$app->params['pageSize'] = 100;
|
|
|
- $goodsList = self::getGoodsList($id);
|
|
|
- return ['category' => $category, 'goodsList' => $goodsList['list']];
|
|
|
+ $merchantId = Yii::$app->params['merchantId'];
|
|
|
+ $all = GoodsCategoryClass::getAllByCondition(['merchantId' => $merchantId], 'inTurn DESC');
|
|
|
+ if (empty($all)) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ $ids = [];
|
|
|
+ foreach ($all as $category) {
|
|
|
+ $cId = $category['cId'];
|
|
|
+ $gId = $category['gId'];
|
|
|
+ $ids[$cId][] = $gId;
|
|
|
+ }
|
|
|
+ return $ids;
|
|
|
}
|
|
|
|
|
|
}
|