Merge branch 'feature/wap/yuanxiao' of git.dev.yoho.cn:web/yohobuy into feature/wap/yuanxiao
Showing
4 changed files
with
72 additions
and
33 deletions
@@ -24,17 +24,17 @@ class Yohobuy | @@ -24,17 +24,17 @@ class Yohobuy | ||
24 | // const YOHOBUY_URL = 'http://www.yohobuy.com/'; | 24 | // const YOHOBUY_URL = 'http://www.yohobuy.com/'; |
25 | 25 | ||
26 | //java API | 26 | //java API |
27 | - const API_URL = 'http://apih5.yoho.cn/'; | ||
28 | - const API_URL2 = 'http://apih5.yoho.cn/'; | ||
29 | - const SERVICE_URL = 'http://serviceh5.yoho.cn/'; | ||
30 | - const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
31 | - const API_OLD = 'http://api2.open.yohobuy.com/'; | 27 | +// const API_URL = 'http://apih5.yoho.cn/'; |
28 | +// const API_URL2 = 'http://apih5.yoho.cn/'; | ||
29 | +// const SERVICE_URL = 'http://serviceh5.yoho.cn/'; | ||
30 | +// const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
31 | +// const API_OLD = 'http://api2.open.yohobuy.com/'; | ||
32 | 32 | ||
33 | /* 测试环境 */ | 33 | /* 测试环境 */ |
34 | -// const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/' | ||
35 | -// const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; | ||
36 | -// const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
37 | -// const API_OLD = 'http://test2.open.yohobuy.com/'; | 34 | + const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/' |
35 | + const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; | ||
36 | + const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
37 | + const API_OLD = 'http://test2.open.yohobuy.com/'; | ||
38 | 38 | ||
39 | /* 预览环境 */ | 39 | /* 预览环境 */ |
40 | // const API_URL = 'http://preapi.yoho.cn/'; | 40 | // const API_URL = 'http://preapi.yoho.cn/'; |
@@ -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 | /** |
@@ -35,7 +35,7 @@ class YuanxiaoModel | @@ -35,7 +35,7 @@ class YuanxiaoModel | ||
35 | // 处理个人详情数 | 35 | // 处理个人详情数 |
36 | if (isset($userData['data']) && !empty($userData['data'])) { | 36 | if (isset($userData['data']) && !empty($userData['data'])) { |
37 | $result['birthday'] = $userData['data']['birthday'] ?: '2000-01-01'; | 37 | $result['birthday'] = $userData['data']['birthday'] ?: '2000-01-01'; |
38 | - $result['gender'] = $userData['data']['gender'] == 1 ? '男' : '女'; | 38 | + $result['gender'] = $userData['data']['gender']; |
39 | } | 39 | } |
40 | 40 | ||
41 | return $result; | 41 | return $result; |
@@ -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 | } |
@@ -38,13 +38,7 @@ class YuanxiaoController extends HuodongAction | @@ -38,13 +38,7 @@ class YuanxiaoController extends HuodongAction | ||
38 | 'staticFile' => self::STATIC_FILE, | 38 | 'staticFile' => self::STATIC_FILE, |
39 | 'staticJS' => array( | 39 | 'staticJS' => array( |
40 | 'home.js' | 40 | 'home.js' |
41 | - ), | ||
42 | - 'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享 | ||
43 | - 'shareLink' => 'http://feature.yoho.cn/2016lishifeng/index.html', | ||
44 | - 'shareTitle' => 'YOHO!BUY有货新年寻宝大作战,千元利是等你赢!', | ||
45 | - 'shareDesc' => 'YOHO!BUY有货,全球800+潮流品牌每日上新!', | ||
46 | - 'shareImg' => 'http://img12.static.yhbimg.com/couponImg/2015/12/30/12/02008a9724b898dee56852de9f1a3978bf.jpg', | ||
47 | - 'showPopupFlag' => $showPopupFlag, | 41 | + ) |
48 | )); | 42 | )); |
49 | } | 43 | } |
50 | 44 | ||
@@ -62,15 +56,17 @@ class YuanxiaoController extends HuodongAction | @@ -62,15 +56,17 @@ class YuanxiaoController extends HuodongAction | ||
62 | if (!empty($posts)) { | 56 | if (!empty($posts)) { |
63 | $nickName = $this->post('nick', ''); | 57 | $nickName = $this->post('nick', ''); |
64 | $birthday = $this->post('birthday', ''); | 58 | $birthday = $this->post('birthday', ''); |
65 | - $gender = $this->post('gender', 0); | 59 | + $gender = $this->post('gender', 1); |
66 | 60 | ||
67 | // 调用接口 | 61 | // 调用接口 |
68 | $result = YuanxiaoModel::getChouqianInfo($uid, $nickName, $birthday, $gender); | 62 | $result = YuanxiaoModel::getChouqianInfo($uid, $nickName, $birthday, $gender); |
69 | - $result['code'] = 200; | ||
70 | - $result['data'] = array('name' => $nickName, 'type' => 'M2'); | ||
71 | if ($result['code'] === 200) { // 处理成功就跳转到等待页 | 63 | if ($result['code'] === 200) { // 处理成功就跳转到等待页 |
72 | // 将返回的结果存入cookeie中15分钟 | 64 | // 将返回的结果存入cookeie中15分钟 |
73 | - $this->setCookie('yuanxiaochouqian', json_encode($result['data']), time() + 15*60); | 65 | + $cookieData = array( |
66 | + 'name' => $nickName, | ||
67 | + 'type' => $result['data']['randomCode'] | ||
68 | + ); | ||
69 | + $this->setCookie('yuanxiaochouqian', json_encode($cookieData), time() + 15*60); | ||
74 | $this->go(Helpers::url('/cuxiao/yuanxiao/wait')); | 70 | $this->go(Helpers::url('/cuxiao/yuanxiao/wait')); |
75 | } else { // 不成功就显示返回的错误信息 | 71 | } else { // 不成功就显示返回的错误信息 |
76 | $this->_view->display('info', array( | 72 | $this->_view->display('info', array( |
@@ -131,13 +127,12 @@ class YuanxiaoController extends HuodongAction | @@ -131,13 +127,12 @@ class YuanxiaoController extends HuodongAction | ||
131 | // cookie中存的结果 | 127 | // cookie中存的结果 |
132 | $result = json_decode($result, true); | 128 | $result = json_decode($result, true); |
133 | $shareUrl = Helpers::url('/cuxiao/yuanxiao/share', array( | 129 | $shareUrl = Helpers::url('/cuxiao/yuanxiao/share', array( |
134 | - 'name' => $this->encrypt($result['name']), | ||
135 | 'hash' => $this->encrypt($this->getUid()) | 130 | 'hash' => $this->encrypt($this->getUid()) |
136 | )); | 131 | )); |
137 | - $result['type'] = $this->get('type', 'M2'); | ||
138 | 132 | ||
139 | $this->_view->display('result', array( | 133 | $this->_view->display('result', array( |
140 | 'staticTitle' => '元宵抽签', | 134 | 'staticTitle' => '元宵抽签', |
135 | + 'weixinShare' => $this->_isApp ? false : true, // 是否需要微信分享 | ||
141 | 'staticFile' => self::STATIC_FILE, | 136 | 'staticFile' => self::STATIC_FILE, |
142 | 'result' => $result, | 137 | 'result' => $result, |
143 | 'shareUrl' => $shareUrl, | 138 | 'shareUrl' => $shareUrl, |
@@ -152,22 +147,23 @@ class YuanxiaoController extends HuodongAction | @@ -152,22 +147,23 @@ class YuanxiaoController extends HuodongAction | ||
152 | */ | 147 | */ |
153 | public function shareAction() | 148 | public function shareAction() |
154 | { | 149 | { |
155 | - // 昵称从url中解析 | ||
156 | - $name = $this->decrypt($this->get('name', '')); | ||
157 | // 用户UID | 150 | // 用户UID |
158 | $uid = $this->decrypt($this->get('hash', '')); | 151 | $uid = $this->decrypt($this->get('hash', '')); |
152 | + if (empty($uid)) { | ||
153 | + $this->go(Helpers::url('/cuxiao/yuanxiao/index')); | ||
154 | + } | ||
159 | 155 | ||
160 | // 调用接口获取type和count | 156 | // 调用接口获取type和count |
161 | - $result = array('type' => 'M1', 'count' => 9887); | 157 | + $result = YuanxiaoModel::getChoujiangShareInfo($uid); |
162 | 158 | ||
163 | $this->_view->display('share', array( | 159 | $this->_view->display('share', array( |
164 | 'staticTitle' => '元宵抽签', | 160 | 'staticTitle' => '元宵抽签', |
165 | 'staticFile' => self::STATIC_FILE, | 161 | 'staticFile' => self::STATIC_FILE, |
166 | 'result' => array( | 162 | 'result' => array( |
167 | - 'name' => $name, | 163 | + 'name' => $result['name'], |
168 | 'type' => $result['type'] | 164 | 'type' => $result['type'] |
169 | ), | 165 | ), |
170 | - 'count' => $result['count'], | 166 | + 'count' => $result['total'], |
171 | 'staticJS' => array( | 167 | 'staticJS' => array( |
172 | 'share.js' | 168 | 'share.js' |
173 | ) | 169 | ) |
-
Please register or login to post a comment