AdminGoodsOrderController.php
4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author:kane < chengjin005@163.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\AdminBaseController;
use think\Db;
/**
* Class AdminGoodsOrderController
* @package app\portal\controller
* @adminMenuRoot(
* 'name' =>'订单管理',
* 'action' =>'default',
* 'parent' =>'',
* 'display'=> true,
* 'order' => 30,
* 'icon' =>'th',
* 'remark' =>'订单管理'
* )
*/
class AdminGoodsOrderController extends AdminBaseController
{
/**
* 订单列表
* @adminMenu(
* 'name' => '订单列表',
* 'parent' => 'portal/AdminGoodsOrder/default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '订单列表',
* 'param' => ''
* )
*/
public function index()
{
//接收搜索参数
$param = $this->request->param();
//添加搜索条件
$where = [];
$startTime = empty($param['start_time']) ? '' : strtotime($param['start_time']);
$endTime = empty($param['end_time']) ? '' : strtotime($param['end_time']);
if (!empty($startTime) && !empty($endTime)) {
$where['a.published_time'] = [['>= time', $startTime], ['<= time', $endTime]];
} else {
if (!empty($startTime)) {
$where['go.create_time'] = ['>= time', $startTime];
}
if (!empty($endTime)) {
$where['go.create_time'] = ['<= time', $endTime];
}
}
$order_sn = empty($param['order_sn']) ? '' : $param['order_sn'];
if (!empty($order_sn)) {
$where['go.order_sn'] = ['like', "%$order_sn%"];
}
$status = empty($param['status']) ? '' : $param['status'];
if (!empty($status)) {
$where['go.status'] = $status;
}
$user_nickname = empty($param['user_nickname']) ? '' : $param['user_nickname'];
if (!empty($user_nickname)) {
$where['u.user_nickname'] = ['like', "%$user_nickname%"];
}
$mobile = empty($param['mobile']) ? '' : $param['mobile'];
if (!empty($mobile)) {
$where['u.mobile'] = ['like', "%$mobile%"];
}
$data = Db::name('goods_order')
->alias('go')
->join('goods g','go.goods_id=g.id')
->join('user u','go.user_id=u.id')
->join('address a','go.address_id=a.id')
->where($where)
->field('*,go.create_time as gcreate_time')
->order('go.create_time', 'desc')
->paginate('10');
//向地址传参
$data->appends($param);
$this->assign('page', $data->render());
$this->assign('start_time', $startTime);
$this->assign('end_time', $endTime);
$this->assign('order_sn', $order_sn);
$this->assign('status', $status);
$this->assign('user_nickname', $user_nickname);
$this->assign('mobile', $mobile);
$this->assign('list', $data);
return $this->fetch();
}
public function fahuo(){
$param=$this->request->param();
Db::name('goods_order')->where('id',$param['id'])->update(['status'=>3]);
$this->success('发货成功');
}
/**
* 删除订单
* @adminMenu(
* 'name' => '删除订单',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '删除订单',
* 'param' => ''
* )
*/
public function delete()
{
$param=$this->request->param();
if (!empty($param['ids'])){
Db::name('goods_order')->where(['id' => ['in', $param['ids']]])->delete();
$this->success('删除成功');
}
Db::name('goods_order')->where('id', $param['id'])->delete();
$this->success('删除成功');
}
}