Authored by 周少峰

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into feature/web-list

@@ -465,14 +465,14 @@ class WebAction extends Controller_Abstract @@ -465,14 +465,14 @@ class WebAction extends Controller_Abstract
465 */ 465 */
466 protected function setWebNavHeader($channel = '') 466 protected function setWebNavHeader($channel = '')
467 { 467 {
468 - if(empty($channel)) {  
469 - $channel = \Index\HomeModel::getSwitchChannel();  
470 - }  
471 - else {//设置频道  
472 - \Index\HomeModel::setSwitchToCookie($channel);  
473 - } 468 +// if(empty($channel)) {
  469 +// $channel = \Index\HomeModel::getSwitchChannel();
  470 +// }
  471 +// else {//设置频道
  472 +// \Index\HomeModel::setSwitchToCookie($channel);
  473 +// }
474 $header = array( 474 $header = array(
475 - 'navbars'=>\Index\HomeModel::getNavBars($channel), 475 + 'navbars'=> \Index\HomeModel::getNavBars($channel),
476 'gobytype'=> 'gobuy'.$channel, 476 'gobytype'=> 'gobuy'.$channel,
477 'searchcate'=>'searchcate'.$channel, 477 'searchcate'=>'searchcate'.$channel,
478 'myyoho' => array( 478 'myyoho' => array(
@@ -60,4 +60,8 @@ class CacheConfig @@ -60,4 +60,8 @@ class CacheConfig
60 60
61 const KEY_CODE_YOHOCOIN_BANNER = 'key_code_yohocoin_banner';// 有货币banner数据 61 const KEY_CODE_YOHOCOIN_BANNER = 'key_code_yohocoin_banner';// 有货币banner数据
62 62
  63 + const KEY_WEB_HOME_NAVBAR_DATA = 'key_web_home_navbar_data';//web的导航数据
  64 + const KEY_WEB_HOME_CHANNEL_DATA = 'key_web_home_channel_data';//web首页频道数据[boys, girls, kids, lifestyle]
  65 + const KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA = 'key_web_home_newarrival_data';//web频道最新上架数据[boys, girls, kids, lifestyle]
  66 +
63 } 67 }
@@ -22,7 +22,7 @@ class IndexData @@ -22,7 +22,7 @@ class IndexData
22 $params = array('parent_id'=>'','platform'=>'web', 22 $params = array('parent_id'=>'','platform'=>'web',
23 'status'=> $status,'fields'=> $fields 23 'status'=> $status,'fields'=> $fields
24 ); 24 );
25 - return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_OPERATIONS_CATEGORY,'getCategory', $params, false); 25 + return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_OPERATIONS_CATEGORY,'getCategory', $params, true);
26 } 26 }
27 27
28 /** 28 /**
  1 +<?php
  2 +namespace LibModels\Web\Product;
  3 +
  4 +use Api\Yohobuy;
  5 +use Api\Sign;
  6 +
  7 +
  8 +/**
  9 + * 热销排行
  10 + *
  11 + * */
  12 +class HotrankData extends \LibModels\Wap\Product\SearchData
  13 +{
  14 + const URI_HOTRANK_RES = '/operations/service/v4/resource';
  15 + const URI_HOTRANK_TAG = '/operations/api/v5/resource/get';
  16 +
  17 +
  18 + /**
  19 + 获取热销排行
  20 + * 分类标签
  21 + */
  22 + public static function getHotranktag($client_type = 'web',$channel = 0, $is_concurrent = true, $callback = '')
  23 + {
  24 + // 构建必传参数
  25 + $params = Yohobuy::param();
  26 + $params['client_type'] = 'web';
  27 + $params['channel'] =$channel ;
  28 + $params['is_concurrent'] = true;
  29 + $params['callback'] = $callback;
  30 + $params['client_secret'] = Sign::getSign($params);
  31 + return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_HOTRANK_TAG, $params);
  32 + }
  33 +
  34 +}
@@ -263,7 +263,8 @@ class Process @@ -263,7 +263,8 @@ class Process
263 'mergeNewReportData', 263 'mergeNewReportData',
264 'mergeSinglehotData2', 264 'mergeSinglehotData2',
265 'mergeHotCategoryData', 265 'mergeHotCategoryData',
266 - 'mergeGirlkidsData' 266 + 'mergeGirlkidsData',
  267 + 'mergeHotBrandsData'
267 ); 268 );
268 foreach ($data as $key => $val) { 269 foreach ($data as $key => $val) {
269 foreach ($mergeProcessList as $merge) { 270 foreach ($mergeProcessList as $merge) {
@@ -823,4 +824,57 @@ class Process @@ -823,4 +824,57 @@ class Process
823 return $result; 824 return $result;
824 } 825 }
825 826
  827 + /**
  828 + * 热门品牌数据处理
  829 + *
  830 + * @param array $data
  831 + * @param string $type
  832 + */
  833 + public static function mergeHotBrandsData($key,array &$data,$type)
  834 + {
  835 + $result = array();
  836 + $temp = array();
  837 + if ($data[$key]['template_name'] == 'custom_brands')
  838 + {
  839 + // print_r($data[$key]);
  840 + $result = array(
  841 + 'hotBrands' => array(
  842 + 'name' => '',
  843 + 'brandUrl' => ''
  844 + )
  845 + );
  846 + // text模版
  847 + $result['hotBrands']['name'] = '热门品牌';
  848 + //floor模板
  849 + $floor = array(
  850 + 'logoBrand' => '',
  851 + 'moreBrand' => ''
  852 + );
  853 +
  854 + $brands = $data[$key]['data']['list'];
  855 + foreach ($brands as $val)
  856 + {
  857 + $width = 185;
  858 + $height = 86;
  859 + $type = 'lifestyle';
  860 + $val['src'] = Images::getImageUrl($val['src'], $width, $height, 2);
  861 + $val['url'] = Helpers::transUrl($val['url'], $type);
  862 + $floor['logoBrand'][] = array(
  863 + 'href' => $val['url'],
  864 + 'img' => $val['src']
  865 + );
  866 + }
  867 + $floor['moreBrand'] = 'http://yohobuy.com/brands';
  868 + //$floor['moreBrand'] = 'http://yohobuy.com/brands?gender=1,3&openby:yohobuy={"action":"go.list","params":{"actiontype":0,"gender":"1,3"}}';
  869 + //print_r($floor);
  870 + $type_key = sprintf("%s_%s", $type, $key);
  871 + $cacheKey = sprintf("%s_%s", CacheConfig::KEY_INDEX_BRANDS_LIST_DATA, $type_key);
  872 + //print_r($cacheKey);
  873 + Cache::set($cacheKey, $floor, 7200);
  874 + $result['hotBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key;
  875 + //print_r($result['hotBrands']['brandUrl']);
  876 + }
  877 + return $result;
  878 + }
  879 +
826 } 880 }
@@ -240,9 +240,8 @@ class HelperSearch @@ -240,9 +240,8 @@ class HelperSearch
240 240
241 public static function groupSort($sort) 241 public static function groupSort($sort)
242 { 242 {
243 -  
244 $options = self::$options; 243 $options = self::$options;
245 - if (isset($options['controller']) && $options['controller'] != 'Search') { 244 + if (isset($options['controller']) && $options['controller'] == 'Search') {
246 return array(); 245 return array();
247 } 246 }
248 //设置导航 247 //设置导航
@@ -286,7 +285,6 @@ class HelperSearch @@ -286,7 +285,6 @@ class HelperSearch
286 } 285 }
287 } 286 }
288 $result['list'] = $sortList; 287 $result['list'] = $sortList;
289 -// print_r($result); exit;  
290 return $result; 288 return $result;
291 } 289 }
292 290
@@ -294,7 +292,7 @@ class HelperSearch @@ -294,7 +292,7 @@ class HelperSearch
294 { 292 {
295 $result = array(); 293 $result = array();
296 $options = self::$options; 294 $options = self::$options;
297 - if (!isset($options['controller']) || $options['controller'] != 'Search') { 295 + if (!isset($options['controller']) || $options['controller'] == 'Search') {
298 return $result; 296 return $result;
299 } 297 }
300 $params = self::$params; 298 $params = self::$params;
@@ -88,7 +88,6 @@ $invoice.on('touchend', '.checkbox', function() { @@ -88,7 +88,6 @@ $invoice.on('touchend', '.checkbox', function() {
88 if ($this.hasClass('icon-checkbox')) { 88 if ($this.hasClass('icon-checkbox')) {
89 $invoice.removeClass('focus'); 89 $invoice.removeClass('focus');
90 } 90 }
91 - return false;  
92 }); 91 });
93 92
94 function orderCompute() { 93 function orderCompute() {
@@ -243,10 +242,10 @@ $('.coin').on('touchend', function() { @@ -243,10 +242,10 @@ $('.coin').on('touchend', function() {
243 orderCompute(); 242 orderCompute();
244 }); 243 });
245 244
246 -$invoice.on('touchend', function(e) { 245 +$invoice.on('touchend', '.checkbox', function(e) {
247 var $this = $(this); 246 var $this = $(this);
248 247
249 - orderInfo('invoice', $this.find('.checkbox').hasClass('icon-cb-checked')); 248 + orderInfo('invoice', $this.hasClass('icon-cb-checked'));
250 e.preventDefault(); 249 e.preventDefault();
251 e.stopPropagation(); 250 e.stopPropagation();
252 }); 251 });
@@ -34,6 +34,20 @@ @@ -34,6 +34,20 @@
34 </div> 34 </div>
35 {{/if}} 35 {{/if}}
36 36
  37 + {{#if gender}}
  38 + <div class="channel section">
  39 + <span class="title">性别:</span>
  40 +
  41 + <div class="attr-content clearfix">
  42 + {{#each channel}}
  43 + <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">
  44 + {{name}}
  45 + </a>
  46 + {{/each}}
  47 + </div>
  48 + </div>
  49 + {{/if}}
  50 +
37 {{#if sort}} 51 {{#if sort}}
38 <div class="sort section"> 52 <div class="sort section">
39 <span class="title">分类:</span> 53 <span class="title">分类:</span>
@@ -135,7 +135,6 @@ exports.init = function(num) { @@ -135,7 +135,6 @@ exports.init = function(num) {
135 135
136 // 鼠标悬浮获取到商品信息后显示第一张图片 136 // 鼠标悬浮获取到商品信息后显示第一张图片
137 if (data[0] && data[0].src) { 137 if (data[0] && data[0].src) {
138 - $(event.target).find('.good-thumb img').attr('src', data[0].src);  
139 $goodInfoMain.find('.good-thumb img').attr('src', data[0].src); 138 $goodInfoMain.find('.good-thumb img').attr('src', data[0].src);
140 } 139 }
141 140
@@ -82,6 +82,7 @@ @@ -82,6 +82,7 @@
82 width: 14px; 82 width: 14px;
83 border: 1px solid #fff; 83 border: 1px solid #fff;
84 margin-bottom: -3px; 84 margin-bottom: -3px;
  85 + background-size: 100% !important;
85 } 86 }
86 87
87 .clear-checked { 88 .clear-checked {
@@ -283,6 +284,7 @@ @@ -283,6 +284,7 @@
283 border: 1px solid #ccc; 284 border: 1px solid #ccc;
284 margin-bottom: -6px; 285 margin-bottom: -6px;
285 margin-right: 5px; 286 margin-right: 5px;
  287 + background-size: 100% !important;
286 } 288 }
287 289
288 .senior { 290 .senior {
@@ -125,9 +125,20 @@ @@ -125,9 +125,20 @@
125 } 125 }
126 } 126 }
127 127
  128 + @keyframes slideRight {
  129 + from {
  130 + max-width: 0;
  131 + }
  132 + to {
  133 + max-width: 150px;
  134 + }
  135 + }
  136 +
128 .good-select-color { 137 .good-select-color {
129 float: left; 138 float: left;
130 margin-top: 22px; 139 margin-top: 22px;
  140 + overflow: hidden;
  141 + animation: slideRight 600ms 1;
131 142
132 ul { 143 ul {
133 display: block; 144 display: block;
@@ -167,15 +167,15 @@ class DetailModel @@ -167,15 +167,15 @@ class DetailModel
167 $colorGroup = array(); 167 $colorGroup = array();
168 $sizeGroup = array(); 168 $sizeGroup = array();
169 $goodsGroup = array(); 169 $goodsGroup = array();
  170 + $colorList = array();
170 $sizeList = array(); 171 $sizeList = array();
  172 + $allSizeList = array(); // 所有尺码列表
171 $thumbImageList = array(); 173 $thumbImageList = array();
172 $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔 174 $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
173 - $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔  
174 $colorStorageNum = 0; 175 $colorStorageNum = 0;
175 $totalStorageNum = 0; // 总库存数 176 $totalStorageNum = 0; // 总库存数
176 foreach ($baseInfo['goodsList'] as $value) { 177 foreach ($baseInfo['goodsList'] as $value) {
177 $colorStorageNum = 0; 178 $colorStorageNum = 0;
178 - $sizeStorageStr = '';  
179 179
180 // 商品分组 180 // 商品分组
181 if (isset($value['goodsImagesList'])) { 181 if (isset($value['goodsImagesList'])) {
@@ -188,10 +188,10 @@ class DetailModel @@ -188,10 +188,10 @@ class DetailModel
188 } 188 }
189 189
190 // 商品的尺码列表 190 // 商品的尺码列表
191 - $colorStorageGroup[$value['productSkc']] = array(); 191 + $colorStorageGroup[ $value['productSkc'] ] = array();
192 if (isset($value['goodsSizeBoList'])) { 192 if (isset($value['goodsSizeBoList'])) {
193 foreach ($value['goodsSizeBoList'] as $size) { 193 foreach ($value['goodsSizeBoList'] as $size) {
194 - $sizeList[$value['productSkc']][] = array( 194 + $sizeList[ $value['productSkc'] ][] = array(
195 'id' => $size['id'], 195 'id' => $size['id'],
196 'skuId' => $size['goodsSizeSkuId'], 196 'skuId' => $size['goodsSizeSkuId'],
197 'goodsId' => $size['goodsId'], 197 'goodsId' => $size['goodsId'],
@@ -199,19 +199,21 @@ class DetailModel @@ -199,19 +199,21 @@ class DetailModel
199 'name' => $size['sizeName'], 199 'name' => $size['sizeName'],
200 'sizeNum' => $size['goodsSizeStorageNum'], 200 'sizeNum' => $size['goodsSizeStorageNum'],
201 ); 201 );
  202 +
  203 + // 所有尺码列表,赋值用于前端展示默认尺码的时候 判断出没有库存则显示灰色
  204 + $allSizeList[ $size['sizeName'] ] = empty($allSizeList[ $size['sizeName'] ]) ? $size['goodsSizeStorageNum'] : $allSizeList[ $size['sizeName'] ];
  205 +
202 $colorStorageNum += intval($size['goodsSizeStorageNum']); 206 $colorStorageNum += intval($size['goodsSizeStorageNum']);
203 - $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';  
204 $colorStorageGroup[$value['productSkc']][$size['sizeName']] = $size['goodsSizeStorageNum']; 207 $colorStorageGroup[$value['productSkc']][$size['sizeName']] = $size['goodsSizeStorageNum'];
205 } 208 }
206 209
207 // 颜色分组 210 // 颜色分组
208 - $colorGroup[] = array( 211 + $colorList[] = array(
209 'id' => $value['colorId'], 212 'id' => $value['colorId'],
210 'skcId' => $value['productSkc'], 213 'skcId' => $value['productSkc'],
211 'name' => $value['colorName'], 214 'name' => $value['colorName'],
212 'goodsName' => $value['goodsName'], 215 'goodsName' => $value['goodsName'],
213 'colorNum' => $colorStorageNum, 216 'colorNum' => $colorStorageNum,
214 - 'sizeNumStr' => rtrim($sizeStorageStr, '/'),  
215 ); 217 );
216 } 218 }
217 219
@@ -222,24 +224,29 @@ class DetailModel @@ -222,24 +224,29 @@ class DetailModel
222 $totalStorageNum += $colorStorageNum; 224 $totalStorageNum += $colorStorageNum;
223 } 225 }
224 226
225 - // 遍历所有尺码,统计出该尺码的每个颜色的库存量,没有时添0,不能空着,因为JS中需要判断  
226 - foreach ($sizeList as $skc => $sizeArr) {  
227 - foreach ($sizeArr as $key => $value) {  
228 - $sizeStorageStr = '';  
229 - foreach ($colorStorageGroup as $colorArr) {  
230 - if (isset($colorArr[$value['name']])) {  
231 - $sizeStorageStr .= $colorArr[$value['name']] . '/';  
232 - } else {  
233 - $sizeStorageStr .= '0/';  
234 - }  
235 - }  
236 - $sizeList[$skc][$key]['colorNumStr'] = rtrim($sizeStorageStr, '/');  
237 - } 227 + // 遍历所有尺码,构建颜色显示数据
  228 + $i = 1;
  229 + foreach ($allSizeList as $sizeName => $value) {
  230 + // 默认尺码
  231 + $sizeGroup[0]['size'][] = array(
  232 + 'name' => $sizeName, // 尺码名称
  233 + 'sizeNum' => empty($value) ? false : true, // 是否有库存 (false:表示没有库存,true:表示有库存)
  234 + );
  235 +
  236 + // 各个颜色的尺码, 每行显示一个尺码对应的颜色
  237 + foreach ($colorList as $colorArr) {
  238 + $colorArr['colorNum'] = isset($colorStorageGroup[ $colorArr['skcId'] ][$sizeName]) ? $colorStorageGroup[ $colorArr['skcId'] ][$sizeName] : 0;
  239 + $colorGroup[$i]['color'][] = $colorArr;
238 } 240 }
239 241
240 - // 格式化尺码对应的各个颜色分组  
241 - foreach ($colorGroup as $value) {  
242 - $sizeGroup[]['size'] = $sizeList[$value['skcId']]; 242 + ++ $i;
  243 + }
  244 + // 遍历所有颜色, 构建尺码显示数据
  245 + foreach ($colorList as $value) {
  246 + // 各个尺码的颜色,每行显示一个颜色的对应尺码
  247 + $sizeGroup[]['size'] = $sizeList[ $value['skcId'] ];
  248 + // 默认颜色
  249 + $colorGroup[0]['color'][] = $value;
243 } 250 }
244 251
245 // 商品图: 多个 252 // 商品图: 多个
@@ -563,9 +570,8 @@ class DetailModel @@ -563,9 +570,8 @@ class DetailModel
563 if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) { 570 if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) {
564 $consultList = DetailData::consultList($uid, $productId, $pageNum, $pageSize); 571 $consultList = DetailData::consultList($uid, $productId, $pageNum, $pageSize);
565 if (isset($consultList['code']) && $consultList['code'] === 200) { 572 if (isset($consultList['code']) && $consultList['code'] === 200) {
566 - $consultList = $consultList['data']['list'];  
567 $build = array(); 573 $build = array();
568 - foreach ($consultList as $value) { 574 + foreach ($consultList['data']['list'] as $value) {
569 $build['question'] = $value['ask']; 575 $build['question'] = $value['ask'];
570 $build['time'] = $value['ask_time']; 576 $build['time'] = $value['ask_time'];
571 $build['answer'] = $value['answer']; 577 $build['answer'] = $value['answer'];
@@ -615,8 +621,6 @@ class DetailModel @@ -615,8 +621,6 @@ class DetailModel
615 $result = array('code' => 400, 'message' => '出错啦~'); 621 $result = array('code' => 400, 'message' => '出错啦~');
616 622
617 do { 623 do {
618 - $record = DetailData::upvoteConsult($uid, $id);  
619 -  
620 if (empty($uid)) { 624 if (empty($uid)) {
621 $result['code'] = 401; 625 $result['code'] = 401;
622 $result['message'] = '用户id为空'; 626 $result['message'] = '用户id为空';
@@ -625,11 +629,12 @@ class DetailModel @@ -625,11 +629,12 @@ class DetailModel
625 } 629 }
626 630
627 // 处理数据 631 // 处理数据
628 - if ($record && isset($record['code'])) { 632 + $record = DetailData::upvoteConsult($uid, $id);
  633 + if (!empty($record['code'])) {
629 $result['code'] = $record['code']; 634 $result['code'] = $record['code'];
630 $result['message'] = $record['message']; 635 $result['message'] = $record['message'];
631 } 636 }
632 - }while(false); 637 + } while (false);
633 638
634 return $result; 639 return $result;
635 } 640 }
@@ -648,8 +653,6 @@ class DetailModel @@ -648,8 +653,6 @@ class DetailModel
648 $result = array('code' => 400, 'message' => '出错啦~'); 653 $result = array('code' => 400, 'message' => '出错啦~');
649 654
650 do { 655 do {
651 - $record = DetailData::usefulConsult($uid, $id);  
652 -  
653 if (empty($uid)) { 656 if (empty($uid)) {
654 $result['code'] = 401; 657 $result['code'] = 401;
655 $result['message'] = '用户id为空'; 658 $result['message'] = '用户id为空';
@@ -658,11 +661,12 @@ class DetailModel @@ -658,11 +661,12 @@ class DetailModel
658 } 661 }
659 662
660 // 处理数据 663 // 处理数据
661 - if ($record && isset($record['code'])) { 664 + $record = DetailData::usefulConsult($uid, $id);
  665 + if (!empty($record['code'])) {
662 $result['code'] = $record['code']; 666 $result['code'] = $record['code'];
663 $result['message'] = $record['message']; 667 $result['message'] = $record['message'];
664 } 668 }
665 - }while(false); 669 + } while (false);
666 670
667 return $result; 671 return $result;
668 } 672 }
1 <?php 1 <?php
  2 +
  3 +use Action\WebAction;
  4 +
2 /** 5 /**
3 * 默认控制器 6 * 默认控制器
4 */ 7 */
5 -use Action\WebAction;  
6 -  
7 class IndexController extends WebAction 8 class IndexController extends WebAction
8 { 9 {
9 10
@@ -63,6 +63,9 @@ class HomeModel @@ -63,6 +63,9 @@ class HomeModel
63 return array(); 63 return array();
64 } 64 }
65 $menu = array(); 65 $menu = array();
  66 + $key = sprintf('%s_%s_%s',CacheConfig::KEY_WEB_HOME_NAVBAR_DATA, md5(serialize($data)), $channel);
  67 + $menu = Cache::get($key);
  68 + if(empty($menu)) {
66 $item = array(); 69 $item = array();
67 foreach ($data['data'] as $val) { 70 foreach ($data['data'] as $val) {
68 $item = array( 71 $item = array(
@@ -112,6 +115,8 @@ class HomeModel @@ -112,6 +115,8 @@ class HomeModel
112 } 115 }
113 $menu[] = $item; 116 $menu[] = $item;
114 } 117 }
  118 + Cache::set($key, $menu, 3600);
  119 + }
115 return $menu; 120 return $menu;
116 } 121 }
117 122
@@ -165,9 +170,14 @@ class HomeModel @@ -165,9 +170,14 @@ class HomeModel
165 */ 170 */
166 public static function getChannelResource($channel, $content_code) 171 public static function getChannelResource($channel, $content_code)
167 { 172 {
  173 + $key = sprintf(CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.$channel);
  174 + $data = Cache::get($key);
  175 + if(empty($data)) {
168 $resource = IndexData::getResourceData($content_code); 176 $resource = IndexData::getResourceData($content_code);
169 // 格式化数据 177 // 格式化数据
170 $data = ChannelProcess::getFormat($channel, $resource['data']); 178 $data = ChannelProcess::getFormat($channel, $resource['data']);
  179 + Cache::set($key, $data, 3600);
  180 + }
171 return $data; 181 return $data;
172 } 182 }
173 183
@@ -213,6 +223,10 @@ class HomeModel @@ -213,6 +223,10 @@ class HomeModel
213 public static function getNewArrival($channel) 223 public static function getNewArrival($channel)
214 { 224 {
215 $result = array(); 225 $result = array();
  226 + $key = sprintf(CacheConfig::KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA.'_'.$channel);
  227 + //缓存数据
  228 + $result = Cache::get($key);
  229 + if(empty($result)) {
216 $params = array( 230 $params = array(
217 'order' => 's_t_desc', 231 'order' => 's_t_desc',
218 'shelve_time' => strtotime("-60 days") . ',' . time() 232 'shelve_time' => strtotime("-60 days") . ',' . time()
@@ -253,6 +267,8 @@ class HomeModel @@ -253,6 +267,8 @@ class HomeModel
253 } 267 }
254 } 268 }
255 } 269 }
  270 + Cache::set($key, $result, 3600);
  271 + }
256 return $result; 272 return $result;
257 } 273 }
258 } 274 }
  1 +<?php
  2 +namespace product;
  3 +
  4 +use Plugin\Images;
  5 +use Plugin\Helpers;
  6 +use Plugin\Cache;
  7 +use Configs\CacheConfig;
  8 +use LibModels\Web\Home\IndexData;
  9 +use \LibModels\Web\Product\HotrankData;
  10 +use \LibModels\Web\Product\SearchData;
  11 +
  12 +class HotrankModel {
  13 +
  14 + /**
  15 + * 人气单品 一周热卖
  16 + */
  17 + static public function getSearchData($condition, $options)
  18 + {
  19 + // 调用接口查询商品数据
  20 + $result = SearchData::searchElasticByCondition($condition);
  21 + //print_r($result);
  22 +
  23 + if(!empty($result)){
  24 + $res = self::getProductList($result);
  25 + if(!empty($res['popular'])){
  26 + $data['popular'] = $res['popular'];
  27 + }
  28 + if(!empty($res['hotWeek'])){
  29 + $data['hotWeek'] = $res['hotWeek'];
  30 + }
  31 + }
  32 + return $data;
  33 + }
  34 +
  35 +
  36 +
  37 + /**
  38 + * 获取分类标签
  39 + */
  40 + static public function getHotranktag($classes)
  41 + {
  42 + $list = SearchData::getClassesData($classes);
  43 + //print_r($list);
  44 + $nav = array();
  45 + if(!empty($list['data']['sort'])){
  46 + foreach($list['data']['sort'] as $li=>$lt){
  47 + $nav[$li]['sid'] = $lt['sort_id'];
  48 + $nav[$li]['textCn'] = $lt['sort_name'];
  49 + }
  50 + }
  51 + //print_r($nav);
  52 + return $nav;
  53 + }
  54 +
  55 +
  56 + /**
  57 + * 人气单品 一周热卖 数据处理
  58 + */
  59 + static public function getProductList($result)
  60 + {
  61 + /*----product start---------*/
  62 + if(empty($result) || empty($result['data']) || empty($result['data']['product_list'])){
  63 + return;
  64 + }
  65 + $data = $result['data']['product_list'];
  66 +
  67 + $popular = array();
  68 + $hotWeek = array();
  69 + foreach($data as $key=>$val){
  70 + if(empty($val['goods_list'])){
  71 + continue;
  72 + }
  73 + $defaultGoodsId = 0;
  74 + foreach ($val['goods_list'] as $v){
  75 + if($v['is_default'] == 'Y'){
  76 + $defaultGoodsId = $v['goods_id'];
  77 + }
  78 + }
  79 + if(empty($defaultGoodsId)){
  80 + $defaultGoodsId = $val['goods_list'][0]['goods_id'];
  81 + }
  82 +
  83 + $product_id = empty($val['product_id']) ? '' : $val['product_id'];
  84 + $re['url'] = 'http://item.yohobuy.com/product/pro_'.$product_id.'_'.$defaultGoodsId.'.html';
  85 +
  86 + $re['marketPrice'] = (int)$val['market_price'] == (int)$val['sales_price'] ? '' : '¥'.$val['market_price'];
  87 + $re['salePrice'] = empty($val['sales_price']) ? '' : '¥'.$val['sales_price'];
  88 + $re['name'] = $val['product_name'];
  89 + if($key <= 9){
  90 + $re['rank'] = $key + 1;
  91 + if($key <= 5){
  92 + $re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2);
  93 + $popular['list'][] = $re;
  94 + }else{
  95 + $re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
  96 + $popular['list'][] = $re;
  97 + }
  98 + }else{
  99 + $re['rank'] = '';
  100 + $re['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
  101 + $hot[] = $re;
  102 + }
  103 + }
  104 + $popular['name'] = '人气单品';
  105 +
  106 + $hotWeek = array(
  107 + 'name'=>'一周热卖',
  108 + 'list'=>$hot,
  109 + );
  110 +
  111 + return array('popular'=>$popular,'hotWeek'=>$hotWeek);
  112 + }
  113 +}
@@ -53,7 +53,6 @@ class BackController extends WebAction { @@ -53,7 +53,6 @@ class BackController extends WebAction {
53 if (Helpers::verifyEmail($phoneNum)) { // 验证邮箱 53 if (Helpers::verifyEmail($phoneNum)) { // 验证邮箱
54 $email = $phoneNum; 54 $email = $phoneNum;
55 $data = BackData::sendCodeToEmail($email); 55 $data = BackData::sendCodeToEmail($email);
56 -  
57 if ($data ['code'] == 200) { 56 if ($data ['code'] == 200) {
58 $this->setSession('email', $email); 57 $this->setSession('email', $email);
59 $this->redirect ('sendemail'); 58 $this->redirect ('sendemail');
@@ -64,7 +63,8 @@ class BackController extends WebAction { @@ -64,7 +63,8 @@ class BackController extends WebAction {
64 } else if (Helpers::verifyMobile($phoneNum)) { // 验证手机号 63 } else if (Helpers::verifyMobile($phoneNum)) { // 验证手机号
65 $mobile = $phoneNum; 64 $mobile = $phoneNum;
66 $data = BackData::sendCodeToMobile($mobile, $area); 65 $data = BackData::sendCodeToMobile($mobile, $area);
67 - if ($data ['code'] == 200) { 66 +
  67 + if ($data['code'] == 200) {
68 $this->setSession ('mobile', $mobile ); 68 $this->setSession ('mobile', $mobile );
69 $this->setSession ('area', $area ); 69 $this->setSession ('area', $area );
70 $this->setSession ('verifyCode', $verifyCode ); 70 $this->setSession ('verifyCode', $verifyCode );
@@ -208,6 +208,8 @@ class BackController extends WebAction { @@ -208,6 +208,8 @@ class BackController extends WebAction {
208 $this->redirect ( SITE_MAIN . $url ); 208 $this->redirect ( SITE_MAIN . $url );
209 } 209 }
210 } 210 }
  211 + //出错直接跳到找回密码页
  212 + $this->redirect ('/passport/back/index');
211 } 213 }
212 214
213 /** 215 /**
@@ -224,4 +226,5 @@ class BackController extends WebAction { @@ -224,4 +226,5 @@ class BackController extends WebAction {
224 } 226 }
225 return $info; 227 return $info;
226 } 228 }
  229 +
227 } 230 }
@@ -2,6 +2,10 @@ @@ -2,6 +2,10 @@
2 use Action\WebAction; 2 use Action\WebAction;
3 use LibModels\Web\Product\BrandData; 3 use LibModels\Web\Product\BrandData;
4 4
  5 +use LibModels\Web\Product\HotrankData;
  6 +use product\HotrankModel;
  7 +use LibModels\Web\Home\IndexData;
  8 +
5 class IndexController extends WebAction 9 class IndexController extends WebAction
6 { 10 {
7 /** 11 /**
@@ -47,5 +51,240 @@ class IndexController extends WebAction @@ -47,5 +51,240 @@ class IndexController extends WebAction
47 //渲染模板 51 //渲染模板
48 $this->_view->display('list',$data); 52 $this->_view->display('list',$data);
49 } 53 }
  54 +
  55 + public function hotrankAction() {
  56 + $this->setWebNavHeader(\Index\HomeModel::COOKIE_NAME_LIFESTYLE);
  57 + $data = array(
  58 + 'hotrankPage' => true,
  59 + 'hotrank' => array(
  60 + array(
  61 + 'slide' => array(
  62 + 'list' => array(
  63 + array(
  64 + 'href' => '/?gender=1,3',
  65 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  66 + ),
  67 + array(
  68 + 'href' => '/?gender=1,3',
  69 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  70 + ),
  71 + array(
  72 + 'href' => '/?gender=1,3',
  73 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  74 + ),
  75 + array(
  76 + 'href' => '/?gender=1,3',
  77 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  78 + ),
  79 + array(
  80 + 'href' => '/?gender=1,3',
  81 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  82 + ),
  83 + array(
  84 + 'href' => '/?gender=1,3',
  85 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  86 + ),
  87 + array(
  88 + 'href' => '/?gender=1,3',
  89 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  90 + ),
  91 + array(
  92 + 'href' => '/?gender=1,3',
  93 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  94 + )
  95 + )
  96 + )
  97 + ),
  98 + array(
  99 + 'popular' => array(
  100 + 'name' => '人气单品',
  101 + 'list' => array(
  102 + array(
  103 + 'href' => '',
  104 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  105 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  106 + 'price' => '399',
  107 + 'sPrice' => '199',
  108 + 'rank' => '1'
  109 + ),
  110 + array(
  111 + 'href' => '',
  112 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  113 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  114 + 'price' => '399',
  115 + 'sPrice' => '199',
  116 + 'rank' => '2'
  117 + ),
  118 + array(
  119 + 'href' => '',
  120 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  121 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  122 + 'price' => '399',
  123 + 'sPrice' => '199',
  124 + 'rank' => '3'
  125 + ),
  126 + array(
  127 + 'href' => '',
  128 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  129 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  130 + 'price' => '399',
  131 + 'sPrice' => '199',
  132 + 'rank' => '4'
  133 + ),
  134 + array(
  135 + 'href' => '',
  136 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  137 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  138 + 'price' => '399',
  139 + 'sPrice' => '199',
  140 + 'rank' => '5'
  141 + ),
  142 + array(
  143 + 'href' => '',
  144 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  145 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  146 + 'price' => '399',
  147 + 'sPrice' => '199',
  148 + 'rank' => '6'
  149 + ),
  150 + array(
  151 + 'href' => '',
  152 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  153 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  154 + 'price' => '399',
  155 + 'sPrice' => '199',
  156 + 'rank' => '7'
  157 + ),
  158 + array(
  159 + 'href' => '',
  160 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  161 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  162 + 'price' => '399',
  163 + 'sPrice' => '199',
  164 + 'rank' => '8'
  165 + ),
  166 + array(
  167 + 'href' => '',
  168 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  169 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  170 + 'price' => '399',
  171 + 'sPrice' => '199',
  172 + 'rank' => '9'
  173 + ),
  174 + array(
  175 + 'href' => '',
  176 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  177 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  178 + 'price' => '399',
  179 + 'sPrice' => '199',
  180 + 'rank' => '10'
  181 + )
  182 + )
  183 +
  184 + )
  185 + ),
  186 + array(
  187 + 'hotBrands' => array(
  188 + 'name' => '热门品牌',
  189 + )
  190 + ),
  191 + array(
  192 + 'hotWeek' => array(
  193 + 'name' => '一周热卖',
  194 + 'nav' => array(
  195 + array(
  196 + 'textCn' => 'TOP100',
  197 + 'url' => '',
  198 + 'sid' => 1
  199 + ),
  200 + array(
  201 + 'textCn' => '上装',
  202 + 'url' => '',
  203 + 'sid' => 2
  204 + ),
  205 + array(
  206 + 'textCn' => '男生测试',
  207 + 'url' => '',
  208 + 'sid' => 3
  209 + ),
  210 + array(
  211 + 'textCn' => '配饰',
  212 + 'url' => '',
  213 + 'sid' => 4
  214 + )
  215 + ),
  216 + 'list' => array(
  217 + array(
  218 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  219 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  220 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  221 + 'marketPrice' => '109',
  222 + 'salePrice' => '129'
  223 + ),
  224 + array(
  225 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  226 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  227 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  228 + 'marketPrice' => '109',
  229 + 'salePrice' => '129'
  230 + ),
  231 + array(
  232 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  233 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  234 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  235 + 'marketPrice' => '109',
  236 + 'salePrice' => '129'
  237 + ),
  238 + array(
  239 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  240 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  241 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  242 + 'marketPrice' => '109',
  243 + 'salePrice' => '129'
  244 + ),
  245 + array(
  246 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  247 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  248 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  249 + 'marketPrice' => '109',
  250 + 'salePrice' => '129'
  251 + ),
  252 + array(
  253 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  254 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  255 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  256 + 'marketPrice' => '109',
  257 + 'salePrice' => '129'
  258 + ),
  259 + )
  260 + )
  261 + )
  262 + )
  263 + );
  264 + $data = array( 'hotrankPage' => true,
  265 + 'footerTop'=> true,
  266 + 'hotrank' => array()
  267 + );
  268 + //焦点图 热门品牌
  269 + $focus = \Index\HomeModel::getChannelResource('lifestyle', 'd131aba83a84a6977eee3a7403a713de');
  270 + //print_r($focus);
  271 + $data['hotrank']['slide'] = $focus[0]['slide'];
  272 + $data['hotrank']['hotBrands'] = $focus[1]['hotBrands'];
  273 +
  274 + //人气单品 一周热卖
  275 + $page = 1;
  276 + $param = array('order'=>'s_n_desc','viewNum'=>60,'page'=>1,'stocknumber'=>1,'status'=>1,'gender'=>'','attribute_not'=>2);
  277 + $publiclist = \product\HotrankModel::getSearchData($param,$page);
  278 + $data['hotrank']['popular'] = $publiclist['popular'];
  279 + $data['hotrank']['hotWeek'] = $publiclist['hotWeek'];
  280 + //print_r($publiclist);
  281 +
  282 + //分类标签
  283 + $classes = array('gender' => 2);
  284 + $nav = \product\HotrankModel::getHotranktag($classes);
  285 + $data['hotrank']['hotWeek']['nav'] = $nav;
  286 + //print_r($data);
  287 + $this->_view->display('hotrank', $data);
  288 + }
50 } 289 }
51 ?> 290 ?>
@@ -8,8 +8,26 @@ class ListController extends WebAction @@ -8,8 +8,26 @@ class ListController extends WebAction
8 8
9 } 9 }
10 10
  11 + /**
  12 + * list列表new(模板new-sale)
  13 + */
11 public function newAction(){ 14 public function newAction(){
  15 + $condition = array(
  16 + 'order' => 's_t_desc'
  17 + );
  18 + $options = array(
  19 + 'specialsale_id' => 'Y',
  20 + 'needDay' => 'Y'
  21 + );
12 22
  23 + $newData = Product\NewModel::getNewSearchData($condition, $options);
  24 + $data = array(
  25 + 'productListPage' => true,
  26 + 'newSale' => $newData
  27 + );
  28 + $this->setWebNavHeader();
  29 + //渲染模板
  30 + $this->_view->display('new-sale', $data);
13 } 31 }
14 32
15 /** 33 /**
1 -<?php  
2 -  
3 -use Action\WebAction;  
4 -  
5 -/**  
6 - * new页  
7 - *  
8 - */  
9 -class NewController extends WebAction  
10 -{  
11 -  
12 - public function indexAction()  
13 - {  
14 - $condition = array(  
15 - 'order' => 's_t_desc'  
16 - );  
17 - $options = array(  
18 - 'specialsale_id' => 'Y',  
19 - 'needDay' => 'Y'  
20 - );  
21 -  
22 - $newData = Product\NewModel::getNewSearchData($condition, $options);  
23 - $data = array(  
24 - 'productListPage' => true,  
25 - 'newSale' => $newData  
26 - );  
27 - $this->setWebNavHeader();  
28 - //渲染模板  
29 - $this->_view->display('new-sale', $data);  
30 - }  
31 -  
32 -}