110 lines
4.1 KiB
PHP
110 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace addon\saas\shop\controller;
|
|
|
|
use addon\fenxiao\model\FenxiaoOrder;
|
|
use addon\saas\model\ManageOrder;
|
|
|
|
class Order extends SaasBase
|
|
{
|
|
|
|
protected $replace = []; //视图输出字符串内容替换 相当于配置文件中的'view_replace_str'
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->replace = [
|
|
'SAAS_JS' => __ROOT__ . '/addon/saas/shop/view/public/js',
|
|
'SAAS_CSS' => __ROOT__ . '/addon/saas/shop/view/public/css'
|
|
];
|
|
}
|
|
|
|
/***
|
|
* 获取流水列表
|
|
* @return array|mixed
|
|
*/
|
|
public function lists()
|
|
{
|
|
if (request()->isAjax()) {
|
|
$model = new ManageOrder();
|
|
if ($this->site_id == 1) {
|
|
$condition = [];
|
|
} else {
|
|
$condition[] = ['site_id', '=', $this->site_id];
|
|
}
|
|
$start_time = input('start_time', '');
|
|
$end_time = input('end_time', '');
|
|
if ($start_time && $end_time) {
|
|
$condition[] = ['create_time', 'between', [date_to_time($start_time), date_to_time($end_time)]];
|
|
} elseif (!$start_time && $end_time) {
|
|
$condition[] = ['create_time', '<=', date_to_time($end_time)];
|
|
|
|
} elseif ($start_time && !$end_time) {
|
|
$condition[] = ['create_time', '>=', date_to_time($start_time)];
|
|
}
|
|
$page = input('page', 1);
|
|
$page_size = input('page_size', PAGE_LIST_ROWS);
|
|
$list = $model->getOrderPageList($condition, $page, $page_size, 'create_time desc');
|
|
if (!empty($list['data'][ 'list' ])) {
|
|
$order_info = model('order')->getColumn([ [ 'order_id', 'in', array_column($list[ 'data' ][ 'list' ], 'order_id') ] ], 'name,full_address,mobile,order_status_name','order_id');
|
|
foreach ($list['data'][ 'list' ] as $k => $item) {
|
|
$list['data'][ 'list' ][ $k ][ 'order_goods' ] = [
|
|
array_merge($item, $order_info[$item['order_id']])
|
|
];
|
|
}
|
|
}
|
|
return $list;
|
|
}
|
|
$this->forthMenu();
|
|
return $this->fetch('order/lists', [], $this->replace);
|
|
}
|
|
|
|
public function detail()
|
|
{
|
|
$model = new ManageOrder();
|
|
$order_id = input('order_id', '');
|
|
$order_info = $model->getOrderInfo([ [ 'order_id', '=', $order_id ] ]);
|
|
if (empty($order_info[ 'data' ])) $this->error('未获取到订单数据', addon_url('saas://shop/order/lists'));
|
|
$this->assign('order_detail', $order_info[ 'data' ]);
|
|
return $this->fetch('order/detail');
|
|
}
|
|
|
|
/**
|
|
* 订单导出
|
|
*/
|
|
public function exportorder()
|
|
{
|
|
$model = new FenxiaoOrder();
|
|
$status = input('status', 0);
|
|
$fenxiao_order_id = input('order_ids', "");
|
|
|
|
$condition = [ [ 'fo.site_id', '=', $this->site_id ] ];
|
|
if ($status == 3) {
|
|
$condition[] = [ 'fo.is_refund', '=', 1 ];
|
|
}
|
|
if (in_array($status, [ 1, 2 ])) {
|
|
$condition[] = [ 'fo.is_settlement', '=', $status - 1 ];
|
|
}
|
|
$search_text_type = input('search_text_type', "goods_name");//商品名称/订单编号
|
|
$search_text = input('search_text', "");
|
|
if (!empty($search_text)) {
|
|
$condition[] = [ 'fo.' . $search_text_type, 'like', '%' . $search_text . '%' ];
|
|
}
|
|
//下单时间
|
|
$start_time = input('start_time', '');
|
|
$end_time = input('end_time', '');
|
|
if (!empty($start_time) && empty($end_time)) {
|
|
$condition[] = [ 'fo.create_time', '>=', date_to_time($start_time) ];
|
|
} elseif (empty($start_time) && !empty($end_time)) {
|
|
$condition[] = [ 'fo.create_time', '<=', date_to_time($end_time) ];
|
|
} elseif (!empty($start_time) && !empty(date_to_time($end_time))) {
|
|
$condition[] = [ 'fo.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
|
}
|
|
if ($fenxiao_order_id) {
|
|
$condition = [];
|
|
$condition[] = [ "fo.fenxiao_order_id", "in", $fenxiao_order_id ];
|
|
}
|
|
$model->orderExport($condition);
|
|
}
|
|
}
|