Authored by yangyang

订单列表切换至新接口,订单总价数据暂时接口返回异常

@@ -25,12 +25,10 @@ class OrderData @@ -25,12 +25,10 @@ class OrderData
25 */ 25 */
26 26
27 static function getOrderData($type, $page, $limit, $uid) { 27 static function getOrderData($type, $page, $limit, $uid) {
28 - $param['limit'] = '10';  
29 - $param['page'] = 1;  
30 - $param['type'] = 1;  
31 - $param['uid'] = '12';  
32 -// $param['iscancel'] = false;  
33 -// $param['paymentStatus'] = 'Y'; 28 + $param['limit'] = $limit;
  29 + $param['page'] = $page;
  30 + $param['type'] = $type;
  31 + $param['uid'] = $uid;
34 return Yohobuy::jsonPost(Yohobuy::YOHOBUY_ORDER.'orderInfo/getOrderList',$param); 32 return Yohobuy::jsonPost(Yohobuy::YOHOBUY_ORDER.'orderInfo/getOrderList',$param);
35 } 33 }
36 34
@@ -24,8 +24,7 @@ class HomeController extends AbstractAction @@ -24,8 +24,7 @@ class HomeController extends AbstractAction
24 /** 24 /**
25 * 初始化 25 * 初始化
26 */ 26 */
27 - public function init()  
28 - { 27 + public function init() {
29 // 检查用户是否登录, 未登录则跳转到登录页 28 // 检查用户是否登录, 未登录则跳转到登录页
30 $uid = 8826435; //$this->getUid(true); 29 $uid = 8826435; //$this->getUid(true);
31 $action = $this->getRequest()->getActionName(); 30 $action = $this->getRequest()->getActionName();
@@ -39,8 +38,7 @@ class HomeController extends AbstractAction @@ -39,8 +38,7 @@ class HomeController extends AbstractAction
39 /** 38 /**
40 * 个人中心入口 39 * 个人中心入口
41 */ 40 */
42 - public function indexAction()  
43 - { 41 + public function indexAction() {
44 // 设置网站标题 42 // 设置网站标题
45 $this->setTitle('个人中心'); 43 $this->setTitle('个人中心');
46 $this->setNavHeader('个人中心'); 44 $this->setNavHeader('个人中心');
@@ -66,8 +64,7 @@ class HomeController extends AbstractAction @@ -66,8 +64,7 @@ class HomeController extends AbstractAction
66 /** 64 /**
67 * 用户收藏的商品 65 * 用户收藏的商品
68 */ 66 */
69 - public function favoriteAction()  
70 - { 67 + public function favoriteAction() {
71 // 设置网站标题 68 // 设置网站标题
72 $this->setTitle('我的收藏'); 69 $this->setTitle('我的收藏');
73 $this->setNavHeader('我的收藏', true, SITE_MAIN); 70 $this->setNavHeader('我的收藏', true, SITE_MAIN);
@@ -98,8 +95,7 @@ class HomeController extends AbstractAction @@ -98,8 +95,7 @@ class HomeController extends AbstractAction
98 /** 95 /**
99 * 用户收藏的商品-删除 96 * 用户收藏的商品-删除
100 */ 97 */
101 - public function favoriteDelAction()  
102 - { 98 + public function favoriteDelAction() {
103 $result = array(); 99 $result = array();
104 100
105 if ($this->isAjax()) { 101 if ($this->isAjax()) {
@@ -119,8 +115,7 @@ class HomeController extends AbstractAction @@ -119,8 +115,7 @@ class HomeController extends AbstractAction
119 /** 115 /**
120 * 个人信息 116 * 个人信息
121 */ 117 */
122 - public function personalDetailsAction()  
123 - { 118 + public function personalDetailsAction() {
124 $this->setTitle('个人信息'); 119 $this->setTitle('个人信息');
125 $this->setNavHeader('个人信息', true, SITE_MAIN); 120 $this->setNavHeader('个人信息', true, SITE_MAIN);
126 121
@@ -134,8 +129,7 @@ class HomeController extends AbstractAction @@ -134,8 +129,7 @@ class HomeController extends AbstractAction
134 /** 129 /**
135 * YOHO币 130 * YOHO币
136 */ 131 */
137 - public function currencyAction()  
138 - { 132 + public function currencyAction() {
139 $this->setTitle('YOHO币'); 133 $this->setTitle('YOHO币');
140 $this->setNavHeader('YOHO币', true, false); 134 $this->setNavHeader('YOHO币', true, false);
141 135
@@ -149,8 +143,7 @@ class HomeController extends AbstractAction @@ -149,8 +143,7 @@ class HomeController extends AbstractAction
149 /** 143 /**
150 * 优惠券 144 * 优惠券
151 */ 145 */
152 - public function couponsAction()  
153 - { 146 + public function couponsAction() {
154 $this->setTitle('优惠券'); 147 $this->setTitle('优惠券');
155 $this->setNavHeader('优惠券', true, SITE_MAIN); 148 $this->setNavHeader('优惠券', true, SITE_MAIN);
156 149
@@ -170,8 +163,7 @@ class HomeController extends AbstractAction @@ -170,8 +163,7 @@ class HomeController extends AbstractAction
170 /** 163 /**
171 * 我的消息 164 * 我的消息
172 */ 165 */
173 - public function messageAction()  
174 - { 166 + public function messageAction() {
175 $uid = $this->getUid(); 167 $uid = $this->getUid();
176 $page = $this->get('page', 0); 168 $page = $this->get('page', 0);
177 $size = $this->get('size', 10); 169 $size = $this->get('size', 10);
@@ -184,8 +176,7 @@ class HomeController extends AbstractAction @@ -184,8 +176,7 @@ class HomeController extends AbstractAction
184 /** 176 /**
185 * 地址管理 177 * 地址管理
186 */ 178 */
187 - public function addressAction()  
188 - { 179 + public function addressAction() {
189 // 设置网站标题 180 // 设置网站标题
190 $this->setTitle('地址管理'); 181 $this->setTitle('地址管理');
191 $this->setNavHeader('地址管理'); 182 $this->setNavHeader('地址管理');
@@ -205,8 +196,7 @@ class HomeController extends AbstractAction @@ -205,8 +196,7 @@ class HomeController extends AbstractAction
205 /** 196 /**
206 * 修改地址或者添加新地址 197 * 修改地址或者添加新地址
207 */ 198 */
208 - public function saveAddressAction()  
209 - { 199 + public function saveAddressAction() {
210 $result = array(); 200 $result = array();
211 201
212 if ($this->isAjax()) { 202 if ($this->isAjax()) {
@@ -232,8 +222,7 @@ class HomeController extends AbstractAction @@ -232,8 +222,7 @@ class HomeController extends AbstractAction
232 /** 222 /**
233 * 设置默认地址 223 * 设置默认地址
234 */ 224 */
235 - public function defaultAddressAction()  
236 - { 225 + public function defaultAddressAction() {
237 $result = array(); 226 $result = array();
238 227
239 if ($this->isAjax()) { 228 if ($this->isAjax()) {
@@ -252,8 +241,7 @@ class HomeController extends AbstractAction @@ -252,8 +241,7 @@ class HomeController extends AbstractAction
252 /** 241 /**
253 * 删除地址 242 * 删除地址
254 */ 243 */
255 - public function delAddressAction()  
256 - { 244 + public function delAddressAction() {
257 $result = array(); 245 $result = array();
258 246
259 if ($this->isAjax()) { 247 if ($this->isAjax()) {
@@ -271,8 +259,7 @@ class HomeController extends AbstractAction @@ -271,8 +259,7 @@ class HomeController extends AbstractAction
271 } 259 }
272 260
273 //在线客服 261 //在线客服
274 - public function onlineServiceAction()  
275 - { 262 + public function onlineServiceAction() {
276 // 设置网站标题 263 // 设置网站标题
277 $this->setTitle('在线客服'); 264 $this->setTitle('在线客服');
278 $this->setNavHeader('在线客服', true, SITE_MAIN); 265 $this->setNavHeader('在线客服', true, SITE_MAIN);
@@ -287,8 +274,7 @@ class HomeController extends AbstractAction @@ -287,8 +274,7 @@ class HomeController extends AbstractAction
287 } 274 }
288 275
289 //在线客服-具体详情 276 //在线客服-具体详情
290 - public function onlineServiceDetailAction()  
291 - { 277 + public function onlineServiceDetailAction() {
292 $service = array(); 278 $service = array();
293 $cateId = $this->get('cateId', 0); 279 $cateId = $this->get('cateId', 0);
294 $cateName = $this->get('cateName', ''); 280 $cateName = $this->get('cateName', '');
@@ -303,8 +289,7 @@ class HomeController extends AbstractAction @@ -303,8 +289,7 @@ class HomeController extends AbstractAction
303 /** 289 /**
304 * 我的逛 290 * 我的逛
305 */ 291 */
306 - public function myGuangAction()  
307 - { 292 + public function myGuangAction() {
308 $page = $this->get('page', 1); 293 $page = $this->get('page', 1);
309 $limit = $this->get('limit', 10); 294 $limit = $this->get('limit', 10);
310 $uid = $this->getUid(); 295 $uid = $this->getUid();
@@ -327,8 +312,7 @@ class HomeController extends AbstractAction @@ -327,8 +312,7 @@ class HomeController extends AbstractAction
327 /** 312 /**
328 * 意见反馈 313 * 意见反馈
329 */ 314 */
330 - public function suggestAction()  
331 - { 315 + public function suggestAction() {
332 // 设置网站标题 316 // 设置网站标题
333 $this->setTitle('意见反馈'); 317 $this->setTitle('意见反馈');
334 $this->setNavHeader('意见反馈', true, SITE_MAIN); 318 $this->setNavHeader('意见反馈', true, SITE_MAIN);
@@ -350,8 +334,7 @@ class HomeController extends AbstractAction @@ -350,8 +334,7 @@ class HomeController extends AbstractAction
350 /** 334 /**
351 * 意见反馈-提交表单页面 335 * 意见反馈-提交表单页面
352 */ 336 */
353 - public function suggestSubAction()  
354 - { 337 + public function suggestSubAction() {
355 // 设置网站标题 338 // 设置网站标题
356 $this->setTitle('反馈问题'); 339 $this->setTitle('反馈问题');
357 340
@@ -372,8 +355,7 @@ class HomeController extends AbstractAction @@ -372,8 +355,7 @@ class HomeController extends AbstractAction
372 /** 355 /**
373 * 异步上传图片 356 * 异步上传图片
374 */ 357 */
375 - public function suggestimgUploadAction()  
376 - { 358 + public function suggestimgUploadAction() {
377 //$filename = $this->post('filename', ''); 359 //$filename = $this->post('filename', '');
378 $result = UserModel::saveSuggestImg('fileData'); 360 $result = UserModel::saveSuggestImg('fileData');
379 361
@@ -383,8 +365,7 @@ class HomeController extends AbstractAction @@ -383,8 +365,7 @@ class HomeController extends AbstractAction
383 /** 365 /**
384 * 异步保存意见反馈数据 366 * 异步保存意见反馈数据
385 */ 367 */
386 - public function savesuggestAction()  
387 - { 368 + public function savesuggestAction() {
388 if ($this->isAjax()) { 369 if ($this->isAjax()) {
389 $uid = $this->getUid(); 370 $uid = $this->getUid();
390 $content = $this->post('content', ''); 371 $content = $this->post('content', '');
@@ -399,8 +380,7 @@ class HomeController extends AbstractAction @@ -399,8 +380,7 @@ class HomeController extends AbstractAction
399 /** 380 /**
400 * 异步点击靠谱或者不靠谱 381 * 异步点击靠谱或者不靠谱
401 */ 382 */
402 - public function upAndDownAction()  
403 - { 383 + public function upAndDownAction() {
404 if ($this->isAjax()) { 384 if ($this->isAjax()) {
405 $uid = $this->getUid(); 385 $uid = $this->getUid();
406 $udid = $this->getUdid(); 386 $udid = $this->getUdid();
@@ -414,8 +394,7 @@ class HomeController extends AbstractAction @@ -414,8 +394,7 @@ class HomeController extends AbstractAction
414 /** 394 /**
415 * 会员等级展示页 395 * 会员等级展示页
416 */ 396 */
417 - public function gradeAction()  
418 - { 397 + public function gradeAction() {
419 //设置网站seo信息 398 //设置网站seo信息
420 $this->setTitle('会员等级'); 399 $this->setTitle('会员等级');
421 //显示网站导航头部信息 400 //显示网站导航头部信息
@@ -430,8 +409,8 @@ class HomeController extends AbstractAction @@ -430,8 +409,8 @@ class HomeController extends AbstractAction
430 /* 409 /*
431 * 会员特权查看页 410 * 会员特权查看页
432 */ 411 */
433 - public function preferentialAction()  
434 - { 412 +
  413 + public function preferentialAction() {
435 //设置网站seo信息 414 //设置网站seo信息
436 $this->setTitle('会员等级'); 415 $this->setTitle('会员等级');
437 //显示网站导航头部信息 416 //显示网站导航头部信息
@@ -445,8 +424,8 @@ class HomeController extends AbstractAction @@ -445,8 +424,8 @@ class HomeController extends AbstractAction
445 /* 424 /*
446 * 我的订单页面,获得nav导航条焦点。并且异步请求订单详情列表页(getOrders) 425 * 我的订单页面,获得nav导航条焦点。并且异步请求订单详情列表页(getOrders)
447 */ 426 */
448 - public function orderAction()  
449 - { 427 +
  428 + public function orderAction() {
450 //获得type值,type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论。 429 //获得type值,type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论。
451 $type = $this->get('type', 1); 430 $type = $this->get('type', 1);
452 $this->setTitle('我的订单'); 431 $this->setTitle('我的订单');
@@ -466,17 +445,17 @@ class HomeController extends AbstractAction @@ -466,17 +445,17 @@ class HomeController extends AbstractAction
466 } 445 }
467 446
468 //ajax请求订单页面 447 //ajax请求订单页面
469 - public function getOrdersAction()  
470 - { 448 + public function getOrdersAction() {
471 //判断是不是ajax请求 449 //判断是不是ajax请求
472 if (!$this->isAjax()) { 450 if (!$this->isAjax()) {
473 $this->error(); 451 $this->error();
474 } 452 }
475 - //获取基本参数:type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论 453 + //获取基本参数:type 1:全部 2:待付款 3:待发货 4:待收货 5:待评论 7:失败 取消 订单
476 $type = $this->get('type', 1); 454 $type = $this->get('type', 1);
477 $page = $this->get('page', 1); 455 $page = $this->get('page', 1);
478 $limit = $this->get('limit', 10); 456 $limit = $this->get('limit', 10);
479 $uid = $this->getUid(); 457 $uid = $this->getUid();
  458 + $uid = '12';//测试数据
480 //调用模型层getOrder方法获得并处理数据 459 //调用模型层getOrder方法获得并处理数据
481 $data = OrderModel::getOrder($type, $page, $limit, $uid); 460 $data = OrderModel::getOrder($type, $page, $limit, $uid);
482 /* 如果取不到订单数据时,分两种情况: 461 /* 如果取不到订单数据时,分两种情况:
@@ -501,8 +480,7 @@ class HomeController extends AbstractAction @@ -501,8 +480,7 @@ class HomeController extends AbstractAction
501 * 我的订单-取消订单 480 * 我的订单-取消订单
502 */ 481 */
503 482
504 - public function cancelOrderAction()  
505 - { 483 + public function cancelOrderAction() {
506 484
507 //判断是不是ajax请求 485 //判断是不是ajax请求
508 if (!$this->isAjax()) { 486 if (!$this->isAjax()) {
@@ -524,8 +502,7 @@ class HomeController extends AbstractAction @@ -524,8 +502,7 @@ class HomeController extends AbstractAction
524 * 我的订单-删除订单 502 * 我的订单-删除订单
525 */ 503 */
526 504
527 - public function delOrderAction()  
528 - { 505 + public function delOrderAction() {
529 //判断是不是ajax请求 506 //判断是不是ajax请求
530 if (!$this->isAjax()) { 507 if (!$this->isAjax()) {
531 $this->error(); 508 $this->error();
@@ -546,8 +523,7 @@ class HomeController extends AbstractAction @@ -546,8 +523,7 @@ class HomeController extends AbstractAction
546 * 我的订单-支付链接获取 523 * 我的订单-支付链接获取
547 */ 524 */
548 525
549 - private function paymentAction()  
550 - { 526 + private function paymentAction() {
551 $gender = Helpers::getGenderByCookie(); 527 $gender = Helpers::getGenderByCookie();
552 $yh_channel = $this->get('yh_channel', 1); 528 $yh_channel = $this->get('yh_channel', 1);
553 OrderModel::payment($gender, $yh_channel); 529 OrderModel::payment($gender, $yh_channel);
@@ -557,8 +533,7 @@ class HomeController extends AbstractAction @@ -557,8 +533,7 @@ class HomeController extends AbstractAction
557 * 我的订单-随便逛逛链接获取 533 * 我的订单-随便逛逛链接获取
558 */ 534 */
559 535
560 - private function strollAction()  
561 - { 536 + private function strollAction() {
562 //获取性别、频道数据 537 //获取性别、频道数据
563 $gender = Helpers::getGenderByCookie(); 538 $gender = Helpers::getGenderByCookie();
564 $yh_channel = $this->get('yh_channel', 1); 539 $yh_channel = $this->get('yh_channel', 1);
@@ -570,8 +545,7 @@ class HomeController extends AbstractAction @@ -570,8 +545,7 @@ class HomeController extends AbstractAction
570 /** 545 /**
571 * 订单详情页 546 * 订单详情页
572 */ 547 */
573 - public function orderDetailAction()  
574 - { 548 + public function orderDetailAction() {
575 $data = array( 549 $data = array(
576 'name' => '毛毛莉Lydia', 550 'name' => '毛毛莉Lydia',
577 'phoneNum' => '18600001133', 551 'phoneNum' => '18600001133',
@@ -40,27 +40,72 @@ class OrderModel @@ -40,27 +40,72 @@ class OrderModel
40 } 40 }
41 //调用接口获得数据 41 //调用接口获得数据
42 $data = OrderData::getOrderData($type, $page, $limit, $uid); 42 $data = OrderData::getOrderData($type, $page, $limit, $uid);
43 - print_r($data);  
44 //检查数据返回是否正常,正常则处理数据 43 //检查数据返回是否正常,正常则处理数据
45 if (!empty($data[0])) { 44 if (!empty($data[0])) {
46 $result = array(); 45 $result = array();
47 - foreach($data as $key => $vo){  
48 - $result[$key]['detailUrl'] = $vo['']; 46 + foreach ($data as $key => $vo) {
  47 + if (empty($vo['ordersGoodsList'])) {
  48 + break;
  49 + }
  50 + $result[$key]['goods'] = self::formatOrderGoods($vo['ordersGoodsList']);
  51 + $result[$key]['detailUrl'] = '???';
49 $result[$key]['orderNum'] = $vo['orderCode']; 52 $result[$key]['orderNum'] = $vo['orderCode'];
50 - $result[$key]['orderStatus'] = $vo['status'];  
51 $result[$key]['count'] = count($vo['ordersGoodsList']); 53 $result[$key]['count'] = count($vo['ordersGoodsList']);
52 - $result[$key]['sumCost'] = $vo['amount'];  
53 - $result[$key]['sumCost'] = $vo['amount'];  
54 - switch ($vo['status']) { 54 + $result[$key]['sumCost'] = $vo['goodsTotalAmount'];
  55 + do {
  56 + if ($vo['isCancel'] === 'Y') {
  57 + $result[$key]['canceled'] = true;
  58 + $result[$key]['orderStatus'] = '已取消';
  59 + break;
  60 + }
  61 + if ($vo['paymentType'] != 2) {
  62 + switch ($vo['ordersStatus']) {
  63 + case 0:
  64 + $result[$key]['unpaid'] = true;
  65 + $result[$key]['orderStatus'] = '待付款';
  66 + break;
  67 + //未发货&未收货 状态,统一合并到待收货状态。
55 case 1: 68 case 1:
56 - $result[$key]['sumCost'] = $vo['amount'];  
57 - 69 + case 2:
  70 + case 3:
  71 + $result[$key]['orderStatus'] = '已付款';
  72 + $result[$key]['unreceived'] = true;
  73 + break;
  74 + case 4:
  75 + case 5:
  76 + $result[$key]['orderStatus'] = '已发货';
  77 + $result[$key]['unreceived'] = true;
  78 + //待收货状态,给查看物流url
  79 + $result[$key]['logisticsUrl'] = "暂无logisticsUrl数据";
  80 + break;
  81 + case 6:
  82 + $result[$key]['orderStatus'] = '交易成功';
  83 + $result[$key]['completed'] = true;
58 break; 84 break;
59 -  
60 default: 85 default:
61 break; 86 break;
62 } 87 }
63 - $result[$key]['sumCost'] = $vo['amount']; 88 + } elseif ($vo['paymentType'] == 2) {
  89 + switch ($vo['ordersStatus']) {
  90 + case 0:
  91 + case 1:
  92 + case 2:
  93 + case 3:
  94 + case 4:
  95 + case 5:
  96 + $result[$key]['orderStatus'] = '备货中';
  97 + $result[$key]['unreceived'] = true;
  98 + //待收货状态,给查看物流url
  99 + $result[$key]['logisticsUrl'] = "暂无logisticsUrl数据";
  100 + break;
  101 + case 6:
  102 + $result[$key]['completed'] = true;
  103 + break;
  104 + default:
  105 + break;
  106 + }
  107 + }
  108 + } while (false);
64 } 109 }
65 } 110 }
66 111
@@ -78,20 +123,33 @@ class OrderModel @@ -78,20 +123,33 @@ class OrderModel
78 } 123 }
79 124
80 //格式化订单商品 125 //格式化订单商品
81 - static function formatOrderGoods($orderGoods) { 126 + static function formatOrderGoods($ordersGoodsList) {
82 $arr = array(); 127 $arr = array();
83 - foreach ($orderGoods as $key => $vo) {  
84 - $arr[$key]['thumb'] = Helpers::getImageUrl($vo['goods_image'], 90, 120);  
85 - $arr[$key]['name'] = $vo['product_name'];  
86 - $arr[$key]['color'] = $vo['color_name'];  
87 - $arr[$key]['size'] = $vo['size_name'];  
88 - $arr[$key]['price'] = $vo['goods_price'];  
89 - $arr[$key]['count'] = $vo['buy_number']; 128 + foreach ($ordersGoodsList as $key => $vo) {
  129 + $arr[$key]['thumb'] = Helpers::getImageUrl($vo['goodsImg'][0]['imageUrl'], 90, 120);
  130 + $arr[$key]['name'] = $vo['goodsName'];
  131 + $arr[$key]['color'] = $vo['colorName'];
  132 + $arr[$key]['size'] = $vo['sizeName'];
  133 + $arr[$key]['price'] = $vo['goodsPrice'];
  134 + $arr[$key]['count'] = $vo['num'];
90 //gift=>是否赠品,advanceBuy=>是否加价购; 135 //gift=>是否赠品,advanceBuy=>是否加价购;
91 - if ($vo['goods_type'] == 'gift') { 136 + switch ($vo['goodsType']) {
  137 + case 1://普通商品
  138 + break;
  139 + case 2://商品的赠品
92 $arr[$key]['gift'] = true; 140 $arr[$key]['gift'] = true;
93 - } elseif ($vo['goods_type'] == 'price_gift') { 141 + break;
  142 + case 3://订单的赠品
  143 + $arr[$key]['gift'] = true;
  144 + break;
  145 + case 4://商品满足条件加钱送
  146 + $arr[$key]['advanceBuy'] = true;
  147 + break;
  148 + case 5://订单满足条件价钱送
94 $arr[$key]['advanceBuy'] = true; 149 $arr[$key]['advanceBuy'] = true;
  150 + break;
  151 + default:
  152 + break;
95 } 153 }
96 } 154 }
97 return $arr; 155 return $arr;