public function sendDeptMsgAction() { //判断请求域。是wefafa或子域则不验证授权令牌 $isWeFaFaDomain = $this->checkWWWDomain(); $res = $this->get("request"); $da = $this->get("we_data_access"); if (!$isWeFaFaDomain) { $token = $this->checkAccessToken($res, $da); if (!$token) { $response = new Response("{\"returncode\":\"9999\",\"code\":\"err1015\",\"msg\":\"参数Appid或Openid或Access_token未指定或无效.\"}"); $response->headers->set('Content-Type', 'text/html'); return $response; } } //获取部门人员 $depts = trim($res->get("deptid")); if (empty($depts)) { $response = new Response("{\"returncode\":\"9999\",\"code\":\"err1015\",\"msg\":\"参数deptid未指定或无效.\"}"); $response->headers->set('Content-Type', 'text/html'); return $response; } $r = "{\"returncode\" : \"0000\"}"; $depts = explode(",", $depts); $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $res->get("openid")); $staff = $staffMgr->getInfo(); if (empty($staff)) { $response = new Response("{\"returncode\":\"9999\",\"code\":\"err1015\",\"msg\":\"参数openid未指定或无效.\"}"); $response->headers->set('Content-Type', 'text/html'); return $response; } $type = trim($res->get("type")); $cctomail = $res->get("cctomail"); $deptMgr = new \Justsy\BaseBundle\Management\Dept($da, $this->get("we_data_access_im")); for ($pos = 0; $pos < count($depts); $pos++) { if (empty($depts[$pos])) { continue; } //判断当前人员是否部门所属企业成员 $eno = $deptMgr->getEno($depts[$pos]); if (empty($eno)) { continue; } if ($eno != $staff["eno"]) { continue; } $staffs = $deptMgr->getAllStaffJid($depts[$pos]); if (count($staffs) > 0) { $jids = array(); for ($i = 0; $i < count($staffs); $i++) { $jids[] = $staffs[$i]["jid"]; } $r = $this->sendMsg($res->get("From") . $res->get("from"), implode(",", $jids), $res->get("Title") . $res->get("title"), $res->get("Message") . $res->get("message"), $res->get("Link") . $res->get("link"), $res->get("Linktext") . $res->get("Buttons") . $res->get("linktext") . $res->get("buttons"), false, $type, $cctomail); } } $response = new Response($r); $response->headers->set('Content-Type', 'text/html'); return $response; }