|
|
|
@ -16,6 +16,7 @@ use app\api\service\Goods as GoodsService; |
|
|
|
|
use app\api\service\user\Grade as UserGradeService; |
|
|
|
|
use app\api\model\GoodsSku as GoodsSkuModel; |
|
|
|
|
use app\api\model\store\Module as StoreModuleModel; |
|
|
|
|
use app\common\model\GoodsCategoryRel as GoodsCategoryRelModel; |
|
|
|
|
use app\api\model\GoodsSpecRel as GoodsSpecRelModel; |
|
|
|
|
use app\common\model\Goods as GoodsModel; |
|
|
|
|
use app\common\enum\goods\Status as GoodsStatusEnum; |
|
|
|
@ -94,7 +95,7 @@ class Goods extends GoodsModel |
|
|
|
|
* @return mixed|\think\model\Collection|\think\Paginator |
|
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
|
*/ |
|
|
|
|
public function getList(array $param = [],int $listRows = 15) |
|
|
|
|
public function getList(array $param = [], int $listRows = 15) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
// 整理查询参数 |
|
|
|
@ -130,6 +131,36 @@ class Goods extends GoodsModel |
|
|
|
|
$goodsInfo = $this->getGoodsMain($goodsId, $with, $verifyStatus); |
|
|
|
|
// 商品规格列表 |
|
|
|
|
$goodsInfo['specList'] = GoodsSpecRelModel::getSpecList($goodsInfo['goods_id']); |
|
|
|
|
$GoodsCategoryRelModel = new GoodsCategoryRelModel(); |
|
|
|
|
$category = $GoodsCategoryRelModel |
|
|
|
|
->alias('a') |
|
|
|
|
->join('category b', 'a.category_id = b.category_id') |
|
|
|
|
->where([ |
|
|
|
|
'a.goods_id' => $goodsId, |
|
|
|
|
'a.store_id' => request()->header()['storeid'] |
|
|
|
|
])->find()->toArray(); |
|
|
|
|
$goodsInfo->category = $category; |
|
|
|
|
//多规格 |
|
|
|
|
$goodsInfo->specifications = []; |
|
|
|
|
if ($goodsInfo->spu_id > 0) { |
|
|
|
|
//查同规格的商品 |
|
|
|
|
$spe = GoodsModel::where([ |
|
|
|
|
'spu_id' => $goodsInfo->spu_id, |
|
|
|
|
'store_id' => request()->header()['storeid'], |
|
|
|
|
'is_delete' => 0 |
|
|
|
|
])->column('goods_id'); |
|
|
|
|
$skuList = []; |
|
|
|
|
$specList = []; |
|
|
|
|
foreach ($spe as $v) { |
|
|
|
|
$skuList = $this->getSpecData($v)['skuList']->toArray()[0]; |
|
|
|
|
$specList = $this->getSpecData($v)['specList'][0]; |
|
|
|
|
} |
|
|
|
|
$newList = [ |
|
|
|
|
'skuList' => $skuList, |
|
|
|
|
'specList' => $specList |
|
|
|
|
]; |
|
|
|
|
$goodsInfo->specifications = $newList; |
|
|
|
|
} |
|
|
|
|
return $goodsInfo->hidden(static::getHidden(['images'])); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|