NewsaleData.php
6.81 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
namespace LibModels\Wap\Product;
use Api\Yohobuy;
use Api\Sign;
/**
* 新品到着,折扣专区接口操作类
*
* @name NewsaleData
* @package Library/LibModels/wap/Product
* @copyright yoho.inc
* @version 1.0 (2015-10-8)
* @author gtskk <rocky.zhang@yoho.cn>
*/
class NewsaleData
{
/**
* 获取新品到着,折扣专区焦点图数据
* @param string $contentCode 内容位置码
* @return array 新品到着焦点图有关数据
*/
public static function getNewsaleFocus($contentCode)
{
// 构建必传参数
$param = Yohobuy::param();
$param['content_code'] = $contentCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/get', $param);
}
/**
* 获取新品到着商品数据
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param string $channel 1表示男, 2表示女
* @param string $order 排序方式,默认s_t_desc表示按照时间倒序排列
* @param integer $limit 查询返回的最大限制数, 默认为60
* @param integer $page 分页第几页, 默认第1页
* @return array 新品到着商品数据
*/
public static function getNewProducts($gender, $channel, $order = 's_t_desc', $limit = 60, $page = 1)
{
// 构建url地址列表
$urlList = array();
$param = Yohobuy::param();
$param['method'] = 'app.search.newProduct';
$param['gender'] = $gender;
$param['order'] = $order;
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
$build = $param;
$build['dayLimit'] = 1;
$build['client_secret'] = Sign::getSign($build);
$urlList['new'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $build);
$build = $param;
$build['dayLimit'] = 2;
$build['client_secret'] = Sign::getSign($build);
$urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $build);
$build = $param;
$build['dayLimit'] = 3;
$build['client_secret'] = Sign::getSign($build);
$urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $build);
$build = array();
$param = array();
return Yohobuy::getMulti($urlList);
}
/**
* 筛选新品到着、折扣专区商品
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $brand 品牌Id
* @param integer $sort 品类Id
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
* @param integer $channel 表示频道号,1位男生,2为女生
* @param integer $dayLimit 限制读取多少天,默认为1天
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @param string $order 排序方式,默认s_t_desc表示按照时间倒序排列
*
* @return array 根据指定条件筛选出来的商品
*/
public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 60, $page = 1, $order = 's_t_desc')
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
'sort' => $sort,
'color' => $color,
'size' => $size,
'price' => $price,
'p_d' => $p_d,
'dayLimit' => $dayLimit
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {
return $v !== null;
});
$param = Yohobuy::param();
if(!is_null($dayLimit)) {
$param['method'] = 'app.search.newProduct';
}else {
$param['method'] = 'app.search.sales';
}
$param['page'] = $page;
$param['limit'] = $limit;
$param['order'] = $order;
$param['yh_channel'] = $channel;
$param = array_merge($param, $queriedParams);
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取折扣专区商品数据
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param string $channel 1表示男, 2表示女
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array 折扣专区商品数据
*/
public static function getSaleProducts($gender, $channel, $limit = 60, $page = 1)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.sales';
$param['gender'] = $gender;
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
// 构建url地址列表
$urlList = array();
$param['p_d'] = '0.1,0.9';
$param['client_secret'] = Sign::getSign($param);
$urlList['ALL'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
return Yohobuy::getMulti($urlList);
}
/**
* 筛选折扣专区商品
*
* @param string gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer brand 品牌Id
* @param integer sort 品类Id
* @param integer color 颜色Id
* @param integer size 尺码Id
* @param string price 价格
* @param string $channel 1表示男, 2表示女
* @param integer $p_d 折扣
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array 筛选出来的折扣专区商品
*/
public static function selectSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $limit = 50, $page = 1)
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
'sort' => $sort,
'color' => $color,
'size' => $size,
'price' => $price
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {
return $v !== null;
});
$param = Yohobuy::param();
$param['method'] = 'app.search.sales';
$param['yh_channel'] = $channel;
$param['p_d'] = $p_d;
$param['page'] = $page;
$param['limit'] = $limit;
$param = array_merge($param, $queriedParams);
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}