vr-shopxo-source/application/index/controller/Order.php

356 lines
10 KiB
PHP
Raw Normal View History

2018-12-28 10:58:37 +00:00
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
2019-02-18 05:52:07 +00:00
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
2018-12-28 10:58:37 +00:00
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\index\controller;
use app\service\OrderService;
use app\service\PaymentService;
2019-05-13 10:37:53 +00:00
use app\service\GoodsCommentsService;
2019-11-19 13:46:22 +00:00
use app\service\ConfigService;
2019-12-24 07:18:56 +00:00
use app\service\SeoService;
2018-12-28 10:58:37 +00:00
/**
* 订单管理
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Order extends Common
{
/**
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-30
* @desc description
*/
public function __construct()
{
parent::__construct();
// 是否登录
2019-02-14 15:06:04 +00:00
$this->IsLogin();
2018-12-28 10:58:37 +00:00
}
/**
* 订单列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-28
* @desc description
*/
public function Index()
{
2020-07-24 16:13:18 +00:00
// 总数
$total = OrderService::OrderTotal($this->form_where);
2018-12-28 10:58:37 +00:00
// 分页
2020-07-24 16:13:18 +00:00
$page_params = [
'number' => $this->page_size,
'total' => $total,
'where' => $this->data_request,
'page' => $this->page,
'url' => MyUrl('admin/order/index'),
];
2018-12-28 10:58:37 +00:00
$page = new \base\Page($page_params);
// 获取列表
2020-07-24 16:13:18 +00:00
$data_params = [
'm' => $page->GetPageStarNumber(),
'n' => $this->page_size,
'where' => $this->form_where,
'user_type' => 'user',
];
$ret = OrderService::OrderList($data_params);
2018-12-28 10:58:37 +00:00
2020-07-24 16:13:18 +00:00
// 加载百度地图api
$this->assign('is_load_baidu_map_api', 1);
2018-12-28 10:58:37 +00:00
2019-12-24 07:18:56 +00:00
// 浏览器名称
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('我的订单', 1));
2020-07-24 16:13:18 +00:00
// 基础参数赋值
$this->assign('params', $this->data_request);
$this->assign('page_html', $page->GetPageHtml());
$this->assign('data_list', $ret['data']);
2018-12-28 10:58:37 +00:00
return $this->fetch();
}
/**
* 订单详情
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-10-08
* @desc description
*/
public function Detail()
{
2020-07-24 16:13:18 +00:00
$data = [];
if(!empty($this->data_request['id']))
{
// 条件
$where = [
['is_delete_time', '=', 0],
['user_is_delete_time', '=', 0],
['id', '=', intval($this->data_request['id'])],
['user_id', '=', $this->user['id']],
];
// 获取列表
$data_params = [
'm' => 0,
'n' => 1,
'where' => $where,
'user_type' => 'user',
];
$ret = OrderService::OrderList($data_params);
$data = (empty($ret['data']) || empty($ret['data'][0])) ? [] : $ret['data'][0];
}
if(!empty($data))
2018-12-28 10:58:37 +00:00
{
2020-07-24 16:13:18 +00:00
// 发起支付 - 支付方式
2018-12-28 10:58:37 +00:00
$this->assign('buy_payment_list', PaymentService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]));
2019-11-19 13:46:22 +00:00
// 虚拟销售配置
$site_fictitious = ConfigService::SiteFictitiousConfig();
$this->assign('site_fictitious', $site_fictitious['data']);
2019-11-26 06:00:00 +00:00
// 加载百度地图api
$this->assign('is_load_baidu_map_api', 1);
2020-07-24 16:13:18 +00:00
// 数据赋值
$this->assign('data', $data);
$this->assign('params', $this->data_request);
2018-12-28 10:58:37 +00:00
return $this->fetch();
2019-03-15 16:22:06 +00:00
}
2018-12-28 10:58:37 +00:00
}
/**
* 评价页面
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-10-08
* @desc description
*/
public function Comments()
{
2020-07-24 16:16:11 +00:00
$data = [];
if(!empty($this->data_request['id']))
{
// 条件
$where = [
['is_delete_time', '=', 0],
['user_is_delete_time', '=', 0],
['id', '=', intval($this->data_request['id'])],
['user_id', '=', $this->user['id']],
];
2018-12-28 10:58:37 +00:00
2020-07-24 16:16:11 +00:00
// 获取列表
$data_params = [
'm' => 0,
'n' => 1,
'where' => $where,
'user_type' => 'user',
];
$ret = OrderService::OrderList($data_params);
$data = (empty($ret['data']) || empty($ret['data'][0])) ? [] : $ret['data'][0];
}
if(!empty($data))
2018-12-28 10:58:37 +00:00
{
$this->assign('referer_url', empty($_SERVER['HTTP_REFERER']) ? MyUrl('index/order/index') : $_SERVER['HTTP_REFERER']);
2020-07-24 16:16:11 +00:00
$this->assign('data', $data);
2019-10-11 07:38:29 +00:00
// 编辑器文件存放地址
2020-07-24 16:16:11 +00:00
$this->assign('editor_path_type', 'order_comments-'.$this->user['id'].'-'.$data['id']);
2018-12-28 10:58:37 +00:00
return $this->fetch();
} else {
$this->assign('msg', '没有相关数据');
return $this->fetch('public/tips_error');
2019-05-21 10:34:07 +00:00
}
2018-12-28 10:58:37 +00:00
}
/**
* 评价保存
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-10-09
* @desc description
*/
public function CommentsSave()
{
2020-07-24 16:16:11 +00:00
if($this->data_post)
2018-12-28 10:58:37 +00:00
{
2020-07-24 16:16:11 +00:00
$params = $this->data_post;
2018-12-28 10:58:37 +00:00
$params['user'] = $this->user;
2019-05-14 17:09:10 +00:00
$params['business_type'] = 'order';
2019-05-13 10:37:53 +00:00
return GoodsCommentsService::Comments($params);
2018-12-28 10:58:37 +00:00
} else {
$this->assign('msg', '非法访问');
return $this->fetch('public/tips_error');
}
}
/**
* 订单支付
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-28
* @desc description
*/
public function Pay()
{
$params = input();
$params['user'] = $this->user;
$ret = OrderService::Pay($params);
if($ret['code'] == 0)
{
return redirect($ret['data']['data']);
} else {
$this->assign('msg', $ret['msg']);
return $this->fetch('public/tips_error');
}
}
/**
* 支付同步返回处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-28
* @desc description
*/
public function Respond()
{
2019-05-29 03:33:36 +00:00
// 参数
2018-12-28 10:58:37 +00:00
$params = input();
2019-05-29 03:33:36 +00:00
// 是否自定义状态
if(isset($params['appoint_status']))
{
2019-05-29 03:51:25 +00:00
$ret = ($params['appoint_status'] == 0) ? DataReturn('支付成功', 0) : DataReturn('支付失败', -100);
2019-05-29 03:33:36 +00:00
// 获取支付回调数据
} else {
$params['user'] = $this->user;
$ret = OrderService::Respond($params);
}
2019-05-07 17:07:39 +00:00
// 自定义链接
$this->assign('to_url', MyUrl('index/order/index'));
$this->assign('to_title', '我的订单');
// 状态
2020-04-07 09:29:57 +00:00
$this->assign('msg', $ret['msg']);
2018-12-28 10:58:37 +00:00
if($ret['code'] == 0)
{
2019-05-26 16:58:59 +00:00
return $this->fetch('public/tips_success');
2018-12-28 10:58:37 +00:00
}
2020-04-07 09:29:57 +00:00
return $this->fetch('public/tips_error');
2018-12-28 10:58:37 +00:00
}
/**
* 订单取消
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-30
* @desc description
*/
public function Cancel()
{
2020-07-24 16:16:11 +00:00
if($this->data_post)
2018-12-28 10:58:37 +00:00
{
2020-07-24 16:16:11 +00:00
$params = $this->data_post;
2018-12-28 10:58:37 +00:00
$params['user_id'] = $this->user['id'];
$params['creator'] = $this->user['id'];
$params['creator_name'] = $this->user['user_name_view'];
return OrderService::OrderCancel($params);
} else {
$this->assign('msg', '非法访问');
return $this->fetch('public/tips_error');
}
}
/**
* 订单收货
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-30
* @desc description
*/
public function Collect()
{
2020-07-24 16:16:11 +00:00
if($this->data_post)
2018-12-28 10:58:37 +00:00
{
2020-07-24 16:16:11 +00:00
$params = $this->data_post;
2018-12-28 10:58:37 +00:00
$params['user_id'] = $this->user['id'];
$params['creator'] = $this->user['id'];
$params['creator_name'] = $this->user['user_name_view'];
return OrderService::OrderCollect($params);
} else {
$this->assign('msg', '非法访问');
return $this->fetch('public/tips_error');
}
}
/**
* 订单删除
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-30
* @desc description
*/
public function Delete()
{
2020-07-24 16:16:11 +00:00
if($this->data_post)
2018-12-28 10:58:37 +00:00
{
2020-07-24 16:16:11 +00:00
$params = $this->data_post;
2018-12-28 10:58:37 +00:00
$params['user_id'] = $this->user['id'];
$params['creator'] = $this->user['id'];
$params['creator_name'] = $this->user['user_name_view'];
$params['user_type'] = 'user';
return OrderService::OrderDelete($params);
} else {
$this->assign('msg', '非法访问');
return $this->fetch('public/tips_error');
}
}
2019-01-08 05:59:14 +00:00
/**
* 支付状态校验
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-01-08
* @desc description
*/
public function PayCheck()
{
2020-07-24 16:16:11 +00:00
if($this->data_post)
2019-01-08 05:59:14 +00:00
{
2020-07-24 16:16:11 +00:00
$params = $this->data_post;
2019-01-08 05:59:14 +00:00
$params['user'] = $this->user;
return OrderService::OrderPayCheck($params);
} else {
$this->assign('msg', '非法访问');
return $this->fetch('public/tips_error');
}
}
2018-12-28 10:58:37 +00:00
}
?>