Store.php
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* 店铺搜索
* @author tongdesheng
*
*/
class YHMSearch_Store extends YHMSearch_Core {
private $_searchConditions = array('storetype', 'keyword', 'page', 'viewNum', 'searchuid', 'hasgoods', 'hasstock');
private $_orderType = array('star:desc', "stock_number:desc", 'create_time:asc', 'create_time:desc');
private $_urlPath = 'searchstore';
public function getList($params) {
$condParams = array();
//筛选条件
if (!empty($params)) {
foreach ($this->_searchConditions as $cond) {
if (isset($params[$cond])) {
$condParams[$cond] = $params[$cond];
}
}
}
if (isset($params['order_type'])) {
$typearr = explode(",", $params['order_type']);
$newtype = array_intersect($typearr, $this->_orderType);
//排序方式
if (!empty($params['order_type']) && (count($typearr) == count($newtype))) {
$condParams['order'] = $params['order_type'];
} else {
$condParams['order'] = 'create_time:desc';
}
}
$retData = $this->req($this->_urlPath, $condParams);
//{"searchstore":{"items":["1","0","7"]}}
if (!empty($retData['searchstore']['items'])) {
return $retData['searchstore']['items'];
}
return array();
}
}