Authored by hf

do order detail call api render template

@@ -31,9 +31,10 @@ class AbstractAction extends Controller_Abstract @@ -31,9 +31,10 @@ class AbstractAction extends Controller_Abstract
31 /** 31 /**
32 * 用户相关信息 32 * 用户相关信息
33 */ 33 */
  34 + protected $_vip;
34 protected $_uid = 0; 35 protected $_uid = 0;
35 protected $_uname = ''; 36 protected $_uname = '';
36 - protected $_vip; 37 + protected $_usession = '';
37 protected $_useSession = true; 38 protected $_useSession = true;
38 39
39 /** 40 /**
@@ -299,7 +300,7 @@ class AbstractAction extends Controller_Abstract @@ -299,7 +300,7 @@ class AbstractAction extends Controller_Abstract
299 $useSession = false; 300 $useSession = false;
300 } 301 }
301 $useSession = false; 302 $useSession = false;
302 - 303 +
303 if (!$this->_uid) { 304 if (!$this->_uid) {
304 $cookie = $this->getCookie('_UID'); 305 $cookie = $this->getCookie('_UID');
305 if (!empty($cookie)) { 306 if (!empty($cookie)) {
@@ -317,6 +318,7 @@ class AbstractAction extends Controller_Abstract @@ -317,6 +318,7 @@ class AbstractAction extends Controller_Abstract
317 $this->_uid = $cookieList[1]; 318 $this->_uid = $cookieList[1];
318 } 319 }
319 $this->_uname = $cookieList[0]; 320 $this->_uname = $cookieList[0];
  321 + $this->_usession = $cookieList[3];
320 $this->_vip = $cookieList[2]; 322 $this->_vip = $cookieList[2];
321 } 323 }
322 } 324 }
@@ -419,7 +421,7 @@ class AbstractAction extends Controller_Abstract @@ -419,7 +421,7 @@ class AbstractAction extends Controller_Abstract
419 421
420 // 默认使用男生的头部 422 // 默认使用男生的头部
421 $header['boys'] = true; 423 $header['boys'] = true;
422 - 424 +
423 $controller = $this->getRequest()->getControllerName(); 425 $controller = $this->getRequest()->getControllerName();
424 if ($controller !== 'Home') { 426 if ($controller !== 'Home') {
425 // 根据COOKIE记录的频道进行导航定位 427 // 根据COOKIE记录的频道进行导航定位
@@ -91,7 +91,7 @@ class Yohobuy @@ -91,7 +91,7 @@ class Yohobuy
91 { 91 {
92 $clientType = self::clientType(); 92 $clientType = self::clientType();
93 $param = array( 93 $param = array(
94 - 'app_version' => '3.6', 94 + 'app_version' => '3.8.2',
95 'client_type' => $clientType, 95 'client_type' => $clientType,
96 'os_version' => 'yohobuy:h5', 96 'os_version' => 'yohobuy:h5',
97 'private_key' => self::$privateKeyList[$clientType], 97 'private_key' => self::$privateKeyList[$clientType],
@@ -6,19 +6,15 @@ use Api\Yohobuy; @@ -6,19 +6,15 @@ use Api\Yohobuy;
6 use Api\Sign; 6 use Api\Sign;
7 7
8 /** 8 /**
9 - * Description of OrderData  
10 - *  
11 - * @author Administrator 9 + * 订单相关的数据模型
  10 + *
12 */ 11 */
13 class OrderData 12 class OrderData
14 { 13 {
15 /* 14 /*
16 * 获取订单数据 15 * 获取订单数据
17 - * To change this template file, choose Tools | Templates  
18 - * and open the template in the editor.  
19 */ 16 */
20 -  
21 - public static function getOrderData($type, $page, $limit, $gender, $yh_channel, $uid) 17 + public static function getOrderData($type, $page, $limit, $gender, $channel, $uid)
22 { 18 {
23 //构建必传参数 19 //构建必传参数
24 $param = Yohobuy::param(); 20 $param = Yohobuy::param();
@@ -28,7 +24,7 @@ class OrderData @@ -28,7 +24,7 @@ class OrderData
28 $param['page'] = $page; 24 $param['page'] = $page;
29 $param['type'] = $type; 25 $param['type'] = $type;
30 $param['uid'] = $uid; 26 $param['uid'] = $uid;
31 - $param['yh_channel'] = $yh_channel; 27 + $param['yh_channel'] = $channel;
32 $param['client_secret'] = Sign::getSign($param); 28 $param['client_secret'] = Sign::getSign($param);
33 //调用接口获得数据 29 //调用接口获得数据
34 return Yohobuy::get(Yohobuy::API_URL, $param); 30 return Yohobuy::get(Yohobuy::API_URL, $param);
@@ -36,18 +32,15 @@ class OrderData @@ -36,18 +32,15 @@ class OrderData
36 32
37 /* 33 /*
38 * 取消订单 34 * 取消订单
39 - * To change this template file, choose Tools | Templates  
40 - * and open the template in the editor.  
41 */ 35 */
42 -  
43 - public static function cancelOrderData($order_code, $uid, $gender, $yh_channel) 36 + public static function cancelOrderData($orderCode, $uid, $gender, $channel)
44 { 37 {
45 //构建必传参数 38 //构建必传参数
46 $param = Yohobuy::param(); 39 $param = Yohobuy::param();
47 - $param['order_code'] = $order_code; 40 + $param['order_code'] = $orderCode;
48 $param['uid'] = $uid; 41 $param['uid'] = $uid;
49 $param['gender'] = $gender; 42 $param['gender'] = $gender;
50 - $param['yh_channel'] = $yh_channel; 43 + $param['yh_channel'] = $channel;
51 $param['method'] = 'app.SpaceOrders.close'; 44 $param['method'] = 'app.SpaceOrders.close';
52 $param['client_secret'] = Sign::getSign($param); 45 $param['client_secret'] = Sign::getSign($param);
53 //调用接口获得数据 46 //调用接口获得数据
@@ -56,22 +49,40 @@ class OrderData @@ -56,22 +49,40 @@ class OrderData
56 49
57 /* 50 /*
58 * 删除订单 51 * 删除订单
59 - * To change this template file, choose Tools | Templates  
60 - * and open the template in the editor.  
61 */ 52 */
62 - public static function deleteOrderData($order_code, $uid, $gender, $yh_channel) 53 + public static function deleteOrderData($orderCode, $uid, $gender, $channel)
63 { 54 {
64 //构建必传参数 55 //构建必传参数
65 $param = Yohobuy::param(); 56 $param = Yohobuy::param();
66 - $param['order_code'] = $order_code; 57 + $param['order_code'] = $orderCode;
67 $param['uid'] = $uid; 58 $param['uid'] = $uid;
68 $param['gender'] = $gender; 59 $param['gender'] = $gender;
69 - $param['yh_channel'] = $yh_channel; 60 + $param['yh_channel'] = $channel;
70 $param['method'] = 'app.SpaceOrders.delOrderByCode'; 61 $param['method'] = 'app.SpaceOrders.delOrderByCode';
71 $param['client_secret'] = Sign::getSign($param); 62 $param['client_secret'] = Sign::getSign($param);
72 //调用接口删除订单 63 //调用接口删除订单
73 return Yohobuy::get(Yohobuy::API_URL, $param); 64 return Yohobuy::get(Yohobuy::API_URL, $param);
74 } 65 }
  66 +
  67 + /**
  68 + * 查看订单详情
  69 + *
  70 + * @param string $orderCode 订单号
  71 + * @param int $uid 用户ID
  72 + * @param string $sessionKey 用户会话
  73 + * @return array
  74 + */
  75 + public static function viewOrderData($orderCode, $uid, $sessionKey)
  76 + {
  77 + $param = Yohobuy::param();
  78 + $param['method'] = 'app.SpaceOrders.info';
  79 + $param['order_code'] = $orderCode;
  80 + $param['uid'] = $uid;
  81 + $param['session_key'] = $sessionKey;
  82 + $param['client_secret'] = Sign::getSign($param);
  83 +
  84 + return Yohobuy::get(Yohobuy::API_URL, $param);
  85 + }
75 86
76 /* 87 /*
77 * 我的订单-查看物流 88 * 我的订单-查看物流
@@ -215,9 +215,9 @@ class Helpers @@ -215,9 +215,9 @@ class Helpers
215 $result['salePrice'] && $result['salePrice'] .= '.00'; 215 $result['salePrice'] && $result['salePrice'] .= '.00';
216 } 216 }
217 $result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y'); 217 $result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y');
218 - $result['url'] = SITE_MAIN . '/product/pro_' . $productData['product_id'] . '_' 218 + $result['url'] = self::url('/product/pro_' . $productData['product_id'] . '_'
219 . $productData['goods_list'][0]['goods_id'] 219 . $productData['goods_list'][0]['goods_id']
220 - . '/' . $productData['cn_alphabet'] . '.html'; 220 + . '/' . $productData['cn_alphabet'] . '.html');
221 // APP访问需要加附加的参数 221 // APP访问需要加附加的参数
222 // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 222 // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
223 if ($isApp) { 223 if ($isApp) {
@@ -498,10 +498,15 @@ class Helpers @@ -498,10 +498,15 @@ class Helpers
498 498
499 /** 499 /**
500 * 格式化订单商品 500 * 格式化订单商品
  501 + *
  502 + * @param array $orderGoods 订单
  503 + * @param int $count 计订单件数
  504 + * @param bool $haveLink 控制是否需要商品链接
501 */ 505 */
502 - public static function formatOrderGoods($orderGoods, &$count = 0) 506 + public static function formatOrderGoods($orderGoods, &$count = 0, $haveLink = false)
503 { 507 {
504 $arr = array(); 508 $arr = array();
  509 +
505 foreach ($orderGoods as $key => $vo) { 510 foreach ($orderGoods as $key => $vo) {
506 $arr[$key]['thumb'] = Helpers::getImageUrl($vo['goods_image'], 90, 120); 511 $arr[$key]['thumb'] = Helpers::getImageUrl($vo['goods_image'], 90, 120);
507 $arr[$key]['name'] = $vo['product_name']; 512 $arr[$key]['name'] = $vo['product_name'];
@@ -519,9 +524,14 @@ class Helpers @@ -519,9 +524,14 @@ class Helpers
519 if (!empty($vo['expect_arrival_time'])) { 524 if (!empty($vo['expect_arrival_time'])) {
520 $arr[$key]['appearDate'] = $vo['expect_arrival_time']; 525 $arr[$key]['appearDate'] = $vo['expect_arrival_time'];
521 } 526 }
  527 + // 商品链接
  528 + if ($haveLink && isset($vo['product_id'])) {
  529 + $arr[$key]['link'] = self::url('/product/pro_' . $vo['product_id'] . '_' . $vo['goods_id'] . '/' . $vo['cn_alphabet'] . '.html');
  530 + }
522 // 累计购买数 531 // 累计购买数
523 $count += intval($vo['buy_number']); 532 $count += intval($vo['buy_number']);
524 } 533 }
  534 +
525 return $arr; 535 return $arr;
526 } 536 }
527 537
@@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
25 </p> 25 </p>
26 </div> 26 </div>
27 {{#if unreceived}} 27 {{#if unreceived}}
  28 + {{#if logisticsUrl}}
28 <a class="logistics sub" href="{{logisticsUrl}}"> 29 <a class="logistics sub" href="{{logisticsUrl}}">
29 <span class="iconfont">&#xe630;</span> 30 <span class="iconfont">&#xe630;</span>
30 <p class="beside-icon sub-content"> 31 <p class="beside-icon sub-content">
@@ -34,6 +35,7 @@ @@ -34,6 +35,7 @@
34 </p> 35 </p>
35 <span class="iconfont icon-right">&#xe614;</span> 36 <span class="iconfont icon-right">&#xe614;</span>
36 </a> 37 </a>
  38 + {{/if}}
37 {{/if}} 39 {{/if}}
38 </section> 40 </section>
39 41
@@ -46,23 +48,27 @@ @@ -46,23 +48,27 @@
46 <ul class="cost block"> 48 <ul class="cost block">
47 <li> 49 <li>
48 商品总金额 50 商品总金额
49 - <span>¥{{sumPrice}}</span> 51 + <span>{{sumPrice}}</span>
50 </li> 52 </li>
51 <li> 53 <li>
52 活动金额 54 活动金额
53 - <span>{{salePrice}}</span> 55 + <span>{{salePrice}}</span>
54 </li> 56 </li>
55 <li> 57 <li>
56 运费 58 运费
57 - <span>+¥{{freight}}</span> 59 + <span>{{freight}}</span>
  60 + </li>
  61 + <li>
  62 + 优惠券
  63 + <span>{{coupon}}</span>
58 </li> 64 </li>
59 <li> 65 <li>
60 YOHO币 66 YOHO币
61 - <span>{{yohoCoin}}</span> 67 + <span>{{yohoCoin}}</span>
62 </li> 68 </li>
63 <li> 69 <li>
64 实付金额 70 实付金额
65 - <span>¥{{price}}</span> 71 + <span>{{price}}</span>
66 </li> 72 </li>
67 </ul> 73 </ul>
68 74
@@ -75,9 +81,11 @@ @@ -75,9 +81,11 @@
75 81
76 {{#if unpaid}} 82 {{#if unpaid}}
77 <span class="btn btn-cancel">取消订单</span> 83 <span class="btn btn-cancel">取消订单</span>
  84 + {{#if payUrl}}
78 <a href="{{payUrl}}"> 85 <a href="{{payUrl}}">
79 <span class="btn btn-pay">立即付款</span> 86 <span class="btn btn-pay">立即付款</span>
80 </a> 87 </a>
  88 + {{/if}}
81 {{/if}} 89 {{/if}}
82 90
83 {{#if unreceived}} 91 {{#if unreceived}}
1 <div class="order-good" data-id="{{id}}"> 1 <div class="order-good" data-id="{{id}}">
2 <div class="thumb-wrap"> 2 <div class="thumb-wrap">
3 - <img class="thumb lazy" data-original="{{thumb}}">  
4 - <p class="tag{{#if gift}} gift-tag{{/if}}{{#if advanceBuy}} advance-buy-tag{{/if}}"></p> 3 + {{#if link}}
  4 + <a href="{{link}}"><img class="thumb lazy" data-original="{{thumb}}"></a>
  5 + {{else}}
  6 + <img class="thumb lazy" data-original="{{thumb}}">
  7 + {{/if}}
  8 + <p class="tag{{#if gift}} gift-tag{{/if}}{{#if advanceBuy}} advance-buy-tag{{/if}}"></p>
5 </div> 9 </div>
6 <div class="deps"> 10 <div class="deps">
7 <p class="name row">{{name}}</p> 11 <p class="name row">{{name}}</p>
@@ -71,7 +71,7 @@ class ChristmasController extends HuodongAction @@ -71,7 +71,7 @@ class ChristmasController extends HuodongAction
71 private function getLoggedUid() 71 private function getLoggedUid()
72 { 72 {
73 // 判断是否是应用访问, 拼接APP需要的URL参数 73 // 判断是否是应用访问, 拼接APP需要的URL参数
74 - $this->_isApp = null !== $this->get('app_version'); 74 + $this->_isApp = (null !== $this->get('app_version') || null !== $this->get('uid'));
75 $uid = false; 75 $uid = false;
76 if ($this->_isApp) { 76 if ($this->_isApp) {
77 $uid = $this->get('uid'); 77 $uid = $this->get('uid');
@@ -48,7 +48,7 @@ class HomeController extends AbstractAction @@ -48,7 +48,7 @@ class HomeController extends AbstractAction
48 'showDownloadApp' => true, 48 'showDownloadApp' => true,
49 'pageFooter' => true, 49 'pageFooter' => true,
50 'cartUrl' => Helpers::url('/cart/index/index', null), 50 'cartUrl' => Helpers::url('/cart/index/index', null),
51 - 'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home')) ), 51 + 'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home'))),
52 ); 52 );
53 $uid = $this->getUid(false); 53 $uid = $this->getUid(false);
54 if ($uid) { 54 if ($uid) {
@@ -781,14 +781,14 @@ class HomeController extends AbstractAction @@ -781,14 +781,14 @@ class HomeController extends AbstractAction
781 // 审判跳转登录页 781 // 审判跳转登录页
782 $this->auditJumpLogin(); 782 $this->auditJumpLogin();
783 783
784 - $this->setTitle('支付中心');  
785 - $this->setNavHeader('支付中心');  
786 -  
787 $orderCode = $this->get('order_code'); 784 $orderCode = $this->get('order_code');
788 if (empty($orderCode)) { 785 if (empty($orderCode)) {
789 $this->error(); 786 $this->error();
790 } 787 }
791 788
  789 + $this->setTitle('支付中心');
  790 + $this->setNavHeader('支付中心');
  791 +
792 $this->_view->display('pay', array( 792 $this->_view->display('pay', array(
793 'payCenterPage' => true, 793 'payCenterPage' => true,
794 'payAppInfo' => array( 794 'payAppInfo' => array(
@@ -814,61 +814,26 @@ class HomeController extends AbstractAction @@ -814,61 +814,26 @@ class HomeController extends AbstractAction
814 )); 814 ));
815 } 815 }
816 816
817 -// /*  
818 -// * 我的订单-确认收货  
819 -// */  
820 -// private function confirmAction(){  
821 -// //  
822 -// $gender = Helpers::getGenderByCookie();  
823 -// $order_code = $this->get('id');  
824 -// $order_code = '';  
825 -// $yh_channel = $this->get('yh_channel', 1);  
826 -// $data = OrderData::confirmData($gender,$order_code,$yh_channel,$this->_uid);  
827 -// $this->echoJson($data);  
828 -// }  
829 -  
830 /** 817 /**
831 * 订单详情页 818 * 订单详情页
832 */ 819 */
833 public function orderDetailAction() 820 public function orderDetailAction()
834 { 821 {
835 - $data = array(  
836 - 'name' => '毛毛莉Lydia',  
837 - 'phoneNum' => '18600001133',  
838 - 'address' => '南京市建邺区嘉陵江东街18号国家广告产业园5栋17楼',  
839 - 'orderStatus' => '订单取消',  
840 - 'orderNum' => '418358063',  
841 - 'orderTime' => '2014-03-10 17:25:10',  
842 - 'orderCancel' => true,  
843 - 'goods' => array(  
844 - array(  
845 - 'id' => 1,  
846 - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',  
847 - 'name' => 'Adidas Originals ZX FLUXM22508',  
848 - 'color' => '黄',  
849 - 'size' => '43',  
850 - 'price' => '699.00',  
851 - 'count' => '2'  
852 - ),  
853 - array(  
854 - 'id' => 1,  
855 - 'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',  
856 - 'name' => 'B.Duck浴室玩伴mini浮水鸭',  
857 - 'gift' => true,  
858 - 'color' => '黄',  
859 - 'size' => '43',  
860 - 'price' => '0.00',  
861 - 'count' => '1'  
862 - )  
863 - ),  
864 - 'sumPrice' => 799,  
865 - 'salePrice' => 80,  
866 - 'freight' => 5,  
867 - 'coupon' => 0,  
868 - 'yohoCoin' => 5,  
869 - 'price' => 719  
870 - );  
871 - $this->_view->display('order-detail', array('orderDetail' => $data, 'orderDetailPage' => true)); 822 + // 审判跳转登录页
  823 + $this->auditJumpLogin();
  824 +
  825 + $orderCode = $this->get('order_code', 1507880870);
  826 + if (empty($orderCode)) {
  827 + $this->error();
  828 + }
  829 +
  830 + $this->setTitle('订单详情');
  831 + $this->setNavHeader('订单详情');
  832 +
  833 + $this->_view->display('order-detail', array(
  834 + 'orderDetailPage' => true,
  835 + 'orderDetail' => OrderModel::orderDetail($orderCode, 967016/*$this->_uid*/, 'a3aadd4cce408f8ee062a9add02e8faa'/*$this->_session*/),
  836 + ));
872 } 837 }
873 838
874 // /** 839 // /**
@@ -68,86 +68,20 @@ class OrderModel @@ -68,86 +68,20 @@ class OrderModel
68 } 68 }
69 //检查数据返回是否正常,正常则处理数据 69 //检查数据返回是否正常,正常则处理数据
70 if (!empty($data['data']['order_list'])) { 70 if (!empty($data['data']['order_list'])) {
71 - // 订单的状态列表  
72 - //$orderStatus = Helpers::getOrderStatus();  
73 $count = 0; 71 $count = 0;
74 foreach ($data['data']['order_list'] as $key => $vo) { 72 foreach ($data['data']['order_list'] as $key => $vo) {
75 -// if ($vo['payment_status'] == 'Y' && $vo['status'] == 0) {  
76 -// $vo['status'] = 1;  
77 -// } 73 + // 订单件数清零
78 $count = 0; 74 $count = 0;
  75 + //根据订单status判断订单处于什么状态。
  76 + $result[$key] = self::getOrderStatus($vo);
79 //订单号,支付状态,订单商品数量,订单总价格 77 //订单号,支付状态,订单商品数量,订单总价格
80 $result[$key]['orderNum'] = $vo['order_code']; 78 $result[$key]['orderNum'] = $vo['order_code'];
81 - //$result[$key]['orderStatus'] = ($vo['is_cancel'] === 'Y') ? '已取消' : $orderStatus[ $vo['payment_type'] ][ $vo['status'] ];  
82 $result[$key]['orderStatus'] = $vo['status_str']; 79 $result[$key]['orderStatus'] = $vo['status_str'];
83 $result[$key]['sumCost'] = $vo['amount']; 80 $result[$key]['sumCost'] = $vo['amount'];
84 //类内调用格式化订单商品数据方法 81 //类内调用格式化订单商品数据方法
85 - $result[$key]['goods'] = Helpers::formatOrderGoods($vo['order_goods'], $count); 82 + $result[$key]['goods'] = Helpers::formatOrderGoods($vo['order_goods'], $count);
86 $result[$key]['detailUrl'] = Helpers::url('/home/orders/detail', array('order_code' => $vo['order_code'], 't' => time())); 83 $result[$key]['detailUrl'] = Helpers::url('/home/orders/detail', array('order_code' => $vo['order_code'], 't' => time()));
87 $result[$key]['count'] = $count; 84 $result[$key]['count'] = $count;
88 - //根据订单status判断订单处于什么状态。  
89 - do {  
90 - //订单取消状态 = Y 时,跳出判断订单状态循环,并设置订单状态为已取消。  
91 - if ($vo['is_cancel'] === 'Y') {  
92 - $result[$key]['canceled'] = true;  
93 - break;  
94 - }  
95 - /* 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)  
96 - * 付款方式:1 => 在线支付,2 => 货到付款,3 => 现金支付,4 => 抵消支付;  
97 - */  
98 - //支付方式为非货到付款时,计算订单状态。  
99 - if ($vo['payment_type'] != 2) {  
100 - switch ($vo['status']) {  
101 - case 0: // 待付款  
102 - $result[$key]['unpaid'] = true;  
103 - $result[$key]['payUrl'] = Helpers::url('/home/pay', array('order_code' => $vo['order_code']));  
104 - break;  
105 - //未发货&未收货 状态,统一合并到待收货状态。  
106 - case 1:  
107 - case 2:  
108 - case 3:  
109 - //已付款状态不给查看物流URL  
110 - $result[$key]['unreceived'] = true;  
111 - break;  
112 - case 4:  
113 - case 5:  
114 - //已发货状态,给查看物流URL  
115 - $result[$key]['unreceived'] = true;  
116 - $result[$key]['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $vo['order_code']));  
117 - break;  
118 - case 6:  
119 - $result[$key]['completed'] = true;  
120 - break;  
121 - default:  
122 - break;  
123 - }  
124 - break;  
125 - }  
126 -  
127 - //订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态)  
128 - switch ($vo['status']) {  
129 - case 0: // 备货中  
130 - $result[$key]['unpaid'] = true;  
131 - break;  
132 - case 1:  
133 - case 2:  
134 - case 3:  
135 - //备货中、已付款状态不给查看物流链接  
136 - $result[$key]['unreceived'] = true;  
137 - break;  
138 - case 4:  
139 - case 5:  
140 - //待收货状态,给查看物流url  
141 - $result[$key]['unreceived'] = true;  
142 - $result[$key]['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $vo['order_code']));  
143 - break;  
144 - case 6:  
145 - $result[$key]['completed'] = true;  
146 - break;  
147 - default:  
148 - break;  
149 - }  
150 - } while (false);  
151 } 85 }
152 } 86 }
153 87
@@ -155,16 +89,6 @@ class OrderModel @@ -155,16 +89,6 @@ class OrderModel
155 } 89 }
156 90
157 /** 91 /**
158 - * 获得支付链接  
159 - */  
160 - public static function payment($gender, $yh_channel)  
161 - {  
162 - $code = self::CODE_PAYMENT;  
163 - $data = OrderData::paymentData($gender, $yh_channel, $code);  
164 - return $data;  
165 - }  
166 -  
167 - /**  
168 * 查看物流 92 * 查看物流
169 * 93 *
170 * @param int $orderCode 订单编号 94 * @param int $orderCode 订单编号
@@ -196,6 +120,43 @@ class OrderModel @@ -196,6 +120,43 @@ class OrderModel
196 } 120 }
197 121
198 /** 122 /**
  123 + * 获取订单详情信息
  124 + *
  125 + * @param string $orderCode 订单号
  126 + * @param int $uid 用户ID
  127 + * @param string $sessionKey 用户的会话
  128 + * @return array
  129 + */
  130 + public static function orderDetail($orderCode, $uid, $sessionKey)
  131 + {
  132 + $result = array();
  133 +
  134 + if (is_numeric($orderCode) && is_numeric($uid) && is_string($sessionKey)) {
  135 + $orderDetail = OrderData::viewOrderData($orderCode, $uid, $sessionKey);
  136 + if (isset($orderDetail['data']['order_code'])) {
  137 + $count = 0;
  138 +
  139 + $result = self::getOrderStatus($orderDetail['data'], true); // 订单状态
  140 + $result['name'] = $orderDetail['data']['user_name'];
  141 + $result['phoneNum'] = $orderDetail['data']['mobile'];
  142 + $result['address'] = $orderDetail['data']['area'] . $orderDetail['data']['address'];
  143 + $result['orderStatus'] = $orderDetail['data']['status_str'];
  144 + $result['orderNum'] = $orderDetail['data']['order_code'];
  145 + $result['orderTime'] = date('Y-m-d H:i:s', $orderDetail['data']['create_time']);
  146 + $result['goods'] = Helpers::formatOrderGoods($orderDetail['data']['order_goods'], $count, true);
  147 + $result['sumPrice'] = $orderDetail['data']['goods_total_amount']; // 商品总金额
  148 + $result['salePrice'] = $orderDetail['data']['promotion_amount']; // 活动金额
  149 + $result['freight'] = $orderDetail['data']['shipping_cost']; // 运费
  150 + $result['coupon'] = $orderDetail['data']['coupons_amount']; // 优惠券
  151 + $result['yohoCoin'] = $orderDetail['data']['yoho_coin_num']; // YOHO币
  152 + $result['price'] = $orderDetail['data']['amount']; // 实付金额
  153 + }
  154 + }
  155 +
  156 + return $result;
  157 + }
  158 +
  159 + /**
199 * 根据type值设置nav属性 160 * 根据type值设置nav属性
200 */ 161 */
201 public static function getNavs($type) 162 public static function getNavs($type)
@@ -218,4 +179,89 @@ class OrderModel @@ -218,4 +179,89 @@ class OrderModel
218 return $nav; 179 return $nav;
219 } 180 }
220 181
  182 + /**
  183 + * 获取订单状态
  184 + *
  185 + * @param array $order 订单
  186 + * @param bool $showLogistics 控制是否显示物流信息
  187 + * @return array
  188 + */
  189 + private static function getOrderStatus($order, $showLogistics = false)
  190 + {
  191 + $result = array();
  192 +
  193 + //根据订单status判断订单处于什么状态。
  194 + do {
  195 + //订单取消状态 = Y 时,跳出判断订单状态循环,并设置订单状态为已取消。
  196 + if ($order['is_cancel'] === 'Y') {
  197 + $result['canceled'] = true;
  198 + break;
  199 + }
  200 +
  201 + // 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)
  202 + // 支付方式为非货到付款时,计算订单状态。
  203 + if ($order['payment_type'] != 2) {
  204 + switch ($order['status']) {
  205 + case 0: // 待付款
  206 + $result['unpaid'] = true;
  207 + $result['payUrl'] = Helpers::url('/home/pay', array('order_code' => $order['order_code']));
  208 + break;
  209 + //未发货&未收货 状态,统一合并到待收货状态。
  210 + case 1:
  211 + case 2:
  212 + case 3:
  213 + //已付款状态不给查看物流URL
  214 + $result['unreceived'] = true;
  215 + break;
  216 + case 4:
  217 + case 5:
  218 + //已发货状态,给查看物流URL
  219 + $result['unreceived'] = true;
  220 + $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
  221 + if ($showLogistics) {
  222 + $result['logisticsCompany'] = $order['caption'];
  223 + $result['logisticsNum'] = $order['express_number'];
  224 + }
  225 + break;
  226 + case 6:
  227 + $result['completed'] = true;
  228 + break;
  229 + default:
  230 + break;
  231 + }
  232 + break;
  233 + }
  234 +
  235 + // 订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态)
  236 + switch ($order['status']) {
  237 + case 0: // 备货中
  238 + $result['unpaid'] = true;
  239 + break;
  240 + case 1:
  241 + case 2:
  242 + case 3:
  243 + //备货中、已付款状态不给查看物流链接
  244 + $result['unreceived'] = true;
  245 + break;
  246 + case 4:
  247 + case 5:
  248 + //待收货状态,给查看物流url
  249 + $result['unreceived'] = true;
  250 + $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
  251 + if ($showLogistics) {
  252 + $result['logisticsCompany'] = isset($order['caption']) ? $order['caption'] : '';
  253 + $result['logisticsNum'] = isset($order['express_number']) ? $order['express_number'] : '';
  254 + }
  255 + break;
  256 + case 6:
  257 + $result['completed'] = true;
  258 + break;
  259 + default:
  260 + break;
  261 + }
  262 + } while (false);
  263 +
  264 + return $result;
  265 + }
  266 +
221 } 267 }