Merge branch 'feature/addShopCategory'
Showing
6 changed files
with
139 additions
and
11 deletions
@@ -170,7 +170,7 @@ class SearchData | @@ -170,7 +170,7 @@ class SearchData | ||
170 | $param['viewNum'] = $condition['limit']; | 170 | $param['viewNum'] = $condition['limit']; |
171 | unset($condition['limit']); | 171 | unset($condition['limit']); |
172 | } | 172 | } |
173 | - if (!empty($condition)) { | 173 | + if (!empty($condition)) { |
174 | $param += $condition; | 174 | $param += $condition; |
175 | } | 175 | } |
176 | if (isset($param['age_level'])) { | 176 | if (isset($param['age_level'])) { |
@@ -196,4 +196,23 @@ class SearchData | @@ -196,4 +196,23 @@ class SearchData | ||
196 | } | 196 | } |
197 | return $result; | 197 | return $result; |
198 | } | 198 | } |
199 | + | ||
200 | + public static function getFilter($condition) | ||
201 | + { | ||
202 | + $result = array(); | ||
203 | + $param = Yohobuy::param(); | ||
204 | + $param += $condition; | ||
205 | + if (isset($param['filter_poolId']) && !empty($param['filter_poolId'])) { | ||
206 | + $param['productPool'] = $param['filter_poolId']; | ||
207 | + unset($param['filter_poolId']); | ||
208 | + } | ||
209 | + $param['method'] = 'app.search.pool'; | ||
210 | + $param['client_secret'] = Sign::getSign($param); | ||
211 | + $data = Yohobuy::get(API_URL, $param); | ||
212 | + if (!empty($data['data'])) { | ||
213 | + $result = $data; | ||
214 | + } | ||
215 | + return $result; | ||
216 | + } | ||
217 | + | ||
199 | } | 218 | } |
@@ -19,6 +19,49 @@ class ShopProcess | @@ -19,6 +19,49 @@ class ShopProcess | ||
19 | private static $single = false; | 19 | private static $single = false; |
20 | 20 | ||
21 | /** | 21 | /** |
22 | + * 修改资源位的链接 | ||
23 | + * @param $val | ||
24 | + * @param $shopId | ||
25 | + * @return string | ||
26 | + */ | ||
27 | + private static function modifyWapUrl($val, $shopId) | ||
28 | + { | ||
29 | + if (isset($val['linkType']) && $val['linkType'] == 1) { | ||
30 | + return Helpers::url('', array('filter_poolId' => $val['categoryId'], | ||
31 | + 'title' => $val['categoryName']), 'search'); | ||
32 | + } else { | ||
33 | + | ||
34 | + if (isset($val['url'])) { | ||
35 | + return $val['url']; | ||
36 | + } else { | ||
37 | + return ''; | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * 修改资源位的链接 | ||
44 | + * @param $val | ||
45 | + * @param $shopId | ||
46 | + * @return string | ||
47 | + */ | ||
48 | + private static function modifyAppUrl($val, $shopId) | ||
49 | + { | ||
50 | + if (isset($val['linkType']) && $val['linkType'] == 1) { | ||
51 | + return Helpers::url('/search/list') . sprintf('?openby:yohobuy={"action":"go.poollist","params":{"shop_id":"%s","title":"%s","productPool":"%s"}}', | ||
52 | + $shopId . '', $val['categoryName'] . '', $val['categoryId'] . '', ''); | ||
53 | + } else { | ||
54 | + | ||
55 | + if (isset($val['url'])) { | ||
56 | + return $val['url']; | ||
57 | + } else { | ||
58 | + return ''; | ||
59 | + } | ||
60 | + } | ||
61 | + } | ||
62 | + | ||
63 | + | ||
64 | + /** | ||
22 | * 组织店铺页面数据 | 65 | * 组织店铺页面数据 |
23 | * @param array $data 接口返回的店铺页所需数据 | 66 | * @param array $data 接口返回的店铺页所需数据 |
24 | * @param int $shopId 店铺id | 67 | * @param int $shopId 店铺id |
@@ -34,7 +77,7 @@ class ShopProcess | @@ -34,7 +77,7 @@ class ShopProcess | ||
34 | if (empty($val) || !is_callable("self::$key")) { | 77 | if (empty($val) || !is_callable("self::$key")) { |
35 | continue; | 78 | continue; |
36 | } | 79 | } |
37 | - self::$key($val); | 80 | + self::$key($val, $shopId, $appVersion); |
38 | } | 81 | } |
39 | if (self::$single) { | 82 | if (self::$single) { |
40 | self::$shopData['favId'] = self::$shopData['shopId']; | 83 | self::$shopData['favId'] = self::$shopData['shopId']; |
@@ -87,16 +130,56 @@ class ShopProcess | @@ -87,16 +130,56 @@ class ShopProcess | ||
87 | * @param array $data | 130 | * @param array $data |
88 | * @author sefon 2016-4-26 22:04:04 | 131 | * @author sefon 2016-4-26 22:04:04 |
89 | */ | 132 | */ |
90 | - private static function decorator($data) | 133 | + private static function decorator($data, $shopId, $appVersion) |
91 | { | 134 | { |
92 | if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['list']) || empty($data['data']['list'])) { | 135 | if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['list']) || empty($data['data']['list'])) { |
93 | return; | 136 | return; |
94 | } | 137 | } |
138 | + | ||
139 | + if (empty($appVersion)) { | ||
140 | + $modifyUrl = function ($item, $shopid) { | ||
141 | + return self::modifyWapUrl($item, $shopid); | ||
142 | + }; | ||
143 | + } else { | ||
144 | + $modifyUrl = function ($item, $shopid) { | ||
145 | + return self::modifyAppUrl($item, $shopid); | ||
146 | + }; | ||
147 | + } | ||
148 | + | ||
95 | foreach ($data['data']['list'] as $val) { | 149 | foreach ($data['data']['list'] as $val) { |
96 | if (empty($val['resource_data']) || !is_callable("self::$val[resource_name]")) { | 150 | if (empty($val['resource_data']) || !is_callable("self::$val[resource_name]")) { |
97 | continue; | 151 | continue; |
98 | } | 152 | } |
99 | - self::$val['resource_name'](json_decode($val['resource_data'], true)); | 153 | + |
154 | + $json = json_decode($val['resource_data'], true); | ||
155 | + | ||
156 | + foreach ($json as &$val2) { | ||
157 | + $url = $modifyUrl($val2, $shopId); | ||
158 | + | ||
159 | + if (!empty($url)) { | ||
160 | + $val2['url'] = $url; | ||
161 | + } | ||
162 | + | ||
163 | + if (isset($val2['data']) && is_array($val2['data'])) { | ||
164 | + foreach ($val2['data'] as &$v) { | ||
165 | + $url2 = $modifyUrl($v, $shopId); | ||
166 | + if (!empty($url2)) { | ||
167 | + $v['url'] = $url2; | ||
168 | + } | ||
169 | + } | ||
170 | + } | ||
171 | + | ||
172 | + if (!isset($val2['data']) && is_array($val2)) { | ||
173 | + foreach ($val2 as $k1 => &$v1) { | ||
174 | + $url3 = $modifyUrl($v1, $shopId); | ||
175 | + if (!empty($url3)) { | ||
176 | + $v1['url'] = $url3; | ||
177 | + } | ||
178 | + } | ||
179 | + } | ||
180 | + } | ||
181 | + | ||
182 | + self::$val['resource_name']($json); | ||
100 | } | 183 | } |
101 | } | 184 | } |
102 | 185 |
@@ -76,4 +76,8 @@ | @@ -76,4 +76,8 @@ | ||
76 | 76 | ||
77 | {{#if outlets}} | 77 | {{#if outlets}} |
78 | <input class="query-param" type="hidden" data-attr="outlets" value="{{outlets}}"> | 78 | <input class="query-param" type="hidden" data-attr="outlets" value="{{outlets}}"> |
79 | +{{/if}} | ||
80 | + | ||
81 | +{{#if filter_poolId}} | ||
82 | + <input class="query-param" type="hidden" data-attr="filter_poolId" value="{{filter_poolId}}"> | ||
79 | {{/if}} | 83 | {{/if}} |
@@ -62,7 +62,8 @@ class SearchController extends AbstractAction | @@ -62,7 +62,8 @@ class SearchController extends AbstractAction | ||
62 | 'channel' => FILTER_DEFAULT, | 62 | 'channel' => FILTER_DEFAULT, |
63 | 'outlets' => FILTER_DEFAULT, | 63 | 'outlets' => FILTER_DEFAULT, |
64 | 'ageLevel' => FILTER_DEFAULT, | 64 | 'ageLevel' => FILTER_DEFAULT, |
65 | - 'p_d' => FILTER_DEFAULT,), false); | 65 | + 'p_d' => FILTER_DEFAULT, |
66 | + 'filter_poolId' => FILTER_DEFAULT), false); | ||
66 | if (isset($condition['shop_id'])) { | 67 | if (isset($condition['shop_id'])) { |
67 | $condition['shopId'] = $condition['shop_id']; | 68 | $condition['shopId'] = $condition['shop_id']; |
68 | } | 69 | } |
@@ -79,8 +80,10 @@ class SearchController extends AbstractAction | @@ -79,8 +80,10 @@ class SearchController extends AbstractAction | ||
79 | $condition['query'] = rawurlencode($condition['query']); | 80 | $condition['query'] = rawurlencode($condition['query']); |
80 | } | 81 | } |
81 | 82 | ||
83 | + | ||
84 | + | ||
82 | // 标识用户是否有输入搜索内容 | 85 | // 标识用户是否有输入搜索内容 |
83 | - $haveQuery = $query !== ''; | 86 | + $haveQuery = !empty($query); |
84 | // 标识用户搜的是不是一级品类 | 87 | // 标识用户搜的是不是一级品类 |
85 | $isQueryFirstClass = false; | 88 | $isQueryFirstClass = false; |
86 | // 标识用户搜的是不是二级品类 | 89 | // 标识用户搜的是不是二级品类 |
@@ -161,6 +164,12 @@ class SearchController extends AbstractAction | @@ -161,6 +164,12 @@ class SearchController extends AbstractAction | ||
161 | $data['goodListPage'] = true; | 164 | $data['goodListPage'] = true; |
162 | $data['goodList'] = $condition; | 165 | $data['goodList'] = $condition; |
163 | $data['query'] = $query; | 166 | $data['query'] = $query; |
167 | + | ||
168 | + // 用户自定义商品类目 | ||
169 | + if(isset($condition['filter_poolId'])){ | ||
170 | + $data['filter_poolId'] = rawurldecode($condition['filter_poolId']); | ||
171 | + } | ||
172 | + | ||
164 | // 搜索是一级品类 | 173 | // 搜索是一级品类 |
165 | if ($isQueryFirstClass) { | 174 | if ($isQueryFirstClass) { |
166 | $this->setTitle('全部' . $query); | 175 | $this->setTitle('全部' . $query); |
@@ -252,7 +261,8 @@ class SearchController extends AbstractAction | @@ -252,7 +261,8 @@ class SearchController extends AbstractAction | ||
252 | 'p_d' => FILTER_DEFAULT, | 261 | 'p_d' => FILTER_DEFAULT, |
253 | 'outlets' => FILTER_DEFAULT, | 262 | 'outlets' => FILTER_DEFAULT, |
254 | 'age_level' => FILTER_DEFAULT, | 263 | 'age_level' => FILTER_DEFAULT, |
255 | - 'page' => FILTER_VALIDATE_INT,), false); | 264 | + 'page' => FILTER_VALIDATE_INT, |
265 | + 'filter_poolId' => FILTER_DEFAULT), false); | ||
256 | 266 | ||
257 | if (!empty($condition['shop_id'])) { | 267 | if (!empty($condition['shop_id'])) { |
258 | $condition['shop'] = $condition['shop_id']; | 268 | $condition['shop'] = $condition['shop_id']; |
@@ -313,6 +323,11 @@ class SearchController extends AbstractAction | @@ -313,6 +323,11 @@ class SearchController extends AbstractAction | ||
313 | $condition['outlets'] = rawurldecode($condition['outlets']); | 323 | $condition['outlets'] = rawurldecode($condition['outlets']); |
314 | } | 324 | } |
315 | 325 | ||
326 | + // 用户自定义商品类目 | ||
327 | + if(isset($condition['filter_poolId'])){ | ||
328 | + $condition['filter_poolId'] = rawurldecode($condition['filter_poolId']); | ||
329 | + } | ||
330 | + | ||
316 | // 转换排序方式 | 331 | // 转换排序方式 |
317 | $type = $this->get('type', ''); | 332 | $type = $this->get('type', ''); |
318 | $order = $this->get('order', 0); | 333 | $order = $this->get('order', 0); |
@@ -401,7 +416,9 @@ class SearchController extends AbstractAction | @@ -401,7 +416,9 @@ class SearchController extends AbstractAction | ||
401 | 'gender' => FILTER_DEFAULT, | 416 | 'gender' => FILTER_DEFAULT, |
402 | 'channel' => FILTER_DEFAULT, | 417 | 'channel' => FILTER_DEFAULT, |
403 | 'ageLevel' => FILTER_DEFAULT, | 418 | 'ageLevel' => FILTER_DEFAULT, |
404 | - 'p_d' => FILTER_DEFAULT,), false); | 419 | + 'p_d' => FILTER_DEFAULT, |
420 | + 'filter_poolId' => FILTER_DEFAULT | ||
421 | + ), false); | ||
405 | 422 | ||
406 | // 转义分类 | 423 | // 转义分类 |
407 | if (isset($condition['sort'])) { | 424 | if (isset($condition['sort'])) { |
@@ -103,6 +103,9 @@ class SearchModel | @@ -103,6 +103,9 @@ class SearchModel | ||
103 | } else if (isset($condition['sort'])) { | 103 | } else if (isset($condition['sort'])) { |
104 | $listData = ClassData::filterClassData($condition); | 104 | $listData = ClassData::filterClassData($condition); |
105 | $exclude = 'group_sort'; | 105 | $exclude = 'group_sort'; |
106 | + }else if (isset($condition['filter_poolId'])){ | ||
107 | + $listData = SearchData::getFilter($condition); | ||
108 | + $exclude = null; | ||
106 | } else { | 109 | } else { |
107 | $listData = SearchData::searchByCondition($condition); | 110 | $listData = SearchData::searchByCondition($condition); |
108 | $exclude = null; | 111 | $exclude = null; |
@@ -13,10 +13,12 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer'); | @@ -13,10 +13,12 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer'); | ||
13 | 13 | ||
14 | define('USE_INTER_FACE_SHUNT', false);//分流开关 | 14 | define('USE_INTER_FACE_SHUNT', false);//分流开关 |
15 | 15 | ||
16 | -define('API_URL', 'http://testapi.yoho.cn:28078/'); | ||
17 | -define('SERVICE_URL', 'http://testservice.yoho.cn:28077/'); | 16 | +#dev环境 |
17 | +define('API_URL', 'http://dev-api.yohops.com:9999/'); | ||
18 | +define('SERVICE_URL', 'http://dev-service.yohops.com:9999/'); | ||
18 | define('YOHOBUY_URL', 'http://www.yohobuy.com/'); | 19 | define('YOHOBUY_URL', 'http://www.yohobuy.com/'); |
19 | -define('SERVICE_NOTIFY', 'http://testservice.yoho.cn:28077/'); | 20 | +define('SERVICE_NOTIFY', 'http://test2.open.yohobuy.com/'); |
21 | +define('API_OLD', 'http://devservice.yoho.cn:58077/'); | ||
20 | 22 | ||
21 | $application = new Application(APPLICATION_PATH . '/configs/application.developer.ini'); | 23 | $application = new Application(APPLICATION_PATH . '/configs/application.developer.ini'); |
22 | $application->bootstrap()->run(); | 24 | $application->bootstrap()->run(); |
-
Please register or login to post a comment