ApprovalController.php
3.6 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
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2019/1/15
* Time: 11:10
*/
namespace app\admin\controller;
use app\user\model\UserModel;
use cmf\controller\AdminBaseController;
use EasyWeChat\Foundation\Application;
/**
* Class GroupController
* @package app\admin\controller
* @adminMenuRoot(
* 'name' => '审批管理',
* 'action' => 'default',
* 'parent' => '',
* 'display'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => ''
* )
*/
class ApprovalController extends AdminBaseController
{
/**
*进修审批列表
* @adminMenu(
* 'name' => '进修审批列表',
* 'parent' => 'default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '进修审批管理',
* 'param' => ''
* )
*/
public function engageList(){
$map['delete_time']=null;
$list=db('engage')->where($map)->order('id','desc')->paginate('20');
$page = $list->render();
$this->assign('list', $list);
$this->assign('page', $page);
return $this->fetch();
}
/**
*进修详情
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function engageDetail(){
$id=input('id');
$info=db('engage')->where('id',$id)->find();
$this->assign('info',$info);
return $this->fetch();
}
/**
* 删除信息
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function engageDelete(){
$map['id']=input('id');
$update['delete_time']=time();
$result=db('engage')->where($map)->update($update);
if ($result==1){
$this->success('删除成功!');
}else{
$this->error('删除失败!');
}
}
/**
* 编辑信息
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function engageEdit(){
$map['id']=input('id');
$update['state']=input('state');
$update['answer']=input('answer');
$result=db('engage')->where($map)->update($update);
if ($result==1){
/*发送模板消息*/
$engage=db('engage')->where($map)->find();
$User=new UserModel();
$openid=$User->getUserOpenid($engage['user_id']);
$userId = $openid;
$templateId = 'M0PtJ9xxGWkMoCI6p1ZhQLyj83k3PAqkeG94yyMRxD4';
$url = url('user/expert/engagedetail',['id'=>$map['id']],'',true);
if($update['state']==1){
$first='恭喜您,您提交的进修申请已通过';
}else{
$first='对不起,您提交的进修申请已被驳回';
}
$data = array(
"first"=>"$first",
"keyword1" => "$engage[user_name]",
"keyword2" => $engage['phone_num'],
"keyword3" => date('Y-m-d H:i',$engage['add_time']),
"keyword4" => "进修申请",
"remark" => "点击查看详情确认信息",
);
$config=config('wechat_config');
$Wechat=new Application($config);
$notice = $Wechat->notice;
$result = $notice->uses($templateId)->withUrl($url)->andData($data)->andReceiver($userId)->send();
$this->success('审核成功!');
}else{
$this->error('审核失败!');
}
}
}