用户中心

This commit is contained in:
2016-07-02 10:24:24 +08:00
parent 0398e5bd80
commit 53cdded607
4 changed files with 13 additions and 209 deletions

View File

@@ -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;

View File

@@ -3,12 +3,24 @@
<head>
<meta charset="UTF-8">
<title>SentCMS3.0网站管理系统</title>
<style>
body{font-family: "微软雅黑","Microsoft Yahei";}
a{color: #333333;}
.warp{margin: 100px auto 0 auto; border: 10px solid #F25C05; padding: 50px; width: 600px;}
.warp li{line-height: 35px; display: inline-block; width: 40%}
</style>
</head>
<body>
<div class="warp">
<div class="logo">
<a href="http://www.tensent.cn" target="_blank"><img src="__PUBLIC__/images/logo-foot.png" alt="南昌腾速科技有限公司"></a>
</div>
<ul>
<li><a href="http://www.tensent.cn" target="_blank">南昌腾速科技有限公司</a></li>
<li><a href="http://git.oschina.net/sentcms/sentcms" target="_blank">SentCMS3.0版本库</a></li>
<li><a href="doc.sentcms.com" target="_blank">SentCMS3.0开发文档</a></li>
<li><a href="http://doc.sentcms.com" target="_blank">SentCMS3.0开发文档</a></li>
<li><a href="http://bbs.sentcms.com" target="_blank">SentCMS讨论社区</a></li>
</ul>
</div>
</body>
</html>

View File

@@ -1,135 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
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("取消失败!");
}
}
}

View File

@@ -1,70 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
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("支付失败!");
}
}
}