ApprovalController.php
3.2 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
<?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){
/*发送模板消息*/
$user_id=db('engage')->where($map)->value('user_id');
$User=new UserModel();
$openid=$User->getUserOpenid();
$userId = $openid;
$templateId = 'M0PtJ9xxGWkMoCI6p1ZhQLyj83k3PAqkeG94yyMRxD4';
$url = 'http://overtrue.me';
$data = array(
"keyword1" => "恭喜你购买成功!",
"keyword2" => "巧克力",
"keyword3" => "39.8元",
"keyword4" => "欢迎再次购买!",
);
$Wechat=new Application();
$notice = $Wechat->notice;
$result = $notice->uses($templateId)->withUrl($url)->andData($data)->andReceiver($userId)->send();
var_dump($result);
$this->success('审核成功!');
}else{
$this->error('审核失败!');
}
}
}