1
|
-<?php
|
|
|
2
|
-namespace WebPlugin\DataProcess\WebChannel;
|
|
|
3
|
-
|
|
|
4
|
-use Plugin\Images;
|
|
|
5
|
-use WebPlugin\Helpers;
|
|
|
6
|
-use WebPlugin\Cache;
|
|
|
7
|
-use Configs\CacheConfig;
|
|
|
8
|
-use LibModels\Web\Product\SearchData;
|
|
|
9
|
-
|
|
|
10
|
-/**
|
|
|
11
|
- * web版通用处理器
|
|
|
12
|
- */
|
|
|
13
|
-class Process
|
|
|
14
|
-{
|
|
|
15
|
- /**
|
|
|
16
|
- *
|
|
|
17
|
- * @param array $data
|
|
|
18
|
- * @param string $type (boys, girls, kids, lifestyle)
|
|
|
19
|
- */
|
|
|
20
|
- public static function getContent(array &$data, $type = '')
|
|
|
21
|
- {
|
|
|
22
|
- // 组合处理数据
|
|
|
23
|
- $result = self::mergeProcess($data, $type);
|
|
|
24
|
- foreach ($data as $key => $val) {
|
|
|
25
|
- $fun = $val['template_name'];
|
|
|
26
|
- if (empty($val['data']) || ! is_callable("self::$fun")) {
|
|
|
27
|
- continue;
|
|
|
28
|
- }
|
|
|
29
|
-
|
|
|
30
|
- // 单个处理数据
|
|
|
31
|
- $build = self::$fun($val, $type);
|
|
|
32
|
- if (! empty($build)) {
|
|
|
33
|
- $result[$key] = $build;
|
|
|
34
|
- unset($data[$key]);
|
|
|
35
|
- }
|
|
|
36
|
- }
|
|
|
37
|
- return $result;
|
|
|
38
|
- }
|
|
|
39
|
-
|
|
|
40
|
- /**
|
|
|
41
|
- * 热门分类处理
|
|
|
42
|
- *
|
|
|
43
|
- * @param array $data
|
|
|
44
|
- * @param string $type
|
|
|
45
|
- * @return array
|
|
|
46
|
- */
|
|
|
47
|
- public static function hotCategory(array $data, $type)
|
|
|
48
|
- {
|
|
|
49
|
- $data = $data['data'];
|
|
|
50
|
- $result = $temp = array();
|
|
|
51
|
- $temp = array(
|
|
|
52
|
- 'name' => $data['name'],
|
|
|
53
|
- 'navs' => array(),
|
|
|
54
|
- 'tplrecommend' => array()
|
|
|
55
|
- );
|
|
|
56
|
- foreach ($data['navs']['list'] as $val) {
|
|
|
57
|
- $temp['navs'][] = array(
|
|
|
58
|
- 'id' => '',
|
|
|
59
|
- 'href' => $val['url'],
|
|
|
60
|
- 'name' => $val['name']
|
|
|
61
|
- );
|
|
|
62
|
- }
|
|
|
63
|
- foreach ($data['menuNav']['blocks'] as $val) {
|
|
|
64
|
- $val['img'] = Images::getImageUrl($val['img'], 185, 76, 1);
|
|
|
65
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
66
|
- $temp['tplrecommend']['keyword'][] = array(
|
|
|
67
|
- 'href' => $val['url'],
|
|
|
68
|
- 'name' => $val['title'],
|
|
|
69
|
- 'img' => $val['img']
|
|
|
70
|
- );
|
|
|
71
|
- }
|
|
|
72
|
-
|
|
|
73
|
- foreach ($data['menuNav']['list'] as $val) {
|
|
|
74
|
- if (empty($val['name']) && empty($val['url'])) {
|
|
|
75
|
- continue;
|
|
|
76
|
- }
|
|
|
77
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
78
|
- $temp['tplrecommend']['category'][] = array(
|
|
|
79
|
- 'name' => $val['name'],
|
|
|
80
|
- 'href' => $val['url']
|
|
|
81
|
- );
|
|
|
82
|
- }
|
|
|
83
|
-
|
|
|
84
|
- foreach ($data['imgs'] as $key => $val) {
|
|
|
85
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
86
|
- if ($key == 0) {
|
|
|
87
|
- $val['img'] = Images::getImageUrl($val['img'], 377, 504, 1); // 大图
|
|
|
88
|
- $temp['tplrecommend']['brands'][] = array(
|
|
|
89
|
- 'href' => $val['url'],
|
|
|
90
|
- 'name' => $val['title'],
|
|
|
91
|
- 'img' => $val['img']
|
|
|
92
|
- );
|
|
|
93
|
- } else {
|
|
|
94
|
- $val['img'] = Images::getImageUrl($val['img'], 185, 504, 1); // 小图
|
|
|
95
|
- $temp['tplrecommend']['types'][] = array(
|
|
|
96
|
- 'href' => $val['url'],
|
|
|
97
|
- 'name' => $val['title'],
|
|
|
98
|
- 'img' => $val['img']
|
|
|
99
|
- );
|
|
|
100
|
- }
|
|
|
101
|
- }
|
|
|
102
|
- $result['recommend'] = $temp;
|
|
|
103
|
- return $result;
|
|
|
104
|
- }
|
|
|
105
|
-
|
|
|
106
|
- /**
|
|
|
107
|
- * banner处理
|
|
|
108
|
- *
|
|
|
109
|
- * @param array $data
|
|
|
110
|
- * @param string $type
|
|
|
111
|
- * @return array
|
|
|
112
|
- */
|
|
|
113
|
- public static function focus(array $data, $type)
|
|
|
114
|
- {
|
|
|
115
|
- $result = array();
|
|
|
116
|
- $temp = array();
|
|
|
117
|
- $width = 1150;
|
|
|
118
|
- $height = 450;
|
|
|
119
|
- if ($data['focus_type'] == 1) {
|
|
|
120
|
- foreach ($data['data'] as $val) {
|
|
|
121
|
- $ret = array();
|
|
|
122
|
- $val['src'] = Images::getImageUrl($val['src'], $width, $height, 1);
|
|
|
123
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
124
|
- $ret = array (
|
|
|
125
|
- 'href' => $val['url'],
|
|
|
126
|
- 'img' => $val['src'],
|
|
|
127
|
- );
|
|
|
128
|
- if(!empty($val['bgColor'])) {
|
|
|
129
|
- $ret['bgColor'] = $val['bgColor'];
|
|
|
130
|
- }
|
|
|
131
|
- $temp[] = $ret;
|
|
|
132
|
- }
|
|
|
133
|
- $result['slide']['list'] = $temp;
|
|
|
134
|
- }
|
|
|
135
|
- return $result;
|
|
|
136
|
- }
|
|
|
137
|
-
|
|
|
138
|
- /**
|
|
|
139
|
- * boys焦点图处理
|
|
|
140
|
- *
|
|
|
141
|
- * @param array $data
|
|
|
142
|
- * @param string $type
|
|
|
143
|
- * @return array
|
|
|
144
|
- */
|
|
|
145
|
- public static function recommend_content_three(array $data, $type)
|
|
|
146
|
- {
|
|
|
147
|
- $result = array();
|
|
|
148
|
- $temp = array();
|
|
|
149
|
- if ($data['template_name'] == 'recommend_content_three') {
|
|
|
150
|
- foreach ($data['data']['big_image'] as $val) {
|
|
|
151
|
- $width = 1150;
|
|
|
152
|
- $height = 450;
|
|
|
153
|
- $val['src'] = Images::getImageUrl($val['src'], $width, $height, 1);
|
|
|
154
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
155
|
- $temp['list'][] = array(
|
|
|
156
|
- 'href' => $val['url'],
|
|
|
157
|
- 'img' => $val['src'],
|
|
|
158
|
- // 'bgColor'=> $val[]
|
|
|
159
|
- );
|
|
|
160
|
- }
|
|
|
161
|
-
|
|
|
162
|
- foreach ($data['data']['list'] as $val) {
|
|
|
163
|
- $width = 138;
|
|
|
164
|
- $height = 54;
|
|
|
165
|
- $val['src'] = Images::getImageUrl($val['src'], $width, $height, 1);
|
|
|
166
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
167
|
- $temp['pagination'][] = array(
|
|
|
168
|
- 'href' => $val['url'],
|
|
|
169
|
- 'img' => $val['src']
|
|
|
170
|
- );
|
|
|
171
|
- }
|
|
|
172
|
- $result['slide'] = $temp;
|
|
|
173
|
- }
|
|
|
174
|
- return $result;
|
|
|
175
|
- }
|
|
|
176
|
-
|
|
|
177
|
- /**
|
|
|
178
|
- * 广告位
|
|
|
179
|
- *
|
|
|
180
|
- * @param array $data
|
|
|
181
|
- * @param string $type
|
|
|
182
|
- * @return array
|
|
|
183
|
- */
|
|
|
184
|
- public static function single_image(array $data, $type)
|
|
|
185
|
- {
|
|
|
186
|
- $result = array();
|
|
|
187
|
- $temp = array();
|
|
|
188
|
- if ($data['template_name'] == 'single_image') {
|
|
|
189
|
- $temp = array(
|
|
|
190
|
- 'href' => '',
|
|
|
191
|
- 'img' => '',
|
|
|
192
|
- 'name' => ''
|
|
|
193
|
- );
|
|
|
194
|
- if (isset($data['data'][0])) {
|
|
|
195
|
- $val = $data['data'][0];
|
|
|
196
|
- $temp['img'] = Images::getImageUrl($val['src'], 1150, 129, 1);
|
|
|
197
|
- $temp['href'] = $val['url'];
|
|
|
198
|
- $temp['name'] = $val['title'];
|
|
|
199
|
- $result['adbanner'] = $temp;
|
|
|
200
|
- }
|
|
|
201
|
- }
|
|
|
202
|
- return $result;
|
|
|
203
|
- }
|
|
|
204
|
-
|
|
|
205
|
- /**
|
|
|
206
|
- * 左右banner
|
|
|
207
|
- *
|
|
|
208
|
- * @param array $data
|
|
|
209
|
- * @param string $type
|
|
|
210
|
- */
|
|
|
211
|
- public static function debrisSlider(array $data, $type)
|
|
|
212
|
- {
|
|
|
213
|
- $data = $data['data'];
|
|
|
214
|
- $result = array(
|
|
|
215
|
- 'debrisSlider' => array(
|
|
|
216
|
- 'left' => array(),
|
|
|
217
|
- 'center' => array(),
|
|
|
218
|
- 'right' => array()
|
|
|
219
|
- )
|
|
|
220
|
- );
|
|
|
221
|
- foreach ($data['left'] as $val) {
|
|
|
222
|
- $val['img'] = Images::getImageUrl($val['img'], 280, 265, 1);
|
|
|
223
|
- $result['debrisSlider']['left'][] = array(
|
|
|
224
|
- 'img' => $val['img'],
|
|
|
225
|
- 'href' => $val['url'],
|
|
|
226
|
- 'name' => $val['title']
|
|
|
227
|
- );
|
|
|
228
|
- }
|
|
|
229
|
- foreach ($data['center'] as $val) {
|
|
|
230
|
- $val['img'] = Images::getImageUrl($val['img'], 570, 633, 1);
|
|
|
231
|
- $result['debrisSlider']['center'][] = array(
|
|
|
232
|
- 'img' => $val['img'],
|
|
|
233
|
- 'href' => $val['url'],
|
|
|
234
|
- 'name' => $val['title']
|
|
|
235
|
- );
|
|
|
236
|
- }
|
|
|
237
|
- foreach ($data['right'] as $val) {
|
|
|
238
|
- $val['img'] = Images::getImageUrl($val['img'], 280, 449, 1);
|
|
|
239
|
- $result['debrisSlider']['right'][] = array(
|
|
|
240
|
- 'img' => $val['img'],
|
|
|
241
|
- 'href' => $val['url'],
|
|
|
242
|
- 'name' => $val['title']
|
|
|
243
|
- );
|
|
|
244
|
- }
|
|
|
245
|
- return $result;
|
|
|
246
|
- }
|
|
|
247
|
-
|
|
|
248
|
- /**
|
|
|
249
|
- * 组合数据处理
|
|
|
250
|
- *
|
|
|
251
|
- * @param array $data
|
|
|
252
|
- * @param string $type
|
|
|
253
|
- * @return array
|
|
|
254
|
- */
|
|
|
255
|
- public static function mergeProcess(array &$data, $type)
|
|
|
256
|
- {
|
|
|
257
|
- $result = array();
|
|
|
258
|
- $mergeProcessList = array(
|
|
|
259
|
- 'mergeSinglehotData',
|
|
|
260
|
- 'mergePreferenceBrandsData',
|
|
|
261
|
- 'mergeAccordionData',
|
|
|
262
|
- 'mergeCategoryData',
|
|
|
263
|
- 'mergeNewReportData',
|
|
|
264
|
- 'mergeSinglehotData2',
|
|
|
265
|
- 'mergeHotCategoryData',
|
|
|
266
|
- 'mergeGirlkidsData',
|
|
|
267
|
- 'mergeHotBrandsData'
|
|
|
268
|
- );
|
|
|
269
|
- foreach ($data as $key => $val) {
|
|
|
270
|
- foreach ($mergeProcessList as $merge) {
|
|
|
271
|
- if (isset($data[$key])) {
|
|
|
272
|
- $temp = self::$merge($key, $data, $type);
|
|
|
273
|
- if (! empty($temp)) {
|
|
|
274
|
- $result[$key] = $temp;
|
|
|
275
|
- }
|
|
|
276
|
- }
|
|
|
277
|
- }
|
|
|
278
|
- }
|
|
|
279
|
- return $result;
|
|
|
280
|
- }
|
|
|
281
|
-
|
|
|
282
|
- /**
|
|
|
283
|
- * 组合人气单品 [
|
|
|
284
|
- * template: text & textNav & goods & floor ||
|
|
|
285
|
- * textNav & goods & floor ||
|
|
|
286
|
- * text & textNav & goods & app_icon_list
|
|
|
287
|
- * ]
|
|
|
288
|
- *
|
|
|
289
|
- * @param string $key
|
|
|
290
|
- * @param array $data
|
|
|
291
|
- * @param string $type
|
|
|
292
|
- * @return array
|
|
|
293
|
- */
|
|
|
294
|
- public static function mergeSinglehotData($key, array &$data, $type)
|
|
|
295
|
- {
|
|
|
296
|
- $result = array();
|
|
|
297
|
- if ((isset($data[$key]) && isset($data[$key + 2])) || (isset($data[$key]) && isset($data[$key + 3])))
|
|
|
298
|
- {
|
|
|
299
|
- $title = '';
|
|
|
300
|
- $source = $goods = $floor = array();
|
|
|
301
|
- if ($data[$key]['template_name'] == 'textNav' && $data[$key + 1]['template_name'] == 'goods'
|
|
|
302
|
- && $data[$key + 2]['template_name'] == 'floor')
|
|
|
303
|
- {
|
|
|
304
|
- $title = '人气单品 TOP100';
|
|
|
305
|
- $source = $data[$key];
|
|
|
306
|
- $goods = $data[$key + 1];
|
|
|
307
|
- $floor = $data[$key + 2];
|
|
|
308
|
- unset($data[$key], $data[$key + 1], $data[$key + 2]);
|
|
|
309
|
- } else if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav'
|
|
|
310
|
- && $data[$key + 2]['template_name'] == 'goods' && $data[$key + 3]['template_name'] == 'floor')
|
|
|
311
|
- {
|
|
|
312
|
- $title = $data[$key]['data']['text'];
|
|
|
313
|
- $source = $data[$key + 1];
|
|
|
314
|
- $goods = $data[$key + 2];
|
|
|
315
|
- $floor = $data[$key + 3];
|
|
|
316
|
- unset($data[$key], $data[$key + 1], $data[$key + 2], $data[$key + 3]);
|
|
|
317
|
- } else if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav'
|
|
|
318
|
- && $data[$key + 2]['template_name'] == 'goods' && $data[$key + 3]['template_name'] == 'app_icon_list')
|
|
|
319
|
- {
|
|
|
320
|
- $title = $data[$key]['data']['text'];
|
|
|
321
|
- $source = $data[$key + 1];
|
|
|
322
|
- $goods = $data[$key + 2];
|
|
|
323
|
- $floor = $data[$key + 3];
|
|
|
324
|
- unset($data[$key], $data[$key + 1], $data[$key + 2], $data[$key + 3]);
|
|
|
325
|
- }
|
|
|
326
|
- if (! empty($source) && ! empty($floor))
|
|
|
327
|
- {
|
|
|
328
|
- $result = array(
|
|
|
329
|
- 'singlehot' => array(
|
|
|
330
|
- 'name' => '',
|
|
|
331
|
- 'imgHot' => array(),
|
|
|
332
|
- 'brands' => array(),
|
|
|
333
|
- 'navs'=> array(),
|
|
|
334
|
- )
|
|
|
335
|
- );
|
|
|
336
|
- // text模版
|
|
|
337
|
- $result['singlehot']['name'] = $title;
|
|
|
338
|
- //textNav模版
|
|
|
339
|
- $result['singlehot']['navs'] = self::mergeNavProcess($source, $type);
|
|
|
340
|
- // goods模版
|
|
|
341
|
- $result['singlehot']['imgHot'] = self::mergeGoodsProcess($goods, $type);
|
|
|
342
|
- // floor模版
|
|
|
343
|
- foreach ($floor['data'] as $val) {
|
|
|
344
|
- $val['src'] = Images::getImageUrl($val['src'], 185, 86, 1);
|
|
|
345
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
346
|
- $result['singlehot']['brands'][] = array(
|
|
|
347
|
- 'href' => $val['url'],
|
|
|
348
|
- 'img' => $val['src'],
|
|
|
349
|
- 'name' => $val['title']
|
|
|
350
|
- );
|
|
|
351
|
- }
|
|
|
352
|
- }
|
|
|
353
|
- }
|
|
|
354
|
- return $result;
|
|
|
355
|
- }
|
|
|
356
|
-
|
|
|
357
|
- /**
|
|
|
358
|
- * 组合人气单品 [template: text & small_pic & floor ]
|
|
|
359
|
- *
|
|
|
360
|
- * @return array
|
|
|
361
|
- */
|
|
|
362
|
- public static function mergeSinglehotData2($key, array &$data, $type)
|
|
|
363
|
- {
|
|
|
364
|
- $result = array();
|
|
|
365
|
- if (isset($data[$key]) && isset($data[$key + 2])) {
|
|
|
366
|
- if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'small_pic'
|
|
|
367
|
- && $data[$key + 2]['template_name'] == 'floor')
|
|
|
368
|
- {
|
|
|
369
|
- $result = array(
|
|
|
370
|
- 'singlehot' => array(
|
|
|
371
|
- 'name' => '',
|
|
|
372
|
- 'imgHot' => array()
|
|
|
373
|
- )
|
|
|
374
|
- );
|
|
|
375
|
- // text
|
|
|
376
|
- $result['singlehot']['name'] = $data[$key]['data']['text'];
|
|
|
377
|
- $len = 10;
|
|
|
378
|
- $list = array();
|
|
|
379
|
- // small_pic
|
|
|
380
|
- foreach ($data[$key + 1]['data'] as &$val) {
|
|
|
381
|
- $w = 378;
|
|
|
382
|
- $h = 248;
|
|
|
383
|
- $val['src'] = Images::getImageUrl($val['src'], $w, $h, 1);
|
|
|
384
|
- }
|
|
|
385
|
- //floor
|
|
|
386
|
- foreach ($data[$key + 2]['data'] as &$val)
|
|
|
387
|
- {
|
|
|
388
|
- $w = 185;
|
|
|
389
|
- $h = 248;
|
|
|
390
|
- $val['src'] = Images::getImageUrl($val['src'], $w, $h, 1);
|
|
|
391
|
- }
|
|
|
392
|
- for ($i = 0; $i < $len; $i ++)
|
|
|
393
|
- {
|
|
|
394
|
- $pos = $i;
|
|
|
395
|
- if ($i == 1)
|
|
|
396
|
- {
|
|
|
397
|
- $val = $data[$key + 1]['data'][0]; // 第二个是大图
|
|
|
398
|
- }
|
|
|
399
|
- else if ($i == $len - 1)
|
|
|
400
|
- {
|
|
|
401
|
- $val = $data[$key + 1]['data'][1]; // 最后一个是大图
|
|
|
402
|
- }
|
|
|
403
|
- else
|
|
|
404
|
- {
|
|
|
405
|
- if ($pos > 1) // 小图
|
|
|
406
|
- {
|
|
|
407
|
- $pos = $pos - 1;
|
|
|
408
|
- }
|
|
|
409
|
- $val = $data[$key + 2]['data'][$pos];
|
|
|
410
|
- }
|
|
|
411
|
-
|
|
|
412
|
- $result['singlehot']['imgHot'][] = array(
|
|
|
413
|
- 'href' => $val['url'],
|
|
|
414
|
- 'img' => $val['src'],
|
|
|
415
|
- 'name' => $val['alt']
|
|
|
416
|
- );
|
|
|
417
|
- }
|
|
|
418
|
- unset($data[$key], $data[$key + 1], $data[$key + 2]);
|
|
|
419
|
- }
|
|
|
420
|
- }
|
|
|
421
|
- return $result;
|
|
|
422
|
- }
|
|
|
423
|
-
|
|
|
424
|
- /**
|
|
|
425
|
- * 组合优选品牌数据 [ template: text & focus & floor]
|
|
|
426
|
- *
|
|
|
427
|
- * @param string $key
|
|
|
428
|
- * @param array $data
|
|
|
429
|
- * @param string $type
|
|
|
430
|
- * @return array
|
|
|
431
|
- */
|
|
|
432
|
- public static function mergePreferenceBrandsData($key, array &$data, $type)
|
|
|
433
|
- {
|
|
|
434
|
- $result = array();
|
|
|
435
|
- if (isset($data[$key]) && isset($data[$key + 2])) {
|
|
|
436
|
- if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'focus'
|
|
|
437
|
- && ($data[$key + 2]['template_name'] == 'floor' ||
|
|
|
438
|
- $data[$key + 2]['template_name'] == 'app_icon_list'))
|
|
|
439
|
- {
|
|
|
440
|
- $result = array(
|
|
|
441
|
- 'preferenceBrands' => array(
|
|
|
442
|
- 'name' => '',
|
|
|
443
|
- 'imgBrand' => array(),
|
|
|
444
|
- 'brandUrl' => ''
|
|
|
445
|
- )
|
|
|
446
|
- );
|
|
|
447
|
- // text模版
|
|
|
448
|
- $result['preferenceBrands']['name'] = $data[$key]['data']['text'];
|
|
|
449
|
- // focus模版
|
|
|
450
|
- foreach ($data[$key + 1]['data'] as $val) {
|
|
|
451
|
- if($type == 'boys') {
|
|
|
452
|
- $width = 378; $height = 175;
|
|
|
453
|
- } else{
|
|
|
454
|
- $width = 320;$height = 430;
|
|
|
455
|
- }
|
|
|
456
|
- $val['src'] = Images::getImageUrl($val['src'], $width, $height, 1);
|
|
|
457
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
458
|
- $result['preferenceBrands']['imgBrand'][] = array(
|
|
|
459
|
- 'href' => $val['url'],
|
|
|
460
|
- 'img' => $val['src']
|
|
|
461
|
- );
|
|
|
462
|
- }
|
|
|
463
|
- // floor模版
|
|
|
464
|
- $floor = array(
|
|
|
465
|
- 'logoBrand' => '',
|
|
|
466
|
- 'moreBrand' => ''
|
|
|
467
|
- );
|
|
|
468
|
- foreach ($data[$key + 2]['data'] as $val) {
|
|
|
469
|
- $width = 185;
|
|
|
470
|
- $height = 86;
|
|
|
471
|
- $val['src'] = Images::getImageUrl($val['src'], $width, $height, 2);
|
|
|
472
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
473
|
- $floor['logoBrand'][] = array(
|
|
|
474
|
- 'href' => $val['url'],
|
|
|
475
|
- 'img' => $val['src']
|
|
|
476
|
- );
|
|
|
477
|
- }
|
|
|
478
|
- // textNav模版
|
|
|
479
|
- if (isset($data[$key + 3]['data'][0]['url']) && $data[$key + 3]['template_name'] == 'textNav') {
|
|
|
480
|
- $floor['moreBrand'] = $data[$key + 3]['data'][0]['url'];
|
|
|
481
|
- unset($data[$key + 3]);
|
|
|
482
|
- }
|
|
|
483
|
- $type_key = sprintf("%s_%s", $type, $key + 2);
|
|
|
484
|
- $cacheKey = sprintf("%s_%s", CacheConfig::KEY_INDEX_BRANDS_LIST_DATA, $type_key);
|
|
|
485
|
- Cache::set($cacheKey, $floor, 7200);
|
|
|
486
|
- $result['preferenceBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key;
|
|
|
487
|
- unset($data[$key], $data[$key + 1], $data[$key + 2]);
|
|
|
488
|
- }
|
|
|
489
|
- }
|
|
|
490
|
- return $result;
|
|
|
491
|
- }
|
|
|
492
|
-
|
|
|
493
|
- /**
|
|
|
494
|
- * 组合girlkids数据 [ template: text & textNav & goods]
|
|
|
495
|
- *
|
|
|
496
|
- * @param string $key
|
|
|
497
|
- * @param array $data
|
|
|
498
|
- * @param string $type
|
|
|
499
|
- * @return array
|
|
|
500
|
- */
|
|
|
501
|
- public static function mergeGirlkidsData($key, array &$data, $type)
|
|
|
502
|
- {
|
|
|
503
|
- $result = array();
|
|
|
504
|
- if (isset($data[$key]) && isset($data[$key + 2]))
|
|
|
505
|
- {
|
|
|
506
|
- if ($data[$key]['template_name'] == 'text' && $data[$key + 2]['template_name'] == 'goods')
|
|
|
507
|
- {
|
|
|
508
|
- $result = array(
|
|
|
509
|
- 'girlkids' => array(
|
|
|
510
|
- 'name' => '',
|
|
|
511
|
- 'imgHot' => array()
|
|
|
512
|
- )
|
|
|
513
|
- );
|
|
|
514
|
- // text
|
|
|
515
|
- $result['girlkids']['name'] = $data[$key]['data']['text'];
|
|
|
516
|
-
|
|
|
517
|
- // goods
|
|
|
518
|
- $result['girlkids']['imgHot'] = self::mergeGoodsProcess($data[$key + 2], $type);
|
|
|
519
|
- unset($data[$key], $data[$key + 1], $data[$key + 2]);
|
|
|
520
|
- }
|
|
|
521
|
- }
|
|
|
522
|
-
|
|
|
523
|
- return $result;
|
|
|
524
|
- }
|
|
|
525
|
-
|
|
|
526
|
- /**
|
|
|
527
|
- * 组合accordion数据 [ template: text & textNav & focus ]
|
|
|
528
|
- *
|
|
|
529
|
- * @param string $key
|
|
|
530
|
- * @param array $data
|
|
|
531
|
- * @param string $type
|
|
|
532
|
- * @return array
|
|
|
533
|
- */
|
|
|
534
|
- public static function mergeAccordionData($key, array &$data, $type)
|
|
|
535
|
- {
|
|
|
536
|
- $result = array();
|
|
|
537
|
- if (isset($data[$key]) && isset($data[$key + 2]))
|
|
|
538
|
- {
|
|
|
539
|
- if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav'
|
|
|
540
|
- && $data[$key + 2]['template_name'] == 'focus')
|
|
|
541
|
- {
|
|
|
542
|
- $result = array(
|
|
|
543
|
- 'accordion' => array(
|
|
|
544
|
- 'name' => '',
|
|
|
545
|
- 'navs' => array(),
|
|
|
546
|
- 'slide' => array()
|
|
|
547
|
- )
|
|
|
548
|
- );
|
|
|
549
|
- $result['accordion']['name'] = $data[$key]['data']['text'];
|
|
|
550
|
-
|
|
|
551
|
- // textNav模版
|
|
|
552
|
- if (! empty($data[$key + 1]['data'])) {
|
|
|
553
|
- $result['accordion']['navs'] = self::mergeNavProcess($data[$key + 1], $type);
|
|
|
554
|
- }
|
|
|
555
|
-
|
|
|
556
|
- // focus模版
|
|
|
557
|
- foreach ($data[$key + 2]['data'] as $val) {
|
|
|
558
|
- $val['src'] = Images::getImageUrl($val['src'], 650, 400, 1);
|
|
|
559
|
- $result['accordion']['slide'][] = array(
|
|
|
560
|
- 'href' => $val['url'],
|
|
|
561
|
- 'img' => $val['src'],
|
|
|
562
|
- 'name' => $val['title']
|
|
|
563
|
- );
|
|
|
564
|
- }
|
|
|
565
|
- unset($data[$key], $data[$key + 1], $data[$key + 2]);
|
|
|
566
|
- }
|
|
|
567
|
- }
|
|
|
568
|
-
|
|
|
569
|
- return $result;
|
|
|
570
|
- }
|
|
|
571
|
-
|
|
|
572
|
- /**
|
|
|
573
|
- * 组合boys最新速报数据 [ template: text & single_image & floor & single_image]
|
|
|
574
|
- *
|
|
|
575
|
- * @param string $key
|
|
|
576
|
- * @param array $data
|
|
|
577
|
- * @param string $type
|
|
|
578
|
- * @return array
|
|
|
579
|
- */
|
|
|
580
|
- public static function mergeNewReportData($key, array &$data, $type)
|
|
|
581
|
- {
|
|
|
582
|
- $result = array();
|
|
|
583
|
- if (isset($data[$key]) && isset($data[$key + 3]))
|
|
|
584
|
- {
|
|
|
585
|
- if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'single_image'
|
|
|
586
|
- && $data[$key + 2]['template_name'] == 'floor' &&
|
|
|
587
|
- $data[$key + 3]['template_name'] == 'single_image')
|
|
|
588
|
- {
|
|
|
589
|
- $result = array(
|
|
|
590
|
- 'newReport' => array(
|
|
|
591
|
- 'name' => '',
|
|
|
592
|
- 'list' => array()
|
|
|
593
|
- )
|
|
|
594
|
- );
|
|
|
595
|
- // text
|
|
|
596
|
- $result['newReport']['name'] = $data[$key]['data']['text'];
|
|
|
597
|
- // single_image & floor & single_image
|
|
|
598
|
- $list = array_merge($data[$key + 1]['data'], array_slice($data[$key + 2]['data'], 0, 6), $data[$key + 3]['data']);
|
|
|
599
|
- foreach ($list as $listKey => $val) {
|
|
|
600
|
- $width = 185;
|
|
|
601
|
- $height = 248;
|
|
|
602
|
- $w = 377;
|
|
|
603
|
- $h = 504;
|
|
|
604
|
- if ($listKey == 0 || $listKey == 7) {
|
|
|
605
|
- $val['src'] = Images::getImageUrl($val['src'], $w, $h, 1);
|
|
|
606
|
- $result['newReport']['list'][] = array(
|
|
|
607
|
- 'href' => $val['url'],
|
|
|
608
|
- 'img' => $val['src']
|
|
|
609
|
- );
|
|
|
610
|
- } else {
|
|
|
611
|
- $val['src'] = Images::getImageUrl($val['src'], $width, $height, 1);
|
|
|
612
|
- $result['newReport']['list'][] = array(
|
|
|
613
|
- 'href' => $val['url'],
|
|
|
614
|
- 'img' => $val['src']
|
|
|
615
|
- );
|
|
|
616
|
- }
|
|
|
617
|
- }
|
|
|
618
|
- unset($data[$key], $data[$key + 1], $data[$key + 2], $data[$key + 3]);
|
|
|
619
|
- }
|
|
|
620
|
- }
|
|
|
621
|
- return $result;
|
|
|
622
|
- }
|
|
|
623
|
-
|
|
|
624
|
- /**
|
|
|
625
|
- * 组合category数据 [template: text & textNav & floor ]
|
|
|
626
|
- *
|
|
|
627
|
- * @param array $data
|
|
|
628
|
- * @param string $type
|
|
|
629
|
- * @return array
|
|
|
630
|
- */
|
|
|
631
|
- public static function mergeCategoryData($key, array &$data, $type)
|
|
|
632
|
- {
|
|
|
633
|
- $result = array();
|
|
|
634
|
- if (isset($data[$key]) && isset($data[$key + 2])) {
|
|
|
635
|
- if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav'
|
|
|
636
|
- && $data[$key + 2]['template_name'] == 'floor') {
|
|
|
637
|
- $result = array(
|
|
|
638
|
- 'category' => array(
|
|
|
639
|
- 'name' => '',
|
|
|
640
|
- 'navs' => array(),
|
|
|
641
|
- 'list' => array()
|
|
|
642
|
- )
|
|
|
643
|
- );
|
|
|
644
|
- // text模版
|
|
|
645
|
- $result['category']['name'] = $data[$key]['data']['text'];
|
|
|
646
|
-
|
|
|
647
|
- // textNav模版
|
|
|
648
|
- if (! empty($data[$key + 1]['data'])) {
|
|
|
649
|
- $result['category']['navs'] = self::mergeNavProcess($data[$key + 1], $type);
|
|
|
650
|
- }
|
|
|
651
|
- // floor模版
|
|
|
652
|
- foreach ($data[$key + 2]['data'] as $pos => $val) {
|
|
|
653
|
- $width = 185; $height = 510;
|
|
|
654
|
- if($pos == 1) {
|
|
|
655
|
- $width = 377; $height = 504;
|
|
|
656
|
- }
|
|
|
657
|
- $val['src'] = Images::getImageUrl($val['src'], $width, $height, 2);
|
|
|
658
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
659
|
- $result['category']['list'][] = array(
|
|
|
660
|
- 'href' => $val['url'],
|
|
|
661
|
- 'img' => $val['src'],
|
|
|
662
|
- 'name' => $val['title']
|
|
|
663
|
- );
|
|
|
664
|
- }
|
|
|
665
|
- unset($data[$key], $data[$key + 1], $data[$key + 2]);
|
|
|
666
|
- }
|
|
|
667
|
- }
|
|
|
668
|
-
|
|
|
669
|
- return $result;
|
|
|
670
|
- }
|
|
|
671
|
-
|
|
|
672
|
- /**
|
|
|
673
|
- * 组合HotCategory数据 [template: hotCategory & floor] 首页使用
|
|
|
674
|
- *
|
|
|
675
|
- * @param string $key
|
|
|
676
|
- * @param array $data
|
|
|
677
|
- * @param string $type
|
|
|
678
|
- * @return array
|
|
|
679
|
- */
|
|
|
680
|
- public static function mergeHotCategoryData($key, &$data, $type)
|
|
|
681
|
- {
|
|
|
682
|
- $result = array();
|
|
|
683
|
- if (isset($data[$key]) && isset($data[$key + 1]))
|
|
|
684
|
- {
|
|
|
685
|
- if ($data[$key]['template_name'] == 'hotCategory' && $data[$key + 1]['template_name'] == 'floor')
|
|
|
686
|
- {
|
|
|
687
|
- $result = array(
|
|
|
688
|
- 'name' => '',
|
|
|
689
|
- 'navs' => array(),
|
|
|
690
|
- 'tplrecommend' => array(
|
|
|
691
|
- 'keyword' => array(),
|
|
|
692
|
- 'category' => array(),
|
|
|
693
|
- 'brands' => array(),
|
|
|
694
|
- 'types' => array(),
|
|
|
695
|
- 'products' => array()
|
|
|
696
|
- )
|
|
|
697
|
- );
|
|
|
698
|
- // hotCategory模版
|
|
|
699
|
- $temp = self::hotCategory($data[$key], $type);
|
|
|
700
|
- $temp = $temp['recommend'];
|
|
|
701
|
- $result['name'] = $temp['name'];
|
|
|
702
|
- $result['navs'] = $temp['navs'];
|
|
|
703
|
- $result['tplrecommend']['keyword'] = $temp['tplrecommend']['keyword'];
|
|
|
704
|
- $result['tplrecommend']['category'] = $temp['tplrecommend']['category'];
|
|
|
705
|
- foreach ($data[$key]['data']['imgs'] as $key2 => $val)
|
|
|
706
|
- {
|
|
|
707
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
708
|
- if ($key2 == 0 || $key2 == 4) // 两个大图
|
|
|
709
|
- {
|
|
|
710
|
- $val['img'] = Images::getImageUrl($val['img'], 378, 248, 1); // 大图
|
|
|
711
|
- $result['tplrecommend']['brands'][] = array(
|
|
|
712
|
- 'href' => $val['url'],
|
|
|
713
|
- 'name' => $val['title'],
|
|
|
714
|
- 'img' => $val['img']
|
|
|
715
|
- );
|
|
|
716
|
- } else {
|
|
|
717
|
- $val['img'] = Images::getImageUrl($val['img'], 185, 248, 1); // 小图
|
|
|
718
|
- $result['tplrecommend']['types'][] = array(
|
|
|
719
|
- 'href' => $val['url'],
|
|
|
720
|
- 'name' => $val['title'],
|
|
|
721
|
- 'img' => $val['img']
|
|
|
722
|
- );
|
|
|
723
|
- }
|
|
|
724
|
- }
|
|
|
725
|
-
|
|
|
726
|
- // floor模版
|
|
|
727
|
- foreach ($data[$key + 1]['data'] as $val)
|
|
|
728
|
- {
|
|
|
729
|
- $val['src'] = Images::getImageUrl($val['src'], 222, 298, 1); // 小图
|
|
|
730
|
- $result['tplrecommend']['products'][] = array(
|
|
|
731
|
- 'href' => $val['url'],
|
|
|
732
|
- 'name' => $val['title'],
|
|
|
733
|
- 'img' => $val['src']
|
|
|
734
|
- );
|
|
|
735
|
- }
|
|
|
736
|
- unset($data[$key], $data[$key + 1]);
|
|
|
737
|
- $result = array(
|
|
|
738
|
- 'recommend' => $result
|
|
|
739
|
- );
|
|
|
740
|
- }
|
|
|
741
|
- }
|
|
|
742
|
-
|
|
|
743
|
- return $result;
|
|
|
744
|
- }
|
|
|
745
|
-
|
|
|
746
|
- /**
|
|
|
747
|
- * 组合之nav处理
|
|
|
748
|
- *
|
|
|
749
|
- * @param array $data
|
|
|
750
|
- * @param string $type
|
|
|
751
|
- * @return array
|
|
|
752
|
- */
|
|
|
753
|
- public static function mergeNavProcess(array $data, $type)
|
|
|
754
|
- {
|
|
|
755
|
- $result = array();
|
|
|
756
|
- foreach ($data['data'] as $val) {
|
|
|
757
|
- if (empty($val))
|
|
|
758
|
- continue;
|
|
|
759
|
- $result[] = array(
|
|
|
760
|
- 'href' => $val['url'],
|
|
|
761
|
- 'name' => $val['name']
|
|
|
762
|
- );
|
|
|
763
|
- }
|
|
|
764
|
- return $result;
|
|
|
765
|
- }
|
|
|
766
|
-
|
|
|
767
|
- /**
|
|
|
768
|
- * 组合之商品处理
|
|
|
769
|
- *
|
|
|
770
|
- * @param array $data
|
|
|
771
|
- * @param string $type
|
|
|
772
|
- * @return array
|
|
|
773
|
- */
|
|
|
774
|
- public static function mergeGoodsProcess(array $data, $type)
|
|
|
775
|
- {
|
|
|
776
|
- $result = array();
|
|
|
777
|
- $skns = '';
|
|
|
778
|
- foreach ($data['data'] as $val) {
|
|
|
779
|
- $skns .= $val['id'] . ' ';
|
|
|
780
|
- }
|
|
|
781
|
- $params = array(
|
|
|
782
|
- 'query' => rtrim($skns),
|
|
|
783
|
- 'client_type' => 'web'
|
|
|
784
|
- );
|
|
|
785
|
- $goodsList = SearchData::searchElasticByCondition($params, false);
|
|
|
786
|
- $goodsList = $goodsList['data']['product_list'];
|
|
|
787
|
- $pos = 0;
|
|
|
788
|
- foreach ($goodsList as $goods)
|
|
|
789
|
- {
|
|
|
790
|
- $oneGoods = array();
|
|
|
791
|
- $pos ++;
|
|
|
792
|
- if ($pos > 12) {
|
|
|
793
|
- break;
|
|
|
794
|
- }
|
|
|
795
|
- if (empty($goods)) {
|
|
|
796
|
- continue;
|
|
|
797
|
- }
|
|
|
798
|
- $oneGoods['img'] = Images::getImageUrl($goods['goods_list'][0]['images_url'], 280, 373, 1);
|
|
|
799
|
- $oneGoods['name'] = $goods['product_name'];
|
|
|
800
|
- $oneGoods['price'] = $goods['sales_price'];
|
|
|
801
|
- $url = 'http://item.yohobuy.com/product/pro_' .
|
|
|
802
|
- $goods['product_id'] . '_' . $goods['goods_list'][0]['goods_id']
|
|
|
803
|
- . '/' . $goods['cn_alphabet'] . '.html';
|
|
|
804
|
- $oneGoods['href'] = Helpers::transUrl($url, $type);
|
|
|
805
|
- $result[$goods['product_skn']] = $oneGoods;
|
|
|
806
|
- }
|
|
|
807
|
-
|
|
|
808
|
- // 排序
|
|
|
809
|
- uksort($result, function ($a, $b) use($skns) {
|
|
|
810
|
- $skn_arr = explode(' ', $skns);
|
|
|
811
|
- return array_search($a, $skn_arr) > array_search($b, $skn_arr);
|
|
|
812
|
- });
|
|
|
813
|
- $pos = 1;
|
|
|
814
|
- //添加TOP标示
|
|
|
815
|
- foreach($result as &$val) {
|
|
|
816
|
- if($pos < 4) {
|
|
|
817
|
- $val['tip'] = 'TOP'.$pos;
|
|
|
818
|
- }
|
|
|
819
|
- else {
|
|
|
820
|
- break;
|
|
|
821
|
- }
|
|
|
822
|
- $pos ++;
|
|
|
823
|
- }
|
|
|
824
|
- return $result;
|
|
|
825
|
- }
|
|
|
826
|
-
|
|
|
827
|
- /**
|
|
|
828
|
- * 热门品牌数据处理
|
|
|
829
|
- *
|
|
|
830
|
- * @param array $data
|
|
|
831
|
- * @param string $type
|
|
|
832
|
- */
|
|
|
833
|
- public static function mergeHotBrandsData($key,array &$data,$type)
|
|
|
834
|
- {
|
|
|
835
|
- $result = array();
|
|
|
836
|
- $temp = array();
|
|
|
837
|
- if ($data[$key]['template_name'] == 'custom_brands' || $data[$key]['template_name'] == 'kids_brands')
|
|
|
838
|
- {
|
|
|
839
|
- $result = array(
|
|
|
840
|
- 'hotBrands' => array(
|
|
|
841
|
- 'name' => '',
|
|
|
842
|
- 'brandUrl' => ''
|
|
|
843
|
- )
|
|
|
844
|
- );
|
|
|
845
|
- // text模版
|
|
|
846
|
- $result['hotBrands']['name'] = '热门品牌';
|
|
|
847
|
- //floor模板
|
|
|
848
|
- $floor = array(
|
|
|
849
|
- 'logoBrand' => '',
|
|
|
850
|
- 'moreBrand' => ''
|
|
|
851
|
- );
|
|
|
852
|
-
|
|
|
853
|
- $brands = $data[$key]['data']['list'];
|
|
|
854
|
- foreach ($brands as $val)
|
|
|
855
|
- {
|
|
|
856
|
- $width = 185;
|
|
|
857
|
- $height = 86;
|
|
|
858
|
- $val['src'] = Images::getImageUrl($val['src'], $width, $height, 2);
|
|
|
859
|
- $val['url'] = Helpers::transUrl($val['url'], $type);
|
|
|
860
|
- $floor['logoBrand'][] = array(
|
|
|
861
|
- 'href' => $val['url'],
|
|
|
862
|
- 'img' => $val['src']
|
|
|
863
|
- );
|
|
|
864
|
- }
|
|
|
865
|
- $floor['moreBrand'] = 'http://yohobuy.com/brands';
|
|
|
866
|
- $type_key = sprintf("%s_%s", $type, $key);
|
|
|
867
|
- $cacheKey = sprintf("%s_%s", CacheConfig::KEY_INDEX_BRANDS_LIST_DATA, $type_key);
|
|
|
868
|
- Cache::set($cacheKey, $floor, 7200);
|
|
|
869
|
- $result['hotBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key;
|
|
|
870
|
- }
|
|
|
871
|
- return $result;
|
|
|
872
|
- }
|
|
|
873
|
-
|
|
|
874
|
-} |
|
|