Search.php
3.22 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
class QLibView_Search {
private static $page = 1;
private static $params;
private static $rows = 100;
private static $gender = '1,3';
private static $num = '';
public static function getSearch($params, $type = 'newProduct') {
$match = new QINSearch_Tyr_Match ( $project = 'search_sort', $index = 'search_sort' );
if ($type == 'newProduct' || $type == 'favoriteTotal' || $type == 'newProductRecom') {
if (empty ( $params ['day'] )) {
$dayList = $match->getNewProduct ( array('gender'=>$params['gender']) );
$arrayKeys = array_keys ( $dayList );
$start_time = strtotime ( date ( 'Y-m-d', array_pop ( $arrayKeys ) ) );
$end_time = strtotime ( date ( 'Y-m-d', array_shift ( $arrayKeys ) ) ) + 86400 - 1;
$params ['shelve_time'] = $start_time . ',' . $end_time;
}
}
if ($type == 'saleFavoriteTotal' || $type == 'saleFavoriteProduct') {
if (empty ( $params ['p_d'] )) {
$params ['p_d'] = '0.1,0.9';
}
}
if (! empty ( $params ['page'] )) {
self::$page = $params ['page'];
}
if (! empty ( $params ['rows'] )) {
self::$rows = $params ['rows'];
}
if (!empty ( $params ['gender'] )) {
self::$gender = $params ['gender'];
}
$match = new QINSearch_Tyr_Match ( $project = 'search_sort', $index = 'search_sort' );
$search = $match->search ();
$search->setSortModes ( $params );
if ($type == 'favoriteTotal' || $type == 'saleFavoriteTotal') {
if (isset($params['brand'])) {
unset($params['brand']);
}
$_result = $match->getGoodsNumByBrand($params);
}
elseif ($type == 'saleProduct' || $type == 'newProductRecom') {
$_result = $search->setFilters ( $params )->setLimits ( 0, 100, 100 )->query ();
} else {
$_result = $search->setFilters ( $params )->setLimits ( (self::$page - 1) * self::$rows, ( int ) self::$rows, 300 )->query ();
}
return $_result;
}
public static function getNewProductNum($params){
$match = new QINSearch_Tyr_Match ( $project = 'search_sort', $index = 'search_sort' );
$dayList = $match->getNewProduct ();
$arrayKeys = array_keys ( $dayList );
$start_time = strtotime ( date ( 'Y-m-d', array_pop ( $arrayKeys ) ) );
$end_time = strtotime ( date ( 'Y-m-d', array_shift ( $arrayKeys ) ) ) + 86400 - 1;
$params ['shelve_time'] = $start_time . ',' . $end_time;
$search = $match->search ();
$_result = $search->setFilters ( $params )->setLimits ( (self::$page - 1) * self::$rows, ( int ) self::$rows)->query ();
return $_result;
}
}?>