Authored by 郭成尧

领券修改为领单张券

@@ -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,14 +49,14 @@ class CouponController extends AbstractAction @@ -49,14 +49,14 @@ 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 ];
@@ -75,21 +75,24 @@ class CouponController extends AbstractAction @@ -75,21 +75,24 @@ class CouponController extends AbstractAction
75 public function receiveCouponAction() 75 public function receiveCouponAction()
76 { 76 {
77 $receiveData = filter_input_array(INPUT_GET, array( 77 $receiveData = filter_input_array(INPUT_GET, array(
78 - 'couponIds' => FILTER_DEFAULT 78 + 'couponId' => FILTER_DEFAULT
79 )); 79 ));
80 $returnData = array(); 80 $returnData = array();
81 - $couponIds = explode(',', str_replace(' ', '', $receiveData['couponIds']));  
82 - $result = $this->getCoupons($couponIds);  
83 - if($result === 200){ 81 + // 调用领券接口
  82 + $result = $this->getCoupon($receiveData['couponId']);
  83 + switch ($result['code']) {
  84 + case 200:
84 $returnData = [ 85 $returnData = [
85 'msg' => '领券成功!', 86 'msg' => '领券成功!',
86 'status' => true, 87 'status' => true,
87 ]; 88 ];
88 - }else{ 89 + break;
  90 + default:
89 $returnData = [ 91 $returnData = [
90 'msg' => '领券失败!', 92 'msg' => '领券失败!',
91 'status' => false, 93 'status' => false,
92 ]; 94 ];
  95 + break;
93 } 96 }
94 echo json_encode($returnData); 97 echo json_encode($returnData);
95 } 98 }
@@ -97,22 +100,22 @@ class CouponController extends AbstractAction @@ -97,22 +100,22 @@ class CouponController extends AbstractAction
97 /** 100 /**
98 * 领券接口模拟 101 * 领券接口模拟
99 * 102 *
100 - * @param $couponIds 103 + * @param $couponId
101 * @return array 104 * @return array
102 * @internal param $couponId 105 * @internal param $couponId
103 */ 106 */
104 - public function getCoupons($couponIds) 107 + public function getCoupon($couponId)
105 { 108 {
106 - if($couponIds){ 109 + if ($couponId) {
107 $param['alg'] = 'SALT_MD5'; 110 $param['alg'] = 'SALT_MD5';
108 $param['code'] = 200; 111 $param['code'] = 200;
109 - $param['data']= ''; 112 + $param['data'] = '';
110 $param['md5'] = '50d19f5f5098c34607018f144baec14a'; 113 $param['md5'] = '50d19f5f5098c34607018f144baec14a';
111 $param['message'] = '操作成功'; 114 $param['message'] = '操作成功';
112 - }else{ 115 + } else {
113 $param['alg'] = 'SALT_MD5'; 116 $param['alg'] = 'SALT_MD5';
114 - $param['code'] = 300;  
115 - $param['data']= ''; 117 + $param['code'] = 402;
  118 + $param['data'] = '';
116 $param['md5'] = '50d19f5f5098c34607018f144baec14a'; 119 $param['md5'] = '50d19f5f5098c34607018f144baec14a';
117 $param['message'] = '操作失败'; 120 $param['message'] = '操作失败';
118 } 121 }