Authored by Rock Zhang

修复订单详情页快递信息的显示(现在交易成功的订单也显示物流信息)

Code Review By Rock Zhang
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="order-detail-page yoho-page"> 2 <div class="order-detail-page yoho-page">
3 {{# orderDetail}} 3 {{# orderDetail}}
4 - <div id="order-detail" data-id="{{orderNum}}">  
5 - <section class="owner-info block">  
6 - <span class="iconfont">&#xe631;</span>  
7 - <div class="beside-icon">  
8 - <p class="name-phone">  
9 - {{name}}  
10 - <span>{{phoneNum}}</span>  
11 - </p>  
12 - <p class="address">  
13 - {{address}}  
14 - </p>  
15 - </div>  
16 - </section> 4 + <div id="order-detail" data-id="{{orderNum}}">
  5 + <section class="owner-info block">
  6 + <span class="iconfont">&#xe631;</span>
17 7
18 - <section class="order-status block">  
19 - <div class="status sub">  
20 - <span class="iconfont">&#xe632;</span>  
21 - <p class="beside-icon sub-content">  
22 - <span class="sub-title">{{orderStatus}}</span>  
23 - <span>订单编号:{{orderNum}}</span>  
24 - <span>下单时间:{{orderTime}}</span>  
25 - </p>  
26 - </div>  
27 - {{#if unreceived}}  
28 - {{#if logisticsUrl}}  
29 - <a class="logistics sub" href="{{logisticsUrl}}">  
30 - <span class="iconfont">&#xe630;</span>  
31 - <p class="beside-icon sub-content">  
32 - <span class="sub-title">物流信息</span>  
33 - <span>物流公司:{{logisticsCompany}}</span>  
34 - <span>快递单号:{{logisticsNum}}</span>  
35 - </p>  
36 - <span class="iconfont icon-right">&#xe614;</span>  
37 - </a>  
38 - {{/if}}  
39 - {{/if}}  
40 - </section> 8 + <div class="beside-icon">
  9 + <p class="name-phone">
  10 + {{name}}
  11 + <span>{{phoneNum}}</span>
  12 + </p>
41 13
42 - <section class="goods block">  
43 - {{# goods}}  
44 - {{> me/order/good}}  
45 - {{/ goods}}  
46 - </section> 14 + <p class="address">
  15 + {{address}}
  16 + </p>
  17 + </div>
  18 + </section>
  19 +
  20 + <section class="order-status block">
  21 + <div class="status sub">
  22 + <span class="iconfont">&#xe632;</span>
47 23
48 - <ul class="cost block">  
49 - <li>  
50 - 商品总金额  
51 - <span>{{sumPrice}}</span>  
52 - </li>  
53 - {{#if salePrice}}  
54 - <li>  
55 - 活动金额  
56 - <span>{{salePrice}}</span>  
57 - </li>  
58 - {{/if}}  
59 - <li>  
60 - 运费  
61 - <span>{{freight}}</span>  
62 - </li>  
63 - {{#if promo_code_amount}}  
64 - <li>  
65 - 优惠码  
66 - <span>{{promo_code_amount}}</span>  
67 - </li>  
68 - {{/if}}  
69 - {{#if coupon}}  
70 - <li>  
71 - 优惠券  
72 - <span>{{coupon}}</span>  
73 - </li>  
74 - {{/if}}  
75 - {{#if yohoCoin}}  
76 - <li>  
77 - YOHO币  
78 - <span>{{yohoCoin}}</span>  
79 - </li>  
80 - {{/if}}  
81 - <li>  
82 - 实付金额  
83 - <span>{{price}}</span>  
84 - </li>  
85 - </ul> 24 + <p class="beside-icon sub-content">
  25 + <span class="sub-title">{{orderStatus}}</span>
  26 + <span>订单编号:{{orderNum}}</span>
  27 + <span>下单时间:{{orderTime}}</span>
  28 + </p>
  29 + </div>
  30 + {{#if logisticsUrl}}
  31 + <a class="logistics sub" href="{{logisticsUrl}}">
  32 + <span class="iconfont">&#xe630;</span>
86 33
87 - <div class="opt block">  
88 - {{#unless unreceived}}  
89 - {{#unless unpaid}}  
90 - <span class="btn btn-del">删除订单</span>  
91 - {{/unless}}  
92 - {{/unless}} 34 + <p class="beside-icon sub-content">
  35 + <span class="sub-title">物流信息</span>
  36 + <span>物流公司:{{logisticsCompany}}</span>
  37 + <span>快递单号:{{logisticsNum}}</span>
  38 + </p>
  39 + <span class="iconfont icon-right">&#xe614;</span>
  40 + </a>
  41 + {{/if}}
  42 + </section>
93 43
94 - {{#if unpaid}}  
95 - <span class="btn btn-cancel">取消订单</span>  
96 - {{#if payUrl}}  
97 - <a href="{{payUrl}}">  
98 - <span class="btn btn-pay">立即付款</span>  
99 - </a>  
100 - {{/if}}  
101 - {{/if}} 44 + <section class="goods block">
  45 + {{# goods}}
  46 + {{> me/order/good}}
  47 + {{/ goods}}
  48 + </section>
102 49
103 - {{#if logisticsUrl}}  
104 - <a href="{{logisticsUrl}}">  
105 - <span class="btn btn-check-logistics">查看物流</span>  
106 - </a>  
107 - {{/if}}  
108 - </div> 50 + <ul class="cost block">
  51 + <li>
  52 + 商品总金额
  53 + <span>{{sumPrice}}</span>
  54 + </li>
  55 + {{#if salePrice}}
  56 + <li>
  57 + 活动金额
  58 + <span>{{salePrice}}</span>
  59 + </li>
  60 + {{/if}}
  61 + <li>
  62 + 运费
  63 + <span>{{freight}}</span>
  64 + </li>
  65 + {{#if promo_code_amount}}
  66 + <li>
  67 + 优惠码
  68 + <span>{{promo_code_amount}}</span>
  69 + </li>
  70 + {{/if}}
  71 + {{#if coupon}}
  72 + <li>
  73 + 优惠券
  74 + <span>{{coupon}}</span>
  75 + </li>
  76 + {{/if}}
  77 + {{#if yohoCoin}}
  78 + <li>
  79 + YOHO币
  80 + <span>{{yohoCoin}}</span>
  81 + </li>
  82 + {{/if}}
  83 + <li>
  84 + 实付金额
  85 + <span>{{price}}</span>
  86 + </li>
  87 + </ul>
  88 +
  89 + <div class="opt block">
  90 + {{#unless unreceived}}
  91 + {{#unless unpaid}}
  92 + <span class="btn btn-del">删除订单</span>
  93 + {{/unless}}
  94 + {{/unless}}
  95 +
  96 + {{#if unpaid}}
  97 + <span class="btn btn-cancel">取消订单</span>
  98 + {{#if payUrl}}
  99 + <a href="{{payUrl}}">
  100 + <span class="btn btn-pay">立即付款</span>
  101 + </a>
  102 + {{/if}}
  103 + {{/if}}
  104 +
  105 + {{#if logisticsUrl}}
  106 + <a href="{{logisticsUrl}}">
  107 + <span class="btn btn-check-logistics">查看物流</span>
  108 + </a>
  109 + {{/if}}
109 </div> 110 </div>
  111 + </div>
110 {{/ orderDetail}} 112 {{/ orderDetail}}
111 </div> 113 </div>
112 -<script>_ozprm="orderid={{orderCode}}&ordertotal={{orderTotal}}";</script>  
113 -<script type="text/javascript" src ="http://static.yohobuy.com/m/v1/js/AG_Tracking.js"></script> 114 +<script>_ozprm = "orderid={{orderCode}}&ordertotal={{orderTotal}}";</script>
  115 +<script type="text/javascript" src="http://static.yohobuy.com/m/v1/js/AG_Tracking.js"></script>
114 <script type="text/javascript"> 116 <script type="text/javascript">
115 -var _agq = _agq || [];  
116 -_agq.push(['_cid', '415']); //生成value  
117 -_agq.push(['_eid', '102']); //生成value  
118 -_agq.push(['_orderSum',"{{orderTotal}}"]);//订单金额,客户在页面填写  
119 -_agq.push(['_orderNo',"{{orderCode}}"]);//订单号,客户在页面填写  
120 -_agq.push(['_orderNew',"{{isOldUser}}"]);//是否新客单,客户标记是为true否为false  
121 -_agq.push(['_orderCount',"{{orderCount}}"]);//订单货品数目,客户填写  
122 -ag_send(_agq); 117 + var _agq = _agq || [];
  118 + _agq.push(['_cid', '415']); //生成value
  119 + _agq.push(['_eid', '102']); //生成value
  120 + _agq.push(['_orderSum', "{{orderTotal}}"]);//订单金额,客户在页面填写
  121 + _agq.push(['_orderNo', "{{orderCode}}"]);//订单号,客户在页面填写
  122 + _agq.push(['_orderNew', "{{isOldUser}}"]);//是否新客单,客户标记是为true否为false
  123 + _agq.push(['_orderCount', "{{orderCount}}"]);//订单货品数目,客户填写
  124 + ag_send(_agq);
123 125
124 -var __order_code = "{{orderCode}}";  
125 -var __order_amount = "{{orderTotal}}";  
126 -var __order_user = "{{isOldUser}}";  
127 -var __order_goods_num = {{orderCount}};  
128 -var __order_uid = '{{uid}}'; 126 + var __order_code = "{{orderCode}}";
  127 + var __order_amount = "{{orderTotal}}";
  128 + var __order_user = "{{isOldUser}}";
  129 + var __order_goods_num = {{orderCount}};
  130 + var __order_uid = '{{uid}}';
129 131
130 -var _fxcmd=_fxcmd||[];  
131 -_fxcmd.push(['trackOrder', {  
132 - oid: "{{orderCode}}",  
133 - otp : "{{orderTotalFormat}}",  
134 - unid : "{{uid}}"  
135 -}]); 132 + var _fxcmd = _fxcmd || [];
  133 + _fxcmd.push(['trackOrder', {
  134 + oid: "{{orderCode}}",
  135 + otp: "{{orderTotalFormat}}",
  136 + unid: "{{uid}}"
  137 + }]);
136 </script> 138 </script>
137 <script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script> 139 <script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
138 <script type="text/javascript"> 140 <script type="text/javascript">
139 -window.criteo_q = window.criteo_q || [];  
140 -window.criteo_q.push(  
141 -{ event: "setAccount", account: [21397] },  
142 -{ event: "setHashedEmail", email: "" },  
143 -{ event: "setSiteType", type: "m" },  
144 -{ event: "trackTransaction" , id: "{{orderCode}}", currency: "CNY", item: ""}  
145 -); 141 + window.criteo_q = window.criteo_q || [];
  142 + window.criteo_q.push(
  143 + {event: "setAccount", account: [21397]},
  144 + {event: "setHashedEmail", email: ""},
  145 + {event: "setSiteType", type: "m"},
  146 + {event: "trackTransaction", id: "{{orderCode}}", currency: "CNY", item: ""}
  147 + );
146 </script> 148 </script>
147 {{> layout/footer}} 149 {{> layout/footer}}
@@ -284,14 +284,12 @@ class OrderModel @@ -284,14 +284,12 @@ class OrderModel
284 case 5: 284 case 5:
285 //已发货状态,给查看物流URL 285 //已发货状态,给查看物流URL
286 $result['unreceived'] = true; 286 $result['unreceived'] = true;
287 - $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));  
288 - if ($showLogistics && isset($order['caption'])) {  
289 - $result['logisticsCompany'] = $order['caption'];  
290 - $result['logisticsNum'] = $order['express_number'];  
291 - } 287 + self::assignExpressInfo($showLogistics, $order, $result);
292 break; 288 break;
293 case 6: 289 case 6:
294 $result['completed'] = true; 290 $result['completed'] = true;
  291 + // 已成功订单,给查看物流URL
  292 + self::assignExpressInfo($showLogistics, $order, $result);
295 break; 293 break;
296 default: 294 default:
297 break; 295 break;
@@ -314,14 +312,11 @@ class OrderModel @@ -314,14 +312,11 @@ class OrderModel
314 case 5: 312 case 5:
315 //待收货状态,给查看物流url 313 //待收货状态,给查看物流url
316 $result['unreceived'] = true; 314 $result['unreceived'] = true;
317 - $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));  
318 - if ($showLogistics && isset($order['caption'])) {  
319 - $result['logisticsCompany'] = $order['caption'];  
320 - $result['logisticsNum'] = $order['express_number'];  
321 - } 315 + self::assignExpressInfo($showLogistics, $order, $result);
322 break; 316 break;
323 case 6: 317 case 6:
324 $result['completed'] = true; 318 $result['completed'] = true;
  319 + self::assignExpressInfo($showLogistics, $order, $result);
325 break; 320 break;
326 default: 321 default:
327 break; 322 break;
@@ -331,6 +326,16 @@ class OrderModel @@ -331,6 +326,16 @@ class OrderModel
331 return $result; 326 return $result;
332 } 327 }
333 328
  329 + private static function assignExpressInfo($showLogistics, $order, &$result)
  330 + {
  331 + $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
  332 +
  333 + if ($showLogistics && isset($order['express_company']['caption'])) {
  334 + $result['logisticsCompany'] = $order['express_company']['caption'];
  335 + $result['logisticsNum'] = $order['express_number'];
  336 + }
  337 + }
  338 +
334 /** 339 /**
335 * 过滤掉为0的价格数据 340 * 过滤掉为0的价格数据
336 * 341 *