Authored by 周少峰

change passport api url

@@ -648,6 +648,11 @@ class UserData @@ -648,6 +648,11 @@ class UserData
648 return Yohobuy::get(API_URL, $param); 648 return Yohobuy::get(API_URL, $param);
649 } 649 }
650 650
  651 + /**
  652 + * 获取用户登录信息
  653 + * @param $uid
  654 + * @return mixed
  655 + */
651 public static function passportGet($uid) 656 public static function passportGet($uid)
652 { 657 {
653 $param = Yohobuy::param(); 658 $param = Yohobuy::param();
@@ -657,4 +662,42 @@ class UserData @@ -657,4 +662,42 @@ class UserData
657 return Yohobuy::get(API_URL, $param); 662 return Yohobuy::get(API_URL, $param);
658 } 663 }
659 664
  665 + /**
  666 + * 获取用户信息
  667 + * @param $uid
  668 + * @param bool|false $urlOnly
  669 + * @return string
  670 + */
  671 + public static function getUserProfile($uid, $urlOnly = false)
  672 + {
  673 + $param = Yohobuy::param();
  674 + $param['method'] = 'app.passport.profile';
  675 + $param['uid'] = $uid;
  676 + $param['client_secret'] = Sign::getSign($param);
  677 + if (!$urlOnly) {
  678 + return Yohobuy::gebt(API_URL, $param);
  679 + } else {
  680 + return Yohobuy::httpBuildQuery(API_URL, $param);;
  681 + }
  682 + }
  683 +
  684 + /**
  685 + * 获取用户信息
  686 + * @param $uid
  687 + * @param bool|false $urlOnly
  688 + * @return string
  689 + */
  690 + public static function getUserInfoNum($uid, $urlOnly = false)
  691 + {
  692 + $param = Yohobuy::param();
  693 + $param['method'] = 'app.home.getInfoNum';
  694 + $param['uid'] = $uid;
  695 + $param['client_secret'] = Sign::getSign($param);
  696 + if (!$urlOnly) {
  697 + return Yohobuy::gebt(API_URL, $param);
  698 + } else {
  699 + return Yohobuy::httpBuildQuery(API_URL, $param);;
  700 + }
  701 + }
  702 +
660 } 703 }
@@ -239,12 +239,30 @@ class CommonController extends WebAction @@ -239,12 +239,30 @@ class CommonController extends WebAction
239 */ 239 */
240 public function passportAction() 240 public function passportAction()
241 { 241 {
  242 + $userInfo = array();
242 $callback = $this->get('callback'); 243 $callback = $this->get('callback');
243 $uid = $this->getUid(); 244 $uid = $this->getUid();
244 - $userInfo = UserData::passportGet($uid);  
245 - if (!empty($uid)) {  
246 - $total = 0; 245 +
  246 + do {
  247 +
  248 + if (empty($uid)) {
  249 + break;
  250 + }
  251 +
  252 + //调用用户信息
  253 +// $userInfo = UserData::passportGet($uid);
  254 +
  255 + $api['profile'] = UserData::getUserProfile($uid, true);
  256 + $api['number'] = UserData::getUserInfoNum($uid, true);
  257 + $apiInfo = \Api\Yohobuy::getMulti($api);
  258 +
  259 + $userInfo['data'] = array_merge($apiInfo['profile'], $apiInfo['number']);
  260 + $userInfo['data']['vip'] = $userInfo['data']['vip_info'];
  261 + unset($userInfo['data']['vip_info']);
  262 + $userInfo['data']['result'] = 1;
  263 +
247 //更新购物车cookie信息 264 //更新购物车cookie信息
  265 + $total = 0;
248 $shoppingKey = Helpers::getShoppingKeyByCookie(); 266 $shoppingKey = Helpers::getShoppingKeyByCookie();
249 $result = CartModel::shoppingCart($uid, $shoppingKey); 267 $result = CartModel::shoppingCart($uid, $shoppingKey);
250 if (isset($result['main_goods'])) { 268 if (isset($result['main_goods'])) {
@@ -259,25 +277,15 @@ class CommonController extends WebAction @@ -259,25 +277,15 @@ class CommonController extends WebAction
259 '_r' => 1 277 '_r' => 1
260 ))); 278 )));
261 } 279 }
262 - }  
263 - if (isset($userInfo['data'])) {  
264 - if (isset($userInfo['data']['data']['vip']['curYearCost'])) {  
265 - $userInfo['data']['data']['vip']['curYearCost'] = intval($userInfo['data']['data']['vip']['curYearCost']);  
266 - }  
267 - if (isset($userInfo['data']['data']['vip']['nextVipInfo']['needCost'])) {  
268 - $userInfo['data']['data']['vip']['nextVipInfo']['needCost'] = intval($userInfo['data']['data']['vip']['nextVipInfo']['needCost']);  
269 - }  
270 - if (isset($userInfo['data']['data']['head_ico']) && !empty($userInfo['data']['data']['head_ico'])) {  
271 - $userInfo['data']['data']['head_ico'] = Images::getImageUrl($userInfo['data']['data']['head_ico'], 63, 63, 2, 'yhb-head');  
272 - }  
273 - if (isset($userInfo['data']['data']['vip']['curYearCostPer'])) {  
274 - $userInfo['data']['data']['vip']['curYearCostPer'] = intval($userInfo['data']['data']['vip']['curYearCostPer']);  
275 - }  
276 - $userInfo['data']['result'] = 1;  
277 - $this->helpJsonCallbackResult($callback, 200,'User info', $userInfo['data']);  
278 - } else { 280 +
  281 + } while(false);
  282 +
  283 + if (empty($userInfo)) {
279 $this->helpJsonCallbackResult($callback, 403,'User info', ''); 284 $this->helpJsonCallbackResult($callback, 403,'User info', '');
  285 + } else {
  286 + $this->helpJsonCallbackResult($callback, 200,'User info', $userInfo);
280 } 287 }
  288 +
281 } 289 }
282 290
283 /** 291 /**
@@ -298,7 +306,6 @@ class CommonController extends WebAction @@ -298,7 +306,6 @@ class CommonController extends WebAction
298 $sknArray = explode('-', $val); 306 $sknArray = explode('-', $val);
299 $skn[]= $sknArray[0]; 307 $skn[]= $sknArray[0];
300 } 308 }
301 -// rsort($skn);  
302 $skn = array_slice($skn, 0 ,$limit); 309 $skn = array_slice($skn, 0 ,$limit);
303 $result = SearchModel::historyProduct($skn, $limit); 310 $result = SearchModel::historyProduct($skn, $limit);
304 } while(false); 311 } while(false);