public function SaveApplyAction() { $da = $this->get('we_data_access'); $request = $this->getRequest(); $user = $this->get('security.context')->getToken()->getUser(); //获取请求消息 $applyer = $user->getUserName(); $recver = $request->get('recver'); $code = ReturnCode::$SUCCESS; $msg = ''; try { //将jid转成邮箱帐号 //$applyer=$this->getAccountByJid($da,$applyer); $recver = $this->getAccounts($da, explode(',', $recver)); $sex = $user->sex_id; $duty = $user->duty; $mobile = $user->mobile; $vilidateinfo = $request->get('authren'); //获取最小同意数 $identify = new IdentifyAuth($da, $this->get('logger'), $this->container); $n = $identify->getMinAreeNum($user->eno); $ec = new \Justsy\BaseBundle\Controller\IdentifyAuthController(); $ec->setContainer($this->container); $return = $ec->SaveUserAuth($da, $applyer, $recver, $mobile, $n); if ($return['s'] == '0') { $code = ReturnCode::$SYSERROR; $msg = $return['m']; } } catch (\Exception $e) { $this->get('logger')->err($e); $code = ReturnCode::$SYSERROR; $msg = "系统错误"; } $response = new Response(json_encode(array('returncode' => $code, 'msg' => $msg))); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function SaveUserAuth($da, $account, $postto, $mobile, $n = 1) { $re = array('s' => '1', 'm' => ''); try { $user = $this->get('security.context')->getToken()->getUser(); //保存认证信息 $content = $n; $l = $postto; $sendarr = array(); $sendbnt = array(); //最少同意数跟新 $sql[] = "update we_apply set content=? where account=? and recv_type='p'"; $params[] = array($n, $account); for ($i = 0; $i < count($l); $i++) { //判断是否需要 $sql1 = "select id from we_apply where account=? and recv_type='p' and recv_id=? and (is_valid='1' or (is_valid='0' and result='1'))"; $params1 = array($account, $l[$i]); $ds = $da->Getdata('count', $sql1, $params1); if ($ds['count']['recordcount'] == 0) { $apply_id = SysSeq::GetSeqNextValue($da, "we_apply", "id"); $sql[] = "insert into we_apply (id,account,recv_type,recv_id,content,is_valid,apply_date) values(?,?,?,?,?,?,now())"; $params[] = array($apply_id, $account, 'p', $l[$i], $n, '1'); //写入消息 $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $msg = $this->getauthmsg($apply_id, $user); $sql[] = "insert into we_message (msg_id,sender,recver,title,content,send_date) values(?,?,?,?,?,now())"; $params[] = array($msg_id, $account, $l[$i], '用户认证协助审核', $msg); $sendarr[] = $l[$i]; //群发即时消息 $identify = new IdentifyAuth($da, $this->get('logger'), $this->container); $buttons = $identify->getVerifyButton($apply_id); $sendbnt[] = $buttons; } else { /* $apply_id=$ds['count']['rows'][0]['id']; //写入消息 $msg_id=SysSeq::GetSeqNextValue($da,"we_message","msg_id"); $msg=$this->getauthmsg($apply_id,$user); $sql[]="insert into we_message (msg_id,sender,recver,title,content,send_date) values(?,?,?,?,?,now())"; $params[]=array($msg_id,$account,$l[$i],'用户认证协助审核',$msg); $sendarr[]=$l[$i]; //群发即时消息 $identify=new IdentifyAuth($da,$this->get('logger'),$this->container); $buttons=$identify->getVerifyButton($apply_id); $sendbnt[]=$buttons; */ } } if (!$da->ExecSQLs($sql, $params)) { $re = array('s' => '0', 'm' => '认证信息保存失败'); } else { for ($j = 0; $j < count($sendarr); $j++) { Utils::sendImMessage('', implode(',', $this->getOpenid($da, array($sendarr[$j]))), "用户身份认证", $user->nick_name . "(邮箱:" . $user->getUserName() . ",手机:" . $mobile . ")邀请您协助身份认证。", $this->container, "", $sendbnt[$j], true, Utils::$systemmessage_code); } } } catch (\Exception $e) { $this->get('logger')->err($e); return array('s' => '0', 'm' => '系统错误'); } return $re; }