Christmas.php
12.4 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
<?php
use Action\HuodongAction;
use Plugin\Helpers;
use LibModels\Wap\Cuxiao\ActivityData;
/**
* 圣诞领券活动
* @author Administrator
*/
class ChristmasController extends HuodongAction
{
// private $_isApp = false;
/**
* 备注:2015年12月11号上线
*/
public function christmasAction()
{
//获取登录者ID,未登录返回false
$uid = $this->getLoggedUid();
if (!$uid || !is_numeric($uid)) {
//未登录的用户访问,跳转到登录页面。并且在登陆后跳转回本页面
$this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/cuxiao/christmas/christmas')), 'default'));
}
// 该变量用来控制和显示页面的弹出提示
$showPopupFlag = '0';
//获取跳转到个人中心-我的优惠券链接,并调用接口,完成领券操作
$myCouponUrl = Helpers::url('/home/coupons', null, 'default') . '?openby:yohobuy={"action":"go.coupon"}';
$activityId = $this->getActivityId();
$result = ActivityData::getCouponAll($uid, $activityId);
if (isset($result['code'])) {
switch (intval($result['code'])) {
case 200: // 领取成功, 发送站内信消息
$showPopupFlag = '0';
$this->sendMessage($uid, '【优惠券】您有6张潮集圣诞优惠券', '尊敬的客户:恭喜您成功获得6张潮集圣诞优惠券 !您可以在个人中心的交易管理中查看‘我的优惠券’。');
break;
case 201: // 已领取过, 提示重复领券
$showPopupFlag = '1';
break;
default: // 领取失败, 提示领券失败
$showPopupFlag = '2';
break;
}
}
$this->_view->display('index', array(
'staticTitle' => '潮集圣诞',
'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享
'shareLink' => 'http://feature.yohobuy.com/0/0/675/index.html',
'shareTitle' => 'YOHO!BUY有货【潮集圣诞】第一弹来袭!500元优惠券引爆圣诞!',
'shareDesc' => '万件潮品限时58折封顶,再享折上满减,还有惊喜圣诞礼物等你来挑哦!',
'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/12/10/09/029fd41969b67002126ff7a71fe5396b6e.png',
'showPopupFlag' => $showPopupFlag,
'myCouponUrl' => $myCouponUrl,
'bannerUrl_1' => 'http://feature.yoho.cn/1211/1211APPHOMEBOY/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"潮集圣诞","url":"http://feature.yoho.cn/1211/1211APPHOMEBOY/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"454"},"param":{"share_id":"454"}}}',
'bannerUrl_2' => 'http://feature.yoho.cn/1211/1211APPHOMEGIRL/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"潮集圣诞","url":"http://feature.yoho.cn/1211/1211APPHOMEGIRL/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"456"},"param":{"share_id":"456"}}}',
));
}
/**
* 备注:2015年12月11号上线
*/
public function christmas2Action()
{
//获取登录者ID,未登录返回false
$uid = $this->getLoggedUid();
if (!$uid || !is_numeric($uid)) {
//未登录的用户访问,跳转到登录页面。并且在登陆后跳转回本页面
$this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/cuxiao/christmas/christmas2')), 'default'));
}
// 该变量用来控制和显示页面的弹出提示
$showPopupFlag = '0';
//获取跳转到个人中心-我的优惠券链接,并调用接口,完成领券操作
$myCouponUrl = Helpers::url('/home/coupons', null, 'default') . '?openby:yohobuy={"action":"go.coupon"}';
$activityId = $this->getActivityId2();
$result = ActivityData::getCouponAll($uid, $activityId);
if (isset($result['code'])) {
switch (intval($result['code'])) {
case 200: // 领取成功, 发送站内信消息
$showPopupFlag = '0';
$this->sendMessage($uid, '【优惠券】您获得1000元套券', '尊敬的客户:恭喜您成功获得1000元套券!您可以在个人中心的交易管理中查看‘我的优惠券’。');
break;
case 201: // 已领取过, 提示重复领券
$showPopupFlag = '1';
break;
default: // 领取失败, 提示领券失败
$showPopupFlag = '2';
break;
}
}
$this->_view->display('index-2', array(
'staticTitle' => '潮集圣诞',
'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享
'shareLink' => 'http://feature.yohobuy.com/0/0/701/index.html',
'shareTitle' => 'YOHO!BUY有货【潮集圣诞】第二弹来袭!1000元优惠券引爆圣诞!',
'shareDesc' => '万件潮品限时5折封顶,冬季优品最高直减800元,还有惊喜圣诞礼物等你来挑哦!',
'shareImg' => 'http://img11.static.yhbimg.com/couponImg/2015/12/17/09/014bba1e01a0aef86fa4c81f1c926a0d62.png',
'showPopupFlag' => $showPopupFlag,
'myCouponUrl' => $myCouponUrl,
'bannerUrl_1' => 'http://feature.yoho.cn/1221/1221APPHOMEBOY/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"潮集圣诞","url":"http://feature.yoho.cn/1221/1221APPHOMEBOY/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"530"},"param":{"share_id":"530"}}}',
'bannerUrl_2' => 'http://feature.yoho.cn/1221/1221APPHOMEGIRL/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"潮集圣诞","url":"http://feature.yoho.cn/1221/1221APPHOMEGIRL/index.html","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"532"},"param":{"share_id":"532"}}}',
'bannerUrl_3' => 'http://feature.yoho.cn/1221/1221APPHOMELIFE/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"潮集圣诞","url":"http://feature.yoho.cn/1221/1221APPHOMELIFE/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"536"},"param":{"share_id":"536"}}}',
'bannerUrl_4' => 'http://feature.yoho.cn/1221/1221APPHOMEKIDS/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"潮集圣诞","url":"http://feature.yoho.cn/1221/1221APPHOMEKIDS/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"534"},"param":{"share_id":"534"}}}',
));
}
/**
* 元旦领券(圣诞领券第三波)
*
* 备注:2015年12月28号上线
*/
public function newyearAction()
{
//获取登录者ID,未登录返回false
$uid = $this->getLoggedUid();
if (!$uid || !is_numeric($uid)) {
//未登录的用户访问,跳转到登录页面。并且在登陆后跳转回本页面
$this->go(Helpers::url('/signin.html', array('refer' => Helpers::url('/cuxiao/christmas/newyear')), 'default'));
}
// 该变量用来控制和显示页面的弹出提示
$showPopupFlag = '0';
//获取跳转到个人中心-我的优惠券链接,并调用接口,完成领券操作
$myCouponUrl = Helpers::url('/home/coupons', null, 'default') . '?openby:yohobuy={"action":"go.coupon"}';
$activityId = $this->getActivityId3();
$result = ActivityData::getCouponAll($uid, $activityId);
if (isset($result['code'])) {
switch (intval($result['code'])) {
case 200: // 领取成功, 发送站内信消息
$showPopupFlag = '0';
$this->sendMessage($uid, '【优惠券】您获得500元元旦优惠券', '尊敬的客户:恭喜您成功获得500元套券 !您可以在个人中心的交易管理中查看‘我的优惠券’。');
break;
case 201: // 已领取过, 提示重复领券
$showPopupFlag = '1';
break;
default: // 领取失败, 提示领券失败
$showPopupFlag = '2';
break;
}
}
$this->_view->display('index-3', array(
'staticTitle' => '年终热促',
'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享
'shareLink' => 'http://feature.yohobuy.com/0/0/724/index.html',
'shareTitle' => 'YOHO!BUY有货【Final Sale】年终热促开启,限时4.8折封顶!',
'shareDesc' => '500元优惠券限时派送,更有800+潮牌跨年礼物赠不停!',
'shareImg' => 'http://img11.static.yhbimg.com/couponImg/2015/12/25/07/010657d070da271499ad9367c5806486b2.png',
'showPopupFlag' => $showPopupFlag,
'myCouponUrl' => $myCouponUrl,
'bannerUrl_1' => 'http://feature.yoho.cn/1228/1228APPHOMEBOY/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"Final sale","url":"http://feature.yoho.cn/1228/1228APPHOMEBOY/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"360"},param":{"share_id":"360"}}}',
'bannerUrl_2' => 'http://feature.yoho.cn/1228/1228APPHOMEGIRL/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"Final sale","url":"http://feature.yoho.cn/1228/1228APPHOMEGIRL/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"358"},param":{"share_id":"358"}}}',
'bannerUrl_3' => 'http://feature.yoho.cn/1228/1228APPHOMEKIDS/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"Final sale","url":"http://feature.yoho.cn/1228/1228APPHOMEKIDS/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"356"},param":{"share_id":"356"}}}',
'bannerUrl_4' => 'http://feature.yoho.cn/1228/1228APPHOMELIFE/index.html?openby:yohobuy={"action":"go.h5","params":{"title":"Final sale","url":"http://feature.yoho.cn/1228/1228APPHOMELIFE/index.html?","share":"\/operations\/api\/v5\/webshare\/getShare","shareparam":{"share_id":"354"},param":{"share_id":"354"}}}',
));
}
/**
* 检测登录状态
*
* @return int
*/
private function getLoggedUid()
{
// 判断是否是应用访问, 拼接APP需要的URL参数
$this->_isApp = (null !== $this->get('app_version') || null !== $this->get('uid'));
$uid = false;
if ($this->_isApp) {
$uid = $this->get('uid');
} else {
$uid = $this->getUid();
}
return $uid;
}
/**
* 发送站内信
*
* @param int $uid 用户ID
*/
private function sendMessage($uid, $title, $content)
{
try {
ActivityData::message($uid, $title, $content);
} catch (Exception $e) {
// do nothing
}
}
/**
* 根据环境来获取活动ID
*
* @return int
*/
private function getActivityId()
{
// 设置环境变量
switch (APPLICATION_ENV) {
case 'production': // 生产
return 388;
case 'preview': // 预览
case 'testing': // 测试
case 'develop': // 开发
default:
return 84;
}
}
/**
* 根据环境来获取活动ID
*
* @return int
*/
private function getActivityId2()
{
// 设置环境变量
switch (APPLICATION_ENV) {
case 'production': // 生产
return 390;
case 'preview': // 预览
case 'testing': // 测试
case 'develop': // 开发
default:
return 85;
}
}
/**
* 根据环境来获取活动ID
*
* @return int
*/
private function getActivityId3()
{
// 设置环境变量
switch (APPLICATION_ENV) {
case 'production': // 生产
return 390;
case 'preview': // 预览
case 'testing': // 测试
case 'develop': // 开发
default:
return 85;
}
}
}