public function agreeJoinCircleAction($para) { if (empty($para)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '参数错误!')); } $da = $this->get('we_data_access'); $res = $this->get('request'); $urlSource = $res->get("_urlSource"); //获取操作源。FaFaWin:从PC客户端操作的 //受邀人员帐号,圈子id,邀请人帐号 $paraArr = explode(",", trim(DES::decrypt($para))); //是否有帐号 $sql = "select nick_name,fafa_jid from we_staff where login_account=?"; $ds = $da->GetData("we_staff", $sql, array((string) $paraArr[0])); if (!$ds || $ds['we_staff']['recordcount'] == 0) { if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您还没有微发发帐号,请先注册!')); } else { $response = new Response("{\"succeed\":0,\"msg\":\"您还没有微发发帐号,请先注册!\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } } //判断是否是邀请加入人脉圈子,则在互相关注 if ($paraArr[1] == "9999") { //互相添加好友 $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $paraArr[2], $this->get("logger")); try { $staffMgr->attentionTo($paraArr[0]); } catch (\Exception $e) { } try { $staffMgr->attentionMe($paraArr[0]); } catch (\Exception $e) { } try { $staffMgr->bothAddFriend($this->container, $paraArr[0]); } catch (\Exception $e) { } $response = new Response("{\"succeed\":1,\"name\":\"人脉圈\",\"circleurl\":\"" . $this->generateUrl("JustsyBaseBundle_enterprise", array('network_domain' => "9999"), true) . "\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } $nick_name = $ds['we_staff']['rows'][0]['nick_name']; $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid']; //圈子是否存在 $sql = "select network_domain,circle_name,fafa_groupid from we_circle where circle_id=?"; $ds = $da->GetData("we_circle", $sql, array((string) $paraArr[1])); if (!$ds || $ds['we_circle']['recordcount'] == 0) { if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您要加入的圈子不存在!')); } else { $response = new Response("{\"succeed\":0,\"msg\":\"您要加入的圈子不存在!\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } } $fafa_groupid = $ds['we_circle']['rows'][0]['fafa_groupid']; $network_domain = $ds['we_circle']['rows'][0]['network_domain']; $circle_name = $ds['we_circle']['rows'][0]['circle_name']; //是否已经加入圈子 $sql = "select count(1) cnt from we_circle_staff where login_account=? and circle_id=?"; $ds = $da->GetData("cnt", $sql, array((string) $paraArr[0], (string) $paraArr[1])); if ($ds && $ds['cnt']['rows'][0]['cnt'] > 0) { if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您已经加入该圈子!')); } else { $response = new Response("{\"succeed\":0,\"msg\":\"您已经加入该圈子!\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } } //圈子id+nick_name不能重复 $sql = "select count(1) cnt from we_circle_staff where circle_id=? and nick_name=?"; $ds = $da->GetData("cnt", $sql, array((string) $paraArr[1], (string) $nick_name)); if ($ds && $ds['cnt']['rows'][0]['cnt'] > 0) { $user = $this->get('security.context')->getToken()->getUser(); $nick_name = $nick_name . "(" . $user->eshortname . ")"; } //判断圈子是否有人 $sql = "select count(1) as cnt from we_circle_staff where circle_id=?"; $ds = $da->GetData('we_circle_staff', $sql, array((string) $paraArr[1])); if ($ds && $ds['we_circle_staff']['rows'][0]['cnt'] == 0) { $sql = "update we_circle set create_staff=? where circle_id=?"; $da->ExecSQL($sql, array((string) $paraArr[0], (string) $paraArr[1])); } $sql = "insert into we_circle_staff (circle_id,login_account,nick_name) values (?,?,?)"; $da->ExecSQL($sql, array((string) $paraArr[1], (string) $paraArr[0], (string) $nick_name)); //更新邀请信息 $sql = "update we_invite set real_active_email=?,active_date=now() where invite_send_email=? and invite_recv_email=? and eno=?"; $da->ExecSQL($sql, array((string) $paraArr[0], (string) $paraArr[2], (string) $paraArr[0], (string) ("c" . $paraArr[1]))); //10-加入外部圈子-5 $sql = "insert into we_staff_points (login_account,point_type,point_desc,point,point_date) values (?,?,?,?,now())"; $da->ExecSQL($sql, array((string) $paraArr[0], (string) '10', (string) '成功加入外部圈子' . $circle_name . ',获得积分5', (int) 5)); $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null); $apply->SetCircleApplyInvalid($paraArr[0], $paraArr[1]); //发送即时消息通知申请人及成员 $circleObj = new \Justsy\BaseBundle\Controller\CircleController(); $circleObj->setContainer($this->container); $message = Utils::makeHTMLElementTag('employee', $fafa_jid, $nick_name) . "加入了圈子【" . Utils::makeHTMLElementTag('circle', $fafa_groupid, $circle_name) . "】"; $circleObj->sendPresenceCirlce($paraArr[1], "circle_addmember", $message); $backurl = $this->generateUrl("JustsyBaseBundle_enterprise", array('network_domain' => $paraArr[0]), true); if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:success.html.twig', array('backurl' => $backurl)); } else { $response = new Response("{\"succeed\":1,\"name\":\"" . $circle_name . "\",\"circleurl\":\"" . $backurl . "\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } }
public function joinbycode($paraObj) { $currUser = $paraObj["user"]; if (empty($currUser)) { return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN); } if ($currUser->eno != Utils::$PUBLIC_ENO) { return Utils::WrapResultError("你已加入企业"); } $invitecode = $paraObj["invitecode"]; if (empty($invitecode)) { return Utils::WrapResultError("邀请码不能为空"); } //获取设置的邀请码过期小时数,默认为1小时 //企业参数名称:invitecode_expire_hour $sys = new \Justsy\BaseBundle\DataAccess\SysParam($this->container); $hour = $sys->GetSysParam("invitecode_expire_hour"); if (empty($hour)) { $hour = 1; } $sql = "select eno,review_staff from we_register where active_code=? and register_date>date_sub(now(),interval " . $hour . " hour)"; $dataset = $this->da->GetData("t", $sql, array((string) $invitecode)); if (count($dataset["t"]["rows"]) > 0) { $eno = $dataset["t"]["rows"][0]["eno"]; if (empty($eno)) { return Utils::WrapResultError("邀请码已过期"); } if ($currUser->eno == $eno) { return Utils::WrapResultError("你已经是该企业员工"); } //消息通知 $message = "你已成功加入企业"; Utils::sendImPresence("", $currUser->fafa_jid, "enterprise_joinagree", $message, $this->container, "", "", false, '', '0'); //加入企业 $jid = SysSeq::GetSeqNextValue($this->da, "we_staff", "fafa_jid"); $jid .= "-" . $eno . "@fafacn.com"; $staffobj = new \Justsy\BaseBundle\Management\Staff($this->da, $this->container->get("we_data_access_im"), $currUser->getUsername(), $this->logger, $this->container); $tr = $staffobj->swtichEno($eno); //更换企业号 if ($tr) { $staffobj->updateJid($currUser->fafa_jid, $jid); } //更新im库中的jid //申请人和邀请人成为好友 $staffobj->bothAddFriend($this->container, $dataset["t"]["rows"][0]["review_staff"]); $newinfo = $staffobj->getInfo(); $enodata = $this->getInfo($eno); return Utils::WrapResultOK($enodata); } return Utils::WrapResultError("无效的邀请码"); }
public function attentionAction($attenaccount) { $this->get("logger")->err("---------------------------2222222222222222------------------"); $curuser = $this->get('security.context')->getToken()->getUser(); $isme = $curuser->getUsername(); $da = $this->get('we_data_access'); $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $curuser->getUserName(), $this->get("logger")); $staffMgr->attentionTo($attenaccount); //变更版本信息 $eno = $curuser->eno; $this->get("logger")->err("----------------------------eno:" . $eno . "----------------------"); $verchange = new \Justsy\BaseBundle\Management\VersionChange($da, $this->get("logger")); $result = $verchange->SetVersionChange(1, $attenaccount, $eno); $result = $verchange->SetVersionChange(1, $isme, $eno); $this->get("logger")->err("-----------------444444-------------------"); //发送关注消息 $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $sql = "insert into we_message(msg_id,sender,recver,send_date,title,content)values(?,?,?,now(),?,?)"; $da->ExecSQL($sql, array((int) $msgId, (string) $isme, (string) $attenaccount, "好友请求", "你的好友<a style='cursor:pointer;color:#1A65A5' class='employee_name' login_account='{$isme}'>" . $curuser->nick_name . "</a>关注了你")); //查询是否互关注 $sql = "select f_checkAttentionWithAccount(?,?) cnt"; $ds = $da->GetData("both", $sql, array((string) $isme, (string) $attenaccount)); $IsBoth = $ds["both"]["rows"][0]["cnt"]; $im_sender = $this->container->getParameter('im_sender'); $fafa_jid = Utils::getJidByAccount($da, $attenaccount); if ($IsBoth != 2) { //发送即时消息 $message = "您的好友 " . Utils::makeHTMLElementTag("employee", $curuser->fafa_jid, $curuser->nick_name) . " 关注了您"; $link = $this->generateUrl("JustsyBaseBundle_component_emp_attention", array("attenaccount" => $isme), true); $linkButtons = Utils::makeBusButton(array(array("code" => "action", "text" => "关注TA", "value" => "atten"))); Utils::sendImMessage($im_sender, $fafa_jid, "好友请求", $message, $this->container, $link, $linkButtons, false, Utils::$systemmessage_code); $response = new Response("{\"succeed\":1,\"both\":{$IsBoth}}"); //提醒交换名片 $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $sql = "insert into we_message (msg_id,sender,recver,send_date,title,content,msg_type) values(?,?,?,now(),?,?,'02')"; $params = array($msg_id, $isme, $attenaccount, '好友请求', "<a login_account='" . $isme . "' class='account_baseinfo'>" . $curuser->nick_name . "</a>希望与您成为好友"); $da->ExecSQL($sql, $params); } else { //互相添加好友 $staffMgr->bothAddFriend($this->container, $attenaccount); //加入对方的人脉圈子 $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $sql = "insert into we_message (msg_id,sender,recver,send_date,title,content,msg_type) values(?,?,?,now(),?,?,'02')"; $params = array($msg_id, $isme, $attenaccount, '好友消息', "<a login_account='" . $isme . "' class='account_baseinfo'>" . $curuser->nick_name . "</a>与您成为了好友,并进入了您的人脉圈"); $da->ExecSQL($sql, $params); $response = new Response("{\"succeed\":1,\"both\":{$IsBoth},\"msg\":\"\"}"); } $response->headers->set('Content-Type', 'text/json'); return $response; }