|
@@ -57,20 +57,198 @@ class PlusstarData |
|
@@ -57,20 +57,198 @@ class PlusstarData |
57
|
|
57
|
|
58
|
/**
|
58
|
/**
|
59
|
* 品牌介绍
|
59
|
* 品牌介绍
|
|
|
60
|
+ *
|
|
|
61
|
+ * @param int $id 唯一的ID
|
|
|
62
|
+ * @param string $gender $gender "1,3"表示男, "2,3"表示女
|
|
|
63
|
+ * @param int $uid 用户ID
|
|
|
64
|
+ * @param string $udid cookie记录唯一标识
|
|
|
65
|
+ * @return array(
|
|
|
66
|
+ * "getBrandInfo" => array(品牌详情信息),
|
|
|
67
|
+ * "getUidBrandFav" => false,
|
|
|
68
|
+ * "getArticleByBrand" => array(3篇相关资讯),
|
|
|
69
|
+ * "getNewProduct" => array(6篇新品到着),
|
|
|
70
|
+ * "getUidProductFav" => array(用户是否收藏新品)
|
|
|
71
|
+ * )
|
60
|
*/
|
72
|
*/
|
61
|
- public static function brandInfo($id)
|
73
|
+ public static function brandInfo($id, $gender, $uid, $udid = null)
|
62
|
{
|
74
|
{
|
|
|
75
|
+ $isUidOk = $uid && is_numeric($uid);
|
|
|
76
|
+
|
|
|
77
|
+ // 品牌详情信息
|
63
|
$result = array();
|
78
|
$result = array();
|
|
|
79
|
+ $result['getBrandInfo'] = Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v1/plustar/', 'getBrandInfo', array(array('id' => $id)) );
|
|
|
80
|
+ $result['getUidBrandFav'] = false;
|
|
|
81
|
+ $result['getNewProduct'] = array();
|
|
|
82
|
+ $result['getUidProductFav'] = array();
|
|
|
83
|
+ $result['getArticleByBrand'] = array();
|
64
|
|
84
|
|
65
|
- Yohobuy::yarConcurrentCall('http://service.api.yohobuy.com/guang/service/v1/plustar/', 'getBrandInfo', array('id' => 289), function($retval, $callinfo) use(&$result) {
|
|
|
66
|
- $result[ $callinfo['method'] ] = empty($retval['data']) ? array() : $retval['data'];
|
|
|
67
|
- });
|
|
|
68
|
- Yohobuy::yarConcurrentCall('http://service.api.yohobuy.com/guang/service/v1/plustar/', 'getList', array('id' => 289), function($retval, $callinfo) use(&$result) {
|
|
|
69
|
- $result[ $callinfo['method'] ] = empty($retval['data']) ? array() : $retval['data'];
|
85
|
+ // 判断
|
|
|
86
|
+ if (!isset($result['getBrandInfo']['brand_id'])) {
|
|
|
87
|
+ return $result;
|
|
|
88
|
+ }
|
|
|
89
|
+
|
|
|
90
|
+ // 是否收藏店铺
|
|
|
91
|
+ if ($isUidOk) {
|
|
|
92
|
+ Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'getUidBrandFav', array($uid, $id), function($retval) use(&$result) {
|
|
|
93
|
+ $result['getUidBrandFav'] = empty($retval['data']) ? false : $retval['data'];
|
|
|
94
|
+ });
|
|
|
95
|
+ }
|
|
|
96
|
+
|
|
|
97
|
+ // 相关资讯列表 (3篇)
|
|
|
98
|
+ $result['getArticleByBrand'] = array();
|
|
|
99
|
+ Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'guang/service/v1/article/', 'getArticleByBrand', array($result['getBrandInfo']['brand_id'], 3, $udid), function($retval) use(&$result) {
|
|
|
100
|
+ $result['getArticleByBrand'] = empty($retval) ? array() : $retval;
|
70
|
});
|
101
|
});
|
71
|
- Yohobuy::yarConcurrentLoop();
|
|
|
72
|
|
102
|
|
|
|
103
|
+ // 新品到着列表 (6篇)
|
|
|
104
|
+ $result['getNewProduct'] = array();
|
|
|
105
|
+ $result['getUidProductFav'] = array();
|
|
|
106
|
+
|
|
|
107
|
+ do {
|
|
|
108
|
+ // 调用搜索接口
|
|
|
109
|
+ $param = Yohobuy::param();
|
|
|
110
|
+ $param['method'] = 'app.search.li';
|
|
|
111
|
+ $param['brand'] = $result['getBrandInfo']['brand_id'];
|
|
|
112
|
+ $param['page'] = '0';
|
|
|
113
|
+ $param['limit'] = '6';
|
|
|
114
|
+ $param['gender'] = $gender;
|
|
|
115
|
+ $param['order'] = 's_t_desc';
|
|
|
116
|
+ $param['client_secret'] = Sign::getSign($param);
|
|
|
117
|
+ $newProduct = Yohobuy::get(Yohobuy::API_URL, $param);
|
|
|
118
|
+ if (empty($newProduct['data']['product_list'])) {
|
|
|
119
|
+ break;
|
|
|
120
|
+ }
|
|
|
121
|
+
|
|
|
122
|
+ //$result['getNewProduct'] = $newProduct['data']['product_list'];
|
|
|
123
|
+
|
|
|
124
|
+ $skn = '';
|
|
|
125
|
+ foreach ($newProduct['data']['product_list'] as $value) {
|
|
|
126
|
+ if (empty($value['goods_list'])) {
|
|
|
127
|
+ continue;
|
|
|
128
|
+ }
|
|
|
129
|
+
|
|
|
130
|
+ // 用户是否收藏该商品
|
|
|
131
|
+ $skn = $value['product_skn'];
|
|
|
132
|
+ $result['getUidProductFav'][ $skn ] = false;
|
|
|
133
|
+ if ($isUidOk) {
|
|
|
134
|
+ Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'getUidProductFav', array($uid, $value['product_skn']), function($retval) use(&$result,&$skn) {
|
|
|
135
|
+ $result['getUidProductFav'][ $skn ] = empty($retval['data']) ? false : $retval['data'];
|
|
|
136
|
+ });
|
|
|
137
|
+ }
|
|
|
138
|
+
|
|
|
139
|
+ // @todo 需要根据页面结构封装返回数据
|
|
|
140
|
+ }
|
|
|
141
|
+ } while (false);
|
|
|
142
|
+
|
|
|
143
|
+ // 调用发起请求
|
|
|
144
|
+ Yohobuy::yarConcurrentLoop();
|
|
|
145
|
+
|
73
|
return $result;
|
146
|
return $result;
|
|
|
147
|
+
|
|
|
148
|
+
|
|
|
149
|
+ // @todo 根据页面展示数据封装
|
|
|
150
|
+// $url = '';
|
|
|
151
|
+// if($uid > 0){
|
|
|
152
|
+// $isLike = Favorite::getUidProductFav($uid, $new_goods_info['product_skn']);
|
|
|
153
|
+// }
|
|
|
154
|
+// if($client_type == 'web'){
|
|
|
155
|
+// $baseUrl = QUtilsConfig::$websiteRoot['yohobuy'];
|
|
|
156
|
+// }else{
|
|
|
157
|
+// $baseUrl = QUtilsConfig::$websiteRoot['h5'];
|
|
|
158
|
+// }
|
|
|
159
|
+// $goods_url = MakeUrl::h5ProductDetailUrl($baseUrl,$new_goods_info['product_id'],$new_goods_info['goods_list'][0]['goods_id'],$new_goods_info['cn_alphabet']);
|
|
|
160
|
+// $url = MakeUrl::makeUrl('go.productDetail',$goods_url, array('product_skn'=>$new_goods_info['product_skn']),$client_type);
|
|
|
161
|
+// if((int)$new_goods_info['market_price'] == (int)$new_goods_info['sales_price'])
|
|
|
162
|
+// {
|
|
|
163
|
+// $new_goods_info['market_price'] = '';
|
|
|
164
|
+// }
|
|
|
165
|
+// $tags = array(
|
|
|
166
|
+// 'isNew' => false,
|
|
|
167
|
+// 'isSale' => false,
|
|
|
168
|
+// 'isLimit' => false,
|
|
|
169
|
+// 'isYohood' => false,
|
|
|
170
|
+// 'midYear' => false,
|
|
|
171
|
+// 'yearEnd' => false,
|
|
|
172
|
+// );
|
|
|
173
|
+// foreach ($new_goods_info['tags'] as $v){
|
|
|
174
|
+// if($v == 'is_new'){
|
|
|
175
|
+// $tags['isNew'] = true;
|
|
|
176
|
+// }elseif($v == 'is_discount'){
|
|
|
177
|
+// $tags['isSale'] = true;
|
|
|
178
|
+// }elseif($v == 'is_limited'){
|
|
|
179
|
+// $tags['isLimit'] = true;
|
|
|
180
|
+// }elseif($v == 'is_yohood'){
|
|
|
181
|
+// $tags['isYohood'] = true;
|
|
|
182
|
+// }elseif($v == 'mid-year'){
|
|
|
183
|
+// $tags['midYear'] = true;
|
|
|
184
|
+// }elseif($v == 'year-end'){
|
|
|
185
|
+// $tags['yearEnd'] = true;
|
|
|
186
|
+// }
|
|
|
187
|
+// }
|
|
|
188
|
+// $newPatterns[$new_goods_info['product_skn']]= array (
|
|
|
189
|
+// 'id'=>$new_goods_info['product_skn'],
|
|
|
190
|
+// 'product_id'=>$new_goods_info['product_id'],
|
|
|
191
|
+// 'product_skn'=>$new_goods_info['product_skn'],
|
|
|
192
|
+// 'thumb' => $new_goods_info['default_images'],
|
|
|
193
|
+// 'name' => $new_goods_info['product_name'],
|
|
|
194
|
+// 'isLike' => $isLike,
|
|
|
195
|
+// 'price' => $new_goods_info['market_price'],
|
|
|
196
|
+// 'salePrice' => $new_goods_info['sales_price'],
|
|
|
197
|
+// 'isSale' => $new_goods_info['is_discount'] == 'Y' ? true : false,
|
|
|
198
|
+// 'isFew' => $new_goods_info['is_soon_sold_out'] == 'Y' ? true : false,
|
|
|
199
|
+// 'isNew' => $new_goods_info['is_new'] == 'Y' ? true : false,
|
|
|
200
|
+// 'url' => $url,
|
|
|
201
|
+// 'tags' => $tags
|
|
|
202
|
+// );
|
|
|
203
|
+
|
|
|
204
|
+
|
|
|
205
|
+ }
|
|
|
206
|
+
|
|
|
207
|
+ /**
|
|
|
208
|
+ * 品牌收藏/取消收藏
|
|
|
209
|
+ *
|
|
|
210
|
+ * @param int $uid 用户ID
|
|
|
211
|
+ * @param int $id 唯一的ID
|
|
|
212
|
+ * @param string $opt 操作(ok:表示确定,cancel:表示取消)
|
|
|
213
|
+ * @return array
|
|
|
214
|
+ */
|
|
|
215
|
+ public static function favoriteBrand($uid, $id, $opt = 'ok')
|
|
|
216
|
+ {
|
|
|
217
|
+ return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'toggleBrandFav', array($uid, $id));
|
|
|
218
|
+ }
|
|
|
219
|
+
|
|
|
220
|
+ /**
|
|
|
221
|
+ * 商品收藏/取消收藏
|
|
|
222
|
+ *
|
|
|
223
|
+ * @param int $uid 用户ID
|
|
|
224
|
+ * @param int $skn 商品标识
|
|
|
225
|
+ * @param string $opt 操作(ok:表示确定,cancel:表示取消)
|
|
|
226
|
+ * @return array
|
|
|
227
|
+ */
|
|
|
228
|
+ public static function favoriteProduct($uid, $skn, $opt = 'ok')
|
|
|
229
|
+ {
|
|
|
230
|
+ if ($opt === 'cancel') {
|
|
|
231
|
+ return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'addUidProductFav', array($uid, $skn));
|
|
|
232
|
+ } else {
|
|
|
233
|
+ return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'delUidProductFav', array($uid, $skn));
|
|
|
234
|
+ }
|
|
|
235
|
+ }
|
|
|
236
|
+
|
|
|
237
|
+ /**
|
|
|
238
|
+ * 资讯点赞/取消赞
|
|
|
239
|
+ *
|
|
|
240
|
+ * @param int $uid 用户ID
|
|
|
241
|
+ * @param int $id 唯一的ID
|
|
|
242
|
+ * @param string $opt 操作(ok:表示确定,cancel:表示取消)
|
|
|
243
|
+ * @return array
|
|
|
244
|
+ */
|
|
|
245
|
+ public static function praiseArticle($uid, $id, $opt = 'ok')
|
|
|
246
|
+ {
|
|
|
247
|
+ if ($opt === 'cancel') {
|
|
|
248
|
+ return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v1/favorite/', 'cancelPraise', array($id, $uid));
|
|
|
249
|
+ } else {
|
|
|
250
|
+ return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v1/favorite/', 'setPraise', array($id, $uid));
|
|
|
251
|
+ }
|
74
|
}
|
252
|
}
|
75
|
|
253
|
|
76
|
} |
254
|
} |