|
|
1
|
+<?php
|
|
|
2
|
+/**
|
|
|
3
|
+ * Created by PhpStorm.
|
|
|
4
|
+ * User: Administrator
|
|
|
5
|
+ * Date: 2016/3/18
|
|
|
6
|
+ * Time: 10:30
|
|
|
7
|
+ */
|
|
|
8
|
+use Action\HuodongAction;
|
|
|
9
|
+use Plugin\Helpers;
|
|
|
10
|
+use LibModels\Wap\Cuxiao\ActivityData;
|
|
|
11
|
+use Plugin\Cache;
|
|
|
12
|
+use Configs\CacheConfig;
|
|
|
13
|
+
|
|
|
14
|
+class GirlfourController extends HuodongAction
|
|
|
15
|
+{
|
|
|
16
|
+ const SESSION_UID = 'coupon_uid';
|
|
|
17
|
+
|
|
|
18
|
+ /**
|
|
|
19
|
+ * 女生节第四波领券活动-男生品牌页面控制器
|
|
|
20
|
+ */
|
|
|
21
|
+ public function boyAction()
|
|
|
22
|
+ {
|
|
|
23
|
+ // 判断是否是应用访问, 拼接APP需要的URL参数
|
|
|
24
|
+ $isApp = null !== $this->get('app_version');
|
|
|
25
|
+ $isAppLogged = true;
|
|
|
26
|
+ if ($isApp) {
|
|
|
27
|
+ $isLogged = $this->get('uid') !== null;
|
|
|
28
|
+ $isAppLogged = $this->checkIsLogin();
|
|
|
29
|
+ } else {
|
|
|
30
|
+ $isLogged = $this->getUid();
|
|
|
31
|
+ }
|
|
|
32
|
+ $urlKids = Helpers::url('/cuxiao/girlfour/boy');
|
|
|
33
|
+ $urlEncode = strtr($urlKids, array('/' => '\\/'));
|
|
|
34
|
+
|
|
|
35
|
+ $this->_view->display('index', array(
|
|
|
36
|
+ 'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
|
|
|
37
|
+ 'staticJS' => array(
|
|
|
38
|
+ 'main.js'
|
|
|
39
|
+ ),
|
|
|
40
|
+ 'jumpUrl' => $isAppLogged ? 'javascript:;' : $urlKids . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $urlEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}',
|
|
|
41
|
+ 'pageType' => 'boy',
|
|
|
42
|
+ 'isOnline' => $this->getisOnline(),
|
|
|
43
|
+ 'tab' => array('jp', 'hk', 'cn', 'trousers', 'more'),
|
|
|
44
|
+ 'moreBrand' => 'http://feature.yoho.cn/0318/TICKETSBOY/index.html',
|
|
|
45
|
+ 'isApp' => $this->_isApp,
|
|
|
46
|
+ 'isAppLogin' => $isAppLogged,
|
|
|
47
|
+ 'getCouponUrl' => Helpers::url('/cuxiao/girlfour/getnamed', array('uid' => $this->getLoggedUid())),
|
|
|
48
|
+ 'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
|
|
|
49
|
+ 'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
|
|
|
50
|
+ 'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/03/10/10/0298ef8fbbb543144af487fbcd6718041b.png',
|
|
|
51
|
+ 'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
|
|
|
52
|
+ ));
|
|
|
53
|
+ }
|
|
|
54
|
+
|
|
|
55
|
+
|
|
|
56
|
+ /**
|
|
|
57
|
+ * 女生节第四波领券活动-女生品牌页面控制器
|
|
|
58
|
+ */
|
|
|
59
|
+ public function girlAction()
|
|
|
60
|
+ {
|
|
|
61
|
+ // 判断是否是应用访问, 拼接APP需要的URL参数
|
|
|
62
|
+ $isApp = null !== $this->get('app_version');
|
|
|
63
|
+ $isAppLogged = true;
|
|
|
64
|
+ if ($isApp) {
|
|
|
65
|
+ $isLogged = $this->get('uid') !== null;
|
|
|
66
|
+ $isAppLogged = $this->checkIsLogin();
|
|
|
67
|
+ } else {
|
|
|
68
|
+ $isLogged = $this->getUid();
|
|
|
69
|
+ }
|
|
|
70
|
+ $urlKids = Helpers::url('/cuxiao/girlfour/girl');
|
|
|
71
|
+ $urlEncode = strtr($urlKids, array('/' => '\\/'));
|
|
|
72
|
+
|
|
|
73
|
+ $this->_view->display('index', array(
|
|
|
74
|
+ 'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
|
|
|
75
|
+ 'staticJS' => array(
|
|
|
76
|
+ 'main.js'
|
|
|
77
|
+ ),
|
|
|
78
|
+ 'jumpUrl' => $isAppLogged ? 'javascript:;' : $urlKids . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $urlEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}',
|
|
|
79
|
+ 'pageType' => 'girl',
|
|
|
80
|
+ 'isOnline' => $this->getisOnline(),
|
|
|
81
|
+ 'tab' => array('hk', 'yohope', 'jean', 'shoes', 'more'),
|
|
|
82
|
+ 'moreBrand' => 'http://feature.yoho.cn/0318/TICKETSBOY/index.html',
|
|
|
83
|
+ 'isApp' => $this->_isApp,
|
|
|
84
|
+ 'isAppLogin' => $isAppLogged,
|
|
|
85
|
+ 'getCouponUrl' => Helpers::url('/cuxiao/girlfour/getnamed', array('uid' => $this->getLoggedUid())),
|
|
|
86
|
+ 'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
|
|
|
87
|
+ 'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
|
|
|
88
|
+ 'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/03/10/10/0298ef8fbbb543144af487fbcd6718041b.png',
|
|
|
89
|
+ 'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
|
|
|
90
|
+ ));
|
|
|
91
|
+ }
|
|
|
92
|
+
|
|
|
93
|
+ /**
|
|
|
94
|
+ * 女生节第四波领券活动-童品牌页面控制器
|
|
|
95
|
+ */
|
|
|
96
|
+ public function kidAction()
|
|
|
97
|
+ {
|
|
|
98
|
+ // 判断是否是应用访问, 拼接APP需要的URL参数
|
|
|
99
|
+ $isApp = null !== $this->get('app_version');
|
|
|
100
|
+ $isAppLogged = true;
|
|
|
101
|
+ if ($isApp) {
|
|
|
102
|
+ $isLogged = $this->get('uid') !== null;
|
|
|
103
|
+ $isAppLogged = $this->checkIsLogin();
|
|
|
104
|
+ } else {
|
|
|
105
|
+ $isLogged = $this->getUid();
|
|
|
106
|
+ }
|
|
|
107
|
+ $urlKids = Helpers::url('/cuxiao/girlfour/kid');
|
|
|
108
|
+ $urlEncode = strtr($urlKids, array('/' => '\\/'));
|
|
|
109
|
+
|
|
|
110
|
+ $this->_view->display('index', array(
|
|
|
111
|
+ 'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
|
|
|
112
|
+ 'staticJS' => array(
|
|
|
113
|
+ 'main.js'
|
|
|
114
|
+ ),
|
|
|
115
|
+ 'jumpUrl' => $isAppLogged ? 'javascript:;' : $urlKids . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $urlEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}',
|
|
|
116
|
+ 'isOnline' => $this->getisOnline(),
|
|
|
117
|
+ 'pageType' => 'kid',
|
|
|
118
|
+ // 'tab' => array('us', 'bag', 'yohope', 'shoes', 'more'),
|
|
|
119
|
+ 'isApp' => $this->_isApp,
|
|
|
120
|
+ 'isAppLogin' => $isAppLogged,
|
|
|
121
|
+ 'getCouponUrl' => Helpers::url('/cuxiao/girlfour/getnamed', array('uid' => $this->getLoggedUid())),
|
|
|
122
|
+ 'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
|
|
|
123
|
+ 'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
|
|
|
124
|
+ 'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/03/10/10/0298ef8fbbb543144af487fbcd6718041b.png',
|
|
|
125
|
+ 'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
|
|
|
126
|
+ ));
|
|
|
127
|
+ }
|
|
|
128
|
+
|
|
|
129
|
+ /**
|
|
|
130
|
+ * 女生节第四波领券活动-创意生活品牌页面控制器
|
|
|
131
|
+ */
|
|
|
132
|
+ public function lifestyleAction()
|
|
|
133
|
+ {
|
|
|
134
|
+ // 判断是否是应用访问, 拼接APP需要的URL参数
|
|
|
135
|
+ $isApp = null !== $this->get('app_version');
|
|
|
136
|
+ $isAppLogged = true;
|
|
|
137
|
+ if ($isApp) {
|
|
|
138
|
+ $isLogged = $this->get('uid') !== null;
|
|
|
139
|
+ $isAppLogged = $this->checkIsLogin();
|
|
|
140
|
+ } else {
|
|
|
141
|
+ $isLogged = $this->getUid();
|
|
|
142
|
+ }
|
|
|
143
|
+ $urlKids = Helpers::url('/cuxiao/girlfour/lifestyle');
|
|
|
144
|
+ $urlEncode = strtr($urlKids, array('/' => '\\/'));
|
|
|
145
|
+
|
|
|
146
|
+ $this->_view->display('index', array(
|
|
|
147
|
+ 'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
|
|
|
148
|
+ 'staticJS' => array(
|
|
|
149
|
+ 'main.js'
|
|
|
150
|
+ ),
|
|
|
151
|
+ 'jumpUrl' => $isAppLogged ? 'javascript:;' : $urlKids . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $urlEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}',
|
|
|
152
|
+ 'isOnline' => $this->getisOnline(),
|
|
|
153
|
+ 'pageType' => 'lifestyle',
|
|
|
154
|
+ 'tab' => array('us', 'hot', 'more'),
|
|
|
155
|
+ 'moreBrand' => 'http://feature.yoho.cn/0318/TICKETSLIFE/index.html',
|
|
|
156
|
+ 'isApp' => $this->_isApp,
|
|
|
157
|
+ 'isAppLogin' => $isAppLogged,
|
|
|
158
|
+ 'getCouponUrl' => Helpers::url('/cuxiao/girlfour/getnamed', array('uid' => $this->getLoggedUid())),
|
|
|
159
|
+ 'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
|
|
|
160
|
+ 'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
|
|
|
161
|
+ 'shareImg' => 'http://img02.yohoboys.com/staticimg/2016/03/10/10/0298ef8fbbb543144af487fbcd6718041b.png',
|
|
|
162
|
+ 'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
|
|
|
163
|
+ ));
|
|
|
164
|
+ }
|
|
|
165
|
+
|
|
|
166
|
+ /**
|
|
|
167
|
+ * 领取指定的优惠券
|
|
|
168
|
+ *
|
|
|
169
|
+ * @param int activityId 活动ID
|
|
|
170
|
+ * @param int couponId 优惠券ID
|
|
|
171
|
+ * @return json
|
|
|
172
|
+ */
|
|
|
173
|
+ public function getnamedAction()
|
|
|
174
|
+ {
|
|
|
175
|
+ $result = array('code' => 401, 'message' => '领取失败', 'data' => '');
|
|
|
176
|
+ do {
|
|
|
177
|
+ /* 判断是不是AJAX请求 */
|
|
|
178
|
+ if (!$this->isAjax()) {
|
|
|
179
|
+ break;
|
|
|
180
|
+ }
|
|
|
181
|
+
|
|
|
182
|
+ /* 判断参数是否有效 */
|
|
|
183
|
+ $couponId = $this->post('couponId');
|
|
|
184
|
+ $activityId = $this->getActivityId();
|
|
|
185
|
+ if (!is_numeric($activityId) || !is_numeric($couponId)) {
|
|
|
186
|
+ break;
|
|
|
187
|
+ }
|
|
|
188
|
+ $uid = $this->getLoggedUid();
|
|
|
189
|
+ if (!$uid) {
|
|
|
190
|
+ $result['code'] = 400;
|
|
|
191
|
+ $result['message'] = '请先登录';
|
|
|
192
|
+ $result['data'] = Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', '/')), 'default');
|
|
|
193
|
+ break;
|
|
|
194
|
+ }
|
|
|
195
|
+
|
|
|
196
|
+ /* 领取指定的优惠券操作 */
|
|
|
197
|
+ $result = ActivityData::getCouponNamed($uid, $activityId, $couponId);
|
|
|
198
|
+ if ($uid && isset($result['code']) && intval($result['code'])==200) {
|
|
|
199
|
+ $couponfour='couponnvshengjiedisibo'.$uid;
|
|
|
200
|
+ $status = Cache::get($couponfour);
|
|
|
201
|
+ if(!$status){
|
|
|
202
|
+ $this->sendMessage($uid, '【优惠券】您已成功领取春潮新势力-品牌优惠券。', '尊敬的客户:恭喜您成功获得春潮新势力-品牌优惠券 !您可以在个人中心查看优惠券详情。');
|
|
|
203
|
+ Cache::set($couponfour,true,3600*24*5);
|
|
|
204
|
+ }
|
|
|
205
|
+ }
|
|
|
206
|
+ } while (false);
|
|
|
207
|
+
|
|
|
208
|
+ $this->echoJson($result);
|
|
|
209
|
+ }
|
|
|
210
|
+
|
|
|
211
|
+ /**
|
|
|
212
|
+ * 检测登录状态
|
|
|
213
|
+ *
|
|
|
214
|
+ */
|
|
|
215
|
+ private function getLoggedUid()
|
|
|
216
|
+ {
|
|
|
217
|
+ if ($this->_isApp) {
|
|
|
218
|
+ $uid = $this->get('uid');
|
|
|
219
|
+ } else {
|
|
|
220
|
+ $uid = $this->getUid();
|
|
|
221
|
+ }
|
|
|
222
|
+
|
|
|
223
|
+ return $uid;
|
|
|
224
|
+ }
|
|
|
225
|
+
|
|
|
226
|
+ /**
|
|
|
227
|
+ * 发送站内信
|
|
|
228
|
+ *
|
|
|
229
|
+ * @param int $uid 用户ID
|
|
|
230
|
+ */
|
|
|
231
|
+ private function sendMessage($uid, $title, $content)
|
|
|
232
|
+ {
|
|
|
233
|
+ try {
|
|
|
234
|
+ ActivityData::message($uid, $title, $content);
|
|
|
235
|
+ } catch (Exception $e) {
|
|
|
236
|
+ // do nothing
|
|
|
237
|
+ }
|
|
|
238
|
+ }
|
|
|
239
|
+
|
|
|
240
|
+ /**
|
|
|
241
|
+ * 检查用户是否登录
|
|
|
242
|
+ *
|
|
|
243
|
+ * @return bool (false:表示未登录,true:表示已登录)
|
|
|
244
|
+ */
|
|
|
245
|
+ private function checkIsLogin()
|
|
|
246
|
+ {
|
|
|
247
|
+ do {
|
|
|
248
|
+ /* 判断是否有参数 */
|
|
|
249
|
+ $uid = $this->get('uid');
|
|
|
250
|
+ if (empty($uid) || !is_numeric($uid)) {
|
|
|
251
|
+ break;
|
|
|
252
|
+ }
|
|
|
253
|
+
|
|
|
254
|
+ /* 判断参数是否有效 */
|
|
|
255
|
+ $secret = $this->get('client_secret');
|
|
|
256
|
+ if (!isset($secret)) {
|
|
|
257
|
+ break;
|
|
|
258
|
+ }
|
|
|
259
|
+
|
|
|
260
|
+ $this->setSession(self::SESSION_UID, $uid);
|
|
|
261
|
+
|
|
|
262
|
+ return true;
|
|
|
263
|
+ } while (false);
|
|
|
264
|
+
|
|
|
265
|
+ return false;
|
|
|
266
|
+ }
|
|
|
267
|
+
|
|
|
268
|
+ /**
|
|
|
269
|
+ * 根据环境来获取线上线下
|
|
|
270
|
+ *
|
|
|
271
|
+ * @return int
|
|
|
272
|
+ */
|
|
|
273
|
+ private function getisOnline()
|
|
|
274
|
+ {
|
|
|
275
|
+ // 设置环境变量
|
|
|
276
|
+ switch (APPLICATION_ENV) {
|
|
|
277
|
+ case 'production': // 生产
|
|
|
278
|
+ return 1;
|
|
|
279
|
+ case 'preview': // 预览
|
|
|
280
|
+ case 'testing': // 测试
|
|
|
281
|
+ case 'develop': // 开发
|
|
|
282
|
+ default:
|
|
|
283
|
+ return 0;
|
|
|
284
|
+ }
|
|
|
285
|
+ }
|
|
|
286
|
+
|
|
|
287
|
+ /**
|
|
|
288
|
+ * 根据环境来获取活动ID
|
|
|
289
|
+ *
|
|
|
290
|
+ * @return int
|
|
|
291
|
+ */
|
|
|
292
|
+ private function getActivityId()
|
|
|
293
|
+ {
|
|
|
294
|
+ // 设置环境变量
|
|
|
295
|
+ switch (APPLICATION_ENV) {
|
|
|
296
|
+ case 'production': // 生产
|
|
|
297
|
+ return 558;
|
|
|
298
|
+ case 'preview': // 预览
|
|
|
299
|
+ case 'testing': // 测试
|
|
|
300
|
+ case 'develop': // 开发
|
|
|
301
|
+ default:
|
|
|
302
|
+ return 496;
|
|
|
303
|
+ }
|
|
|
304
|
+ }
|
|
|
305
|
+
|
|
|
306
|
+}
|
|
|
307
|
+
|
|
|
308
|
+?> |