Authored by Rock Zhang

修复加价购商品详情的bug

Code Review By Rock Zhang
framework @ e9d066dd
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
Subproject commit e9d066dd88a8e7e37103021c427a205a5cfcdcec
... ...
... ... @@ -69,7 +69,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
i;
var $siblingBlock = $this.closest('.block-list').siblings(':first'),
currentNumArray = $this.data('numstr').split('/');
currentNumArray = ($this.data('numstr') + '').split('/');
$this.siblings('.chosed').removeClass('chosed');
$this.toggleClass('chosed');
... ... @@ -96,7 +96,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}
});
} else if ($chosed.length === 1 && $this.hasClass('chosed')) {
numArray = $chosed.data('numstr').split('/');
numArray = ($chosed.data('numstr') + '').split('/');
$siblingBlock.find('.block').removeClass('zero-stock');
for (i = 0; i < numArray.length; i++) {
if (0 === numArray[i] - 0) {
... ...
... ... @@ -582,18 +582,14 @@ class CartModel
{
$data = array();
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['price'] = Helpers::transPrice($productData['market_price']);
$data['salePrice'] = Helpers::transPrice($productData['sales_price']);
if (isset($productData['storage_sum'])) {
$data['storage'] = $productData['storage_sum'];
}
$data['num'] = 1;
if ($num !== null) {
$data['num'] = $num;
}
... ... @@ -606,25 +602,62 @@ class CartModel
$oneColor = array();
$sizes = array();
$oneSize = array();
$thumbImageList = array();
$colorNum = 0;
$totalStorageNum = 0; // 总库存数
$colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
$colorNum = 0;
$sizeStorageStr = '';
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['skuId'] = $one['product_sku'];
$oneSize['goodsId'] = $val['goods_id'];
$oneSize['colorId'] = $val['color_id'];
$oneSize['name'] = $one['size_name'];
$oneSize['sizeNum'] = $one['storage_number'];
$colorNum += $one['storage_number'];
$sizeStorageStr .= $one['storage_number'] . '/';
$sizes[] = $oneSize;
$colorStorageGroup[$one['size_name']][$val['color_name']] = $one['storage_number'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
// 统计尺码对应的各个颜色的库存量
foreach ($sizes as &$sizeArr) {
$sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) );
}
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['skcId'] = $val['product_skc'];
$oneColor['name'] = $val['color_name'];
$oneColor['goodsName'] = $productData['product_name'];
$oneColor['colorNum'] = $colorNum;
$oneColor['sizeNumStr'] = rtrim($sizeStorageStr, '/');
$colors[] = $oneColor;
// 缩略图
foreach ($val['images_list'] as $image) {
$thumbImageList[] = array(
'img' => Helpers::getImageUrl($image['image_url'], 60, 60)
);
}
// 商品库存总数
$totalStorageNum += $colorNum;
}
$data['thumbs'] = $thumbImageList;
$data['colors'] = $colors;
$data['sizes'] = $sizes;
$data['totalNum'] = $totalStorageNum;
}
return $data;
... ... @@ -668,7 +701,7 @@ class CartModel
// 失效商品列表
$notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list']);
if (!empty($notValidGoods)) {
$result['$notValidGoods'] = $notValidGoods;
$result['notValidGoods'] = $notValidGoods;
}
// 赠品和加价购商品
... ...
... ... @@ -207,11 +207,11 @@ class IndexController extends AbstractAction
{
$result = array();
if ($this->isAjax()) {
// if ($this->isAjax()) {
$skn = $this->get('skn', null);
$promotionId = $this->get('promotionId', null);
$result = CartModel::giftProductData($skn, $promotionId);
}
// }
if (empty($result)) {
echo ' ';
... ...