|
|
1
|
+<?php
|
|
|
2
|
+/**
|
|
|
3
|
+ * Created by PhpStorm.
|
|
|
4
|
+ * User: 29925
|
|
|
5
|
+ * Date: 2018/8/16
|
|
|
6
|
+ * Time: 14:14
|
|
|
7
|
+ */
|
|
|
8
|
+
|
|
|
9
|
+namespace app\admin\controller;
|
|
|
10
|
+
|
|
|
11
|
+use app\admin\model\OrderModel;
|
|
|
12
|
+use cmf\controller\AdminBaseController;
|
|
|
13
|
+use think\Db;
|
|
|
14
|
+
|
|
|
15
|
+class OrderController extends AdminBaseController
|
|
|
16
|
+{
|
|
|
17
|
+
|
|
|
18
|
+ protected $decto_array;
|
|
|
19
|
+ protected $bin_array;
|
|
|
20
|
+
|
|
|
21
|
+ protected $table;
|
|
|
22
|
+ protected $order_model;
|
|
|
23
|
+ protected $option_table;
|
|
|
24
|
+ protected $sort_model;
|
|
|
25
|
+ protected $order_sort_table;
|
|
|
26
|
+ public function _initialize()
|
|
|
27
|
+ {
|
|
|
28
|
+ $this->decto_array = [ 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24, 'Z' => 25 ];
|
|
|
29
|
+ $this->bin_array = [ 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24, 'Z' => 25 ];
|
|
|
30
|
+
|
|
|
31
|
+ $this->table = 'Order';
|
|
|
32
|
+ $this->order_model = new OrderModel();
|
|
|
33
|
+ $this->option_table = 'OrderOption';
|
|
|
34
|
+ $this->order_sort_table = 'OrderSort';
|
|
|
35
|
+
|
|
|
36
|
+ // 订单字段类型定义
|
|
|
37
|
+ $this->sort_model[1] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
38
|
+ <p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
39
|
+ <input type="text" name="" id="" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
40
|
+ </div>';
|
|
|
41
|
+ $this->sort_model[2] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
42
|
+ <p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
43
|
+ <input type="number" name="" id="" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
44
|
+ </div>';
|
|
|
45
|
+ $this->sort_model[3] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
46
|
+ <p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
47
|
+ <input type="number" maxlength="11" name="" id="" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
48
|
+ </div>';
|
|
|
49
|
+ $this->sort_model[4] = '<div class="write_tit form_options" data-validate="{validate}">
|
|
|
50
|
+ <p class="tit"><span class=" _validate">{name}</span></p>
|
|
|
51
|
+ <div class="flex_style">
|
|
|
52
|
+ {options}
|
|
|
53
|
+ </div>
|
|
|
54
|
+ </div>';
|
|
|
55
|
+ $this->sort_model[5] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
56
|
+ <p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
57
|
+ <input type="text" name="" id="" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
58
|
+ </div>';
|
|
|
59
|
+ $this->sort_model[6] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
60
|
+ <p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
61
|
+ <textarea class="baby_input">{value}</textarea>
|
|
|
62
|
+ </div>';
|
|
|
63
|
+ $this->sort_model[7] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
64
|
+ <p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
65
|
+ <input type="text" name="" id="product" value="{value}" class="baby_input" placeholder="请选择{name}" />
|
|
|
66
|
+ <img src="__TMPL__/public/mobile/images/youjiantou.png" class="jiantou" />
|
|
|
67
|
+ </div>';
|
|
|
68
|
+ $this->sort_model[8] = '<div class="write_wrap" style="margin: 0;" data-validate="{validate}">
|
|
|
69
|
+ <p class="text_tit" style="line-height: 0.6rem;"><span class=" _validate">{name}</span>{must}</p>
|
|
|
70
|
+ </div>
|
|
|
71
|
+ <div class="up_wrap form_options">
|
|
|
72
|
+ <div class="up_pic">
|
|
|
73
|
+ <i class="iconfont icon-msnui-cloud-upload"></i>
|
|
|
74
|
+ <p class="click_up">点击上传</p>
|
|
|
75
|
+ </div>
|
|
|
76
|
+ </div>';
|
|
|
77
|
+ $this->sort_model[10] = '<div class="text_item no_margin form_options" data-validate="{validate}">
|
|
|
78
|
+ <p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
79
|
+ <input type="text" name="" id="birthday" readonly="readonly" value="{value}" class="baby_input" placeholder="请选择{name}" />
|
|
|
80
|
+ <img src="__TMPL__/public/mobile/images/youjiantou.png" class="jiantou" />
|
|
|
81
|
+ </div>';
|
|
|
82
|
+ $this->sort_model[11] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
83
|
+ <p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
84
|
+ <weui-distpicker province="广东省" city="广州市" area="海珠区"></weui-distpicker>
|
|
|
85
|
+ <input type="text" name="" id="address" readonly="readonly" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
86
|
+ <img src="__TMPL__/public/mobile/images/youjiantou.png" class="jiantou" />
|
|
|
87
|
+ </div>';
|
|
|
88
|
+ $this->sort_model[12] = '<div class="text_item form_options" data-validate="{validate}" data-type="12">
|
|
|
89
|
+ <p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
90
|
+ <input type="text" name="" id="" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
91
|
+ </div>';
|
|
|
92
|
+ }
|
|
|
93
|
+
|
|
|
94
|
+ /**
|
|
|
95
|
+ * 电子订单列表
|
|
|
96
|
+ * @adminMenu(
|
|
|
97
|
+ * 'name' => '电子订单列表',
|
|
|
98
|
+ * 'parent' => 'admin/OrderOption/default',
|
|
|
99
|
+ * 'display'=> true,
|
|
|
100
|
+ * 'hasView'=> true,
|
|
|
101
|
+ * 'order' => 10000,
|
|
|
102
|
+ * 'icon' => '',
|
|
|
103
|
+ * 'remark' => '电子订单列表',
|
|
|
104
|
+ * 'param' => ''
|
|
|
105
|
+ * )
|
|
|
106
|
+ */
|
|
|
107
|
+ public function index() {
|
|
|
108
|
+ $param = $this->request->param();
|
|
|
109
|
+ // 查询条件处理
|
|
|
110
|
+ $where = [
|
|
|
111
|
+ 'delete_time'=>0
|
|
|
112
|
+ ];
|
|
|
113
|
+ if(isset($param['keyword'])) {
|
|
|
114
|
+ $where['order_sn|sort_name|user_login|number'] = ['like','%'.$param['keyword'].'%'];
|
|
|
115
|
+ }
|
|
|
116
|
+ if(!empty($param['sort_id'])) {
|
|
|
117
|
+ $where['sort_id'] = $param['sort_id'];
|
|
|
118
|
+ }
|
|
|
119
|
+ if(isset($param['status']) && $param['status'] >= 0) {
|
|
|
120
|
+ $where['status'] = $param['status'];
|
|
|
121
|
+ }
|
|
|
122
|
+ if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
|
|
|
123
|
+ $where['is_excel'] = $param['is_excel'];
|
|
|
124
|
+ }
|
|
|
125
|
+ if(isset($param['is_over']) && $param['is_over'] >= 0) {
|
|
|
126
|
+ if($param['is_over'] == 0) {
|
|
|
127
|
+ $where['over_time'] = ['egt',time()];
|
|
|
128
|
+ }
|
|
|
129
|
+ if($param['is_over'] == 1) {
|
|
|
130
|
+ $where['over_time'] = ['lt',time()];
|
|
|
131
|
+ }
|
|
|
132
|
+ }
|
|
|
133
|
+ $startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
|
|
|
134
|
+ $endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
|
|
|
135
|
+ if (!empty($startTime) && !empty($endTime)) {
|
|
|
136
|
+ $where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
137
|
+ } else {
|
|
|
138
|
+ if (!empty($startTime)) {
|
|
|
139
|
+ $where['create_time'] = ['>= time', $startTime];
|
|
|
140
|
+ }
|
|
|
141
|
+ if (!empty($endTime)) {
|
|
|
142
|
+ $where['create_time'] = ['<= time', $endTime];
|
|
|
143
|
+ }
|
|
|
144
|
+ }
|
|
|
145
|
+ $list = $this->singleData('order_view',$where,2,[],10);
|
|
|
146
|
+ $list->appends($param);
|
|
|
147
|
+ $this->assign('list',$list->items());
|
|
|
148
|
+ $this->assign('page',$list->render());
|
|
|
149
|
+ $this->assign('keyword',isset($param['keyword']) ? $param['keyword'] : '');
|
|
|
150
|
+ $this->assign('sort_id',isset($param['sort_id']) ? $param['sort_id'] : '');
|
|
|
151
|
+ $this->assign('status',isset($param['status']) ? $param['status'] : '');
|
|
|
152
|
+ $this->assign('is_excel',isset($param['is_excel']) ? $param['is_excel'] : '');
|
|
|
153
|
+ $this->assign('is_over',isset($param['is_over']) ? $param['is_over'] : '');
|
|
|
154
|
+ $this->assign('start_time',isset($param['start_time']) ? $param['start_time'] : '');
|
|
|
155
|
+ $this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
|
|
|
156
|
+ // 订单类型查询
|
|
|
157
|
+ $sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
|
|
|
158
|
+ $this->assign('sortList',$sortList);
|
|
|
159
|
+ return $this->fetch();
|
|
|
160
|
+ }
|
|
|
161
|
+
|
|
|
162
|
+ /**
|
|
|
163
|
+ * 电子订单列表(表单类型下)
|
|
|
164
|
+ * @adminMenu(
|
|
|
165
|
+ * 'name' => '电子订单列表',
|
|
|
166
|
+ * 'parent' => 'admin/OrderSort/index',
|
|
|
167
|
+ * 'display'=> false,
|
|
|
168
|
+ * 'hasView'=> false,
|
|
|
169
|
+ * 'order' => 1,
|
|
|
170
|
+ * 'icon' => '',
|
|
|
171
|
+ * 'remark' => '电子订单列表(表单类型下)',
|
|
|
172
|
+ * 'param' => ''
|
|
|
173
|
+ * )
|
|
|
174
|
+ */
|
|
|
175
|
+ public function index_sort() {
|
|
|
176
|
+ $param = $this->request->param();
|
|
|
177
|
+ $where = [
|
|
|
178
|
+ 'delete_time'=>0
|
|
|
179
|
+ ];
|
|
|
180
|
+ if(empty($param['sort_id'])) {
|
|
|
181
|
+ $this->error('参数错误');
|
|
|
182
|
+ }
|
|
|
183
|
+ $where['sort_id'] = $param['sort_id'];
|
|
|
184
|
+ if(isset($param['status']) && $param['status'] >= 0) {
|
|
|
185
|
+ $where['status'] = $param['status'];
|
|
|
186
|
+ }
|
|
|
187
|
+ if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
|
|
|
188
|
+ $where['is_excel'] = $param['is_excel'];
|
|
|
189
|
+ }
|
|
|
190
|
+ if(isset($param['is_over']) && $param['is_over'] >= 0) {
|
|
|
191
|
+ if($param['is_over'] == 0) {
|
|
|
192
|
+ $where['over_time'] = ['egt',time()];
|
|
|
193
|
+ }
|
|
|
194
|
+ if($param['is_over'] == 1) {
|
|
|
195
|
+ $where['over_time'] = ['lt',time()];
|
|
|
196
|
+ }
|
|
|
197
|
+ }
|
|
|
198
|
+ $startTime = empty($filter['start_time']) ? 0 : strtotime($filter['start_time']);
|
|
|
199
|
+ $endTime = empty($filter['end_time']) ? 0 : strtotime($filter['end_time']);
|
|
|
200
|
+ if (!empty($startTime) && !empty($endTime)) {
|
|
|
201
|
+ $where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
202
|
+ } else {
|
|
|
203
|
+ if (!empty($startTime)) {
|
|
|
204
|
+ $where['create_time'] = ['>= time', $startTime];
|
|
|
205
|
+ }
|
|
|
206
|
+ if (!empty($endTime)) {
|
|
|
207
|
+ $where['create_time'] = ['<= time', $endTime];
|
|
|
208
|
+ }
|
|
|
209
|
+ }
|
|
|
210
|
+ $list = $this->singleData('order_view',$where,2,[],10);
|
|
|
211
|
+ $list->appends($param);
|
|
|
212
|
+ $this->assign('list',$list->items());
|
|
|
213
|
+ $this->assign('page',$list->render());
|
|
|
214
|
+ $this->assign('keyword',isset($param['keyword']) ? $param['keyword'] : '');
|
|
|
215
|
+ $this->assign('status',isset($param['status']) ? $param['status'] : '');
|
|
|
216
|
+ $this->assign('is_excel',isset($param['is_excel']) ? $param['is_excel'] : '');
|
|
|
217
|
+ $this->assign('is_over',isset($param['is_over']) ? $param['is_over'] : '');
|
|
|
218
|
+ $this->assign('start_time',isset($param['start_time']) ? $param['start_time'] : '');
|
|
|
219
|
+ $this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
|
|
|
220
|
+ $this->assign('sort_id',$param['sort_id']);
|
|
|
221
|
+ // 订单类型
|
|
|
222
|
+ $sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
|
|
|
223
|
+ $this->assign('sortList',$sortList);
|
|
|
224
|
+ return $this->fetch();
|
|
|
225
|
+ }
|
|
|
226
|
+
|
|
|
227
|
+ /**
|
|
|
228
|
+ * 电子订单列表(销售人员下)
|
|
|
229
|
+ * @adminMenu(
|
|
|
230
|
+ * 'name' => '电子订单列表',
|
|
|
231
|
+ * 'parent' => 'admin/OrderSort/index',
|
|
|
232
|
+ * 'display'=> false,
|
|
|
233
|
+ * 'hasView'=> false,
|
|
|
234
|
+ * 'order' => 2,
|
|
|
235
|
+ * 'icon' => '',
|
|
|
236
|
+ * 'remark' => '电子订单列表(销售人员下)',
|
|
|
237
|
+ * 'param' => ''
|
|
|
238
|
+ * )
|
|
|
239
|
+ */
|
|
|
240
|
+ public function index_sales() {
|
|
|
241
|
+ $param = $this->request->param();
|
|
|
242
|
+ $where = [
|
|
|
243
|
+ 'delete_time'=>0
|
|
|
244
|
+ ];
|
|
|
245
|
+ if(empty($param['user_id'])) {
|
|
|
246
|
+ $this->error('参数错误');
|
|
|
247
|
+ }
|
|
|
248
|
+ $where['user_id'] = $param['user_id'];
|
|
|
249
|
+ if(isset($param['keyword'])) {
|
|
|
250
|
+ $where['order_sn|sort_name|user_login|number'] = ['like','%'.$param['keyword'].'%'];
|
|
|
251
|
+ }
|
|
|
252
|
+ if(!empty($param['sort_id'])) {
|
|
|
253
|
+ $where['sort_id'] = $param['sort_id'];
|
|
|
254
|
+ }
|
|
|
255
|
+ if(isset($param['status']) && $param['status'] >= 0) {
|
|
|
256
|
+ $where['status'] = $param['status'];
|
|
|
257
|
+ }
|
|
|
258
|
+ if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
|
|
|
259
|
+ $where['is_excel'] = $param['is_excel'];
|
|
|
260
|
+ }
|
|
|
261
|
+ if(isset($param['is_over']) && $param['is_over'] >= 0) {
|
|
|
262
|
+ if($param['is_over'] == 0) {
|
|
|
263
|
+ $where['over_time'] = ['egt',time()];
|
|
|
264
|
+ }
|
|
|
265
|
+ if($param['is_over'] == 1) {
|
|
|
266
|
+ $where['over_time'] = ['lt',time()];
|
|
|
267
|
+ }
|
|
|
268
|
+ }
|
|
|
269
|
+ $startTime = empty($filter['start_time']) ? 0 : strtotime($filter['start_time']);
|
|
|
270
|
+ $endTime = empty($filter['end_time']) ? 0 : strtotime($filter['end_time']);
|
|
|
271
|
+ if (!empty($startTime) && !empty($endTime)) {
|
|
|
272
|
+ $where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
273
|
+ } else {
|
|
|
274
|
+ if (!empty($startTime)) {
|
|
|
275
|
+ $where['create_time'] = ['>= time', $startTime];
|
|
|
276
|
+ }
|
|
|
277
|
+ if (!empty($endTime)) {
|
|
|
278
|
+ $where['create_time'] = ['<= time', $endTime];
|
|
|
279
|
+ }
|
|
|
280
|
+ }
|
|
|
281
|
+ $list = $this->singleData('order_view',$where,2,[],10);
|
|
|
282
|
+ $list->appends($param);
|
|
|
283
|
+ $this->assign('list',$list->items());
|
|
|
284
|
+ $this->assign('page',$list->render());
|
|
|
285
|
+ $this->assign('keyword',isset($param['keyword']) ? $param['keyword'] : '');
|
|
|
286
|
+ $this->assign('sort_id',isset($param['sort_id']) ? $param['sort_id'] : '');
|
|
|
287
|
+ $this->assign('status',isset($param['status']) ? $param['status'] : '');
|
|
|
288
|
+ $this->assign('is_excel',isset($param['is_excel']) ? $param['is_excel'] : '');
|
|
|
289
|
+ $this->assign('is_over',isset($param['is_over']) ? $param['is_over'] : '');
|
|
|
290
|
+ $this->assign('start_time',isset($param['start_time']) ? $param['start_time'] : '');
|
|
|
291
|
+ $this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
|
|
|
292
|
+ $this->assign('user_id',$param['user_id']);
|
|
|
293
|
+ // 订单类型
|
|
|
294
|
+ $sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
|
|
|
295
|
+ $this->assign('sortList',$sortList);
|
|
|
296
|
+ return $this->fetch();
|
|
|
297
|
+ }
|
|
|
298
|
+
|
|
|
299
|
+ /**
|
|
|
300
|
+ * 用户数据导出
|
|
|
301
|
+ * @adminMenu(
|
|
|
302
|
+ * 'name' => '用户数据导出',
|
|
|
303
|
+ * 'parent' => 'index',
|
|
|
304
|
+ * 'display'=> false,
|
|
|
305
|
+ * 'hasView'=> false,
|
|
|
306
|
+ * 'order' => 3,
|
|
|
307
|
+ * 'icon' => '',
|
|
|
308
|
+ * 'remark' => '用户数据导出',
|
|
|
309
|
+ * 'param' => ''
|
|
|
310
|
+ * )
|
|
|
311
|
+ */
|
|
|
312
|
+ public function excel()
|
|
|
313
|
+ {
|
|
|
314
|
+ $param = $this->request->param();
|
|
|
315
|
+ // 进行查询条件的处理
|
|
|
316
|
+ $where = [
|
|
|
317
|
+ 'delete_time'=>0
|
|
|
318
|
+ ];
|
|
|
319
|
+ if(!empty($param['ids'])) {
|
|
|
320
|
+ $where['id'] = ['in',$param['ids']];
|
|
|
321
|
+ }
|
|
|
322
|
+ if(isset($param['keyword'])) {
|
|
|
323
|
+ $where['order_sn|sort_name|user_login|number'] = ['like','%'.$param['keyword'].'%'];
|
|
|
324
|
+ }
|
|
|
325
|
+ if(!empty($param['sort_id'])) {
|
|
|
326
|
+ $where['sort_id'] = $param['sort_id'];
|
|
|
327
|
+ }
|
|
|
328
|
+ if(isset($param['status']) && $param['status'] >= 0) {
|
|
|
329
|
+ $where['status'] = $param['status'];
|
|
|
330
|
+ }
|
|
|
331
|
+ if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
|
|
|
332
|
+ $where['is_excel'] = $param['is_excel'];
|
|
|
333
|
+ }
|
|
|
334
|
+ if(isset($param['is_over']) && $param['is_over'] >= 0) {
|
|
|
335
|
+ if($param['is_over'] == 0) {
|
|
|
336
|
+ $where['over_time'] = ['egt',time()];
|
|
|
337
|
+ }
|
|
|
338
|
+ if($param['is_over'] == 1) {
|
|
|
339
|
+ $where['over_time'] = ['lt',time()];
|
|
|
340
|
+ }
|
|
|
341
|
+ }
|
|
|
342
|
+ $startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
|
|
|
343
|
+ $endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
|
|
|
344
|
+ if (!empty($startTime) && !empty($endTime)) {
|
|
|
345
|
+ $where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
346
|
+ } else {
|
|
|
347
|
+ if (!empty($startTime)) {
|
|
|
348
|
+ $where['create_time'] = ['>= time', $startTime];
|
|
|
349
|
+ }
|
|
|
350
|
+ if (!empty($endTime)) {
|
|
|
351
|
+ $where['create_time'] = ['<= time', $endTime];
|
|
|
352
|
+ }
|
|
|
353
|
+ }
|
|
|
354
|
+ // 查询数据并导出
|
|
|
355
|
+ $list = $this->singleData('order_view',$where,1);
|
|
|
356
|
+ $this->expList($list);
|
|
|
357
|
+ }
|
|
|
358
|
+
|
|
|
359
|
+ /**
|
|
|
360
|
+ * 数字转字母 (类似于Excel列标)
|
|
|
361
|
+ * @param Int $index 索引值
|
|
|
362
|
+ * @param Int $start 字母起始值
|
|
|
363
|
+ * @return String 返回字母
|
|
|
364
|
+ */
|
|
|
365
|
+ private function IntToChr($index, $start = 65) {
|
|
|
366
|
+ $str = '';
|
|
|
367
|
+ if (floor($index / 26) > 0) {
|
|
|
368
|
+ $str .= $this->IntToChr(floor($index / 26)-1);
|
|
|
369
|
+ }
|
|
|
370
|
+ return $str . chr($index % 26 + $start);
|
|
|
371
|
+ }
|
|
|
372
|
+
|
|
|
373
|
+ // 数据导出
|
|
|
374
|
+ private function expList($array)
|
|
|
375
|
+ {
|
|
|
376
|
+ // 获取可显示的字段列表
|
|
|
377
|
+ $option_list = $this->singleData($this->option_table,['delete_time'=>0],1);
|
|
|
378
|
+
|
|
|
379
|
+ //导出Excel
|
|
|
380
|
+ $objPHPExcel = new \PHPExcel();
|
|
|
381
|
+
|
|
|
382
|
+ // 设置单元格宽度
|
|
|
383
|
+ $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
|
|
|
384
|
+ $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
|
|
|
385
|
+ $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
|
|
|
386
|
+ $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
|
|
|
387
|
+ $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
|
|
|
388
|
+ $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
|
|
|
389
|
+ $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(20);
|
|
|
390
|
+ $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(20);
|
|
|
391
|
+ // 设置水平居中
|
|
|
392
|
+ $objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
393
|
+ // 设置垂直居中
|
|
|
394
|
+ $objPHPExcel->getDefaultStyle()->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
|
|
|
395
|
+ //Add some data
|
|
|
396
|
+ $objPHPExcel->setActiveSheetIndex(0)
|
|
|
397
|
+ ->setCellValue('A1', 'ID')
|
|
|
398
|
+ ->setCellValue('B1', '订单号')
|
|
|
399
|
+ ->setCellValue('C1', '订单类型')
|
|
|
400
|
+ ->setCellValue('D1', '销售用户名')
|
|
|
401
|
+ ->setCellValue('E1', '订单确认码')
|
|
|
402
|
+ ->setCellValue('F1', '订单状态')
|
|
|
403
|
+ ->setCellValue('G1', '收集状态')
|
|
|
404
|
+ ->setCellValue('H1', '发布时间')
|
|
|
405
|
+ ->setCellValue('I1', '失效时间');
|
|
|
406
|
+
|
|
|
407
|
+ // 设置表单字段的单元格宽度及第一行文字
|
|
|
408
|
+ $option_id_array = [];
|
|
|
409
|
+ foreach ($option_list as $k=>$v) {
|
|
|
410
|
+ $column = $this->IntToChr($k+10);
|
|
|
411
|
+ $objPHPExcel->getActiveSheet()->getColumnDimension($column)->setWidth(20);
|
|
|
412
|
+ $objPHPExcel->setActiveSheetIndex(0)
|
|
|
413
|
+ ->setCellValue($column.'1', $v['name']);
|
|
|
414
|
+ $option_id_array[$k] = $v['id'];
|
|
|
415
|
+ }
|
|
|
416
|
+
|
|
|
417
|
+ $i = 2;
|
|
|
418
|
+
|
|
|
419
|
+ // 循环到导出数据
|
|
|
420
|
+ foreach ($array as $v) {
|
|
|
421
|
+ $status = '未支付';
|
|
|
422
|
+ if($v['status'] == 1) {
|
|
|
423
|
+ $status = '已支付';
|
|
|
424
|
+ }
|
|
|
425
|
+ $is_stop = '收集中';
|
|
|
426
|
+ if($v['is_stop'] == 1) {
|
|
|
427
|
+ $is_stop = '已停止';
|
|
|
428
|
+ }
|
|
|
429
|
+ $objPHPExcel->setActiveSheetIndex(0)
|
|
|
430
|
+ ->setCellValue('A' . $i, $v['id'])
|
|
|
431
|
+ ->setCellValueExplicit('B' . $i, $v['order_sn'],\PHPExcel_Cell_DataType::TYPE_STRING)
|
|
|
432
|
+// ->setCellValueExplicit('B' . $i, $v['order_sn'],\PHPExcel_Cell_DataType::TYPE_STRING)
|
|
|
433
|
+ ->setCellValue('C' . $i, $v['sort_name'])
|
|
|
434
|
+ ->setCellValue('D' . $i, $v['user_login'])
|
|
|
435
|
+ ->setCellValue('E' . $i, $v['number'])
|
|
|
436
|
+ ->setCellValue('F' . $i, $status)
|
|
|
437
|
+ ->setCellValue('G' . $i, $is_stop)
|
|
|
438
|
+ ->setCellValue('H' . $i, date('Y-m-d H:i',$v['create_time']))
|
|
|
439
|
+ ->setCellValue('I' . $i, date('Y-m-d H:i',$v['over_time']));
|
|
|
440
|
+ $v['options'] = json_decode($v['options'],true);
|
|
|
441
|
+ foreach ($v['options'] as $ks=>$vs) {
|
|
|
442
|
+// $where = [
|
|
|
443
|
+// 'id' => $vs['id']
|
|
|
444
|
+// ];
|
|
|
445
|
+// $vs['cell'] = Db::name('OrderOption')->where($where)->value('cell');
|
|
|
446
|
+ $key = array_search($vs['id'], $option_id_array);
|
|
|
447
|
+ $vs['cell'] = $this->IntToChr($key+10);
|
|
|
448
|
+ if($vs['cell']) {
|
|
|
449
|
+ if($vs['type'] == 3) {
|
|
|
450
|
+ // 纯数字字段转化为字符串格式,防止以科学计数法进行显示
|
|
|
451
|
+ $objPHPExcel->setActiveSheetIndex(0)
|
|
|
452
|
+ ->setCellValueExplicit($vs['cell'] . $i, $vs['user_choose'],\PHPExcel_Cell_DataType::TYPE_STRING);
|
|
|
453
|
+ } elseif($vs['type'] == 8) {
|
|
|
454
|
+ // 导出图片格式,高度自适应
|
|
|
455
|
+ $filePath = './upload/'.$vs['user_choose'];
|
|
|
456
|
+ if(!empty($vs['user_choose']) && file_exists($filePath)) {
|
|
|
457
|
+ $image = \think\Image::open('./upload/'.$vs['user_choose']);
|
|
|
458
|
+ // 返回图片的宽度
|
|
|
459
|
+ $width = $image->width();
|
|
|
460
|
+ // 返回图片的高度
|
|
|
461
|
+ $height = $image->height();
|
|
|
462
|
+ $default = $height/($width/100);
|
|
|
463
|
+ //设置默认行高(通过图片缩放比例计算高度)
|
|
|
464
|
+ $objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight($default);
|
|
|
465
|
+ // 图片生成
|
|
|
466
|
+ $objDrawing[$i] = new \PHPExcel_Worksheet_Drawing();
|
|
|
467
|
+ $objDrawing[$i]->setPath($filePath);
|
|
|
468
|
+ // 设置宽度
|
|
|
469
|
+ $objDrawing[$i]->setWidth(100); //照片宽度
|
|
|
470
|
+ /*设置图片要插入的单元格*/
|
|
|
471
|
+ $objDrawing[$i]->setCoordinates($vs['cell'].$i);
|
|
|
472
|
+ // 图片偏移距离
|
|
|
473
|
+ $objDrawing[$i]->setOffsetX(12);
|
|
|
474
|
+ $objDrawing[$i]->setOffsetY(12);
|
|
|
475
|
+ $objDrawing[$i]->setWorksheet($objPHPExcel->getActiveSheet());
|
|
|
476
|
+ }
|
|
|
477
|
+ } else {
|
|
|
478
|
+ $objPHPExcel->setActiveSheetIndex(0)
|
|
|
479
|
+ ->setCellValue($vs['cell'] . $i, $vs['user_choose']);
|
|
|
480
|
+ }
|
|
|
481
|
+ }
|
|
|
482
|
+ }
|
|
|
483
|
+ $i++;
|
|
|
484
|
+ Db::name('Order')->where(['order_sn'=>$v['order_sn']])->update(['is_excel'=>1,'excel_time'=>time()]);
|
|
|
485
|
+ }
|
|
|
486
|
+
|
|
|
487
|
+ $filename = '订单数据导出'. date('Y-m-d').'.xls';
|
|
|
488
|
+ ob_end_clean();
|
|
|
489
|
+ header("Content-type:application/vnd.ms-excel;charset=UTF-8");
|
|
|
490
|
+ header('Content-Type: application/vnd.ms-excel');
|
|
|
491
|
+ header('Content-Disposition: attachment;filename="' . $filename . '"');
|
|
|
492
|
+ header('Cache-Control: max-age=0');
|
|
|
493
|
+ $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
494
|
+ $objWriter->save('php://output');
|
|
|
495
|
+ }
|
|
|
496
|
+
|
|
|
497
|
+ /**
|
|
|
498
|
+ * 编辑订单
|
|
|
499
|
+ * @adminMenu(
|
|
|
500
|
+ * 'name' => '编辑订单',
|
|
|
501
|
+ * 'parent' => 'index',
|
|
|
502
|
+ * 'display'=> false,
|
|
|
503
|
+ * 'hasView'=> false,
|
|
|
504
|
+ * 'order' => 4,
|
|
|
505
|
+ * 'icon' => '',
|
|
|
506
|
+ * 'remark' => '编辑订单',
|
|
|
507
|
+ * 'param' => ''
|
|
|
508
|
+ * )
|
|
|
509
|
+ */
|
|
|
510
|
+ public function edit() {
|
|
|
511
|
+ $id = $this->request->param('id',0,'intval');
|
|
|
512
|
+ if(!$id) {
|
|
|
513
|
+ $this->error('参数错误');
|
|
|
514
|
+ }
|
|
|
515
|
+ $where = [
|
|
|
516
|
+ 'id' => $id,
|
|
|
517
|
+ 'delete_time'=>0
|
|
|
518
|
+ ];
|
|
|
519
|
+ $info = Db::name('order_view')->where($where)->find();
|
|
|
520
|
+ $info['options'] = json_decode($info['options'],true);
|
|
|
521
|
+ foreach ($info['options'] as $k=>$v) {
|
|
|
522
|
+ $optionsInfo = $this->singleData($this->option_table,['id'=>$v['id']]);
|
|
|
523
|
+ $v['name'] = $optionsInfo['name'];
|
|
|
524
|
+ $v['html'] = $this->form_model($v);
|
|
|
525
|
+ $info['group'][] = $v;
|
|
|
526
|
+ }
|
|
|
527
|
+ $this->assign($info);
|
|
|
528
|
+ return $this->fetch();
|
|
|
529
|
+ }
|
|
|
530
|
+
|
|
|
531
|
+ // 处理订单模型数据
|
|
|
532
|
+ private function form_model($formData) {
|
|
|
533
|
+ $html = $this->sort_model[$formData['type']];
|
|
|
534
|
+ $html = str_replace('{name}',$formData['name'],$html);
|
|
|
535
|
+ if($formData['checked'] == 1) {
|
|
|
536
|
+ $html = str_replace('{must}','*',$html);
|
|
|
537
|
+ $html = str_replace('{validate}',1,$html);
|
|
|
538
|
+ } else {
|
|
|
539
|
+ $html = str_replace('{must}','',$html);
|
|
|
540
|
+ $html = str_replace('{validate}',0,$html);
|
|
|
541
|
+ }
|
|
|
542
|
+ if(!empty($formData['values']) && $formData['values'] != null) {
|
|
|
543
|
+ $array = explode(',',$formData['values']);
|
|
|
544
|
+ $options = '';
|
|
|
545
|
+ foreach ($array as $k=>$v) {
|
|
|
546
|
+ $active = isset($formData['user_choose'])?($formData['user_choose']==$v?'active':''):($k==0?'active':'');
|
|
|
547
|
+ $options .= '<p class="order_style '.$active.'">'.$v.'</p>';
|
|
|
548
|
+ }
|
|
|
549
|
+ $html = str_replace('{options}',$options,$html);
|
|
|
550
|
+ }
|
|
|
551
|
+ if(!empty($formData['user_choose'])) {
|
|
|
552
|
+ $html = str_replace('{value}',$formData['user_choose'],$html);
|
|
|
553
|
+ } else {
|
|
|
554
|
+ $html = str_replace('{value}','',$html);
|
|
|
555
|
+ }
|
|
|
556
|
+ return $html;
|
|
|
557
|
+ }
|
|
|
558
|
+
|
|
|
559
|
+ /**
|
|
|
560
|
+ * 修改订单收集状态
|
|
|
561
|
+ * @adminMenu(
|
|
|
562
|
+ * 'name' => '修改订单收集状态',
|
|
|
563
|
+ * 'parent' => 'index',
|
|
|
564
|
+ * 'display'=> false,
|
|
|
565
|
+ * 'hasView'=> false,
|
|
|
566
|
+ * 'order' => 5,
|
|
|
567
|
+ * 'icon' => '',
|
|
|
568
|
+ * 'remark' => '修改订单收集状态',
|
|
|
569
|
+ * 'param' => ''
|
|
|
570
|
+ * )
|
|
|
571
|
+ */
|
|
|
572
|
+ public function stop()
|
|
|
573
|
+ {
|
|
|
574
|
+ $param = $this->request->param();
|
|
|
575
|
+ $msg = '';
|
|
|
576
|
+
|
|
|
577
|
+ if (isset($param['ids']) && isset($param["is_stop"])) {
|
|
|
578
|
+ $stop = $param["is_stop"];
|
|
|
579
|
+ $ids = $this->request->param('ids/a');
|
|
|
580
|
+
|
|
|
581
|
+ $this->order_model->where(['id' => ['in', $ids]])->update(['is_stop' => $stop, 'update_time' => time()]);
|
|
|
582
|
+
|
|
|
583
|
+ if($stop == 0) {
|
|
|
584
|
+ $msg = "开启收集成功!";
|
|
|
585
|
+ }
|
|
|
586
|
+ if($stop == 1) {
|
|
|
587
|
+ $msg = "停止收集成功!";
|
|
|
588
|
+ }
|
|
|
589
|
+ $this->success($msg, '');
|
|
|
590
|
+
|
|
|
591
|
+ }
|
|
|
592
|
+ if (isset($param['id']) && isset($param["is_stop"])) {
|
|
|
593
|
+ $stop = $param["is_stop"];
|
|
|
594
|
+ $id = $this->request->param('id');
|
|
|
595
|
+
|
|
|
596
|
+ $this->order_model->where(['id' => $id])->update(['is_stop' => $stop, 'update_time' => time()]);
|
|
|
597
|
+
|
|
|
598
|
+ if($stop == 0) {
|
|
|
599
|
+ $msg = "开启收集成功!";
|
|
|
600
|
+ }
|
|
|
601
|
+ if($stop == 1) {
|
|
|
602
|
+ $msg = "停止收集成功!";
|
|
|
603
|
+ }
|
|
|
604
|
+ $this->success($msg,'');
|
|
|
605
|
+
|
|
|
606
|
+ }
|
|
|
607
|
+ }
|
|
|
608
|
+
|
|
|
609
|
+ /**
|
|
|
610
|
+ * 删除订单
|
|
|
611
|
+ * @adminMenu(
|
|
|
612
|
+ * 'name' => '删除订单',
|
|
|
613
|
+ * 'parent' => 'index',
|
|
|
614
|
+ * 'display'=> false,
|
|
|
615
|
+ * 'hasView'=> false,
|
|
|
616
|
+ * 'order' => 6,
|
|
|
617
|
+ * 'icon' => '',
|
|
|
618
|
+ * 'remark' => '删除订单',
|
|
|
619
|
+ * 'param' => ''
|
|
|
620
|
+ * )
|
|
|
621
|
+ */
|
|
|
622
|
+ public function delete() {
|
|
|
623
|
+ $id = $this->request->param('id',0,'intval');
|
|
|
624
|
+ $ids = $this->request->param('ids/a');
|
|
|
625
|
+ if(isset($id)) {
|
|
|
626
|
+ $result = $this->order_model->where(['id'=>$id])->update(['delete_time'=>time()]);
|
|
|
627
|
+ }
|
|
|
628
|
+ if(isset($ids)) {
|
|
|
629
|
+ $result = $this->order_model->where(['id'=>['in',$ids]])->update(['delete_time'=>time()]);
|
|
|
630
|
+ }
|
|
|
631
|
+ if(!$result) {
|
|
|
632
|
+ $this->error('删除失败');
|
|
|
633
|
+ }
|
|
|
634
|
+ $this->success('删除成功');
|
|
|
635
|
+ }
|
|
|
636
|
+} |