Authored by xuqi

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -133,6 +133,7 @@ class SearchData extends \LibModels\Wap\Product\SearchData @@ -133,6 +133,7 @@ class SearchData extends \LibModels\Wap\Product\SearchData
133 133
134 return Yohobuy::get(self::getUrl('search'), $param, $cache); 134 return Yohobuy::get(self::getUrl('search'), $param, $cache);
135 } 135 }
  136 +
136 /** 137 /**
137 * 根据分类列表获取商品信息 138 * 根据分类列表获取商品信息
138 * 139 *
@@ -157,20 +158,48 @@ class SearchData extends \LibModels\Wap\Product\SearchData @@ -157,20 +158,48 @@ class SearchData extends \LibModels\Wap\Product\SearchData
157 // } 158 // }
158 // return $data; 159 // return $data;
159 160
160 - /* 2016/01/26 code review by fei.hong: 优化合并misort参数, 减少调用搜索的次数 */  
161 - $sortIds = '';  
162 - $viewNum = 0;  
163 - foreach ($sortList as $value) {  
164 - $viewNum += intval($value['viewNum']);  
165 - $sortIds .= $value['misort'] . ','; 161 + /* code review by fei.hong: 2016/01/26 优化合并misort参数, 减少调用搜索接口的次数 */
  162 + $data = array();
  163 +
  164 + // 按照时间降序排的参数
  165 + $params['order'] = 'shelve_time:desc';
  166 + // 获取新品的接口URL,以数组列表返回
  167 + $urlList = self::getNewArrivalUrl($sortList, $params);
  168 + // 并行调用搜索新品接口
  169 + $searchd = Yohobuy::getMulti($urlList);
  170 +
  171 + // 该变量用于记录数组最后一个值的索引
  172 + $lastIndex = 0;
  173 + // 业务逻辑:按照指定品类排序显示
  174 + foreach ($sortList as $key => $value) {
  175 + $lastIndex = $value['viewNum'] - 1;
  176 + // 业务逻辑:一个品类不满指定个数时,前台不显示
  177 + if (!empty($searchd[$key]) && isset($searchd[$key]['product_list'][$lastIndex])) {
  178 + $data = array_merge($data, $searchd[$key]['product_list']);
  179 + }
166 } 180 }
167 - $params['viewNum'] = $viewNum;  
168 - $params['misort'] = rtrim($sortIds, ',');  
169 - $searchd = self::searchElasticByCondition($params);  
170 - if (empty($searchd['data']['product_list'])) {  
171 - return array(); 181 + // 用完清空不使用的变量
  182 + $searchd = array();
  183 +
  184 + return $data;
  185 + }
  186 +
  187 + /**
  188 + * 获取推荐新品的接口URL列表
  189 + *
  190 + * @param array $sortList 分类列表
  191 + * @param array $params 附加参数
  192 + * @return arary
  193 + */
  194 + public static function getNewArrivalUrl($sortList, $params)
  195 + {
  196 + $urlList = array();
  197 + $option = array();
  198 + foreach ($sortList as $key => $value) {
  199 + $option = $params + $value;
  200 + $urlList[$key] = Yohobuy::httpBuildQuery(self::getUrl('search'), $option);
172 } 201 }
173 - return $searchd['data']['product_list']; 202 + return $urlList;
174 } 203 }
175 204
176 /** 205 /**
@@ -604,18 +604,14 @@ class Process @@ -604,18 +604,14 @@ class Process
604 // single_image & floor & single_image 604 // single_image & floor & single_image
605 $list = array_merge($data[$key + 1]['data'], array_slice($data[$key + 2]['data'], 0, 6), $data[$key + 3]['data']); 605 $list = array_merge($data[$key + 1]['data'], array_slice($data[$key + 2]['data'], 0, 6), $data[$key + 3]['data']);
606 foreach ($list as $listKey => $val) { 606 foreach ($list as $listKey => $val) {
607 - $width = 185;  
608 - $height = 248;  
609 - $w = 377;  
610 - $h = 504;  
611 if ($listKey == 0 || $listKey == 7) { 607 if ($listKey == 0 || $listKey == 7) {
612 - $val['src'] = Images::getImageUrl($val['src'], $w, $h, 1); 608 + $val['src'] = Images::getImageUrl($val['src'], 377, 504, 1);
613 $result['newReport']['list'][] = array( 609 $result['newReport']['list'][] = array(
614 'href' => $val['url'], 610 'href' => $val['url'],
615 'img' => $val['src'] 611 'img' => $val['src']
616 ); 612 );
617 } else { 613 } else {
618 - $val['src'] = Images::getImageUrl($val['src'], $width, $height, 1); 614 + $val['src'] = Images::getImageUrl($val['src'], 185, 248, 1);
619 $result['newReport']['list'][] = array( 615 $result['newReport']['list'][] = array(
620 'href' => $val['url'], 616 'href' => $val['url'],
621 'img' => $val['src'] 617 'img' => $val['src']
@@ -656,6 +652,8 @@ class Process @@ -656,6 +652,8 @@ class Process
656 $result['category']['navs'] = self::mergeNavProcess($data[$key + 1], $type); 652 $result['category']['navs'] = self::mergeNavProcess($data[$key + 1], $type);
657 } 653 }
658 // floor模版 654 // floor模版
  655 + $width = 0;
  656 + $height = 0;
659 foreach ($data[$key + 2]['data'] as $pos => $val) { 657 foreach ($data[$key + 2]['data'] as $pos => $val) {
660 $width = 185; $height = 510; 658 $width = 185; $height = 510;
661 if($pos == 1) { 659 if($pos == 1) {
@@ -761,8 +759,9 @@ class Process @@ -761,8 +759,9 @@ class Process
761 { 759 {
762 $result = array(); 760 $result = array();
763 foreach ($data['data'] as $val) { 761 foreach ($data['data'] as $val) {
764 - if (empty($val)) 762 + if (empty($val)) {
765 continue; 763 continue;
  764 + }
766 $result[] = array( 765 $result[] = array(
767 'href' => $val['url'], 766 'href' => $val['url'],
768 'name' => $val['name'] 767 'name' => $val['name']
@@ -790,8 +789,10 @@ class Process @@ -790,8 +789,10 @@ class Process
790 'client_type' => 'web' 789 'client_type' => 'web'
791 ); 790 );
792 $goodsList = SearchData::searchElasticByCondition($params, false); 791 $goodsList = SearchData::searchElasticByCondition($params, false);
793 - $goodsList = $goodsList['data']['product_list']; 792 + $goodsList = empty($goodsList) ? array() : $goodsList['data']['product_list'];
794 $pos = 0; 793 $pos = 0;
  794 + $url = '';
  795 + $oneGoods = array();
795 foreach ($goodsList as $goods) 796 foreach ($goodsList as $goods)
796 { 797 {
797 $oneGoods = array(); 798 $oneGoods = array();
@@ -802,10 +803,10 @@ class Process @@ -802,10 +803,10 @@ class Process
802 if (empty($goods)) { 803 if (empty($goods)) {
803 continue; 804 continue;
804 } 805 }
  806 + $url = Helpers::getUrlBySkc($goods['product_id'], $goods['goods_list'][0]['goods_id'], $goods['cn_alphabet']);
805 $oneGoods['img'] = Images::getImageUrl($goods['goods_list'][0]['images_url'], 280, 373, 1); 807 $oneGoods['img'] = Images::getImageUrl($goods['goods_list'][0]['images_url'], 280, 373, 1);
806 $oneGoods['name'] = $goods['product_name']; 808 $oneGoods['name'] = $goods['product_name'];
807 $oneGoods['price'] = $goods['sales_price']; 809 $oneGoods['price'] = $goods['sales_price'];
808 - $url = Helpers::getUrlBySkc($goods['product_id'], $goods['goods_list'][0]['goods_id'], $goods['cn_alphabet']);  
809 $oneGoods['href'] = Helpers::transUrl($url, $type); 810 $oneGoods['href'] = Helpers::transUrl($url, $type);
810 $result[$goods['product_skn']] = $oneGoods; 811 $result[$goods['product_skn']] = $oneGoods;
811 } 812 }
@@ -838,7 +839,6 @@ class Process @@ -838,7 +839,6 @@ class Process
838 public static function mergeHotBrandsData($key,array &$data,$type) 839 public static function mergeHotBrandsData($key,array &$data,$type)
839 { 840 {
840 $result = array(); 841 $result = array();
841 - $temp = array();  
842 if ($data[$key]['template_name'] == 'custom_brands') 842 if ($data[$key]['template_name'] == 'custom_brands')
843 { 843 {
844 $result = array( 844 $result = array(
@@ -858,20 +858,18 @@ class Process @@ -858,20 +858,18 @@ class Process
858 $brands = $data[$key]['data']['list']; 858 $brands = $data[$key]['data']['list'];
859 foreach ($brands as $val) 859 foreach ($brands as $val)
860 { 860 {
861 - $width = 185;  
862 - $height = 86;  
863 - $val['src'] = Images::getImageUrl($val['src'], $width, $height, 2); 861 + $val['src'] = Images::getImageUrl($val['src'], 185, 86, 2);
864 $val['url'] = Helpers::transUrl($val['url'], $type); 862 $val['url'] = Helpers::transUrl($val['url'], $type);
865 $floor['logoBrand'][] = array( 863 $floor['logoBrand'][] = array(
866 'href' => $val['url'], 864 'href' => $val['url'],
867 'img' => $val['src'] 865 'img' => $val['src']
868 ); 866 );
869 } 867 }
870 - $floor['moreBrand'] = 'http://yohobuy.com/brands';  
871 - $type_key = sprintf("%s_%s", $type, $key);  
872 - $cacheKey = sprintf("%s_%s", WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA, $type_key); 868 + $floor['moreBrand'] = Helpers::url('/brands');
  869 + $typeKey = sprintf("%s_%s", $type, $key);
  870 + $cacheKey = sprintf("%s_%s", WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA, $typeKey);
873 Cache::set($cacheKey, $floor, 86400); 871 Cache::set($cacheKey, $floor, 86400);
874 - $result['hotBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key; 872 + $result['hotBrands']['brandUrl'] = Helpers::url('/common/getIndexResourceBrand', array('type' => $typeKey));
875 } 873 }
876 return $result; 874 return $result;
877 } 875 }
@@ -24,7 +24,7 @@ class Helpers @@ -24,7 +24,7 @@ class Helpers
24 24
25 switch ($module) { 25 switch ($module) {
26 case 'default': 26 case 'default':
27 - $url = 'http://m.yohobuy.com'; 27 + $url = 'http://www.yohobuy.com';
28 break; 28 break;
29 case 'guang': // 逛 29 case 'guang': // 逛
30 $url = 'http://guang' . SUB_DOMAIN; 30 $url = 'http://guang' . SUB_DOMAIN;
@@ -479,6 +479,9 @@ @@ -479,6 +479,9 @@
479 } 479 }
480 } 480 }
481 } 481 }
  482 + .tpl-brands{
  483 + margin-top:-8px!important;
  484 + }
482 } 485 }
483 .boys,.lifestyle{ 486 .boys,.lifestyle{
484 .goods-container{ 487 .goods-container{
@@ -46,6 +46,7 @@ class ClassModel @@ -46,6 +46,7 @@ class ClassModel
46 $genderArr = array('boy' => '1,3', 'girl' => '2,3', 'kids' => '1,2,3', 'lifestyle' => '1,2,3'); 46 $genderArr = array('boy' => '1,3', 'girl' => '2,3', 'kids' => '1,2,3', 'lifestyle' => '1,2,3');
47 $oneClass = array(); 47 $oneClass = array();
48 $item = array(); 48 $item = array();
  49 + $subitem = array();
49 foreach ($data['data'] as $k => $v) { 50 foreach ($data['data'] as $k => $v) {
50 $oneClass = array('name' => ucfirst(rtrim($k, 's')), 'ca' => array()); 51 $oneClass = array('name' => ucfirst(rtrim($k, 's')), 'ca' => array());
51 52
1 <?php 1 <?php
2 use Action\WebAction; 2 use Action\WebAction;
3 use Index\HomeModel; 3 use Index\HomeModel;
  4 +use Configs\WebCacheConfig;
4 use LibModels\Web\Home\IndexData; 5 use LibModels\Web\Home\IndexData;
5 use WebPlugin\Cache; 6 use WebPlugin\Cache;
6 -use Configs\WebCacheConfig;  
7 -use Api\Yohobuy;  
8 use WebPlugin\Images; 7 use WebPlugin\Images;
9 use WebPlugin\Helpers; 8 use WebPlugin\Helpers;
10 9
@@ -16,15 +15,27 @@ class CommonController extends WebAction @@ -16,15 +15,27 @@ class CommonController extends WebAction
16 */ 15 */
17 public function getIndexResourceBrandAction() 16 public function getIndexResourceBrandAction()
18 { 17 {
  18 + $data = array();
  19 +
  20 + do {
  21 + if (!$this->isAjax()) {
  22 + break;
  23 + }
  24 +
  25 + $type = $this->get('type');
  26 + if (empty($type)) {
  27 + break;
  28 + }
  29 + }
  30 + while (false);
19 // 首页资源品牌,采用内存存储 31 // 首页资源品牌,采用内存存储
20 $type = $this->get('type'); 32 $type = $this->get('type');
21 - $data = array();  
22 if (! empty($type)) { 33 if (! empty($type)) {
23 $key = WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA . '_' . $type; 34 $key = WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA . '_' . $type;
24 // array('logoBrand'=>'','moreBrand'=>'') 35 // array('logoBrand'=>'','moreBrand'=>'')
25 $data = Cache::get($key); 36 $data = Cache::get($key);
26 } 37 }
27 - echo $this->echoJson($data); 38 + $this->echoJson($data);
28 } 39 }
29 40
30 /** 41 /**
@@ -36,7 +47,7 @@ class CommonController extends WebAction @@ -36,7 +47,7 @@ class CommonController extends WebAction
36 */ 47 */
37 public function getNewArrivalAction() 48 public function getNewArrivalAction()
38 { 49 {
39 - $result = $data = array(); 50 + $result = array();
40 do { 51 do {
41 /* 判断是不是AJAX请求 */ 52 /* 判断是不是AJAX请求 */
42 if (! $this->isAjax()) { 53 if (! $this->isAjax()) {
@@ -53,23 +64,29 @@ class CommonController extends WebAction @@ -53,23 +64,29 @@ class CommonController extends WebAction
53 $pageCount = (int) $this->post('pageCount', 8); 64 $pageCount = (int) $this->post('pageCount', 8);
54 if (! in_array($channel, $channels)) { 65 if (! in_array($channel, $channels)) {
55 break; 66 break;
56 - } else {  
57 - $data = HomeModel::getNewArrival($channel);  
58 } 67 }
59 - if($pageIndex < 0) { 68 +
  69 + $data = HomeModel::getNewArrival($channel);
  70 + if (empty($data)) {
  71 + break;
  72 + }
  73 +
  74 + if ($pageIndex < 0) {
60 $pageIndex = 0; 75 $pageIndex = 0;
61 } 76 }
62 - if($pageCount < 0 || $pageCount > 50) { 77 + if ($pageCount < 0 || $pageCount > 50) {
63 $pageCount = 20; 78 $pageCount = 20;
64 } 79 }
65 - $result = array_slice($data, $pageIndex, $pageCount);  
66 - if (empty($result)) { 80 + $data = array_slice($data, $pageIndex, $pageCount);
  81 + if (empty($data)) {
67 break; 82 break;
68 } 83 }
69 $result = array( 84 $result = array(
70 'code' => 200, 85 'code' => 200,
71 - 'goods' => $result 86 + 'goods' => $data
72 ); 87 );
  88 + $data = array();
  89 +
73 } while (false); 90 } while (false);
74 91
75 $this->echoJson($result); 92 $this->echoJson($result);
@@ -110,18 +110,20 @@ class HotrankModel @@ -110,18 +110,20 @@ class HotrankModel
110 'gender' => $data['gender'], 110 'gender' => $data['gender'],
111 'road' => $data['road']); 111 'road' => $data['road']);
112 $list = self::getSearchData($config, $page, 1); 112 $list = self::getSearchData($config, $page, 1);
113 - $lister = $list['hotWeek']['list'];  
114 - $lister = array_values($lister);  
115 - if ($sid == 1 && $page == 1) {  
116 - $lister = array_slice($lister, 10, 50);  
117 - }  
118 - else {  
119 - $lister = array_slice($lister, 0, 50); 113 + if (!empty($list)) {
  114 + $lister = $list['hotWeek']['list'];
  115 + $lister = array_values($lister);
  116 + if ($sid == 1 && $page == 1) {
  117 + $lister = array_slice($lister, 10, 50);
  118 + }
  119 + else {
  120 + $lister = array_slice($lister, 0, 50);
  121 + }
  122 + $data = array(
  123 + 'code' => 200,
  124 + 'data' => $lister,);
  125 + return $data;
120 } 126 }
121 - $data = array(  
122 - 'code' => 200,  
123 - 'data' => $lister,);  
124 - return $data;  
125 } 127 }
126 128
127 /** 129 /**
@@ -171,6 +173,7 @@ class HotrankModel @@ -171,6 +173,7 @@ class HotrankModel
171 } 173 }
172 //根据给定查询数据搜索数据列表 174 //根据给定查询数据搜索数据列表
173 $result = SearchData::searchElasticByCondition($param); 175 $result = SearchData::searchElasticByCondition($param);
  176 + //人气单品,一周热卖数据处理
174 $data = self::getProductList($result, $page, $ajax); 177 $data = self::getProductList($result, $page, $ajax);
175 return $data; 178 return $data;
176 } 179 }
@@ -208,13 +211,13 @@ class HotrankModel @@ -208,13 +211,13 @@ class HotrankModel
208 return $product; 211 return $product;
209 } 212 }
210 $data = $result['data']['product_list']; 213 $data = $result['data']['product_list'];
211 - $popular = array();  
212 - $hotWeek = array(); 214 + $popular = array(); //一周热卖
  215 + $hotWeek = array(); //人气单品
213 foreach ($data as $key => $val) { 216 foreach ($data as $key => $val) {
214 if (empty($val['goods_list'])) { 217 if (empty($val['goods_list'])) {
215 continue; 218 continue;
216 } 219 }
217 - //$defaultGoodsId = 0; 220 + $defaultGoodsId = 0;
218 foreach ($val['goods_list'] as $v) { 221 foreach ($val['goods_list'] as $v) {
219 if ($v['is_default'] == 'Y') { 222 if ($v['is_default'] == 'Y') {
220 $defaultGoodsId = empty($v['goods_id']) ? $val['goods_list'][0]['goods_id'] : $v['goods_id']; 223 $defaultGoodsId = empty($v['goods_id']) ? $val['goods_list'][0]['goods_id'] : $v['goods_id'];
@@ -226,8 +229,8 @@ class HotrankModel @@ -226,8 +229,8 @@ class HotrankModel
226 $product['rank'] = $key + 1; 229 $product['rank'] = $key + 1;
227 $product['title'] = $val['product_name']; 230 $product['title'] = $val['product_name'];
228 $product['href'] = $url . '_' . $product_id . '_' . $defaultGoodsId . '.html'; 231 $product['href'] = $url . '_' . $product_id . '_' . $defaultGoodsId . '.html';
229 - $product['price'] = (int) $val['market_price'] == (int) $val['sales_price'] ? '' : $val['market_price'];  
230 - $product['sPrice'] = empty($val['sales_price']) ? '' : $val['sales_price']; 232 + $product['price'] = (int) $val['market_price'] == (int) $val['sales_price'] ? false : $val['market_price'];
  233 + $product['sPrice'] = empty($val['sales_price']) ? false : $val['sales_price'];
231 if ($key <= 5) { 234 if ($key <= 5) {
232 //6张大图 235 //6张大图
233 $product['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2); 236 $product['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2);
@@ -243,8 +246,8 @@ class HotrankModel @@ -243,8 +246,8 @@ class HotrankModel
243 //一周热卖 246 //一周热卖
244 $product['name'] = $val['product_name']; 247 $product['name'] = $val['product_name'];
245 $product['url'] = $url . '_' . $product_id . '_' . $defaultGoodsId . '.html'; 248 $product['url'] = $url . '_' . $product_id . '_' . $defaultGoodsId . '.html';
246 - $product['marketPrice'] = (int) $val['market_price'] == (int) $val['sales_price'] ? '' : $val['market_price'];  
247 - $product['salePrice'] = empty($val['sales_price']) ? '' : $val['sales_price']; 249 + $product['marketPrice'] = (int) $val['market_price'] == (int) $val['sales_price'] ? false : $val['market_price'];
  250 + $product['salePrice'] = empty($val['sales_price']) ? false : $val['sales_price'];
248 $product['rank'] = ''; 251 $product['rank'] = '';
249 $product['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2); 252 $product['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
250 $hot[] = $product; 253 $hot[] = $product;
@@ -148,6 +148,7 @@ class IndexController extends WebAction @@ -148,6 +148,7 @@ class IndexController extends WebAction
148 //获取频道 148 //获取频道
149 $channel = HotrankModel::getChannelResource(); 149 $channel = HotrankModel::getChannelResource();
150 $this->setWebNavHeader($channel['channel']); 150 $this->setWebNavHeader($channel['channel']);
  151 + $this->setTitle('热销排行|YOHO!BUY有货');
151 $page = $this->get('page', 1); 152 $page = $this->get('page', 1);
152 $sort = $this->get('sid', 1); 153 $sort = $this->get('sid', 1);
153 $data = array('hotrankPage' => true, 154 $data = array('hotrankPage' => true,