Authored by yangyang

先删除home文件夹,改大写。优化gradedata.php

... ... @@ -15,10 +15,11 @@ class GradeData
/**
* 获取会员等级数据
* @param string $yh_channel 频道数据,1->男,2->女,3->潮童,4->创意生活,5->其他
* @param strint $gender 用户性别
* @param string $uid 用户id
* @return array 接口返回的会员等级数据
*/
public function getGradeData($channel, $uid) {
public function getGradeData($gender,$channel, $uid) {
$urlList = array();
//获取会员等级数据
$param = Yohobuy::param();
... ... @@ -29,7 +30,6 @@ class GradeData
$urlList['grade'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
//获取用户基本信息数据(用来得到username)
$param = array();
$param = Yohobuy::param();
$param['gender'] = $gender;
$param['uid'] = $uid;
... ... @@ -39,7 +39,6 @@ class GradeData
$urlList['userProfile'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
return Yohobuy::getMulti($urlList);
//return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
... ... @@ -58,18 +57,4 @@ class GradeData
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);
//
// return Yohobuy::get("http://api.open.yohobuy.com/",$param);
// }
}
... ...
<?php
namespace home;
use LibModels\Wap\Home\GradeData;
use Action\AbstractAction;
use Plugin\Helpers;
/**
* 会员等级相关数据处理
*/
class GradeModel
{
/*
* 获取个人中心-会员等级数据
*/
public function getGrade($gender, $channel, $uid) {
$result = array();
if (USE_CACHE) {
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get(CacheConfig::KEY_ACTION_HOME_GRADE, 'master');
if (!empty($result)) {
return $result;
}
}
//调用接口获取数据
$data = GradeData::getGradeData($gender,$channel, $uid);
print_r($data);
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'] = 100*(round($data['data']['current_total_cost'] / $data['data']['next_need_cost'], 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 调用获取用户基本信息数据,获得username;
$userProfile = GradeData::getUserProfileData($gender,$uid,$channel);
$result['vipGrade']['name'] = $userProfile['data']['username'];
//跳转url(会员特权详情)
$result['vipGrade']['allUrl'] = Helpers::url('/Home/preferential',null);
//当前vip等级享受的特权
$result['vipGrade']['privilege'] = $data['data']['enjoy_preferential'];
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get(CacheConfig::KEY_ACTION_HOME_GRADE, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set(CacheConfig::KEY_ACTION_HOME_GRADE, $result);
}
}
return $result;
}
/*
* 获取个人中心-会员特权详情页
*/
public function getPreferential($channel, $uid) {
$result = array();
if (USE_CACHE) {
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get(CacheConfig::KEY_ACTION_HOME_PREFERENTIAL, 'master');
if (!empty($result)) {
return $result;
}
}
//调取接口获得数据
$data = GradeData::getPreferentialData($channel, $uid);
if (isset($data['code']) && $data['code'] == 200) {
$result['vipGrade']['privilege'] = $data['data'];
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get(CacheConfig::KEY_ACTION_HOME_GRADE, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set(CacheConfig::KEY_ACTION_HOME_PREFERENTIAL, $result);
}
}
return $result;
}
}
<?php
namespace home;
use LibModels\Wap\Home\OrderData;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of Order
*
*/
class OrderModel
{
/**
* 订单相关数据处理
*/
public function getOrder($type = 1,$page = 1,$limit,$gender,$yh_channel,$uid){
$data = OrderData::getOrderData($type,$page,$limit,$gender,$yh_channel,$uid);
return $data;
}
}