|
@@ -4,6 +4,7 @@ namespace Plugin; |
|
@@ -4,6 +4,7 @@ namespace Plugin; |
4
|
|
4
|
|
5
|
use Plugin\Paging;
|
5
|
use Plugin\Paging;
|
6
|
use LibModels\Web\Product\BrandData;
|
6
|
use LibModels\Web\Product\BrandData;
|
|
|
7
|
+use LibModels\Web\Product\SearchData;
|
7
|
use Api\Yohobuy;
|
8
|
use Api\Yohobuy;
|
8
|
use Api\Sign;
|
9
|
use Api\Sign;
|
9
|
/**
|
10
|
/**
|
|
@@ -90,7 +91,9 @@ class HelperSearch |
|
@@ -90,7 +91,9 @@ class HelperSearch |
90
|
//分页
|
91
|
//分页
|
91
|
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
|
92
|
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
|
92
|
//浏览记录
|
93
|
//浏览记录
|
93
|
- $result['latestWalk'] = array();
|
94
|
+ if ($options['reviewNum']) {
|
|
|
95
|
+ $result['latestWalk'] = $options['reviewNum'];
|
|
|
96
|
+ }
|
94
|
//选中条件
|
97
|
//选中条件
|
95
|
$result['filters']['checkedConditions'] = self::getSelected();
|
98
|
$result['filters']['checkedConditions'] = self::getSelected();
|
96
|
if (isset($options['controller']) && $options['controller'] == 'Search') {
|
99
|
if (isset($options['controller']) && $options['controller'] == 'Search') {
|
|
@@ -349,10 +352,6 @@ class HelperSearch |
|
@@ -349,10 +352,6 @@ class HelperSearch |
349
|
array(
|
352
|
array(
|
350
|
'index' => 'all',
|
353
|
'index' => 'all',
|
351
|
'name' => '全部'
|
354
|
'name' => '全部'
|
352
|
- ),
|
|
|
353
|
- array(
|
|
|
354
|
- 'index' => '0-9',
|
|
|
355
|
- 'name' => '0 ~ 9'
|
|
|
356
|
)
|
355
|
)
|
357
|
),
|
356
|
),
|
358
|
'brandsShow' => array()
|
357
|
'brandsShow' => array()
|
|
@@ -362,17 +361,29 @@ class HelperSearch |
|
@@ -362,17 +361,29 @@ class HelperSearch |
362
|
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
361
|
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
363
|
if (isset($filter['brand']) && !empty($filter['brand'])) {
|
362
|
if (isset($filter['brand']) && !empty($filter['brand'])) {
|
364
|
$brand = $filter['brand'];
|
363
|
$brand = $filter['brand'];
|
|
|
364
|
+// print_r($filter); exit;
|
|
|
365
|
+ //已选中品牌数量
|
|
|
366
|
+ $existBrandNum = 0;
|
|
|
367
|
+ //已选中品牌标签名
|
|
|
368
|
+ $existName = '';
|
365
|
foreach ($brand as $key => $v) {
|
369
|
foreach ($brand as $key => $v) {
|
366
|
$selectBrandIds = $brandIds;
|
370
|
$selectBrandIds = $brandIds;
|
367
|
- //品牌id在提交的参数中,构造url参数去除该品牌id
|
371
|
+ //品牌已被选中
|
368
|
if (in_array($v['id'], $brandIds)) {
|
372
|
if (in_array($v['id'], $brandIds)) {
|
369
|
$filterKey = array_search($v['id'], $selectBrandIds);
|
373
|
$filterKey = array_search($v['id'], $selectBrandIds);
|
370
|
unset($selectBrandIds[$filterKey]);
|
374
|
unset($selectBrandIds[$filterKey]);
|
371
|
$url = self::buildUrl(array_merge($params, array(
|
375
|
$url = self::buildUrl(array_merge($params, array(
|
372
|
'brand' => implode(',', $selectBrandIds)
|
376
|
'brand' => implode(',', $selectBrandIds)
|
373
|
)));
|
377
|
)));
|
|
|
378
|
+ if ($existBrandNum === 0) {
|
|
|
379
|
+ $existName .= $v['brand_name'].'、';
|
|
|
380
|
+ }
|
|
|
381
|
+ if ($existBrandNum === 1){
|
|
|
382
|
+ $existName .= substr($v['brand_name'], 0, 3).'...';
|
|
|
383
|
+ }
|
|
|
384
|
+ $existBrandNum++;
|
374
|
}
|
385
|
}
|
375
|
- //该品牌url参数中添加该品牌的id
|
386
|
+ //该品牌未被选中
|
376
|
else {
|
387
|
else {
|
377
|
$selectBrandIds[] = $v['id'];
|
388
|
$selectBrandIds[] = $v['id'];
|
378
|
$url = self::buildUrl(array_merge($params, array(
|
389
|
$url = self::buildUrl(array_merge($params, array(
|
|
@@ -402,25 +413,6 @@ class HelperSearch |
|
@@ -402,25 +413,6 @@ class HelperSearch |
402
|
}
|
413
|
}
|
403
|
//清空品牌参数
|
414
|
//清空品牌参数
|
404
|
unset($params['brand']);
|
415
|
unset($params['brand']);
|
405
|
- //设置已选中的品牌
|
|
|
406
|
- $existBrandNum = 0;
|
|
|
407
|
- $existName = '';
|
|
|
408
|
- foreach ($brandIds as $key => $val) {
|
|
|
409
|
- if (isset($brandAll[$val])) {
|
|
|
410
|
- $brandParam = $brandIds;
|
|
|
411
|
- unset($brandParam[$key]);
|
|
|
412
|
- if ($existBrandNum === 0) {
|
|
|
413
|
- $existName .= $brandAll[$val].'、';
|
|
|
414
|
- }
|
|
|
415
|
- if ($existBrandNum === 1){
|
|
|
416
|
- $existName .= substr($brandAll[$val], 0, 3).'...';
|
|
|
417
|
- }
|
|
|
418
|
- $existBrandNum++;
|
|
|
419
|
- }
|
|
|
420
|
- if ($existBrandNum > 1) {
|
|
|
421
|
- break;
|
|
|
422
|
- }
|
|
|
423
|
- }
|
|
|
424
|
//设置选中
|
416
|
//设置选中
|
425
|
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
|
417
|
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
|
426
|
self::$selected['brand'] = array(
|
418
|
self::$selected['brand'] = array(
|
|
@@ -454,6 +446,7 @@ class HelperSearch |
|
@@ -454,6 +446,7 @@ class HelperSearch |
454
|
if (count($result['brandsShow']) < 11) {
|
446
|
if (count($result['brandsShow']) < 11) {
|
455
|
$result['hideMore'] = true;
|
447
|
$result['hideMore'] = true;
|
456
|
}
|
448
|
}
|
|
|
449
|
+// print_r($result); exit;
|
457
|
return $result;
|
450
|
return $result;
|
458
|
}
|
451
|
}
|
459
|
/**
|
452
|
/**
|
|
@@ -1206,7 +1199,7 @@ class HelperSearch |
|
@@ -1206,7 +1199,7 @@ class HelperSearch |
1206
|
if (!empty($condition)) {
|
1199
|
if (!empty($condition)) {
|
1207
|
$param += $condition;
|
1200
|
$param += $condition;
|
1208
|
}
|
1201
|
}
|
1209
|
- return Yohobuy::httpBuildQuery(self::getUrl(), $param);
|
1202
|
+ return Yohobuy::httpBuildQuery(SearchData::getUrl(), $param);
|
1210
|
}
|
1203
|
}
|
1211
|
|
1204
|
|
1212
|
/**
|
1205
|
/**
|
|
@@ -1219,7 +1212,7 @@ class HelperSearch |
|
@@ -1219,7 +1212,7 @@ class HelperSearch |
1219
|
$condition['sales'] = 'Y'; //在销售商品分类
|
1212
|
$condition['sales'] = 'Y'; //在销售商品分类
|
1220
|
$condition['status'] = 1; //上架商品分类
|
1213
|
$condition['status'] = 1; //上架商品分类
|
1221
|
$condition['stocknumber'] = 1; //过滤掉已售罄
|
1214
|
$condition['stocknumber'] = 1; //过滤掉已售罄
|
1222
|
- return Yohobuy::httpBuildQuery(self::getUrl('sort'), $condition);
|
1215
|
+ return Yohobuy::httpBuildQuery(SearchData::getUrl('sort'), $condition);
|
1223
|
}
|
1216
|
}
|
1224
|
|
1217
|
|
1225
|
/**
|
1218
|
/**
|
|
@@ -1229,7 +1222,7 @@ class HelperSearch |
|
@@ -1229,7 +1222,7 @@ class HelperSearch |
1229
|
|
1222
|
|
1230
|
public static function getDiscountUrl($param = array())
|
1223
|
public static function getDiscountUrl($param = array())
|
1231
|
{
|
1224
|
{
|
1232
|
- return Yohobuy::httpBuildQuery(self::getUrl('discount'), $param);
|
1225
|
+ return Yohobuy::httpBuildQuery(SearchData::getUrl('discount'), $param);
|
1233
|
}
|
1226
|
}
|
1234
|
|
1227
|
|
1235
|
/**
|
1228
|
/**
|
|
@@ -1237,7 +1230,7 @@ class HelperSearch |
|
@@ -1237,7 +1230,7 @@ class HelperSearch |
1237
|
*/
|
1230
|
*/
|
1238
|
public static function getRecentShelveUrl($param = array())
|
1231
|
public static function getRecentShelveUrl($param = array())
|
1239
|
{
|
1232
|
{
|
1240
|
- return Yohobuy::httpBuildQuery(self::getUrl('recent'), $param);
|
1233
|
+ return Yohobuy::httpBuildQuery(SearchData::getUrl('recent'), $param);
|
1241
|
}
|
1234
|
}
|
1242
|
|
1235
|
|
1243
|
/**
|
1236
|
/**
|
|
@@ -1268,15 +1261,6 @@ class HelperSearch |
|
@@ -1268,15 +1261,6 @@ class HelperSearch |
1268
|
|
1261
|
|
1269
|
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
|
1262
|
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
|
1270
|
}
|
1263
|
}
|
1271
|
-
|
|
|
1272
|
-
|
|
|
1273
|
- /**
|
|
|
1274
|
- * 并行调接口url获取(获取用户浏览记录)
|
|
|
1275
|
- */
|
|
|
1276
|
-// public static function getReviewUrl($param = array())
|
|
|
1277
|
-// {
|
|
|
1278
|
-// return Yohobuy::httpBuildQuery(self::getUrl('review'), $param);
|
|
|
1279
|
-// }
|
|
|
1280
|
|
1264
|
|
1281
|
|
1265
|
|
1282
|
/**
|
1266
|
/**
|
|
@@ -1286,58 +1270,7 @@ class HelperSearch |
|
@@ -1286,58 +1270,7 @@ class HelperSearch |
1286
|
*/
|
1270
|
*/
|
1287
|
public static function getShopUrl($param)
|
1271
|
public static function getShopUrl($param)
|
1288
|
{
|
1272
|
{
|
1289
|
- return Yohobuy::httpBuildQuery(self::getUrl('shop'), $param);
|
|
|
1290
|
- }
|
|
|
1291
|
- /**
|
|
|
1292
|
- * 获取搜索的服务地址
|
|
|
1293
|
- *
|
|
|
1294
|
- * 备注:此处是根据环境来确定使用阿里云内网还是外网的URL
|
|
|
1295
|
- *
|
|
|
1296
|
- * @return string
|
|
|
1297
|
- */
|
|
|
1298
|
- private static function getUrl($type = 'search')
|
|
|
1299
|
- {
|
|
|
1300
|
- defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
|
|
|
1301
|
- switch (APPLICATION_ENV) {
|
|
|
1302
|
- case 'release':
|
|
|
1303
|
- if ($type == 'sort') {
|
|
|
1304
|
- return 'http://100.98.132.63/yohosearch/sortgroup.json';
|
|
|
1305
|
- }
|
|
|
1306
|
- elseif ($type == 'discount') {
|
|
|
1307
|
- return 'http://100.98.132.63/yohosearch/discount.json';
|
|
|
1308
|
- }
|
|
|
1309
|
- elseif ($type == 'recent') {
|
|
|
1310
|
- return 'http://100.98.132.63/yohosearch/recent.json';
|
|
|
1311
|
- }
|
|
|
1312
|
-// elseif ($type == 'review') {
|
|
|
1313
|
-//
|
|
|
1314
|
-// }
|
|
|
1315
|
- elseif ($type == 'shop') {
|
|
|
1316
|
- return 'http://100.98.132.63/yohosearch/shops.json';
|
|
|
1317
|
- }
|
|
|
1318
|
- return 'http://100.98.132.63/yohosearch/search.json';
|
|
|
1319
|
- case 'test':
|
|
|
1320
|
- case 'preview':
|
|
|
1321
|
- case 'developer':
|
|
|
1322
|
- default:
|
|
|
1323
|
- if ($type == 'sort') {
|
|
|
1324
|
- return 'http://101.200.31.165/yohosearch/sortgroup.json';
|
|
|
1325
|
- }
|
|
|
1326
|
- elseif ($type == 'discount') {
|
|
|
1327
|
- return 'http://101.200.31.165/yohosearch/discount.json';
|
|
|
1328
|
- }
|
|
|
1329
|
- elseif ($type == 'recent') {
|
|
|
1330
|
- return 'http://101.200.31.165/yohosearch/recent.json';
|
|
|
1331
|
- }
|
|
|
1332
|
-// elseif ($type == 'review') {
|
|
|
1333
|
-//
|
|
|
1334
|
-// }
|
|
|
1335
|
- elseif ($type == 'shop') {
|
|
|
1336
|
- return 'http://101.200.31.165/yohosearch/shops.json';
|
|
|
1337
|
- }
|
|
|
1338
|
-// return 'http://101.200.31.165/yohosearch/search.json';
|
|
|
1339
|
- return 'http://192.168.10.64:8080/yohosearch/search-once.json';
|
|
|
1340
|
- }
|
1273
|
+ return Yohobuy::httpBuildQuery(SearchData::getUrl('shop'), $param);
|
1341
|
}
|
1274
|
}
|
1342
|
|
1275
|
|
1343
|
/**
|
1276
|
/**
|