...
|
...
|
@@ -157,39 +157,57 @@ class DetailModel |
|
|
|
|
|
// 商品信息
|
|
|
if (!empty($baseInfo['goodsList'])) {
|
|
|
// $colorGroup = array();
|
|
|
// $sizeGroup = array();
|
|
|
$goodsList = array();
|
|
|
$colorGroup = array();
|
|
|
$sizeList = array();
|
|
|
$goodsGroup = array();
|
|
|
$colorId = 0;
|
|
|
foreach ($baseInfo['goodsList'] as $value) {
|
|
|
$colorId = intval($value['colorId']);
|
|
|
// 商品按颜色进行分类分组
|
|
|
$coverImage = '';
|
|
|
$colorStorageNum = 0; // 颜色的库存总数
|
|
|
$totalStorageNum = 0; // 总库存数
|
|
|
foreach ($baseInfo['goodsList'] as $i => $value) {
|
|
|
$sizeList = array();
|
|
|
$colorStorageNum = 0;
|
|
|
|
|
|
// 获取默认的封面图
|
|
|
if ($i === 0) {
|
|
|
$coverImage = Helpers::getImageUrl($value['colorImage'], 60, 60);
|
|
|
}
|
|
|
|
|
|
// 商品分组
|
|
|
if (isset($value['goodsImagesList'])) {
|
|
|
foreach ($value['goodsImagesList'] as $goods) {
|
|
|
$goodsList[$goods['goodsId']] = $colorId;
|
|
|
$goodsGroup[] = array(
|
|
|
'goodsId' => $goods['goodsId'],
|
|
|
'img' => $goods['imageUrl'],
|
|
|
);
|
|
|
// $colorGroup[$colorId] = array(
|
|
|
// 'colorId' => $colorId,
|
|
|
// 'colorName' => $value['colorName'],
|
|
|
// 'colorImage' => Helpers::getImageUrl($value['colorImage'], 60, 60),
|
|
|
// );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// // 商品的尺码列表
|
|
|
// if (isset($value['goodsSizeBoList'])) {
|
|
|
// foreach ($value['goodsSizeBoList'] as $size) {
|
|
|
// $sizeGroup[$colorId] = array(
|
|
|
// 'sizeName' => $size['sizeName'],
|
|
|
// 'sizeSku' => $size['goodsSizeSkuId'],
|
|
|
// 'sizeStorage' => $size['goodsSizeStorageNum'],
|
|
|
// );
|
|
|
// }
|
|
|
// }
|
|
|
// 商品的尺码列表
|
|
|
if (isset($value['goodsSizeBoList'])) {
|
|
|
foreach ($value['goodsSizeBoList'] as $size) {
|
|
|
$sizeList[] = array(
|
|
|
'id' => $size['id'],
|
|
|
'skuId' => $size['goodsSizeSkuId'],
|
|
|
'goodsId' => $size['goodsId'],
|
|
|
'name' => $size['sizeName'],
|
|
|
'sizeNum' => $size['goodsSizeStorageNum'],
|
|
|
);
|
|
|
$colorStorageNum += intval($size['goodsSizeStorageNum']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 颜色分组
|
|
|
$colorGroup[] = array(
|
|
|
'id' => $value['colorId'],
|
|
|
'skcId' => $value['productSkc'],
|
|
|
'name' => $value['colorName'],
|
|
|
'goodsName' => $value['goodsName'],
|
|
|
'shortUrl' => Helpers::getImageUrl($value['colorImage'], 60, 60),
|
|
|
'colorNum' => $colorStorageNum,
|
|
|
'sizes' => $sizeList,
|
|
|
);
|
|
|
|
|
|
$totalStorageNum += $colorStorageNum;
|
|
|
}
|
|
|
|
|
|
// 商品图: 多个
|
...
|
...
|
@@ -214,11 +232,19 @@ class DetailModel |
|
|
'numInCart' => 0,
|
|
|
'goodsInstore' => $baseInfo['storage'], // 库存量
|
|
|
);
|
|
|
$soldOut = $baseInfo['storage'] == 0;
|
|
|
$soldOut = $totalStorageNum === 0;
|
|
|
$notForSale = $baseInfo['attribute'] == 2;
|
|
|
// 显示加入购物车链接
|
|
|
if (!$soldOut && !$notForSale) {
|
|
|
$result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'); //
|
|
|
$result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
|
|
|
|
|
|
$result['cartInfo']['productId'] = $productId;
|
|
|
$result['cartInfo']['thumb'] = $coverImage;
|
|
|
$result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
|
|
|
$result['cartInfo']['price'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : '';
|
|
|
$result['cartInfo']['salePrice'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : '';
|
|
|
$result['cartInfo']['totalNum'] = $totalStorageNum;
|
|
|
$result['cartInfo']['colors'] = $colorGroup;
|
|
|
}
|
|
|
// 非卖品
|
|
|
elseif ($notForSale) {
|
...
|
...
|
@@ -345,7 +371,6 @@ class DetailModel |
|
|
} else {
|
|
|
$result['sizeInfo']['detail']['list'][0]['params'] = array(0 => array('param' => ''));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 测量方式
|
...
|
...
|
|