1
|
<?php
|
1
|
<?php
|
|
|
2
|
+
|
2
|
/**
|
3
|
/**
|
3
|
* Created by PhpStorm.
|
4
|
* Created by PhpStorm.
|
4
|
* User: Administrator
|
5
|
* User: Administrator
|
|
@@ -8,61 +9,121 @@ |
|
@@ -8,61 +9,121 @@ |
8
|
use Action\HuodongWebAction;
|
9
|
use Action\HuodongWebAction;
|
9
|
use Cuxiao\GirldayModel;
|
10
|
use Cuxiao\GirldayModel;
|
10
|
use WebPlugin\Helpers;
|
11
|
use WebPlugin\Helpers;
|
|
|
12
|
+use LibModels\Wap\Cuxiao\ActivityData;
|
|
|
13
|
+use Plugin\Cache;
|
|
|
14
|
+
|
11
|
/**
|
15
|
/**
|
12
|
* 女生节活动领券-第二波
|
16
|
* 女生节活动领券-第二波
|
13
|
* @author Administrator
|
17
|
* @author Administrator
|
14
|
*/
|
18
|
*/
|
15
|
class GirldayController extends HuodongWebAction
|
19
|
class GirldayController extends HuodongWebAction
|
16
|
{
|
20
|
{
|
17
|
- // const STATIC_FILE = 'http://localhost:2222/1.0.3';
|
|
|
18
|
- const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016xinshili-2-web/1.0.3';
|
21
|
+ const STATIC_FILE = 'http://cdn.yoho.cn/huodong/2016xinshili-2-web/1.0.2';
|
|
|
22
|
+
|
19
|
/**
|
23
|
/**
|
20
|
- * 检测登录状态
|
|
|
21
|
- *
|
|
|
22
|
- * @return int
|
24
|
+ * 第二波
|
23
|
*/
|
25
|
*/
|
24
|
- private function getLoggedUid()
|
26
|
+ public function indexAction()
|
25
|
{
|
27
|
{
|
26
|
- if ($this->_isApp) {
|
|
|
27
|
- $uid = $this->get('uid');
|
|
|
28
|
- } else {
|
|
|
29
|
- $uid = $this->getUid();
|
|
|
30
|
- }
|
|
|
31
|
- return $uid;
|
28
|
+ //echo
|
|
|
29
|
+ $this->checkLogin();
|
|
|
30
|
+ //获取跳转到个人中心-我的优惠券链接,并调用接口,完成领券操作
|
|
|
31
|
+ $myCouponUrl = Helpers::url('/home/coupons', null, 'default');
|
|
|
32
|
+
|
|
|
33
|
+ $this->_view->display('index', array(
|
|
|
34
|
+ 'staticTitle' => 'YOHO!BUY有货【春潮新势力】', // 标题
|
|
|
35
|
+ 'staticFile' => self::STATIC_FILE,
|
|
|
36
|
+ 'staticJS' => array(
|
|
|
37
|
+ 'home.js'
|
|
|
38
|
+ ),
|
|
|
39
|
+ 'couponUrl' => $myCouponUrl, // 个人中心优惠券地址
|
|
|
40
|
+ 'banner' => array(
|
|
|
41
|
+ 'img' => '',
|
|
|
42
|
+ 'url' => 'http://www.yohobuy.com/special_14548_0310PCHOME.html',
|
|
|
43
|
+ ),
|
|
|
44
|
+ 'selectUrl' => 'http://www.yohobuy.com/home/coupons',
|
|
|
45
|
+ ));
|
32
|
}
|
46
|
}
|
33
|
|
47
|
|
34
|
/**
|
48
|
/**
|
35
|
- * 判断是否登录
|
49
|
+ * 领券活动-第三波页面控制器
|
36
|
*/
|
50
|
*/
|
37
|
- private function checkLogin()
|
51
|
+ public function girlthreeBoyAction()
|
38
|
{
|
52
|
{
|
39
|
- $url = Helpers::url('/cuxiao/girlday/index');
|
|
|
40
|
- $uid = $this->getLoggedUid();
|
|
|
41
|
- if (!$uid) {
|
|
|
42
|
- $this->go(Helpers::url('/signin.html', array('refer' => $url), 'default'));
|
|
|
43
|
- }
|
53
|
+ $this->_view->display('girlsday-three', array(
|
|
|
54
|
+ 'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
|
|
|
55
|
+ 'staticJS' => array(
|
|
|
56
|
+ 'main.js'
|
|
|
57
|
+ ),
|
|
|
58
|
+ 'jumpUrl' => 'javascript:;',
|
|
|
59
|
+ 'pageType' => 'boy',
|
|
|
60
|
+ 'tab' => array('us', 'bag', 'yohope', 'shoes'),
|
|
|
61
|
+ 'isOnline' => $this->getisOnline(),
|
|
|
62
|
+ 'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
|
|
|
63
|
+ 'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
|
|
|
64
|
+ 'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
|
|
|
65
|
+ ));
|
44
|
}
|
66
|
}
|
45
|
|
67
|
|
|
|
68
|
+ /**
|
|
|
69
|
+ * 女生节第3波-女生的品牌领券
|
|
|
70
|
+ */
|
|
|
71
|
+ public function girlthreeGirlAction()
|
|
|
72
|
+ {
|
|
|
73
|
+ $this->_view->display('girlsday-three', array(
|
|
|
74
|
+ 'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
|
|
|
75
|
+ 'staticJS' => array(
|
|
|
76
|
+ 'main.js'
|
|
|
77
|
+ ),
|
|
|
78
|
+ 'jumpUrl' => 'javascript:;',
|
|
|
79
|
+ 'pageType' => 'girl',
|
|
|
80
|
+ 'tab' => array('us', 'huimei', 'sport', 'yohope'),
|
|
|
81
|
+ 'isOnline' => $this->getisOnline(),
|
|
|
82
|
+ 'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
|
|
|
83
|
+ 'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
|
|
|
84
|
+ 'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
|
|
|
85
|
+ ));
|
|
|
86
|
+ }
|
46
|
|
87
|
|
47
|
/**
|
88
|
/**
|
48
|
- * 根据环境来获取活动ID
|
|
|
49
|
- *
|
|
|
50
|
- * @return int
|
89
|
+ * 女生节第3波-童品牌领券
|
51
|
*/
|
90
|
*/
|
52
|
- private function getActivityId()
|
91
|
+ public function girlthreeKidAction()
|
53
|
{
|
92
|
{
|
54
|
- // 设置环境变量
|
|
|
55
|
- switch (APPLICATION_ENV) {
|
|
|
56
|
- case 'production': // 生产
|
|
|
57
|
- return 528;
|
|
|
58
|
- case 'preview': // 预览
|
|
|
59
|
- case 'testing': // 测试
|
|
|
60
|
- case 'develop': // 开发
|
|
|
61
|
- default:
|
|
|
62
|
- return 528; //490;
|
|
|
63
|
- }
|
93
|
+ $this->_view->display('girlsday-three', array(
|
|
|
94
|
+ 'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
|
|
|
95
|
+ 'staticJS' => array(
|
|
|
96
|
+ 'main.js'
|
|
|
97
|
+ ),
|
|
|
98
|
+ 'jumpUrl' => 'javascript:;',
|
|
|
99
|
+ 'pageType' => 'kid',
|
|
|
100
|
+ // 'tab' => array('us', 'bag', 'yohope', 'shoes'),
|
|
|
101
|
+ 'isOnline' => $this->getisOnline(),
|
|
|
102
|
+ 'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
|
|
|
103
|
+ 'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
|
|
|
104
|
+ 'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
|
|
|
105
|
+ ));
|
64
|
}
|
106
|
}
|
65
|
|
107
|
|
|
|
108
|
+ /**
|
|
|
109
|
+ * 女生节第3波-创意生活品牌领券
|
|
|
110
|
+ */
|
|
|
111
|
+ public function girlthreeLifestyleAction()
|
|
|
112
|
+ {
|
|
|
113
|
+ $this->_view->display('girlsday-three', array(
|
|
|
114
|
+ 'staticTitle' => 'YOHO!BUY有货【春潮新势力】',
|
|
|
115
|
+ 'staticJS' => array(
|
|
|
116
|
+ 'main.js'
|
|
|
117
|
+ ),
|
|
|
118
|
+ 'jumpUrl' => 'javascript:;',
|
|
|
119
|
+ 'pageType' => 'lifestyle',
|
|
|
120
|
+ 'tab' => array('us', 'hot'),
|
|
|
121
|
+ 'isOnline' => $this->getisOnline(),
|
|
|
122
|
+ 'shareTitle' => 'YOHO!BUY有货【春潮新势力】千万元优惠券限时派送中!',
|
|
|
123
|
+ 'shareDesc' => '全球1000+潮牌春季上新,万款新品首发,唤醒潮流尽在有货【春潮新势力】!',
|
|
|
124
|
+ 'shareLink' => 'http://feature.yoho.cn/0318/0318APPHOME/index.html',
|
|
|
125
|
+ ));
|
|
|
126
|
+ }
|
66
|
|
127
|
|
67
|
/**
|
128
|
/**
|
68
|
* 领券接口
|
129
|
* 领券接口
|
|
@@ -79,30 +140,156 @@ class GirldayController extends HuodongWebAction |
|
@@ -79,30 +140,156 @@ class GirldayController extends HuodongWebAction |
79
|
$activityId = $this->getActivityId();
|
140
|
$activityId = $this->getActivityId();
|
80
|
$uid = $this->getLoggedUid();
|
141
|
$uid = $this->getLoggedUid();
|
81
|
$result = GirldayModel::getGirldayCoupon($uid, $activityId);
|
142
|
$result = GirldayModel::getGirldayCoupon($uid, $activityId);
|
|
|
143
|
+
|
82
|
} while (false);
|
144
|
} while (false);
|
83
|
|
145
|
|
84
|
$this->echoJson($result);
|
146
|
$this->echoJson($result);
|
85
|
}
|
147
|
}
|
86
|
|
148
|
|
87
|
- public function indexAction()
|
149
|
+ /**
|
|
|
150
|
+ * 领取指定的优惠券
|
|
|
151
|
+ *
|
|
|
152
|
+ * @param int activityId 活动ID
|
|
|
153
|
+ * @param int couponId 优惠券ID
|
|
|
154
|
+ * @return json
|
|
|
155
|
+ */
|
|
|
156
|
+ public function getnamedAction()
|
88
|
{
|
157
|
{
|
|
|
158
|
+ $result = array('code' => 401, 'message' => '领取失败', 'data' => '');
|
89
|
|
159
|
|
90
|
- $this->checkLogin();
|
|
|
91
|
- //获取跳转到个人中心-我的优惠券链接,并调用接口,完成领券操作
|
|
|
92
|
- $myCouponUrl = Helpers::url('/home/coupons', null, 'default');
|
160
|
+ do {
|
|
|
161
|
+ /* 判断是不是AJAX请求 */
|
|
|
162
|
+ if (!$this->isAjax()) {
|
|
|
163
|
+ break;
|
|
|
164
|
+ }
|
93
|
|
165
|
|
94
|
- $this->_view->display('index', array(
|
|
|
95
|
- 'staticTitle' => 'YOHO!BUY有货【春潮新势力】', // 标题
|
|
|
96
|
- 'staticFile' => self::STATIC_FILE,
|
|
|
97
|
- 'staticJS' => array(
|
|
|
98
|
- 'home.js'
|
|
|
99
|
- ),
|
|
|
100
|
- 'couponUrl' => $myCouponUrl, // 个人中心优惠券地址
|
|
|
101
|
- 'banner' => array(
|
|
|
102
|
- 'img' => 'http://img02.yohoboys.com/staticimg/2016/03/10/10/020ea7cb1f9c2f26b14e08107f778485ff.jpg',
|
|
|
103
|
- 'url' => 'http://www.yohobuy.com/special_14548_0310PCHOME.html',
|
|
|
104
|
- ),
|
|
|
105
|
- 'selectUrl' => 'http://www.yohobuy.com/home/coupons',
|
|
|
106
|
- ));
|
166
|
+ /* 判断参数是否有效 */
|
|
|
167
|
+ $activityId = $this->getthreeActivityId();
|
|
|
168
|
+ $couponId = $this->post('couponId');
|
|
|
169
|
+ if (!is_numeric($activityId) || !is_numeric($couponId)) {
|
|
|
170
|
+ break;
|
|
|
171
|
+ }
|
|
|
172
|
+
|
|
|
173
|
+ $uid = $this->getUid();
|
|
|
174
|
+ if (!$uid) {
|
|
|
175
|
+ $result['code'] = 400;
|
|
|
176
|
+ $result['message'] = '请先登录';
|
|
|
177
|
+ $result['data'] = Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', '/')), 'default');
|
|
|
178
|
+ break;
|
|
|
179
|
+ }
|
|
|
180
|
+
|
|
|
181
|
+ /* 领取指定的优惠券操作 */
|
|
|
182
|
+ $result = ActivityData::getCouponNamed($uid, $activityId, $couponId);
|
|
|
183
|
+ if ($uid && isset($result['code']) && $result['code'] == 200) {
|
|
|
184
|
+ // 领取成功, 发送站内信消息
|
|
|
185
|
+ $couponuid = 'couponnvshengjiedisanbo' . $uid;
|
|
|
186
|
+ $status = Cache::get($couponuid);
|
|
|
187
|
+ if (!$status) {
|
|
|
188
|
+ $this->sendMessage($uid, '【优惠券】您已成功领取春潮新势力-品牌优惠券。', '尊敬的客户:恭喜您成功获得春潮新势力-品牌优惠券 !您可以在个人中心查看优惠券详情。');
|
|
|
189
|
+ Cache::set($couponuid, true, 3600 * 24 * 5);
|
|
|
190
|
+ }
|
|
|
191
|
+ }
|
|
|
192
|
+ } while (false);
|
|
|
193
|
+
|
|
|
194
|
+ $this->echoJson($result);
|
107
|
}
|
195
|
}
|
|
|
196
|
+
|
|
|
197
|
+ /**
|
|
|
198
|
+ * 根据环境来获取活动ID
|
|
|
199
|
+ *
|
|
|
200
|
+ * @return int
|
|
|
201
|
+ */
|
|
|
202
|
+ private function getActivityId()
|
|
|
203
|
+ {
|
|
|
204
|
+ // 设置环境变量
|
|
|
205
|
+ switch (APPLICATION_ENV) {
|
|
|
206
|
+ case 'production': // 生产
|
|
|
207
|
+ return 528;
|
|
|
208
|
+ case 'preview': // 预览
|
|
|
209
|
+ case 'testing': // 测试
|
|
|
210
|
+ case 'develop': // 开发
|
|
|
211
|
+ default:
|
|
|
212
|
+ return 540;
|
|
|
213
|
+ }
|
|
|
214
|
+ }
|
|
|
215
|
+
|
|
|
216
|
+ /**
|
|
|
217
|
+ * 根据环境来获取活动ID
|
|
|
218
|
+ *
|
|
|
219
|
+ * @return int
|
|
|
220
|
+ */
|
|
|
221
|
+ private function getthreeActivityId()
|
|
|
222
|
+ {
|
|
|
223
|
+ // 设置环境变量
|
|
|
224
|
+ switch (APPLICATION_ENV) {
|
|
|
225
|
+ case 'production': // 生产
|
|
|
226
|
+ return 544;
|
|
|
227
|
+ case 'preview': // 预览
|
|
|
228
|
+ case 'testing': // 测试
|
|
|
229
|
+ case 'develop': // 开发
|
|
|
230
|
+ default:
|
|
|
231
|
+ return 496;
|
|
|
232
|
+ }
|
|
|
233
|
+ }
|
|
|
234
|
+
|
|
|
235
|
+ /**
|
|
|
236
|
+ * 发送站内信
|
|
|
237
|
+ *
|
|
|
238
|
+ * @param int $uid 用户ID
|
|
|
239
|
+ */
|
|
|
240
|
+ private function sendMessage($uid, $title, $content)
|
|
|
241
|
+ {
|
|
|
242
|
+ try {
|
|
|
243
|
+ ActivityData::message($uid, $title, $content);
|
|
|
244
|
+ } catch (Exception $e) {
|
|
|
245
|
+ // do nothing
|
|
|
246
|
+ }
|
|
|
247
|
+ }
|
|
|
248
|
+
|
|
|
249
|
+ /**
|
|
|
250
|
+ * 根据环境来获取线上线下
|
|
|
251
|
+ *
|
|
|
252
|
+ * @return int
|
|
|
253
|
+ */
|
|
|
254
|
+ private function getisOnline()
|
|
|
255
|
+ {
|
|
|
256
|
+ // 设置环境变量
|
|
|
257
|
+ switch (APPLICATION_ENV) {
|
|
|
258
|
+ case 'production': // 生产
|
|
|
259
|
+ return 1;
|
|
|
260
|
+ case 'preview': // 预览
|
|
|
261
|
+ case 'testing': // 测试
|
|
|
262
|
+ case 'develop': // 开发
|
|
|
263
|
+ default:
|
|
|
264
|
+ return 0;
|
|
|
265
|
+ }
|
|
|
266
|
+ }
|
|
|
267
|
+
|
|
|
268
|
+ /**
|
|
|
269
|
+ * 检测登录状态
|
|
|
270
|
+ *
|
|
|
271
|
+ * @return int
|
|
|
272
|
+ */
|
|
|
273
|
+ private function getLoggedUid()
|
|
|
274
|
+ {
|
|
|
275
|
+ if ($this->_isApp) {
|
|
|
276
|
+ $uid = $this->get('uid');
|
|
|
277
|
+ } else {
|
|
|
278
|
+ $uid = $this->getUid();
|
|
|
279
|
+ }
|
|
|
280
|
+ return $uid;
|
|
|
281
|
+ }
|
|
|
282
|
+
|
|
|
283
|
+ /**
|
|
|
284
|
+ * 判断是否登录
|
|
|
285
|
+ */
|
|
|
286
|
+ private function checkLogin()
|
|
|
287
|
+ {
|
|
|
288
|
+ $url = Helpers::url('/cuxiao/girlday/index');
|
|
|
289
|
+ $uid = $this->getLoggedUid();
|
|
|
290
|
+ if (!$uid) {
|
|
|
291
|
+ $this->go(Helpers::url('/signin.html', array('refer' => $url), 'default'));
|
|
|
292
|
+ }
|
|
|
293
|
+ }
|
|
|
294
|
+
|
108
|
} |
295
|
} |