TeamController.php
4.9 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2020/10/12
* Time: 9:54
*/
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
class TeamController extends AdminBaseController
{
/**
* 首页内容
* @return mixed
* @throws \think\exception\DbException
*/
public function index(){
$teamId=$this->getAdminTeamId();
$param=$this->request->param();
if ($teamId==0){
$map=[];
}else{
$map['id']=$teamId;
}
$data= db('team')->where($map)->order('id desc')->paginate();
$data->appends($param);
$list=$data->items();
$this->assign([
'data'=>$list,
'page'=>$data->render(),
]);
$this->assign('teamId',$teamId);
return $this->fetch();
}
/**
* 申请列表
*/
public function applylist(){
$param=$this->request->param();
$map['t.team_id']=$param['id'];
$data= db('team_apply')
->field('t.*,v.name')
->alias('t')->join('volunteer v','v.user_id=t.user_id')
->where($map)
->order('t.id desc')
->paginate();
$data->appends($param);
$list=$data->items();
$this->assign([
'data'=>$list,
'page'=>$data->render(),
]);
return $this->fetch();
}
/**
* 是否通过
*/
public function pass(){
$data=input();
$update['status']=$data['status'];
$info=db('team')->where('id',$data['id'])->update($update);
if (!empty($info)){
$this->success('操作成功!');
}else{
$this->error('操作失败');
}
}
/**
* 编辑
*/
public function edit(){
$id=input('id');
$data=db('team')->where('id',$id)->find();
$provincedb=db('position_province')->select()->toArray();
foreach ($provincedb as $k=>$v){
$province[$v['id']]['name']=$v['province_name'];
$province[$v['id']]['id']=$v['id'];
}
$this->assign('data',$data);
$this->assign('area',$province);
return $this->fetch();
}
/**
* 编辑提交
*/
public function editPost(){
$id=input('id');
$data=input('');
$info=db('team')->where('id',$data['id'])->update($data);
$this->success('操作成功!');
}
/**
* 申请通过
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function apply_pass(){
$teamId=$this->getAdminTeamId();
$data=input();
$update['status']=$data['status'];
$info=db('team_apply')->where('id',$data['id'])->find();
db('team')->where('id',$info['team_id'])->setInc('people_num');
$info=db('team_apply')->where('id',$data['id'])->update($update);
if (!empty($info)){
if ($data['status']==1){
$action='审核通过';
}else{
$action='审核不同过';
}
if ($teamId>0){
$this->addTeamLog($teamId,'团队',$action,$info);
}
$openid=db('third_party_user')->where('user_id',$info['user_id'])->value('openid');
$volunteer=db('volunteer')->where('user_id',$info['user_id'])->find();
$date=date('Y-m-d H:i');
$data=[
'phrase1' => ['value' =>"$volunteer[name] $action"], //审核结果
'thing2'=>['value'=>$info['name']], //活动名称
'thing4'=>['value'=>$action], //备注
'date7'=>['value'=>$date] //审核时间
];
$Info=sendSubMessage($data,$openid);
$this->success('操作成功!');
}else{
$this->success('操作成功!');
}
}
/**
* 添加团队
* @return mixed
*/
public function addTeam(){
$provincedb=db('position_province')->select()->toArray();
foreach ($provincedb as $k=>$v){
$province[$v['id']]['name']=$v['province_name'];
$province[$v['id']]['id']=$v['id'];
}
$this->assign('area',$province);
return $this->fetch();
}
/**
* 提交信息
*/
public function addPost(){
$data=input('');
$data['create_time']=time();
$info=db('team')->insert($data);
if (!empty($info)){
$this->success('操作成功!');
}
}
/**
* 删除信息
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function delete(){
$id=input('id');
db('team')->where('id',$id)->delete();
$this->success('操作成功!');
}
}