Authored by 周少峰

change passport api url

... ... @@ -648,6 +648,11 @@ class UserData
return Yohobuy::get(API_URL, $param);
}
/**
* 获取用户登录信息
* @param $uid
* @return mixed
*/
public static function passportGet($uid)
{
$param = Yohobuy::param();
... ... @@ -657,4 +662,42 @@ class UserData
return Yohobuy::get(API_URL, $param);
}
/**
* 获取用户信息
* @param $uid
* @param bool|false $urlOnly
* @return string
*/
public static function getUserProfile($uid, $urlOnly = false)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.profile';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
if (!$urlOnly) {
return Yohobuy::gebt(API_URL, $param);
} else {
return Yohobuy::httpBuildQuery(API_URL, $param);;
}
}
/**
* 获取用户信息
* @param $uid
* @param bool|false $urlOnly
* @return string
*/
public static function getUserInfoNum($uid, $urlOnly = false)
{
$param = Yohobuy::param();
$param['method'] = 'app.home.getInfoNum';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
if (!$urlOnly) {
return Yohobuy::gebt(API_URL, $param);
} else {
return Yohobuy::httpBuildQuery(API_URL, $param);;
}
}
}
... ...
... ... @@ -239,12 +239,30 @@ class CommonController extends WebAction
*/
public function passportAction()
{
$userInfo = array();
$callback = $this->get('callback');
$uid = $this->getUid();
$userInfo = UserData::passportGet($uid);
if (!empty($uid)) {
$total = 0;
do {
if (empty($uid)) {
break;
}
//调用用户信息
// $userInfo = UserData::passportGet($uid);
$api['profile'] = UserData::getUserProfile($uid, true);
$api['number'] = UserData::getUserInfoNum($uid, true);
$apiInfo = \Api\Yohobuy::getMulti($api);
$userInfo['data'] = array_merge($apiInfo['profile'], $apiInfo['number']);
$userInfo['data']['vip'] = $userInfo['data']['vip_info'];
unset($userInfo['data']['vip_info']);
$userInfo['data']['result'] = 1;
//更新购物车cookie信息
$total = 0;
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::shoppingCart($uid, $shoppingKey);
if (isset($result['main_goods'])) {
... ... @@ -259,25 +277,15 @@ class CommonController extends WebAction
'_r' => 1
)));
}
}
if (isset($userInfo['data'])) {
if (isset($userInfo['data']['data']['vip']['curYearCost'])) {
$userInfo['data']['data']['vip']['curYearCost'] = intval($userInfo['data']['data']['vip']['curYearCost']);
}
if (isset($userInfo['data']['data']['vip']['nextVipInfo']['needCost'])) {
$userInfo['data']['data']['vip']['nextVipInfo']['needCost'] = intval($userInfo['data']['data']['vip']['nextVipInfo']['needCost']);
}
if (isset($userInfo['data']['data']['head_ico']) && !empty($userInfo['data']['data']['head_ico'])) {
$userInfo['data']['data']['head_ico'] = Images::getImageUrl($userInfo['data']['data']['head_ico'], 63, 63, 2, 'yhb-head');
}
if (isset($userInfo['data']['data']['vip']['curYearCostPer'])) {
$userInfo['data']['data']['vip']['curYearCostPer'] = intval($userInfo['data']['data']['vip']['curYearCostPer']);
}
$userInfo['data']['result'] = 1;
$this->helpJsonCallbackResult($callback, 200,'User info', $userInfo['data']);
} else {
} while(false);
if (empty($userInfo)) {
$this->helpJsonCallbackResult($callback, 403,'User info', '');
} else {
$this->helpJsonCallbackResult($callback, 200,'User info', $userInfo);
}
}
/**
... ... @@ -298,7 +306,6 @@ class CommonController extends WebAction
$sknArray = explode('-', $val);
$skn[]= $sknArray[0];
}
// rsort($skn);
$skn = array_slice($skn, 0 ,$limit);
$result = SearchModel::historyProduct($skn, $limit);
} while(false);
... ...