Authored by yangyang

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

@@ -28,7 +28,6 @@ class UserData @@ -28,7 +28,6 @@ class UserData
28 $param = array(); 28 $param = array();
29 $param['uid'] = $uid; 29 $param['uid'] = $uid;
30 30
31 -  
32 return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'ProfilesRest/getUserprofile', $param); 31 return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'ProfilesRest/getUserprofile', $param);
33 } 32 }
34 33
@@ -92,6 +91,21 @@ class UserData @@ -92,6 +91,21 @@ class UserData
92 } 91 }
93 92
94 /** 93 /**
  94 + * 消息数目
  95 + *
  96 + * @param int $uid 用户ID
  97 + * @return array 接口返回的数据
  98 + */
  99 + public static function messageNum($uid)
  100 + {
  101 + $param = Yohobuy::param();
  102 + $param['uid'] = $uid;
  103 + $param['isRead'] = 'N';
  104 +
  105 + return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'inbox/getFavoriteProductCount', $param);
  106 + }
  107 +
  108 + /**
95 * 个人中心页面优选新品数据 109 * 个人中心页面优选新品数据
96 * 110 *
97 * @param int $yh_channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活 111 * @param int $yh_channel 频道,1代表男生,2代表女生,3代表潮童,4代表创意生活
@@ -139,36 +153,32 @@ class UserData @@ -139,36 +153,32 @@ class UserData
139 */ 153 */
140 public static function favoriteProductData($uid, $page = 1, $limit = 10) 154 public static function favoriteProductData($uid, $page = 1, $limit = 10)
141 { 155 {
142 - $param = Yohobuy::param();  
143 - $param['method'] = 'app.favorite.product'; 156 + $param = array();
144 $param['uid'] = $uid; 157 $param['uid'] = $uid;
145 $param['page'] = $page; 158 $param['page'] = $page;
146 $param['limit'] = $limit; 159 $param['limit'] = $limit;
147 - $param['client_secret'] = Sign::getSign($param);  
148 160
149 - return Yohobuy::get(Yohobuy::API_URL, $param); 161 + return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'FavoriteRest/getFavoriteProductList', $param);
150 } 162 }
151 163
152 /** 164 /**
153 * 收藏的品牌数据 165 * 收藏的品牌数据
154 * 166 *
155 * @param int $uid 用户ID 167 * @param int $uid 用户ID
156 - * @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部 168 + * @param int $size 每页条数,size会覆盖limit值
157 * @param int $page 第几页,默认1 169 * @param int $page 第几页,默认1
158 * @param int $limit 限制读取的数目,默认10 170 * @param int $limit 限制读取的数目,默认10
159 * @return array 收藏的品牌接口返回的数据 171 * @return array 收藏的品牌接口返回的数据
160 */ 172 */
161 - public static function favoriteBrandData($uid, $gender, $page = 1, $limit = 10) 173 + public static function favoriteBrandData($uid, $size, $page = 1, $limit = 10)
162 { 174 {
163 - $param = Yohobuy::param();  
164 - $param['method'] = 'app.favorite.brand'; 175 + $param = array();
165 $param['uid'] = $uid; 176 $param['uid'] = $uid;
166 - $param['gender'] = $gender;  
167 $param['page'] = $page; 177 $param['page'] = $page;
  178 + $param['size'] = $size;
168 $param['limit'] = $limit; 179 $param['limit'] = $limit;
169 - $param['client_secret'] = Sign::getSign($param);  
170 180
171 - return Yohobuy::get(Yohobuy::API_URL, $param); 181 + return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'FavoriteRest/getFavoriteBrandList', $param);
172 } 182 }
173 183
174 /** 184 /**
@@ -74,10 +74,9 @@ class HomeController extends AbstractAction @@ -74,10 +74,9 @@ class HomeController extends AbstractAction
74 74
75 $tab = $this->get('tab', ''); 75 $tab = $this->get('tab', '');
76 $uid = $this->getUid(); 76 $uid = $this->getUid();
77 - $gender = Helpers::getGenderByCookie();  
78 77
79 $favProducts = UserModel::getFavProductData($uid); 78 $favProducts = UserModel::getFavProductData($uid);
80 - $favBrands = UserModel::getFavBrandData($uid, $gender); 79 + $favBrands = UserModel::getFavBrandData($uid, 10, 1, 10);
81 80
82 $data = array( 81 $data = array(
83 'favPage' => true, //加载js 82 'favPage' => true, //加载js
@@ -33,7 +33,7 @@ class UserModel @@ -33,7 +33,7 @@ class UserModel
33 $userData = UserData::userData($uid); 33 $userData = UserData::userData($uid);
34 34
35 // 处理个人详情数 35 // 处理个人详情数
36 - if ($userData) { 36 + if (!isset($userData['code'])) {
37 $result = $userData; 37 $result = $userData;
38 $result['gender'] = $result['gender'] == 1 ? '男' : '女'; 38 $result['gender'] = $result['gender'] == 1 ? '男' : '女';
39 $result['head_ico'] = $result['head_ico'] ? Images::getImageUrl($result['head_ico'], 128, 128) : ''; 39 $result['head_ico'] = $result['head_ico'] ? Images::getImageUrl($result['head_ico'], 128, 128) : '';
@@ -82,11 +82,30 @@ class UserModel @@ -82,11 +82,30 @@ class UserModel
82 $result = array(); 82 $result = array();
83 83
84 // 用户优惠券数量 84 // 用户优惠券数量
85 - $couponNum = UserData::couponNum($uid) ?: 0; 85 + $couponNum = UserData::couponNum($uid);
  86 + if(!isset($couponNum['code'])) {
  87 + $result['coupon_num'] = $couponNum;
  88 + }
86 // 用户收藏的品牌数量 89 // 用户收藏的品牌数量
87 - $favBrandNum = UserData::favoriteBrandNum($uid) ?: 0; 90 + $favBrandNum = UserData::favoriteBrandNum($uid);
  91 + if(!isset($favBrandNum['code'])) {
  92 + $result['brand_favorite_total'] = $favBrandNum;
  93 + }
88 // 用户收藏的商品数量 94 // 用户收藏的商品数量
89 - $favProductNum = UserData::favoriteProductNum($uid) ?: 0; 95 + $favProductNum = UserData::favoriteProductNum($uid);
  96 + if(!isset($favProductNum['code'])) {
  97 + $result['product_favorite_total'] = $favProductNum;
  98 + }
  99 + // 未读消息数目
  100 + $messageNum = UserData::messageNum($uid);
  101 + if(!isset($messageNum['code'])) {
  102 + $result['inbox_total'] = $messageNum;
  103 + }
  104 + // 有货币数量
  105 + $coinNum = UserData::yohoCoinData($uid);
  106 + if(!isset($coinNum['code'])) {
  107 + $result['yoho_coin_num'] = $coinNum;
  108 + }
90 109
91 return $result; 110 return $result;
92 } 111 }
@@ -175,12 +194,12 @@ class UserModel @@ -175,12 +194,12 @@ class UserModel
175 $favProduct = UserData::favoriteProductData($uid); 194 $favProduct = UserData::favoriteProductData($uid);
176 195
177 // 处理用户收藏的商品数据 196 // 处理用户收藏的商品数据
178 - if (isset($favProduct['data']) && !empty($favProduct['data'])) { 197 + if (isset($favProduct['list']) && !empty($favProduct['list'])) {
179 $product = array(); 198 $product = array();
180 - foreach ($favProduct['data']['product_list'] as $val) { 199 + foreach ($favProduct['list'] as $val) {
181 $product = array(); 200 $product = array();
182 $product['fav_id'] = $val['product_id']; 201 $product['fav_id'] = $val['product_id'];
183 - $product['imgUrl'] = $val['image']; 202 + $product['imgUrl'] = Helpers::getImageUrl($val['image'], 140, 140);
184 $product['title'] = $val['product_name']; 203 $product['title'] = $val['product_name'];
185 $product['price'] = '¥'.$val['market_price']; 204 $product['price'] = '¥'.$val['market_price'];
186 $product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥'.$val['sales_price'] : false; 205 $product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥'.$val['sales_price'] : false;
@@ -199,20 +218,22 @@ class UserModel @@ -199,20 +218,22 @@ class UserModel
199 * 处理用户收藏的品牌数据 218 * 处理用户收藏的品牌数据
200 * 219 *
201 * @param int $uid 用户ID 220 * @param int $uid 用户ID
202 - * @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部 221 + * @param int $size 每页条数,size会覆盖limit值
  222 + * @param int $page 第几页,默认1
  223 + * @param int $limit 限制读取的数目,默认10
203 * @return array|mixed 处理之后的收藏的品牌数据 224 * @return array|mixed 处理之后的收藏的品牌数据
204 */ 225 */
205 - public static function getFavBrandData($uid, $gender) 226 + public static function getFavBrandData($uid, $size, $page, $limit)
206 { 227 {
207 $result = array(); 228 $result = array();
208 229
209 // 调用接口获取户收藏的品牌数据 230 // 调用接口获取户收藏的品牌数据
210 - $favBrand = UserData::favoriteBrandData($uid, $gender); 231 + $favBrand = UserData::favoriteBrandData($uid, $size, $page, $limit);
211 232
212 // 处理用户收藏的品牌数据 233 // 处理用户收藏的品牌数据
213 - if (isset($favBrand['data']) && !empty($favBrand['data'])) { 234 + if (isset($favBrand['list']) && !empty($favBrand['list'])) {
214 $brand = array(); 235 $brand = array();
215 - foreach ($favBrand['data']['brand_list'] as $val) { 236 + foreach ($favBrand['list'] as $val) {
216 $brand = array(); 237 $brand = array();
217 $brand['id'] = $val['brand_id']; 238 $brand['id'] = $val['brand_id'];
218 $brand['brandImg'] = Images::getImageUrl($val['brand_ico'], 235, 314); 239 $brand['brandImg'] = Images::getImageUrl($val['brand_ico'], 235, 314);