Authored by hf

code review by hf: do cuxiao huodong christmas second times

@@ -23,15 +23,15 @@ class Yohobuy @@ -23,15 +23,15 @@ class Yohobuy
23 // const SERVICE_URL = 'http://service.api.yohobuy.com/'; 23 // const SERVICE_URL = 'http://service.api.yohobuy.com/';
24 // const YOHOBUY_URL = 'http://www.yohobuy.com/'; 24 // const YOHOBUY_URL = 'http://www.yohobuy.com/';
25 25
26 -// const API_URL = 'http://apih5.yoho.cn/';  
27 -// const API_URL2 = 'http://apih5.yoho.cn/';  
28 -// const SERVICE_URL = 'http://serviceh5.yoho.cn/';  
29 -// const YOHOBUY_URL = 'http://www.yohobuy.com/';  
30 -  
31 - /* 测试环境 */  
32 - const API_URL = 'http://testapi.yoho.cn:28078/';  
33 - const SERVICE_URL = 'http://testservice.yoho.cn:28077/';  
34 - const YOHOBUY_URL = 'http://www.yohobuy.com/'; 26 + const API_URL = 'http://apih5.yoho.cn/';
  27 + const API_URL2 = 'http://apih5.yoho.cn/';
  28 + const SERVICE_URL = 'http://serviceh5.yoho.cn/';
  29 + const YOHOBUY_URL = 'http://www.yohobuy.com/';
  30 +
  31 +// /* 测试环境 */
  32 +// const API_URL = 'http://testapi.yoho.cn:28078/';
  33 +// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
  34 +// const YOHOBUY_URL = 'http://www.yohobuy.com/';
35 35
36 /** 36 /**
37 * 私钥列表 37 * 私钥列表
@@ -34,10 +34,12 @@ class DetailModel @@ -34,10 +34,12 @@ class DetailModel
34 $baseInfo = DetailData::baseInfo($productId, $uid); 34 $baseInfo = DetailData::baseInfo($productId, $uid);
35 35
36 // 商品名称 36 // 商品名称
37 - if (isset($baseInfo['productName'])) {  
38 - $result['goodsName'] = $baseInfo['productName']; 37 + if (empty($baseInfo['productName'])) {
  38 + return $result;
39 } 39 }
40 40
  41 + $result['goodsName'] = $baseInfo['productName'];
  42 +
41 // 商品促销短语 43 // 商品促销短语
42 if (!empty($baseInfo['salesPhrase'])) { 44 if (!empty($baseInfo['salesPhrase'])) {
43 $result['goodsSubtitle'] = $baseInfo['salesPhrase']; 45 $result['goodsSubtitle'] = $baseInfo['salesPhrase'];
@@ -159,12 +161,12 @@ class DetailModel @@ -159,12 +161,12 @@ class DetailModel
159 $thumbImageList = array(); 161 $thumbImageList = array();
160 $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔 162 $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
161 $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔 163 $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔
162 - $colorStorageNum = 0; 164 + $colorStorageNum = 0;
163 $totalStorageNum = 0; // 总库存数 165 $totalStorageNum = 0; // 总库存数
164 foreach ($baseInfo['goodsList'] as $value) { 166 foreach ($baseInfo['goodsList'] as $value) {
165 $colorStorageNum = 0; 167 $colorStorageNum = 0;
166 $sizeStorageStr = ''; 168 $sizeStorageStr = '';
167 - 169 +
168 // 商品分组 170 // 商品分组
169 if (isset($value['goodsImagesList'])) { 171 if (isset($value['goodsImagesList'])) {
170 foreach ($value['goodsImagesList'] as $goods) { 172 foreach ($value['goodsImagesList'] as $goods) {
@@ -178,7 +180,7 @@ class DetailModel @@ -178,7 +180,7 @@ class DetailModel
178 // 商品的尺码列表 180 // 商品的尺码列表
179 if (isset($value['goodsSizeBoList'])) { 181 if (isset($value['goodsSizeBoList'])) {
180 foreach ($value['goodsSizeBoList'] as $size) { 182 foreach ($value['goodsSizeBoList'] as $size) {
181 - $sizeList[ $value['colorId'] ][] = array( 183 + $sizeList[$value['colorId']][] = array(
182 'id' => $size['id'], 184 'id' => $size['id'],
183 'skuId' => $size['goodsSizeSkuId'], 185 'skuId' => $size['goodsSizeSkuId'],
184 'goodsId' => $size['goodsId'], 186 'goodsId' => $size['goodsId'],
@@ -188,9 +190,9 @@ class DetailModel @@ -188,9 +190,9 @@ class DetailModel
188 ); 190 );
189 $colorStorageNum += intval($size['goodsSizeStorageNum']); 191 $colorStorageNum += intval($size['goodsSizeStorageNum']);
190 $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/'; 192 $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
191 - $colorStorageGroup[ $size['sizeName'] ][ $value['colorName'] ] = $size['goodsSizeStorageNum']; 193 + $colorStorageGroup[$size['sizeName']][$value['colorName']] = $size['goodsSizeStorageNum'];
192 } 194 }
193 - 195 +
194 // 颜色分组 196 // 颜色分组
195 $colorGroup[] = array( 197 $colorGroup[] = array(
196 'id' => $value['colorId'], 198 'id' => $value['colorId'],
@@ -201,21 +203,24 @@ class DetailModel @@ -201,21 +203,24 @@ class DetailModel
201 'sizeNumStr' => rtrim($sizeStorageStr, '/'), 203 'sizeNumStr' => rtrim($sizeStorageStr, '/'),
202 ); 204 );
203 } 205 }
204 - 206 +
205 // 缩略图 207 // 缩略图
206 - $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60) );  
207 -  
208 - foreach ($sizeList as &$sizeArr) {  
209 - $sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) ); 208 + $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60));
  209 +
  210 + // 添加尺码对应的各个颜色的库存量
  211 + foreach ($sizeList as $colorId => $sizeArr) {
  212 + foreach ($sizeArr as $key => $value) {
  213 + $sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[$value['name']]));
  214 + }
210 } 215 }
211 - 216 +
212 // 商品库存总数 217 // 商品库存总数
213 $totalStorageNum += $colorStorageNum; 218 $totalStorageNum += $colorStorageNum;
214 } 219 }
215 -  
216 - // 统计尺码对应的各个颜色的库存量 220 +
  221 + // 格式化尺码对应的各个颜色分组
217 foreach ($colorGroup as $value) { 222 foreach ($colorGroup as $value) {
218 - $sizeGroup[]['size'] = $sizeList[ $value['colorId'] ]; 223 + $sizeGroup[]['size'] = $sizeList[ $value['id'] ];
219 } 224 }
220 225
221 // 商品图: 多个 226 // 商品图: 多个
@@ -360,10 +365,9 @@ class DetailModel @@ -360,10 +365,9 @@ class DetailModel
360 foreach ($sizeInfo['sizeInfoBo']['sizeBoList'] as $value) { 365 foreach ($sizeInfo['sizeInfoBo']['sizeBoList'] as $value) {
361 $item = array(); 366 $item = array();
362 $sizeNameList[] = array('param' => $value['sizeName']); 367 $sizeNameList[] = array('param' => $value['sizeName']);
363 - if ($boyReference && ($gender == 1 || $gender == 3) ) { 368 + if ($boyReference && ($gender == 1 || $gender == 3)) {
364 $referenceList[] = array('param' => empty($value['boyReferSize']['referenceName']) ? ' ' : $value['boyReferSize']['referenceName']); 369 $referenceList[] = array('param' => empty($value['boyReferSize']['referenceName']) ? ' ' : $value['boyReferSize']['referenceName']);
365 - }  
366 - elseif ($girlReference && ($gender == 2 || $gender == 3) ) { 370 + } elseif ($girlReference && ($gender == 2 || $gender == 3)) {
367 $referenceList[] = array('param' => empty($value['girlReferSize']['referenceName']) ? ' ' : $value['girlReferSize']['referenceName']); 371 $referenceList[] = array('param' => empty($value['girlReferSize']['referenceName']) ? ' ' : $value['girlReferSize']['referenceName']);
368 } 372 }
369 foreach ($value['sortAttributes'] as $attr) { 373 foreach ($value['sortAttributes'] as $attr) {