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
return Yohobuy::get(self::getUrl('search'), $param, $cache);
}
/**
* 根据分类列表获取商品信息
*
... ... @@ -157,20 +158,48 @@ class SearchData extends \LibModels\Wap\Product\SearchData
// }
// return $data;
/* 2016/01/26 code review by fei.hong: 优化合并misort参数, 减少调用搜索的次数 */
$sortIds = '';
$viewNum = 0;
foreach ($sortList as $value) {
$viewNum += intval($value['viewNum']);
$sortIds .= $value['misort'] . ',';
/* code review by fei.hong: 2016/01/26 优化合并misort参数, 减少调用搜索接口的次数 */
$data = array();
// 按照时间降序排的参数
$params['order'] = 'shelve_time:desc';
// 获取新品的接口URL,以数组列表返回
$urlList = self::getNewArrivalUrl($sortList, $params);
// 并行调用搜索新品接口
$searchd = Yohobuy::getMulti($urlList);
// 该变量用于记录数组最后一个值的索引
$lastIndex = 0;
// 业务逻辑:按照指定品类排序显示
foreach ($sortList as $key => $value) {
$lastIndex = $value['viewNum'] - 1;
// 业务逻辑:一个品类不满指定个数时,前台不显示
if (!empty($searchd[$key]) && isset($searchd[$key]['product_list'][$lastIndex])) {
$data = array_merge($data, $searchd[$key]['product_list']);
}
}
$params['viewNum'] = $viewNum;
$params['misort'] = rtrim($sortIds, ',');
$searchd = self::searchElasticByCondition($params);
if (empty($searchd['data']['product_list'])) {
return array();
// 用完清空不使用的变量
$searchd = array();
return $data;
}
/**
* 获取推荐新品的接口URL列表
*
* @param array $sortList 分类列表
* @param array $params 附加参数
* @return arary
*/
public static function getNewArrivalUrl($sortList, $params)
{
$urlList = array();
$option = array();
foreach ($sortList as $key => $value) {
$option = $params + $value;
$urlList[$key] = Yohobuy::httpBuildQuery(self::getUrl('search'), $option);
}
return $searchd['data']['product_list'];
return $urlList;
}
/**
... ...
... ... @@ -604,18 +604,14 @@ class Process
// single_image & floor & single_image
$list = array_merge($data[$key + 1]['data'], array_slice($data[$key + 2]['data'], 0, 6), $data[$key + 3]['data']);
foreach ($list as $listKey => $val) {
$width = 185;
$height = 248;
$w = 377;
$h = 504;
if ($listKey == 0 || $listKey == 7) {
$val['src'] = Images::getImageUrl($val['src'], $w, $h, 1);
$val['src'] = Images::getImageUrl($val['src'], 377, 504, 1);
$result['newReport']['list'][] = array(
'href' => $val['url'],
'img' => $val['src']
);
} else {
$val['src'] = Images::getImageUrl($val['src'], $width, $height, 1);
$val['src'] = Images::getImageUrl($val['src'], 185, 248, 1);
$result['newReport']['list'][] = array(
'href' => $val['url'],
'img' => $val['src']
... ... @@ -656,6 +652,8 @@ class Process
$result['category']['navs'] = self::mergeNavProcess($data[$key + 1], $type);
}
// floor模版
$width = 0;
$height = 0;
foreach ($data[$key + 2]['data'] as $pos => $val) {
$width = 185; $height = 510;
if($pos == 1) {
... ... @@ -761,8 +759,9 @@ class Process
{
$result = array();
foreach ($data['data'] as $val) {
if (empty($val))
if (empty($val)) {
continue;
}
$result[] = array(
'href' => $val['url'],
'name' => $val['name']
... ... @@ -790,8 +789,10 @@ class Process
'client_type' => 'web'
);
$goodsList = SearchData::searchElasticByCondition($params, false);
$goodsList = $goodsList['data']['product_list'];
$goodsList = empty($goodsList) ? array() : $goodsList['data']['product_list'];
$pos = 0;
$url = '';
$oneGoods = array();
foreach ($goodsList as $goods)
{
$oneGoods = array();
... ... @@ -802,10 +803,10 @@ class Process
if (empty($goods)) {
continue;
}
$url = Helpers::getUrlBySkc($goods['product_id'], $goods['goods_list'][0]['goods_id'], $goods['cn_alphabet']);
$oneGoods['img'] = Images::getImageUrl($goods['goods_list'][0]['images_url'], 280, 373, 1);
$oneGoods['name'] = $goods['product_name'];
$oneGoods['price'] = $goods['sales_price'];
$url = Helpers::getUrlBySkc($goods['product_id'], $goods['goods_list'][0]['goods_id'], $goods['cn_alphabet']);
$oneGoods['href'] = Helpers::transUrl($url, $type);
$result[$goods['product_skn']] = $oneGoods;
}
... ... @@ -838,7 +839,6 @@ class Process
public static function mergeHotBrandsData($key,array &$data,$type)
{
$result = array();
$temp = array();
if ($data[$key]['template_name'] == 'custom_brands')
{
$result = array(
... ... @@ -858,20 +858,18 @@ class Process
$brands = $data[$key]['data']['list'];
foreach ($brands as $val)
{
$width = 185;
$height = 86;
$val['src'] = Images::getImageUrl($val['src'], $width, $height, 2);
$val['src'] = Images::getImageUrl($val['src'], 185, 86, 2);
$val['url'] = Helpers::transUrl($val['url'], $type);
$floor['logoBrand'][] = array(
'href' => $val['url'],
'img' => $val['src']
);
}
$floor['moreBrand'] = 'http://yohobuy.com/brands';
$type_key = sprintf("%s_%s", $type, $key);
$cacheKey = sprintf("%s_%s", WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA, $type_key);
$floor['moreBrand'] = Helpers::url('/brands');
$typeKey = sprintf("%s_%s", $type, $key);
$cacheKey = sprintf("%s_%s", WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA, $typeKey);
Cache::set($cacheKey, $floor, 86400);
$result['hotBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key;
$result['hotBrands']['brandUrl'] = Helpers::url('/common/getIndexResourceBrand', array('type' => $typeKey));
}
return $result;
}
... ...
... ... @@ -24,7 +24,7 @@ class Helpers
switch ($module) {
case 'default':
$url = 'http://m.yohobuy.com';
$url = 'http://www.yohobuy.com';
break;
case 'guang': // 逛
$url = 'http://guang' . SUB_DOMAIN;
... ...
... ... @@ -479,6 +479,9 @@
}
}
}
.tpl-brands{
margin-top:-8px!important;
}
}
.boys,.lifestyle{
.goods-container{
... ...
... ... @@ -46,6 +46,7 @@ class ClassModel
$genderArr = array('boy' => '1,3', 'girl' => '2,3', 'kids' => '1,2,3', 'lifestyle' => '1,2,3');
$oneClass = array();
$item = array();
$subitem = array();
foreach ($data['data'] as $k => $v) {
$oneClass = array('name' => ucfirst(rtrim($k, 's')), 'ca' => array());
... ...
<?php
use Action\WebAction;
use Index\HomeModel;
use Configs\WebCacheConfig;
use LibModels\Web\Home\IndexData;
use WebPlugin\Cache;
use Configs\WebCacheConfig;
use Api\Yohobuy;
use WebPlugin\Images;
use WebPlugin\Helpers;
... ... @@ -16,15 +15,27 @@ class CommonController extends WebAction
*/
public function getIndexResourceBrandAction()
{
$data = array();
do {
if (!$this->isAjax()) {
break;
}
$type = $this->get('type');
if (empty($type)) {
break;
}
}
while (false);
// 首页资源品牌,采用内存存储
$type = $this->get('type');
$data = array();
if (! empty($type)) {
$key = WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA . '_' . $type;
// array('logoBrand'=>'','moreBrand'=>'')
$data = Cache::get($key);
}
echo $this->echoJson($data);
$this->echoJson($data);
}
/**
... ... @@ -36,7 +47,7 @@ class CommonController extends WebAction
*/
public function getNewArrivalAction()
{
$result = $data = array();
$result = array();
do {
/* 判断是不是AJAX请求 */
if (! $this->isAjax()) {
... ... @@ -53,23 +64,29 @@ class CommonController extends WebAction
$pageCount = (int) $this->post('pageCount', 8);
if (! in_array($channel, $channels)) {
break;
} else {
$data = HomeModel::getNewArrival($channel);
}
if($pageIndex < 0) {
$data = HomeModel::getNewArrival($channel);
if (empty($data)) {
break;
}
if ($pageIndex < 0) {
$pageIndex = 0;
}
if($pageCount < 0 || $pageCount > 50) {
if ($pageCount < 0 || $pageCount > 50) {
$pageCount = 20;
}
$result = array_slice($data, $pageIndex, $pageCount);
if (empty($result)) {
$data = array_slice($data, $pageIndex, $pageCount);
if (empty($data)) {
break;
}
$result = array(
'code' => 200,
'goods' => $result
'goods' => $data
);
$data = array();
} while (false);
$this->echoJson($result);
... ...
... ... @@ -110,18 +110,20 @@ class HotrankModel
'gender' => $data['gender'],
'road' => $data['road']);
$list = self::getSearchData($config, $page, 1);
$lister = $list['hotWeek']['list'];
$lister = array_values($lister);
if ($sid == 1 && $page == 1) {
$lister = array_slice($lister, 10, 50);
}
else {
$lister = array_slice($lister, 0, 50);
if (!empty($list)) {
$lister = $list['hotWeek']['list'];
$lister = array_values($lister);
if ($sid == 1 && $page == 1) {
$lister = array_slice($lister, 10, 50);
}
else {
$lister = array_slice($lister, 0, 50);
}
$data = array(
'code' => 200,
'data' => $lister,);
return $data;
}
$data = array(
'code' => 200,
'data' => $lister,);
return $data;
}
/**
... ... @@ -171,6 +173,7 @@ class HotrankModel
}
//根据给定查询数据搜索数据列表
$result = SearchData::searchElasticByCondition($param);
//人气单品,一周热卖数据处理
$data = self::getProductList($result, $page, $ajax);
return $data;
}
... ... @@ -208,13 +211,13 @@ class HotrankModel
return $product;
}
$data = $result['data']['product_list'];
$popular = array();
$hotWeek = array();
$popular = array(); //一周热卖
$hotWeek = array(); //人气单品
foreach ($data as $key => $val) {
if (empty($val['goods_list'])) {
continue;
}
//$defaultGoodsId = 0;
$defaultGoodsId = 0;
foreach ($val['goods_list'] as $v) {
if ($v['is_default'] == 'Y') {
$defaultGoodsId = empty($v['goods_id']) ? $val['goods_list'][0]['goods_id'] : $v['goods_id'];
... ... @@ -226,8 +229,8 @@ class HotrankModel
$product['rank'] = $key + 1;
$product['title'] = $val['product_name'];
$product['href'] = $url . '_' . $product_id . '_' . $defaultGoodsId . '.html';
$product['price'] = (int) $val['market_price'] == (int) $val['sales_price'] ? '' : $val['market_price'];
$product['sPrice'] = empty($val['sales_price']) ? '' : $val['sales_price'];
$product['price'] = (int) $val['market_price'] == (int) $val['sales_price'] ? false : $val['market_price'];
$product['sPrice'] = empty($val['sales_price']) ? false : $val['sales_price'];
if ($key <= 5) {
//6张大图
$product['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2);
... ... @@ -243,8 +246,8 @@ class HotrankModel
//一周热卖
$product['name'] = $val['product_name'];
$product['url'] = $url . '_' . $product_id . '_' . $defaultGoodsId . '.html';
$product['marketPrice'] = (int) $val['market_price'] == (int) $val['sales_price'] ? '' : $val['market_price'];
$product['salePrice'] = empty($val['sales_price']) ? '' : $val['sales_price'];
$product['marketPrice'] = (int) $val['market_price'] == (int) $val['sales_price'] ? false : $val['market_price'];
$product['salePrice'] = empty($val['sales_price']) ? false : $val['sales_price'];
$product['rank'] = '';
$product['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
$hot[] = $product;
... ...
... ... @@ -148,6 +148,7 @@ class IndexController extends WebAction
//获取频道
$channel = HotrankModel::getChannelResource();
$this->setWebNavHeader($channel['channel']);
$this->setTitle('热销排行|YOHO!BUY有货');
$page = $this->get('page', 1);
$sort = $this->get('sid', 1);
$data = array('hotrankPage' => true,
... ...