Files
shopxo/application/index/controller/Order.php

358 lines
10 KiB
PHP
Raw Normal View History

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