diff --git a/application/common/controller/User.php b/application/common/controller/User.php index b50ae1f2..99d5e725 100644 --- a/application/common/controller/User.php +++ b/application/common/controller/User.php @@ -34,9 +34,6 @@ class User extends Base{ array('title'=>'密码修改', 'url'=>'user/profile/editpw', 'icon'=>'key'), array('title'=>'更换头像', 'url'=>'user/profile/avatar', 'icon'=>'male'), ); - $menu['订单管理'] = array( - array('title'=>'我的订单', 'url'=>'user/order/index', 'icon'=>'shopping-bag'), - ); $contetnmenu = $this->getContentMenu(); if (!empty($contetnmenu)) { $menu['内容管理'] = $contetnmenu; diff --git a/application/index/view/index/index.html b/application/index/view/index/index.html index f836f74a..ba2c9270 100644 --- a/application/index/view/index/index.html +++ b/application/index/view/index/index.html @@ -3,12 +3,24 @@ SentCMS3.0网站管理系统 + +
+ +
\ No newline at end of file diff --git a/application/user/controller/Order.php b/application/user/controller/Order.php deleted file mode 100644 index df0fcd2d..00000000 --- a/application/user/controller/Order.php +++ /dev/null @@ -1,135 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace app\user\controller; -use app\common\controller\User; - -class Order extends User{ - - public function _initialize(){ - parent::_initialize(); - $this->order = model('Order'); - $this->cart = new \com\Cart(); - } - - //会员中心订单首页 - public function index(){ - $map['uid'] = session('user_auth.uid'); - $map['status'] = array('gt',0); - - $rows = array(); - $list = $this->order->where($map)->order('id desc')->paginate(10); - foreach ($list as $key => $value) { - $value['product'] = $value->product; - $rows[] = $value; - } - - $data = array( - 'list' => $rows, - 'page' => $list->render() - ); - $this->assign($data); - return $this->fetch(); - } - - //订单结算列表 - public function lists(){ - $id = input('id', '', 'trim'); - $order_id = input('order_id', '', 'trim'); - - //立即购买,把物品放入购物车 - if ($id) { - $this->cart->addItem($id, 1); - } - - if (!$order_id) { - $price_count = '0.00'; - $list = $this->cart->all(); - if ($list) { - foreach ($list as $key => $value) { - $price_count += $value['price_count']; - } - - $data = array( - 'list' => $list, - 'price_count' => $price_count - ); - - //生成订单 - $map['id'] = $this->order->createOrder($data); - } - }else{ - $map['id'] = $order_id; - } - - if (!isset($map['id'])) { - return $this->error('非法操作!'); - } - - $order = $this->order->where($map)->find(); - - $data = array( - 'list' => $order->product, - 'order_id' => $map['id'], - 'price_count' => $order['price_count'] - ); - //订单生成后情况购物车 - $this->cart->clear(); - $this->assign($data); - return $this->fetch(); - } - - public function confirm(){ - $order_id = input('order_id', '', 'trim'); - $payment = input('payment', '', 'trim'); - $map['id'] = $order_id; - $this->order->where($map)->update(array('pay_type'=>$payment)); - $info = $this->order->where($map)->find(); - - $data = array( - 'info' => $info - ); - $this->assign($data); - return $this->fetch(); - } - - /** - * 订单支付 - * @param int $order_id - * @return html - */ - public function pay($order_id){ - $info = $this->order->where(array('id'=>$order_id))->find(); - if ($info['pay_status']) { - return $this->success("您已支付!", url('user/order/index')); - } - $pay = array( - 'body' => '测试支付', - 'fee' => $info['price_count'], - //'fee' => 0.01, - 'order_no' => $info['order_no'], - 'title' => config('web_site_title') . ' - 订单付款', - 'param' => array('order_id'=>$info['id']) - ); - $data = array('type' => $info['pay_type'], 'pay_data'=>$pay); - $data = action('user/pay/index',$data); - $data['order_no'] = $info['order_no']; - $this->assign($data); - return $this->fetch(); - } - - public function cancel($order_id){ - $result = $this->order->where(array('id'=>$order_id))->setField('status',0); - if ($result) { - return $this->success("已取消!"); - }else{ - return $this->error("取消失败!"); - } - } -} \ No newline at end of file diff --git a/application/user/controller/Pay.php b/application/user/controller/Pay.php deleted file mode 100644 index ff42d720..00000000 --- a/application/user/controller/Pay.php +++ /dev/null @@ -1,70 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace app\user\controller; -use app\common\controller\User; - -class Pay extends User{ - - public function index($type = 'alipay', $pay_data){ - $pay = new \com\Pay($type); - $pay_data['bank'] = isset($pay_data['bank']) ? $pay_data['bank'] : ''; - $pay_data['callback'] = url('user/pay/returnback',array('apitype'=>input('apitype', 'alipay', 'trim'))); - $pay_data['url'] = url('user/pay/returnback',array('apitype'=>input('apitype', 'alipay', 'trim'))); - $pay_data['param'] = isset($pay_data['param']) ? $pay_data['param'] : ''; - - $input = new \com\pay\Input(); - $input->setBody($pay_data['body']) - ->setUid(session('user_auth.uid')) - ->setFee($pay_data['fee']) //支付金额 - ->setOrderNo($pay_data['order_no'])//订单号 - ->setTitle($pay_data['title'])//设置商品名称 - ->setBank($pay_data['bank'])//设置银行 - ->setCallback($pay_data['callback'])/*** 设置支付完成后的后续操作接口 */ - ->setUrl($pay_data['url']) /* 设置支付完成后的跳转地址*/ - ->setParam($pay_data['param']); - $data = $pay->pay($input); - return $data; - } - - //返回 - public function returnback(){ - $apitype = input('get.apitype'); - $method = input('get.method'); - if (!empty($_POST)) { - $result = input('post.'); - }elseif (!empty($_GET)) { - $result = input('get.');; - unset($result['method']); - unset($result['apitype']); - } else { - exit('Access Denied'); - } - $pay = new \com\Pay($apitype); - $res = $pay->verifyNotify($result); - $status = ($result['trade_status'] == 'TRADE_FINISHED' || $result['trade_status'] == 'TRADE_SUCCESS') ? true : false; - if ($res && $status) { - db('Order')->where(array('order_no'=>$result['out_trade_no']))->update(array('pay_status'=>1)); - return $this->success("支付成功!", url('user/order/index')); - }else{ - return $this->error("支付失败!"); - } - } - - //异步获取 - public function notify(){ - $order_no = input('post.order_no'); - $pay_status = db('Order')->where(array('order_no'=>$order_no))->value('pay_status'); - if ($pay_status) { - return $this->success("支付成功!", url('user/order/index')); - }else{ - return $this->error("支付失败!"); - } - } -} \ No newline at end of file