|
|
@ -332,9 +332,17 @@ class Goods extends GoodsModel |
|
|
|
public function getDetails(int $goodsId, bool $verifyStatus = true) |
|
|
|
public function getDetails(int $goodsId, bool $verifyStatus = true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// 关联查询(商品图片、sku列表) |
|
|
|
// 关联查询(商品图片、sku列表) |
|
|
|
$with = ['images.file', 'skuList.image', 'video', 'videoCover']; |
|
|
|
//$with = ['images.file', 'skuList.image', 'video', 'videoCover']; |
|
|
|
|
|
|
|
$info = $this->field('spec_type,goods_id')->find($goodsId); |
|
|
|
|
|
|
|
// 关联查询 |
|
|
|
|
|
|
|
if ($info->spec_type == GoodsSpecTypeEnum::SINGLE) { |
|
|
|
|
|
|
|
$with = ['images.file', 'skuList1.image', 'video', 'videoCover']; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$with = ['images.file', 'skuList.image', 'video', 'videoCover']; |
|
|
|
|
|
|
|
} |
|
|
|
// 获取商品记录 |
|
|
|
// 获取商品记录 |
|
|
|
$goodsInfo = $this->getGoodsMain($goodsId, $with, $verifyStatus); |
|
|
|
$goodsInfo = $this->getGoodsMain($goodsId, $with, $verifyStatus); |
|
|
|
|
|
|
|
|
|
|
|
// 商品规格列表 |
|
|
|
// 商品规格列表 |
|
|
|
$goodsInfo['specList'] = GoodsSpecRelModel::getSpecList($goodsInfo['goods_id']); |
|
|
|
$goodsInfo['specList'] = GoodsSpecRelModel::getSpecList($goodsInfo['goods_id']); |
|
|
|
$GoodsCategoryRelModel = new GoodsCategoryRelModel(); |
|
|
|
$GoodsCategoryRelModel = new GoodsCategoryRelModel(); |
|
|
@ -348,41 +356,13 @@ class Goods extends GoodsModel |
|
|
|
$goodsInfo->category = $category ? $category->toArray() : []; |
|
|
|
$goodsInfo->category = $category ? $category->toArray() : []; |
|
|
|
//多规格 |
|
|
|
//多规格 |
|
|
|
$goodsInfo->specifications = []; |
|
|
|
$goodsInfo->specifications = []; |
|
|
|
// $skuList = []; |
|
|
|
|
|
|
|
// $specList = []; |
|
|
|
|
|
|
|
// if ($goodsInfo->spu_id > 0) { |
|
|
|
|
|
|
|
// //查同规格的商品 |
|
|
|
|
|
|
|
// $spe = GoodsModel::where([ |
|
|
|
|
|
|
|
// 'spu_id' => $goodsInfo->spu_id, |
|
|
|
|
|
|
|
// 'store_id' => request()->header()['storeid'], |
|
|
|
|
|
|
|
// 'is_delete' => 0 |
|
|
|
|
|
|
|
// ])->column('goods_id'); |
|
|
|
|
|
|
|
// foreach ($spe as $k => $v) { |
|
|
|
|
|
|
|
// //$sku1 = $this->getSpecData($v)['skuList']->toArray()[0]; |
|
|
|
|
|
|
|
// // $skuList[] = $sku1; |
|
|
|
|
|
|
|
// $spe1 = $this->getSpecData($v)['specList'][0]; |
|
|
|
|
|
|
|
// $spe1['valueList'][0]['goods_id'] = $v; |
|
|
|
|
|
|
|
// $aa = 0; |
|
|
|
|
|
|
|
// foreach ($specList as &$v2) { |
|
|
|
|
|
|
|
// if ($v2['spec_name'] == $spe1['spec_name']) { |
|
|
|
|
|
|
|
// $aa = 1; |
|
|
|
|
|
|
|
// $v2['valueList'][] = $spe1['valueList']; |
|
|
|
|
|
|
|
// break; |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if ($aa == 0) { |
|
|
|
|
|
|
|
// $specList[] = $spe1; |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$goodsInfo = $goodsInfo->toArray(); |
|
|
|
$goodsInfo = $goodsInfo->toArray(); |
|
|
|
|
|
|
|
|
|
|
|
//替换原规格数组 |
|
|
|
if (isset($goodsInfo['skuList1'])) { |
|
|
|
// $goodsInfo['skuList2'] = $skuList; |
|
|
|
$goodsInfo['skuList'] = $goodsInfo['skuList1']; |
|
|
|
$goodsInfo['specList2'] = $specList ?? []; |
|
|
|
unset($goodsInfo['skuList1']); |
|
|
|
|
|
|
|
} |
|
|
|
//加入足迹 |
|
|
|
//加入足迹 |
|
|
|
$userId = UserService::getCurrentLoginUserId(false) ?? ''; |
|
|
|
$userId = UserService::getCurrentLoginUserId(false) ?? ''; |
|
|
|
if ($userId) { |
|
|
|
if ($userId) { |
|
|
@ -426,6 +406,8 @@ class Goods extends GoodsModel |
|
|
|
{ |
|
|
|
{ |
|
|
|
// 关联查询(商品图片) |
|
|
|
// 关联查询(商品图片) |
|
|
|
$with = ['images.file']; |
|
|
|
$with = ['images.file']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取商品记录 |
|
|
|
// 获取商品记录 |
|
|
|
return $this->getGoodsMain($goodsId, $with, $verifyStatus); |
|
|
|
return $this->getGoodsMain($goodsId, $with, $verifyStatus); |
|
|
|
} |
|
|
|
} |
|
|
|