Authored by yangyang

home中增加了取消订单,删除订单控制器,和接口处理

@@ -39,4 +39,39 @@ class OrderData @@ -39,4 +39,39 @@ class OrderData
39 return Yohobuy::get(Yohobuy::API_URL2, $param); 39 return Yohobuy::get(Yohobuy::API_URL2, $param);
40 } 40 }
41 41
  42 + /*
  43 + * 取消订单
  44 + * To change this template file, choose Tools | Templates
  45 + * and open the template in the editor.
  46 + */
  47 +
  48 + public function cancelOrderData($order_code, $uid, $gender, $yh_channel, $method) {
  49 + $param = Yohobuy::param();
  50 + $param['order_code'] = $order_code;
  51 + $param['uid'] = $uid;
  52 + $param['gender'] = $gender;
  53 + $param['yh_channel'] = $yh_channel;
  54 + $param['method'] = $method;
  55 + $param['client_secret'] = Sign::getSign($param);
  56 + return Yohobuy::get(Yohobuy::API_URL, $param);
  57 + }
  58 +
  59 + /*
  60 + * 删除订单
  61 + * To change this template file, choose Tools | Templates
  62 + * and open the template in the editor.
  63 + */
  64 +
  65 + public function deleteOrderData($order_code, $uid, $gender, $yh_channel, $method) {
  66 + $param = Yohobuy::param();
  67 + $param['order_code'] = $order_code;
  68 + $param['uid'] = $uid;
  69 + $param['gender'] = $gender;
  70 + $param['yh_channel'] = $yh_channel;
  71 + $param['method'] = $method;
  72 + $param['client_secret'] = Sign::getSign($param);
  73 +
  74 + return Yohobuy::get(Yohobuy::API_URL, $param);
  75 + }
  76 +
42 } 77 }
@@ -4,6 +4,7 @@ use Action\AbstractAction; @@ -4,6 +4,7 @@ use Action\AbstractAction;
4 use home\GradeModel; 4 use home\GradeModel;
5 use home\OrderModel; 5 use home\OrderModel;
6 use Plugin\Helpers; 6 use Plugin\Helpers;
  7 +use LibModels\Wap\Home\OrderData;
7 8
8 /** 9 /**
9 * 个人中心相关的控制器 10 * 个人中心相关的控制器
@@ -44,8 +45,7 @@ class HomeController extends AbstractAction @@ -44,8 +45,7 @@ class HomeController extends AbstractAction
44 /** 45 /**
45 * 用户订单 46 * 用户订单
46 */ 47 */
47 - public function ordersAction()  
48 - { 48 + public function ordersAction() {
49 // 设置网站标题 49 // 设置网站标题
50 $this->setTitle('我的订单'); 50 $this->setTitle('我的订单');
51 $this->setNavHeader('我的订单', true, SITE_MAIN); 51 $this->setNavHeader('我的订单', true, SITE_MAIN);
@@ -131,7 +131,7 @@ class HomeController extends AbstractAction @@ -131,7 +131,7 @@ class HomeController extends AbstractAction
131 ), 131 ),
132 'hasFavBrand' => array( 132 'hasFavBrand' => array(
133 '0' => array( 133 '0' => array(
134 - 'id'=> '1', 134 + 'id' => '1',
135 'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', 135 'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
136 'brandName' => 'VANS', 136 'brandName' => 'VANS',
137 'update' => 12, 137 'update' => 12,
@@ -161,7 +161,7 @@ class HomeController extends AbstractAction @@ -161,7 +161,7 @@ class HomeController extends AbstractAction
161 ) 161 )
162 ), 162 ),
163 '1' => array( 163 '1' => array(
164 - 'id'=> '2', 164 + 'id' => '2',
165 'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', 165 'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
166 'brandName' => 'VANS', 166 'brandName' => 'VANS',
167 'update' => 12, 167 'update' => 12,
@@ -191,7 +191,7 @@ class HomeController extends AbstractAction @@ -191,7 +191,7 @@ class HomeController extends AbstractAction
191 ) 191 )
192 ), 192 ),
193 '2' => array( 193 '2' => array(
194 - 'id'=> '3', 194 + 'id' => '3',
195 'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', 195 'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
196 'brandName' => 'VANS', 196 'brandName' => 'VANS',
197 'update' => 12, 197 'update' => 12,
@@ -441,12 +441,10 @@ class HomeController extends AbstractAction @@ -441,12 +441,10 @@ class HomeController extends AbstractAction
441 )); 441 ));
442 } 442 }
443 443
444 -  
445 /** 444 /**
446 * 意见反馈-提交表单 445 * 意见反馈-提交表单
447 */ 446 */
448 - public function suggest_subAction()  
449 - { 447 + public function suggest_subAction() {
450 $udid = $this->getUdid(); 448 $udid = $this->getUdid();
451 $page = $this->get('page', 1); 449 $page = $this->get('page', 1);
452 $limit = $this->get('limit', 30); 450 $limit = $this->get('limit', 30);
@@ -464,15 +462,13 @@ class HomeController extends AbstractAction @@ -464,15 +462,13 @@ class HomeController extends AbstractAction
464 'suggestSub' => true, 462 'suggestSub' => true,
465 'pageFooter' => true 463 'pageFooter' => true
466 )); 464 ));
467 -  
468 } 465 }
469 466
470 /** 467 /**
471 * 异步保存意见反馈数据 468 * 异步保存意见反馈数据
472 */ 469 */
473 - public function savesuggestAction()  
474 - {  
475 - if($this->isAjax()) { 470 + public function savesuggestAction() {
  471 + if ($this->isAjax()) {
476 $uid = $this->getUid(); 472 $uid = $this->getUid();
477 $content = $this->post('content', ''); 473 $content = $this->post('content', '');
478 $suggest_type = $this->get('suggest_type', 2); 474 $suggest_type = $this->get('suggest_type', 2);
@@ -503,6 +499,7 @@ class HomeController extends AbstractAction @@ -503,6 +499,7 @@ class HomeController extends AbstractAction
503 /* 499 /*
504 * 会员特权查看页 500 * 会员特权查看页
505 */ 501 */
  502 +
506 public function preferentialAction() { 503 public function preferentialAction() {
507 //设置网站seo信息 504 //设置网站seo信息
508 $this->setTitle('会员等级'); 505 $this->setTitle('会员等级');
@@ -519,7 +516,12 @@ class HomeController extends AbstractAction @@ -519,7 +516,12 @@ class HomeController extends AbstractAction
519 /* 516 /*
520 * 我的订单页面 517 * 我的订单页面
521 */ 518 */
  519 +
522 public function orderAction() { 520 public function orderAction() {
  521 + //判断是不是ajax请求
  522 + if (!$this->isAjax()) {
  523 + $this->error();
  524 + }
523 //获取基本参数:type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论 525 //获取基本参数:type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论
524 $type = $this->get('type', 1); 526 $type = $this->get('type', 1);
525 $page = $this->get('page', 1); 527 $page = $this->get('page', 1);
@@ -528,8 +530,8 @@ class HomeController extends AbstractAction @@ -528,8 +530,8 @@ class HomeController extends AbstractAction
528 $yh_channel = $this->get('yh_channel', 1); 530 $yh_channel = $this->get('yh_channel', 1);
529 $uid = $this->getUid(); 531 $uid = $this->getUid();
530 $uid = '7566245'; //测试用 532 $uid = '7566245'; //测试用
531 - $this -> setTitle('我的订单');  
532 - $this -> setNavHeader('我的订单'); 533 + $this->setTitle('我的订单');
  534 + $this->setNavHeader('我的订单');
533 //调用模型层getOrder方法获得并处理数据 535 //调用模型层getOrder方法获得并处理数据
534 $data = OrderModel::getOrder($type, $page, $limit, $gender, $yh_channel, $uid); 536 $data = OrderModel::getOrder($type, $page, $limit, $gender, $yh_channel, $uid);
535 //如果没有订单数据,就给一个随便逛逛链接 537 //如果没有订单数据,就给一个随便逛逛链接
@@ -549,15 +551,48 @@ class HomeController extends AbstractAction @@ -549,15 +551,48 @@ class HomeController extends AbstractAction
549 } 551 }
550 552
551 /* 553 /*
552 - * 我的订单-处理ajax请求页面(切换订单状态) 554 + * 我的订单-取消订单
  555 + */
  556 +
  557 + public function cancelOrderAction() {
  558 +
  559 + //判断是不是ajax请求
  560 + if (!$this->isAjax()) {
  561 + $this->error();
  562 + }
  563 + //传入order_code和uid以取消订单
  564 + $order_code = $this->get('orderCode');
  565 + $uid = $this->getUid();
  566 + $uid = '10267443'; //测试用
  567 + $gender = Helpers::getGenderByCookie();
  568 + $yh_channel = $this->get('yh_channel', 1);
  569 + $method = 'app.SpaceOrders.close';
  570 + $data = OrderData::cancelOrderData($order_code, $uid, $gender, $yh_channel, $method);
  571 + if ($data['code'] == 200) {
  572 + echo $data['message'];
  573 + }
  574 + }
  575 +
  576 + /*
  577 + * 我的订单-删除订单
553 */ 578 */
554 - public function getOrdersAction() {  
555 579
  580 + public function deleteOrderAction() {
556 //判断是不是ajax请求 581 //判断是不是ajax请求
557 if (!$this->isAjax()) { 582 if (!$this->isAjax()) {
558 $this->error(); 583 $this->error();
559 } 584 }
560 - self::orderAction(); 585 + //传入order_code和uid以删除订单
  586 + $order_code = $this->get('orderCode');
  587 + $uid = $this->getUid();
  588 + $uid = '10267443'; //测试用
  589 + $gender = Helpers::getGenderByCookie();
  590 + $yh_channel = $this->get('yh_channel', 1);
  591 + $method = 'app.SpaceOrders.delOrderByCode';
  592 + $data = OrderData::deleteOrderData($order_code, $uid, $gender, $yh_channel, $method);
  593 + if ($data['code'] == 200) {
  594 + echo $data['message'];
  595 + }
561 } 596 }
562 597
563 } 598 }