Authored by yangyang

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

  1 +<?php
  2 +
  3 + namespace LibModels\Wap\Home;
  4 + use Api\Yohobuy;
  5 + use Api\Sign;
  6 +/*
  7 + *个人中心-会员等级接口操作类
  8 + */
  9 +
  10 +class GradeData {
  11 +
  12 + /**
  13 + * 获取会员等级展示数据
  14 + */
  15 + public function getGradeData($channel,$uid){
  16 +
  17 + $param = Yohobuy::param();
  18 + $param['yh_channel'] = $channel;
  19 + $param['uid'] = $uid;
  20 + $param['method'] = 'app.Passport.vip';
  21 + $param['client_secret'] = Sign::getSign($param);
  22 + return Yohobuy::get(Yohobuy::API_URL,$param);
  23 + }
  24 + /**
  25 + * 获取会员特权查看页面数据
  26 + */
  27 + public function getPreferentialData($channel,$uid){
  28 + $param = Yohobuy::param();
  29 + $param['yh_channel'] = $channel;
  30 + $param['uid'] = $uid;
  31 + $param['method'] = 'app.passport.getPrivilege';
  32 + $param['client_secret'] = Sign::getSign($param);
  33 + //print_r($param);
  34 + //print_r(Yohobuy::get('http://api.open.yohobuy.com',$param));
  35 + return Yohobuy::get(Yohobuy::API_URL,$param);
  36 + }
  37 +
  38 + /**
  39 + * 获取用户基本信息数据
  40 + */
  41 + public function getUserProfileData($gender,$uid,$channel){
  42 + $param = Yohobuy::param();
  43 + $param['gender'] = $gender;
  44 + $param['uid'] = $uid;
  45 + $param['yh_channel'] = $channel;
  46 + $param['method'] = 'app.passport.profile';
  47 + $param['client_secret'] = Sign::getSign($param);
  48 +
  49 + var_dump(Yohobuy::get(Yohobuy::API_URL,$param));
  50 + }
  51 +}
@@ -150,8 +150,8 @@ class HomeController extends AbstractAction @@ -150,8 +150,8 @@ class HomeController extends AbstractAction
150 $uid = $this -> getUid(); 150 $uid = $this -> getUid();
151 $uid = '10267443'; 151 $uid = '10267443';
152 $data = GradeModel::getGrade($gender,$channel,$uid); 152 $data = GradeModel::getGrade($gender,$channel,$uid);
153 - //print_r($data);  
154 - //$this -> _view -> display('index',$data); 153 +
  154 + $this -> _view -> display('vip-grade',$data);
155 } 155 }
156 /* 156 /*
157 *会员特权查看页 157 *会员特权查看页
@@ -161,8 +161,8 @@ class HomeController extends AbstractAction @@ -161,8 +161,8 @@ class HomeController extends AbstractAction
161 $uid = $this -> getUid(); 161 $uid = $this -> getUid();
162 162
163 $data = GradeModel::getPreferential($channel,$uid); 163 $data = GradeModel::getPreferential($channel,$uid);
164 - print_r($data);  
165 - //$this -> _view -> display('index',$data); 164 + //print_r($data);
  165 + //$this -> _view -> display('index',$data);
166 } 166 }
167 167
168 } 168 }
  1 +<?php
  2 +namespace home;
  3 +
  4 +use LibModels\Wap\Home\GradeData;
  5 +/**
  6 + *会员等级相关数据处理
  7 + */
  8 +class GradeModel {
  9 + /*
  10 + * 获取个人中心-会员等级数据
  11 + */
  12 + public function getGrade($gender,$channel,$uid){
  13 + $result = array();
  14 + //调用接口获取数据
  15 + $data = GradeData::getGradeData($channel,$uid);
  16 + if(isset($data['code']) && $data['code'] === 200 &&isset($data['data'])){
  17 + switch(intval($data['data']['current_vip_level'])){
  18 + case 0://普通会员
  19 + $result['vipGrade']['vip0'] = true;
  20 + break;
  21 + case 1://银卡会员
  22 + $result['vipGrade']['vip1'] = true;
  23 + break;
  24 + case 2://金卡会员
  25 + $result['vipGrade']['vip2'] = true;
  26 + break;
  27 + case 3://白金会员
  28 + $result['vipGrade']['vip3'] = true;
  29 + break;
  30 + }
  31 + //今年总消费
  32 + $result['vipGrade']['costOfThisYear'] = $data['data']['current_year_cost'];
  33 + //升级下一等级会员的进度;
  34 + $result['vipGrade']['percent'] = round(round($data['data']['current_total_cost'],2)/round($data['data']['next_need_cost'],2),2);
  35 + //距离升级所需消费金额
  36 + if($data['data']['current_vip_level'] != 3){
  37 + $result['vipGrade']['costGap'] = $data['data']['upgrade_need_cost'];
  38 + }
  39 + //消费总计
  40 + $result['vipGrade']['sumCost'] = $data['data']['current_total_cost'];
  41 + //username
  42 + //$result['vipGrade']['username'] = GradeData::getUserProfileData($gender,$uid,$channel);
  43 + $result['vipGrade']['name'] = 'yangyang';
  44 + //print_r($result);
  45 +
  46 + return $result;
  47 + }
  48 +
  49 + return false;
  50 + }
  51 + /*
  52 + * 获取个人中心-会员特权详情页
  53 + */
  54 + public function getPreferential($channel,$uid){
  55 + $result = array();
  56 + $data = GradeData::getPreferentialData($channel,$uid);
  57 + if(isset($data['code']) && $data['code'] == 200){
  58 + //$data['data']
  59 + }
  60 + return $data;
  61 + }
  62 +}
  1 +<?php
  2 +
  3 +use Action\AbstractAction;
  4 +
  5 +/**
  6 + * 会员等级
  7 + */
  8 +class GradeController extends AbstractAction{
  9 +
  10 + /**
  11 + * 会员等级展示页
  12 + */
  13 + public function indexAction(){
  14 + //$data =
  15 + echo "1";
  16 + //$data = '1';
  17 + //$this -> _view -> display('index',$data);
  18 + }
  19 +}