public function indexAction($name)
 {
     $user = $this->get('security.context')->getToken()->getUser();
     $this->photo_url = $this->container->getParameter('FILE_WEBSERVER_URL') . $user->photo_path_big;
     $this->InfoCompletePercent = $this->GetInfoCompletePercent($user->getUsername());
     //发升级通知
     if ($user->level > 1 && $user->level > $user->we_level) {
         $user->we_level = $user->level;
         $sqls = array();
         $all_params = array();
         $sql = "update we_staff set we_level = ? where login_account=?";
         $params = array();
         $params[] = (string) $user->level;
         $params[] = (string) $user->getUserName();
         $sqls[] = $sql;
         $all_params[] = $params;
         $da = $this->get('we_data_access');
         $ds = $da->ExecSQLs($sqls, $all_params);
         $conv_id = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_convers_list", "conv_id");
         $conv_content = "【喜讯】@{$user->nick_name} 的Wefafa等级已升至 {$user->level} 级![强] ";
         $circle_id = $user->get_circle_id($user->edomain);
         $group_id = "ALL";
         $conv = new \Justsy\BaseBundle\Business\Conv();
         $conv->newSysTrend($da, $conv_id, $conv_content, $circle_id, $group_id, array(), array());
     }
     return $this->render('JustsyBaseBundle:CPerBaseInfo:index.html.twig', array('this' => $this));
 }
示例#2
0
 public function wefafaShareAction(Request $request)
 {
     $result = true;
     $da = $this->container->get('we_data_access');
     $conv_id = SysSeq::GetSeqNextValue($da, "we_convers_list", "conv_id");
     $account = $request->get("account");
     $content = $request->get("content");
     $reason = $request->get("reason");
     //分享理由
     $group_id = $request->get("group_id");
     $circle_id = $request->get("circle_id");
     $ref_url = $request->get("ref_url");
     $tmp = parse_url($ref_url);
     $host = $tmp["host"];
     $attachs = null;
     //		if(!empty($host) && !Utils::is_ip($host))
     //		{
     //			  $host = strpos($host,".")===false? $host : substr($host, strpos($host,".")+1);
     //		}
     $conv = new \Justsy\BaseBundle\Business\Conv();
     $conv->newShareTrend($da, $account, $conv_id, $reason, $content, $circle_id, $group_id, $ref_url, $attachs, $host, $this->container);
     //	  $sql = "insert into we_convers_list(conv_id,login_account,post_date,conv_type_id,conv_root_id,conv_content,post_to_group,post_to_circle,comefrom)values(?,?,now(),?,?,?,?,?,?)";
     //	  $parameter = array($conv_id,$account,"98",$conv_id,$content,$group_id,$circle_id,$ref_url);
     //	  try{
     //	    $da->ExecSQL($sql,$parameter);
     //	  }
     //	  catch (\Exception $e){
     //	    $result = false;
     //	  }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($result) . ");" : json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
示例#3
0
 public function Add($content)
 {
     $convId = 'ws' . SysSeq::GetSeqNextValue($da, "we_official_publish", "info_id");
     $sqls = "insert into we_official_publish (info_id, info_type,content) \n\t        values (?, 'static', ?)";
     $paras = array((string) $convId, (string) $content);
     return $this->conn->ExecSQL($sqls, $paras);
 }
示例#4
0
 public function updateAction($network_domain)
 {
     $DataAccess = $this->get('we_data_access');
     $id = $this->getRequest()->get('id');
     $content = $this->getRequest()->get('content');
     $start_time = $this->getRequest()->get('start_time');
     $end_time = $this->getRequest()->get('end_time');
     $title = substr($content, 0, 20);
     $login_account = $this->get('security.context')->getToken()->getUser()->getUsername();
     $sql = 'select 1 from we_persontask where id=? and login_account=?';
     $dataset = $DataAccess->GetData('we_persontask', $sql, array((string) $id, (string) $login_account));
     if ($dataset['we_persontask']['recordcount'] > 0) {
         $sql = 'update we_persontask set title=?, content=?,start_time=?,end_time=? where id=? ';
         $dataexec = $DataAccess->ExecSQL($sql, array((string) $title, (string) $content, (string) $start_time, (string) $end_time, (string) $id));
     } else {
         $id = (string) SysSeq::GetSeqNextValue($DataAccess, "we_persontask", "id");
         $sql = 'insert into we_persontask(id,login_account,title,content,start_time,end_time,is_finish)values(?,?,?,?,?,?,"0")';
         $dataexec = $DataAccess->ExecSQL($sql, array((string) $id, (string) $login_account, (string) $title, (string) $content, (string) $start_time, (string) $end_time));
     }
     if ($dataexec > 0) {
         $res = new Response('{"success":1}');
     } else {
         $res = new Response('{"success":0}');
     }
     $res->headers->set('Content-Type', 'text/json');
     return $res;
 }
 public function OperateEnterpriseDataAction()
 {
     $da = $this->get("we_data_access");
     $request = $this->getRequest();
     $r["returncode"] = ReturnCode::$SUCCESS;
     $r["msg"] = "";
     $cus_content = $request->get("cus");
     if (empty($cus_content)) {
         $r["returncode"] = ReturnCode::$SYSERROR;
         $r["msg"] = "参数不能为空";
     } else {
         $cus = json_decode($cus_content);
         if (empty($cus)) {
             $r["returncode"] = ReturnCode::$SYSERROR;
             $r["msg"] = "参数格式有误,请确认";
         } else {
             if (empty($cus["ename"]) || empty($cus["e_mail"])) {
                 $r["returncode"] = ReturnCode::$SYSERROR;
                 $r["msg"] = "企业名称和邮箱不能为空";
             } else {
                 $sql_sel = "select count(1) as count from we_enterprise_stored where enoname=? or eno_mail=?";
                 $para_sel = array((string) $cus["ename"], (string) $cus["e_mail"]);
                 $data_sel = $da->GetData("dt", $sql_sel, $para_sel);
                 if ($data_sel != null && count($data_sel["dt"]["rows"][0]["count"]) > 0) {
                     $r["returncode"] = ReturnCode::$SYSERROR;
                     $r["msg"] = "企业名称和邮箱已经存在";
                 } else {
                     $id = SysSeq::GetSeqNextValue($da, "we_enterprise_stored", "id");
                     $sql = "INSERT INTO `we_sns`.`we_enterprise_stored` (`id`, `enoname`, `eno_city`, `eno_website`, `eno_phone`, `eno_mail`, ";
                     $sql .= "`eno_fax`, `eno_introduction`,`leaders_account`, `leaders_phone`, `leaders_mobile`, `leaders_mail`,) ";
                     $sql .= "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?);";
                     $para = array((string) $id, (string) $cus["ename"], (string) $cus["address"], (string) $cus["website"], (string) $cus["phone"], (string) $cus["e_mail"], (string) $cus["fax"], (string) $cus["industry"], (string) $cus["contact"], (string) $cus["contact_phone"], (string) $cus["contact_mobile"], (string) $cus["contact_mail"]);
                     try {
                         $dataexec = $da->ExecSQL($sql, $para);
                         if (!$dataexec) {
                             $re['returncode'] = ReturnCode::$SYSERROR;
                             $r["msg"] = "保存企业数据失败,请确认信息";
                         } else {
                             $r["returncode"] = ReturnCode::$SUCCESS;
                             $r["msg"] = "保存企业数据成功";
                         }
                     } catch (\Exception $e) {
                         $this->get('logger')->err($e);
                         $re['returncode'] = ReturnCode::$SYSERROR;
                         $r["msg"] = "保存企业数据出现异常,请确认信息";
                     }
                 }
             }
         }
     }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
示例#6
0
 public function commit($parameters)
 {
     if (empty($parameters)) {
         $result = Utils::WrapResultError("无效的数据");
         return $result;
     }
     $currUser = $parameters["user"];
     if (empty($currUser)) {
         return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN);
     }
     $audit_staffs = $parameters["audit_staffs"];
     //审批人。多个审批人使用;分隔
     if (empty($audit_staffs)) {
         return Utils::WrapResultError("审批人不能为空");
     }
     $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container);
     try {
         $content = $currUser->nick_name . "申请请假" . $parameters["days"] . "天";
         //创建新流程
         $result = $wfl->createWorkflow(array("appid" => $parameters["appid"], "user" => $currUser, "to" => $audit_staffs, "wf_name" => "请假申请", "wf_content" => $content, "wf_type" => $wf_type, "attachment" => $parameters["attachment"]));
         if (!empty($result)) {
             try {
                 //写业务表
                 $apply_id = SysSeq::GetSeqNextValue($this->conn, "we_app_apply_leave", "id");
                 $sql = "insert into we_app_apply_leave(id,wf_id,leavetype,start_date,end_date,days,reason,create_datetime,staff,eno,appid)values(?,?,?,?,?,?,?,now(),?,?,?)";
                 $this->conn->ExecSQL($sql, array((string) $apply_id, (string) $result["wf_id"], (string) $parameters["leavetype"], (string) $parameters["start_date"], (string) $parameters["end_date"], (double) $parameters["days"], (string) $parameters["reason"], (string) $currUser->getUserName(), (string) $currUser->eno, (string) $parameters["appid"]));
             } catch (\Exception $e) {
                 $wfl->removeWorkflow(array("wf_id" => $result["wf_id"]));
                 throw new \Exception($e);
             }
             //获取审批人的jid
             $to = explode(";", $audit_staffs);
             $tojids = array();
             for ($i = 0; $i < count($to); $i++) {
                 $staff = new Staff($this->conn, $this->conn_im, $to[$i], $this->logger, $this->container);
                 $staffdata = $staff->getInfo();
                 if (empty($staffdata)) {
                     continue;
                 }
                 $tojids[] = $staffdata["fafa_jid"];
             }
             //向审批人发送消息
             Utils::sendImMessage("", $tojids, "bus_apply", json_encode($re), $this->container, "", "", false, '', '0');
         }
         return $result;
     } catch (\Exception $e) {
         $this->logger->err($e);
         $result = Utils::WrapResultError($e->getMessage());
     }
     return $result;
 }
示例#7
0
 public function authorizeUser($appid, $staff_loginname)
 {
     try {
         $da = $this->get('we_data_access');
         $appinfo = $da->GetData("t", "select 1 from  we_appcenter_apps where appid=? and apptype!='00'", array((string) $appid));
         if ($appinfo != null && $appinfo["t"]["recordcount"] > 0) {
             $id = SysSeq::GetSeqNextValue($da, "we_app_userpriv", "id");
             $sql = "insert into we_app_userpriv(id,login_account,appid,role) values(?,?,?,0) ";
             $da->ExecSQL($sql, array((string) $id, (string) $staff_loginname, (string) $appid));
         }
     } catch (\Exception $e) {
         $this->get("logger")->err($e->getMessage());
     }
 }
示例#8
0
 public function ApplyJoinGroup($account, $groupid, $remark)
 {
     //判断是否已申请
     $isapply = $this->GetGroupApplyValid($account, $groupid);
     if ($isapply === false) {
         return 0;
     }
     //判断已申请的圈子总数是否超过了groupapplylimit设置
     $c = $this->GetGroupApply($account);
     if (count($c) >= $this->groupapplylimit) {
         return 99999;
     }
     $Id = SysSeq::GetSeqNextValue($this->conn, "we_apply", "id");
     $sqls = "insert into we_apply (id, account,recv_type,recv_id,content,is_valid,apply_date) \n\t        values (?, ?, 'g',?,?,'1',now())";
     $paras = array((string) $Id, (string) $account, (string) $groupid, (string) $remark);
     return $this->conn->ExecSQL($sqls, $paras);
 }
示例#9
0
 public function commit($parameters)
 {
     if (empty($parameters)) {
         $result = Utils::WrapResultError("无效的数据");
         return $result;
     }
     $currUser = $parameters["user"];
     if (empty($currUser)) {
         return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN);
     }
     try {
         //写业务表
         $apply_id = SysSeq::GetSeqNextValue($this->conn, "we_app_notice", "id");
         $sql = "insert into we_app_notice(id,title,content,author,publishdate,publishstaff,publisharea,isprivate,status,eno,appid)values(?,?,?,?,now(),?,?,?,'1',?,?)";
         $this->conn->ExecSQL($sql, array((string) $apply_id, (string) $parameters["title"], (string) $parameters["content"], (string) $currUser->getUserName(), (string) $currUser->getUserName(), (string) $parameters["publisharea"], (string) $parameters["isprivate"], (string) $currUser->eno, (string) $parameters["appid"]));
         //消息内容
         $message_body = array("appid" => $parameters["appid"], "title" => $parameters["title"], "id" => $apply_id);
         //获取发布范围内的人员jid
         $toDept = explode(",", $parameters["publisharea"]);
         $tojids = array();
         $deptMgr = new Dept($this->conn, $this->conn_im, $this->container);
         for ($i = 0; $i < count($toDept); $i++) {
             //获取部门下的所有人员jid
             $staffjid = $deptMgr->getAllStaffJid($toDept[$i]);
             for ($i = 0; $i < count($staffjid); $i++) {
                 $tojids[] = $staffjid[$i]["jid"];
                 if (count($tojids) >= 500) {
                     //向审批人发送消息,一次性最多推送500个帐号
                     Utils::sendImMessage("", $tojids, "bus_app_msgpush", json_encode($message_body), $this->container, "", "", false, '', '0');
                     $tojids = array();
                 }
             }
         }
         if (count($tojids) > 0) {
             //向审批人发送消息
             Utils::sendImMessage("", $tojids, "bus_app_msgpush", json_encode($message_body), $this->container, "", "", false, '', '0');
         }
         $result = Utils::WrapResultOK("");
     } catch (\Exception $e) {
         $this->logger->err($e);
         $result = Utils::WrapResultError($e->getMessage());
     }
     return $result;
 }
示例#10
0
 public function addtag($login_account, $tag_name, $tag_desc)
 {
     try {
         $tag_id = SysSeq::GetSeqNextValue($this->da, "we_tag", "tag_id");
         $sql = "insert into we_tag (tag_id,tag_name,owner_id,owner_type,tag_desc,create_date) values(?,?,?,?,?,now())";
         $params = array($tag_id, $tag_name, $login_account, '01', $tag_desc);
         if (!$this->da->ExecSQL($sql, $params)) {
             return null;
         } else {
             $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($this->da, $this->logger, $this->container);
             $friendevent->addtag($login_account, $tag_id, $tag_name, $tag_desc);
             return $tag_id;
         }
     } catch (\Exception $e) {
         //var_dump($e->getMessage());
         $this->writelog($e);
         return null;
     }
 }
示例#11
0
 public function saveToken($token, $openid, $openkey, $login_account, $eno)
 {
     try {
         $openid = strtolower($openid);
         $access_token = $token["access_token"];
         $expire_in = $token["expires_in"];
         $refresh_token = $token["refresh_token"];
         //获取用户基本信息
         $client = new TencentClient(TencentOAuth::$client_id, TencentOAuth::$client_key, $openid, $access_token);
         $userinfo = $client->get_user_baseinfo();
         $id = SysSeq::GetSeqNextValue($this->conn, "we_weibo_account", "id");
         $sql = "insert into we_weibo_account (id,uid,access_token,expires_in,nick_name,user_name,appid,appkey,followers_count,favourites_count,created_at,verified,refresh_token,openid,openkey,head_url,owner_staff,type,eno) \n\t\t  \tvalues(?,?,?,date_add(now(),interval ? second),?,?,?,?,?,?,now(),?,?,?,?,?,?,?,?)";
         $params = array($id, $openid, $access_token, (int) $expire_in, $userinfo['nick'], $userinfo['name'], TencentOAuth::$client_id, TencentOAuth::$client_key, $userinfo['fansnum'], $userinfo['favnum'], $userinfo['isvip'] == '1' ? true : false, $refresh_token, $openid, $openkey, $userinfo['head'], $login_account, 'tencent', $eno);
         $this->conn->ExecSQL($sql, $params);
         return true;
     } catch (\Exception $e) {
         var_dump($e->getMessage());
     }
 }
示例#12
0
 public function saveAction()
 {
     //try{
     $request = $this->get("request");
     $user = $this->get('security.context')->getToken()->getUser();
     $da = $this->get("we_data_access");
     $new_id = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_sys_feedback", "id");
     $sql = "insert into we_sys_feedback (id,login_account,ip,feedback_con,feedback_date)values(?,?,?,?,now())";
     $da->ExecSQL($sql, array((string) $new_id, (string) $user->getUserName(), "", (string) $request->get("txt")));
     //查询出开发公司的圈子id
     $sql = "select * from we_circle where network_domain='fafatime.com'";
     $ds = $da->GetData("tmp", $sql);
     $circle_id = $ds["tmp"]["rows"][0]["circle_id"];
     //发公告
     $txt = "用户反馈:" . $request->get("txt");
     //发送站内消息
     $msgId = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_bulletin", "bulletin_id");
     $sql = "insert into we_bulletin(bulletin_id,circle_id,group_id,bulletin_date,bulletin_desc)values(?,?,?,now(),?)";
     $da->ExecSQL($sql, array((int) $msgId, (string) $circle_id, "ALL", $txt));
     //通知圈子成员
     $members = $this->notifyCircleMember($da, $circle_id);
     for ($i = 0; $i < count($members); $i++) {
         $membersrow = $members[$i];
         if ($membersrow["login_account"] == $user->getUserName()) {
             continue;
         }
         $sql = "insert into we_notify(notify_type, msg_id,notify_staff)values('01',?,?)";
         $da->ExecSQL($sql, array((int) $msgId, (string) (string) $user->getUserName()));
         //向对方发送及时消息
         //认证码格式:当前人员企业号、帐号、密码(空)、空、空
         $encode = $user->eno . "," . $user->fafa_jid . ",,,";
         $encode = "00442," . DES::encrypt($encode);
         $url = $this->container->getParameter("FAFA_REG_JID_URL");
         //Utils::sendImMessage($url,"",$user->fafa_jid,$row["fafa_jid"],$txt);
     }
     return new Response("1");
     //}
     //catch(\Exception $e)
     //{
     //    	return new Response("0");
     //}
 }
示例#13
0
 public function saveToken($token, $login_account, $eno)
 {
     try {
         $access_token = $token["Token"];
         $expire_in = $token["ExpiresIn"];
         $uid = $token["UID"];
         //获取用户基本信息
         $client = new SaeTClientV2(SaeTOAuthV2::$appid, SaeTOAuthV2::$appkey, $access_token);
         $userinfo = $client->get_user_baseinfo($uid);
         var_dump($userinfo);
         $id = SysSeq::GetSeqNextValue($da, "we_weibo_account", "id");
         $sql = "insert into we_weibo_account (id,uid,access_token,expires_in,nick_name,user_name,appid,appkey,followers_count,friends_count,statuses_count,favourites_count,created_at,verified,refresh_token,head_url,owner_staff,type,eno) \n\t\t  \tvalues(?,?,?,FROM_UNIXTIME({$expire_in},'%Y-%m-%d %H:%i:%S'),?,?,?,?,?,?,?,?,now(),?,?,?,?,?,?)";
         $params = array($id, $uid, $access_token, $userinfo['screen_name'], $userinfo['screen_name'], SaeTOAuthV2::$appid, SaeTOAuthV2::$appkey, $userinfo['followers_count'], $userinfo['friends_count'], $userinfo['statuses_count'], $userinfo['favourites_count'], $userinfo['verified'], '', $userinfo['head_url'], $login_account, 'sina', $eno);
         $this->conn->ExecSQL($sql, $params);
         return true;
     } catch (\Exception $e) {
         var_dump($e->getMessage());
         die;
         return false;
     }
 }
示例#14
0
 public function settingEditAction()
 {
     $da = $this->get('we_data_access');
     $request = $this->getRequest();
     $id = $request->get("id");
     $keyword = $request->get("keyword");
     $title = $request->get("title");
     $content = $request->get("content");
     $keyword = empty($keyword) ? null : $keyword;
     $title = empty($title) ? null : $title;
     $content = empty($content) ? null : $content;
     $sql = "";
     $para = array();
     if (empty($id) || $id == "0") {
         $currUser = $this->get('security.context')->getToken();
         $staffid = $currUser->getUser()->getUserName();
         $id = SysSeq::GetSeqNextValue($da, "mb_buffet", "id");
         $sql = "insert into mb_buffet(id,keyword,title,content,create_date,create_staffid)values(?,?,?,?,now(),?)";
         $para = array((string) $id, $keyword, $title, $content, $staffid);
     } else {
         $sql = "update mb_buffet set keyword=?,title=?,content=? where id=?";
         $para = array($keyword, $title, $content, (string) $id);
     }
     $success = true;
     $message = "";
     try {
         $da->ExecSQL($sql, $para);
     } catch (\Exception $e) {
         $this->get("logger")->err($e->getMessage());
         $success = false;
         $message = "编辑数据错误,请重试!";
     }
     $result = array("success" => $success, "message" => $message, "id" => $id);
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
示例#15
0
 public function updateAction(Request $request)
 {
     $da = $this->container->get('we_data_access');
     $msg_id = "";
     $sender = $this->get('security.context')->getToken()->getUser()->getUserName();
     $content = $request->get('msg');
     $recver = $request->get('txtNotify');
     $attachs = $request->get('attachs');
     $attachsName = $request->get('attachsName');
     $title = $request->get('titl');
     $countRecver = count($recver);
     $countAttachs = count($attachs);
     $params = array();
     $params[] = (string) $msg_id;
     $params[] = (string) $sender;
     $params[] = (string) $title;
     $params[] = (string) $content;
     $params[] = (string) '0';
     $sql = 'insert into we_message(msg_id,sender,send_date,title,content,isread,recver) values(?,?,CURRENT_TIMESTAMP(),?,?,?,?)';
     for ($i = 0; $i < $countRecver; $i++) {
         $msg_id = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
         $params[0] = $msg_id;
         $params[5] = (string) $recver[$i];
         $da->ExecSQL($sql, $params);
         $sql2 = ' into we_message_attach(msg_id, attach_type, attach_id) values(?,?,?)';
         $params2 = array();
         $params2[] = (string) $msg_id;
         $params2[] = (string) '0';
         for ($j = 0; $j < $countAttachs; $j++) {
             $params2[2] = (string) $attachs[$j];
             $da->ExecSQL($sql2, $params);
         }
     }
     $re = array('success' => '1');
     return new Response(json_encode($re));
 }
示例#16
0
 public function Modify($keyid, $year, $month, $day, $hour, $minute, $week, $content, $remind_type, $send_type, $remind_staffid, $staff_type, $remind_category, $mobile)
 {
     $this->cur_user = $this->get('security.context')->getToken()->getUser();
     $create_staff = $this->cur_user->getUserName();
     if ($remind_staffid == null || empty($remind_staffid)) {
         $remind_staffid = $create_staff;
         $staff_type = 1;
     }
     $da = $this->get('we_data_access');
     //如果手机号不为空则修改用户手机号码
     if ($mobile != null && !empty($mobile)) {
         $sql = "update we_staff set mobile=? where login_account=?";
         $params = array((string) $mobile, (string) $create_staff);
         $da->ExecSQL($sql, $params);
     }
     $edit = false;
     //新增或修改标志,如为false表示添加数据记录
     if ($keyid == null || empty($eyid)) {
         $keyid = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_remind", "id");
     } else {
         $edit = true;
     }
     //添加we_remind表
     $sqls = array();
     $parameters = array();
     $parameter = array();
     if (!$edit) {
         $sql = "insert into we_remind(id,`year`,`month`,`day`,`hour`,`minute`,week,remind_content,remind_type,send_type,create_staffid,create_date)value(?,?,?,?,?,?,?,?,?,?,?,now())";
         $parameter = array($keyid, $year, $month, $day, $hour, $minute, $week, $content, $remind_type, $send_type, $create_staff);
     } else {
         $sql = "update we_remind set `year`=?,`month`=?,`day`=?,`hour`=?,`minute`=?,week=?,remind_content=?,remind_type=?,send_type=? where id=?";
         $parameter = array($year, $month, $day, $hour, $minute, $week, $content, $remind_type, $send_type, $create_staff);
     }
     array_push($sqls, $sql);
     array_push($parameters, $parameter);
     //添加we_remind_details表
     $staff = explode(",", $remind_staffid);
     $stafftype = explode(",", $staff_type);
     $detailsid = null;
     $date = $this->SetRemindDate($year, $month, $day, $hour, $minute, $week);
     for ($i = 0; $i < count($staff); $i++) {
         if (!$edit) {
             $detailsid = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_remind_details", "detailsid");
             $sql = "insert into we_remind_details(detailsid,remindid,remindcontent,remind_date,state,remind_staffid,staff_type,remind_category)values(?,?,?,?,1,?,?,?)";
             $parameter = array((string) $detailsid, (string) $keyid, (string) $content, (string) $date, (string) $staff[$i], (string) $stafftype[$i], (string) $remind_category);
             array_push($sqls, $sql);
             array_push($parameters, $parameter);
         } else {
         }
     }
     $result = true;
     try {
         $da->ExecSQLs($sqls, $parameters);
     } catch (\Exception $e) {
         $result = false;
     }
     return $result;
 }
示例#17
0
 private function editGroupMemberAera($groupid, $area)
 {
     $success = true;
     $da_im = $this->conn_im;
     $deptids = $area["deptid"];
     $allow_jid = $area["allow_jid"];
     $sqls = array();
     $paras = array();
     //添加部门(修改时不做此操作)
     for ($i = 0; $i < count($deptids); $i++) {
         $id = SysSeq::GetSeqNextValue($da_im, "im_group_memberarea", "id");
         $deptid = $deptids[$i];
         $sql = "insert into im_group_memberarea(id,groupid,objid,status)values(?,?,?,'1');";
         $para = array((string) $id, $groupid, $deptid);
         array_push($sqls, $sql);
         array_push($paras, $para);
     }
     if (!empty($allow_jid)) {
         //添加允许的人员
         $sql = 'insert into im_group_memberarea(id,groupid,objid,status)values';
         $values = array();
         for ($j = 0; $j < count($allow_jid); $j++) {
             $id = SysSeq::GetSeqNextValue($da_im, "im_group_memberarea", "id");
             $jid = $allow_jid[$j];
             $values[] = '(\'' . $id . '\',\'' . $groupid . '\',\'' . $jid . '\',\'2\')';
         }
         array_push($sqls, $sql . implode(',', $values));
         array_push($paras, array());
     }
     try {
         $da_im->ExecSQL('delete from im_group_memberarea where groupid=?', array((string) $groupid));
         $da_im->ExecSQLS($sqls, $paras);
     } catch (\Exception $e) {
         $success = false;
         $this->logger->err($e->getMessage());
     }
     return $success;
 }
示例#18
0
 public function deptsaveAction($network_domain)
 {
     $res = $this->get("request");
     $deptname = trim($res->get("deptname"));
     $pid = trim($res->get("pid"));
     $deptid = trim($res->get("deptid"));
     $user = $this->get('security.context')->getToken()->getUser();
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     //判断是否已存在
     $sqls = "select * from we_department where eno=? and dept_name=?";
     $ds = $da->GetData("dept", $sqls, array((string) $user->eno, (string) $deptname));
     if ($ds && count($ds["dept"]["rows"]) > 0) {
         if ($ds["dept"]["rows"][0]["dept_id"] == $deptid) {
             $response = new Response(json_encode(array("s" => 1, "id" => $ds["dept"]["rows"][0]["dept_id"], "name" => $ds["dept"]["rows"][0]["dept_name"], "pId" => $ds["dept"]["rows"][0]["parent_dept_id"], "owner" => $ds["dept"]["rows"][0]["create_staff"])));
         } else {
             $response = new Response(json_encode(array("s" => 0, "msg" => "部门名称已存在", "deptid" => $deptid)));
         }
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     if (empty($deptname)) {
         $response = new Response(json_encode(array("s" => 0, "msg" => "部门名称不能为空")));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     if ($pid == "") {
         $response = new Response(json_encode(array("s" => 0, "msg" => "无效的父级部门")));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     if (!empty($deptid)) {
         $sqls = "select fafa_deptid from we_department where eno=? and dept_id=?";
         $ds = $da->GetData("dept2", $sqls, array((string) $user->eno, (string) $deptid));
         if ($ds == null || count($ds["dept2"]["rows"]) == 0 && $deptid != "v" . $user->eno) {
             $response = new Response(json_encode(array("s" => 0, "msg" => "无效的部门信息")));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         if ($deptid == "v" . $user->eno) {
             $fafa_deptid = $deptid;
             $sqls_1 = array();
             $paras_1 = array();
             $sqls_1[] = "update we_enterprise_stored set eshortname=? where enoname=?";
             $paras_1[] = array($deptname, $user->ename);
             $sqls_1[] = "update we_enterprise set eshortname=? where eno=?";
             $paras_1[] = array($deptname, $user->eno);
             $sqls_1[] = "update we_micro_account set name=? where eno=? and locate('_weixin_',number)>0";
             $paras_1[] = array($deptname, $user->eno);
             $da->ExecSQLs($sqls_1, $paras_1);
         } else {
             $fafa_deptid = $ds["dept2"]["rows"][0]["fafa_deptid"];
             //编辑部门名称
             $sql = "update we_department set dept_name=? where dept_id=?";
             $da->ExecSQL($sql, array((string) $deptname, (string) $deptid));
         }
         //同步IM库
         $sql_ims = array();
         $para_ims = array();
         $sql_ims[] = "update im_base_dept set deptname=? where deptid=? ";
         $para_ims[] = array((string) $deptname, (string) $fafa_deptid);
         $sql_ims[] = "update rostergroups set grp=? where grp=?";
         $para_ims[] = array($deptname, $user->eshortname);
         $da_im->ExecSQLs($sql_ims, $para_ims);
         //重置IM数据版本
         $sql_im = "delete from im_dept_version where us in(SELECT loginname FROM we_im.im_employee a, im_base_dept b where a.deptid=b.deptid and b.path like ? )";
         $para_im = array();
         $para_im[] = "/-10000/v" . $user->eno . "/%";
         $da_im->ExecSQL($sql_im, $para_im);
     } else {
         $deptid = SysSeq::GetSeqNextValue($da, "we_department", "dept_id");
         $fafa_deptid = SysSeq::GetSeqNextValue($da_im, "im_base_dept", "deptid");
         $sqls = "insert into we_department (eno,dept_id,dept_name,parent_dept_id,fafa_deptid,create_staff) values (?,?,?,?,?,?)";
         $paras = array((string) $user->eno, (string) $deptid, (string) $deptname, (string) $pid, (string) $fafa_deptid, (string) $user->getUserName());
         $da->ExecSQL($sqls, $paras);
         $sqls = "select fafa_deptid from we_department where eno=? and dept_id=?";
         $ds = $da->GetData("dept2", $sqls, array((string) $user->eno, (string) $pid));
         $sql_im = "insert im_base_dept(deptid, deptname, pid, path, noorder, manager, remark) \nselect ?, ?, deptid, concat(path, '" . $fafa_deptid . "/'), (select count(*)+1 from im_base_dept where pid=?) noorder, null, null \nfrom im_base_dept \nwhere deptid=? ";
         $para_im = array();
         $para_im[] = (string) $fafa_deptid;
         $para_im[] = (string) $deptname;
         $para_im[] = (string) (count($ds["dept2"]["rows"]) > 0 ? $ds["dept2"]["rows"][0]["fafa_deptid"] : $pid);
         $para_im[] = (string) (count($ds["dept2"]["rows"]) > 0 ? $ds["dept2"]["rows"][0]["fafa_deptid"] : $pid);
         $da_im->ExecSQL($sql_im, $para_im);
         $sql_im = "insert into im_dept_stat(deptid,empcount) values(?,0)";
         $para_im = array((string) $fafa_deptid);
         $da_im->ExecSQL($sql_im, $para_im);
         $sql_im = "delete from im_dept_version where us in(SELECT loginname FROM we_im.im_employee a, im_base_dept b where a.deptid=b.deptid and b.path like ? )";
         $para_im = array();
         $para_im[] = "/-10000/v" . $user->eno . "/%";
         $da_im->ExecSQL($sql_im, $para_im);
     }
     $response = new Response(json_encode(array("s" => 1, "id" => $deptid, "name" => $deptname, "pId" => $pid, "owner" => $user->getUserName())));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
示例#19
0
 public function getProxySession($appid, $code, $state, $userid = "wefafaproxy")
 {
     $conn = $this->get("we_data_access");
     $conn_im = $this->get("we_data_access_im");
     $expires_in = 60 * 60 * 24;
     //一天
     $sql = "select * from we_app_oauth_sessions where appid=? and user_type='sys' and userid=? and access_token_expires>=?";
     $time = time();
     $data = $conn->GetData("dt", $sql, array((string) $appid, (string) $userid, $time));
     $accessTokenExpires = $time + $expires_in;
     $response = array();
     if ($data != null && count($data["dt"]["rows"]) > 0 && !empty($data["dt"]["rows"][0]["access_token"])) {
         //token存在并且有效
         try {
             $sql_upd = "update we_app_oauth_sessions set last_updated=? where appid=? and user_type='sys' and userid=? ";
             $conn->ExecSQL($sql_upd, array($time, (string) $appid, (string) $userid));
             $access_token = $data["dt"]["rows"][0]["access_token"];
             $response = array('access_token' => $access_token, 'token_type' => 'bearer', 'expires' => $accessTokenExpires, 'expires_in' => $expires_in, 'state' => $state);
         } catch (\Exception $e) {
             $response = array('error' => ReturnCode::$SYSERROR, 'msg' => '获取token失败,请稍后重试。');
             $this->get('logger')->err($e);
         }
     } else {
         $sql_token = "select * from we_app_oauth_sessions where appid=? and user_type='sys' and userid=? ";
         $data_token = $conn->GetData("dt", $sql_token, array((string) $appid, (string) $userid));
         //存在APPID缓存,并且存在Token,只是Token过期
         if ($data_token != null && count($data_token["dt"]["rows"]) > 0 && !empty($data_token["dt"]["rows"][0]["access_token"])) {
             try {
                 $access_token = $this->createKey($appid);
                 if (empty($access_token)) {
                     $response = array('error' => ReturnCode::$SYSERROR, 'msg' => '生成token失败,请稍后重试。');
                 } else {
                     $sql_upd = "update we_app_oauth_sessions set access_token=?, access_token_expires=?,last_updated=? where appid=? and user_type='sys' and userid=? ";
                     $conn->ExecSQL($sql_upd, array((string) $access_token, (string) $accessTokenExpires, $time, (string) $appid, (string) $userid));
                     $response = array('access_token' => $access_token, 'token_type' => 'bearer', 'expires' => $accessTokenExpires, 'expires_in' => $expires_in, 'state' => $state);
                 }
             } catch (\Exception $e) {
                 $response = array('error' => ReturnCode::$SYSERROR, 'msg' => '获取token失败,请稍后重试。');
                 $this->get('logger')->err($e);
             }
             //存在APPID缓存,但是TOKEN为空,生成Token并修改记录
         } else {
             if ($data_token != null && count($data_token["dt"]["rows"]) > 0 && empty($data_token["dt"]["rows"][0]["access_token"])) {
                 try {
                     $access_token = $this->createKey($appid);
                     if (empty($access_token)) {
                         $response = array('error' => ReturnCode::$SYSERROR, 'msg' => '生成token失败,请稍后重试。');
                     } else {
                         $sql_upd = "update we_app_oauth_sessions set access_token=?,access_token_expires=?,last_updated=? where appid=? and user_type='sys' and userid=? ";
                         $conn->ExecSQL($sql_upd, array((string) $access_token, (string) $accessTokenExpires, $time, (string) $appid, (string) $userid));
                         $response = array('access_token' => $access_token, 'token_type' => 'bearer', 'expires' => $accessTokenExpires, 'expires_in' => $expires_in, 'state' => $state);
                     }
                 } catch (\Exception $e) {
                     $response = array('error' => ReturnCode::$SYSERROR, 'msg' => '获取token失败,请稍后重试。');
                     $this->get('logger')->err($e);
                 }
                 //不存在APPID缓存,生成Token并添加一条记录
             } else {
                 try {
                     $access_token = $this->createKey($appid);
                     if (empty($access_token)) {
                         $response = array('error' => ReturnCode::$SYSERROR, 'msg' => '生成token失败,请稍后重试。');
                     } else {
                         $refresh_token = $this->createKey($appid);
                         $sql_insert = "INSERT INTO we_app_oauth_sessions(id,appid,user_type,userid,access_token,access_token_expires,auth_code,auth_code_expires,stage,refresh_token,redirect_uri,first_requested,last_updated) VALUES(?,?,?,?,?,?,?,?,?,?,'',?,?)";
                         $id = SysSeq::GetSeqNextValue($conn, "we_app_oauth_sessions", "id");
                         $stage = "requested";
                         $auth_code = "";
                         $user_type = "sys";
                         $auth_code_expires = 30000;
                         $paras = array($id, (string) $appid, (string) $user_type, (string) $userid, $access_token, $accessTokenExpires, $auth_code, $auth_code_expires, $stage, $refresh_token, $time, $time);
                         $conn->ExecSQL($sql_insert, $paras);
                         $response = array('access_token' => $access_token, 'token_type' => 'bearer', 'expires' => $accessTokenExpires, 'expires_in' => $expires_in, 'state' => $state);
                     }
                 } catch (\Exception $e) {
                     $response = array('error' => ReturnCode::$SYSERROR, 'msg' => '获取token失败,请稍后重试。');
                     $this->get('logger')->err($e);
                 }
             }
         }
     }
     return $response;
 }
示例#20
0
 public function sendsharemsgAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get("we_data_access_im");
     $re = array("returncode" => ReturnCode::$SUCCESS, 'msg' => '');
     $res = $this->getRequest();
     $user = $this->get('security.context')->getToken()->getUser();
     try {
         //获取接收者
         $openids = $res->get("openids");
         $groupid = $res->get("groupid");
         $circleid = $res->get("circleid");
         //分享到指定的圈子中,需要单独 处理。不走实时消息通道
         if (empty($openids) && empty($groupid) && empty($circleid)) {
             $toType = $res->get("totype");
             //分享目标类型,当openids\groupid\circleid存在时无效
             //分享到其他网站或者平台上,暂时支持微信朋友圈\QQ空间
             $re = "";
             $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         //获取推送的分享图片地址
         $imgurl = $res->get("imgurl");
         //获取推送的分享内容
         $content = $res->get("content");
         $shareitem = array();
         $shareitem["content"] = $content;
         if (!empty($imgurl)) {
             $shareitem["image"] = array("value" => $imgurl, "type" => "URL");
         }
         $shareitem["iosclass"] = $res->get("iosclass");
         $shareitem["androidclass"] = $res->get("androidclass");
         $shareitem["bizdata"] = $res->get("bizdata");
         if (!empty($circleid)) {
             $ref_url = json_encode(array("iosclass" => $shareitem["iosclass"], "androidclass" => $shareitem["androidclass"], "bizdata" => $shareitem["bizdata"]));
             //分享到圈子
             $conv_id = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_convers_list", "conv_id");
             $conv = new \Justsy\BaseBundle\Business\Conv();
             $conv->newShareTrend($da, $user->getUserName(), $conv_id, $content, $imgurl, $circleid, "ALL", $ref_url, array(), "00", null);
             $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         $msgBody = array();
         $msgBody["snssharemsg"] = array("shareitem" => $shareitem);
         $tolist = array();
         if (!empty($groupid)) {
             $groupmgr = new \Justsy\BaseBundle\Management\GroupMgr($da, $da_im);
             //$groupdata = $groupmgr->GetByIM($groupid);
             $tolist = $groupmgr->getGroupMembersJidByIM($groupid);
             $msgBody["snssharemsg"]["shareitem"]["groupid"] = $groupid;
         }
         if (!empty($openids)) {
             $tolist = array_merge($tolist, explode(",", $openids));
         }
         $cnt = count($tolist);
         if ($cnt > 0) {
             $api = new \Justsy\OpenAPIBundle\Controller\ApiController();
             $api->setContainer($this->container);
             $re = $api->sendMsg2($user->fafa_jid, implode(",", $tolist), json_encode($msgBody), "sharemsg", true);
         }
     } catch (\Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["msg"] = "系统错误";
         $this->get('logger')->err($e);
     }
     $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
示例#21
0
 public function noticePublishAction($network_domain)
 {
     $request = $this->getRequest();
     $user = $this->get('security.context')->getToken()->getUser();
     $da = $this->get('we_data_access');
     $notice_content = $request->get('notice');
     $post_to_group = $request->get('post_to_group');
     $bulletin_id = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_bulletin", "bulletin_id");
     //跟新we_bulletin表
     $sqls = array();
     $all_params = array();
     /*
     if(($post_to_group=="all"||$post_to_group=="ALL")&&$this->isPower($network_domain)==0)
     {
     	$sql1 = "select group_id from we_groups where create_staff=? and circle_id=?";
     	$params1 = array();
       $params1[] = (string)$user->getUserName();
       $params1[] = (string)$user->get_circle_id($network_domain);
       $ds=$da->Getdata("we_groups",$sql1,$params1);
       
       foreach($ds['we_groups']['rows'] as $row)
       {
       	$sqlInsert = 'insert into we_bulletin (bulletin_date,bulletin_desc,bulletin_id,group_id,circle_id,bulletin_staff) values (CURRENT_TIMESTAMP(), ?, ?, ?, ?,?)';
         $params = array();
         $params[]=(string)$notice_content;
         $params[] = (string)$bulletin_id;
         $params[] = (string)$post_to_group;
         $params[] = (string)$user->get_circle_id($network_domain);
         $params[]=(string)$user->getUserName();
          
     $sqls[] = $sqlInsert;
     $all_params[] = $params;
       }
     }
     else()
     {
     	
     }
     */
     $sqlInsert = 'insert into we_bulletin (bulletin_date,bulletin_desc,bulletin_id,group_id,circle_id,bulletin_staff) values (CURRENT_TIMESTAMP(), ?, ?, ?, ?,?)';
     $params = array();
     $params[] = (string) $notice_content;
     $params[] = (string) $bulletin_id;
     $params[] = (string) $post_to_group;
     $params[] = (string) $user->get_circle_id($network_domain);
     $params[] = (string) $user->getUserName();
     $sqls[] = $sqlInsert;
     $all_params[] = $params;
     $da->ExecSQLs($sqls, $all_params);
     //跟新we_notify表,保存未读的通知性息
     $sql_Insert = "insert into we_notify (notify_type,msg_id,notify_staff) values('01',?,?)";
     $data = null;
     if ($post_to_group == "ALL" || $post_to_group == "all") {
         $sql_str = "select login_account from we_circle_staff where circle_id=?";
         $params_array = array((string) $user->get_circle_id($network_domain));
         //$param[]=(string)$user->get_circle_id($network_domain);
         $ds = $da->Getdata("we_circle_staff", $sql_str, $params_array);
         $data = $ds['we_circle_staff']['rows'];
     } else {
         $sql_str = "select login_account from we_group_staff where group_id=?";
         $params_array = array((string) $post_to_group);
         //$param[]=(string)$post_to_group;
         $ds = $da->Getdata("we_group_staff", $sql_str, $params_array);
         $data = $ds['we_group_staff']['rows'];
     }
     foreach ($data as $row) {
         $param = array();
         $param[] = (string) $bulletin_id;
         $param[] = (string) $row['login_account'];
         $da->ExecSQL($sql_Insert, $param);
     }
     $re = array('success' => '1', 'bulletin_id' => $bulletin_id);
     $response = new Response(json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
示例#22
0
文件: Role.php 项目: 3116246/haolinju
 public function saveEnRole($eno, $rolecode, $rolename)
 {
     $id = SysSeq::GetSeqNextValue($this->conn, "we_role", "id");
     $sql = "insert into we_role(id,name,code,role_type,eno)values(?,?,?,'2',?)";
     $para = array((string) $id, (string) $rolename, (string) $rolecode, (string) $eno);
     $this->conn->ExecSQL($sql, $para);
     $datarow = array("id" => $id, "name" => $rolename, "code" => $rolecode, "role_type" => "2", "eno" => $eno);
     Cache_Enterprise::set(Cache_Enterprise::$EN_ROLE, $rolecode, json_encode($datarow));
     return 1;
 }
示例#23
0
 public function SendMsgAction()
 {
     $conn = $this->get("we_data_access");
     $conn_im = $this->get("we_data_access_im");
     $request = $this->getRequest();
     $currUser = $this->get('security.context')->getToken();
     if ($currUser == null) {
         $openid = $request->get('openid');
         $staffinfo = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, $openid, $this->get("logger"), $this->container);
         $staffdata = $staffinfo->getInfo();
         if (empty($staffdata)) {
             $re = array('returncode' => '9999', 'msg' => '无效的操作人');
             return $this->responseJson(json_encode($re));
         }
         $user = $staffinfo->getSessionUser($staffdata);
     } else {
         $user = $this->get('security.context')->getToken()->getUser();
     }
     //公众号相关参数
     $microObj = $request->get('microObj');
     $microName = $microObj["microName"];
     //接收对象(公众号名称)
     $microNumber = $microObj["microNumber"];
     //接收对象(公众号帐号)
     $microOpenid = $microObj["microOpenid"];
     //接收对象(公众号Openid)
     $microType = $microObj["microType"];
     //接收对象(公众号类型,内部或外部)
     $microUse = $microObj["microUse"];
     //接收对象(是公众号还是微应用)
     $microGroupId = "";
     //$microObj["microGroupId"]; //接收对象(公众号分组主键)
     //消息参数
     $msgType = "";
     //消息类型
     $msgContent = "";
     //消息内容(XML拼接Json字符串,包括标题,图片,摘要等)
     $msgContentHtml = "";
     //消息内容(HTML内容)
     $msgTitle = "";
     //消息标题
     $imgUrl = "";
     //图片地址
     $formid = "";
     //表单编号。推送表单时设置
     $webpage_url = "";
     //网页地址。推送网页地址时设置
     $msgObj_list = $request->get('msgObj');
     //消息对象
     if (!empty($msgObj_list)) {
         foreach ($msgObj_list as $key => $val) {
             if ($key == "type") {
                 $msgType = $val;
             } else {
                 if ($key == "msgContent") {
                     $msgContent = $val;
                 } else {
                     if ($key == "contentHtml") {
                         $msgContentHtml = $val;
                     } else {
                         if ($key == "title") {
                             $msgTitle = $val;
                         } else {
                             if ($key == "imgUrl") {
                                 $imgUrl = $val;
                             } else {
                                 if ($key == "formid") {
                                     $formid = $val;
                                 } else {
                                     if ($key == "webpage_url") {
                                         $webpage_url = $val;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $staffinfo = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, empty($microNumber) ? $microOpenid : $microNumber, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         $re = array('returncode' => '9999', 'msg' => '请选择接收对象');
         return $this->responseJson(json_encode($re));
     } else {
         $microOpenid = $staffdata["openid"];
         $microNumber = $staffdata["login_account"];
     }
     $re = array('returncode' => '0000');
     $sqls = array();
     $paras = array();
     $send_state = '2';
     $id = SysSeq::GetSeqNextValue($conn, 'we_micro_send_message', 'id');
     $sqls[] = "insert into `we_micro_send_message` (`id`, `send_account`, `send_groupid`, `send_datetime`, `send_state`, `send_isbutton`, `send_source`,`send_type`) VALUES (?, ?, ?, now(), ?, ?, ?,?);";
     $paras[] = array($id, $microNumber, $microGroupId, $send_state, false, 'wefafa', $msgType);
     $error = array('returncode' => '9999', 'msg' => '消息内容有误,请检查');
     //处理消息
     switch ($msgType) {
         case 'PICTURE':
             $title = '';
             //标题
             $image_type = '';
             //图片类型  URL或CODE
             $image_value = '';
             //图片地址
             $content = '';
             //摘要
             $link = '';
             //手机端点击之后连接地址
             try {
                 foreach ($msgContent as $key => $value) {
                     if ($key == 'picturemsg') {
                         $picturemsg = $value;
                         //判断参数是否为空。并返回错误提示
                         if (empty($picturemsg)) {
                             return $this->responseJson(json_encode($error));
                         }
                         foreach ($picturemsg as $pkey => $pvalue) {
                             if ($pkey == 'headitem') {
                                 $headitem = $pvalue;
                                 //判断参数是否为空。并返回错误提示
                                 if (empty($headitem)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 foreach ($headitem as $hkey => $hvalue) {
                                     if ($hkey == 'title') {
                                         $title = $hvalue;
                                     } else {
                                         if ($hkey == 'image') {
                                             $image = $hvalue;
                                             //判断参数是否为空。并返回错误提示
                                             if (empty($image)) {
                                                 return $this->responseJson(json_encode($error));
                                             }
                                             foreach ($image as $ikey => $ivalue) {
                                                 if ($ikey == 'type') {
                                                     $image_type = $ivalue;
                                                 } else {
                                                     if ($ikey == 'value') {
                                                         $image_value = $ivalue;
                                                     }
                                                 }
                                             }
                                         } else {
                                             if ($hkey == 'content') {
                                                 $content = $hvalue;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             } catch (Exception $e) {
                 $this->get('logger')->err($e->getMessage());
                 return $this->responseJson(json_encode($error));
             }
             if (!empty($webpage_url)) {
                 $link = $webpage_url;
                 $uniqid = $webpage_url;
             } else {
                 $uniqid = str_replace('.', '', uniqid('', true));
                 $link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid);
                 if (!empty($formid)) {
                     $uniqid = $link;
                 }
             }
             $noticeinfo = Utils::WrapMessageNoticeinfo($title, $microName);
             $msgContent = Utils::WrapMessage("mm-picturemsg", array('headitem' => array('title' => $title, 'image' => array('type' => $image_type, 'value' => $image_value), 'content' => $content, 'link' => $link)), $noticeinfo);
             //$msgContent= array('picturemsg'=>array('headitem'=>array('title'=>$title,'image'=>array('type'=>$image_type,'value'=>$image_value),'content'=>$content,'link'=>$link)));
             $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
             $sqls[] = "insert into `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
             $msgContentHtml = $this->SetElementStyle($msgContentHtml);
             $paras[] = array($msgid, $id, $title, $msgType, null, $msgContentHtml, $content, $image_type, $image_value, $uniqid, true, false);
             break;
         case 'TEXTPICTURE':
             try {
                 $headitem = array();
                 $items = array();
                 foreach ($msgContent as $key => $value) {
                     if ($key == 'textpicturemsg') {
                         $textpicturemsg = $value;
                         if (empty($textpicturemsg)) {
                             return $this->responseJson(json_encode($error));
                         }
                         foreach ($textpicturemsg as $tpmkey => $tpmvalue) {
                             if ($tpmkey == 'headitem') {
                                 $headitem = $tpmvalue;
                                 if (empty($headitem)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 $head_title = '';
                                 $head_img_type = '';
                                 $head_img_url = '';
                                 $head_contentHtml = '';
                                 $head_link = '';
                                 $formid = "";
                                 foreach ($headitem as $hkey => $hvalue) {
                                     if ($hkey == 'title') {
                                         $head_title = $hvalue;
                                     } else {
                                         if ($hkey == 'image') {
                                             $image = $hvalue;
                                             if (empty($image)) {
                                                 return $this->responseJson(json_encode($error));
                                             }
                                             foreach ($image as $imgkey => $imgvalue) {
                                                 if ($imgkey == 'type') {
                                                     $head_img_type = $imgvalue;
                                                 } else {
                                                     if ($imgkey == 'value') {
                                                         $head_img_url = $imgvalue;
                                                     }
                                                 }
                                             }
                                         } else {
                                             if ($hkey == 'content') {
                                                 $head_contentHtml = $hvalue;
                                             } else {
                                                 if ($hkey == 'formid') {
                                                     $formid = $hvalue;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 $uniqid = str_replace('.', '', uniqid('', true));
                                 $head_link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid);
                                 $headitem = array('title' => $head_title, 'image' => array('type' => $head_img_type, 'value' => $head_img_url), 'link' => $head_link);
                                 $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                                 $sqls[] = "insert into `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                                 $head_contentHtml = $this->SetElementStyle($head_contentHtml);
                                 $paras[] = array($msgid, $id, $head_title, $msgType, null, $head_contentHtml, null, $head_img_type, $head_img_url, $uniqid, true, false);
                             } else {
                                 if ($tpmkey == 'item') {
                                     $item = $tpmvalue;
                                     if (empty($item)) {
                                         return $this->responseJson(json_encode($error));
                                     }
                                     $item_array = array();
                                     for ($i = 0; $i < count($item); $i++) {
                                         $item_title = '';
                                         $item_img_type = '';
                                         $item_img_url = '';
                                         $item_contentHtml = '';
                                         $item_link = '';
                                         $formid = "";
                                         foreach ($item[$i] as $itemkey => $itemvalue) {
                                             if ($itemkey == 'title') {
                                                 $item_title = $itemvalue;
                                             } else {
                                                 if ($itemkey == 'image') {
                                                     $image = $itemvalue;
                                                     if (empty($image)) {
                                                         return $this->responseJson(json_encode($error));
                                                     }
                                                     foreach ($image as $imgkey => $imgvalue) {
                                                         if ($imgkey == 'type') {
                                                             $item_img_type = $imgvalue;
                                                         } else {
                                                             if ($imgkey == 'value') {
                                                                 $item_img_url = $imgvalue;
                                                             }
                                                         }
                                                     }
                                                 } else {
                                                     if ($itemkey == 'content') {
                                                         $item_contentHtml = $itemvalue;
                                                     } else {
                                                         if ($itemkey == 'formid') {
                                                             $formid = $itemvalue;
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         $uniqid = str_replace('.', '', uniqid('', true));
                                         $item_link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid);
                                         $item_array = array('title' => $item_title, 'image' => array('type' => $item_img_type, 'value' => $item_img_url), 'link' => $item_link);
                                         array_push($items, $item_array);
                                         $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                                         $sqls[] = "INSERT INTO `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                                         $paras[] = array($msgid, $id, $item_title, $msgType, null, $item_contentHtml, null, $item_img_type, $item_img_url, $uniqid, false, false);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $noticeinfo = Utils::WrapMessageNoticeinfo($headitem["title"], $microName);
                 $msgContent = Utils::WrapMessage("mm-textpicturemsg", array('headitem' => $headitem, 'item' => $items), $noticeinfo);
                 //$msgContent= array('textpicturemsg'=>array('headitem'=>$headitem,'item'=>$items));
             } catch (\Exception $e) {
                 $this->get('logger')->err($e->getMessage());
                 return $this->responseJson(json_encode($error));
             }
             break;
         case 'TEXT':
             foreach ($msgContent as $key => $value) {
                 if ($key == 'textmsg') {
                     $textmsg = $value;
                     //判断参数是否为空。并返回错误提示
                     if (empty($textmsg)) {
                         return $this->responseJson(json_encode($error));
                     }
                     foreach ($textmsg as $tkey => $tvalue) {
                         if ($tkey == 'item') {
                             $items = $tvalue;
                             //判断参数是否为空。并返回错误提示
                             if (empty($items)) {
                                 return $this->responseJson(json_encode($error));
                             }
                             $new_items = array();
                             for ($i = 0; $i < count($items); $i++) {
                                 $title = '';
                                 $content = '';
                                 foreach ($items[$i] as $itemkey => $itemvalue) {
                                     if ($itemkey == 'title') {
                                         $title = $itemvalue;
                                     } else {
                                         if ($itemkey == 'content') {
                                             $content = $itemvalue;
                                         }
                                     }
                                 }
                                 if (empty($title)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 if (empty($content)) {
                                     return $this->responseJson(json_encode($error));
                                 }
                                 array_push($new_items, array('title' => $title, 'content' => $content));
                                 $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                                 $sqls[] = "INSERT INTO `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                                 $paras[] = array($msgid, $id, $title, $msgType, $content, null, null, null, null, null, false, false);
                             }
                             $noticeinfo = Utils::WrapMessageNoticeinfo($title, $microName);
                             $msgContent = Utils::WrapMessage("mm-textmsg", array('item' => $new_items), $noticeinfo);
                             // array('code'=>'textmsg','data'=>array('item'=>$new_items),'noticeinfo'=>'');
                         }
                     }
                 }
             }
             break;
         default:
             //消息类型有误
             return $this->responseJson(json_encode($error));
             break;
     }
     $msgContent = json_encode($msgContent);
     try {
         $staffMgr = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, $microNumber, $this->get("logger"), $this->container);
         $microData = $staffMgr->getInfo();
         $mic_jid = $microData["fafa_jid"];
         $msgxml = Utils::WrapMicroMessageXml($mic_jid, $msgContent, $id);
         $im_msg_sql = "insert into im_microaccount_msg(microaccount,msg,created,us,msgid)values(?,?,now(),?,?)";
         $conn_im->ExecSQL($im_msg_sql, array((string) $mic_jid, (string) $msgxml, "", (string) $id));
         $fafa_jids = array();
         $sqls_staff = array();
         $paras_staff = array();
         $apicontroller = new \Justsy\OpenAPIBundle\Controller\ApiController();
         $apicontroller->setContainer($this->container);
         $serviceMgr = new \Justsy\BaseBundle\Management\Service($this->container);
         //$this->get('logger')->err("================1:".time());
         $fafa_jids = $serviceMgr->service_sendjid($mic_jid, true);
         //$this->get('logger')->err("================:".json_encode($fafa_jids));
         if (!empty($fafa_jids)) {
             $jids = array();
             $count = count($fafa_jids);
             for ($i = 0; $i < $count; $i++) {
                 array_push($jids, (string) $fafa_jids[$i]);
                 if ($i > 0 && $i % 5000 == 0) {
                     $re = $apicontroller->sendMsg2($microOpenid, implode(",", $jids), $msgContent, $msgType, false, "0", $id);
                     $jids = array();
                 }
             }
             if (!empty($jids) && count($jids) > 0) {
                 $re = $apicontroller->sendMsg2($microOpenid, implode(",", $jids), $msgContent, $msgType, false, "0", $id);
             }
         }
         //$this->get('logger')->err("================3:".time());
         if (!empty($re['returncode']) && $re['returncode'] == '0000') {
             //添加发送消息数据
             if (!empty($sqls)) {
                 $conn->ExecSQLs($sqls, $paras);
             }
             //添加接收人员
             if (!empty($sqls_staff)) {
                 $conn->ExecSQLs($sqls_staff, $paras_staff);
             }
         }
     } catch (\Exception $e) {
         $this->get('logger')->err($e->getMessage());
         $re = array('returncode' => '9999', 'msg' => '消息发送失败');
     }
     return $this->responseJson(json_encode($re));
 }
示例#24
0
 public function editschoolAction()
 {
     $da = $this->get('we_data_access');
     $request = $this->getRequest();
     $schoolid = $request->get("schoolid");
     $fileid = $request->get("fileid");
     $filename = $request->get("filename");
     $staffobj = $request->get("staff");
     $title = $request->get("title");
     $sql = "";
     $para = array();
     $data = array();
     $id = "";
     if (empty($schoolid)) {
         //添加
         $currUser = $this->get('security.context')->getToken();
         $staffid = $currUser->getUser()->getUserName();
         $id = SysSeq::GetSeqNextValue($da, "mb_content_publish", "id");
         $sql = "insert into mb_school(id,fileid,title,filename,date,staffid)values(?,?,?,?,now(),?)";
         $para = array((string) $id, (string) $fileid, (string) $title, (string) $filename, (string) $staffid);
     } else {
         //判断fileid和表中的fileid是否一致,如果不一致则删除原来的文件
         $sql = "select fileid from mb_school where id=?";
         $ds = $da->GetData("table", $sql, array((string) $schoolid));
         if ($ds && $ds["table"]["recordcount"] > 0) {
             $oldfileid = $ds["table"]["rows"][0]["fileid"];
             if ($oldfileid != $fileid) {
                 $this->deleteFile($oldfileid);
             }
         }
         $sql = "update mb_school set fileid=?,title=?,filename=? where id=?";
         $para = array((string) $fileid, (string) $title, (string) $filename, (string) $schoolid);
     }
     $success = true;
     $message = "";
     if (count($para) > 0) {
         try {
             $da->ExecSQL($sql, $para);
         } catch (Exception $e) {
             $this->get("logger")->err($e->getMessage());
             $succcess = false;
             $message = $e->getMessage();
         }
     }
     //保存用户权限
     if ($success) {
         if (empty($schoolid)) {
             $success = $this->editSchool($da, false, $id, $staffobj);
         } else {
             $success = $this->editSchool($da, true, $schoolid, $staffobj);
         }
         if (!$success) {
             $message = "保存用户权限失败!";
         }
     }
     $result = array("success" => $success, "message" => $message);
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
 private function getIMParentId($da_im, $dept_name)
 {
     $curUser = $this->get('security.context')->getToken()->getUser();
     $eno = $curUser->eno;
     $sql = "select deptid from im_base_dept where deptname=?";
     $ds = $da_im->GetData("table", $sql, array((string) $dept_name));
     if ($ds && $ds["table"]["recordcount"] > 0) {
         return $ds["table"]["rows"][0]["deptid"];
     } else {
         $deptid = SysSeq::GetSeqNextValue($da_im, "im_base_dept", "deptid");
         $sql = "insert into im_base_dept(deptid,deptname,pid,noorder)values(?,?,?,0);";
         $para = array((string) $deptid, $dept_name, "v" . $eno);
         $da_im->ExecSQL($sql, $para);
         return $deptid;
     }
 }
示例#26
0
 public function reply($data)
 {
     $noticeid = $data["noticeid"];
     if (empty($noticeid)) {
         return Utils::WrapResultError("noticeid不能为空");
     }
     $files = isset($data["files"]) ? $data["files"] : '';
     if (!empty($files) && is_array($files)) {
         $files = implode(',', $files);
     }
     $sql = 'update im_pushnotice_memebr set receive_time=now() where noticeid=? and employeeid=? and receive_time is not null';
     $sql1 = 'insert into im_pushnotice_msg(id,replyid,msg,created,us,msgid)values(?,?,?,now(),?,?)';
     $replyid = SysSeq::GetSeqNextValue($this->conn_im, "im_pushnotice_msg", "id");
     $sql = 'select count(1)+1 cnt from im_pushnotice_msg where replyid=?';
     $ds = $this->conn_im->Getdata('t', $sql, array((int) $noticeid));
     $cnt = $ds['t']['rows'][0]['cnt'];
     $senddata = array();
     $senddata = array('noticeid' => $noticeid, 'reply_count' => $cnt, 'reply' => array('id' => $replyid, 'nickname' => $this->user["nick_name"], 'photo' => $this->user["photo_path"], 'jid' => $this->user["jid"], 'text' => $data["reply-text"], 'files' => $files, 'sendtime' => date("Y-m-d H:i:s", time())));
     $notice = array();
     // Utils::WrapMessageNoticeinfo($data["reply-text"],$this->module["appname"],null,$this->module["logo"]);
     $msg = Utils::WrapMessage('push-notice-reply', $senddata, $notice);
     $msgxml = Utils::WrapMessageXml($this->module["jid"], $msg, 'push-notice-reply-' . $replyid);
     $this->conn_im->ExecSQLs(array($sql, $sql1), array(array((int) $noticeid, (string) $this->user["jid"]), array((int) $replyid, (int) $noticeid, (string) json_encode($senddata['reply']), $this->user['jid'], 'push-notice-reply-' . $replyid)));
     $noticeinfo = $this->getinfo($noticeid);
     $receiver = $this->getmember($noticeid);
     $receiver[] = $noticeinfo["us"];
     Utils::findonlinejid($this->conn_im, $receiver);
     if (!empty($receiver)) {
         //发送消息
         $presence = new \Justsy\OpenAPIBundle\Controller\ApiController();
         $presence->setContainer($this->container);
         $presence->sendMsg($this->module["jid"], $receiver, '通知回复', json_encode($msg));
     }
     return Utils::WrapResultOK(array('noticeid' => $noticeid));
 }
示例#27
0
文件: App.php 项目: 3116246/haolinju
 public function setappsession($parameter)
 {
     $appid = $parameter["appid"];
     $openid = $parameter["openid"];
     $retuenAry = $parameter["session"];
     //存储token=>we_app_oauth_sessions
     $sql = "select 1 from we_app_oauth_sessions where appid=? and userid=?";
     $db = $this->conn;
     $dsset = $db->getdata("t", $sql, array((string) $appid, (string) $openid));
     if (isset($retuenAry["expires_in"])) {
         $expires_in = (int) $retuenAry["expires_in"];
         $accessTokenExpires = time() + $expires_in;
         $retuenAry["expires_in"] = $accessTokenExpires;
     } else {
         $retuenAry["expires_in"] = 0;
         $accessTokenExpires = 0;
         $expires_in = 0;
     }
     if ($dsset && count($dsset["t"]["rows"]) > 0) {
         $sql = "update we_app_oauth_sessions set access_token=?,refresh_token=?,access_token_expires=? where appid=? and userid=?";
         $db->ExecSQL($sql, array((string) $retuenAry["access_token"], isset($retuenAry["refresh_token"]) ? (string) $retuenAry["refresh_token"] : "", (int) $accessTokenExpires, (string) $appid, (string) $openid));
     } else {
         $id = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($db, "we_app_oauth_sessions", "id");
         $sql = "insert into we_app_oauth_sessions(id,appid,userid,user_type,access_token,refresh_token,access_token_expires)values(?,?,?,?,?,?,?)";
         $db->ExecSQL($sql, array((int) $id, (string) $appid, (string) $openid, "user", (string) $retuenAry["access_token"], isset($retuenAry["refresh_token"]) ? (string) $retuenAry["refresh_token"] : "", (int) $accessTokenExpires));
     }
     $cacheKey = md5($appid . $openid);
     Cache_Enterprise::set(Cache_Enterprise::$EN_OAUTH2, $cacheKey, json_encode($retuenAry), $expires_in, $this->containerObj);
 }
示例#28
0
 public static function saveMail($da, $send_email, $recv_email, $title, $content, $remark = null)
 {
     $id = SysSeq::GetSeqNextValue($da, "we_mails", "id");
     $sql = "insert into we_mails (id,send_email,recv_email,title,content,remark,is_send,into_date) values (?,?,?,?,?,?,'0',now())";
     $da->ExecSQL($sql, array((string) $id, (string) $send_email, (string) $recv_email, (string) $title, (string) $content, (string) $remark));
 }
示例#29
0
 public function Del($planid)
 {
     if (empty($planid)) {
         $resp = new Response('');
         $resp->headers->set('Content-Type', 'text/json');
         return $resp;
     }
     $ds = $this->GetPlan($planid);
     $groupid = $ds[0]["groupid"];
     $sqls = array();
     $paras = array();
     $sqlsim = array();
     $parasim = array();
     $staffold = "";
     $cycle = $ds[0]["cycle"];
     //线上语音会议
     if (!empty($groupid)) {
         //例会   创建新例会  删除临时成员
         if (!empty($cycle)) {
             $newplanid = "we" . SysSeq::GetSeqNextValue($this->conn, "we_meeting_plan", "id");
             //修改例会时间  以周为单位进行修改
             $sqls[] = "insert into we_meeting_plan(id,groupid,name,subject,item,meetingstartdate,meetingenddate,meetingtype,addrType,defaultAddr,cycle,master,remind,create_staff,create_date) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
             $sqlplan_data = "select * from (select meetingstartdate,meetingenddate from we_meeting_plan where groupid='" . $groupid . "' order by meetingstartdate limit 0,1) as t1";
             $sqlplan_data .= " union ";
             $sqlplan_data .= "select * from (select meetingstartdate,meetingenddate from we_meeting_plan where groupid='" . $groupid . "' order by meetingstartdate desc  limit 0,1) as t2 ";
             $parasplan_date = array((string) $groupid);
             $dsplan_date = $this->conn->GetData("rt", $sqlplan_data, $parasplan_date);
             $meetingstartdate = "";
             $meetingenddate = "";
             $starttime = "";
             $endtime = "";
             $count = count($dsplan_date);
             if ($count > 0) {
                 for ($i = 0; $i < $count; $i++) {
                     if ($i == 0) {
                         //只有一条数据
                         $meetingstartdate = $dsplan_date["rt"]["rows"][$i]["meetingstartdate"];
                         $meetingenddate = $dsplan_date["rt"]["rows"][$i]["meetingenddate"];
                         $starttime = date("H:i:s", strtotime($meetingstartdate));
                         $endtime = date("H:i:s", strtotime($meetingenddate));
                     } else {
                         $startdate = date("Y-m-d", strtotime($dsplan_date["rt"]["rows"][$i]["meetingstartdate"]));
                         $enddate = date("Y-m-d", strtotime($dsplan_date["rt"]["rows"][$i]["meetingenddate"]));
                         $meetingstartdate = $startdate . " " . $starttime;
                         $meetingenddate = $enddate . " " . $endtime;
                         break;
                     }
                 }
             }
             $cycle = $ds[0]["cycle"];
             switch ($cycle) {
                 case "1":
                     $meetingstartdate = date("Y-m-d H:i:s", strtotime("+1 months", strtotime($meetingstartdate)));
                     $meetingenddate = date("Y-m-d H:i:s", strtotime("+1 months", strtotime($meetingenddate)));
                     break;
                 case "3":
                     $meetingstartdate = date("Y-m-d H:i:s", strtotime("+3 months", strtotime($meetingstartdate)));
                     $meetingenddate = date("Y-m-d H:i:s", strtotime("+3 months", strtotime($meetingenddate)));
                     break;
                 case "7":
                     $meetingstartdate = date("Y-m-d H:i:s", strtotime("+1 week", strtotime($meetingstartdate)));
                     $meetingenddate = date("Y-m-d H:i:s", strtotime("+1 week", strtotime($meetingenddate)));
                     break;
                 case "12":
                     $meetingstartdate = date("Y-m-d H:i:s", strtotime("+1 year", strtotime($meetingstartdate)));
                     $meetingenddate = date("Y-m-d H:i:s", strtotime("+1 year", strtotime($meetingenddate)));
                     break;
             }
             $name = $ds[0]["name"];
             $subject = $ds[0]["subject"];
             $item = $ds[0]["item"];
             $meetingtype = $ds[0]["meetingtype"];
             $addrType = $ds[0]["addrType"];
             $defaultAddr = $ds[0]["defaultAddr"];
             $master = $ds[0]["master"];
             $remind = $ds[0]["remind"];
             $create_staff = $ds[0]["create_staff"];
             $create_date = $ds[0]["create_date"];
             $paras[] = array((string) $newplanid, $groupid, $name, $subject, $item, $meetingstartdate, $meetingenddate, $meetingtype, $addrType, $defaultAddr, $cycle, $master, $remind, $create_staff, $create_date);
             //删除例会临时成员
             $sqls[] = "delete from we_meeting_member where planid=? and stafftype!='1'";
             $paras[] = array((string) $planid);
             $sqlsim[] = "DELETE FROM im_groupemployee_version WHERE groupid=?";
             $parasim[] = array($groupid);
             //需要删除群组的相关人员
             $staffold = $this->GetStaffByType($planid);
             for ($i = 0; $i < count($staffold); $i++) {
                 $sqlsim[] = "delete from im_groupemployee where groupid=? and employeeid=?";
                 $parasim[] = array((string) $groupid, (string) $staffold[$i]);
                 $sqlsim[] = "DELETE FROM we_im.im_group_version WHERE us=? ";
                 $parasim[] = array($staffold[$i]);
             }
         } else {
             //单例会  删除群组和成员
             //删除会议计划所有成员
             $sqls[] = "delete from we_meeting_member where planid=?";
             $paras[] = array((string) $planid);
             //删除一次性会议计划
             $sqls[] = "delete from we_meeting_plan where id=? ";
             $paras[] = array((string) $planid);
             //删除对应群组的所有人员
             $sqlsim[] = "delete from im_groupemployee where groupid=?";
             $parasim[] = array((string) $groupid);
             //删除会议计划对应的群组
             $sqlsim[] = "delete from im_group where groupid=?";
             $parasim[] = array((string) $groupid);
             $sqlsim[] = "DELETE FROM im_groupemployee_version WHERE groupid=?";
             $parasim[] = array($groupid);
             $sql_im_groupemployee = "SELECT employeeid FROM we_im.im_groupemployee WHERE groupid=? AND employeeid IS NOT NULL ;";
             $para_im_groupemployee = array($groupid);
             $data_im_groupemployee = $conn_im->GetData('dt', $sql_im_groupemployee, $para_im_groupemployee);
             if ($data_im_groupemployee != null && count($data_im_groupemployee["dt"]["rows"]) > 0 && $data_im_groupemployee["dt"]["rows"][0]['employeeid']) {
                 for ($i = 0; $i < count($data_im_groupemployee["dt"]["rows"]); $i++) {
                     $sqlsim[] = "DELETE FROM we_im.im_group_version WHERE us=? ";
                     $parasim[] = array($data_im_groupemployee["dt"]["rows"][$i]['employeeid']);
                 }
             }
         }
     } else {
         //线下会议
         //例会   创建新例会  删除临时成员
         if (!empty($cycle)) {
         } else {
             //单例会
             //删除会议计划所有成员
             $sqls[] = "delete from we_meeting_member where planid=?";
             $paras[] = array((string) $planid);
             //删除一次性会议计划
             $sqls[] = "delete from we_meeting_plan where id=? ";
             $paras[] = array((string) $planid);
         }
     }
     try {
         if (!empty($groupid)) {
             //线上会议
             if (!empty($sqls)) {
                 $this->conn->ExecSQLs($sqls, $paras);
             }
             if (!empty($sqlsim)) {
                 $this->conn_im->ExecSQLs($sqlsim, $parasim);
             }
         } else {
             //线下会议
             if (!empty($sqls)) {
                 $this->conn->ExecSQLs($sqls, $paras);
             }
         }
         //发送出席消息
         $this->SendImPresence($planid, "del", "", "", false, "", "");
         if (!empty($cycle)) {
             //例会发送提示消息
             if (!empty($staffold)) {
                 $tojid = implode(",", $staffold);
                 $this->SendImMessage($planid, "del", $tojid, "");
             }
         } else {
             //线下会议
             $ds = $this->GetStaff($planid, "");
             $tojid = implode(",", $ds);
             $this->SendImMessage($planid, "del", $tojid, "");
         }
     } catch (\Exception $exc) {
         $this->container->get('logger')->err($exc);
         $planid = 0;
     }
     $resp = new Response($planid);
     $resp->headers->set('Content-Type', 'text');
     return $resp;
 }
示例#30
0
 public function TextPictureMsgAction()
 {
     //if($_SERVER['REQUEST_METHOD']!="POST")
     //	return $this->responseJson(json_encode(array("error"=>"10009","msg"=>"HTTP请求仅支持POST提交方式")));
     $conn = $this->get("we_data_access");
     $conn_im = $this->get("we_data_access_im");
     $request = $this->getRequest();
     $micro_account = $request->get('micro_account');
     $micro_groupid = $request->get('micro_groupid');
     $appid = $request->get('appid');
     $openid = 'wefafaproxy';
     $recopenid = $request->get('openid');
     $access_token = $request->get('access_token');
     $msg = $request->get('msg');
     if (empty($appid) && empty($micro_account)) {
         return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => 'appid不能为空。')));
     }
     if (empty($access_token)) {
         return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '访问令牌不能为空。')));
     }
     if (empty($msg)) {
         return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '消息不能为空。')));
     }
     $msgObj = json_decode($msg);
     if (empty($msgObj)) {
         return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '消息格式不正确。')));
     }
     if (empty($openid)) {
         $openid = "wefafaproxy";
     }
     $token_appid = $this->checkAccessToken($conn, $appid, $openid, $access_token);
     if ($token_appid === false) {
         return $this->responseJson(json_encode(array('returncode' => '0001', 'msg' => '访问令牌已过期。')));
     }
     if ($token_appid != $appid) {
         return $this->responseJson(json_encode(array('returncode' => '0001', 'msg' => 'appid无效。')));
     }
     //token通过认证
     if (empty($micro_account)) {
         $sql_micro_account = "select number from we_micro_account where micro_source=? ";
         $data_micro_account = $conn->GetData("dt", $sql_micro_account, array((string) $appid));
         if ($data_micro_account != null && count($data_micro_account["dt"]["rows"]) > 0 && !empty($data_micro_account["dt"]["rows"][0]["number"])) {
             $micro_account = $data_micro_account["dt"]["rows"][0]["number"];
         } else {
             return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '应用未开启业务代理,不能推送消息。')));
         }
     }
     $login_account = $micro_account;
     if ($openid != "wefafaproxy") {
         $staff = $this->checkOpenid($conn, $openid);
         if (empty($staff)) {
             return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => 'openid不存在。')));
         }
     }
     $sql = "SELECT b.fafa_jid openid FROM we_micro_account a LEFT JOIN we_staff b ON b.login_account=a.number AND b.eno=a.eno WHERE a.number=?;";
     $para = array($micro_account);
     $data = $conn->GetData('dt', $sql, $para);
     if ($data == null || count($data['dt']['rows']) == 0 || empty($data['dt']['rows'][0]['openid'])) {
         return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '微应用帐号不存在。')));
     }
     $microOpenid = $data['dt']['rows'][0]['openid'];
     $re = array('returncode' => '9999', 'msg' => '消息发送失败。');
     try {
         $msgType = 'TEXTPICTURE';
         $send_state = '2';
         $sqls = array();
         $paras = array();
         $headitem = array();
         $items = array();
         $file_url = $this->container->getParameter('FILE_WEBSERVER_URL');
         $id = SysSeq::GetSeqNextValue($conn, 'we_micro_send_message', 'id');
         $sqls[] = "INSERT INTO `we_micro_send_message` (`id`, `send_account`, `send_groupid`, `send_datetime`, `send_state`, `send_isbutton`, `send_source`,`send_type`) VALUES (?, ?, ?, now(), ?, ?, ?,?);";
         $paras[] = array($id, $micro_account, $micro_groupid, $send_state, false, 'interface', $msgType);
         foreach ($msgObj as $tpmkey => $tpmvalue) {
             if ($tpmkey == 'headitem') {
                 $headitem = $tpmvalue;
                 if (empty($headitem)) {
                     return $this->responseJson(json_encode($error));
                 }
                 $head_title = '';
                 $head_img = '';
                 $head_contentHtml = '';
                 $head_link = '';
                 foreach ($headitem as $hkey => $hvalue) {
                     if ($hkey == 'title') {
                         $head_title = $hvalue;
                     } else {
                         if ($hkey == 'image') {
                             $head_img = $hvalue;
                         } else {
                             if ($hkey == 'content') {
                                 $head_contentHtml = htmlspecialchars_decode($hvalue);
                             }
                         }
                     }
                 }
                 if (empty($head_title)) {
                     return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '消息头部标题不能为空。')));
                 }
                 if (empty($head_img)) {
                     return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '消息头部图片不能为空。')));
                 }
                 if (empty($head_contentHtml)) {
                     return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '消息头部内容不能为空。')));
                 }
                 $uniqid = str_replace('.', '', uniqid('', true));
                 $head_link = $this->getLink($uniqid);
                 if (strpos($head_img, $file_url) === false) {
                     $head_img = $file_url . $head_img;
                 }
                 $headitem = array('title' => $head_title, 'image' => array('type' => 'URL', 'value' => $head_img), 'link' => $head_link);
                 $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                 $sqls[] = "INSERT INTO `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                 $paras[] = array($msgid, $id, $head_title, $msgType, null, $head_contentHtml, null, 'URL', $head_img, $uniqid, true, false);
             } else {
                 if ($tpmkey == 'items') {
                     $item = $tpmvalue;
                     if (empty($item)) {
                         return $this->responseJson(json_encode($error));
                     }
                     $item_array = array();
                     for ($i = 0; $i < count($item); $i++) {
                         $item_title = '';
                         $item_img = '';
                         $item_contentHtml = '';
                         $item_link = '';
                         foreach ($item[$i] as $itemkey => $itemvalue) {
                             if ($itemkey == 'title') {
                                 $item_title = $itemvalue;
                             } else {
                                 if ($itemkey == 'image') {
                                     $item_img = $itemvalue;
                                 } else {
                                     if ($itemkey == 'content') {
                                         $item_contentHtml = htmlspecialchars_decode($itemvalue);
                                     }
                                 }
                             }
                         }
                         if (empty($item_title)) {
                             return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '消息子项标题不能为空。')));
                         }
                         if (empty($item_img)) {
                             return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '消息子项图片不能为空。')));
                         }
                         if (empty($item_contentHtml)) {
                             return $this->responseJson(json_encode(array('returncode' => '9999', 'msg' => '消息子项内容不能为空。')));
                         }
                         $uniqid = str_replace('.', '', uniqid('', true));
                         $item_link = $this->getLink($uniqid);
                         if (strpos($item_img, $file_url) === false) {
                             $item_img = $file_url . $item_img;
                         }
                         $item_array = array('title' => $item_title, 'image' => array('type' => 'URL', 'value' => $item_img), 'link' => $item_link);
                         array_push($items, $item_array);
                         $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id');
                         $sqls[] = "INSERT INTO `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
                         $paras[] = array($msgid, $id, $item_title, $msgType, null, $item_contentHtml, null, 'URL', $item_img, $uniqid, false, false);
                     }
                 }
             }
         }
         $msgContent = array('textpicturemsg' => array('headitem' => $headitem, 'item' => $items));
         $msgContent = json_encode($msgContent);
         $fafa_jids = array();
         $sqls_staff = array();
         $paras_staff = array();
         $apicontroller = new \Justsy\OpenAPIBundle\Controller\ApiController();
         $apicontroller->setContainer($this->container);
         $MicroAccountMgr = new \Justsy\BaseBundle\Management\MicroAccountMgr($conn, $conn_im, $login_account, $this->get("logger"), $this->container);
         if ($this->checkint($micro_groupid)) {
             $count = $MicroAccountMgr->check_micro_fans_groupid($micro_account, $micro_groupid);
             $microdata = array();
             if ($count > 0) {
                 //分组主键在数据库不存在
                 $microdata = $MicroAccountMgr->get_micro_fans_group($micro_account, $micro_groupid);
                 for ($i = 0; $i < count($microdata); $i++) {
                     if (!in_array($microdata[$i]["fafa_jid"], $fafa_jids) && !empty($microdata[$i]["fafa_jid"])) {
                         if (!in_array($microdata[$i]["fafa_jid"], $fafa_jids)) {
                             array_push($fafa_jids, $microdata[$i]["fafa_jid"]);
                             $staffid = SysSeq::GetSeqNextValue($conn, 'we_micro_message_recipient', 'id');
                             $sqls_staff[] = "INSERT INTO `we_micro_message_recipient` (`id`, `send_id`, `eno`, `login_account`, `openid`, `fafa_jid`, `rec_datetime`) VALUES (?, ?, ?, ?, ?, ?, now());";
                             $paras_staff[] = array($staffid, $id, $microdata[$i]["eno"], $microdata[$i]["login_account"], $microdata[$i]["openid"], $microdata[$i]["fafa_jid"]);
                         }
                     }
                 }
             }
             if (!empty($recopenid)) {
                 $openids = explode(',', $recopenid);
                 for ($i = 0; $i < count($openids); $i++) {
                     $sql_staff = "select fafa_jid,login_account,openid,eno from we_staff where openid=?";
                     $data_staff = $conn->GetData("dt", $sql_staff, array((string) $openids[$i]));
                     if ($data_staff != null && count($data_staff["dt"]["rows"]) > 0) {
                         if (!in_array($data_staff["dt"]["rows"][0]["fafa_jid"], $fafa_jids)) {
                             array_push($fafa_jids, $data_staff["dt"]["rows"][0]["fafa_jid"]);
                             $staffid = SysSeq::GetSeqNextValue($conn, 'we_micro_message_recipient', 'id');
                             $sqls_staff[] = "INSERT INTO `we_micro_message_recipient` (`id`, `send_id`, `eno`, `login_account`, `openid`, `fafa_jid`, `rec_datetime`) VALUES (?, ?, ?, ?, ?, ?, now());";
                             $paras_staff[] = array($staffid, $id, $data_staff["dt"]["rows"][0]["eno"], $data_staff["dt"]["rows"][0]["login_account"], $data_staff["dt"]["rows"][0]["openid"], $data_staff["dt"]["rows"][0]["fafa_jid"]);
                         }
                     }
                 }
             }
         } else {
             if (!empty($recopenid)) {
                 $openids = explode(',', $recopenid);
                 for ($i = 0; $i < count($openids); $i++) {
                     $sql_staff = "select fafa_jid,login_account,openid,eno from we_staff where openid=?";
                     $data_staff = $conn->GetData("dt", $sql_staff, array((string) $openids[$i]));
                     if ($data_staff != null && count($data_staff["dt"]["rows"]) > 0) {
                         if (!in_array($data_staff["dt"]["rows"][0]["fafa_jid"], $fafa_jids)) {
                             array_push($fafa_jids, $data_staff["dt"]["rows"][0]["fafa_jid"]);
                             $staffid = SysSeq::GetSeqNextValue($conn, 'we_micro_message_recipient', 'id');
                             $sqls_staff[] = "INSERT INTO `we_micro_message_recipient` (`id`, `send_id`, `eno`, `login_account`, `openid`, `fafa_jid`, `rec_datetime`) VALUES (?, ?, ?, ?, ?, ?, now());";
                             $paras_staff[] = array($staffid, $id, $data_staff["dt"]["rows"][0]["eno"], $data_staff["dt"]["rows"][0]["login_account"], $data_staff["dt"]["rows"][0]["openid"], $data_staff["dt"]["rows"][0]["fafa_jid"]);
                         }
                     }
                 }
             } else {
                 $microdata = $MicroAccountMgr->get_micro_all_fans($micro_account);
                 for ($i = 0; $i < count($microdata); $i++) {
                     if (!in_array($microdata[$i]["fafa_jid"], $fafa_jids) && !empty($microdata[$i]["fafa_jid"])) {
                         array_push($fafa_jids, $microdata[$i]["fafa_jid"]);
                         $staffid = SysSeq::GetSeqNextValue($conn, 'we_micro_message_recipient', 'id');
                         $sqls_staff[] = "INSERT INTO `we_micro_message_recipient` (`id`, `send_id`, `eno`, `login_account`, `openid`, `fafa_jid`, `rec_datetime`) VALUES (?, ?, ?, ?, ?, ?, now());";
                         $paras_staff[] = array($staffid, $id, $microdata[$i]["eno"], $microdata[$i]["login_account"], $microdata[$i]["openid"], $microdata[$i]["fafa_jid"]);
                     }
                 }
             }
         }
         if (!empty($fafa_jids)) {
             $jids = array();
             for ($i = 0; $i < count($fafa_jids); $i++) {
                 array_push($jids, (string) $fafa_jids[$i]);
                 if (count($jids) == 500) {
                     $re = $apicontroller->sendMsg2($microOpenid, implode(",", $jids), $msgContent, $msgType, false, "0", $id);
                     $jids = array();
                 }
             }
             if (!empty($jids)) {
                 $re = $apicontroller->sendMsg2($microOpenid, implode(",", $jids), $msgContent, $msgType, false, "0", $id);
             }
         }
         if (!empty($re['returncode']) && $re['returncode'] == '0000') {
             //添加发送消息数据
             if (!empty($sqls)) {
                 $conn->ExecSQLs($sqls, $paras);
             }
             //添加接收人员
             if (!empty($sqls_staff)) {
                 $conn->ExecSQLs($sqls_staff, $paras_staff);
             }
         }
     } catch (\Exception $e) {
         $this->get('logger')->err($e->getMessage());
     }
     return $this->responseJson(json_encode($re));
 }