OrderController.php
2.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
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2019/1/19
* Time: 15:17
*/
namespace app\admin\controller;
use app\admin\model\OrderModel;
use cmf\controller\AdminBaseController;
use think\Request;
/**
* Class OrderController
* @package app\admin\controller
* @adminMenuRoot(
* 'name' => '订单列表',
* 'action' => 'default',
* 'parent' => '',
* 'display'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '管理组'
* )
*/
class OrderController extends AdminBaseController
{
/**
*订单列表
* @adminMenu(
* 'name' => '订单列表',
* 'parent' => 'default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '订单列表',
* 'param' => ''
* )
*/
public function index(){
$Order=new OrderModel();
$map['o.delete_time']=null;
$list=$Order->alias('o')
->field('o.*,u.user_login,u.avatar,g.name')
->join('user u','u.id=o.user_id')
->join('goods g','g.id=o.good_id')
->where($map)
->order('id','desc')
->paginate('20');
$page = $list->render();
$this->assign('list',$list);
$this->assign('page',$page);
return $this->fetch();
}
public function orderDelete(){
$id=input('id');
$delete['delete_time']=time();
$result=db('order')->where('id',$id)->update($delete);
if ($result==1){
$this->success('操作成功!');
}else{
$this->error('操作失败!');
}
}
public function orderDetail(){
$map['o.id']=input('id');
$info=db('order')
->alias('o')
->field('o.*,u.user_login,u.avatar,g.name')
->join('user u','u.id=o.user_id')
->join('goods g','g.id=o.good_id')
->where($map)
->find();
$this->assign('info',$info);
return $this->fetch();
}
public function orderEdit(){
$map['id']=input('good_id');
$data=input();
unset($data['good_id']);
$result=db('order')->where($map)->update($data);
if ($result==1){
$this->success('编辑成功!');
}else{
$this->error('编辑失败!');
}
}
}