Authored by 周少峰

Merge branch 'feature/addShopCategory'

... ... @@ -170,7 +170,7 @@ class SearchData
$param['viewNum'] = $condition['limit'];
unset($condition['limit']);
}
if (!empty($condition)) {
if (!empty($condition)) {
$param += $condition;
}
if (isset($param['age_level'])) {
... ... @@ -196,4 +196,23 @@ class SearchData
}
return $result;
}
public static function getFilter($condition)
{
$result = array();
$param = Yohobuy::param();
$param += $condition;
if (isset($param['filter_poolId']) && !empty($param['filter_poolId'])) {
$param['productPool'] = $param['filter_poolId'];
unset($param['filter_poolId']);
}
$param['method'] = 'app.search.pool';
$param['client_secret'] = Sign::getSign($param);
$data = Yohobuy::get(API_URL, $param);
if (!empty($data['data'])) {
$result = $data;
}
return $result;
}
}
... ...
... ... @@ -19,6 +19,49 @@ class ShopProcess
private static $single = false;
/**
* 修改资源位的链接
* @param $val
* @param $shopId
* @return string
*/
private static function modifyWapUrl($val, $shopId)
{
if (isset($val['linkType']) && $val['linkType'] == 1) {
return Helpers::url('', array('filter_poolId' => $val['categoryId'],
'title' => $val['categoryName']), 'search');
} else {
if (isset($val['url'])) {
return $val['url'];
} else {
return '';
}
}
}
/**
* 修改资源位的链接
* @param $val
* @param $shopId
* @return string
*/
private static function modifyAppUrl($val, $shopId)
{
if (isset($val['linkType']) && $val['linkType'] == 1) {
return Helpers::url('/search/list') . sprintf('?openby:yohobuy={"action":"go.poollist","params":{"shop_id":"%s","title":"%s","productPool":"%s"}}',
$shopId . '', $val['categoryName'] . '', $val['categoryId'] . '', '');
} else {
if (isset($val['url'])) {
return $val['url'];
} else {
return '';
}
}
}
/**
* 组织店铺页面数据
* @param array $data 接口返回的店铺页所需数据
* @param int $shopId 店铺id
... ... @@ -34,7 +77,7 @@ class ShopProcess
if (empty($val) || !is_callable("self::$key")) {
continue;
}
self::$key($val);
self::$key($val, $shopId, $appVersion);
}
if (self::$single) {
self::$shopData['favId'] = self::$shopData['shopId'];
... ... @@ -87,16 +130,56 @@ class ShopProcess
* @param array $data
* @author sefon 2016-4-26 22:04:04
*/
private static function decorator($data)
private static function decorator($data, $shopId, $appVersion)
{
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['list']) || empty($data['data']['list'])) {
return;
}
if (empty($appVersion)) {
$modifyUrl = function ($item, $shopid) {
return self::modifyWapUrl($item, $shopid);
};
} else {
$modifyUrl = function ($item, $shopid) {
return self::modifyAppUrl($item, $shopid);
};
}
foreach ($data['data']['list'] as $val) {
if (empty($val['resource_data']) || !is_callable("self::$val[resource_name]")) {
continue;
}
self::$val['resource_name'](json_decode($val['resource_data'], true));
$json = json_decode($val['resource_data'], true);
foreach ($json as &$val2) {
$url = $modifyUrl($val2, $shopId);
if (!empty($url)) {
$val2['url'] = $url;
}
if (isset($val2['data']) && is_array($val2['data'])) {
foreach ($val2['data'] as &$v) {
$url2 = $modifyUrl($v, $shopId);
if (!empty($url2)) {
$v['url'] = $url2;
}
}
}
if (!isset($val2['data']) && is_array($val2)) {
foreach ($val2 as $k1 => &$v1) {
$url3 = $modifyUrl($v1, $shopId);
if (!empty($url3)) {
$v1['url'] = $url3;
}
}
}
}
self::$val['resource_name']($json);
}
}
... ...
... ... @@ -76,4 +76,8 @@
{{#if outlets}}
<input class="query-param" type="hidden" data-attr="outlets" value="{{outlets}}">
{{/if}}
{{#if filter_poolId}}
<input class="query-param" type="hidden" data-attr="filter_poolId" value="{{filter_poolId}}">
{{/if}}
\ No newline at end of file
... ...
... ... @@ -62,7 +62,8 @@ class SearchController extends AbstractAction
'channel' => FILTER_DEFAULT,
'outlets' => FILTER_DEFAULT,
'ageLevel' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
'p_d' => FILTER_DEFAULT,
'filter_poolId' => FILTER_DEFAULT), false);
if (isset($condition['shop_id'])) {
$condition['shopId'] = $condition['shop_id'];
}
... ... @@ -79,8 +80,10 @@ class SearchController extends AbstractAction
$condition['query'] = rawurlencode($condition['query']);
}
// 标识用户是否有输入搜索内容
$haveQuery = $query !== '';
$haveQuery = !empty($query);
// 标识用户搜的是不是一级品类
$isQueryFirstClass = false;
// 标识用户搜的是不是二级品类
... ... @@ -161,6 +164,12 @@ class SearchController extends AbstractAction
$data['goodListPage'] = true;
$data['goodList'] = $condition;
$data['query'] = $query;
// 用户自定义商品类目
if(isset($condition['filter_poolId'])){
$data['filter_poolId'] = rawurldecode($condition['filter_poolId']);
}
// 搜索是一级品类
if ($isQueryFirstClass) {
$this->setTitle('全部' . $query);
... ... @@ -252,7 +261,8 @@ class SearchController extends AbstractAction
'p_d' => FILTER_DEFAULT,
'outlets' => FILTER_DEFAULT,
'age_level' => FILTER_DEFAULT,
'page' => FILTER_VALIDATE_INT,), false);
'page' => FILTER_VALIDATE_INT,
'filter_poolId' => FILTER_DEFAULT), false);
if (!empty($condition['shop_id'])) {
$condition['shop'] = $condition['shop_id'];
... ... @@ -313,6 +323,11 @@ class SearchController extends AbstractAction
$condition['outlets'] = rawurldecode($condition['outlets']);
}
// 用户自定义商品类目
if(isset($condition['filter_poolId'])){
$condition['filter_poolId'] = rawurldecode($condition['filter_poolId']);
}
// 转换排序方式
$type = $this->get('type', '');
$order = $this->get('order', 0);
... ... @@ -401,7 +416,9 @@ class SearchController extends AbstractAction
'gender' => FILTER_DEFAULT,
'channel' => FILTER_DEFAULT,
'ageLevel' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
'p_d' => FILTER_DEFAULT,
'filter_poolId' => FILTER_DEFAULT
), false);
// 转义分类
if (isset($condition['sort'])) {
... ...
... ... @@ -103,6 +103,9 @@ class SearchModel
} else if (isset($condition['sort'])) {
$listData = ClassData::filterClassData($condition);
$exclude = 'group_sort';
}else if (isset($condition['filter_poolId'])){
$listData = SearchData::getFilter($condition);
$exclude = null;
} else {
$listData = SearchData::searchByCondition($condition);
$exclude = null;
... ...
... ... @@ -13,10 +13,12 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
define('USE_INTER_FACE_SHUNT', false);//分流开关
define('API_URL', 'http://testapi.yoho.cn:28078/');
define('SERVICE_URL', 'http://testservice.yoho.cn:28077/');
#dev环境
define('API_URL', 'http://dev-api.yohops.com:9999/');
define('SERVICE_URL', 'http://dev-service.yohops.com:9999/');
define('YOHOBUY_URL', 'http://www.yohobuy.com/');
define('SERVICE_NOTIFY', 'http://testservice.yoho.cn:28077/');
define('SERVICE_NOTIFY', 'http://test2.open.yohobuy.com/');
define('API_OLD', 'http://devservice.yoho.cn:58077/');
$application = new Application(APPLICATION_PATH . '/configs/application.developer.ini');
$application->bootstrap()->run();
... ...