Authored by yangyang

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

framework @ 75bbc3b0
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ... @@ -63,5 +63,6 @@ class CacheConfig
const KEY_WEB_HOME_NAVBAR_DATA = 'key_web_home_navbar_data';//web的导航数据
const KEY_WEB_HOME_CHANNEL_DATA = 'key_web_home_channel_data';//web首页频道数据[boys, girls, kids, lifestyle]
const KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA = 'key_web_home_newarrival_data';//web频道最新上架数据[boys, girls, kids, lifestyle]
const KEY_WEB_PRODUCT_SEARCH_DATA = 'key_web_product_search_data'; // web搜索的数据
}
... ...
... ... @@ -2,7 +2,7 @@
namespace LibModels\Web\Home;
use Api\Yohobuy;
use Api\Sign;
use Plugin\Helpers;
use WebPlugin\Helpers;
class UserData extends \LibModels\Wap\Home\UserData
{
/**
... ...
... ... @@ -25,6 +25,10 @@ class SearchData extends \LibModels\Wap\Product\SearchData
elseif ($type == 'recent') {
return 'http://100.98.132.63/yohosearch/recent.json';
}
elseif ($type == 'suggest') {
//return 'http://101.200.31.165/yohosearch/suggest.json';
return 'http://100.98.132.63/yohosearch/suggest.json';
}
elseif ($type == 'shop') {
return 'http://100.98.132.63/yohosearch/shops.json';
}
... ... @@ -34,19 +38,27 @@ class SearchData extends \LibModels\Wap\Product\SearchData
case 'developer':
default:
if ($type == 'sort') {
return 'http://101.200.31.165/yohosearch/sortgroup.json';
//return 'http://101.200.31.165/yohosearch/sortgroup.json';
return 'http://182.92.99.119:8080/yohosearch/sortgroup.json';
}
elseif ($type == 'discount') {
return 'http://101.200.31.165/yohosearch/discount.json';
//return 'http://101.200.31.165/yohosearch/discount.json';
return 'http://182.92.99.119:8080/yohosearch/discount.json';
}
elseif ($type == 'recent') {
return 'http://101.200.31.165/yohosearch/recent.json';
//return 'http://101.200.31.165/yohosearch/recent.json';
return 'http://182.92.99.119:8080/yohosearch/recent.json';
}
elseif ($type == 'suggest') {
// return 'http://101.200.31.165/yohosearch/suggest.json';
return 'http://182.92.99.119:8080/yohosearch/suggest.json';
}
elseif ($type == 'shop') {
return 'http://101.200.31.165/yohosearch/shops.json';
//return 'http://101.200.31.165/yohosearch/shops.json';
return 'http://182.92.99.119:8080/yohosearch/shops.json';
}
// return 'http://101.200.31.165/yohosearch/search.json';
return 'http://192.168.10.64:8080/yohosearch/search-once.json';
return 'http://182.92.99.119:8080/yohosearch/search-once.json';
}
}
... ...
<?php
namespace WebPlugin\DataProcess\WebChannel;
namespace WebPlugin\DataProcess;
class Channel
{
public static $formatChannel = array(
'boys' => '\WebPlugin\DataProcess\WebChannel\Channel\Boys',
'girls' => '\WebPlugin\DataProcess\WebChannel\Channel\Girls',
'kids' => '\WebPlugin\DataProcess\WebChannel\Channel\Kids',
'lifestyle' => '\WebPlugin\DataProcess\WebChannel\Channel\Lifestyle'
'boys' => '\WebPlugin\DataProcess\Channel\Boys',
'girls' => '\WebPlugin\DataProcess\Channel\Girls',
'kids' => '\WebPlugin\DataProcess\Channel\Kids',
'lifestyle' => '\WebPlugin\DataProcess\Channel\Lifestyle'
);
public static function getFormat($channel, $data)
... ...
<?php
namespace WebPlugin\DataProcess\WebChannel\Channel;
namespace WebPlugin\DataProcess\Channel;
abstract class AbstractChannel
{
/***
... ...
<?php
namespace WebPlugin\DataProcess\WebChannel\Channel;
namespace WebPlugin\DataProcess\Channel;
class Boys extends AbstractChannel
{
/**
... ...
<?php
namespace WebPlugin\DataProcess\WebChannel\Channel;
namespace WebPlugin\DataProcess\Channel;
class Girls extends AbstractChannel
{
public static function format($resource)
... ...
<?php
namespace WebPlugin\DataProcess\WebChannel\Channel;
namespace WebPlugin\DataProcess\Channel;
class Kids extends AbstractChannel
{
/**
... ...
<?php
namespace WebPlugin\DataProcess\WebChannel\Channel;
namespace WebPlugin\DataProcess\Channel;
class Lifestyle extends AbstractChannel
{
/**
... ...
<?php
namespace WebPlugin\DataProcess\WebChannel;
namespace WebPlugin\DataProcess;
use Plugin\Images;
use WebPlugin\Images;
use WebPlugin\Helpers;
use WebPlugin\Cache;
use Configs\CacheConfig;
... ...
... ... @@ -59,35 +59,49 @@ class HelperSearch
self::$options = $options;
unset(self::$params['/']);
unset(self::$params['page']);
self::$filter = $data['product']['filter'];
self::$filter = isset($data['product']['filter']) ? $data['product']['filter'] : array();
//产品列表
$result['goods'] = self::getProductList($data['product']['product_list'], $options['imgSize']);
$result['goods'] = isset($data['product']['product_list']) ? self::getProductList($data['product']['product_list'], $options['imgSize']) : array();
//总页数
$result['page_total'] = $data['product']['page_total'];
self::$pageTotal = $data['product']['page_total'];
$result['page_total'] = isset($data['product']['page_total']) ? $data['product']['page_total'] : '';
self::$pageTotal = $result['page_total'];
//当前页
$result['page'] = $data['product']['page'];
$result['page'] = isset($data['product']['page']) ? $data['product']['page'] : '';
self::$page = $result['page'];
//筛选条件
$result['filters'] = self::filter();
$result['filters'] = isset($data['product']['filter']) ? self::filter() : array();
//排序方式、显示数量等其他选项
$result['opts'] = self::getOpts();
$result['opts'] = isset($data['product']['filter']) ? self::getOpts() : array();
//下一页
if (isset($data['product']['page_total'])) {
$result['hasNextPage'] = self::next($data['product']['page_total']);
}
//全部折扣
$result['leftContent'][]['allDiscount'] = isset($data['discount']) ? self::getDiscount($data['discount']['discount']) : array();
//分类条件
$result['filters']['sort'] = isset($data['sort']) ? self::searchSort($data['sort']['sort']) : array();
if (isset($data['discount']['discount']) && !empty($data['discount']['discount'])) {
$result['leftContent'][]['allDiscount'] = self::getDiscount($data['discount']['discount']);
}
//分类条件(搜索页面)
if (isset($data['sort']['sort'])) {
//分类条件(搜索页面)
if (isset($options['controller']) && $options['controller'] != 'Search') {
$result['filters']['sort'] = self::searchSort($data['sort']['sort']);
}else{
//左侧分类分类
$result['leftContent'][]['allSort'] = isset($data['sort']) ? self::groupSort($data['sort']['sort']) : array();
$result['leftContent'][]['allSort'] = self::groupSort($data['sort']['sort']);
}
}
//一周新品上架
$result['leftContent'][]['newSales'] = isset($data['recent']) ? self::recentShelve($data['recent']['recent']) : array();
if (isset($data['recent']['recent']) && !empty($data['recent']['recent'])) {
$result['leftContent'][]['newSales'] = self::recentShelve($data['recent']['recent']);
}
//品牌banner
$result['brandBanner'] = isset($data['brand']) ? self::getBannerFormat($data['brand'], $options['brandBanner']) : array();
//总记录数
$result['totalCount'] = $data['product']['total'];
//品牌店铺信息
$result['shopEntry'] = isset($data['shop']) && !empty($data['shop']) ? self::shop($data['shop'], $data['sort']['sort']) : array();
if (isset($data['shop']) && !empty($data['shop'])) {
$result['shopEntry'] = self::shop($data['shop'], $data['sort']['sort']);
}
//分页
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
//浏览记录
... ... @@ -117,6 +131,9 @@ class HelperSearch
{
$params = self::$params;
$goods = array();
if (empty($product)) {
return $goods;
}
foreach($product as $key => $val){
//NEW
$isNew = $val['is_new'] == 'Y' ? true : false;
... ... @@ -306,9 +323,6 @@ class HelperSearch
{
$result = array();
$options = self::$options;
if (!isset($options['controller']) || $options['controller'] != 'Search') {
return $result;
}
$params = self::$params;
foreach ($sort as $key => $val) {
$result[$key]['id'] = $val['sort_id'];
... ... @@ -361,7 +375,6 @@ class HelperSearch
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
if (isset($filter['brand']) && !empty($filter['brand'])) {
$brand = $filter['brand'];
// print_r($filter); exit;
//已选中品牌数量
$existBrandNum = 0;
//已选中品牌标签名
... ... @@ -427,15 +440,20 @@ class HelperSearch
if ($key && !in_array($key, $index_key) && !is_numeric($key)) {
$index['index'] = strtolower(($key));
$index['name'] = $key;
$result['brandIndex'][] = $index;
$index_key[] = $index;
}
if ($key && !in_array($key, $index_key) && is_numeric($key) && count($result['brandIndex']) === 1) {
$index['index'] = '0-9';
$index['name'] = '0~9';
$result['brandIndex'][] = $index;
}
if (is_array($val)) {
foreach ($val as $v) {
$result['brandsShow'][] = $v;
}
}
}
$result['brandIndex'] = array_merge($result['brandIndex'], $index_key);
unset($brandList);
}
//搜索页已选中,返回空
... ... @@ -952,9 +970,6 @@ class HelperSearch
public static function getDiscount(array $list = array())
{
$params = self::$params;
if (empty($list)) {
return array();
}
$query = array();
$total = 0;
foreach ($list as $k => $v) {
... ... @@ -1141,7 +1156,7 @@ class HelperSearch
if (isset($options['controller']) && $options['controller'] == 'Search' && isset($param['query'])) {
self::$listNav[1] = array(
'href' => '',
'name' => "".$param['query']." ".$total."个结果"
'name' => '搜索“<span id="nav_keyword">'.$param['query'].'</span>”共<span id="nav_keyword_count">'.$total.'</span>个结果'
);
}else{
self::$listNav[1] = array(
... ...
... ... @@ -10,13 +10,15 @@
{{/unless}}
</a>
{{^}}
<span>
{{name}}
{{{name}}}
{{#unless @last}}
<span>
<i class="iconfont">&#xe601;</i>
{{/unless}}
</span>
{{/unless}}
{{/if}}
{{/each}}
</p>
... ...
<?php
use Action\WebAction;
use Index\HomeModel;
use WebPlugin\Captcha;
/**
* 女首
*/
... ...
... ... @@ -7,7 +7,7 @@ use WebPlugin\Helpers;
use WebPlugin\Cache;
use LibModels\Web\Home\IndexData;
use LibModels\Web\Product\SearchData;
use WebPlugin\DataProcess\WebChannel\Channel as ChannelProcess;
use WebPlugin\DataProcess\Channel as ChannelProcess;
/**
* web首页模板数据模型
... ...
... ... @@ -4,7 +4,9 @@ namespace Product;
use Api\Yohobuy;
use WebPlugin\Helpers;
use WebPlugin\HelperSearch;
use LibModels\Web\Product\SearchData;
use \LibModels\Web\Product\SearchData;
use Configs\CacheConfig;
use WebPlugin\Cache;
/**
* sale首页模板数据模型
... ... @@ -148,13 +150,8 @@ class SearchModel
$urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['sortCondition']);
// 组合搜索折扣区间url
$urlList['discount'] = HelperSearch::getDiscountUrl($searchCondition['condition']);
// 组合搜索最新上架url
//$urlList['recent'] = HelperSearch::getRecentShelveUrl($searchCondition['condition']);
//用户浏览记录
//$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
$result = Yohobuy::getMulti($urlList, array(), true);
// 组织模板数据
$data = HelperSearch::getList($result, $searchCondition['options']);
return $data;
... ... @@ -170,21 +167,41 @@ class SearchModel
{
$urlList = array();
$searchCondition = self::searchCondition($customCondition, $customOptions);
// if (USE_CACHE) {
// $key = CacheConfig::KEY_WEB_PRODUCT_SEARCH_DATA;
// if (!empty($condition)) {
// $key .= http_build_query($searchCondition['condition'], null, '&');
// }
// // 先尝试获取一级缓存(master), 有数据则直接返回.
// $result = Cache::get($key, 'master');
// if (!empty($result)) {
// return $result;
// }
// }
// 组合搜索商品url
$urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']);
// 组合搜索分类url
$urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']);
$urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['sortCondition']);
// 组合搜索店铺url
if (isset($searchCondition['condition']['query'])) {
$param['keyword'] = $searchCondition['condition']['query'];
$urlList['shop'] = HelperSearch::getShopUrl($param);
}
//用户浏览记录
//$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
$result = Yohobuy::getMulti($urlList, array(), true);
$data = Yohobuy::getMulti($urlList, array(), true);
// 组织模板数据
$data = HelperSearch::getList($result, $searchCondition['options']);
return $data;
$result = HelperSearch::getList($data, $searchCondition['options']);
// if (USE_CACHE) {
// // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
// if (empty($result)) {
// $result = Cache::get($key, 'slave');
// }
// // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
// else {
// Cache::set($key, $result, 1800); // 缓存30分钟
// }
// }
return $result;
}
/**
* 根据product_sn查询产品图片信息
... ... @@ -230,7 +247,6 @@ class SearchModel
*/
public static function getSortSize($condition)
{
$size = array();
//返回搜索条件
$condition['needFilter'] = 1;
$condition['viewNum'] = 1;
... ...
... ... @@ -5,7 +5,7 @@ define('SITE_MAIN', 'http://web.dev.yohobuy.com'); // 网站主域名
define('OLD_MAIN', 'http://www.yohobuy.com'); // 网站旧域名
define('COOKIE_DOMAIN', '.yohobuy.com'); // COOKIE作用域
define('SUB_DOMAIN', '.yohobuy.com'); // 子域名后缀
define('USE_CACHE', true); // 缓存的开关
define('USE_CACHE', false); // 缓存的开关
define('APPLICATION_PATH', dirname(__DIR__)); // 应用目录
define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); // 根目录
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
... ...