Authored by yangyang

增加了会员等级管理功能相关的控制器,模型层与接口文件

<?php
namespace LibModels\Wap\Home;
use Api\Yohobuy;
use Api\Sign;
/*
*个人中心-会员等级接口操作类
*/
class GradeData {
/**
* 获取会员等级展示数据
*/
public function getGradeData($channel,$uid){
$param = Yohobuy::param();
$param['yh_channel'] = $channel;
$param['uid'] = $uid;
$param['method'] = 'app.Passport.vip';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL,$param);
}
/**
* 获取会员特权查看页面数据
*/
public function getPreferentialData($channel,$uid){
$param = Yohobuy::param();
$param['yh_channel'] = $channel;
$param['uid'] = $uid;
$param['method'] = 'app.passport.getPrivilege';
$param['client_secret'] = Sign::getSign($param);
//print_r($param);
//print_r(Yohobuy::get('http://api.open.yohobuy.com',$param));
return Yohobuy::get(Yohobuy::API_URL,$param);
}
/**
* 获取用户基本信息数据
*/
public function getUserProfileData($gender,$uid,$channel){
$param = Yohobuy::param();
$param['gender'] = $gender;
$param['uid'] = $uid;
$param['yh_channel'] = $channel;
$param['method'] = 'app.passport.profile';
$param['client_secret'] = Sign::getSign($param);
var_dump(Yohobuy::get(Yohobuy::API_URL,$param));
}
}
... ...
... ... @@ -150,8 +150,8 @@ class HomeController extends AbstractAction
$uid = $this -> getUid();
$uid = '10267443';
$data = GradeModel::getGrade($gender,$channel,$uid);
//print_r($data);
//$this -> _view -> display('index',$data);
$this -> _view -> display('vip-grade',$data);
}
/*
*会员特权查看页
... ... @@ -161,8 +161,8 @@ class HomeController extends AbstractAction
$uid = $this -> getUid();
$data = GradeModel::getPreferential($channel,$uid);
print_r($data);
//$this -> _view -> display('index',$data);
//print_r($data);
//$this -> _view -> display('index',$data);
}
}
... ...
<?php
namespace home;
use LibModels\Wap\Home\GradeData;
/**
*会员等级相关数据处理
*/
class GradeModel {
/*
* 获取个人中心-会员等级数据
*/
public function getGrade($gender,$channel,$uid){
$result = array();
//调用接口获取数据
$data = GradeData::getGradeData($channel,$uid);
if(isset($data['code']) && $data['code'] === 200 &&isset($data['data'])){
switch(intval($data['data']['current_vip_level'])){
case 0://普通会员
$result['vipGrade']['vip0'] = true;
break;
case 1://银卡会员
$result['vipGrade']['vip1'] = true;
break;
case 2://金卡会员
$result['vipGrade']['vip2'] = true;
break;
case 3://白金会员
$result['vipGrade']['vip3'] = true;
break;
}
//今年总消费
$result['vipGrade']['costOfThisYear'] = $data['data']['current_year_cost'];
//升级下一等级会员的进度;
$result['vipGrade']['percent'] = round(round($data['data']['current_total_cost'],2)/round($data['data']['next_need_cost'],2),2);
//距离升级所需消费金额
if($data['data']['current_vip_level'] != 3){
$result['vipGrade']['costGap'] = $data['data']['upgrade_need_cost'];
}
//消费总计
$result['vipGrade']['sumCost'] = $data['data']['current_total_cost'];
//username
//$result['vipGrade']['username'] = GradeData::getUserProfileData($gender,$uid,$channel);
$result['vipGrade']['name'] = 'yangyang';
//print_r($result);
return $result;
}
return false;
}
/*
* 获取个人中心-会员特权详情页
*/
public function getPreferential($channel,$uid){
$result = array();
$data = GradeData::getPreferentialData($channel,$uid);
if(isset($data['code']) && $data['code'] == 200){
//$data['data']
}
return $data;
}
}
... ...
<?php
use Action\AbstractAction;
/**
* 会员等级
*/
class GradeController extends AbstractAction{
/**
* 会员等级展示页
*/
public function indexAction(){
//$data =
echo "1";
//$data = '1';
//$this -> _view -> display('index',$data);
}
}
... ...