Index.php
25.7 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
<?php
use Action\AbstractAction;
use LibModels\Wap\Product\SaleData;
use LibModels\Wap\Product\ShopData;
use Plugin\Helpers;
use Product\ListModel;
use LibModels\Wap\Coupon\CouponData;
use Plugin\Encryption;
/**
* 商品列表相关的控制器
*
*/
class IndexController extends AbstractAction
{
/**
* 品类商品列表页
*
* @internal param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @internal param int $brand 品牌Id
* @internal param int $sort 品类查询sort参数
* @internal param int $color 颜色Id
* @internal param int $size 尺码Id
* @internal param string $price 价格
* @internal param string $p_d 折扣
*/
public function indexAction()
{
// 过滤请求参数
$condition = filter_input_array(INPUT_GET, array(
'brand' => FILTER_DEFAULT,
'sort' => FILTER_DEFAULT,
'msort' => FILTER_DEFAULT,
'misort' => FILTER_DEFAULT,
'color' => FILTER_DEFAULT,
'size' => FILTER_DEFAULT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'discount' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'channel' => FILTER_DEFAULT,
'ageLevel' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
// 转义店铺
if (isset($condition['shop_id'])) {
$condition['shop_id'] = rawurldecode($condition['shop_id']);
}
// 转义品牌
if (isset($condition['brand'])) {
$condition['brand'] = rawurldecode($condition['brand']);
}
// 转义分类
if (isset($condition['sort'])) {
$condition['sort'] = rawurldecode($condition['sort']);
}
// 转义一级分类
if (isset($condition['msort'])) {
$condition['msort'] = rawurldecode($condition['msort']);
}
// 转义二级分类
if (isset($condition['misort'])) {
$condition['misort'] = rawurldecode($condition['misort']);
}
// 转义颜色
if (isset($condition['color'])) {
$condition['color'] = rawurldecode($condition['color']);
}
// 转义尺码
if (isset($condition['size'])) {
$condition['size'] = rawurldecode($condition['size']);
}
// 转义风格
if (isset($condition['style'])) {
$condition['style'] = rawurldecode($condition['style']);
}
// 转义价格
if (isset($condition['price'])) {
$condition['price'] = rawurldecode($condition['price']);
}
// 转换折扣
if (isset($condition['discount'])) {
$condition['p_d'] = rawurldecode($condition['discount']);
}
// 为了兼容现在运营在用的p_d
if (isset($condition['p_d'])) {
$condition['discount'] = rawurldecode($condition['p_d']);
}
// 性别参数,不传则从COOKIE获取
if (!isset($condition['gender'])) {
$condition['gender'] = Helpers::getGenderByCookie();
} else {
$condition['gender'] = rawurldecode($condition['gender']);
}
// 品类名称参数, 不传则默认为全部
$name = $this->get('sort_name');
if (empty($name)) {
$name = $this->get('title', '全部');
}
$this->setTitle($name);
$this->setNavHeader($name, true, SITE_MAIN);
if (!$condition) {
$condition = array();
}
$goodList = $condition;
$goodList['cartUrl'] = Helpers::url('/cart/index/index', null);
$this->_view->display('index', array(
'goodListPage' => true,
'showDownloadApp' => true,
'goodList' => $goodList,
'pageFooter' => true,
));
}
/**
* 品牌商品列表页
*
* @internal param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @internal param int $sort 品类查询sort参数
* @internal param int $color 颜色Id
* @internal param int $size 尺码Id
* @internal param string $price 价格
* @internal param string $p_d 折扣
*/
public function brandAction()
{
//如果是app 或者多品店,可直接获取shopId
$appShopId = $this->get('shop_id');
if (!empty($appShopId)) {
$this->shop($appShopId);
exit;
}
/* 品牌域名参数 @see Bootstrap.php */
$domain = $this->param('named');
if (empty($domain)) {
$this->go(SITE_MAIN);
}
// 当前的登录用户UID
$uid = $this->getUid();
// 存标题信息
$title = '';
$brandLogo = Product\ListModel::getBrandLogoByDomain($domain, $title);
//无店铺:0--->品牌页 无单品店有多品店:1--->搜索页 有单品店:2--->店铺页面
if ($brandLogo['type'] == 2 && !empty($brandLogo['shopId'])) {
$this->shop($brandLogo['shopId']);
exit;
}
$brandId = 0;
if ($brandLogo && isset($brandLogo['id'])) {
$brandId = $brandLogo['id'];
}
//获取品牌店铺信息
$brandShop = $this->brandShop($brandId);
/* 搜索框相关 */
$from = $this->get('from');
$query = $this->get('query');
/* 过滤请求参数 */
$condition = filter_input_array(INPUT_GET, array(
'sort' => FILTER_DEFAULT,
'msort' => FILTER_DEFAULT,
'misort' => FILTER_DEFAULT,
'color' => FILTER_DEFAULT,
'size' => FILTER_DEFAULT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'discount' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'channel' => FILTER_DEFAULT,
'ageLevel' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
$condition['brand'] = $brandId;
// 转义店铺
if (isset($condition['shop_id'])) {
$condition['shop_id'] = rawurldecode($condition['shop_id']);
}
// 转义分类
if (isset($condition['sort'])) {
$condition['sort'] = rawurldecode($condition['sort']);
}
// 转义一级分类
if (isset($condition['msort'])) {
$condition['msort'] = rawurldecode($condition['msort']);
}
// 转义二级分类
if (isset($condition['misort'])) {
$condition['misort'] = rawurldecode($condition['misort']);
}
// 转义颜色
if (isset($condition['color'])) {
$condition['color'] = rawurldecode($condition['color']);
}
// 转义尺码
if (isset($condition['size'])) {
$condition['size'] = rawurldecode($condition['size']);
}
// 转义风格
if (isset($condition['style'])) {
$condition['style'] = rawurldecode($condition['style']);
}
// 转义价格
if (isset($condition['price'])) {
$condition['price'] = rawurldecode($condition['price']);
}
// 转换折扣
if (isset($condition['discount'])) {
$condition['p_d'] = rawurldecode($condition['discount']);
}
// 为了兼容现在运营在用的p_d
if (isset($condition['p_d'])) {
$condition['discount'] = rawurldecode($condition['p_d']);
}
if ($brandId === 0) {
$condition['query'] = $domain;
}
if (isset($condition['gender'])) {
$condition['gender'] = rawurldecode($condition['gender']);
}/* else {
$condition['gender'] = Helpers::getGenderByCookie();
}*/
$data = array();
$data['goodListPage'] = true;
$data['showDownloadApp'] = true;
// 从搜索页过来的,显示搜索框, 和进入品牌引导信息 或者品牌关联多店铺
if ($from === 'search' || !empty($brandShop)) {
$data['goodList'] = array();
//$data['goodList']['brandWay'] = \Product\ListModel::getBrandLogoByIds($brandId, $title);
$data['goodList']['brandWay'] = $brandShop ? $brandShop : $brandLogo;
$data['goodList']['search']['default'] = $query;
$data['goodList']['search']['url'] = Helpers::url('', null, 'search');
} // 品牌一览过来的展示品牌介绍和LOGO
elseif ($brandId !== 0) {
$data['brandHome'] = \Product\ListModel::getBrandIntro($brandId, $uid, $title);
$data['goodList'] = array();
}
// 右下角的购物车链接
$data['goodList']['cartUrl'] = Helpers::url('/cart/index/index', null);
$data['goodList'] += $condition;
$data['pageFooter'] = true;
if (empty($title)) {
$title = $domain;
}
$this->setTitle($title);
$this->setNavHeader($title, true, SITE_MAIN);
$this->_view->display('index', $data);
}
/**
* 活动专区
*
* @param int channel 1:男生,2:女生,3:潮童,4:创意生活
*/
public function saleAction()
{
// 过滤请求参数
$condition = filter_input_array(INPUT_GET, array(
'brand' => FILTER_DEFAULT,
'specialsale_id' => FILTER_DEFAULT,
'promotion' => FILTER_DEFAULT,
'sort' => FILTER_DEFAULT,
'msort' => FILTER_DEFAULT,
'misort' => FILTER_DEFAULT,
'color' => FILTER_DEFAULT,
'size' => FILTER_DEFAULT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'discount' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'channel' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
//专区ID和促销ID都为空时,跳转到主页
if (!isset($condition['specialsale_id']) && !isset($condition['promotion'])) {
$this->go(SITE_MAIN);
}
// 转义活动ID
if (isset($condition['specialsale_id'])) {
$condition['specialsale_id'] = rawurldecode($condition['specialsale_id']);
}
if (isset($condition['promotion'])) {
$condition['promotion'] = rawurldecode($condition['promotion']);
}
// 获取促销信息
$special = array();
$specialInfo = SaleData::getSpecial($condition['specialsale_id']);
if(isset($specialInfo['data'])) {
$special = $specialInfo['data'];
}
//传促销id,促销id为空时传专区id
if(!empty($special['ispromotion'])){
$condition['promotion'] = $special['ispromotion'];
}
// 转义品牌
if (isset($condition['brand'])) {
$condition['brand'] = rawurldecode($condition['brand']);
} else {
//传品牌ID参数
if(!empty($special['brand_id'])){
$condition['brand'] = $special['brand_id'];
}
}
// 转义分类
if (isset($condition['sort'])) {
$condition['sort'] = rawurldecode($condition['sort']);
}
// 转义一级分类
if (isset($condition['msort'])) {
$condition['msort'] = rawurldecode($condition['msort']);
}
// 转义二级分类
if (isset($condition['misort'])) {
$condition['misort'] = rawurldecode($condition['misort']);
}
// 转义颜色
if (isset($condition['color'])) {
$condition['color'] = rawurldecode($condition['color']);
}
// 转义尺码
if (isset($condition['size'])) {
$condition['size'] = rawurldecode($condition['size']);
}
// 转义风格
if (isset($condition['style'])) {
$condition['style'] = rawurldecode($condition['style']);
}
// 转义价格
if (isset($condition['price'])) {
$condition['price'] = rawurldecode($condition['price']);
}
// 转换折扣
if (isset($condition['discount'])) {
$condition['p_d'] = rawurldecode($condition['discount']);
}
// 为了兼容现在运营在用的p_d
if (isset($condition['p_d'])) {
$condition['discount'] = rawurldecode($condition['p_d']);
}
// 性别参数,不传则从COOKIE获取
if (!isset($condition['gender'])) {
$condition['gender'] = Helpers::getGenderByCookie();
} else {
$condition['gender'] = rawurldecode($condition['gender']);
}
if (!$condition) {
$condition = array();
}
$goodList = $condition;
$goodList['cartUrl'] = Helpers::url('/cart/index/index', null);
$this->setTitle('专区活动');
$this->setNavHeader('专区活动', true, SITE_MAIN);
$this->_view->display('index', array(
'goodListPage' => true,
'showDownloadApp' => true,
'goodList' => $goodList,
'pageFooter' => true,
));
}
/**
* 店铺全部品牌页面
* @author chengyao.guo
* @return mixed
*/
public function allBrandAction()
{
$requestData = filter_input_array(INPUT_GET, array(
'shop_id' => FILTER_DEFAULT,
));
if (empty($requestData['shop_id'])) {
$this->go(SITE_MAIN);
}
$result = array();
$resource = ShopData::getShopBrands($requestData['shop_id']);
if($resource['code'] === 200){
$result = ListModel::brandData($resource['data'],$requestData['shop_id']);
}
if($this->isApp()){
$this->setTitle('品牌');
}else{
$this->setNavHeader('品牌', true, SITE_MAIN);
}
return $this->_view->display('brand', array(
'content' => $result,
));
}
/**
*
* 店铺品类页面
* @author chengyao.guo
* @return mixed
*/
public function categoryAction()
{
$requestData = filter_input_array(INPUT_GET, array(
'shop_id' => FILTER_DEFAULT,
));
if (empty($requestData['shop_id'])) {
$this->go(SITE_MAIN);
}
$result = array();
$resource = ShopData::getShopCategory($requestData['shop_id'], Helpers::getChannelByCookie(), Helpers::getGenderByCookie());
if ($resource['code'] === 200) {
$result = ListModel::categoryData($resource['data'],$requestData['shop_id']);
}
if($this->isApp()){
$this->setTitle('品类');
}else{
$this->setNavHeader('品类', true, SITE_MAIN);
}
return $this->_view->display('category', array(
'productCategoryPage' => true,
'content' => $result,
));
}
/**
* 店铺简介页面
* @author chengyao.guo
* @return mixed
*/
public function introAction()
{
$requestData = filter_input_array(INPUT_GET, array(
'shop_id' => FILTER_DEFAULT,
));
if (empty($requestData['shop_id'])) {
$this->go(SITE_MAIN);
}
$result = array();
$resource = ShopData::getShopIntro($requestData['shop_id']);
if ($resource['code'] === 200) {
$result = ListModel::introData($resource['data']);
}
if($this->isApp()){
$this->setTitle('店铺简介');
}else{
$this->setNavHeader('店铺简介', true, SITE_MAIN);
}
return $this->_view->display('intro', array(
'content' => $result,
));
}
/**
* 店铺首页 || 若店铺使用基础模板跳转基础模板页
* @param int $shopId
* @return int
* @author sefon 2016-4-26 20:50:58
*/
private function shop($shopId)
{
$appVersion = $this->get('app_version');
if (empty($appVersion)) {
$this->setNavHeader('', true, SITE_MAIN);
$uid = $this->getUid(true);
}
//app环境
else {
$uid = $this->get('uid');
$this->setSession('appUid', $uid);
$this->setCookie('appUid', $uid);
}
$data = ListModel::shopData($shopId, $uid, $appVersion);
if (isset($data['goBrand'])) {
//跳转基础模板
self::baseShop($data['goBrand']);
exit;
}
/* tar add 160826 */
$data['gender'] = $this->get('gender');
//接受APP传来的封面频道参数
$coverChannel = Helpers::getYhHhannel($this->get('yh_channel', ''));
$filter = Product\SearchModel::filter(array(
'shop_id' => $shopId,
'gender' => isset($data['gender']) ? $data['gender'] : '',
'brand' => isset($data['brand']) ? $data['brand'] : ''
));
$data['filter'] = isset($filter['filter']) ? $filter['filter'] : array();
/* tar add 160931 首屏加载,加载一次 goods */
$goods = \Product\SearchModel::search(array(
'shop' => $shopId,
'gender' => isset($data['gender']) ? $data['gender'] : '',
'brand' => isset($data['brand']) ? $data['brand'] : '',
'coverChannel' => $coverChannel
));
$data['goods'] = isset($goods['new']) ? $goods['new'] : array();
$data['shopCoupons'] = ListModel::getShopCouponsList($shopId, $uid);
$data['shopCouponsOne'] = count($data['shopCoupons']) === 1;
$this->_view->display('shop', array(
'shopIndex' => $data,
'shopPage' => array(
'text' => '分类',
'url' => Helpers::url('/product/index/category', array('shop_id' => $shopId))
),
'gender' => $data['gender'],
'coverChannel' => $coverChannel,
'appVersion' => !empty($appVersion),
'shopPager' => true
));
}
/**
* 店铺基础模板
* @param int $shop
* @author sefon 2016-4-26 20:50:58
* @return int
*/
private function baseShop($shop)
{
$appVersion = $this->get('app_version');
$uid = '';
if (empty($appVersion)) {
$uid = $this->getUid(true);
}
//app环境
else {
$uid = $this->get('uid');
$this->setSession('appUid', $uid);
$this->setCookie('appUid', $uid);
}
/* 过滤请求参数 */
$condition = filter_input_array(INPUT_GET, array(
'sort' => FILTER_DEFAULT,
'brand' => FILTER_DEFAULT,
'msort' => FILTER_DEFAULT,
'misort' => FILTER_DEFAULT,
'color' => FILTER_DEFAULT,
'size' => FILTER_DEFAULT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'discount' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'channel' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
if ($shop['mult_brand_shop_type'] == 2) {
// 转义店铺
$condition['shop_id'] = $shop['shops_id'];
} else {
$brands = ShopData::getShopBrands($shop['shops_id']);
if (isset($brands['code']) && $brands['code'] == 200 && isset($brands['data']) && !empty($brands['data']))
$condition['brand'] = $brands['data'][0]['brand_id'];
}
// 转义分类
if (isset($condition['sort'])) {
$condition['sort'] = rawurldecode($condition['sort']);
}
// 转义一级分类
if (isset($condition['msort'])) {
$condition['msort'] = rawurldecode($condition['msort']);
}
// 转义二级分类
if (isset($condition['misort'])) {
$condition['misort'] = rawurldecode($condition['misort']);
}
// 转义颜色
if (isset($condition['color'])) {
$condition['color'] = rawurldecode($condition['color']);
}
// 转义尺码
if (isset($condition['size'])) {
$condition['size'] = rawurldecode($condition['size']);
}
// 转义风格
if (isset($condition['style'])) {
$condition['style'] = rawurldecode($condition['style']);
}
// 转义价格
if (isset($condition['price'])) {
$condition['price'] = rawurldecode($condition['price']);
}
// 转换折扣
if (isset($condition['discount'])) {
$condition['p_d'] = rawurldecode($condition['discount']);
}
// 为了兼容现在运营在用的p_d
if (isset($condition['p_d'])) {
$condition['discount'] = rawurldecode($condition['p_d']);
}
if (isset($condition['gender'])) {
$condition['gender'] = rawurldecode($condition['gender']);
}/* else {
$condition['gender'] = Helpers::getGenderByCookie();
}*/
$data = array();
$data['goodListPage'] = true;
$data['showDownloadApp'] = true;
$title = $shop['shop_name'];
// 右下角的购物车链接
$data['goodList']['cartUrl'] = Helpers::url('/cart/index/index', null);
$data['goodList'] += $condition;
$data['pageFooter'] = true;
//基础模板,于水说APP没有,H5暂时不须要
// $data['shopCoupons'] = ListModel::getShopCouponsList($shop['shops_id'], $uid);
// $data['shopCouponsOne'] = count($data['shopCoupons']) === 1;
$this->setTitle($title);
$this->setNavHeader($title, true, SITE_MAIN);
// 店铺使用基础模板
$baseShopInfo = ListModel::getShopInfoById($shop['shops_id'], $uid);
if ($baseShopInfo['code'] === 200) {
$data['baseShopHome'] = array(
'appVersion' => $this->get('app_version'),
'isBaseShop' => true,
'id' => $shop['shops_id'],
'intro' => $baseShopInfo['data']['shop_intro'],
'collected' => $baseShopInfo['data']['is_favorite'] === 'Y',
'banner' => ListModel::getShopBaseBanner($shop['shops_id'])
);
}
$this->_view->display('index', $data);
}
/**
* 店铺收藏
* @author sefon 2016-4-28 23:00:11
*/
public function shopFavAction()
{
header('Access-Control-Allow-Origin:' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Credentials:true');
$data = array();
$shopId = $this->get('shop_id', 0);
$appVersion = $this->get('app_version', 0);
if (!empty($appVersion)){
$uid = $this->getCookie('appUid');
} else {
$uid = $this->getUid();
}
do {
if (empty($uid)) {
$data['code'] = 400;
$refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$toUrl = Helpers::url('/signin.html')."?refer=".$refer;
if (!empty($appVersion)){
$toUrl .= '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"'.$refer.'","param":{}},"requesturl":{"param":{"method":"app.favorite.add","id":"'.$shopId.'","fav_id":"'.$shopId.'","type":"shop"},"url":"'.API_URL.'"},"priority":"Y"}}';
}
$data['url'] = $toUrl;
break;
}
if (!empty($shopId) && !empty($uid)) {
$data = ShopData::shopFav($uid, $shopId);
}
} while(false);
$this->echoJson($data);
}
/**
* 取消店铺收藏
* @author sefon 2016-4-28 23:01:43
*/
public function cancelShopFavAction()
{
header('Access-Control-Allow-Origin:' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Credentials:true');
$data = array();
$shopId = $this->get('shop_id', 0);
$appVersion = $this->get('app_version', 0);
if (!empty($appVersion)){
$uid = $this->getCookie('appUid');
} else {
$uid = $this->getUid();
}
if (!empty($shopId) && !empty($uid)) {
$data = ShopData::cancelShopFav($uid, $shopId);
}
$this->echoJson($data);
}
/**
* 根据brandId 获取相关店铺列表
* @param int $brandId
* @author sefon 2016-4-28 13:38:23
* @return array
*/
public static function brandShop($brandId)
{
return ListModel::getBrandShops($brandId);
}
/**
* 用户领券
* @param int app_version
* @param int couponID
* @return json
*/
public function userCouponAction()
{
header('Access-Control-Allow-Origin:' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Credentials:true');
$data = array();
$appVersion = $this->post('app_version', 0);
$couponID = $this->post('couponID', 0);
if (empty($couponID)) {
exit(0);
}
if (empty($appVersion)){
$uid = $this->getUid();
} else {
$uid = $this->getCookie('appUid');
}
do {
if (empty($uid)) {
$data['code'] = 4401;//401错误已经被接口占用
$refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$toUrl = Helpers::url('/signin.html')."?refer=".$refer;
if (!empty($appVersion)){
$toUrl .= '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"'. $refer . '","param":{}},"requesturl":{"param":{"method":"app.promotion.getCoupon","couponId":"' . Encryption::decrypt($couponID) . '"},"url":"' . API_URL . '"},"priority":"Y"}}';
}
$data['url'] = $toUrl;
break;
}
$data = CouponData::receiveCoupon($uid, Encryption::decrypt($couponID));
} while(false);
$this->echoJson($data);
}
}