|
|
@@ -3,7 +3,6 @@
|
|
|
namespace biz\goods\services;
|
|
|
|
|
|
use biz\base\services\BaseService;
|
|
|
-
|
|
|
use biz\goods\classes\GoodsCategoryClass;
|
|
|
use Yii;
|
|
|
use linslin\yii2\curl;
|
|
|
@@ -13,48 +12,18 @@ class GoodsCategoryService extends BaseService
|
|
|
|
|
|
public static $baseFile = '\biz\goods\classes\GoodsCategoryClass';
|
|
|
|
|
|
- //分页取分类下的商品,包括商品明细 shish 2019.8.28
|
|
|
- public static function getGoodsList($categoryId)
|
|
|
- {
|
|
|
- $select = '*';
|
|
|
- $order = 'inTurn desc';
|
|
|
- $merchantId = Yii::$app->params['merchantId'];
|
|
|
- $where = ['merchantId' => $merchantId, 'cId' => $categoryId];
|
|
|
- $return = self::getList($select, $where, $order);
|
|
|
- $list = $return['list'];
|
|
|
- $ids = array_column($list, 'gId');
|
|
|
- $goodsList = [];
|
|
|
- if (!empty($ids)) {
|
|
|
- $goodsList = GoodsService::getByIds($ids);
|
|
|
- foreach ($goodsList as $key => $val) {
|
|
|
- //取出较小的封面图 shish 2019.8.3
|
|
|
- $url = $val['cover'];
|
|
|
- $pos = strrpos($url, '.');
|
|
|
- $pre = substr($url, 0, $pos);
|
|
|
- $ext = substr($url, ($pos + 1));
|
|
|
- $middleCover = $pre . '_200.' . $ext;
|
|
|
- $goodsList[$key]['middleCover'] = $middleCover;
|
|
|
- }
|
|
|
- }
|
|
|
- $return['list'] = $goodsList;
|
|
|
- return $return;
|
|
|
- }
|
|
|
-
|
|
|
- //取出商家分类下的商品id
|
|
|
- public static function getCategoryIdList()
|
|
|
+ //分类下的商品 shish 2019.12.2
|
|
|
+ public static function getGoodsList($where)
|
|
|
{
|
|
|
- $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;
|
|
|
+ $data = GoodsCategoryClass::getList('*', $where, 'inTurn DESC');
|
|
|
+ $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
|
|
|
+ if (empty($list)) {
|
|
|
+ return $data;
|
|
|
}
|
|
|
- return $ids;
|
|
|
+ $ids = array_column($list, 'gId');
|
|
|
+ $list = GoodsService::getAllByCondition(['id' => ['in', $ids]], 'inTurn DESC', 'goodsName,shopImg,price,sold');
|
|
|
+ $data['list'] = GoodsCategoryClass::groupGoodsBaseInfo($list);
|
|
|
+ return $data;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|