Authored by Rock Zhang

修复等级信息中的bug,修复取消收藏商品的bug

... ... @@ -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);
... ...
<?php
use Action\AbstractAction;
use home\GradeModel;
use Home\GradeModel;
use home\OrderModel;
use Plugin\Helpers;
use LibModels\Wap\Home\OrderData;
use Index\UserModel as UserModel;
/**
* 个人中心相关的控制器
... ... @@ -51,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);
... ... @@ -75,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
... ... @@ -106,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)) {
... ... @@ -125,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);
... ... @@ -140,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);
... ... @@ -156,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);
... ... @@ -171,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);
}
... ... @@ -186,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,
... ... @@ -214,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)) {
... ... @@ -234,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)) {
... ... @@ -255,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)) {
... ... @@ -332,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
... ... @@ -370,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);
}
... ... @@ -385,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);
}
... ... @@ -400,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);
}
... ...
... ... @@ -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;
... ...