1
|
<?php
|
1
|
<?php
|
|
|
2
|
+
|
2
|
/**
|
3
|
/**
|
3
|
* Created by PhpStorm.
|
4
|
* Created by PhpStorm.
|
4
|
* User: Administrator
|
5
|
* User: Administrator
|
|
@@ -8,41 +9,190 @@ |
|
@@ -8,41 +9,190 @@ |
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();
|
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
|
+ ));
|
30
|
}
|
46
|
}
|
31
|
- return $uid;
|
47
|
+
|
|
|
48
|
+ /**
|
|
|
49
|
+ * 领券活动-第三波页面控制器
|
|
|
50
|
+ */
|
|
|
51
|
+ public function girlthreeBoyAction()
|
|
|
52
|
+ {
|
|
|
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
|
+ ));
|
32
|
}
|
66
|
}
|
33
|
|
67
|
|
34
|
/**
|
68
|
/**
|
35
|
- * 判断是否登录
|
69
|
+ * 女生节第3波-女生的品牌领券
|
36
|
*/
|
70
|
*/
|
37
|
- private function checkLogin()
|
71
|
+ public function girlthreeGirlAction()
|
38
|
{
|
72
|
{
|
39
|
- $url = Helpers::url('/cuxiao/girlday/index');
|
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
|
+ }
|
|
|
87
|
+
|
|
|
88
|
+ /**
|
|
|
89
|
+ * 女生节第3波-童品牌领券
|
|
|
90
|
+ */
|
|
|
91
|
+ public function girlthreeKidAction()
|
|
|
92
|
+ {
|
|
|
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
|
+ ));
|
|
|
106
|
+ }
|
|
|
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
|
+ }
|
|
|
127
|
+
|
|
|
128
|
+ /**
|
|
|
129
|
+ * 领券接口
|
|
|
130
|
+ */
|
|
|
131
|
+ public function sendCouponAction()
|
|
|
132
|
+ {
|
|
|
133
|
+ $result = array('code' => 201);
|
|
|
134
|
+
|
|
|
135
|
+ do {
|
|
|
136
|
+ if (!$this->isAjax()) {
|
|
|
137
|
+ break;
|
|
|
138
|
+ }
|
|
|
139
|
+
|
|
|
140
|
+ $activityId = $this->getActivityId();
|
40
|
$uid = $this->getLoggedUid();
|
141
|
$uid = $this->getLoggedUid();
|
|
|
142
|
+ $result = GirldayModel::getGirldayCoupon($uid, $activityId);
|
|
|
143
|
+
|
|
|
144
|
+ } while (false);
|
|
|
145
|
+
|
|
|
146
|
+ $this->echoJson($result);
|
|
|
147
|
+ }
|
|
|
148
|
+
|
|
|
149
|
+ /**
|
|
|
150
|
+ * 领取指定的优惠券
|
|
|
151
|
+ *
|
|
|
152
|
+ * @param int activityId 活动ID
|
|
|
153
|
+ * @param int couponId 优惠券ID
|
|
|
154
|
+ * @return json
|
|
|
155
|
+ */
|
|
|
156
|
+ public function getnamedAction()
|
|
|
157
|
+ {
|
|
|
158
|
+ $result = array('code' => 401, 'message' => '领取失败', 'data' => '');
|
|
|
159
|
+
|
|
|
160
|
+ do {
|
|
|
161
|
+ /* 判断是不是AJAX请求 */
|
|
|
162
|
+ if (!$this->isAjax()) {
|
|
|
163
|
+ break;
|
|
|
164
|
+ }
|
|
|
165
|
+
|
|
|
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();
|
41
|
if (!$uid) {
|
174
|
if (!$uid) {
|
42
|
- $this->go(Helpers::url('/signin.html', array('refer' => $url), 'default'));
|
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);
|
43
|
}
|
190
|
}
|
44
|
}
|
191
|
}
|
|
|
192
|
+ } while (false);
|
45
|
|
193
|
|
|
|
194
|
+ $this->echoJson($result);
|
|
|
195
|
+ }
|
46
|
|
196
|
|
47
|
/**
|
197
|
/**
|
48
|
* 根据环境来获取活动ID
|
198
|
* 根据环境来获取活动ID
|
|
@@ -59,50 +209,87 @@ class GirldayController extends HuodongWebAction |
|
@@ -59,50 +209,87 @@ class GirldayController extends HuodongWebAction |
59
|
case 'testing': // 测试
|
209
|
case 'testing': // 测试
|
60
|
case 'develop': // 开发
|
210
|
case 'develop': // 开发
|
61
|
default:
|
211
|
default:
|
62
|
- return 528; //490;
|
212
|
+ return 540;
|
63
|
}
|
213
|
}
|
64
|
}
|
214
|
}
|
65
|
|
215
|
|
66
|
-
|
|
|
67
|
/**
|
216
|
/**
|
68
|
- * 领券接口
|
217
|
+ * 根据环境来获取活动ID
|
|
|
218
|
+ *
|
|
|
219
|
+ * @return int
|
69
|
*/
|
220
|
*/
|
70
|
- public function sendCouponAction()
|
221
|
+ private function getthreeActivityId()
|
71
|
{
|
222
|
{
|
72
|
- $result = array('code' => 201);
|
|
|
73
|
-
|
|
|
74
|
- do {
|
|
|
75
|
- if (!$this->isAjax()) {
|
|
|
76
|
- break;
|
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
|
+ }
|
77
|
}
|
233
|
}
|
78
|
|
234
|
|
79
|
- $activityId = $this->getActivityId();
|
|
|
80
|
- $uid = $this->getLoggedUid();
|
|
|
81
|
- $result = GirldayModel::getGirldayCoupon($uid, $activityId);
|
|
|
82
|
- } while (false);
|
|
|
83
|
-
|
|
|
84
|
- $this->echoJson($result);
|
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
|
+ }
|
85
|
}
|
247
|
}
|
86
|
|
248
|
|
87
|
- public function indexAction()
|
249
|
+ /**
|
|
|
250
|
+ * 根据环境来获取线上线下
|
|
|
251
|
+ *
|
|
|
252
|
+ * @return int
|
|
|
253
|
+ */
|
|
|
254
|
+ private function getisOnline()
|
88
|
{
|
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
|
+ }
|
89
|
|
267
|
|
90
|
- $this->checkLogin();
|
|
|
91
|
- //获取跳转到个人中心-我的优惠券链接,并调用接口,完成领券操作
|
|
|
92
|
- $myCouponUrl = Helpers::url('/home/coupons', null, 'default');
|
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
|
+ }
|
93
|
|
282
|
|
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
|
- ));
|
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'));
|
107
|
}
|
292
|
}
|
|
|
293
|
+ }
|
|
|
294
|
+
|
108
|
} |
295
|
} |