...
|
...
|
@@ -75,9 +75,48 @@ class VolunteerController extends AdminBaseController |
|
|
$level_map['max'] = ['>', $param['work_time']];
|
|
|
$level = db('level')->where($level_map)->value('level');
|
|
|
$param['level'] = $level;
|
|
|
Db::name('volunteer')
|
|
|
$result= Db::name('volunteer')
|
|
|
->where('id', $id)
|
|
|
->update($param);
|
|
|
/*发送模板消息进行通知*/
|
|
|
if ($result>0){
|
|
|
$volunteer=\db('volunteer')->where('user_id',$id)->find();
|
|
|
$userMap['user_id']=$id;
|
|
|
$openid=db('third_party_user')->where($userMap)->value('openid');
|
|
|
$formMap['user_id']=$id;
|
|
|
$formMap['use_time']=0;
|
|
|
$formMap['expire_time']=['>',time()];
|
|
|
$form_id=\db('form_id')->where($formMap)->find();
|
|
|
if (!empty($form_id)&& $param['status']!=1){
|
|
|
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]);
|
|
|
$data['keyword1']= $volunteer['name'];
|
|
|
$data['keyword2']='志愿者审核';
|
|
|
if ($param['status']==2){
|
|
|
$data['keyword3']='通过';
|
|
|
}
|
|
|
if ($param['status']==3){
|
|
|
$data['keyword3']='未通过 原因:'.$param['refund_reason'];
|
|
|
}
|
|
|
$data['keyword4']='申请成为志愿者';
|
|
|
$message = [
|
|
|
'touser' => $openid,
|
|
|
'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw',
|
|
|
'page' => 'pages/index/index',
|
|
|
'form_id' => $form_id['value'],
|
|
|
'data' => $data,
|
|
|
'emphasis_keyword' =>$data['keyword3']='状态',
|
|
|
];
|
|
|
$this->wxappNotice($message);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
$this->success('操作成功!');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->success('更新成功!');
|
|
|
} else {
|
...
|
...
|
@@ -91,6 +130,28 @@ class VolunteerController extends AdminBaseController |
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 模板消息发送
|
|
|
* @param $message
|
|
|
* @return \EasyWeChat\Support\Collection
|
|
|
* @throws \EasyWeChat\Core\Exceptions\InvalidArgumentException
|
|
|
*/
|
|
|
protected function wxappNotice($message){
|
|
|
$appId = 'wx7a3bf4e0796c070a';
|
|
|
$secret = '755478f064e09a8301345e0c427c6cf3';
|
|
|
$config = [
|
|
|
'app_id' => $appId,
|
|
|
'secret' => $secret,
|
|
|
];
|
|
|
try{
|
|
|
$wechat=new Application($config);
|
|
|
$notice=$wechat->mini_program->notice;
|
|
|
$result= $notice->send($message);
|
|
|
}catch(Exception $e){
|
|
|
$e->getMessage();
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
//删除
|
|
|
public function delete()
|
|
|
{
|
...
|
...
|
@@ -213,4 +274,40 @@ class VolunteerController extends AdminBaseController |
|
|
$letter = $Excel->excelAcross(count($title));
|
|
|
$Excel->excel($letter, $title, $data, '志愿者列表');
|
|
|
}
|
|
|
|
|
|
public function sendnotice(){
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
|
|
|
public function sendsms(){
|
|
|
$data = Db::name('volunteer')
|
|
|
->where('delete_time', 0)
|
|
|
->order('create_time desc')
|
|
|
->select();
|
|
|
$this->assign([
|
|
|
'list' => $data,
|
|
|
]);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
public function smsPost(){
|
|
|
$user=input('to_user_id');
|
|
|
$content=input('description');
|
|
|
if (empty($user)||$user==0){
|
|
|
$this->error('请选择用户!');
|
|
|
}
|
|
|
if (empty($content)){
|
|
|
$this->error('内容不能为空!');
|
|
|
}
|
|
|
$users=explode(',',$user);
|
|
|
dump($users);
|
|
|
foreach($users as $k=>$v){
|
|
|
|
|
|
send_sms();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|