Authored by Rock Zhang

修复购物车加价购商品显示选择框的bug

@@ -664,14 +664,7 @@ class CartModel @@ -664,14 +664,7 @@ class CartModel
664 664
665 $sizeList[$val['color_id']][] = $oneSize; 665 $sizeList[$val['color_id']][] = $oneSize;
666 666
667 - $colorStorageGroup[$one['size_name']][$val['color_name']] = $one['storage_number'];  
668 - }  
669 -  
670 - // 统计尺码对应的各个颜色的库存量  
671 - foreach ($sizes as $colorId => $sizeArr) {  
672 - foreach ($sizeArr as $key => $value) {  
673 - $sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) );  
674 - } 667 + $colorStorageGroup[$one['productSkc']][$val['sizeName']] = $val['storage_number'];
675 } 668 }
676 669
677 // 颜色 670 // 颜色
@@ -695,9 +688,24 @@ class CartModel @@ -695,9 +688,24 @@ class CartModel
695 $totalStorageNum += $colorNum; 688 $totalStorageNum += $colorNum;
696 } 689 }
697 690
  691 + // 遍历所有尺码,统计出该尺码的每个颜色的库存量,没有时添0,不能空着,因为JS中需要判断
  692 + foreach ($sizeList as $skc => $sizeArr) {
  693 + foreach ($sizeArr as $key => $value) {
  694 + $sizeStorageStr = '';
  695 + foreach ($colorStorageGroup as $colorArr) {
  696 + if (isset($colorArr[ $value['name'] ])) {
  697 + $sizeStorageStr .= $colorArr[ $value['name'] ] . '/';
  698 + } else {
  699 + $sizeStorageStr .= '0/';
  700 + }
  701 + }
  702 + $sizeList[$skc][$key]['colorNumStr'] = rtrim($sizeStorageStr, '/');
  703 + }
  704 + }
  705 +
698 // 格式化尺码对应的各个颜色分组 706 // 格式化尺码对应的各个颜色分组
699 foreach ($colors as $color) { 707 foreach ($colors as $color) {
700 - $sizes[]['size'] = $sizeList[$color['id']]; 708 + $sizes[]['size'] = $sizeList[$color['skcId']];
701 } 709 }
702 710
703 $data['thumbs'] = $thumbImageList; 711 $data['thumbs'] = $thumbImageList;