public function UpdateStaffRoleAction() { $request = $this->getRequest(); $conn = $this->get("we_data_access"); $conn_im = $this->get("we_data_access_im"); $currUser = $this->get('security.context')->getToken(); if (!empty($currUser)) { $currUser = $currUser->getUser(); } else { //当应用通过api接口调用时,不用登录,只能通过openid获取人员信息 $baseinfoCtl = new Staff($conn, null, $request->get("openid"), $this->get("logger")); $currUser = $baseinfoCtl->getSessionUser(); } $rolecode = $request->get("rolecode"); $newrolecode = $request->get("newrolecode"); $staffRole = new StaffRole($conn, $conn_im, $this->get("logger")); $re = $staffRole->UpdateStaffRoleByCode($currUser->getUsername(), $rolecode, $newrolecode, $currUser->getEno()); $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function UserAgreeAction() { $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $logger = $this->get('logger'); $request = $this->getRequest(); $apply_id = $request->get('apply_id'); $re = $request->get('re'); $user = $this->get('security.context')->getToken()->getUser(); $r = array('s' => 1, 'm' => ''); try { //验证是否能审核 $sql = "select result,is_valid from we_apply where id=?"; $params = array($apply_id); $ds = $da->Getdata('info', $sql, $params); if ($ds['info']['recordcount'] == 0) { $r = array('s' => 0, 'm' => '该条审核记录已失效'); } else { if ($ds['info']['rows'][0]['is_valid'] == '0') { $r = array('s' => 0, 'm' => '你已经审核过了!'); } } if ($r['s'] == '1') { //同意人数 $sql = "select a.content,a.account,b.openid,b.fafa_jid from we_apply a left join we_staff b on b.login_account=a.account where a.id=?"; $params = array($apply_id); $ds = $da->Getdata('content', $sql, $params); if ($ds['content']['recordcount'] > 0) { $content = $ds['content']['rows'][0]['content']; $account = $ds['content']['rows'][0]['account']; $acc_openid = $ds['content']['rows'][0]['openid']; $acc_jid = $ds['content']['rows'][0]['fafa_jid']; $num = (int) $content; $sql2[] = "select 1 from we_apply where account=? and recv_type='p' and result='1'"; $sql2[] = "select distinct recv_id from we_apply where account=? and recv_type='p' and result='0'"; $sql2[] = "select distinct recv_id from we_apply where account=? and recv_type='p'"; $params2[] = array($account); $params2[] = array($account); $params2[] = array($account); $ds = $da->GetDatas(array('agreenum', 'confictnum', 'allnum'), $sql2, $params2); $n = $ds['agreenum']['recordcount']; $m = $ds['confictnum']['recordcount']; $allnum = $ds['allnum']['recordcount']; if ($re == '1') { $n++; } if ($re == '0') { $m++; } //更新审核结果 $sql1[] = "update we_apply set result=?,is_valid='0' where id=? and (result is null or result='') and is_valid='1'"; $params1[] = array($re, $apply_id); if ($num <= $n) { $sql1[] = "update we_staff set auth_level=? where login_account=?"; $params1[] = array($user->eno_level, $account); if ($user->edomain == $user->eno) { $sql = "select 1 from we_public_domain where LOCATE(domain_name,?)=0 and not exists(select 1 from we_enterprise where edomain=?)"; $params = array($account, $this->getSubDomain($account)); $ds = $da->Getdata('acc', $sql, $params); if ($ds['acc']['recordcount'] > 0) { $sql1[] = "update we_enterprise set edomain=? where eno=?"; $params1[] = array($this->getSubDomain($account), $user->eno); $sql1[] = "update we_enterprise_stored set eno_mail=? where enoname=?"; $params1[] = array($account, $user->ename); $sql1[] = "update we_circle set network_domain=? where enterprise_no=?"; $params1[] = array($this->getSubDomain($account), $user->eno); } } //写入消息 $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $msg = "您已通过身份认证,现在就可以正常使用Wefafa平台了!"; $sql1[] = "insert into we_message (msg_id,sender,recver,title,content,send_date) values(?,?,?,?,?,now())"; $params1[] = array($msg_id, '*****@*****.**', $account, '用户认证协助审核', $msg); } if ($allnum - $m < $num) { //写入消息 $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $msg = "您的身份认证申请未通过审核。"; $sql1[] = "insert into we_message (msg_id,sender,recver,title,content,send_date) values(?,?,?,?,?,now())"; $params1[] = array($msg_id, '*****@*****.**', $account, '用户认证协助审核', $msg); } if (!$da->ExecSQLs($sql1, $params1)) { $r = array('s' => 0, 'm' => '系统错误'); } if ($r['s'] == '1') { //通知申请人审核结果 //Utils::sendImMessage($user->openid,$acc_openid,"用户身份认证",$user->nick_name.($re=='1'?"通过了您的加入请求。":"拒绝了您的加入请求。"),$this->container,"","",true,Utils::$systemmessage_code); if ($num <= $n) { //同步权限到Rbac $staffRole = new StaffRole($da, $da_im, $this->get('logger')); /* if($user->vip_level!='0') $staffRole->UpdateStaffRoleByCode($account,(Identify::$SIdent).($user->vip_level),(Identify::$BIdent).($user->vip_level),$user->eno); else $staffRole->UpdateStaffRoleByCode($account,(Identify::$SIdent).($user->vip_level),(Identify::$MIdent).($user->vip_level),$user->eno); */ $staffRole->UpdateStaffRoleByCode($account, Identify::$SIdent . $user->vip_level, $user->eno_level . $user->vip_level, $user->eno); //通知申请人权限已通过 Utils::sendImMessage('', $acc_openid, "用户身份认证", "您的身份认证申请已被审核通过。", $this->container, "", "", true, Utils::$systemmessage_code); //发送出席 Utils::sendImPresence('', $acc_jid, "用户身份认证", "您的身份认证申请已被审核通过。", $this->container, "", "", false, Utils::$eno_identify_auth); } else { if ($allnum - $m < $num) { //通知申请人权限已通过 Utils::sendImMessage('', $acc_openid, "用户身份认证", "您的身份认证申请未通过审核。", $this->container, "", "", true, Utils::$systemmessage_code); } } } } } } catch (\Exception $e) { $this->get('logger')->err($e); $r = array('s' => 0, 'm' => '审核出现错误'); } $desc = ""; $title = ""; if ($r['s'] == '0') { $title = "提交失败"; $desc = $r['m']; } else { $title = "提交成功"; $desc = "您的审核结果已经提交成功,谢谢你的配合。"; } $home = $this->container->getParameter('open_api_url'); return $this->render("JustsyBaseBundle:IdentifyAuth:verify_success.html.twig", array('desc' => $desc, 'home' => $home, 'title' => $title)); }