rzcheck.inc.php
7.66 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php
global $_GPC, $_W;
$day=100;
// echo date('Y-m-d H:i:s',strtotime("+{$day}day"));die;
// echo strtotime('2020-06-08');die;
$GLOBALS['frames'] = $this->getMainMenu();
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
$type=empty($_GPC['type']) ? 'all' :$_GPC['type'];
$state=$_GPC['state'];
$pageindex = max(1, intval($_GPC['page']));
$pagesize=20;
$where=' WHERE uniacid=:uniacid and sq_id>0 and zf_state=2';
$data[':uniacid']=$_W['uniacid'];
if($_GPC['keywords']){
$op=$_GPC['keywords'];
$where.=" and name LIKE concat('%', :name,'%') ";
$data[':name']=$op;
}
if($type !='all'){
$where.= " and state=".$state;
}
$sql="SELECT * FROM ".tablename('cjdc_store'). $where." ORDER BY id DESC";
$total=pdo_fetchcolumn("SELECT count(*) FROM ".tablename('cjdc_store') .$where,$data);
$select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
$list=pdo_fetchall($select_sql,$data);
$pager = pagination($total, $pageindex, $pagesize);
if($operation=='adopt'){//审核通过
$id=$_GPC['id'];
$store=pdo_get('cjdc_store',array('id'=>$id));
if(!$store['md_type']){
message('门店类型不能为空,为门店编辑分类后再来审核!','','error');
}
$dqtime=date('Y-m-d H:i:s',strtotime("+{$store['rz_time']}day"));
$res=pdo_update('cjdc_store',array('state'=>2,'rzdq_time'=>$dqtime),array('id'=>$id));
if($res){
$set=pdo_get('cjdc_storeset',array('store_id'=>$id));
if(!$set){
$data3['store_id']=$id;
pdo_insert('cjdc_storeset',$data3);
}
pdo_delete('cjdc_formid',array('time <='=>time()-60*60*24*7));
///////////////模板消息拒绝///////////////////
function getaccess_token($_W){
$res=pdo_get('cjdc_system',array('uniacid'=>$_W['uniacid']));
$appid=$res['appid'];
$secret=$res['appsecret'];
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret."";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
$data = curl_exec($ch);
curl_close($ch);
$data = json_decode($data,true);
return $data['access_token'];
}
//设置与发送模板信息
function set_msg($_W){
$access_token = getaccess_token($_W);
$res=pdo_get('cjdc_message',array('uniacid'=>$_W['uniacid']));
$res2=pdo_get('cjdc_store',array('id'=>$_GET['id']));
$user=pdo_get('cjdc_user',array('id'=>$res2['sq_id']));
if($res2['state']==2){
$state="审核通过";
$note="审核通过,请尽快完善信息";
} if($res2['state']==3){
$state="审核拒绝";
$note="审核拒绝,请核对信息后再次提交";
}
$form=pdo_get('cjdc_formid',array('user_id'=>$res2['sq_id'],'time >='=>time()-60*60*24*7));
$formwork ='{
"touser": "'.$user["openid"].'",
"template_id": "'.$res["rzcg_tid"].'",
"page": "zh_cjdianc/pages/Liar/loginindex",
"form_id":"'.$form['form_id'].'",
"data": {
"keyword1": {
"value": "'.$state.'",
"color": "#173177"
},
"keyword2": {
"value":"'.$res2['sq_time'].'",
"color": "#173177"
},
"keyword3": {
"value": "'.$res2['name'].'",
"color": "#173177"
},
"keyword4": {
"value": "'. $note.'",
"color": "#173177"
}
}
}';
// $formwork=$data;
$url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=".$access_token."";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$formwork);
$data = curl_exec($ch);
curl_close($ch);
// return $data;
pdo_delete('cjdc_formid',array('id'=>$form['id']));
}
echo set_msg($_W);
message('审核成功',$this->createWebUrl('rzcheck',array()),'success');
}else{
message('审核失败','','error');
}
}
if($operation=='reject'){
$id=$_GPC['id'];
$res=pdo_update('cjdc_store',array('state'=>3),array('id'=>$id));
if($res){
pdo_delete('cjdc_formid',array('time <='=>time()-60*60*24*7));
///////////////模板消息拒绝///////////////////
function getaccess_token($_W){
$res=pdo_get('cjdc_system',array('uniacid'=>$_W['uniacid']));
$appid=$res['appid'];
$secret=$res['appsecret'];
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret."";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
$data = curl_exec($ch);
curl_close($ch);
$data = json_decode($data,true);
return $data['access_token'];
}
//设置与发送模板信息
function set_msg($_W){
$access_token = getaccess_token($_W);
$res=pdo_get('cjdc_message',array('uniacid'=>$_W['uniacid']));
$res2=pdo_get('cjdc_store',array('id'=>$_GET['id']));
$user=pdo_get('cjdc_user',array('id'=>$res2['sq_id']));
if($res2['state']==2){
$state="审核通过";
$note="审核通过,请尽快完善信息";
} if($res2['state']==3){
$state="审核拒绝";
$note="审核拒绝,请核对信息后再次提交";
}
$form=pdo_get('cjdc_formid',array('user_id'=>$res2['sq_id'],'time >='=>time()-60*60*24*7));
$formwork ='{
"touser": "'.$user["openid"].'",
"template_id": "'.$res["rzcg_tid"].'",
"page": "zh_cjdianc/pages/Liar/loginindex",
"form_id":"'.$form['form_id'].'",
"data": {
"keyword1": {
"value": "'.$state.'",
"color": "#173177"
},
"keyword2": {
"value":"'.$res2['sq_time'].'",
"color": "#173177"
},
"keyword3": {
"value": "'.$res2['name'].'",
"color": "#173177"
},
"keyword4": {
"value": "'. $note.'",
"color": "#173177"
}
}
}';
// $formwork=$data;
$url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=".$access_token."";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$formwork);
$data = curl_exec($ch);
curl_close($ch);
// return $data;
pdo_delete('cjdc_formid',array('id'=>$form['id']));
}
echo set_msg($_W);
message('拒绝成功',$this->createWebUrl('rzcheck',array()),'success');
}else{
message('拒绝失败','','error');
}
}
if($operation=='delete'){
$id=$_GPC['id'];
$res=pdo_delete('cjdc_store',array('id'=>$id));
if($res){
message('删除成功',$this->createWebUrl('rzcheck',array()),'success');
}else{
message('删除失败','','error');
}
}
include $this->template('web/rzcheck');