Authored by yangyang

解决冲突

... ... @@ -292,12 +292,12 @@ class ChannelConfig
//from统计模块标识
public static $itemFromStats = array(
'search' => array('domain' =>'search','module'=>'s'),//搜索页search.yohobuy.com
'search_index' => array('domain' =>'search','module'=>'s'),//搜索页search.yohobuy.com
'list_sale' => array('domain' =>'list','module'=>'s'),//list.yohobuy.com/sale
'list' => array('domain' =>'list','module'=>'c'),//list.yohobuy.com
'list_index' => array('domain' =>'list','module'=>'c'),//list.yohobuy.com
'list_new' => array('domain' =>'list','module'=>'n'),//list.yohobuy.com/new
'brand' => array('domain' =>'brand','module'=>'b'),//xxx.yohobuy.com[品牌域名]
'sale' => array('domain' =>'sale','module' => 's'),//sale.yohobuy.com
'index_brand' => array('domain' =>'brand','module'=>'b'),//xxx.yohobuy.com[品牌域名]
'sale_index' => array('domain' =>'sale','module' => 's'),//sale.yohobuy.com
);
//左侧广告默认图片-passport相关页面
... ...
... ... @@ -218,4 +218,109 @@ class SearchData extends \LibModels\Wap\Product\SearchData
}
return Yohobuy::get(self::getUrl('suggest'),$param, $cache);
}
/**
* 并行调接口url获取(搜索产品数据)
* @param
*/
public static function getProductUrl($condition)
{
// 排序数据映射表
$orderMaps = array(
's_t_desc' => 'shelve_time:desc',
's_t_asc' => 'shelve_time:asc',
's_p_asc' => 'sales_price:asc',
's_p_desc' => 'sales_price:desc',
'p_d_desc' => 'discount:desc',
'p_d_asc' => 'discount:asc',
'skn_desc' => 'product_skn:desc',
'skn_asc' => 'product_skn:asc',
'activities_desc' => 'activities.order_by:desc',
'activities_asc' => 'activities.order_by:asc',
's_n_asc' => 'sales_num:asc',
's_n_desc' => 'sales_num:desc',
'activities_id_desc' => 'activities.activity_id:desc',
'activities_id_asc' => 'activities.activity_id:asc',
);
$param = array();
$param['status'] = 1; // 是否上架,1表示在架,2表示不在
$param['sales'] = 'Y'; // 只搜索销售的产品
$param['stocknumber'] = 1; // 过滤掉已售罄的商品
if (!isset($condition['order'])) {
$param['order'] = $orderMaps['s_t_desc'];
} else {
$param['order'] = $orderMaps[$condition['order']];
}
if (!isset($condition['page'])) {
$param['page'] = 1;
}
if(isset($condition['viewNum'])) {
$param['viewNum'] = $condition['viewNum'];
} else if (!isset($condition['limit'])) {
$param['viewNum'] = 60;
} else {
$param['viewNum'] = $condition['limit'];
unset($condition['limit']);
}
if (!empty($condition)) {
$param += $condition;
}
return Yohobuy::httpBuildQuery(SearchData::getUrl(), $param);
}
/**
* 并行调接口url获取(产品分类)
* @param
*/
public static function getClassesUrl($condition)
{
$condition['sales'] = 'Y'; //在销售商品分类
$condition['status'] = 1; //上架商品分类
$condition['stocknumber'] = 1; //过滤掉已售罄
return Yohobuy::httpBuildQuery(SearchData::getUrl('sort'), $condition);
}
/**
* 并行调接口url获取(获取折扣区间)
* @param
*/
public static function getDiscountUrl($param = array())
{
return Yohobuy::httpBuildQuery(SearchData::getUrl('discount'), $param);
}
/**
* 并行调接口url获取(获取最新上架)
*/
public static function getRecentShelveUrl($param = array())
{
return Yohobuy::httpBuildQuery(SearchData::getUrl('recent'), $param);
}
/**
* 并行调接口url获取(获取品牌数据)
*/
public static function getBrandUrl($customOptions = array())
{
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = $customOptions['brandId'];
$param['uid'] = $customOptions['uid'];
$param['method'] = 'app.brand.getBrandIntro';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
}
/**
* 获取品牌店铺接口地址
* @param $param
* @return string
*/
public static function getShopUrl($param)
{
return Yohobuy::httpBuildQuery(SearchData::getUrl('shop'), $param);
}
}
\ No newline at end of file
... ...
... ... @@ -7,6 +7,7 @@ use LibModels\Web\Product\BrandData;
use LibModels\Web\Product\SearchData;
use Api\Yohobuy;
use Api\Sign;
use Configs\ChannelConfig;
use Index\HomeModel;
/**
* 搜索辅助类
... ... @@ -73,8 +74,8 @@ class HelperSearch
$result = array();
self::$params = $_GET;
self::$options = $options;
unset(self::$params['/']);
unset(self::$params['page']);
// unset(self::$params['/']);
// unset(self::$params['page']);
self::$filter = isset($data['product']['filter']) ? $data['product']['filter'] : array();
//产品列表
$result['goods'] = isset($data['product']['product_list']) ? self::getProductList($data['product']['product_list'], $options['imgSize']) : array();
... ... @@ -121,8 +122,8 @@ class HelperSearch
}
}
//品牌店铺信息
if (isset($data['shop']) && !empty($data['shop'])) {
$result['shopEntry'] = self::shop($data['shop'], $data['sort']['sort']);
if (isset($data['shop']) && !empty($data['shop']) && isset($data['shopSort'])) {
$result['shopEntry'] = self::shop($data['shop'], $data['shopSort']);
}
//分页
if (isset($result['totalCount'])) {
... ... @@ -171,18 +172,20 @@ class HelperSearch
$goods_list[$k]['url'] = Helpers::getUrlBySkc($val['product_id'], $v['goods_id'], $val['cn_alphabet']);
//筛选符合颜色条件的封面图片
if (isset($params['color']) && $params['color'] == $v['color_id']) {
$val['default_images'] = Images::getImageUrl($v['images_url'],$imgSize[0],$imgSize[1]);
$val['default_images'] = $v['images_url'];
break;
}
}
if (!empty($val['default_images'])) {
$val['default_images'] = Images::getImageUrl($val['default_images'],$imgSize[0],$imgSize[1]);
}
$good = array(
'tags' => array(
'isNew' => $isNew,
'isLimit' => $isLimit
),
'url' => $goods_list[0]['url'],
'url' => self::fromPram($goods_list[0]['url'],++$key),
'thumb' => $val['default_images'],
'name' => $val['product_name'],
'salePrice' => $val['sales_price'],
... ... @@ -357,10 +360,14 @@ class HelperSearch
return $result;
}
/**
* 搜索页分类筛选条件
* @param $sort
* @return array
*/
public static function searchSort($sort)
{
$result = array();
$options = self::$options;
$params = self::$params;
foreach ($sort as $key => $val) {
$result[$key]['id'] = $val['sort_id'];
... ... @@ -411,98 +418,87 @@ class HelperSearch
$params = self::$params;
//url中的品牌ids
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
if (isset($filter['brand']) && !empty($filter['brand'])) {
$brand = $filter['brand'];
//已选中品牌数量
$existBrandNum = 0;
//已选中品牌标签名
$existName = '';
foreach ($brand as $key => $v) {
$selectBrandIds = $brandIds;
//品牌已被选中
if (in_array($v['id'], $brandIds)) {
$filterKey = array_search($v['id'], $selectBrandIds);
unset($selectBrandIds[$filterKey]);
$url = self::buildUrl(array_merge($params, array(
'brand' => implode(',', $selectBrandIds)
)));
if ($existBrandNum === 0) {
$existName .= $v['brand_name'].'、';
}
if ($existBrandNum === 1){
$existName .= substr($v['brand_name'], 0, 3).'...';
}
$existBrandNum++;
}
//该品牌未被选中
else {
$selectBrandIds[] = $v['id'];
$url = self::buildUrl(array_merge($params, array(
'brand' => implode(',', $selectBrandIds)
)));
}
$this_brand = array(
'id' => $v['id'],
'href' => $url,
'name' => $v['brand_name'],
'key' => strtolower($v['brand_name']),
'checked' => in_array($v['id'], $brandIds) ? true : false
);
if (is_numeric($v['brand_alif'])) {
$this_brand['index'] = '0-9';
//如果没有品牌返回空
if (!isset($filter['brand']) || empty($filter['brand'])) {
return array();
}
$brand = $filter['brand'];
//已选中品牌数量
$existBrandNum = 0;
//已选中品牌标签名
$existName = '';
foreach ($brand as $key => $v) {
$selectBrandIds = $brandIds;
//品牌已被选中
if (in_array($v['id'], $brandIds)) {
$filterKey = array_search($v['id'], $selectBrandIds);
unset($selectBrandIds[$filterKey]);
$url = self::buildUrl(array_merge($params, array(
'brand' => implode(',', $selectBrandIds)
)));
if ($existBrandNum === 0) {
$existName .= $v['brand_name'].'、';
}
else {
$this_brand['index'] = strtolower($v['brand_alif']);
if ($existBrandNum === 1){
$existName .= substr($v['brand_name'], 0, 3).'...';
}
$existBrandNum++;
}
//该品牌未被选中
else {
$selectBrandIds[] = $v['id'];
$url = self::buildUrl(array_merge($params, array(
'brand' => implode(',', $selectBrandIds)
)));
}
$this_brand = array(
'id' => $v['id'],
'href' => $url,
'name' => $v['brand_name'],
'key' => strtolower($v['brand_name']),
'checked' => in_array($v['id'], $brandIds) ? true : false
);
//默认品牌
if ($key < 10) {
//默认品牌
if (count($result['default']) < 10) {
$result['default'][] = $this_brand;
}
//品牌列表
$brandList[$v['brand_alif']][] = $this_brand;
$brandAll[$v['id']] = $v['brand_name'];
$result['default'][] = $this_brand;
}
//清空品牌参数
unset($params['brand']);
//设置选中
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
self::$selected['brand'] = array(
'name' => rtrim($existName, '、'),
'href' => self::buildUrl($params)
);
if (is_numeric($v['brand_alif'])) {
$this_brand['index'] = '0-9';
}
ksort($brandList);
//品牌列表排序, 添加品牌索引
$index_key = array();
foreach ($brandList as $key => $val) {
if ($key && !in_array($key, $index_key) && !is_numeric($key)) {
$index['index'] = strtolower(($key));
$index['name'] = $key;
$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;
}
}
else {
$this_brand['index'] = strtolower($v['brand_alif']);
}
$result['brandIndex'] = array_merge($result['brandIndex'], $index_key);
unset($brandList);
//品牌列表
$brandList[$this_brand['index']][] = $this_brand;
$brandAll[$v['id']] = $v['brand_name'];
}
//清空品牌参数
unset($params['brand']);
//设置选中
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
self::$selected['brand'] = array(
'name' => rtrim($existName, '、'),
'href' => self::buildUrl($params)
);
}
ksort($brandList);
//品牌列表排序
foreach ($brandList as $key => $val) {
$index['name'] = $key != '0-9' ? strtoupper($key) : '0~9';
$index['index'] = $key;
$result['brandsShow'] = array_merge_recursive($result['brandsShow'], $val);
$result['brandIndex'][] = $index;
}
unset($brandList);
//搜索页已选中,返回空
if (self::checkSearch('brand')) {
return array();
}
//品牌数量小于等于10,隐藏更多按钮
if (count($result['brandsShow']) < 11) {
$result['hideMore'] = true;
}
// print_r($result); exit;
$result['showMulti'] = count($result['brandsShow']) > 1 ? true :false;
$result['showMore'] = count($result['brandsShow']) > 10 ? true :false;
return $result;
}
/**
... ... @@ -598,25 +594,14 @@ class HelperSearch
}
$result = array();
//设置已选中价格
if (!empty($priceId) && isset($filter['price'][$priceId])) {
if (!empty($priceId)) {
$price = explode(',' ,$priceId);
$customName = self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$price[0] . '-' . (int)$price[1];
$name = isset($filter['price'][$priceId]) ? $filter['price'][$priceId] : $customName;
self::$selected['price'] = array(
'name' => $filter['price'][$priceId],
'name' => $name,
'href' => self::buildUrl($params)
);
}else{
$price = explode(',', $priceId);
if (count($price) == 2) {
if (!$price[0]) {
$price[0] = 0;
}
if (!$price[1]) {
$price[1] = 99999;
}
self::$selected['price'] = array(
'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$price[0] . '-' . (int)$price[1],
'href' => self::buildurl($params)
);
}
}
if (self::checkSearch('price')) {
return array();
... ... @@ -670,6 +655,7 @@ class HelperSearch
*/
public static function style($filter)
{
$data = array();
$params = self::$params;
$styleIds = isset($params['style']) && !empty($params['style']) ? explode(',', $params['style']) : array();
if (isset($params['style'])) {
... ... @@ -718,12 +704,14 @@ class HelperSearch
'href' => self::buildUrl($params)
);
}
$data[0] = array(
'attr' => 'style',
'name' => '风格',
'showMulti' => true,
'sub' => $result
);
if ($result) {
$data[0] = array(
'attr' => 'style',
'name' => '风格',
'showMulti' => count($result) > 1 ? true : false,
'sub' => $result
);
}
return $data;
}
/**
... ... @@ -815,7 +803,7 @@ class HelperSearch
/**
* 是否新品
*/
public static function isnew()
public static function isNew()
{
$params = self::$params;
$selected = '';
... ... @@ -1116,7 +1104,7 @@ class HelperSearch
//组织静态资源数据格式
public static function getNodeContent($code)
{
$nodeContent = BrandData::getByNodeContent($code);
$nodeContent = BrandData::getByNodeContent($code);//TODO异步
if (isset($nodeContent['code']) && $nodeContent['code'] === 200) {
$result = array();
... ... @@ -1210,114 +1198,6 @@ class HelperSearch
}
/**
* 并行调接口url获取(搜索产品数据)
* @param
*/
public static function getProductUrl($condition)
{
// 排序数据映射表
$orderMaps = array(
's_t_desc' => 'shelve_time:desc',
's_t_asc' => 'shelve_time:asc',
's_p_asc' => 'sales_price:asc',
's_p_desc' => 'sales_price:desc',
'p_d_desc' => 'discount:desc',
'p_d_asc' => 'discount:asc',
'skn_desc' => 'product_skn:desc',
'skn_asc' => 'product_skn:asc',
'activities_desc' => 'activities.order_by:desc',
'activities_asc' => 'activities.order_by:asc',
's_n_asc' => 'sales_num:asc',
's_n_desc' => 'sales_num:desc',
'activities_id_desc' => 'activities.activity_id:desc',
'activities_id_asc' => 'activities.activity_id:asc',
);
$param = array();
$param['status'] = 1; // 是否上架,1表示在架,2表示不在
$param['sales'] = 'Y'; // 只搜索销售的产品
$param['stocknumber'] = 1; // 过滤掉已售罄的商品
if (!isset($condition['order'])) {
$param['order'] = $orderMaps['s_t_desc'];
} else {
$param['order'] = $orderMaps[$condition['order']];
}
if (!isset($condition['page'])) {
$param['page'] = 1;
}
if(isset($condition['viewNum'])) {
$param['viewNum'] = $condition['viewNum'];
} else if (!isset($condition['limit'])) {
$param['viewNum'] = 60;
} else {
$param['viewNum'] = $condition['limit'];
unset($condition['limit']);
}
if (!empty($condition)) {
$param += $condition;
}
return Yohobuy::httpBuildQuery(SearchData::getUrl(), $param);
}
/**
* 并行调接口url获取(产品分类)
* @param
*/
public static function getClassesUrl($condition)
{
$condition['sales'] = 'Y'; //在销售商品分类
$condition['status'] = 1; //上架商品分类
$condition['stocknumber'] = 1; //过滤掉已售罄
return Yohobuy::httpBuildQuery(SearchData::getUrl('sort'), $condition);
}
/**
* 并行调接口url获取(获取折扣区间)
* @param
*/
public static function getDiscountUrl($param = array())
{
return Yohobuy::httpBuildQuery(SearchData::getUrl('discount'), $param);
}
/**
* 并行调接口url获取(获取最新上架)
*/
public static function getRecentShelveUrl($param = array())
{
return Yohobuy::httpBuildQuery(SearchData::getUrl('recent'), $param);
}
/**
* 并行调接口url获取(获取品牌数据)
*/
public static function getBrandUrl($customOptions = array())
{
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = $customOptions['brandId'];
$param['uid'] = $customOptions['uid'];
$param['method'] = 'app.brand.getBrandIntro';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
}
/**
* 获取品牌店铺接口地址
* @param $param
* @return string
*/
public static function getShopUrl($param)
{
return Yohobuy::httpBuildQuery(SearchData::getUrl('shop'), $param);
}
/**
* 获取品牌首页banner条
*
* @return array 品牌banner条数据
... ... @@ -1380,7 +1260,7 @@ class HelperSearch
//排序方式
$result['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount());
//特殊:新品、特价、限量
$result['checks'] = array(self::isnew(),self::specialoffer(),self::limited());
$result['checks'] = array(self::isNew(),self::specialoffer(),self::limited());
//每行显示5个产品
$result['fivePerLine'] = true;
//每行显示6个产品
... ... @@ -1394,4 +1274,27 @@ class HelperSearch
$result['nextHref'] = ($next = self::next(self::$pageTotal, self::$filter)) ? $next['href'] : '';
return $result;
}
/**
* 商品链接from参数
* @param $url
* @param $position
* @param bool $abEnabled
* @return string
*/
public static function fromPram($url, $position, $abEnabled = false)
{
$itemFrom = ChannelConfig::$itemFromStats;
$controller = isset(self::$options['controller']) ? strtolower(self::$options['controller']) : '';
$action = isset(self::$options['action']) ? strtolower(self::$options['action']) : '';
$itemIndex = $controller."_".$action;
//获取domain-module-$keyword_page_position{ab}
$ab = (isset($_COOKIE['ab_5']) && $abEnabled == true) ? '_'.$_COOKIE['ab_5'] : '';
$page = self::$page;
$keyword = isset(self::$options['query']) ? self::$options['query'] : '';
if (isset($itemFrom[$itemIndex])) {
$url .= "?from={$itemFrom[$itemIndex]['domain']}-{$itemFrom[$itemIndex]['module']}-{$keyword}_{$page}_{$position}{$ab}";
}
return $url;
}
}
... ...
... ... @@ -40,7 +40,7 @@ class ToolsController extends WebAction
);
$html = '';
foreach ($channels as $key => $val) {
$url = '/tools/cacheclear?key='.AuthCode::encode($val, 'yohobuy');
$url = '/tools/cacheclear?key='.urlencode(AuthCode::encode($val, 'yohobuy'));
$html.= sprintf('<li><a href="%s" target="_blank">清除%s缓存</a></li>',$url, $key);
}
echo $html;
... ...
... ... @@ -38,7 +38,7 @@ class IndexModel
$misort = isset($searchCondition['condition']['misort']) ? $searchCondition['condition']['misort'] : false;
$positionId = isset($searchCondition['options']['positionId']) ? $searchCondition['options']['positionId'] : '';
$gender = $searchCondition['condition']['gender'] == '2,3' ? 2 : 1;
if ($msort && $misort) {
if ($msort && $misort) {//TODO
$bannerData = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_INDEX_TBANNER, 'get', array($positionId,$msort,$misort,$gender,0,0,0,0,0));
if (isset($bannerData['code']) && $bannerData['code'] == '200') {
$banner = self::formatBanner($bannerData['data']);
... ...
... ... @@ -31,37 +31,37 @@ class NewModel
$data = HelperSearch::getList($result, $searchCondition['options']);
//new页面模拟数据
$data['newMain'] = array(
'banner' => 'http://img11.static.yhbimg.com/yhb-img01/2015/11/23/07/010a459d41b99a839cba9377532f1c19b2.jpg?imageView/3/w/970/h/200',
'date' => '12月16日',
'title' => '新品到着',
'brands' => array(
array(
'href' => '',
'logo' => 'http://img13.static.yhbimg.com/brandLogo/2012/02/28/15/02b2b5ded161ab31e2e097a327ed475052.jpg?imageView/2/w/170/h/120'
),
array(
'href' => '',
'logo' => 'http://img13.static.yhbimg.com/brandLogo/2012/11/09/09/023721f44182f775d79904010af421331e.jpg?imageView/2/w/170/h/120'
),
array(
'href' => '',
'logo' => 'http://img11.static.yhbimg.com/brandLogo/2012/12/13/17/01408fb72646c8f3fa59d870514f08a356.jpg?imageView/2/w/170/h/120'
),
array(
'href' => '',
'logo' => 'http://img13.static.yhbimg.com/brandLogo/2012/12/24/13/0265b45e37af697c5ba12d5415fb341f27.jpg?imageView/2/w/170/h/120'
),
array(
'href' => '',
'logo' => 'http://img11.static.yhbimg.com/brandLogo/2015/08/11/15/012d09a5cae187af1f6f3ed246b9b5a4fc.jpg?imageView/2/w/170/h/120'
),
array(
'href' => '',
'logo' => 'http://img11.static.yhbimg.com/brandLogo/2015/08/20/16/01047ffb3ca182871821d551af31ac2378.jpg?imageView/2/w/170/h/120'
)
)
);
// $data['newMain'] = array(
// 'banner' => 'http://img11.static.yhbimg.com/yhb-img01/2015/11/23/07/010a459d41b99a839cba9377532f1c19b2.jpg?imageView/3/w/970/h/200',
// 'date' => '12月16日',
// 'title' => '新品到着',
// 'brands' => array(
// array(
// 'href' => '',
// 'logo' => 'http://img13.static.yhbimg.com/brandLogo/2012/02/28/15/02b2b5ded161ab31e2e097a327ed475052.jpg?imageView/2/w/170/h/120'
// ),
// array(
// 'href' => '',
// 'logo' => 'http://img13.static.yhbimg.com/brandLogo/2012/11/09/09/023721f44182f775d79904010af421331e.jpg?imageView/2/w/170/h/120'
// ),
// array(
// 'href' => '',
// 'logo' => 'http://img11.static.yhbimg.com/brandLogo/2012/12/13/17/01408fb72646c8f3fa59d870514f08a356.jpg?imageView/2/w/170/h/120'
// ),
// array(
// 'href' => '',
// 'logo' => 'http://img13.static.yhbimg.com/brandLogo/2012/12/24/13/0265b45e37af697c5ba12d5415fb341f27.jpg?imageView/2/w/170/h/120'
// ),
// array(
// 'href' => '',
// 'logo' => 'http://img11.static.yhbimg.com/brandLogo/2015/08/11/15/012d09a5cae187af1f6f3ed246b9b5a4fc.jpg?imageView/2/w/170/h/120'
// ),
// array(
// 'href' => '',
// 'logo' => 'http://img11.static.yhbimg.com/brandLogo/2015/08/20/16/01047ffb3ca182871821d551af31ac2378.jpg?imageView/2/w/170/h/120'
// )
// )
// );
return $data;
}
... ...
... ... @@ -145,11 +145,11 @@ class SearchModel
$urlList = array();
$searchCondition = self::searchCondition($customCondition, $customOptions);
// 组合搜索商品url
$urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']);
$urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
// 组合搜索分类url
$urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['sortCondition']);
$urlList['sort'] = SearchData::getClassesUrl($searchCondition['sortCondition']);
// 组合搜索折扣区间url
$urlList['discount'] = HelperSearch::getDiscountUrl($searchCondition['condition']);
$urlList['discount'] = SearchData::getDiscountUrl($searchCondition['condition']);
$result = Yohobuy::getMulti($urlList, array(), true);
// 组织模板数据
... ... @@ -167,40 +167,48 @@ 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;
// }
// }
if (USE_CACHE) {
$key = CacheConfig::KEY_WEB_PRODUCT_SEARCH_DATA;
if (!empty($searchCondition['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']);
$urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
// 组合搜索分类url
$urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['sortCondition']);
$urlList['sort'] = SearchData::getClassesUrl($searchCondition['sortCondition']);
// 组合搜索店铺url
if (isset($searchCondition['condition']['query'])) {
$param['keyword'] = $searchCondition['condition']['query'];
$urlList['shop'] = HelperSearch::getShopUrl($param);
$urlList['shop'] = SearchData::getShopUrl($param);
}
$data = Yohobuy::getMulti($urlList, array(), true);
//获取品牌商品分类
if (isset($data['shop']) && !empty($data['shop'])) {
$shopSortParam['brand'] = $data['shop']['id'];
$shopSort = SearchData::getClassesData($shopSortParam);
if (isset($shopSort['code']) && $shopSort['code'] == 200) {
$data['shopSort'] = $shopSort['data']['sort'];
}
}
// 组织模板数据
$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分钟
// }
// }
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result, 1800); // 缓存30分钟
}
}
return $result;
}
/**
... ...
... ... @@ -19,7 +19,7 @@ class IndexController extends WebAction
}
//根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页
$fields = 'id,brand_name,brand_name_cn,brand_name_en,brand_domain,brand_alif,brand_banner,brand_ico,static_content_code';
$result = BrandsModel::getBrandByDomain($domain, $fields);
$result = BrandsModel::getBrandByDomain($domain, $fields);//TODO
if (!$result) {
$this->go(SITE_MAIN);
}
... ... @@ -32,8 +32,7 @@ class IndexController extends WebAction
$condition['brand'] = isset($result['brandId']) ? $result['brandId'] : '';
//品牌系列参数
$folderId = $this->get('folder_id');
$condition['folder_id'] = $folderId;
$condition['folder_id'] = $this->get('folder_id');
//$options参数数组
$options = array();
... ... @@ -56,7 +55,7 @@ class IndexController extends WebAction
'searchListPage' => true,
'list' => $data
);
//TODO
$this->setWebNavHeader();
//渲染模板
$this->_view->display('list',$data);
... ... @@ -73,7 +72,7 @@ class IndexController extends WebAction
$uid = $this->getUid();
//根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页
//根据品牌域名获取品牌id(同时判断品牌域名是否有效),无效跳转首页TODO
$fields = 'id,brand_name,brand_name_cn,brand_banner,brand_ico,brand_intro';
$result = BrandsModel::getBrandByDomain($domain, $fields);
if (!$result) {
... ... @@ -113,7 +112,7 @@ class IndexController extends WebAction
if (!$this->isAjax()) {
return;
}
$uid = $this->post('uid');
//$uid = $this->post('uid');TODO
$brandId = $this->post('brandId');
if ($uid && $brandId) {
... ... @@ -121,7 +120,7 @@ class IndexController extends WebAction
$result = FavoriteData::changeFavoriteBrand($uid, $brandId);
if (isset($result['code']) && $result['code'] == 200) {
$this ->echoJson($result);
}
}//TODO
}
}
... ...
... ... @@ -13,7 +13,7 @@ class ListController extends WebAction
$options = array(
'positionId' => $positionId,
'reviewNum' => 6,
'controller' => $this->_request->controller,
'controller' => $this->_request->controller,//TODO
'action' => $this->_request->action
);
... ... @@ -57,6 +57,9 @@ class ListController extends WebAction
*/
public function saleAction()
{
$options['controller'] = $this->_request->controller;
$options['action'] = $this->_request->action;
$options['reviewNum'] = 6;
$condition = array();
$option = array(
'controller' => 'list',
... ... @@ -83,7 +86,7 @@ class ListController extends WebAction
if (!$this->isAjax()) {
return;
}
$product_skn = $this->post('skn');
$product_skn = $this->post('skn');//TODO
$uid = $this->getUid();
if (!$product_skn) {
... ... @@ -115,7 +118,7 @@ class ListController extends WebAction
}
}
$options['isFavorite'] = $isFavorite;
SearchModel::getProductPic($product_skn, $options);
SearchModel::getProductPic($product_skn, $options);//TODO
}
/**
... ... @@ -134,7 +137,7 @@ class ListController extends WebAction
do {
if (!$product_skn && !$uid) {
break;
break;//TODO
}
if ($isFavorite) {
$result = FavoriteData::delUidProductFav($uid, $product_skn);
... ...
... ... @@ -14,18 +14,21 @@ class SaleController extends WebAction
{
//获取专区ID
$specialsaleId = $this->get('specialsale_id');
$specialInfo = SaleData::getSpecial($specialsaleId);
if(isset($specialInfo['data'])) {
$special = $specialInfo['data'];
} else {
$special = array();
}
//获取促销ID
$promotion = $this->get('promotion');
//专区ID和促销ID都为空时,跳转到主页
if (empty($specialsaleId) && empty($promotion)) {
$this->go(SITE_MAIN);
}
$specialInfo = SaleData::getSpecial($specialsaleId);
if(isset($specialInfo['data'])) {
$special = $specialInfo['data'];
} else {
$special = array();
}
$condition = array();
//传品牌ID参数
... ...
... ... @@ -5,13 +5,19 @@ class SearchController extends WebAction
{
public function indexAction()
{
//当前控制器
$options['controller'] = $this->_request->controller;
$options['action'] = $this->_request->action;
//浏览记录数
$options['reviewNum'] = 7;
$searchData = SearchModel::searchData(array(),$options);
$data = array(
//初始化js
'searchListPage' => true,
'search' => $searchData
);
// $this->setTitle();
// $this->setTitle();
$this->setWebNavHeader();
$this->_view->display('search', $data);
}
... ...