添加实际业务逻辑
Code Review By Rock Zhang
Showing
3 changed files
with
60 additions
and
15 deletions
@@ -2,7 +2,6 @@ | @@ -2,7 +2,6 @@ | ||
2 | 2 | ||
3 | namespace LibModels\Wap\Cuxiao; | 3 | namespace LibModels\Wap\Cuxiao; |
4 | 4 | ||
5 | -use Api\Sign; | ||
6 | use Api\Yohobuy; | 5 | use Api\Yohobuy; |
7 | 6 | ||
8 | /** | 7 | /** |
@@ -21,6 +20,8 @@ class ActivityData | @@ -21,6 +20,8 @@ class ActivityData | ||
21 | const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon'; | 20 | const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon'; |
22 | const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon'; | 21 | const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon'; |
23 | const URI_SEND_MESSAGE = 'inbox/service/v1/inbox'; | 22 | const URI_SEND_MESSAGE = 'inbox/service/v1/inbox'; |
23 | + const URI_YUANXIAO_CHOUQIAN = 'union/ActivityRest/draw'; | ||
24 | + const URI_YUANXIAO_CHOUQIAN_SHARE = 'union/ActivityRest/getDrawInfo'; | ||
24 | 25 | ||
25 | /** | 26 | /** |
26 | * 用户获取某个活动指定的单个优惠券 | 27 | * 用户获取某个活动指定的单个优惠券 |
@@ -70,6 +71,8 @@ class ActivityData | @@ -70,6 +71,8 @@ class ActivityData | ||
70 | } | 71 | } |
71 | 72 | ||
72 | /** | 73 | /** |
74 | + * 获取元宵抽签的结果 | ||
75 | + * | ||
73 | * @param int $uid 用户UID | 76 | * @param int $uid 用户UID |
74 | * @param string $nickName 用户昵称 | 77 | * @param string $nickName 用户昵称 |
75 | * @param string $birthday 用户生日 | 78 | * @param string $birthday 用户生日 |
@@ -78,15 +81,29 @@ class ActivityData | @@ -78,15 +81,29 @@ class ActivityData | ||
78 | */ | 81 | */ |
79 | public static function getYuanxiaoInfo($uid, $nickName, $birthday, $gender) | 82 | public static function getYuanxiaoInfo($uid, $nickName, $birthday, $gender) |
80 | { | 83 | { |
81 | - $param = Yohobuy::param(); | 84 | + $param = array(); |
82 | $param['method'] = 'wap.activity.draw'; | 85 | $param['method'] = 'wap.activity.draw'; |
83 | $param['uid'] = $uid; | 86 | $param['uid'] = $uid; |
84 | - $param['nick_name'] = $nickName; | 87 | + $param['nickname'] = $nickName; |
85 | $param['birthday'] = $birthday; | 88 | $param['birthday'] = $birthday; |
86 | $param['gender'] = $gender; | 89 | $param['gender'] = $gender; |
87 | - $param['client_secret'] = Sign::getSign($param); | ||
88 | 90 | ||
89 | - return Yohobuy::get(Yohobuy::API_URL, $param); | 91 | + return Yohobuy::jsonPost(Yohobuy::SERVICE_URL . self::URI_YUANXIAO_CHOUQIAN, $param); |
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * 获取分享结果页元宵抽签的结果 | ||
96 | + * | ||
97 | + * @param int $uid 用户UID | ||
98 | + * @return mixed 抽签的结果 | ||
99 | + */ | ||
100 | + public static function getYuanxiaoShareInfo($uid) | ||
101 | + { | ||
102 | + $param = array(); | ||
103 | + $param['method'] = 'wap.activity.draw'; | ||
104 | + $param['uid'] = $uid; | ||
105 | + | ||
106 | + return Yohobuy::jsonPost(Yohobuy::SERVICE_URL . self::URI_YUANXIAO_CHOUQIAN_SHARE, $param); | ||
90 | } | 107 | } |
91 | 108 | ||
92 | /** | 109 | /** |
@@ -80,4 +80,30 @@ class YuanxiaoModel | @@ -80,4 +80,30 @@ class YuanxiaoModel | ||
80 | 80 | ||
81 | return $result; | 81 | return $result; |
82 | } | 82 | } |
83 | + | ||
84 | + /** | ||
85 | + * @param int $uid 用户UID | ||
86 | + * @return array|mixed 抽奖的结果 | ||
87 | + */ | ||
88 | + public static function getChoujiangShareInfo($uid) | ||
89 | + { | ||
90 | + $result = array('code' => 400, 'message' => '出错啦~'); | ||
91 | + | ||
92 | + do { | ||
93 | + if (empty($uid)) { | ||
94 | + break; | ||
95 | + } | ||
96 | + | ||
97 | + $chouqian = ActivityData::getYuanxiaoShareInfo($uid); | ||
98 | + if (isset($chouqian['data'])) { | ||
99 | + $result = array( | ||
100 | + 'name' => $chouqian['data']['nickname'], | ||
101 | + 'type' => $chouqian['data']['randomCode'], | ||
102 | + 'total' => $chouqian['data']['total'] | ||
103 | + ); | ||
104 | + } | ||
105 | + } while (false); | ||
106 | + | ||
107 | + return $result; | ||
108 | + } | ||
83 | } | 109 | } |
@@ -66,11 +66,13 @@ class YuanxiaoController extends HuodongAction | @@ -66,11 +66,13 @@ class YuanxiaoController extends HuodongAction | ||
66 | 66 | ||
67 | // 调用接口 | 67 | // 调用接口 |
68 | $result = YuanxiaoModel::getChouqianInfo($uid, $nickName, $birthday, $gender); | 68 | $result = YuanxiaoModel::getChouqianInfo($uid, $nickName, $birthday, $gender); |
69 | - $result['code'] = 200; | ||
70 | - $result['data'] = array('name' => $nickName, 'type' => 'M2'); | ||
71 | if ($result['code'] === 200) { // 处理成功就跳转到等待页 | 69 | if ($result['code'] === 200) { // 处理成功就跳转到等待页 |
72 | // 将返回的结果存入cookeie中15分钟 | 70 | // 将返回的结果存入cookeie中15分钟 |
73 | - $this->setCookie('yuanxiaochouqian', json_encode($result['data']), time() + 15*60); | 71 | + $cookieData = array( |
72 | + 'name' => $nickName, | ||
73 | + 'type' => $result['data']['randomCode'] | ||
74 | + ); | ||
75 | + $this->setCookie('yuanxiaochouqian', json_encode($cookieData), time() + 15*60); | ||
74 | $this->go(Helpers::url('/cuxiao/yuanxiao/wait')); | 76 | $this->go(Helpers::url('/cuxiao/yuanxiao/wait')); |
75 | } else { // 不成功就显示返回的错误信息 | 77 | } else { // 不成功就显示返回的错误信息 |
76 | $this->_view->display('info', array( | 78 | $this->_view->display('info', array( |
@@ -131,13 +133,12 @@ class YuanxiaoController extends HuodongAction | @@ -131,13 +133,12 @@ class YuanxiaoController extends HuodongAction | ||
131 | // cookie中存的结果 | 133 | // cookie中存的结果 |
132 | $result = json_decode($result, true); | 134 | $result = json_decode($result, true); |
133 | $shareUrl = Helpers::url('/cuxiao/yuanxiao/share', array( | 135 | $shareUrl = Helpers::url('/cuxiao/yuanxiao/share', array( |
134 | - 'name' => $this->encrypt($result['name']), | ||
135 | 'hash' => $this->encrypt($this->getUid()) | 136 | 'hash' => $this->encrypt($this->getUid()) |
136 | )); | 137 | )); |
137 | - $result['type'] = $this->get('type', 'M2'); | ||
138 | 138 | ||
139 | $this->_view->display('result', array( | 139 | $this->_view->display('result', array( |
140 | 'staticTitle' => '元宵抽签', | 140 | 'staticTitle' => '元宵抽签', |
141 | + 'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享 | ||
141 | 'staticFile' => self::STATIC_FILE, | 142 | 'staticFile' => self::STATIC_FILE, |
142 | 'result' => $result, | 143 | 'result' => $result, |
143 | 'shareUrl' => $shareUrl, | 144 | 'shareUrl' => $shareUrl, |
@@ -152,22 +153,23 @@ class YuanxiaoController extends HuodongAction | @@ -152,22 +153,23 @@ class YuanxiaoController extends HuodongAction | ||
152 | */ | 153 | */ |
153 | public function shareAction() | 154 | public function shareAction() |
154 | { | 155 | { |
155 | - // 昵称从url中解析 | ||
156 | - $name = $this->decrypt($this->get('name', '')); | ||
157 | // 用户UID | 156 | // 用户UID |
158 | $uid = $this->decrypt($this->get('hash', '')); | 157 | $uid = $this->decrypt($this->get('hash', '')); |
158 | + if (empty($uid)) { | ||
159 | + $this->go(Helpers::url('/cuxiao/yuanxiao/index')); | ||
160 | + } | ||
159 | 161 | ||
160 | // 调用接口获取type和count | 162 | // 调用接口获取type和count |
161 | - $result = array('type' => 'M1', 'count' => 9887); | 163 | + $result = YuanxiaoModel::getChoujiangShareInfo($uid); |
162 | 164 | ||
163 | $this->_view->display('share', array( | 165 | $this->_view->display('share', array( |
164 | 'staticTitle' => '元宵抽签', | 166 | 'staticTitle' => '元宵抽签', |
165 | 'staticFile' => self::STATIC_FILE, | 167 | 'staticFile' => self::STATIC_FILE, |
166 | 'result' => array( | 168 | 'result' => array( |
167 | - 'name' => $name, | 169 | + 'name' => $result['name'], |
168 | 'type' => $result['type'] | 170 | 'type' => $result['type'] |
169 | ), | 171 | ), |
170 | - 'count' => $result['count'], | 172 | + 'count' => $result['total'], |
171 | 'staticJS' => array( | 173 | 'staticJS' => array( |
172 | 'share.js' | 174 | 'share.js' |
173 | ) | 175 | ) |
-
Please register or login to post a comment