Brand.class.php
8.8 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<?php
/**
* 品牌
*
* @name Facade_Brand
* @version 1.0 (2013-5-27)
* @package Facade/Brand
* @author hbomb
* @since 1.0
*/
class Facade_Brand
{
private static $service = null;
/**
* 返回service对象
*
* @return Service_Brand_Brand
*/
public static function service()
{
if (null === self::$service)
{
self::$service = new Service_Brand();
}
return self::$service;
}
/**
* 获取品牌
*
* @param unknown_type $offset
* @param unknown_type $limit
* @param unknown_type $status
* @return Ambigous <multitype:, Util_Dao_Db_PdoQuery>
*/
public static function getBrandByState ($offset, $limit, $state)
{
return self::service()->getBrandByState($offset, $limit, $state);
}
/**
* 根据状态获取所有品牌个数. 用于前端分页
*
* @param $status
*/
public static function getBrandTotal ($state)
{
return self::service()->getBrandTotal($state);
}
/**
* 根据id更新品牌状态. 用于管理员更新一个品牌的操作.
* @param string $id
* @param string $name
* @param string $logo
* @param string $description
* @param string $state
* @param string $pics
* @param string $person
* @param string $seq
* @param string $news_ids
* @param int $boothId
* @param string $link
* @return boolean
*/
public static function updateBrand ($id, $name,$logo,$description,$state,$pics,$person,$seq,$news_ids, $boothId, $link)
{
return self::service()->updateBrand($id, $name, $logo, $description, $state, $pics, $person, $seq, $news_ids, $boothId, $link);
}
/**
* 用户提交品牌.
* @param string $name
* @param string $logo
* @param string $description
* @param string $pics
* @param string $person
* @param string $news_ids
* @param string $seq
* @param string $state
* @param int $boothId
* @param string $link
* @return int
*/
public static function submitBrand ($name,$logo,$description,$state,$pics,$person,$seq, $news_ids, $boothId, $link)
{
return self::service()->submitBrand($name, $logo, $description, $pics, $person, $news_ids, $seq, $state, $boothId, $link);
}
/**
* 根据ID获取品牌
* @param unknown_type $id
* @return Ambigous <multitype:, Util_Dao_Db_PdoQuery>
*/
public static function getBrandbyID($id)
{
return self::service()->getBrandbyID($id);
}
/**
* 设置booth
*
* @param string $booth_id
* @param string $position
* @return boolean
*/
public static function setBooth($booth_id, $position)
{
return self::service()->setBooth($booth_id, $position);
}
/**
* 获取booth
*
* @return array
*/
public static function getBoothList()
{
return self::service()->getBoothList();
}
/**
* 删除booth
*
* @return bolean
*/
public static function delBooth($booth_id)
{
return self::service()->delBooth($booth_id);
}
/**
* 获取签到布局
*
* @return array
*/
public static function getSignLayout()
{
$key = 'yohood_sign_layout_v1';
$result = array();
$result = Lib_Utils_Cache_Data::get($key);
if(empty($result))
{
$layoutList = self::service()->getSignLayoutList();
$picList = self::service()->getSignPicList();
$positions = self::getSignPosition();
foreach($layoutList as $layout)
{
$place = $layout['place'];
$picId = $layout['pic_id'];
$image = $picList[$picId]['pic'];
$picSignPositon = array();
foreach($positions as $position)
{
if($position['imageId'] == $picId)
{
$picSignPositon [] = $position;
}
}
if(isset($result[$place]))
{
$result[$place]['images'][] = array('id' => $picId, 'image'=> $image, 'boothList'=> $picSignPositon, 'place'=> $place);
}
else
{
$result[$place] = array('place'=> $place, 'images'=> array(array('id'=> $picId, 'image'=> $image, 'boothList'=> $picSignPositon, 'place'=> $place)));
}
}
Lib_Utils_Cache_Data::set($key, $result);
}
return $result;
}
/**
* 获取签到坐标
*
* @return array
*/
public static function getSignPosition()
{
$positions = self::service()->getSignPosition();
$result = array();
$picList = self::service()->getSignPicList();
$signBrands = self::service()->getSignBrand();
$brands = self::service()->getBrand();
foreach($positions as $position)
{
$width = (float) $picList[$position['pic_id']]['width'];
$height = (float) $picList[$position['pic_id']]['height'];
$bias = array('android' => array('x' => 50, 'y'=> 70 + 245), 'ios' => array('x' => 32, 'y'=> 52 + 245));
if(preg_match('/(java .+)/isU', $_SERVER['HTTP_USER_AGENT']))
{
$platform = 'android';
}
else
{
$platform = 'ios';
}
$x = $position['x'] - $bias[$platform]['x'];
$y = $position['y'] - $bias[$platform]['y'];
foreach($signBrands as $signBrand)
{
$position['booth_id'] = trim($position['booth_id']);
$signBrand['booth_id'] = trim($signBrand['booth_id']);
$ret = array();
if($signBrand['brand_name'] == '潮流市集' || $signBrand['brand_name'] == 'BE@RBRICK展区')
{
if($signBrand['brand_name'] == '潮流市集')
{
$ret = array('brand_name' => '潮流市集', 'url' => SITE_MAIN, 'image'=> SITE_IMG.'/yohood/sign_market_logo.png');
}
else
{
$ret = array('brand_name' => 'BE@RBRICK展区', 'url' => SITE_MAIN, 'image'=> SITE_IMG.'/yohood/sign_block_logo.jpg');
}
}
else
{
foreach($brands as $brand)
{
if( trim(strtolower($signBrand['brand_name'])) == trim(strtolower($brand['name'])))
{
$ret = $brand;
break;
}
}
if(empty($ret))
{
continue;
}
$styles = json_decode($ret['pics'], true);
$ret['image'] = '';
$ret['url'] = SITE_MAIN.'/brand/detail/id/'.$ret['id'];
foreach($styles as $style)
{
if($style['type'] == 'pic')
{
$ret['image'] = Lib_Images::getImageUrl($style['url'], 'source','fragmentimg');
}
else
{
$ret['image'] = Lib_Video::getVideoUrl($style['url']);
}
}
}
if($signBrand['booth_id'] == $position['booth_id'])
{
$result[] = array('id'=> $signBrand['brand_id'], 'x' => strval( $x / $width), 'brandName'=> $signBrand['brand_name'], 'tag' => strval(intval(crc32($position['booth_id'])/10000)),
'brandImage' => $ret['image'],'brandUrl'=> $ret['url'],'y'=> strval($y / $height), 'imageId' => $position['pic_id']);
}
}
}
return $result;
}
/**
* 获取签到品牌
*
* @return array
*/
public static function getSignBrand()
{
return self::service()->getSignBrand();
}
/**
* 获取有货品牌
*
* @return array
*/
public static function getYohobuyBrand()
{
return self::service()->getYohobuyBrand();
}
/**
* 设置品牌和资讯对应关系
*
* @param int $news_id
* @param int $brand_id
* @return boolean
*/
public static function setBrandNewsRela($news_id, $brand_id)
{
return self::service()->setBrandNewsRela($news_id, $brand_id);
}
/**
* 根据news_id获取品牌和资讯对应关系
*
* @param int|array $news_id
* @return array
*/
public static function getBrandNewsRelaByNewsID($news_id)
{
return self::service()->getBrandNewsRelaByNewsID($news_id);
}
/**
* 根据brand_id获取品牌和资讯对应关系
*
* @param int|array $brand_id
* @return array
*/
public static function getBrandNewsRelaByBrandID($brand_id)
{
return self::service()->getBrandNewsRelaByBrandID($brand_id);
}
/**
* 根据news_id删除品牌和资讯对应关系
*
* @param int $news_id
* @return array
*/
public static function deleteBrandNewsRelaByNewsID($news_id)
{
return self::service()->deleteBrandNewsRelaByNewsID($news_id);
}
/**
* 根据名称获取品牌列表
*
* @param string $name
* @param int $state
* @return array
*/
public static function getBrandByName($name, $state)
{
return self::service()->getBrandByName($name, $state);
}
}