Authored by yangyang

Merge branch 'java-api' of http://git.dev.yoho.cn/web/yohobuy into java-api

... ... @@ -28,7 +28,6 @@ class UserData
$param = array();
$param['uid'] = $uid;
return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'ProfilesRest/getUserprofile', $param);
}
... ... @@ -92,6 +91,21 @@ class UserData
}
/**
* 消息数目
*
* @param int $uid 用户ID
* @return array 接口返回的数据
*/
public static function messageNum($uid)
{
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['isRead'] = 'N';
return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'inbox/getFavoriteProductCount', $param);
}
/**
* 个人中心页面优选新品数据
*
* @param int $yh_channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
... ... @@ -139,36 +153,32 @@ class UserData
*/
public static function favoriteProductData($uid, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.product';
$param = array();
$param['uid'] = $uid;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'FavoriteRest/getFavoriteProductList', $param);
}
/**
* 收藏的品牌数据
*
* @param int $uid 用户ID
* @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部
* @param int $size 每页条数,size会覆盖limit值
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array 收藏的品牌接口返回的数据
*/
public static function favoriteBrandData($uid, $gender, $page = 1, $limit = 10)
public static function favoriteBrandData($uid, $size, $page = 1, $limit = 10)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.brand';
$param = array();
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['page'] = $page;
$param['size'] = $size;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'FavoriteRest/getFavoriteBrandList', $param);
}
/**
... ...
... ... @@ -74,10 +74,9 @@ class HomeController extends AbstractAction
$tab = $this->get('tab', '');
$uid = $this->getUid();
$gender = Helpers::getGenderByCookie();
$favProducts = UserModel::getFavProductData($uid);
$favBrands = UserModel::getFavBrandData($uid, $gender);
$favBrands = UserModel::getFavBrandData($uid, 10, 1, 10);
$data = array(
'favPage' => true, //加载js
... ...
... ... @@ -33,7 +33,7 @@ class UserModel
$userData = UserData::userData($uid);
// 处理个人详情数
if ($userData) {
if (!isset($userData['code'])) {
$result = $userData;
$result['gender'] = $result['gender'] == 1 ? '男' : '女';
$result['head_ico'] = $result['head_ico'] ? Images::getImageUrl($result['head_ico'], 128, 128) : '';
... ... @@ -82,11 +82,30 @@ class UserModel
$result = array();
// 用户优惠券数量
$couponNum = UserData::couponNum($uid) ?: 0;
$couponNum = UserData::couponNum($uid);
if(!isset($couponNum['code'])) {
$result['coupon_num'] = $couponNum;
}
// 用户收藏的品牌数量
$favBrandNum = UserData::favoriteBrandNum($uid) ?: 0;
$favBrandNum = UserData::favoriteBrandNum($uid);
if(!isset($favBrandNum['code'])) {
$result['brand_favorite_total'] = $favBrandNum;
}
// 用户收藏的商品数量
$favProductNum = UserData::favoriteProductNum($uid) ?: 0;
$favProductNum = UserData::favoriteProductNum($uid);
if(!isset($favProductNum['code'])) {
$result['product_favorite_total'] = $favProductNum;
}
// 未读消息数目
$messageNum = UserData::messageNum($uid);
if(!isset($messageNum['code'])) {
$result['inbox_total'] = $messageNum;
}
// 有货币数量
$coinNum = UserData::yohoCoinData($uid);
if(!isset($coinNum['code'])) {
$result['yoho_coin_num'] = $coinNum;
}
return $result;
}
... ... @@ -175,12 +194,12 @@ class UserModel
$favProduct = UserData::favoriteProductData($uid);
// 处理用户收藏的商品数据
if (isset($favProduct['data']) && !empty($favProduct['data'])) {
if (isset($favProduct['list']) && !empty($favProduct['list'])) {
$product = array();
foreach ($favProduct['data']['product_list'] as $val) {
foreach ($favProduct['list'] as $val) {
$product = array();
$product['fav_id'] = $val['product_id'];
$product['imgUrl'] = $val['image'];
$product['imgUrl'] = Helpers::getImageUrl($val['image'], 140, 140);
$product['title'] = $val['product_name'];
$product['price'] = '¥'.$val['market_price'];
$product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥'.$val['sales_price'] : false;
... ... @@ -199,20 +218,22 @@ class UserModel
* 处理用户收藏的品牌数据
*
* @param int $uid 用户ID
* @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部
* @param int $size 每页条数,size会覆盖limit值
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @return array|mixed 处理之后的收藏的品牌数据
*/
public static function getFavBrandData($uid, $gender)
public static function getFavBrandData($uid, $size, $page, $limit)
{
$result = array();
// 调用接口获取户收藏的品牌数据
$favBrand = UserData::favoriteBrandData($uid, $gender);
$favBrand = UserData::favoriteBrandData($uid, $size, $page, $limit);
// 处理用户收藏的品牌数据
if (isset($favBrand['data']) && !empty($favBrand['data'])) {
if (isset($favBrand['list']) && !empty($favBrand['list'])) {
$brand = array();
foreach ($favBrand['data']['brand_list'] as $val) {
foreach ($favBrand['list'] as $val) {
$brand = array();
$brand['id'] = $val['brand_id'];
$brand['brandImg'] = Images::getImageUrl($val['brand_ico'], 235, 314);
... ...