|
@@ -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
|
/**
|
|
@@ -89,6 +90,10 @@ class HelperSearch |
|
@@ -89,6 +90,10 @@ class HelperSearch |
89
|
$result['shopEntry'] = isset($data['shop']) && !empty($data['shop']) ? self::shop($data['shop'], $data['sort']['sort']) : array();
|
90
|
$result['shopEntry'] = isset($data['shop']) && !empty($data['shop']) ? self::shop($data['shop'], $data['sort']['sort']) : array();
|
90
|
//分页
|
91
|
//分页
|
91
|
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
|
92
|
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
|
|
|
93
|
+ //浏览记录
|
|
|
94
|
+ if (isset($options['reviewNum']) && !empty($options['reviewNum'])) {
|
|
|
95
|
+ $result['latestWalk'] = $options['reviewNum'];
|
|
|
96
|
+ }
|
92
|
//选中条件
|
97
|
//选中条件
|
93
|
$result['filters']['checkedConditions'] = self::getSelected();
|
98
|
$result['filters']['checkedConditions'] = self::getSelected();
|
94
|
if (isset($options['controller']) && $options['controller'] == 'Search') {
|
99
|
if (isset($options['controller']) && $options['controller'] == 'Search') {
|
|
@@ -134,7 +139,7 @@ class HelperSearch |
|
@@ -134,7 +139,7 @@ class HelperSearch |
134
|
if (!empty($val['default_images'])) {
|
139
|
if (!empty($val['default_images'])) {
|
135
|
$val['default_images'] = Images::getImageUrl($val['default_images'],$imgSize[0],$imgSize[1]);
|
140
|
$val['default_images'] = Images::getImageUrl($val['default_images'],$imgSize[0],$imgSize[1]);
|
136
|
}
|
141
|
}
|
137
|
- $goods[] = array(
|
142
|
+ $good = array(
|
138
|
'tags' => array(
|
143
|
'tags' => array(
|
139
|
'isNew' => $isNew,
|
144
|
'isNew' => $isNew,
|
140
|
'isLimit' => $isLimit
|
145
|
'isLimit' => $isLimit
|
|
@@ -143,12 +148,16 @@ class HelperSearch |
|
@@ -143,12 +148,16 @@ class HelperSearch |
143
|
'thumb' => $val['default_images'],
|
148
|
'thumb' => $val['default_images'],
|
144
|
'name' => $val['product_name'],
|
149
|
'name' => $val['product_name'],
|
145
|
'salePrice' => $val['sales_price'],
|
150
|
'salePrice' => $val['sales_price'],
|
146
|
- 'marketPrice' => $val['market_price'],
|
|
|
147
|
'isFew' => $isFew,
|
151
|
'isFew' => $isFew,
|
148
|
'skn' => $val['product_skn'],
|
152
|
'skn' => $val['product_skn'],
|
149
|
'showColBtn' => true,
|
153
|
'showColBtn' => true,
|
150
|
'coled' => true
|
154
|
'coled' => true
|
151
|
);
|
155
|
);
|
|
|
156
|
+ //市场价不等于售价时显示
|
|
|
157
|
+ if ($val['market_price'] != $val['sales_price']) {
|
|
|
158
|
+ $good['marketPrice'] = $val['market_price'];
|
|
|
159
|
+ }
|
|
|
160
|
+ $goods[] = $good;
|
152
|
}
|
161
|
}
|
153
|
return $goods;
|
162
|
return $goods;
|
154
|
}
|
163
|
}
|
|
@@ -343,10 +352,6 @@ class HelperSearch |
|
@@ -343,10 +352,6 @@ class HelperSearch |
343
|
array(
|
352
|
array(
|
344
|
'index' => 'all',
|
353
|
'index' => 'all',
|
345
|
'name' => '全部'
|
354
|
'name' => '全部'
|
346
|
- ),
|
|
|
347
|
- array(
|
|
|
348
|
- 'index' => '0-9',
|
|
|
349
|
- 'name' => '0 ~ 9'
|
|
|
350
|
)
|
355
|
)
|
351
|
),
|
356
|
),
|
352
|
'brandsShow' => array()
|
357
|
'brandsShow' => array()
|
|
@@ -356,17 +361,29 @@ class HelperSearch |
|
@@ -356,17 +361,29 @@ class HelperSearch |
356
|
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
361
|
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
357
|
if (isset($filter['brand']) && !empty($filter['brand'])) {
|
362
|
if (isset($filter['brand']) && !empty($filter['brand'])) {
|
358
|
$brand = $filter['brand'];
|
363
|
$brand = $filter['brand'];
|
|
|
364
|
+// print_r($filter); exit;
|
|
|
365
|
+ //已选中品牌数量
|
|
|
366
|
+ $existBrandNum = 0;
|
|
|
367
|
+ //已选中品牌标签名
|
|
|
368
|
+ $existName = '';
|
359
|
foreach ($brand as $key => $v) {
|
369
|
foreach ($brand as $key => $v) {
|
360
|
$selectBrandIds = $brandIds;
|
370
|
$selectBrandIds = $brandIds;
|
361
|
- //品牌id在提交的参数中,构造url参数去除该品牌id
|
371
|
+ //品牌已被选中
|
362
|
if (in_array($v['id'], $brandIds)) {
|
372
|
if (in_array($v['id'], $brandIds)) {
|
363
|
$filterKey = array_search($v['id'], $selectBrandIds);
|
373
|
$filterKey = array_search($v['id'], $selectBrandIds);
|
364
|
unset($selectBrandIds[$filterKey]);
|
374
|
unset($selectBrandIds[$filterKey]);
|
365
|
$url = self::buildUrl(array_merge($params, array(
|
375
|
$url = self::buildUrl(array_merge($params, array(
|
366
|
'brand' => implode(',', $selectBrandIds)
|
376
|
'brand' => implode(',', $selectBrandIds)
|
367
|
)));
|
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++;
|
368
|
}
|
385
|
}
|
369
|
- //该品牌url参数中添加该品牌的id
|
386
|
+ //该品牌未被选中
|
370
|
else {
|
387
|
else {
|
371
|
$selectBrandIds[] = $v['id'];
|
388
|
$selectBrandIds[] = $v['id'];
|
372
|
$url = self::buildUrl(array_merge($params, array(
|
389
|
$url = self::buildUrl(array_merge($params, array(
|
|
@@ -396,25 +413,6 @@ class HelperSearch |
|
@@ -396,25 +413,6 @@ class HelperSearch |
396
|
}
|
413
|
}
|
397
|
//清空品牌参数
|
414
|
//清空品牌参数
|
398
|
unset($params['brand']);
|
415
|
unset($params['brand']);
|
399
|
- //设置已选中的品牌
|
|
|
400
|
- $existBrandNum = 0;
|
|
|
401
|
- $existName = '';
|
|
|
402
|
- foreach ($brandIds as $key => $val) {
|
|
|
403
|
- if (isset($brandAll[$val])) {
|
|
|
404
|
- $brandParam = $brandIds;
|
|
|
405
|
- unset($brandParam[$key]);
|
|
|
406
|
- if ($existBrandNum === 0) {
|
|
|
407
|
- $existName .= $brandAll[$val].'、';
|
|
|
408
|
- }
|
|
|
409
|
- if ($existBrandNum === 1){
|
|
|
410
|
- $existName .= substr($brandAll[$val], 0, 3).'...';
|
|
|
411
|
- }
|
|
|
412
|
- $existBrandNum++;
|
|
|
413
|
- }
|
|
|
414
|
- if ($existBrandNum > 1) {
|
|
|
415
|
- break;
|
|
|
416
|
- }
|
|
|
417
|
- }
|
|
|
418
|
//设置选中
|
416
|
//设置选中
|
419
|
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
|
417
|
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
|
420
|
self::$selected['brand'] = array(
|
418
|
self::$selected['brand'] = array(
|
|
@@ -448,6 +446,7 @@ class HelperSearch |
|
@@ -448,6 +446,7 @@ class HelperSearch |
448
|
if (count($result['brandsShow']) < 11) {
|
446
|
if (count($result['brandsShow']) < 11) {
|
449
|
$result['hideMore'] = true;
|
447
|
$result['hideMore'] = true;
|
450
|
}
|
448
|
}
|
|
|
449
|
+// print_r($result); exit;
|
451
|
return $result;
|
450
|
return $result;
|
452
|
}
|
451
|
}
|
453
|
/**
|
452
|
/**
|
|
@@ -459,14 +458,14 @@ class HelperSearch |
|
@@ -459,14 +458,14 @@ class HelperSearch |
459
|
{
|
458
|
{
|
460
|
$params = self::$params;
|
459
|
$params = self::$params;
|
461
|
$paramsValue = array_filter($params);
|
460
|
$paramsValue = array_filter($params);
|
462
|
- if (!$isAjax && empty($paramsValue)) {
|
|
|
463
|
- return array();
|
|
|
464
|
- }
|
|
|
465
|
$sizeId = isset($params['size']) && !empty($params['size']) ? $params['size'] : '';
|
461
|
$sizeId = isset($params['size']) && !empty($params['size']) ? $params['size'] : '';
|
466
|
if (isset($params['size'])) {
|
462
|
if (isset($params['size'])) {
|
467
|
unset($params['size']);
|
463
|
unset($params['size']);
|
468
|
}
|
464
|
}
|
469
|
$result = array();
|
465
|
$result = array();
|
|
|
466
|
+ if (!$isAjax && empty($paramsValue)) {
|
|
|
467
|
+ return array();
|
|
|
468
|
+ }
|
470
|
if (isset($filter['size']) && !empty($filter['size'])) {
|
469
|
if (isset($filter['size']) && !empty($filter['size'])) {
|
471
|
$size = $filter['size'];
|
470
|
$size = $filter['size'];
|
472
|
foreach ($size as $k=> $v) {
|
471
|
foreach ($size as $k=> $v) {
|
|
@@ -485,7 +484,7 @@ class HelperSearch |
|
@@ -485,7 +484,7 @@ class HelperSearch |
485
|
'checked' => isset(self::$params['size']) && self::$params['size'] == $v['size_id'] ? true : false
|
484
|
'checked' => isset(self::$params['size']) && self::$params['size'] == $v['size_id'] ? true : false
|
486
|
);
|
485
|
);
|
487
|
}
|
486
|
}
|
488
|
- if (self::checkSearch('size')) {
|
487
|
+ if ( self::checkSearch('size')) {
|
489
|
return array();
|
488
|
return array();
|
490
|
}
|
489
|
}
|
491
|
}
|
490
|
}
|
|
@@ -940,8 +939,8 @@ class HelperSearch |
|
@@ -940,8 +939,8 @@ class HelperSearch |
940
|
}
|
939
|
}
|
941
|
if ($data) {
|
940
|
if ($data) {
|
942
|
$result['conditions'] = $data;
|
941
|
$result['conditions'] = $data;
|
|
|
942
|
+ $result['clearUrl'] = self::current();
|
943
|
}
|
943
|
}
|
944
|
- $result['clearUrl'] = self::current();
|
|
|
945
|
return $result;
|
944
|
return $result;
|
946
|
}
|
945
|
}
|
947
|
|
946
|
|
|
@@ -1200,7 +1199,7 @@ class HelperSearch |
|
@@ -1200,7 +1199,7 @@ class HelperSearch |
1200
|
if (!empty($condition)) {
|
1199
|
if (!empty($condition)) {
|
1201
|
$param += $condition;
|
1200
|
$param += $condition;
|
1202
|
}
|
1201
|
}
|
1203
|
- return Yohobuy::httpBuildQuery(self::getUrl(), $param);
|
1202
|
+ return Yohobuy::httpBuildQuery(SearchData::getUrl(), $param);
|
1204
|
}
|
1203
|
}
|
1205
|
|
1204
|
|
1206
|
/**
|
1205
|
/**
|
|
@@ -1213,7 +1212,7 @@ class HelperSearch |
|
@@ -1213,7 +1212,7 @@ class HelperSearch |
1213
|
$condition['sales'] = 'Y'; //在销售商品分类
|
1212
|
$condition['sales'] = 'Y'; //在销售商品分类
|
1214
|
$condition['status'] = 1; //上架商品分类
|
1213
|
$condition['status'] = 1; //上架商品分类
|
1215
|
$condition['stocknumber'] = 1; //过滤掉已售罄
|
1214
|
$condition['stocknumber'] = 1; //过滤掉已售罄
|
1216
|
- return Yohobuy::httpBuildQuery(self::getUrl('sort'), $condition);
|
1215
|
+ return Yohobuy::httpBuildQuery(SearchData::getUrl('sort'), $condition);
|
1217
|
}
|
1216
|
}
|
1218
|
|
1217
|
|
1219
|
/**
|
1218
|
/**
|
|
@@ -1223,7 +1222,7 @@ class HelperSearch |
|
@@ -1223,7 +1222,7 @@ class HelperSearch |
1223
|
|
1222
|
|
1224
|
public static function getDiscountUrl($param = array())
|
1223
|
public static function getDiscountUrl($param = array())
|
1225
|
{
|
1224
|
{
|
1226
|
- return Yohobuy::httpBuildQuery(self::getUrl('discount'), $param);
|
1225
|
+ return Yohobuy::httpBuildQuery(SearchData::getUrl('discount'), $param);
|
1227
|
}
|
1226
|
}
|
1228
|
|
1227
|
|
1229
|
/**
|
1228
|
/**
|
|
@@ -1231,7 +1230,7 @@ class HelperSearch |
|
@@ -1231,7 +1230,7 @@ class HelperSearch |
1231
|
*/
|
1230
|
*/
|
1232
|
public static function getRecentShelveUrl($param = array())
|
1231
|
public static function getRecentShelveUrl($param = array())
|
1233
|
{
|
1232
|
{
|
1234
|
- return Yohobuy::httpBuildQuery(self::getUrl('recent'), $param);
|
1233
|
+ return Yohobuy::httpBuildQuery(SearchData::getUrl('recent'), $param);
|
1235
|
}
|
1234
|
}
|
1236
|
|
1235
|
|
1237
|
/**
|
1236
|
/**
|
|
@@ -1262,15 +1261,6 @@ class HelperSearch |
|
@@ -1262,15 +1261,6 @@ class HelperSearch |
1262
|
|
1261
|
|
1263
|
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
|
1262
|
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
|
1264
|
}
|
1263
|
}
|
1265
|
-
|
|
|
1266
|
-
|
|
|
1267
|
- /**
|
|
|
1268
|
- * 并行调接口url获取(获取用户浏览记录)
|
|
|
1269
|
- */
|
|
|
1270
|
-// public static function getReviewUrl($param = array())
|
|
|
1271
|
-// {
|
|
|
1272
|
-// return Yohobuy::httpBuildQuery(self::getUrl('review'), $param);
|
|
|
1273
|
-// }
|
|
|
1274
|
|
1264
|
|
1275
|
|
1265
|
|
1276
|
/**
|
1266
|
/**
|
|
@@ -1280,58 +1270,7 @@ class HelperSearch |
|
@@ -1280,58 +1270,7 @@ class HelperSearch |
1280
|
*/
|
1270
|
*/
|
1281
|
public static function getShopUrl($param)
|
1271
|
public static function getShopUrl($param)
|
1282
|
{
|
1272
|
{
|
1283
|
- return Yohobuy::httpBuildQuery(self::getUrl('shop'), $param);
|
|
|
1284
|
- }
|
|
|
1285
|
- /**
|
|
|
1286
|
- * 获取搜索的服务地址
|
|
|
1287
|
- *
|
|
|
1288
|
- * 备注:此处是根据环境来确定使用阿里云内网还是外网的URL
|
|
|
1289
|
- *
|
|
|
1290
|
- * @return string
|
|
|
1291
|
- */
|
|
|
1292
|
- private static function getUrl($type = 'search')
|
|
|
1293
|
- {
|
|
|
1294
|
- defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
|
|
|
1295
|
- switch (APPLICATION_ENV) {
|
|
|
1296
|
- case 'release':
|
|
|
1297
|
- if ($type == 'sort') {
|
|
|
1298
|
- return 'http://100.98.132.63/yohosearch/sortgroup.json';
|
|
|
1299
|
- }
|
|
|
1300
|
- elseif ($type == 'discount') {
|
|
|
1301
|
- return 'http://100.98.132.63/yohosearch/discount.json';
|
|
|
1302
|
- }
|
|
|
1303
|
- elseif ($type == 'recent') {
|
|
|
1304
|
- return 'http://100.98.132.63/yohosearch/recent.json';
|
|
|
1305
|
- }
|
|
|
1306
|
-// elseif ($type == 'review') {
|
|
|
1307
|
-//
|
|
|
1308
|
-// }
|
|
|
1309
|
- elseif ($type == 'shop') {
|
|
|
1310
|
- return 'http://100.98.132.63/yohosearch/shops.json';
|
|
|
1311
|
- }
|
|
|
1312
|
- return 'http://100.98.132.63/yohosearch/search.json';
|
|
|
1313
|
- case 'test':
|
|
|
1314
|
- case 'preview':
|
|
|
1315
|
- case 'developer':
|
|
|
1316
|
- default:
|
|
|
1317
|
- if ($type == 'sort') {
|
|
|
1318
|
- return 'http://101.200.31.165/yohosearch/sortgroup.json';
|
|
|
1319
|
- }
|
|
|
1320
|
- elseif ($type == 'discount') {
|
|
|
1321
|
- return 'http://101.200.31.165/yohosearch/discount.json';
|
|
|
1322
|
- }
|
|
|
1323
|
- elseif ($type == 'recent') {
|
|
|
1324
|
- return 'http://101.200.31.165/yohosearch/recent.json';
|
|
|
1325
|
- }
|
|
|
1326
|
-// elseif ($type == 'review') {
|
|
|
1327
|
-//
|
|
|
1328
|
-// }
|
|
|
1329
|
- elseif ($type == 'shop') {
|
|
|
1330
|
- return 'http://101.200.31.165/yohosearch/shops.json';
|
|
|
1331
|
- }
|
|
|
1332
|
-// return 'http://101.200.31.165/yohosearch/search.json';
|
|
|
1333
|
- return 'http://192.168.10.64:8080/yohosearch/search-once.json';
|
|
|
1334
|
- }
|
1273
|
+ return Yohobuy::httpBuildQuery(SearchData::getUrl('shop'), $param);
|
1335
|
}
|
1274
|
}
|
1336
|
|
1275
|
|
1337
|
/**
|
1276
|
/**
|