1
|
<?php
|
1
|
<?php
|
|
|
2
|
+
|
2
|
namespace Product;
|
3
|
namespace Product;
|
3
|
|
4
|
|
4
|
use Plugin\Helpers;
|
5
|
use Plugin\Helpers;
|
|
|
6
|
+use Plugin\HelperSearch;
|
5
|
use LibModels\Web\Product\BrandData;
|
7
|
use LibModels\Web\Product\BrandData;
|
6
|
use LibModels\Wap\Product\SearchData;
|
8
|
use LibModels\Wap\Product\SearchData;
|
7
|
use LibModels\Web\Product\SearchData as WebProduct;
|
9
|
use LibModels\Web\Product\SearchData as WebProduct;
|
|
@@ -11,15 +13,14 @@ use LibModels\Web\Product\SearchData as WebProduct; |
|
@@ -11,15 +13,14 @@ use LibModels\Web\Product\SearchData as WebProduct; |
11
|
*
|
13
|
*
|
12
|
* @author Administrator
|
14
|
* @author Administrator
|
13
|
*/
|
15
|
*/
|
14
|
-class BrandsModel
|
|
|
15
|
-{
|
16
|
+class BrandsModel {
|
16
|
|
17
|
|
17
|
const URL_BRAND_INDEX = '/product/index/brand';
|
18
|
const URL_BRAND_INDEX = '/product/index/brand';
|
18
|
-
|
19
|
+
|
19
|
public static $shopName;
|
20
|
public static $shopName;
|
20
|
public static $home;
|
21
|
public static $home;
|
21
|
-
|
|
|
22
|
- /**
|
22
|
+
|
|
|
23
|
+ /**
|
23
|
* 搜索品牌数据
|
24
|
* 搜索品牌数据
|
24
|
*
|
25
|
*
|
25
|
* @param $condition array
|
26
|
* @param $condition array
|
|
@@ -27,38 +28,59 @@ class BrandsModel |
|
@@ -27,38 +28,59 @@ class BrandsModel |
27
|
* @param $options array
|
28
|
* @param $options array
|
28
|
* @return array
|
29
|
* @return array
|
29
|
*/
|
30
|
*/
|
30
|
- public static function getBrandSearchData($condition, $options,$domain,$uid,$brandId)
|
|
|
31
|
- {
|
|
|
32
|
-
|
31
|
+ public static function getBrandSearchData($condition, $options, $domain, $uid, $brandId) {
|
|
|
32
|
+
|
33
|
// 调用商品搜索接口
|
33
|
// 调用商品搜索接口
|
34
|
$data = SearchData::searchElasticByCondition($condition);
|
34
|
$data = SearchData::searchElasticByCondition($condition);
|
|
|
35
|
+ //获取品牌banner数据
|
|
|
36
|
+ $banner = self::getBannerByDomain($domain, $brandId, $uid = '');
|
35
|
|
37
|
|
36
|
- //导航名
|
|
|
37
|
- $brandName = self::$shopName;
|
|
|
38
|
- $option['brandName'] = $brandName;
|
|
|
39
|
-
|
|
|
40
|
- //配置调用分类接口参数
|
|
|
41
|
- $param = array();
|
|
|
42
|
- $param['brand'] = $condition['brand'];
|
|
|
43
|
- //获取分类列表数据
|
|
|
44
|
- $classes = WebProduct::getClassesData($param);
|
|
|
45
|
-
|
38
|
+ if (isset($data['code']) && $data['code'] === 200) {
|
|
|
39
|
+ //获取分类列表数据
|
|
|
40
|
+ $param = array();
|
|
|
41
|
+ $param['brand'] = $condition['brand'];
|
|
|
42
|
+ $classes = WebProduct::getClassesData($param);
|
|
|
43
|
+ if (isset($classes['code']) && $classes['code'] === 200) {
|
|
|
44
|
+ $data['data']['filter']['group_sort'] = $classes['data']['sort'];
|
|
|
45
|
+ }
|
|
|
46
|
+
|
|
|
47
|
+ $brandName = self::$shopName;
|
|
|
48
|
+ $options['brandName'] = $brandName;
|
|
|
49
|
+
|
|
|
50
|
+
|
|
|
51
|
+ //用户浏览记录
|
|
|
52
|
+
|
|
|
53
|
+ // 组织模板数据
|
|
|
54
|
+ $list = HelperSearch::getList($data, $options);
|
|
|
55
|
+
|
|
|
56
|
+ //合并商品搜索数据与品牌banner数据
|
|
|
57
|
+ $data = array_merge_recursive($data, $banner);
|
|
|
58
|
+
|
|
|
59
|
+ $data = array(
|
|
|
60
|
+ //初始化js
|
|
|
61
|
+ 'productListPage' => true,
|
|
|
62
|
+ 'list' => $list
|
|
|
63
|
+ );
|
|
|
64
|
+ } else {
|
|
|
65
|
+ $data = array();
|
|
|
66
|
+ }
|
|
|
67
|
+
|
46
|
|
68
|
|
|
|
69
|
+
|
|
|
70
|
+
|
47
|
//获取品牌系列数据
|
71
|
//获取品牌系列数据
|
48
|
$adNav = self::getAdNav($condition['brand']);
|
72
|
$adNav = self::getAdNav($condition['brand']);
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
- //获取品牌数据
|
|
|
52
|
- $banner = self::getBannerByDomain($domain, $brandId, $uid = '');
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
- //开始组装数据
|
|
|
56
|
-
|
|
|
57
|
-
|
73
|
+ $data['list']['leftContent'][] = array('picLink' => $adNav);
|
|
|
74
|
+
|
|
|
75
|
+
|
|
|
76
|
+
|
|
|
77
|
+
|
|
|
78
|
+
|
|
|
79
|
+
|
|
|
80
|
+
|
58
|
return $data;
|
81
|
return $data;
|
59
|
}
|
82
|
}
|
60
|
-
|
|
|
61
|
-
|
83
|
+
|
62
|
/**
|
84
|
/**
|
63
|
* 获取品牌首页banner条
|
85
|
* 获取品牌首页banner条
|
64
|
* @string $domain 品牌域名
|
86
|
* @string $domain 品牌域名
|
|
@@ -67,8 +89,7 @@ class BrandsModel |
|
@@ -67,8 +89,7 @@ class BrandsModel |
67
|
*
|
89
|
*
|
68
|
* @return array 品牌banner条数据
|
90
|
* @return array 品牌banner条数据
|
69
|
*/
|
91
|
*/
|
70
|
- public static function getBannerByDomain($domain, $brandId, $uid = '')
|
|
|
71
|
- {
|
92
|
+ public static function getBannerByDomain($domain, $brandId, $uid = '') {
|
72
|
// 构造品牌主页url
|
93
|
// 构造品牌主页url
|
73
|
self::$home = Helpers::url('', '', $domain) . self::URL_BRAND_INDEX;
|
94
|
self::$home = Helpers::url('', '', $domain) . self::URL_BRAND_INDEX;
|
74
|
// 根据品牌Id获取品牌banner图
|
95
|
// 根据品牌Id获取品牌banner图
|
|
@@ -83,9 +104,9 @@ class BrandsModel |
|
@@ -83,9 +104,9 @@ class BrandsModel |
83
|
$is_favorite = false;
|
104
|
$is_favorite = false;
|
84
|
$logo = false;
|
105
|
$logo = false;
|
85
|
$shopName = false;
|
106
|
$shopName = false;
|
86
|
-
|
107
|
+
|
87
|
do {
|
108
|
do {
|
88
|
- if (! isset($intro['data'])) {
|
109
|
+ if (!isset($intro['data'])) {
|
89
|
break;
|
110
|
break;
|
90
|
}
|
111
|
}
|
91
|
// 获取是否收藏
|
112
|
// 获取是否收藏
|
|
@@ -99,7 +120,7 @@ class BrandsModel |
|
@@ -99,7 +120,7 @@ class BrandsModel |
99
|
// 获取品牌名
|
120
|
// 获取品牌名
|
100
|
self::$shopName = $intro['data']['brand_name'];
|
121
|
self::$shopName = $intro['data']['brand_name'];
|
101
|
} while (false);
|
122
|
} while (false);
|
102
|
-
|
123
|
+
|
103
|
// 返回banner数据
|
124
|
// 返回banner数据
|
104
|
return array(
|
125
|
return array(
|
105
|
'list' => array(
|
126
|
'list' => array(
|
|
@@ -127,22 +148,18 @@ class BrandsModel |
|
@@ -127,22 +148,18 @@ class BrandsModel |
127
|
);
|
148
|
);
|
128
|
}
|
149
|
}
|
129
|
|
150
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
//获取品牌系列数据
|
151
|
//获取品牌系列数据
|
133
|
- public static function getAdNav($brandId,$status = 1)
|
|
|
134
|
- {//$condition['brand']
|
152
|
+ public static function getAdNav($brandId, $status = 1) {
|
135
|
//调用接口获得数据
|
153
|
//调用接口获得数据
|
136
|
- $advNav = BrandData::getFolderByBrand($brandId,$status);
|
154
|
+ $advNav = BrandData::getFolderByBrand($brandId, $status);
|
137
|
$result = array();
|
155
|
$result = array();
|
138
|
if (isset($advNav['data']) && $advNav['code'] === 200) {
|
156
|
if (isset($advNav['data']) && $advNav['code'] === 200) {
|
139
|
foreach ($advNav['data'] as $key => $value) {
|
157
|
foreach ($advNav['data'] as $key => $value) {
|
140
|
- $result['list'][$key]['href'] = self::$home . '?folder=' . $value['id'];
|
158
|
+ $result['list'][$key]['href'] = self::$home . '?folder_id=' . $value['id'];
|
141
|
$result['list'][$key]['src'] = $value['brand_sort_ico'];
|
159
|
$result['list'][$key]['src'] = $value['brand_sort_ico'];
|
142
|
}
|
160
|
}
|
143
|
}
|
161
|
}
|
144
|
return $result;
|
162
|
return $result;
|
145
|
- //$data['list']['advNav'] = $result;
|
|
|
146
|
}
|
163
|
}
|
147
|
-
|
164
|
+
|
148
|
} |
165
|
} |