Authored by yangyang

修改了GradeData.php:username数据修复;

@@ -45,16 +45,17 @@ class GradeData @@ -45,16 +45,17 @@ class GradeData
45 } 45 }
46 46
47 /** 47 /**
48 - * 获取用户基本信息数据??获取不到 48 + * 获取用户基本信息数据
49 */ 49 */
50 -// public function getUserProfileData($gender, $uid, $channel) {  
51 -// $param = Yohobuy::param();  
52 -// $param['gender'] = $gender;  
53 -// $param['uid'] = $uid;  
54 -// $param['yh_channel'] = $channel;  
55 -// $param['method'] = 'app.passport.profile';  
56 -// $param['client_secret'] = Sign::getSign($param);  
57 -// var_dump(Yohobuy::post(Yohobuy::API_URL,$param));  
58 -// } 50 + public function getUserProfileData($gender, $uid, $channel) {
  51 + $param = Yohobuy::param();
  52 + $param['gender'] = $gender;
  53 + $param['uid'] = $uid;
  54 + $param['yh_channel'] = $channel;
  55 + $param['method'] = 'app.passport.profile';
  56 + $param['client_secret'] = Sign::getSign($param);
  57 +
  58 + return Yohobuy::get("http://api.open.yohobuy.com/",$param);
  59 + }
59 60
60 } 61 }
@@ -239,7 +239,7 @@ class HomeController extends AbstractAction @@ -239,7 +239,7 @@ class HomeController extends AbstractAction
239 $gender = Helpers::getGenderByCookie(); 239 $gender = Helpers::getGenderByCookie();
240 $channel = Helpers::getChannelByCookie(); 240 $channel = Helpers::getChannelByCookie();
241 $uid = $this -> getUid(); 241 $uid = $this -> getUid();
242 - $uid = '10267443';//临时测试用 242 + $uid = '7566245';//临时测试用
243 $data = GradeModel::getGrade($gender,$channel,$uid); 243 $data = GradeModel::getGrade($gender,$channel,$uid);
244 $this -> _view -> display('vip-grade',$data); 244 $this -> _view -> display('vip-grade',$data);
245 } 245 }
@@ -27,6 +27,7 @@ class GradeModel @@ -27,6 +27,7 @@ class GradeModel
27 } 27 }
28 //调用接口获取数据 28 //调用接口获取数据
29 $data = GradeData::getGradeData($channel, $uid); 29 $data = GradeData::getGradeData($channel, $uid);
  30 +
30 if (isset($data['code']) && $data['code'] === 200 && isset($data['data'])) { 31 if (isset($data['code']) && $data['code'] === 200 && isset($data['data'])) {
31 switch (intval($data['data']['current_vip_level'])) { 32 switch (intval($data['data']['current_vip_level'])) {
32 case 0://普通会员 33 case 0://普通会员
@@ -42,19 +43,25 @@ class GradeModel @@ -42,19 +43,25 @@ class GradeModel
42 $result['vipGrade']['vip3'] = true; 43 $result['vipGrade']['vip3'] = true;
43 break; 44 break;
44 } 45 }
  46 +
45 //今年总消费 47 //今年总消费
46 $result['vipGrade']['costOfThisYear'] = $data['data']['current_year_cost']; 48 $result['vipGrade']['costOfThisYear'] = $data['data']['current_year_cost'];
47 //升级下一等级会员的进度; 49 //升级下一等级会员的进度;
48 - $result['vipGrade']['percent'] = 100*(round(round($data['data']['current_total_cost'], 2) / round($data['data']['next_need_cost'], 2), 2)); 50 + $result['vipGrade']['percent'] = 100*(round($data['data']['current_total_cost'] / $data['data']['next_need_cost'], 2));
49 //距离升级所需消费金额 51 //距离升级所需消费金额
  52 +
50 if ($data['data']['current_vip_level'] != 3) { 53 if ($data['data']['current_vip_level'] != 3) {
51 $result['vipGrade']['costGap'] = $data['data']['upgrade_need_cost']; 54 $result['vipGrade']['costGap'] = $data['data']['upgrade_need_cost'];
52 } 55 }
53 //消费总计 56 //消费总计
54 $result['vipGrade']['sumCost'] = $data['data']['current_total_cost']; 57 $result['vipGrade']['sumCost'] = $data['data']['current_total_cost'];
55 - //username 接口问题取不到,暂时写uid  
56 - $result['vipGrade']['name'] = $uid; 58 + //username 调用获取用户基本信息数据,获得username;
  59 + $userProfile = GradeData::getUserProfileData($gender,$uid,$channel);
  60 + $result['vipGrade']['name'] = $userProfile['data']['username'];
  61 + //跳转url(会员特权详情)
57 $result['vipGrade']['allUrl'] = Helpers::url('/Home/preferential',null); 62 $result['vipGrade']['allUrl'] = Helpers::url('/Home/preferential',null);
  63 + //当前vip等级享受的特权
  64 + $result['vipGrade']['privilege'] = $data['data']['enjoy_preferential'];
58 } 65 }
59 66
60 if (USE_CACHE) { 67 if (USE_CACHE) {