信呼OA版本v2.3.8

This commit is contained in:
雨中磐石
2022-08-14 16:47:40 +08:00
parent 4640677d27
commit e3fcd913e3
1405 changed files with 133635 additions and 73 deletions

View File

@@ -0,0 +1,84 @@
<?php
/**
* 对外开发接口文件
* createname信呼
* homeurlhttp://www.rockoa.com/
* Copyright (c) 2016 rainrock (www.rockoa.com)
* Date:2016-11-01
* explain返回200为正常
* post需开启always_populate_raw_post_data = On
*/
class openapiAction extends ActionNot
{
private $openkey = '';
public $postdata= '';
//是否验证openkey
protected $keycheck= true;
public function initAction()
{
$this->display= false;
$openkey = $this->post('openkey');
$this->openkey = getconfig('openkey');
if($this->keycheck && HOST != '127.0.0.1' && !contain(HOST,'192.168') && $this->openkey != ''){
if($openkey != md5($this->openkey))$this->showreturn('', 'openkey not access', 201);
}
$this->getpostdata();
}
public function getpostdata()
{
if(isset($GLOBALS['HTTP_RAW_POST_DATA']))$this->postdata = $GLOBALS['HTTP_RAW_POST_DATA'];
if($this->postdata=='')$this->postdata = trim(file_get_contents('php://input'));
}
public function getvals($nae, $dev='')
{
$sv = $this->rock->jm->base64decode($this->post($nae));
if($this->isempt($sv))$sv=$dev;
return $sv;
}
/**
* 获取提交的数据
*/
public function getpostarr()
{
$str = $this->postdata;
if(isempt($str))return false;
$arr = json_decode($str, true);
return $arr;
}
/**
* 根据关键字获取用户
*/
public function getuserid($id, $sur=true)
{
if(isempt($id))return 0;
$where = "`user`='$id'";
$check = c('check');
if($check->iscnmobile($id)){
$where = "`mobile`='$id'";
}elseif($check->isemail($id)){
$where = "`email`='$id'";
}elseif($check->isincn($id)){
$where = "`name`='$id'";
}elseif($check->isnumber($id)){
$where = "`id`='$id'";
}
$urs = $this->db->getall("select `id`,`name` from `[Q]admin` where $where and `status`=1");
if($this->db->count!=1)return 0;
$urs = $urs[0];
$uid = (int)$urs['id'];
if($sur){
$this->adminid = $uid;
$this->adminname = $urs['name'];
$this->rock->adminid = $uid; //用户Id
$this->rock->adminname = $urs['name'];
}
return $uid;
}
}

View File

@@ -0,0 +1,63 @@
<?php
/**
* 基本接口
* 请求地址如http://URL/api.php?m=openbase&openkey=openkey&a=方法名
*/
class openbaseClassAction extends openapiAction
{
/**
* 例子1新增模块单据如新增流程单据等
* 接口地址http://URL/api.php?m=openbase&openkey=openkey&a=querydata
*/
public function querydataAction()
{
$arr = $this->getpostarr();
if(!$arr)return returnerror('not data');
$modenum = $arr['basemodenum'];
$adminid = $arr['baseoptid']; //提交的用户
if(isempt($modenum))return returnerror('modenum is empty');
$uid = $this->getuserid($adminid);
if($uid==0)return returnerror('['.$adminid.']用户不存在');
$sm = arrvalue($arr,'baseexplain'); //说明
unset($arr['basemodenum']);
unset($arr['baseoptid']);
if($sm)unset($arr['baseexplain']);
//此方法在文件webmain/model/flowModel.php下的querydata方法。
$mid = m('flow')->querydata($modenum, $arr, $sm);
return returnsuccess(array(
'mid' => $mid,
));
}
/**
* 例子2推送消息到应用中
* 接口地址http://URL/api.php?m=openbase&openkey=openkey&a=pushtodo
*/
public function pushtodoAction()
{
$mid = null; //要推送单据ID
$modenum = 'daily'; //推送到哪个模块中,daily是工作日报模块
//1、初始化流程
$flow = m('flow')->initflow($modenum, $mid);
//2、调用推送方法调用webmain/model/flow/flow.php 下的push方法
$receid = '1'; //接收人ID,多个,分开如推送给全部人员写d1
$gname = ''; //推送到哪个应用下,为空,默认是跟当前模块名一样的应用。
$cont = '这是个推送的内容';
$title = '这是个标题'; //可以为空
$flow->push($receid, $gname, $cont, $title);
return '推送完成';
}
/**
* 例子3向单用户/会话发消息,聊天的。
*/
}

View File

@@ -0,0 +1,133 @@
<?php
/**
* 将数据上传到打卡记录表上
* 请求地址如http://127.0.0.1/api.php?m=opendkq&openkey=key
* 请求方式POST
* 提交过来数据[{"name":"姓名","dkdt":"2016-10-22 09:00:00"}]
*/
class opendkqClassAction extends openapiAction
{
public function indexAction()
{
//6 接口导入
$carr = $this->senddata(6);
$this->showreturn('成功导入'.$carr['oi'].'条数据');
}
//
private function senddata($type)
{
$str = $this->postdata;
if(isempt($str))$this->showreturn('', 'not data', 201);
$arr = json_decode($str, true);
$oi = 0;$uarr = array();$finarr = array();
$dtobj = c('date');$adb = m('admin');$db = m('kqdkjl');$uobj = m('userinfo');
$updt = '';
$cheobj = c('check');
$snarr = array();
if($type==9){
$snarr = $this->db->getarr('[Q]kqjsn','`pinpai`=1','`id`,`name`','num');
}
$datype = array('密码','指纹','刷卡');
if(is_array($arr))foreach($arr as $k=>$rs){
$name = isset($rs['name']) ? $rs['name'] : '';
$dkdt = isset($rs['dkdt']) ? $rs['dkdt'] : '';
$finge= isset($rs['finge']) ? $rs['finge'] : '';
$name = str_replace("'",'', $name);
$uid = 0;
$snid = 0;
$sntype = 1;
$comid = 0;
$explain = '';
if($type==9){
$sn = arrvalue($rs, 'sn');
if(!$sn)continue;
$snrs = arrvalue($snarr, $sn);
if(!$snrs)continue;
$snid = $snrs['id'];
$explain = '使用['.$snrs['name'].']打卡';
if(!isset($snrs['isgx'])){
m('kqjsn')->update("`lastdt`='$this->now'", $snid);
$snarr[$sn]['isgx'] = 'a';
}
}
if(!isempt($name) && !isempt($dkdt)){
if(!$dtobj->isdate($dkdt))continue;
if($updt=='' || $dkdt>$updt)$updt = $dkdt;
if($type==9 && $finge){
if(isset($finarr[$finge])){
if($finarr[$finge]){
$uid = $finarr[$finge]['id'];
$comid = $finarr[$finge]['companyid'];
}
}else{
$uwher = "`finger`='$finge'";
$usobj = $uobj->getrows($uwher,'`id`,`companyid`');
if($usobj){
$uid = $usobj[0]['id'];
$comid = $usobj[0]['companyid'];
$finarr[$finge] = $usobj[0];
}else{
$finarr[$finge] = false;
}
}
}
if($uid==0){
if(isset($uarr[$name])){
if($uarr[$name]){
$uid = $uarr[$name]['id'];
$comid = $uarr[$name]['companyid'];
}
}else{
$uwher = "`name`='$name'";
if($cheobj->iscnmobile($name))$uwher = "`mobile`='$name'";
if($cheobj->isemail($name))$uwher = "`email`='$name'";
$usar = $adb->getrows($uwher,'`id`,`companyid`');
if($usar){
$uid = $usar[0]['id'];
$comid = $usar[0]['companyid'];
$uarr[$name] = $usar[0];
}else{
$uarr[$name] = false;
}
}
}
if($uid==0)continue;
if($comid==0)$comid = 1;
if($db->rows("`uid`='$uid' and `dkdt`='$dkdt'")>0)continue;
$oi++;
$db->insert(array(
'uid' => $uid,
'dkdt' => $dkdt,
'optdt' => $this->now,
'type' => $type,
'snid' => $snid,
'sntype'=> $sntype,
'explain'=> $explain,
'comid'=> $comid,
));
}
}
if($updt && $updt>$this->now)$updt=$this->now;
//$this->rock->debugs(array($uarr, $finarr),'daorudaka');
return array(
'oi' => $oi,
'updt' => $updt,
);
}
/**
* 中控考勤机导入
*/
public function zktimeAction()
{
//9中控
$carr = $this->senddata(9);
echo $carr['updt'];
}
}

View File

@@ -0,0 +1,70 @@
<?php
/**
* 群英考勤机
* 请求地址如http://127.0.0.1/api.php?m=opendkq&openkey=key
*/
class openkqjClassAction extends openapiAction
{
private $snid = 0; //设备号ID
public function initAction()
{
$this->display= false;
$this->getpostdata();
}
public function indexAction()
{
echo 'ok';
}
//考勤机的使用
public function apiAction()
{
//print_r($_SERVER);
$path = arrvalue($GLOBALS,'_paths', $_SERVER['REQUEST_URI']);
if(isempt($path))return '';
$patha = explode('/', $path);
$acta = explode('?', $patha[count($patha)-1]);
$act = $acta[0];
$data = array();
$num = $this->get('sn'); //设备号
if(!$num)return 'notdata';
$dbs = m('kqjsn');
$snid = (int)$dbs->getmou('id',"`num`='$num'");
if($snid==0)$snid = $dbs->insert(array(
'num' => $num,
'optdt' => $this->rock->now,
'status' => 1
));
$this->snid = $snid;
//考勤机请求
if($act=='get'){
$data= m('kqjcmd')->getcmd($this->snid); //向考勤机发送命令
}
//推送来的
if($act=='post' && $this->postdata!=''){
$data= m('kqjcmd')->postdata($this->snid, $this->postdata);
}
//设备上获取服务器时间
if($act=='unixtime'){
$this->rock->debugs(json_encode($_GET),'unixtime');
$data['timezone'] = 'UTC';
$data['unixtime'] = time()-8*3600; //由于北京时间多8小时所有要减
$data['datetime'] = date('Y-m-d H:i:s', $data['unixtime']);
}
$barr['status'] = 1;
$barr['info'] = 'ok';
$barr['data'] = $data;
return $barr;
}
//推送过来的数据
//[{"id":"5056928","data":"return","return":[{"id":"0","result":"0"}]},{"id":"8993137","data":"return","return":[{"id":"0","result":"0"}]},{"id":"1275640","data":"return","return":[{"id":"0","result":"0"}]},{"id":"8085763","data":"return","return":[{"id":"0","result":"0"}]},{"id":"3896216","data":"return","return":[{"id":"0","result":"0"}]},{"id":"5036770","data":"return","return":[{"id":"0","result":"0"}]},{"id":"3554609","data":"return","return":[{"id":"0","result":"0"}]},{"id":"2144747","data":"return","return":[{"id":"0","result":"0"}]},{"id":"235805","data":"return","return":[{"id":"0","result":"0"}]},{"id":"186003","data":"return","return":[{"id":"0","result":"0"}]}]
}

View File

@@ -0,0 +1,95 @@
<?php
/**
* 电子合同小程序用的接口
*/
class openmodhetongClassAction extends openapiAction
{
/**
* 首页返回数据
*/
public function dataAction()
{
$mobile = $this->get('mobile');
$xcytype = $this->get('xcytype');
$openid = $this->get('openid');
$nickName = $this->jm->base64decode($this->get('nickName'));
$htdata = array();
$db = m('wxxcyus');
$uarr['mobile'] = $mobile;
$uarr['xcytype'] = $xcytype;
$uarr['openid'] = $openid;
$uarr['nickName'] = $nickName;
$uarr['province'] = $this->get('province');
$uarr['city'] = $this->get('city');
$uarr['gender'] = $this->get('gender');
$uarr['dingyue'] = $this->get('dingyue');
$uarr['avatarUrl'] = $this->jm->base64decode($this->get('avatarUrl'));
$where = "`openid`='$openid'";
if($db->rows($where)==0){
$uarr['adddt'] = $this->now;
$where='';
}else{
$uarr['optdt'] = $this->now;
}
$db->record($uarr, $where);
$custid = '0'; //客户id
$rows = m('customer')->getall("`mobile`='$mobile' and `status`=1",'id');
foreach($rows as $k=>$rs)$custid.=','.$rs['id'].'';
if($custid!='0'){
$htrows = m('custract')->getall('custid in('.$custid.')','custid,custname,id,startdt,enddt,signdt,type,money,num','id desc');
$dt = $this->rock->date;
foreach($htrows as $k=>$rs){
if($rs['startdt']>$dt){
$statustext='待生效';
$statuscolor='blue';
}else if($rs['startdt']<=$dt && $rs['enddt']>=$dt){
$statustext='生效中';
$statuscolor='green';
}else if($rs['enddt']<$dt){
$statustext='已过期';
$statuscolor='gray';
}
$htdata[] = array(
'id' => $rs['id'],
'name' => $rs['custname'],
'modenum' => 'custract',
'explain' => '金额:'.$rs['money'].',编号:'.$rs['num'].',有效期:'.$rs['startdt'].'→'.$rs['enddt'].'',
'statustext'=>$statustext,
'statuscolor'=>$statuscolor,
);
}
}
return returnsuccess(array(
'htdata' => $htdata,
));
}
/**
* 获取客户数据
*/
public function customerAction()
{
$mobile = $this->get('mobile');
$xcytype = $this->get('xcytype');
$openid = $this->get('openid');
$sql = "select a.id,a.name,a.unitname,b.name as yewuname from [Q]customer a left join [Q]admin b on a.uid=b.id where a.`mobile`='$mobile' and a.`status`=1";
$rows = $this->db->getall($sql);
$custdata = array();
foreach($rows as $k=>$rs){
$custdata[] = array(
'id' => $rs['id'],
'name' => $rs['name'],
'modenum' => 'customer',
'explain' => '业务员:'.$rs['yewuname'].'',
);
}
return returnsuccess(array(
'custdata' => $custdata,
));
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* sso登录
* 访问地址如http://demo.rockoa.com/api.php?m=opensso
*/
class openssoClassAction extends openapiAction
{
public function initAction()
{
$this->display= false;
}
public function indexAction()
{
$ssotoken = $this->get('ssotoken');
$lurl = urldecode($this->get('backurl')); //登录成功跳转地址urlencode
if(isempt($ssotoken))return '没有参数ssotoken';
$checkurl = getconfig('sso_checkurl'); //验证地址
$ssokey = getconfig('sso_key'); //验证key
if(isempt($checkurl))return '没有配置验证地址';
$jg = contain($checkurl,'?')?'&':'?';
$url = $checkurl.$jg.'ssotoken='.$ssotoken.'&ssokey='.$ssokey.'';
$user = c('curl')->getcurl($url); //要返回用户帐号/手机号
if(isempt($user))return '验证失败没有返回值';
//调用登录方法验证
$lobj = m('login');
$rand = md5(''.$this->rock->now.''.$user.'');
$lobj->setloginrand($rand);
$arr = $lobj->start($user, $rand, 'pc','SSO');
if(!is_array($arr)){
return $arr;
}else{
$uid = $arr['uid'];
$name = $arr['name'];
$user = $arr['user'];
$token = $arr['token'];
$lobj->setsession($uid, $name, $token, $user);
if(isempt($lurl)){
$lurl = 'index.php?m=index';
if($this->rock->ismobile())$lurl='index.php?d=we';
}
$this->rock->location($lurl);//跳转
return 'success';
}
}
}

View File

@@ -0,0 +1,73 @@
<?php
/**
* 外部调用单据详情页
*/
class openxiangClassAction extends openapiAction
{
/**
* 详情
*/
public function dataAction()
{
$list['hetong'] = 'custract,customer'; //配置可读取模块
$num = $this->get('num');
$xcytype = $this->get('xcytype');
$mid = (int)$this->get('mid','0');
if(isempt($num) || !$xcytype || $mid==0)return returnerror('num isempt');
$kears = arrvalue($list, $xcytype);
if(!$kears)return returnerror('无效模块1');
if(!in_array($num,explode(',', $kears)))return returnerror('无效模块2');
$flow = m('flow')->initflow($num,$mid, false);
$barr['modename'] = $flow->modename;
$barr['btndata'] = array();
$barr['xiangdata']= array();
if(method_exists($flow,'openxiang')){
$lbarr = $flow->openxiang();
if(is_array($lbarr))foreach($lbarr as $k=>$v)$barr[$k]=$v;
}
return returnsuccess($barr);
}
/**
* 操作菜单
*/
public function optmenuAction()
{
$num = $this->get('num');
$xcytype = $this->get('xcytype');
$mid = (int)$this->get('mid','0');
$menuid = (int)$this->get('menuid','0');
$sm = $this->jm->base64decode($this->get('sm'));
if(isempt($num) || !$xcytype || $mid==0)return returnerror('num isempt');
$flow = m('flow')->initflow($num,$mid, false);
$msg = $flow->optmenu($menuid,1,$sm);
if($msg!='ok')return returnerror($msg);
return returnsuccess($msg);
}
/**
* 下载文件
*/
public function downurlAction()
{
$id = (int)$this->get('id','0');
$openid = $this->get('openid');
if(isempt($openid))return;
if(m('wxxcyus')->rows("`openid`='$openid'")==0)return;
m('file')->show($id, true);
}
/**
* 返回文件详情
*/
public function fileinfoAction()
{
$id = (int)$this->get('id','0');
$openid = $this->get('openid');
if(isempt($openid))return returnerror('无效openid1');
if(m('wxxcyus')->rows("`openid`='$openid'")==0)return returnerror('无效openid');
$frs = m('file')->getone($id,'id,filename,filesize,fileext,filepath,filepathout');
return returnsuccess($frs);
}
}

View File

@@ -0,0 +1,162 @@
<?php
/**
* 对接中控考勤机
* 请求地址如http://127.0.0.1/app/xinhu/api.php?m=openzktime&a=get
*/
class openzktimeClassAction extends openapiAction
{
private $snid = 0;
private $snrs;
private function getsnid()
{
$num = $this->get('sn'); //设备号
$snid = 0;
if(!isempt($num)){
$dbs = m('kqjsn');
$snid = (int)$dbs->getmou('id',"`num`='$num'");
if($snid==0)$snid = $dbs->insert(array(
'num' => $num,
'optdt' => $this->rock->now,
'status' => 1,
'pinpai' => '1'
));
$this->snid = $snid;
$this->snrs = $dbs->getone($snid);
}
return $snid;
}
public function testAction()
{
return 'oknew';
}
/**
* 考勤机定时请求命令
*/
public function getAction()
{
$snid = $this->getsnid();
if($snid==0)return 'notdata';
$data= m('kqjcmd')->getcmd($snid);
if($data){
$batr = array();
foreach($data as $k=>$bar){
if(!isset($bar['data']))$bar['data']='none';
$bar['atype'] = $bar['do'];
unset($bar['do']);
$batr[] = json_encode($bar, JSON_UNESCAPED_UNICODE);
}
$data = join('ROCKZK', $batr);
}
return $data;
}
/**
* 获取人员关系
*/
public function getuserAction()
{
$uarr = $this->db->getall('select a.`id`,a.`name`,b.`finger` from `[Q]admin` a left join `[Q]userinfo` b on a.`id`=b.`id` where a.`status`=1');
$batr = array();
foreach($uarr as $k=>$rs){
$cid = $rs['finger'];
if(isempt($cid))$cid=$rs['id'];
$batr[] = '0,'.$cid.','.$rs['name'].','.$rs['id'].'';
}
return join('ROCKZK', $batr);
}
/**
* 命令状态更新
*/
public function getcAction()
{
$this->getsnid();
$id = (int)$this->get('id','0');
if($id==0)return;
$status = (int)$this->get('status');
$cmds = m('kqjcmd');
$cmds->update(array(
'status'=>$status,
'cjtime'=>$this->rock->now
), $id);
$cmds->returnchuli($id, $this->snid);
}
/**
* 中控考勤机插件推送提交过来数据
*/
public function postAction()
{
$this->getsnid();
$atype = $this->get('atype');
$str = $this->postdata;
if(isempt($str))return 'not data';
$arr = json_decode($str, true);
$fenxiarr = array();
//打卡
if($atype=='daka'){
$db = m('kqdkjl');
$kqcmd = m('kqjcmd');
$kqcmd->getsninfo($this->snid);
$type = 9;
$oi = 0;
$ids = '';
foreach($arr as $k=>$rs){
$barr = $kqcmd->adddkjl($this->snid, $rs, $type, $db, 1);
$oi++;
foreach($barr as $k1=>$v1)$fenxiarr[$k1] = $v1;
$ids .= ','.$rs['id'].'';
}
//考勤分析
if($fenxiarr){
$kqobj = m('kaoqin');
foreach($fenxiarr as $keys=>$uid){
$keysa = explode('|', $keys);
$kqobj->kqanay($uid, $keysa[0]);
}
}
if($ids!='')$ids = substr($ids,1);
return array(
'msg' => 'upload add('.$oi.')record',
'ids' => $ids
);
}
//已存在用户Id
if($atype=='user'){
$uids = $arr['uids'];
m('kqjsn')->update(array(
'userids' => $uids
), $this->snid);
echo '上传用户id成功';
}
//上传设备信息
if($atype=='info'){
m('kqjsn')->update(array(
'usershu' => $arr['usershu'],
'fingerprintshu' => $arr['fingerprintshu'],
'clockinshu' => $arr['clockinshu'],
), $this->snid);
echo '上传设备信息成功';
}
//上传指纹模版
if($atype=='fingerprint'){
$kqjdb = m('kqjcmd');
foreach($arr as $k=>$rs){
$kqjdb->savefingerprint($this->snid, $rs['uid'], array($rs['fingerprint1'],$rs['fingerprint2']));
}
echo '上传指纹模版成功';
}
}
}