Coupon.php
8.56 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
<?php
/**
* Created by PhpStorm.
* User: Targaryen
* Date: 2016/4/11
* Time: 16:31
*/
use LibModels\Wap\Coupon\CouponData;
use Action\AbstractAction;
use Plugin\DataProcess\CouponFloorProcess;
use Plugin\Helpers;
class CouponController extends AbstractAction
{
/**
* 领券楼层数据列表
*
* @author Targaryen
*/
public function floorAction()
{
$receiveData = filter_input_array(INPUT_GET, array(
'contentCode' => FILTER_DEFAULT
));
$result = array();
// $uid = $this->getUid();
// 调用模拟接口
// $resource = $this->getFloor();
$resource = CouponData::getCouponRousource('b38b9c4f1c76f89533e9214629b458e4', 8040274);
// $resource = CouponData::getCouponRousource($receiveData['contentCode'],$uid);
if (isset($resource['code']) && $resource['code'] == 200) {
$result = CouponFloorProcess::getContent($resource['data']);
}
// CouponFloorProcess::debugOut($resource);
$this->_view->display('index', array(
'content' => $result,
'floorPage' => true
));
}
/**
* 领券操作
*
* @author Targaryen
*/
public function receiveCouponAction()
{
// CouponFloorProcess::debugOut(CouponData::receiveCoupon(7893817,1516));
$returnData = array();
// 获取优惠券 ID
$receiveData = filter_input_array(INPUT_GET, array(
'couponID' => FILTER_DEFAULT
));
// 跳转 URl
$playUrl = 'coupon/floor';
// 判断用户是否登录
if (!$this->getUid() || !is_numeric($this->getUid())) {
// 用户未登录,跳转登录页面
$returnData['noLogin'] = true;
if (!$this->isApp()) {
$returnData['url'] = Helpers::url('/signin.html', array('refer' => $playUrl), 'default');
} else {
$playUrlEncode = strtr($playUrl, array('/' => '\\/'));
$returnData['url'] = $playUrl . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $playUrlEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}';
}
} else {
// 登录后调用领券接口
$result = CouponData::receiveCoupon($this->getUid(),$receiveData['couponID']);
switch ($result['code']) {
case 200:
$returnData = array(
'msg' => '领券成功!',
'status' => true,
);
break;
default:
$returnData = array(
'msg' => '领券失败!',
'status' => false,
);
break;
}
}
echo json_encode($returnData);
}
/**
* 领券接口模拟
*
* @param $couponId
* @return array
* @internal param $couponId
*/
public function getCouponHandler($couponId)
{
if ($couponId) {
$result['alg'] = 'SALT_MD5';
$result['code'] = 200;
$result['data'] = '';
$result['md5'] = '50d19f5f5098c34607018f144baec14a';
$result['message'] = '操作成功';
} else {
$result['alg'] = 'SALT_MD5';
$result['code'] = 402;
$result['data'] = '';
$result['md5'] = '50d19f5f5098c34607018f144baec14a';
$result['message'] = '操作失败';
}
/* // 组合接口参数
$params['method'] = 'app.promotion.getCoupon';
$params['couponId'] = $couponId;
$params['uid'] = $this->getUid();
$result = \Api\YohobuyH5::get(\Api\YohobuyH5::SERVICE_URL, $params);*/
return $result;
}
/**
* 判断是否是 APP
*
* @return bool
*/
public function isApp()
{
return (null !== $this->get('app_version'));
}
/**
* 模拟后台接口数据
*
* @return array
*/
public function getFloor()
{
$result = array();
$result = [
'alg' => 'SALT_MD5',
'code' => 200,
'data' => [
0 => [
'data' => [
'list' => [
0 => [
'couponID' => 2516,
'status' => 1,
'goShopping' => 'http://item.m.yohobuy.com/product/pro_325933_419711/XiongJiaYouPin619081838990XiongJiaYouPinChuangYiLanRenTanZhuTuiKuan.html',
'image' => [
'src' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/01/02f639de49d79ece0cf86a2f214be781da.jpg?imageView/2/w/640/h/200',
'url' => 'http://2percent.yohobuy.com/?gender=2,3\n',
],
'isShow' => 'YES',
'title' => '标题内容',
],
],
],
'template_id' => 1111253,
'template_name' => 'getCoupon'
],
1 => [
'data' => [
'list' => [
0 => [
'couponID' => 200,
'status' => 3,
'goShopping' => 'http://item.m.yohobuy.com/product/pro_325933_419711/XiongJiaYouPin619081838990XiongJiaYouPinChuangYiLanRenTanZhuTuiKuan.html',
'image' => [
'src' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/01/02f639de49d79ece0cf86a2f214be781da.jpg?imageView/2/w/640/h/200',
'url' => 'http://2percent.yohobuy.com/?gender=2,3\n',
],
'isShow' => 'YES',
'title' => '标题内容',
],
],
],
'template_id' => 1111257,
'template_name' => 'getCoupon'
],
2 => [
'data' => [
'list' => [
0 => [
'couponID' => 1565,
'status' => 2,
'goShopping' => 'http://item.m.yohobuy.com/product/pro_325933_419711/XiongJiaYouPin619081838990XiongJiaYouPinChuangYiLanRenTanZhuTuiKuan.html',
'image' => [
'src' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/01/02f639de49d79ece0cf86a2f214be781da.jpg?imageView/2/w/640/h/200',
'url' => 'http://2percent.yohobuy.com/?gender=2,3\n',
],
'isShow' => 'YES',
'title' => '标题内容',
],
],
],
'template_id' => 1111255,
'template_name' => 'getCoupon'
],
3 => [
'data' => [
'list' => [
0 => [
'src' => 'http://img11.static.yhbimg.com/yhb-img01/2016/04/13/06/019bd2c1581f881c8ea22daf0e39a4a9ab.png?imageView/2/w/640/h/200',
'url' => []
],
1 => [
'src' => 'http://img12.static.yhbimg.com/yhb-img01/2016/04/13/06/02576fa876ccfbfe0648b4e2dabb989b6f.png?imageView/2/w/640/h/200',
'url' => []
],
2 => [
'src' => 'http://img11.static.yhbimg.com/yhb-img01/2016/04/13/06/01362e8c56fd6ac56ad3852b6a192e5336.png?imageView/2/w/640/h/200',
'url' => []
],
],
'speed' => '3'
],
'template_id' => 1111253,
'template_intro' => '轮播banner',
'template_name' => 'carousel_banner'
],
],
'md5' => '8febf00780011298f4a0530b6441827b',
'message' => '请求成功'
];
return $result;
}
}