1
|
<?php
|
1
|
<?php
|
|
|
2
|
+namespace LibModels\wap\Channel;
|
2
|
|
3
|
|
3
|
-/*
|
|
|
4
|
- * To change this license header, choose License Headers in Project Properties.
|
|
|
5
|
- * To change this template file, choose Tools | Templates
|
|
|
6
|
- * and open the template in the editor.
|
4
|
+use Api\Yohobuy;
|
|
|
5
|
+use Api\Sign;
|
|
|
6
|
+use Plugin\Helpers;
|
|
|
7
|
+
|
|
|
8
|
+/**
|
|
|
9
|
+ * 新品到着接口操作类
|
|
|
10
|
+ *
|
|
|
11
|
+ * @name NewsaleData
|
|
|
12
|
+ * @package Library/LibModels/Channel
|
|
|
13
|
+ * @copyright yoho.inc
|
|
|
14
|
+ * @version 1.0 (2015-10-8)
|
|
|
15
|
+ * @author gtskk <rocky.zhang@yoho.cn>
|
|
|
16
|
+ */
|
|
|
17
|
+class NewsaleData
|
|
|
18
|
+{
|
|
|
19
|
+
|
|
|
20
|
+ /**
|
|
|
21
|
+ * 获取新品到着焦点图数据
|
|
|
22
|
+ * @param string $contentCode 内容位置码
|
|
|
23
|
+ * @return array 新品到着焦点图有关数据
|
|
|
24
|
+ */
|
|
|
25
|
+ public static function getNewsaleFocus($contentCode)
|
|
|
26
|
+ {
|
|
|
27
|
+ // 构建必传参数
|
|
|
28
|
+ $param = Yohobuy::param();
|
|
|
29
|
+
|
|
|
30
|
+ $param['content_code'] = $contentCode;
|
|
|
31
|
+ $param['client_secret'] = Sign::getSign($param);
|
|
|
32
|
+
|
|
|
33
|
+ return Yohobuy::get(Yohobuy::SERVICE_URL.'operations/api/v5/resource/get', $param);
|
|
|
34
|
+ }
|
|
|
35
|
+
|
|
|
36
|
+ /**
|
|
|
37
|
+ * 获取新品到着商品数据
|
|
|
38
|
+ *
|
|
|
39
|
+ * @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
|
|
|
40
|
+ * @param string $channel 1表示男, 2表示女
|
|
|
41
|
+ * @param integer $limit 查询返回的最大限制数, 默认为50
|
|
|
42
|
+ * @param integer $page 分页第几页, 默认第1页
|
|
|
43
|
+ * @return array 新品到着商品数据
|
7
|
*/
|
44
|
*/
|
|
|
45
|
+ public static function getNewsaleProducts($gender, $channel, $limit = 50, $page = 1)
|
|
|
46
|
+ {
|
|
|
47
|
+ $param = Yohobuy::param();
|
|
|
48
|
+ $param['method'] = 'app.search.newProduct';
|
|
|
49
|
+ $param['gender'] = $gender;
|
|
|
50
|
+ $param['page'] = $page;
|
|
|
51
|
+ $param['limit'] = $limit;
|
|
|
52
|
+ $param['yh_channel'] = $channel;
|
|
|
53
|
+ $param['client_secret'] = Sign::getSign($param);
|
|
|
54
|
+
|
|
|
55
|
+ // 构建url地址列表
|
|
|
56
|
+ $urlList = array();
|
|
|
57
|
+ $param['dayLimit'] = 1;
|
|
|
58
|
+ $urlList['new'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
|
|
|
59
|
+ $param['dayLimit'] = 2;
|
|
|
60
|
+ $urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
|
|
|
61
|
+ $param['dayLimit'] = 3;
|
|
|
62
|
+ $urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
|
|
|
63
|
+ // var_dump($urlList);exit;
|
|
|
64
|
+
|
|
|
65
|
+ return Yohobuy::getMulti($urlList);
|
|
|
66
|
+ }
|
|
|
67
|
+
|
|
|
68
|
+ /**
|
|
|
69
|
+ * 筛选新品到着商品
|
|
|
70
|
+ *
|
|
|
71
|
+ * @param
|
|
|
72
|
+ * @param array $selectParams 筛选条件参数,可传递的条件参数有:
|
|
|
73
|
+ * string gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
|
|
|
74
|
+ * integer brand 品牌Id
|
|
|
75
|
+ * integer sort 品类Id
|
|
|
76
|
+ * integer color 颜色Id
|
|
|
77
|
+ * integer size 尺码Id
|
|
|
78
|
+ * string price 价格
|
|
|
79
|
+ * string p_d 折扣
|
|
|
80
|
+ * @param string $channel 1表示男, 2表示女
|
|
|
81
|
+ * @param integer $dayLimit 限制读取多少天,默认为1天
|
|
|
82
|
+ * @param integer $limit 查询返回的最大限制数, 默认为50
|
|
|
83
|
+ * @param integer $page 分页第几页, 默认第1页
|
|
|
84
|
+ * @return array 筛选出来的新品到着商品
|
|
|
85
|
+ */
|
|
|
86
|
+ public static function selectNewsaleProducts(array $selectParams, $channel, $dayLimit = 1, $limit = 50, $page = 1)
|
|
|
87
|
+ {
|
|
|
88
|
+ $selectItems = array(
|
|
|
89
|
+ 'gender',
|
|
|
90
|
+ 'brand',
|
|
|
91
|
+ 'sort',
|
|
|
92
|
+ 'color',
|
|
|
93
|
+ 'size',
|
|
|
94
|
+ 'price',
|
|
|
95
|
+ 'p_d'
|
|
|
96
|
+ );
|
|
|
97
|
+
|
|
|
98
|
+ $param = Yohobuy::param();
|
|
|
99
|
+ $param['method'] = 'app.search.newProduct';
|
|
|
100
|
+ $param['dayLimit'] = $dayLimit;
|
|
|
101
|
+ $param['page'] = $page;
|
|
|
102
|
+ $param['limit'] = $limit;
|
|
|
103
|
+ $param['yh_channel'] = $channel;
|
|
|
104
|
+
|
|
|
105
|
+ // 拉取筛选参数
|
|
|
106
|
+ $queriedParams = Helpers::array_get($selectParams, $selectItems);
|
|
|
107
|
+ $param = array_merge($param, $queriedParams);
|
|
|
108
|
+ $param['client_secret'] = Sign::getSign($param);
|
|
|
109
|
+
|
|
|
110
|
+ return Yohobuy::get(Yohobuy::API_URL, $param);
|
|
|
111
|
+ }
|
8
|
|
112
|
|
|
|
113
|
+} |