Authored by yangyang

修改了会员等级接口并调试

... ... @@ -27,8 +27,8 @@ class Yohobuy
const API_URL = 'http://test2.open.yohobuy.com/';
const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const YOHOBUY_ORDER = 'http://192.168.102.209:8080/yoho-order/';
const API_URL_MYCENTER = 'http://192.168.102.209:8080/yoho-users-web/'; // 我的个人中心接口URL
const YOHOBUY_ORDER = 'http://192.168.102.209:8080/yoho-order/'; //我的订单
const API_URL_MYCENTER = 'http://192.168.102.213:8081/yoho-users-web/'; // 我的个人中心接口URL
const API_URL_SHOPINGCART = 'http://192.168.102.213:8080/api-gateway-web/'; // 我的购物车接口URL
const API_URL_PRODUCTDETAIL = 'http://192.168.102.209:18080/yoho-product/'; // 商品详情页
... ...
... ... @@ -18,24 +18,10 @@ class GradeData
* @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);
public static function getGradeData($uid) {
//获取会员等级数据
$param['uid'] = $uid;
return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER.'UserVipRest/getVipDetailInfo', $param);
}
/**
... ... @@ -44,14 +30,9 @@ class GradeData
* @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);
public static function getPreferentialData() {
return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER.'UserVipRest/getPrivilege');
}
}
... ...
... ... @@ -24,27 +24,14 @@ class OrderData
* and open the template in the editor.
*/
static function getOrderData($type, $page, $limit, $gender, $yh_channel, $uid) {
//构建必传参数
// $param = Yohobuy::param();
// $param['gender'] = $gender;
// $param['limit'] = $limit;
// $param['method'] = 'app.SpaceOrders.get';
// $param['page'] = $page;
// $param['type'] = $type;
// $param['uid'] = $uid;
// $param['yh_channel'] = $yh_channel;
// $param['client_secret'] = Sign::getSign($param);
// //调用接口获得数据
// return Yohobuy::get(Yohobuy::API_URL, $param);
static function getOrderData($type, $page, $limit, $uid) {
$param['limit'] = '10';
$param['page'] = 1;
$param['type'] = 1;
$param['uid'] = '12';
$param['iscancel'] = false;
$param['paymentStatus'] = 'Y';
print_r($param);
var_dump(Yohobuy::jsonPost(Yohobuy::YOHOBUY_ORDER.'orderInfo/getOrderList',$param));
// $param['iscancel'] = false;
// $param['paymentStatus'] = 'Y';
return Yohobuy::jsonPost(Yohobuy::YOHOBUY_ORDER.'orderInfo/getOrderList',$param);
}
/*
... ...
... ... @@ -437,10 +437,7 @@ class HomeController extends AbstractAction
$this->setTitle('会员等级');
//显示网站导航头部信息
$this->setNavHeader('会员特权详情');
$channel = Helpers::getChannelByCookie();
$uid = $this->getUid();
$data = GradeModel::getPreferential($channel, $uid);
$data = GradeModel::getPreferential();
$data['pageFooter'] = true;
$this->_view->display('privilege', $data);
... ... @@ -480,11 +477,9 @@ class HomeController extends AbstractAction
$type = $this->get('type', 1);
$page = $this->get('page', 1);
$limit = $this->get('limit', 10);
$gender = Helpers::getGenderByCookie();
$yh_channel = $this->get('yh_channel', 1);
$uid = $this->getUid();
//调用模型层getOrder方法获得并处理数据
$data = OrderModel::getOrder($type, $page, $limit, $gender, $yh_channel, $uid);
$data = OrderModel::getOrder($type, $page, $limit, $uid);
/* 如果取不到订单数据时,分两种情况:
1、page>1时,echo一个空格字符串到浏览器。
2、page=1时,就给一个随便逛逛的链接。
... ...
... ... @@ -29,9 +29,8 @@ class GradeModel
}
//调用接口获取数据
$data = GradeData::getGradeData($uid);
print_r($data);
if (!empty($data['grade'])) {
switch (intval($data['grade']['current_vip_level'])) {
if (!empty($data['curVipInfo'])) {
switch (intval($data['curVipInfo']['curLevel'])) {
case 0://普通会员
$result['vipGrade']['vip0'] = true;
break;
... ... @@ -47,23 +46,23 @@ class GradeModel
}
//今年总消费
$result['vipGrade']['costOfThisYear'] = $data['grade']['current_year_cost'];
$result['vipGrade']['costOfThisYear'] = $data['costInfo']['yearTotal'];
//升级下一等级会员的进度;
$result['vipGrade']['percent'] = 100 * (round($data['grade']['current_total_cost'] / $data['grade']['next_need_cost'], 2));
$result['vipGrade']['percent'] = 100 * (round($data['costInfo']['total'] / $data['nextVipInfo']['needCost'], 2));
//距离升级所需消费金额
if ($data['grade']['current_vip_level'] != 3) {
$result['vipGrade']['costGap'] = $data['grade']['upgrade_need_cost'];
if ($data['curVipInfo']['curLevel'] != 3) {
$result['vipGrade']['costGap'] = $data['nextVipInfo']['needCost'];
}
//消费总计
$result['vipGrade']['sumCost'] = $data['grade']['current_total_cost'];
$result['vipGrade']['sumCost'] = $data['costInfo']['total'];
//username 调用获取用户基本信息数据,获得username;
//$userProfile = GradeData::getUserProfileData($gender,$uid,$channel);
$result['vipGrade']['name'] = $data['userProfile']['username'];
$result['vipGrade']['name'] = '杨阳';
//跳转url(会员特权详情)
$result['vipGrade']['allUrl'] = Helpers::url('/Home/preferential', null);
//当前vip等级享受的特权
$result['vipGrade']['privilege'] = $data['grade']['enjoy_preferential'];
$result['vipGrade']['privilege'] = $data['curVipInfo']['premiumScop'];
}
if (USE_CACHE) {
... ... @@ -84,7 +83,7 @@ class GradeModel
* 获取个人中心-会员特权详情页
*/
public static function getPreferential($channel, $uid)
public static function getPreferential()
{
$result = array();
... ... @@ -96,9 +95,9 @@ class GradeModel
}
}
//调取接口获得数据
$data = GradeData::getPreferentialData($channel, $uid);
if (isset($data['code']) && $data['code'] == 200) {
$result['vipGrade']['privilege'] = $data['data'];
$data = GradeData::getPreferentialData();
if (!empty($data)){
$result['vipGrade']['privilege'] = $data;
}
... ...
... ... @@ -28,7 +28,7 @@ class OrderModel
* 订单相关数据处理
*/
static function getOrder($type = 1, $page = 1, $limit, $gender, $yh_channel, $uid) {
static function getOrder($type, $page, $limit, $uid) {
$result = array();
if (USE_CACHE) {
$key = CacheConfig::KEY_ACTION_HOME_ORDER_ORDER;
... ... @@ -39,66 +39,29 @@ class OrderModel
}
}
//调用接口获得数据
$data = OrderData::getOrderData($type, $page, $limit, $gender, $yh_channel, $uid);
$data = OrderData::getOrderData($type, $page, $limit, $uid);
print_r($data);
//检查数据返回是否正常,正常则处理数据
if ($data['code'] == 200 && isset($data['data'])) {
foreach ($data['data']['order_list'] as $key => $vo) {
//订单号,支付状态,订单商品数量,订单总价格(订单总价加上运费)
$result[$key]['orderNum'] = $vo['order_code'];
$result[$key]['orderStatus'] = $vo['status_str'];
$result[$key]['count'] = count($vo['order_goods']);
$result[$key]['sumCost'] = $vo['amount'] + $vo['shipping_cost'];
//类内调用格式化订单商品数据方法
$result[$key]['goods'] = self::formatOrderGoods($vo['order_goods']);
//根据订单status判断订单处于什么状态。
do {
//订单取消状态 = Y 时,跳出判断订单状态循环,并设置订单状态为已取消。
if ($vo['is_cancel'] === 'Y') {
$result[$key]['canceled'] = true;
break;
}
/* 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)
* 付款方式:1 => 在线支付,2 => 货到付款,3 => 现金支付,4 => 抵消支付;
*/
//支付方式为非货到付款时,计算订单状态。
if ($vo['payment_type'] != 2) {
switch ($vo['status']) {
case 0:
$result[$key]['unpaid'] = true;
break;
//未发货&未收货 状态,统一合并到待收货状态。
case 1:
case 2:
case 3:
case 4:
case 5:
$result[$key]['unreceived'] = true;
//待收货状态,给查看物流url
$result[$key]['logisticsUrl'] = "暂无logisticsUrl数据";
break;
case 6:
$result[$key]['completed'] = true;
break;
default:
break;
}
} elseif ($vo['payment_type'] == 2) {
//订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态)
switch ($vo['status']) {
case 0 || 1 || 2 || 3 || 4 || 5:
$result[$key]['unreceived'] = true;
//待收货状态,给查看物流url
$resault[$key]['logisticsUrl'] = "备注:暂无logisticsUrl数据";
break;
case 6:
$result[$key]['completed'] = true;
break;
default:
break;
}
}
} while (false);
}
if (!empty($data[0])) {
$result = array();
foreach($data as $key => $vo){
$result[$key]['detailUrl'] = $vo[''];
$result[$key]['orderNum'] = $vo['orderCode'];
$result[$key]['orderStatus'] = $vo['status'];
$result[$key]['count'] = count($vo['ordersGoodsList']);
$result[$key]['sumCost'] = $vo['amount'];
$result[$key]['sumCost'] = $vo['amount'];
switch ($vo['status']) {
case 1:
$result[$key]['sumCost'] = $vo['amount'];
break;
default:
break;
}
$result[$key]['sumCost'] = $vo['amount'];
}
}
if (USE_CACHE) {
... ...