Authored by uedxwg

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

... ... @@ -12,49 +12,46 @@ use Api\Sign;
class GradeData
{
/**
* 获取会员等级数据
* @param string $yh_channel 频道数据,1->男,2->女,3->潮童,4->创意生活,5->其他
* @param strint $gender 用户性别
* @param string $uid 用户id
* @return array 接口返回的会员等级数据
*/
public static function getGradeData($gender, $channel, $uid) {
$urlList = array();
//获取会员等级数据
$param = Yohobuy::param();
$param['yh_channel'] = $channel;
$param['uid'] = $uid;
$param['method'] = 'app.Passport.vip';
$param['client_secret'] = Sign::getSign($param);
$urlList['grade'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
//获取用户基本信息数据(用来得到username)
$param = Yohobuy::param();
$param['gender'] = $gender;
$param['uid'] = $uid;
$param['yh_channel'] = $channel;
$param['method'] = 'app.passport.profile';
$param['client_secret'] = Sign::getSign($param);
$urlList['userProfile'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
return Yohobuy::getMulti($urlList);
}
/**
* 获取会员特权详情数据
* @param string $yh_channel 频道数据,1->男,2->女,3->潮童,4->创意生活,5->其他
* @param string $uid 用户id
* @return array 接口返回的会员特权详情数据
*/
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);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取会员等级数据
* @param string $yh_channel 频道数据,1->男,2->女,3->潮童,4->创意生活,5->其他
* @param string $uid 用户id
* @return array 接口返回的会员等级数据
*/
public static function getGradeData($channel, $uid) {
$urlList = array();
//获取会员等级数据
$param = Yohobuy::param();
$param['yh_channel'] = $channel;
$param['uid'] = $uid;
$param['method'] = 'app.Passport.vip';
$param['client_secret'] = Sign::getSign($param);
$urlList['grade'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
//获取用户基本信息数据(用来得到username)
$param = Yohobuy::param();
$param['uid'] = $uid;
$param['method'] = 'app.passport.profile';
$param['client_secret'] = Sign::getSign($param);
$urlList['userProfile'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
return Yohobuy::getMulti($urlList);
}
/**
* 获取会员特权详情数据
* @param string $yh_channel 频道数据,1->男,2->女,3->潮童,4->创意生活,5->其他
* @param string $uid 用户id
* @return array 接口返回的会员特权详情数据
*/
public static 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);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -141,6 +141,7 @@ class UserData
$param = Yohobuy::param();
$param['method'] = 'app.favorite.cancel';
$param['type'] = 'product';
$param['uid'] = $uid;
$param['fav_id'] = $fav_id;
$param['client_secret'] = Sign::getSign($param);
... ...
No preview for this file type
... ... @@ -2,7 +2,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
Created by FontForge 20120731 at Mon Nov 16 18:08:15 2015
Created by FontForge 20120731 at Mon Nov 23 16:04:11 2015
By Ads
</metadata>
<defs>
... ... @@ -13,10 +13,10 @@ Created by FontForge 20120731 at Mon Nov 16 18:08:15 2015
font-stretch="normal"
units-per-em="1024"
panose-1="2 0 6 3 0 0 0 0 0 0"
ascent="812"
descent="-212"
ascent="896"
descent="-128"
x-height="792"
bbox="-0.75 -224 3943 812.871"
bbox="-0.75 -224 3943 833"
underline-thickness="50"
underline-position="-100"
unicode-range="U+0078-E63E"
... ... @@ -237,6 +237,11 @@ t-38 -158.5q0 -78 33 -148.5t93 -125.5l-77 -123q-8 -12 -6.5 -26t10.5 -25l5 -5q2 -
q10 10 11 24t-7 26zM286 160q0 -17 2 -35v1q-35 16 -64.5 38t-53 48t-40.5 55.5t-26 62.5t-9 67q0 85 51.5 157t139.5 114t192 42q142 0 249.5 -76.5t128.5 -189.5q-43 21 -91 32t-98 11q-39 0 -77 -6.5t-71.5 -19t-64.5 -30.5t-56.5 -40t-46.5 -48.5t-35.5 -55.5t-22 -61
t-7.5 -66zM381 160q0 63 38.5 116.5t104 84.5t143.5 31q118 0 202 -68t84 -164q0 -62 -38.5 -115.5t-104.5 -84.5t-143 -31q-118 0 -202 68t-84 163zM527 191q-16 0 -27.5 -11t-11.5 -27q0 -11 5.5 -20t14.5 -14t19 -5q16 0 27.5 11.5t11.5 27.5t-11.5 27t-27.5 11zM667 191
q-16 0 -27.5 -11t-11.5 -27t11.5 -27.5t27.5 -11.5q10 0 19 5t14.5 14t5.5 20q0 7 -3.5 14.5t-8.5 12.5t-12 8t-15 3zM806 191q-16 0 -27 -11t-11 -27t11 -27.5t27 -11.5t27.5 11.5t11.5 27.5q0 7 -3 14.5t-8 12.5t-12.5 8t-15.5 3z" />
<glyph glyph-name="uniE63D" unicode="&#xe63d;"
d="M512 13q-131 0 -241.5 55t-175 149.5t-64.5 205.5t64.5 205.5t175 149.5t241.5 55q98 0 187 -32.5t153.5 -87.5t102.5 -131t38 -159q0 -111 -64.5 -205.5t-175 -149.5t-241.5 -55zM512 751q-54 0 -106 -12t-95.5 -33t-80.5 -51.5t-63 -66.5t-40 -78.5t-14 -86.5
q0 -89 53.5 -164.5t145.5 -119.5t200 -44q65 0 126 16.5t110 47t86 71t57 90.5t20 103q0 89 -53.5 164.5t-145.5 119.5t-200 44zM730 75l184 -82l-102 164zM914 -44q-8 0 -15 3l-184 82q-14 6 -19.5 20.5t0.5 28.5q3 7 8.5 12t12 7.5t14 2t14.5 -3.5l74 -33l-39 62
q-4 6 -5 13.5t0.5 14.5t6 13t10.5 10q13 8 28 4.5t23 -16.5l102 -164q15 -23 -3 -43q-4 -4 -8.5 -7t-9.5 -4.5t-10 -1.5zM379 413q0 -22 -15 -37t-36.5 -15t-36.5 15t-15 37q0 7 2 13.5t5.5 12t8 10.5t10 8t12.5 5t14 2q10 0 19.5 -4t16.5 -11t11 -16.5t4 -19.5zM563 413
q0 -14 -7 -26t-18.5 -19t-25.5 -7t-25.5 7t-18.5 19t-7 26q0 21 15 36t36 15q14 0 25.5 -7t18.5 -18.5t7 -25.5zM748 413q0 -22 -15 -37t-36.5 -15t-36.5 15t-15 36.5t15 36.5t36 15q14 0 26 -7t19 -18.5t7 -25.5z" />
<glyph glyph-name="uniE63E" unicode="&#xe63e;"
d="M521 317zM768 -178h-1h-1h-1h-1h-1h-1h-1h-1h-1h-1h-1q-11 1 -23 2h-1h-1h-1h-1h-1l-1 1h-1h-1h-1h-1h-1h-1h-1l-1 1h-1h-1h-1h-1h-1l-1 1h-1h-1h-1h-1h-1h-1l-1 1h-1h-1h-1h-1l-1 1h-1h-1h-1h-1l-1 1h-1h-1h-1h-1l-1 1h-1h-1h-1l-1 1h-1h-1h-1h-1l-1 1h-1h-1l-1 1h-1h-1
h-1h-1l-1 1h-1h-1h-1l-1 1h-1h-1h-1l-1 1h-1l-1 1h-1h-1h-1l-1 1h-1h-1h-1l-1 1h-1h-1l-1 1h-1h-1h-1l-1 1h-1h-1l-1 1h-1l-1 1h-1h-1l-1 1h-1h-1l-1 1h-1h-1l-1 1h-1h-1l-1 1h-1h-1l-1 1h-1h-1l-1 1h-1h-1l-1 1h-1l-1 1h-1h-1l-1 1h-1l-1 1h-1l-1 1h-1h-1l-1 1h-1h-1l-1 1
... ...
No preview for this file type
No preview for this file type
... ... @@ -398,8 +398,8 @@ if ($brandHeader.length > 0) {
//品牌收藏
brandColHammer = new Hammer($brandHeader.children('.btn-col')[0]);
brandColHammer.on('tap', function() {
var $this = $(this);
brandColHammer.on('tap', function(e) {
var $this = $(e.target).closest('.btn-col');
var id = $brandHeader.data('id'),
opt;
... ...
... ... @@ -88,7 +88,7 @@
<span class="iconfont num">&#xe604;</span>
</a>
<a class="list-item" href="/home/suggest">
<span class="iconfont icon">&#xe63c;</span>
<span class="iconfont icon">&#xe63d;</span>
意见反馈
<span class="iconfont num">&#xe604;</span>
</a>
... ...
<?php
use Action\AbstractAction;
use Home\GradeModel;
use Home\OrderModel;
use Plugin\Helpers;
use LibModels\Wap\Home\OrderData;
use Index\UserModel as UserModel;
/**
* 个人中心相关的控制器
... ... @@ -49,12 +52,12 @@ class HomeController extends AbstractAction
$uid = $this->getUid();
if ($uid) {
$data['isLogin'] = true;
$data += \Index\UserModel::getUserProfileData($uid);
$data += \Index\UserModel::getInfoNumData($uid);
$data += UserModel::getUserProfileData($uid);
$data += UserModel::getInfoNumData($uid);
// 优选新品数据
$channel = Helpers::getChannelByCookie();
$data['recommendForYou'] = \Index\UserModel::getPreferenceData($channel);
$data['recommendForYou'] = UserModel::getPreferenceData($channel);
}
$this->_view->display('index', $data);
... ... @@ -73,8 +76,8 @@ class HomeController extends AbstractAction
$uid = $this->getUid();
$gender = Helpers::getGenderByCookie();
$favProducts = \Index\UserModel::getFavProductData($uid);
$favBrands = \Index\UserModel::getFavBrandData($uid, $gender);
$favProducts = UserModel::getFavProductData($uid);
$favBrands = UserModel::getFavBrandData($uid, $gender);
$data = array(
'favPage' => true, //加载js
... ... @@ -104,7 +107,7 @@ class HomeController extends AbstractAction
$uid = $this->getUid();
$fav_id = $this->post('fav_id', 0);
$result = \Index\UserModel::favoriteDelete($uid, $fav_id);
$result = UserModel::favoriteDelete($uid, $fav_id);
}
if (empty($result)) {
... ... @@ -123,7 +126,7 @@ class HomeController extends AbstractAction
$this->setNavHeader('个人信息', true, SITE_MAIN);
$uid = $this->getUid();
$data = \Index\UserModel::getUserProfileData($uid);
$data = UserModel::getUserProfileData($uid);
$data['personalDetailsPage'] = true;
$data['pageFooter'] = true;
$this->_view->display('personal-details', $data);
... ... @@ -138,7 +141,7 @@ class HomeController extends AbstractAction
$this->setNavHeader('YOHO币', true, false);
$uid = $this->getUid();
$currency = \Index\UserModel::getYohoCoinData($uid);
$currency = UserModel::getYohoCoinData($uid);
$currency['pageFooter'] = true;
$this->_view->display('currency', $currency);
... ... @@ -154,7 +157,7 @@ class HomeController extends AbstractAction
$uid = $this->getUid();
$coupons = array(
'couponsUrl' => \Index\UserModel::getCouponData($uid),
'couponsUrl' => UserModel::getCouponData($uid),
'couponsPage' => true
);
$this->_view->display('coupons', $coupons);
... ... @@ -169,7 +172,7 @@ class HomeController extends AbstractAction
$page = $this->get('page', 0);
$size = $this->get('size', 10);
$messages = \Index\UserModel::getMessageData($uid, $page, $size);
$messages = UserModel::getMessageData($uid, $page, $size);
print_r($messages);
}
... ... @@ -184,8 +187,8 @@ class HomeController extends AbstractAction
$this->setNavHeader('地址管理');
$uid = $this->getUid();
$address = \Index\UserModel::getAddressData($uid);
$addressList = \Index\UserModel::getAddressListData($uid);
$address = UserModel::getAddressData($uid);
$addressList = UserModel::getAddressListData($uid);
$this->_view->display('address', array(
'addressPage' => true,
... ... @@ -212,7 +215,7 @@ class HomeController extends AbstractAction
$mobile = $this->post('mobile', '');
$zip_code = $this->post('zip_code', '');
$result = \Index\UserModel::saveAddressData($uid, $address, $area_code, $consignee, $email, $id, $mobile, $zip_code);
$result = UserModel::saveAddressData($uid, $address, $area_code, $consignee, $email, $id, $mobile, $zip_code);
}
if (empty($result)) {
... ... @@ -232,7 +235,7 @@ class HomeController extends AbstractAction
if ($this->isAjax()) {
$uid = $this->getUid();
$id = $this->post('id', '');
$result = \Index\UserModel::setDefaultAddress($uid, $id);
$result = UserModel::setDefaultAddress($uid, $id);
}
if (empty($result)) {
... ... @@ -253,7 +256,7 @@ class HomeController extends AbstractAction
$uid = $this->getUid();
$id = $this->post('id', '');
$result = \Index\UserModel::deleteAddress($uid, $id);
$result = UserModel::deleteAddress($uid, $id);
}
if (empty($result)) {
... ... @@ -330,7 +333,7 @@ class HomeController extends AbstractAction
$page = $this->get('page', 1);
$limit = $this->get('limit', 30);
$suggest = \Index\UserModel::getSuggestData($udid, $page, $limit);
$suggest = UserModel::getSuggestData($udid, $page, $limit);
$this->_view->display('suggest', array(
'suggestPage' => true, //加载js
... ... @@ -368,7 +371,7 @@ class HomeController extends AbstractAction
public function suggestimgUploadAction()
{
//$filename = $this->post('filename', '');
$result = \Index\UserModel::saveSuggestImg('fileData');
$result = UserModel::saveSuggestImg('fileData');
$this->echoJson($result);
}
... ... @@ -383,7 +386,7 @@ class HomeController extends AbstractAction
$content = $this->post('content', '');
$suggest_type = $this->post('suggest_type', 2);
$image = $this->post('image', null);
$result = \Index\UserModel::saveSuggestData($uid, $content, $image, $suggest_type);
$result = UserModel::saveSuggestData($uid, $content, $image, $suggest_type);
$this->echoJson($result);
}
... ... @@ -398,7 +401,7 @@ class HomeController extends AbstractAction
$uid = $this->getUid();
$udid = $this->getUdid();
$suggest_id = $this->post('suggest_id', 0);
$result = \Index\UserModel::upAndDown($uid, $udid, $suggest_id);
$result = UserModel::upAndDown($uid, $udid, $suggest_id);
$this->echoJson($result);
}
... ... @@ -417,7 +420,7 @@ class HomeController extends AbstractAction
$gender = Helpers::getGenderByCookie();
$channel = Helpers::getChannelByCookie();
$uid = $this->getUid();
$data = \Home\GradeModel::getGrade($gender, $channel, $uid);
$data = GradeModel::getGrade($gender, $channel, $uid);
$data['pageFooter'] = true;
$this->_view->display('vip-grade', $data);
}
... ... @@ -434,7 +437,7 @@ class HomeController extends AbstractAction
$channel = Helpers::getChannelByCookie();
$uid = $this->getUid();
$data = \Home\GradeModel::getPreferential($channel, $uid);
$data = GradeModel::getPreferential($channel, $uid);
$data['pageFooter'] = true;
$this->_view->display('privilege', $data);
... ... @@ -449,7 +452,7 @@ class HomeController extends AbstractAction
$type = $this->get('type', 1);
$this->setTitle('我的订单');
$this->setNavHeader('我的订单');
$data = \Home\OrderModel::getNavs($type);
$data = OrderModel::getNavs($type);
if (!empty($data)) {
$order['navs'] = $data;
} else {
... ... @@ -478,7 +481,7 @@ class HomeController extends AbstractAction
$yh_channel = $this->get('yh_channel', 1);
$uid = $this->getUid();
//调用模型层getOrder方法获得并处理数据
$data = \Home\OrderModel::getOrder($type, $page, $limit, $gender, $yh_channel, $uid);
$data = OrderModel::getOrder($type, $page, $limit, $gender, $yh_channel, $uid);
/* 如果取不到订单数据时,分两种情况:
1、page>1时,echo一个空格字符串到浏览器。
2、page=1时,就给一个随便逛逛的链接。
... ... @@ -515,7 +518,7 @@ class HomeController extends AbstractAction
$yh_channel = $this->get('yh_channel', 1);
$method = 'app.SpaceOrders.close';
//调用取消订单接口,返回订单取消状态
$data = \Home\OrderData::cancelOrderData($order_code, $uid, $gender, $yh_channel, $method);
$data = OrderData::cancelOrderData($order_code, $uid, $gender, $yh_channel, $method);
//将取消状态返回至浏览器
$this->echoJson($data);
}
... ... @@ -537,7 +540,7 @@ class HomeController extends AbstractAction
$yh_channel = $this->get('yh_channel', 1);
$method = 'app.SpaceOrders.delOrderByCode';
//调用接口删除订单,并返回订单删除状态
$data = \Home\OrderData::deleteOrderData($order_code, $uid, $gender, $yh_channel, $method);
$data = OrderData::deleteOrderData($order_code, $uid, $gender, $yh_channel, $method);
//将订单删除状态返回至浏览器
$this->echoJson($data);
}
... ... @@ -550,7 +553,7 @@ class HomeController extends AbstractAction
{
$gender = Helpers::getGenderByCookie();
$yh_channel = $this->get('yh_channel', 1);
\Home\OrderModel::payment($gender, $yh_channel);
OrderModel::payment($gender, $yh_channel);
}
/*
... ... @@ -563,7 +566,7 @@ class HomeController extends AbstractAction
$gender = Helpers::getGenderByCookie();
$yh_channel = $this->get('yh_channel', 1);
//调用接口获取随便逛逛url地址,并return数据
$data = \Home\OrderModel::stroll($gender, $yh_channel);
$data = OrderModel::stroll($gender, $yh_channel);
return $data;
}
... ...
... ... @@ -2,7 +2,9 @@
namespace Home;
use Configs\CacheConfig;
use LibModels\Wap\Home\GradeData;
use Plugin\Cache;
use Plugin\Helpers;
/**
... ... @@ -13,105 +15,104 @@ class GradeModel
/*
* 获取个人中心-会员等级数据
*/
public static 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);
if (!empty($data['grade'])) {
switch (intval($data['grade']['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['grade']['current_year_cost'];
//升级下一等级会员的进度;
$result['vipGrade']['percent'] = 100 * (round($data['grade']['current_total_cost'] / $data['grade']['next_need_cost'], 2));
//距离升级所需消费金额
if ($data['grade']['current_vip_level'] != 3) {
$result['vipGrade']['costGap'] = $data['grade']['upgrade_need_cost'];
}
//消费总计
$result['vipGrade']['sumCost'] = $data['grade']['current_total_cost'];
//username 调用获取用户基本信息数据,获得username;
//$userProfile = GradeData::getUserProfileData($gender,$uid,$channel);
$result['vipGrade']['name'] = $data['userProfile']['username'];
//跳转url(会员特权详情)
$result['vipGrade']['allUrl'] = Helpers::url('/Home/preferential', null);
//当前vip等级享受的特权
$result['vipGrade']['privilege'] = $data['grade']['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 static 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($channel, $uid);
if (!empty($data['grade'])) {
switch (intval($data['grade']['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['grade']['current_year_cost'];
//升级下一等级会员的进度;
$result['vipGrade']['percent'] = 100 * (round($data['grade']['current_total_cost'] / $data['grade']['next_need_cost'], 2));
//距离升级所需消费金额
if ($data['grade']['current_vip_level'] != 3) {
$result['vipGrade']['costGap'] = $data['grade']['upgrade_need_cost'];
}
//消费总计
$result['vipGrade']['sumCost'] = $data['grade']['current_total_cost'];
//username 调用获取用户基本信息数据,获得username;
//$userProfile = GradeData::getUserProfileData($gender,$uid,$channel);
$result['vipGrade']['name'] = !empty($data['userProfile']) ? $data['userProfile']['username'] : '';
//跳转url(会员特权详情)
$result['vipGrade']['allUrl'] = Helpers::url('/Home/preferential', null);
//当前vip等级享受的特权
$result['vipGrade']['privilege'] = $data['grade']['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;
}
public static 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;
}
}
... ...
... ... @@ -2,7 +2,9 @@
namespace Index;
use Configs\CacheConfig;
use LibModels\Wap\Home\UserData;
use Plugin\Cache;
use Plugin\Helpers;
use Plugin\Images;
... ...