|
@@ -142,7 +142,7 @@ class DetailModel |
|
@@ -142,7 +142,7 @@ class DetailModel |
142
|
$result['feedbacks']['comments'][] = $build;
|
142
|
$result['feedbacks']['comments'][] = $build;
|
143
|
}
|
143
|
}
|
144
|
$result['feedbacks']['commentsUrl'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum']));
|
144
|
$result['feedbacks']['commentsUrl'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum']));
|
145
|
- }
|
145
|
+ }
|
146
|
|
146
|
|
147
|
// 品牌信息
|
147
|
// 品牌信息
|
148
|
if (!empty($baseInfo['brand'])) {
|
148
|
if (!empty($baseInfo['brand'])) {
|
|
@@ -157,41 +157,59 @@ class DetailModel |
|
@@ -157,41 +157,59 @@ class DetailModel |
157
|
|
157
|
|
158
|
// 商品信息
|
158
|
// 商品信息
|
159
|
if (!empty($baseInfo['goodsList'])) {
|
159
|
if (!empty($baseInfo['goodsList'])) {
|
160
|
-// $colorGroup = array();
|
|
|
161
|
-// $sizeGroup = array();
|
|
|
162
|
- $goodsList = array();
|
160
|
+ $colorGroup = array();
|
|
|
161
|
+ $sizeList = array();
|
163
|
$goodsGroup = array();
|
162
|
$goodsGroup = array();
|
164
|
- $colorId = 0;
|
|
|
165
|
- foreach ($baseInfo['goodsList'] as $value) {
|
|
|
166
|
- $colorId = intval($value['colorId']);
|
|
|
167
|
- // 商品按颜色进行分类分组
|
163
|
+ $coverImage = '';
|
|
|
164
|
+ $colorStorageNum = 0; // 颜色的库存总数
|
|
|
165
|
+ $totalStorageNum = 0; // 总库存数
|
|
|
166
|
+ foreach ($baseInfo['goodsList'] as $i => $value) {
|
|
|
167
|
+ $sizeList = array();
|
|
|
168
|
+ $colorStorageNum = 0;
|
|
|
169
|
+
|
|
|
170
|
+ // 获取默认的封面图
|
|
|
171
|
+ if ($i === 0) {
|
|
|
172
|
+ $coverImage = Helpers::getImageUrl($value['colorImage'], 60, 60);
|
|
|
173
|
+ }
|
|
|
174
|
+
|
|
|
175
|
+ // 商品分组
|
168
|
if (isset($value['goodsImagesList'])) {
|
176
|
if (isset($value['goodsImagesList'])) {
|
169
|
foreach ($value['goodsImagesList'] as $goods) {
|
177
|
foreach ($value['goodsImagesList'] as $goods) {
|
170
|
- $goodsList[$goods['goodsId']] = $colorId;
|
|
|
171
|
$goodsGroup[] = array(
|
178
|
$goodsGroup[] = array(
|
172
|
'goodsId' => $goods['goodsId'],
|
179
|
'goodsId' => $goods['goodsId'],
|
173
|
'img' => $goods['imageUrl'],
|
180
|
'img' => $goods['imageUrl'],
|
174
|
);
|
181
|
);
|
175
|
-// $colorGroup[$colorId] = array(
|
|
|
176
|
-// 'colorId' => $colorId,
|
|
|
177
|
-// 'colorName' => $value['colorName'],
|
|
|
178
|
-// 'colorImage' => Helpers::getImageUrl($value['colorImage'], 60, 60),
|
|
|
179
|
-// );
|
|
|
180
|
}
|
182
|
}
|
181
|
}
|
183
|
}
|
182
|
|
184
|
|
183
|
-// // 商品的尺码列表
|
|
|
184
|
-// if (isset($value['goodsSizeBoList'])) {
|
|
|
185
|
-// foreach ($value['goodsSizeBoList'] as $size) {
|
|
|
186
|
-// $sizeGroup[$colorId] = array(
|
|
|
187
|
-// 'sizeName' => $size['sizeName'],
|
|
|
188
|
-// 'sizeSku' => $size['goodsSizeSkuId'],
|
|
|
189
|
-// 'sizeStorage' => $size['goodsSizeStorageNum'],
|
|
|
190
|
-// );
|
|
|
191
|
-// }
|
|
|
192
|
-// }
|
185
|
+ // 商品的尺码列表
|
|
|
186
|
+ if (isset($value['goodsSizeBoList'])) {
|
|
|
187
|
+ foreach ($value['goodsSizeBoList'] as $size) {
|
|
|
188
|
+ $sizeList[] = array(
|
|
|
189
|
+ 'id' => $size['id'],
|
|
|
190
|
+ 'skuId' => $size['goodsSizeSkuId'],
|
|
|
191
|
+ 'goodsId' => $size['goodsId'],
|
|
|
192
|
+ 'name' => $size['sizeName'],
|
|
|
193
|
+ 'sizeNum' => $size['goodsSizeStorageNum'],
|
|
|
194
|
+ );
|
|
|
195
|
+ $colorStorageNum += intval($size['goodsSizeStorageNum']);
|
|
|
196
|
+ }
|
|
|
197
|
+ }
|
|
|
198
|
+
|
|
|
199
|
+ // 颜色分组
|
|
|
200
|
+ $colorGroup[] = array(
|
|
|
201
|
+ 'id' => $value['colorId'],
|
|
|
202
|
+ 'skcId' => $value['productSkc'],
|
|
|
203
|
+ 'name' => $value['colorName'],
|
|
|
204
|
+ 'goodsName' => $value['goodsName'],
|
|
|
205
|
+ 'shortUrl' => Helpers::getImageUrl($value['colorImage'], 60, 60),
|
|
|
206
|
+ 'colorNum' => $colorStorageNum,
|
|
|
207
|
+ 'sizes' => $sizeList,
|
|
|
208
|
+ );
|
|
|
209
|
+
|
|
|
210
|
+ $totalStorageNum += $colorStorageNum;
|
193
|
}
|
211
|
}
|
194
|
-
|
212
|
+
|
195
|
// 商品图: 多个
|
213
|
// 商品图: 多个
|
196
|
if (isset($goodsGroup[1])) {
|
214
|
if (isset($goodsGroup[1])) {
|
197
|
foreach ($goodsGroup as $value) {
|
215
|
foreach ($goodsGroup as $value) {
|
|
@@ -214,11 +232,19 @@ class DetailModel |
|
@@ -214,11 +232,19 @@ class DetailModel |
214
|
'numInCart' => 0,
|
232
|
'numInCart' => 0,
|
215
|
'goodsInstore' => $baseInfo['storage'], // 库存量
|
233
|
'goodsInstore' => $baseInfo['storage'], // 库存量
|
216
|
);
|
234
|
);
|
217
|
- $soldOut = $baseInfo['storage'] == 0;
|
235
|
+ $soldOut = $totalStorageNum === 0;
|
218
|
$notForSale = $baseInfo['attribute'] == 2;
|
236
|
$notForSale = $baseInfo['attribute'] == 2;
|
219
|
// 显示加入购物车链接
|
237
|
// 显示加入购物车链接
|
220
|
if (!$soldOut && !$notForSale) {
|
238
|
if (!$soldOut && !$notForSale) {
|
221
|
- $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'); //
|
239
|
+ $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
|
|
|
240
|
+
|
|
|
241
|
+ $result['cartInfo']['productId'] = $productId;
|
|
|
242
|
+ $result['cartInfo']['thumb'] = $coverImage;
|
|
|
243
|
+ $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
|
|
|
244
|
+ $result['cartInfo']['price'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : '';
|
|
|
245
|
+ $result['cartInfo']['salePrice'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : '';
|
|
|
246
|
+ $result['cartInfo']['totalNum'] = $totalStorageNum;
|
|
|
247
|
+ $result['cartInfo']['colors'] = $colorGroup;
|
222
|
}
|
248
|
}
|
223
|
// 非卖品
|
249
|
// 非卖品
|
224
|
elseif ($notForSale) {
|
250
|
elseif ($notForSale) {
|
|
@@ -251,11 +277,11 @@ class DetailModel |
|
@@ -251,11 +277,11 @@ class DetailModel |
251
|
*/
|
277
|
*/
|
252
|
public static function getSizeInfo($productSkn)
|
278
|
public static function getSizeInfo($productSkn)
|
253
|
{
|
279
|
{
|
254
|
- $result = array();
|
280
|
+ $result = array();
|
255
|
|
281
|
|
256
|
if (is_numeric($productSkn)) {
|
282
|
if (is_numeric($productSkn)) {
|
257
|
// 调用服务
|
283
|
// 调用服务
|
258
|
- $sizeInfo = DetailData::sizeInfo($productSkn);
|
284
|
+ $sizeInfo = DetailData::sizeInfo($productSkn);
|
259
|
|
285
|
|
260
|
// 商品信息
|
286
|
// 商品信息
|
261
|
if (isset($sizeInfo['productDescBo']['erpProductId'])) {
|
287
|
if (isset($sizeInfo['productDescBo']['erpProductId'])) {
|
|
@@ -345,7 +371,6 @@ class DetailModel |
|
@@ -345,7 +371,6 @@ class DetailModel |
345
|
} else {
|
371
|
} else {
|
346
|
$result['sizeInfo']['detail']['list'][0]['params'] = array(0 => array('param' => ''));
|
372
|
$result['sizeInfo']['detail']['list'][0]['params'] = array(0 => array('param' => ''));
|
347
|
}
|
373
|
}
|
348
|
-
|
|
|
349
|
}
|
374
|
}
|
350
|
|
375
|
|
351
|
// 测量方式
|
376
|
// 测量方式
|