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 * 个人中心相关的控制器
@@ -25,10 +26,10 @@ class HomeController extends AbstractAction @@ -25,10 +26,10 @@ class HomeController extends AbstractAction
25 $this->setTitle('个人中心'); 26 $this->setTitle('个人中心');
26 $this->setNavHeader('个人中心', true, SITE_MAIN); 27 $this->setNavHeader('个人中心', true, SITE_MAIN);
27 28
28 - // $uid = $this->getUid();  
29 - $uid = 8826435;  
30 - $data = \Index\UserModel::getUserProfileData($uid);  
31 - $data += \Index\UserModel::getInfoNumData($uid); 29 + // $uid = $this->getUid();
  30 + $uid = 8826435;
  31 + $data = \Index\UserModel::getUserProfileData($uid);
  32 + $data += \Index\UserModel::getInfoNumData($uid);
32 33
33 // 优选新品数据 34 // 优选新品数据
34 $channel = Helpers::getChannelByCookie(); 35 $channel = Helpers::getChannelByCookie();
@@ -41,56 +42,55 @@ class HomeController extends AbstractAction @@ -41,56 +42,55 @@ class HomeController extends AbstractAction
41 $this->_view->display('index', $data); 42 $this->_view->display('index', $data);
42 } 43 }
43 44
44 - /**  
45 - * 用户订单  
46 - */  
47 - public function ordersAction()  
48 - {  
49 - // 设置网站标题  
50 - $this->setTitle('我的订单');  
51 - $this->setNavHeader('我的订单', true, SITE_MAIN);  
52 -  
53 - $uid = $this->getUid();  
54 - $uid = 8826435;  
55 - $type = $this->get('type', 1);  
56 -  
57 - $order = \Index\UserModel::getUserOrderData($uid, $type);  
58 -  
59 - $order = array(  
60 - 'orders' => array(  
61 - array(  
62 - 'orderNum' => '408539077',  
63 - 'tradingStatus' => '交易成功',  
64 - 'goods' => array(  
65 - array(  
66 - 'id' => 1,  
67 - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',  
68 - 'name' => 'Adidas Originals ZX FLUXM22508',  
69 - 'color' => '黄',  
70 - 'size' => '43',  
71 - 'price' => '699.00',  
72 - 'count' => '2'  
73 - ),  
74 - array(  
75 - 'id' => 1,  
76 - 'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',  
77 - 'name' => 'B.Duck浴室玩伴mini浮水鸭',  
78 - 'gift' => true,  
79 - 'color' => '黄',  
80 - 'size' => '43',  
81 - 'price' => '0.00',  
82 - 'count' => '1'  
83 - )  
84 - ),  
85 - 'count' => 2,  
86 - 'sumCost' => '699.00',  
87 - 'unpaid' => true,  
88 - )  
89 - )  
90 - );  
91 -  
92 - $this->_view->display('order', array('order' => $order, 'orderPage' => true));  
93 - } 45 + /**
  46 + * 用户订单
  47 + */
  48 + public function ordersAction() {
  49 + // 设置网站标题
  50 + $this->setTitle('我的订单');
  51 + $this->setNavHeader('我的订单', true, SITE_MAIN);
  52 +
  53 + $uid = $this->getUid();
  54 + $uid = 8826435;
  55 + $type = $this->get('type', 1);
  56 +
  57 + $order = \Index\UserModel::getUserOrderData($uid, $type);
  58 +
  59 + $order = array(
  60 + 'orders' => array(
  61 + array(
  62 + 'orderNum' => '408539077',
  63 + 'tradingStatus' => '交易成功',
  64 + 'goods' => array(
  65 + array(
  66 + 'id' => 1,
  67 + 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
  68 + 'name' => 'Adidas Originals ZX FLUXM22508',
  69 + 'color' => '黄',
  70 + 'size' => '43',
  71 + 'price' => '699.00',
  72 + 'count' => '2'
  73 + ),
  74 + array(
  75 + 'id' => 1,
  76 + 'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
  77 + 'name' => 'B.Duck浴室玩伴mini浮水鸭',
  78 + 'gift' => true,
  79 + 'color' => '黄',
  80 + 'size' => '43',
  81 + 'price' => '0.00',
  82 + 'count' => '1'
  83 + )
  84 + ),
  85 + 'count' => 2,
  86 + 'sumCost' => '699.00',
  87 + 'unpaid' => true,
  88 + )
  89 + )
  90 + );
  91 +
  92 + $this->_view->display('order', array('order' => $order, 'orderPage' => true));
  93 + }
94 94
95 /** 95 /**
96 * 用户收藏的商品 96 * 用户收藏的商品
@@ -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,
@@ -244,18 +244,18 @@ class HomeController extends AbstractAction @@ -244,18 +244,18 @@ class HomeController extends AbstractAction
244 $currency = \Index\UserModel::getYohoCoinData($uid); 244 $currency = \Index\UserModel::getYohoCoinData($uid);
245 245
246 $this->setTitle('优惠券'); 246 $this->setTitle('优惠券');
247 - $this->setNavHeader('优惠券', true, SITE_MAIN);  
248 - // $uid = $this->getUid();  
249 - $uid = 8826435;  
250 - $coupons = array(  
251 - 'couponsUrl' => array(  
252 - \Index\UserModel::getCouponData($uid, 0),  
253 - \Index\UserModel::getCouponData($uid, 1),  
254 - ),  
255 - 'couponsPage' => true  
256 - );  
257 -  
258 - print_r($coupons); 247 + $this->setNavHeader('优惠券', true, SITE_MAIN);
  248 + // $uid = $this->getUid();
  249 + $uid = 8826435;
  250 + $coupons = array(
  251 + 'couponsUrl' => array(
  252 + \Index\UserModel::getCouponData($uid, 0),
  253 + \Index\UserModel::getCouponData($uid, 1),
  254 + ),
  255 + 'couponsPage' => true
  256 + );
  257 +
  258 + print_r($coupons);
259 $this->_view->display('coupons', $coupons); 259 $this->_view->display('coupons', $coupons);
260 } 260 }
261 261
@@ -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,18 +462,16 @@ class HomeController extends AbstractAction @@ -464,18 +462,16 @@ class HomeController extends AbstractAction
464 'suggestSub' => true, 462 'suggestSub' => true,
465 'pageFooter' => true 463 'pageFooter' => true
466 )); 464 ));
467 -  
468 } 465 }
469 466
470 - /**  
471 - * 异步保存意见反馈数据  
472 - */  
473 - public function savesuggestAction()  
474 - {  
475 - if($this->isAjax()) {  
476 - $uid = $this->getUid();  
477 - $content = $this->post('content', '');  
478 - $suggest_type = $this->get('suggest_type', 2); 467 + /**
  468 + * 异步保存意见反馈数据
  469 + */
  470 + public function savesuggestAction() {
  471 + if ($this->isAjax()) {
  472 + $uid = $this->getUid();
  473 + $content = $this->post('content', '');
  474 + $suggest_type = $this->get('suggest_type', 2);
479 $result = \Index\UserModel::saveSuggestData($uid, $content, $suggest_type); 475 $result = \Index\UserModel::saveSuggestData($uid, $content, $suggest_type);
480 476
481 $this->echoJson($result); 477 $this->echoJson($result);
@@ -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 //如果没有订单数据,就给一个随便逛逛链接
@@ -537,7 +539,7 @@ class HomeController extends AbstractAction @@ -537,7 +539,7 @@ class HomeController extends AbstractAction
537 if (!empty($data)) { 539 if (!empty($data)) {
538 $order['orders'] = $data; 540 $order['orders'] = $data;
539 } else { 541 } else {
540 - $order['walkwayUrl'] = 'http://www.baidu.com'; 542 + $order['walkwayUrl'] = 'http://www.baidu.com';
541 } 543 }
542 544
543 //渲染模板 545 //渲染模板
@@ -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 }