From 2843e5651b0ff2ea19dfd271a25e26f1ede5a822 Mon Sep 17 00:00:00 2001 From: yangyang <781760363@qq.com> Date: Tue, 17 Nov 2015 11:40:47 +0800 Subject: [PATCH] home中增加了取消订单,删除订单控制器,和接口处理 --- library/LibModels/Wap/Home/OrderData.php | 35 +++++++++++++++++++++++++++++++++++ yohobuy/m.yohobuy.com/application/controllers/Home.php | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------- 2 files changed, 158 insertions(+), 88 deletions(-) diff --git a/library/LibModels/Wap/Home/OrderData.php b/library/LibModels/Wap/Home/OrderData.php index 2ad1990..7b0c1ce 100644 --- a/library/LibModels/Wap/Home/OrderData.php +++ b/library/LibModels/Wap/Home/OrderData.php @@ -39,4 +39,39 @@ class OrderData return Yohobuy::get(Yohobuy::API_URL2, $param); } + /* + * 取消订单 + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + + public function cancelOrderData($order_code, $uid, $gender, $yh_channel, $method) { + $param = Yohobuy::param(); + $param['order_code'] = $order_code; + $param['uid'] = $uid; + $param['gender'] = $gender; + $param['yh_channel'] = $yh_channel; + $param['method'] = $method; + $param['client_secret'] = Sign::getSign($param); + return Yohobuy::get(Yohobuy::API_URL, $param); + } + + /* + * 删除订单 + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + + public function deleteOrderData($order_code, $uid, $gender, $yh_channel, $method) { + $param = Yohobuy::param(); + $param['order_code'] = $order_code; + $param['uid'] = $uid; + $param['gender'] = $gender; + $param['yh_channel'] = $yh_channel; + $param['method'] = $method; + $param['client_secret'] = Sign::getSign($param); + + return Yohobuy::get(Yohobuy::API_URL, $param); + } + } diff --git a/yohobuy/m.yohobuy.com/application/controllers/Home.php b/yohobuy/m.yohobuy.com/application/controllers/Home.php index b1c5670..6e46353 100644 --- a/yohobuy/m.yohobuy.com/application/controllers/Home.php +++ b/yohobuy/m.yohobuy.com/application/controllers/Home.php @@ -4,6 +4,7 @@ use Action\AbstractAction; use home\GradeModel; use home\OrderModel; use Plugin\Helpers; +use LibModels\Wap\Home\OrderData; /** * 个人中心相关的控制器 @@ -25,10 +26,10 @@ class HomeController extends AbstractAction $this->setTitle('个人中心'); $this->setNavHeader('个人中心', true, SITE_MAIN); - // $uid = $this->getUid(); - $uid = 8826435; - $data = \Index\UserModel::getUserProfileData($uid); - $data += \Index\UserModel::getInfoNumData($uid); + // $uid = $this->getUid(); + $uid = 8826435; + $data = \Index\UserModel::getUserProfileData($uid); + $data += \Index\UserModel::getInfoNumData($uid); // 优选新品数据 $channel = Helpers::getChannelByCookie(); @@ -41,56 +42,55 @@ class HomeController extends AbstractAction $this->_view->display('index', $data); } - /** - * 用户订单 - */ - public function ordersAction() - { - // 设置网站标题 - $this->setTitle('我的订单'); - $this->setNavHeader('我的订单', true, SITE_MAIN); - - $uid = $this->getUid(); - $uid = 8826435; - $type = $this->get('type', 1); - - $order = \Index\UserModel::getUserOrderData($uid, $type); - - $order = array( - 'orders' => array( - array( - 'orderNum' => '408539077', - 'tradingStatus' => '交易成功', - 'goods' => array( - array( - 'id' => 1, - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', - 'name' => 'Adidas Originals ZX FLUXM22508', - 'color' => '黄', - 'size' => '43', - 'price' => '699.00', - 'count' => '2' - ), - array( - 'id' => 1, - 'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', - 'name' => 'B.Duck浴室玩伴mini浮水鸭', - 'gift' => true, - 'color' => '黄', - 'size' => '43', - 'price' => '0.00', - 'count' => '1' - ) - ), - 'count' => 2, - 'sumCost' => '699.00', - 'unpaid' => true, - ) - ) - ); - - $this->_view->display('order', array('order' => $order, 'orderPage' => true)); - } + /** + * 用户订单 + */ + public function ordersAction() { + // 设置网站标题 + $this->setTitle('我的订单'); + $this->setNavHeader('我的订单', true, SITE_MAIN); + + $uid = $this->getUid(); + $uid = 8826435; + $type = $this->get('type', 1); + + $order = \Index\UserModel::getUserOrderData($uid, $type); + + $order = array( + 'orders' => array( + array( + 'orderNum' => '408539077', + 'tradingStatus' => '交易成功', + 'goods' => array( + array( + 'id' => 1, + 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', + 'name' => 'Adidas Originals ZX FLUXM22508', + 'color' => '黄', + 'size' => '43', + 'price' => '699.00', + 'count' => '2' + ), + array( + 'id' => 1, + 'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', + 'name' => 'B.Duck浴室玩伴mini浮水鸭', + 'gift' => true, + 'color' => '黄', + 'size' => '43', + 'price' => '0.00', + 'count' => '1' + ) + ), + 'count' => 2, + 'sumCost' => '699.00', + 'unpaid' => true, + ) + ) + ); + + $this->_view->display('order', array('order' => $order, 'orderPage' => true)); + } /** * 用户收藏的商品 @@ -131,7 +131,7 @@ class HomeController extends AbstractAction ), 'hasFavBrand' => array( '0' => array( - 'id'=> '1', + 'id' => '1', 'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', 'brandName' => 'VANS', 'update' => 12, @@ -161,7 +161,7 @@ class HomeController extends AbstractAction ) ), '1' => array( - 'id'=> '2', + 'id' => '2', 'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', 'brandName' => 'VANS', 'update' => 12, @@ -191,7 +191,7 @@ class HomeController extends AbstractAction ) ), '2' => array( - 'id'=> '3', + 'id' => '3', 'brandImg' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', 'brandName' => 'VANS', 'update' => 12, @@ -244,18 +244,18 @@ class HomeController extends AbstractAction $currency = \Index\UserModel::getYohoCoinData($uid); $this->setTitle('优惠券'); - $this->setNavHeader('优惠券', true, SITE_MAIN); - // $uid = $this->getUid(); - $uid = 8826435; - $coupons = array( - 'couponsUrl' => array( - \Index\UserModel::getCouponData($uid, 0), - \Index\UserModel::getCouponData($uid, 1), - ), - 'couponsPage' => true - ); - - print_r($coupons); + $this->setNavHeader('优惠券', true, SITE_MAIN); + // $uid = $this->getUid(); + $uid = 8826435; + $coupons = array( + 'couponsUrl' => array( + \Index\UserModel::getCouponData($uid, 0), + \Index\UserModel::getCouponData($uid, 1), + ), + 'couponsPage' => true + ); + + print_r($coupons); $this->_view->display('coupons', $coupons); } @@ -441,12 +441,10 @@ class HomeController extends AbstractAction )); } - /** * 意见反馈-提交表单 */ - public function suggest_subAction() - { + public function suggest_subAction() { $udid = $this->getUdid(); $page = $this->get('page', 1); $limit = $this->get('limit', 30); @@ -464,18 +462,16 @@ class HomeController extends AbstractAction 'suggestSub' => true, 'pageFooter' => true )); - } - /** - * 异步保存意见反馈数据 - */ - public function savesuggestAction() - { - if($this->isAjax()) { - $uid = $this->getUid(); - $content = $this->post('content', ''); - $suggest_type = $this->get('suggest_type', 2); + /** + * 异步保存意见反馈数据 + */ + public function savesuggestAction() { + if ($this->isAjax()) { + $uid = $this->getUid(); + $content = $this->post('content', ''); + $suggest_type = $this->get('suggest_type', 2); $result = \Index\UserModel::saveSuggestData($uid, $content, $suggest_type); $this->echoJson($result); @@ -503,6 +499,7 @@ class HomeController extends AbstractAction /* * 会员特权查看页 */ + public function preferentialAction() { //设置网站seo信息 $this->setTitle('会员等级'); @@ -519,7 +516,12 @@ class HomeController extends AbstractAction /* * 我的订单页面 */ + public function orderAction() { + //判断是不是ajax请求 + if (!$this->isAjax()) { + $this->error(); + } //获取基本参数:type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论 $type = $this->get('type', 1); $page = $this->get('page', 1); @@ -528,8 +530,8 @@ class HomeController extends AbstractAction $yh_channel = $this->get('yh_channel', 1); $uid = $this->getUid(); $uid = '7566245'; //测试用 - $this -> setTitle('我的订单'); - $this -> setNavHeader('我的订单'); + $this->setTitle('我的订单'); + $this->setNavHeader('我的订单'); //调用模型层getOrder方法获得并处理数据 $data = OrderModel::getOrder($type, $page, $limit, $gender, $yh_channel, $uid); //如果没有订单数据,就给一个随便逛逛链接 @@ -537,7 +539,7 @@ class HomeController extends AbstractAction if (!empty($data)) { $order['orders'] = $data; } else { - $order['walkwayUrl'] = 'http://www.baidu.com'; + $order['walkwayUrl'] = 'http://www.baidu.com'; } //渲染模板 @@ -549,15 +551,48 @@ class HomeController extends AbstractAction } /* - * 我的订单-处理ajax请求页面(切换订单状态) + * 我的订单-取消订单 + */ + + public function cancelOrderAction() { + + //判断是不是ajax请求 + if (!$this->isAjax()) { + $this->error(); + } + //传入order_code和uid以取消订单 + $order_code = $this->get('orderCode'); + $uid = $this->getUid(); + $uid = '10267443'; //测试用 + $gender = Helpers::getGenderByCookie(); + $yh_channel = $this->get('yh_channel', 1); + $method = 'app.SpaceOrders.close'; + $data = OrderData::cancelOrderData($order_code, $uid, $gender, $yh_channel, $method); + if ($data['code'] == 200) { + echo $data['message']; + } + } + + /* + * 我的订单-删除订单 */ - public function getOrdersAction() { + public function deleteOrderAction() { //判断是不是ajax请求 if (!$this->isAjax()) { $this->error(); } - self::orderAction(); + //传入order_code和uid以删除订单 + $order_code = $this->get('orderCode'); + $uid = $this->getUid(); + $uid = '10267443'; //测试用 + $gender = Helpers::getGenderByCookie(); + $yh_channel = $this->get('yh_channel', 1); + $method = 'app.SpaceOrders.delOrderByCode'; + $data = OrderData::deleteOrderData($order_code, $uid, $gender, $yh_channel, $method); + if ($data['code'] == 200) { + echo $data['message']; + } } } -- libgit2 0.24.0