Merge branch 'feature/coupon' of http://git.dev.yoho.cn/web/yohobuy into feature/coupon
Showing
1 changed file
with
68 additions
and
35 deletions
@@ -24,7 +24,7 @@ class CouponController extends AbstractAction | @@ -24,7 +24,7 @@ class CouponController extends AbstractAction | ||
24 | */ | 24 | */ |
25 | public function floorAction() | 25 | public function floorAction() |
26 | { | 26 | { |
27 | - $data = [ | 27 | + $result = [ |
28 | 'title' => '热门推荐', | 28 | 'title' => '热门推荐', |
29 | 'showTitle' => 1, | 29 | 'showTitle' => 1, |
30 | 'coupons' => [ | 30 | 'coupons' => [ |
@@ -34,14 +34,14 @@ class CouponController extends AbstractAction | @@ -34,14 +34,14 @@ class CouponController extends AbstractAction | ||
34 | 'status' => true, | 34 | 'status' => true, |
35 | 'num' => 123, | 35 | 'num' => 123, |
36 | 'go' => 'http://m.dev.yohobuy.com/boys', | 36 | 'go' => 'http://m.dev.yohobuy.com/boys', |
37 | - 'couponIds' => [8024, 2564, 3587] | 37 | + 'couponId' => 3587 |
38 | ], [ | 38 | ], [ |
39 | 'id' => 1, | 39 | 'id' => 1, |
40 | 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200', | 40 | 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200', |
41 | 'status' => false, | 41 | 'status' => false, |
42 | 'num' => 122, | 42 | 'num' => 122, |
43 | 'go' => 'http://m.dev.yohobuy.com/boys', | 43 | 'go' => 'http://m.dev.yohobuy.com/boys', |
44 | - 'couponIds' => [8024, 2564, 3587] | 44 | + 'couponId' => 2564 |
45 | ], [ | 45 | ], [ |
46 | 'id' => 1, | 46 | 'id' => 1, |
47 | 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200', | 47 | 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200', |
@@ -49,21 +49,24 @@ class CouponController extends AbstractAction | @@ -49,21 +49,24 @@ class CouponController extends AbstractAction | ||
49 | 'is_zero' => true, | 49 | 'is_zero' => true, |
50 | 'num' => 0, | 50 | 'num' => 0, |
51 | 'go' => 'http://m.dev.yohobuy.com/boys', | 51 | 'go' => 'http://m.dev.yohobuy.com/boys', |
52 | - 'couponIds' => [8024, 2564, 3587] | 52 | + 'couponId' => 8024 |
53 | ], [ | 53 | ], [ |
54 | 'id' => 1, | 54 | 'id' => 1, |
55 | 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200', | 55 | 'picUrl' => 'http://img12.static.yhbimg.com/yhb-img01/2016/01/19/11/02039485d87cc1b100b883244cf386e62d.jpg?imageView/2/w/640/h/200', |
56 | 'status' => true, | 56 | 'status' => true, |
57 | 'num' => 123, | 57 | 'num' => 123, |
58 | 'go' => 'http://m.dev.yohobuy.com/boys', | 58 | 'go' => 'http://m.dev.yohobuy.com/boys', |
59 | - 'couponIds' => [8024, 2564, 3587] | 59 | + 'couponId' => 1234 |
60 | ] | 60 | ] |
61 | ] | 61 | ] |
62 | ]; | 62 | ]; |
63 | + /*// 优惠券列表接口调用 | ||
64 | + $param['method'] = 'app.promotion.queryCoupon'; | ||
65 | + $result = \Api\YohobuyH5::get(\Api\YohobuyH5::SERVICE_URL,$param);*/ | ||
63 | 66 | ||
64 | $this->_view->display('index', array( | 67 | $this->_view->display('index', array( |
65 | - 'floor' => $data, | ||
66 | - 'floorPage' => true | 68 | + 'floor' => $result, |
69 | + 'floorPage' => true | ||
67 | )); | 70 | )); |
68 | } | 71 | } |
69 | 72 | ||
@@ -75,21 +78,24 @@ class CouponController extends AbstractAction | @@ -75,21 +78,24 @@ class CouponController extends AbstractAction | ||
75 | public function receiveCouponAction() | 78 | public function receiveCouponAction() |
76 | { | 79 | { |
77 | $receiveData = filter_input_array(INPUT_GET, array( | 80 | $receiveData = filter_input_array(INPUT_GET, array( |
78 | - 'couponIds' => FILTER_DEFAULT | 81 | + 'couponId' => FILTER_DEFAULT |
79 | )); | 82 | )); |
80 | $returnData = array(); | 83 | $returnData = array(); |
81 | - $couponIds = explode(',', str_replace(' ', '', $receiveData['couponIds'])); | ||
82 | - $result = $this->getCoupons($couponIds); | ||
83 | - if($result === 200){ | ||
84 | - $returnData = [ | ||
85 | - 'msg' => '领券成功!', | ||
86 | - 'status' => true, | ||
87 | - ]; | ||
88 | - }else{ | ||
89 | - $returnData = [ | ||
90 | - 'msg' => '领券失败!', | ||
91 | - 'status' => false, | ||
92 | - ]; | 84 | + // 调用领券接口 |
85 | + $result = $this->getCoupon($receiveData['couponId']); | ||
86 | + switch ($result['code']) { | ||
87 | + case 200: | ||
88 | + $returnData = [ | ||
89 | + 'msg' => '领券成功!', | ||
90 | + 'status' => true, | ||
91 | + ]; | ||
92 | + break; | ||
93 | + default: | ||
94 | + $returnData = [ | ||
95 | + 'msg' => '领券失败!', | ||
96 | + 'status' => false, | ||
97 | + ]; | ||
98 | + break; | ||
93 | } | 99 | } |
94 | echo json_encode($returnData); | 100 | echo json_encode($returnData); |
95 | } | 101 | } |
@@ -97,26 +103,53 @@ class CouponController extends AbstractAction | @@ -97,26 +103,53 @@ class CouponController extends AbstractAction | ||
97 | /** | 103 | /** |
98 | * 领券接口模拟 | 104 | * 领券接口模拟 |
99 | * | 105 | * |
100 | - * @param $couponIds | 106 | + * @param $couponId |
101 | * @return array | 107 | * @return array |
102 | * @internal param $couponId | 108 | * @internal param $couponId |
103 | */ | 109 | */ |
104 | - public function getCoupons($couponIds) | 110 | + public function getCoupon($couponId) |
105 | { | 111 | { |
106 | - if($couponIds){ | ||
107 | - $param['alg'] = 'SALT_MD5'; | ||
108 | - $param['code'] = 200; | ||
109 | - $param['data']= ''; | ||
110 | - $param['md5'] = '50d19f5f5098c34607018f144baec14a'; | ||
111 | - $param['message'] = '操作成功'; | ||
112 | - }else{ | ||
113 | - $param['alg'] = 'SALT_MD5'; | ||
114 | - $param['code'] = 300; | ||
115 | - $param['data']= ''; | ||
116 | - $param['md5'] = '50d19f5f5098c34607018f144baec14a'; | ||
117 | - $param['message'] = '操作失败'; | 112 | + if ($couponId) { |
113 | + $result['alg'] = 'SALT_MD5'; | ||
114 | + $result['code'] = 200; | ||
115 | + $result['data'] = ''; | ||
116 | + $result['md5'] = '50d19f5f5098c34607018f144baec14a'; | ||
117 | + $result['message'] = '操作成功'; | ||
118 | + } else { | ||
119 | + $result['alg'] = 'SALT_MD5'; | ||
120 | + $result['code'] = 402; | ||
121 | + $result['data'] = ''; | ||
122 | + $result['md5'] = '50d19f5f5098c34607018f144baec14a'; | ||
123 | + $result['message'] = '操作失败'; | ||
124 | + } | ||
125 | + | ||
126 | + /*// 判断用户是否登录 | ||
127 | + if (!$this->getUid() || !is_numeric($this->getUid())) { | ||
128 | + // 用户未登录,跳转登录页面 | ||
129 | + if ($this->isApp()) { | ||
130 | + $this->go(Helpers::url('/signin.html', array('refer' => Helpers::url($_SERVER["REQUEST_URI"])), 'default')); | ||
131 | + } else { | ||
132 | + $this->go($_SERVER["REQUEST_URI"] . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . strtr($_SERVER["REQUEST_URI"], array('/' => '\\/')) . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}'); | ||
133 | + } | ||
118 | } | 134 | } |
119 | - return $param; | 135 | + |
136 | + // 组合接口参数 | ||
137 | + $params['method'] = 'app.promotion.getCoupon'; | ||
138 | + $params['couponId'] = $couponId; | ||
139 | + $params['uid'] = $this->getUid(); | ||
140 | + | ||
141 | + $result = \Api\YohobuyH5::get(\Api\YohobuyH5::SERVICE_URL, $params);*/ | ||
142 | + | ||
143 | + return $result; | ||
120 | } | 144 | } |
121 | 145 | ||
146 | + /** | ||
147 | + * 判断是否是 APP | ||
148 | + * | ||
149 | + * @return bool | ||
150 | + */ | ||
151 | + public function isApp() | ||
152 | + { | ||
153 | + return (null !== $this->get('app_version')); | ||
154 | + } | ||
122 | } | 155 | } |
-
Please register or login to post a comment