Authored by hf

code review by hf: do format product detail data structure

... ... @@ -153,8 +153,9 @@ class DetailModel
// 商品信息
if (!empty($baseInfo['goodsList'])) {
$colorGroup = array();
$sizeList = array();
$sizeGroup = array();
$goodsGroup = array();
$sizeList = array();
$thumbImageList = array();
$colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
$sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔
... ... @@ -177,7 +178,7 @@ class DetailModel
// 商品的尺码列表
if (isset($value['goodsSizeBoList'])) {
foreach ($value['goodsSizeBoList'] as $size) {
$sizeList[] = array(
$sizeList[ $value['colorId'] ][] = array(
'id' => $size['id'],
'skuId' => $size['goodsSizeSkuId'],
'goodsId' => $size['goodsId'],
... ... @@ -189,22 +190,21 @@ class DetailModel
$sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
$colorStorageGroup[ $size['sizeName'] ][ $value['colorName'] ] = $size['goodsSizeStorageNum'];
}
// 颜色分组
$colorGroup[] = array(
'id' => $value['colorId'],
'skcId' => $value['productSkc'],
'name' => $value['colorName'],
'goodsName' => $value['goodsName'],
'colorNum' => $colorStorageNum,
'sizeNumStr' => rtrim($sizeStorageStr, '/'),
);
}
// 颜色分组
$colorGroup[] = array(
'id' => $value['colorId'],
'skcId' => $value['productSkc'],
'name' => $value['colorName'],
'goodsName' => $value['goodsName'],
'colorNum' => $colorStorageNum,
'sizeNumStr' => rtrim($sizeStorageStr, '/'),
);
// 缩略图
$thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60) );
// 统计尺码对应的各个颜色的库存量
foreach ($sizeList as &$sizeArr) {
$sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) );
}
... ... @@ -212,6 +212,11 @@ class DetailModel
// 商品库存总数
$totalStorageNum += $colorStorageNum;
}
// 统计尺码对应的各个颜色的库存量
foreach ($colorGroup as $value) {
$sizeGroup[]['size'] = $sizeList[ $value['colorId'] ];
}
// 商品图: 多个
if (isset($goodsGroup[1])) {
... ... @@ -247,7 +252,7 @@ class DetailModel
$result['cartInfo']['salePrice'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : '';
$result['cartInfo']['totalNum'] = $totalStorageNum;
$result['cartInfo']['colors'] = $colorGroup;
$result['cartInfo']['sizes'] = $sizeList;
$result['cartInfo']['sizes'] = $sizeGroup;
}
// 非卖品
elseif ($notForSale) {
... ...