Authored by hf

do order detail call api render template

... ... @@ -31,9 +31,10 @@ class AbstractAction extends Controller_Abstract
/**
* 用户相关信息
*/
protected $_vip;
protected $_uid = 0;
protected $_uname = '';
protected $_vip;
protected $_usession = '';
protected $_useSession = true;
/**
... ... @@ -299,7 +300,7 @@ class AbstractAction extends Controller_Abstract
$useSession = false;
}
$useSession = false;
if (!$this->_uid) {
$cookie = $this->getCookie('_UID');
if (!empty($cookie)) {
... ... @@ -317,6 +318,7 @@ class AbstractAction extends Controller_Abstract
$this->_uid = $cookieList[1];
}
$this->_uname = $cookieList[0];
$this->_usession = $cookieList[3];
$this->_vip = $cookieList[2];
}
}
... ... @@ -419,7 +421,7 @@ class AbstractAction extends Controller_Abstract
// 默认使用男生的头部
$header['boys'] = true;
$controller = $this->getRequest()->getControllerName();
if ($controller !== 'Home') {
// 根据COOKIE记录的频道进行导航定位
... ...
... ... @@ -91,7 +91,7 @@ class Yohobuy
{
$clientType = self::clientType();
$param = array(
'app_version' => '3.6',
'app_version' => '3.8.2',
'client_type' => $clientType,
'os_version' => 'yohobuy:h5',
'private_key' => self::$privateKeyList[$clientType],
... ...
... ... @@ -6,19 +6,15 @@ use Api\Yohobuy;
use Api\Sign;
/**
* Description of OrderData
*
* @author Administrator
* 订单相关的数据模型
*
*/
class OrderData
{
/*
* 获取订单数据
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public static function getOrderData($type, $page, $limit, $gender, $yh_channel, $uid)
public static function getOrderData($type, $page, $limit, $gender, $channel, $uid)
{
//构建必传参数
$param = Yohobuy::param();
... ... @@ -28,7 +24,7 @@ class OrderData
$param['page'] = $page;
$param['type'] = $type;
$param['uid'] = $uid;
$param['yh_channel'] = $yh_channel;
$param['yh_channel'] = $channel;
$param['client_secret'] = Sign::getSign($param);
//调用接口获得数据
return Yohobuy::get(Yohobuy::API_URL, $param);
... ... @@ -36,18 +32,15 @@ class OrderData
/*
* 取消订单
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public static function cancelOrderData($order_code, $uid, $gender, $yh_channel)
public static function cancelOrderData($orderCode, $uid, $gender, $channel)
{
//构建必传参数
$param = Yohobuy::param();
$param['order_code'] = $order_code;
$param['order_code'] = $orderCode;
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['yh_channel'] = $yh_channel;
$param['yh_channel'] = $channel;
$param['method'] = 'app.SpaceOrders.close';
$param['client_secret'] = Sign::getSign($param);
//调用接口获得数据
... ... @@ -56,22 +49,40 @@ class OrderData
/*
* 删除订单
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public static function deleteOrderData($order_code, $uid, $gender, $yh_channel)
public static function deleteOrderData($orderCode, $uid, $gender, $channel)
{
//构建必传参数
$param = Yohobuy::param();
$param['order_code'] = $order_code;
$param['order_code'] = $orderCode;
$param['uid'] = $uid;
$param['gender'] = $gender;
$param['yh_channel'] = $yh_channel;
$param['yh_channel'] = $channel;
$param['method'] = 'app.SpaceOrders.delOrderByCode';
$param['client_secret'] = Sign::getSign($param);
//调用接口删除订单
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 查看订单详情
*
* @param string $orderCode 订单号
* @param int $uid 用户ID
* @param string $sessionKey 用户会话
* @return array
*/
public static function viewOrderData($orderCode, $uid, $sessionKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.SpaceOrders.info';
$param['order_code'] = $orderCode;
$param['uid'] = $uid;
$param['session_key'] = $sessionKey;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/*
* 我的订单-查看物流
... ...
... ... @@ -215,9 +215,9 @@ class Helpers
$result['salePrice'] && $result['salePrice'] .= '.00';
}
$result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y');
$result['url'] = SITE_MAIN . '/product/pro_' . $productData['product_id'] . '_'
$result['url'] = self::url('/product/pro_' . $productData['product_id'] . '_'
. $productData['goods_list'][0]['goods_id']
. '/' . $productData['cn_alphabet'] . '.html';
. '/' . $productData['cn_alphabet'] . '.html');
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if ($isApp) {
... ... @@ -498,10 +498,15 @@ class Helpers
/**
* 格式化订单商品
*
* @param array $orderGoods 订单
* @param int $count 计订单件数
* @param bool $haveLink 控制是否需要商品链接
*/
public static function formatOrderGoods($orderGoods, &$count = 0)
public static function formatOrderGoods($orderGoods, &$count = 0, $haveLink = false)
{
$arr = array();
foreach ($orderGoods as $key => $vo) {
$arr[$key]['thumb'] = Helpers::getImageUrl($vo['goods_image'], 90, 120);
$arr[$key]['name'] = $vo['product_name'];
... ... @@ -519,9 +524,14 @@ class Helpers
if (!empty($vo['expect_arrival_time'])) {
$arr[$key]['appearDate'] = $vo['expect_arrival_time'];
}
// 商品链接
if ($haveLink && isset($vo['product_id'])) {
$arr[$key]['link'] = self::url('/product/pro_' . $vo['product_id'] . '_' . $vo['goods_id'] . '/' . $vo['cn_alphabet'] . '.html');
}
// 累计购买数
$count += intval($vo['buy_number']);
}
return $arr;
}
... ...
... ... @@ -25,6 +25,7 @@
</p>
</div>
{{#if unreceived}}
{{#if logisticsUrl}}
<a class="logistics sub" href="{{logisticsUrl}}">
<span class="iconfont">&#xe630;</span>
<p class="beside-icon sub-content">
... ... @@ -34,6 +35,7 @@
</p>
<span class="iconfont icon-right">&#xe614;</span>
</a>
{{/if}}
{{/if}}
</section>
... ... @@ -46,23 +48,27 @@
<ul class="cost block">
<li>
商品总金额
<span>¥{{sumPrice}}</span>
<span>{{sumPrice}}</span>
</li>
<li>
活动金额
<span>{{salePrice}}</span>
<span>{{salePrice}}</span>
</li>
<li>
运费
<span>+¥{{freight}}</span>
<span>{{freight}}</span>
</li>
<li>
优惠券
<span>{{coupon}}</span>
</li>
<li>
YOHO币
<span>{{yohoCoin}}</span>
<span>{{yohoCoin}}</span>
</li>
<li>
实付金额
<span>¥{{price}}</span>
<span>{{price}}</span>
</li>
</ul>
... ... @@ -75,9 +81,11 @@
{{#if unpaid}}
<span class="btn btn-cancel">取消订单</span>
{{#if payUrl}}
<a href="{{payUrl}}">
<span class="btn btn-pay">立即付款</span>
</a>
{{/if}}
{{/if}}
{{#if unreceived}}
... ...
<div class="order-good" data-id="{{id}}">
<div class="thumb-wrap">
<img class="thumb lazy" data-original="{{thumb}}">
<p class="tag{{#if gift}} gift-tag{{/if}}{{#if advanceBuy}} advance-buy-tag{{/if}}"></p>
{{#if link}}
<a href="{{link}}"><img class="thumb lazy" data-original="{{thumb}}"></a>
{{else}}
<img class="thumb lazy" data-original="{{thumb}}">
{{/if}}
<p class="tag{{#if gift}} gift-tag{{/if}}{{#if advanceBuy}} advance-buy-tag{{/if}}"></p>
</div>
<div class="deps">
<p class="name row">{{name}}</p>
... ...
... ... @@ -71,7 +71,7 @@ class ChristmasController extends HuodongAction
private function getLoggedUid()
{
// 判断是否是应用访问, 拼接APP需要的URL参数
$this->_isApp = null !== $this->get('app_version');
$this->_isApp = (null !== $this->get('app_version') || null !== $this->get('uid'));
$uid = false;
if ($this->_isApp) {
$uid = $this->get('uid');
... ...
... ... @@ -48,7 +48,7 @@ class HomeController extends AbstractAction
'showDownloadApp' => true,
'pageFooter' => true,
'cartUrl' => Helpers::url('/cart/index/index', null),
'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home')) ),
'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home'))),
);
$uid = $this->getUid(false);
if ($uid) {
... ... @@ -781,14 +781,14 @@ class HomeController extends AbstractAction
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('支付中心');
$this->setNavHeader('支付中心');
$orderCode = $this->get('order_code');
if (empty($orderCode)) {
$this->error();
}
$this->setTitle('支付中心');
$this->setNavHeader('支付中心');
$this->_view->display('pay', array(
'payCenterPage' => true,
'payAppInfo' => array(
... ... @@ -814,61 +814,26 @@ class HomeController extends AbstractAction
));
}
// /*
// * 我的订单-确认收货
// */
// private function confirmAction(){
// //
// $gender = Helpers::getGenderByCookie();
// $order_code = $this->get('id');
// $order_code = '';
// $yh_channel = $this->get('yh_channel', 1);
// $data = OrderData::confirmData($gender,$order_code,$yh_channel,$this->_uid);
// $this->echoJson($data);
// }
/**
* 订单详情页
*/
public function orderDetailAction()
{
$data = array(
'name' => '毛毛莉Lydia',
'phoneNum' => '18600001133',
'address' => '南京市建邺区嘉陵江东街18号国家广告产业园5栋17楼',
'orderStatus' => '订单取消',
'orderNum' => '418358063',
'orderTime' => '2014-03-10 17:25:10',
'orderCancel' => true,
'goods' => array(
array(
'id' => 1,
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => 'Adidas Originals ZX FLUXM22508',
'color' => '黄',
'size' => '43',
'price' => '699.00',
'count' => '2'
),
array(
'id' => 1,
'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
'name' => 'B.Duck浴室玩伴mini浮水鸭',
'gift' => true,
'color' => '黄',
'size' => '43',
'price' => '0.00',
'count' => '1'
)
),
'sumPrice' => 799,
'salePrice' => 80,
'freight' => 5,
'coupon' => 0,
'yohoCoin' => 5,
'price' => 719
);
$this->_view->display('order-detail', array('orderDetail' => $data, 'orderDetailPage' => true));
// 审判跳转登录页
$this->auditJumpLogin();
$orderCode = $this->get('order_code', 1507880870);
if (empty($orderCode)) {
$this->error();
}
$this->setTitle('订单详情');
$this->setNavHeader('订单详情');
$this->_view->display('order-detail', array(
'orderDetailPage' => true,
'orderDetail' => OrderModel::orderDetail($orderCode, 967016/*$this->_uid*/, 'a3aadd4cce408f8ee062a9add02e8faa'/*$this->_session*/),
));
}
// /**
... ...
... ... @@ -68,86 +68,20 @@ class OrderModel
}
//检查数据返回是否正常,正常则处理数据
if (!empty($data['data']['order_list'])) {
// 订单的状态列表
//$orderStatus = Helpers::getOrderStatus();
$count = 0;
foreach ($data['data']['order_list'] as $key => $vo) {
// if ($vo['payment_status'] == 'Y' && $vo['status'] == 0) {
// $vo['status'] = 1;
// }
// 订单件数清零
$count = 0;
//根据订单status判断订单处于什么状态。
$result[$key] = self::getOrderStatus($vo);
//订单号,支付状态,订单商品数量,订单总价格
$result[$key]['orderNum'] = $vo['order_code'];
//$result[$key]['orderStatus'] = ($vo['is_cancel'] === 'Y') ? '已取消' : $orderStatus[ $vo['payment_type'] ][ $vo['status'] ];
$result[$key]['orderStatus'] = $vo['status_str'];
$result[$key]['sumCost'] = $vo['amount'];
//类内调用格式化订单商品数据方法
$result[$key]['goods'] = Helpers::formatOrderGoods($vo['order_goods'], $count);
$result[$key]['goods'] = Helpers::formatOrderGoods($vo['order_goods'], $count);
$result[$key]['detailUrl'] = Helpers::url('/home/orders/detail', array('order_code' => $vo['order_code'], 't' => time()));
$result[$key]['count'] = $count;
//根据订单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;
$result[$key]['payUrl'] = Helpers::url('/home/pay', array('order_code' => $vo['order_code']));
break;
//未发货&未收货 状态,统一合并到待收货状态。
case 1:
case 2:
case 3:
//已付款状态不给查看物流URL
$result[$key]['unreceived'] = true;
break;
case 4:
case 5:
//已发货状态,给查看物流URL
$result[$key]['unreceived'] = true;
$result[$key]['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $vo['order_code']));
break;
case 6:
$result[$key]['completed'] = true;
break;
default:
break;
}
break;
}
//订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态)
switch ($vo['status']) {
case 0: // 备货中
$result[$key]['unpaid'] = true;
break;
case 1:
case 2:
case 3:
//备货中、已付款状态不给查看物流链接
$result[$key]['unreceived'] = true;
break;
case 4:
case 5:
//待收货状态,给查看物流url
$result[$key]['unreceived'] = true;
$result[$key]['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $vo['order_code']));
break;
case 6:
$result[$key]['completed'] = true;
break;
default:
break;
}
} while (false);
}
}
... ... @@ -155,16 +89,6 @@ class OrderModel
}
/**
* 获得支付链接
*/
public static function payment($gender, $yh_channel)
{
$code = self::CODE_PAYMENT;
$data = OrderData::paymentData($gender, $yh_channel, $code);
return $data;
}
/**
* 查看物流
*
* @param int $orderCode 订单编号
... ... @@ -196,6 +120,43 @@ class OrderModel
}
/**
* 获取订单详情信息
*
* @param string $orderCode 订单号
* @param int $uid 用户ID
* @param string $sessionKey 用户的会话
* @return array
*/
public static function orderDetail($orderCode, $uid, $sessionKey)
{
$result = array();
if (is_numeric($orderCode) && is_numeric($uid) && is_string($sessionKey)) {
$orderDetail = OrderData::viewOrderData($orderCode, $uid, $sessionKey);
if (isset($orderDetail['data']['order_code'])) {
$count = 0;
$result = self::getOrderStatus($orderDetail['data'], true); // 订单状态
$result['name'] = $orderDetail['data']['user_name'];
$result['phoneNum'] = $orderDetail['data']['mobile'];
$result['address'] = $orderDetail['data']['area'] . $orderDetail['data']['address'];
$result['orderStatus'] = $orderDetail['data']['status_str'];
$result['orderNum'] = $orderDetail['data']['order_code'];
$result['orderTime'] = date('Y-m-d H:i:s', $orderDetail['data']['create_time']);
$result['goods'] = Helpers::formatOrderGoods($orderDetail['data']['order_goods'], $count, true);
$result['sumPrice'] = $orderDetail['data']['goods_total_amount']; // 商品总金额
$result['salePrice'] = $orderDetail['data']['promotion_amount']; // 活动金额
$result['freight'] = $orderDetail['data']['shipping_cost']; // 运费
$result['coupon'] = $orderDetail['data']['coupons_amount']; // 优惠券
$result['yohoCoin'] = $orderDetail['data']['yoho_coin_num']; // YOHO币
$result['price'] = $orderDetail['data']['amount']; // 实付金额
}
}
return $result;
}
/**
* 根据type值设置nav属性
*/
public static function getNavs($type)
... ... @@ -218,4 +179,89 @@ class OrderModel
return $nav;
}
/**
* 获取订单状态
*
* @param array $order 订单
* @param bool $showLogistics 控制是否显示物流信息
* @return array
*/
private static function getOrderStatus($order, $showLogistics = false)
{
$result = array();
//根据订单status判断订单处于什么状态。
do {
//订单取消状态 = Y 时,跳出判断订单状态循环,并设置订单状态为已取消。
if ($order['is_cancel'] === 'Y') {
$result['canceled'] = true;
break;
}
// 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)
// 支付方式为非货到付款时,计算订单状态。
if ($order['payment_type'] != 2) {
switch ($order['status']) {
case 0: // 待付款
$result['unpaid'] = true;
$result['payUrl'] = Helpers::url('/home/pay', array('order_code' => $order['order_code']));
break;
//未发货&未收货 状态,统一合并到待收货状态。
case 1:
case 2:
case 3:
//已付款状态不给查看物流URL
$result['unreceived'] = true;
break;
case 4:
case 5:
//已发货状态,给查看物流URL
$result['unreceived'] = true;
$result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
if ($showLogistics) {
$result['logisticsCompany'] = $order['caption'];
$result['logisticsNum'] = $order['express_number'];
}
break;
case 6:
$result['completed'] = true;
break;
default:
break;
}
break;
}
// 订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态)
switch ($order['status']) {
case 0: // 备货中
$result['unpaid'] = true;
break;
case 1:
case 2:
case 3:
//备货中、已付款状态不给查看物流链接
$result['unreceived'] = true;
break;
case 4:
case 5:
//待收货状态,给查看物流url
$result['unreceived'] = true;
$result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
if ($showLogistics) {
$result['logisticsCompany'] = isset($order['caption']) ? $order['caption'] : '';
$result['logisticsNum'] = isset($order['express_number']) ? $order['express_number'] : '';
}
break;
case 6:
$result['completed'] = true;
break;
default:
break;
}
} while (false);
return $result;
}
}
... ...