提交 a034afb1 authored 作者: wangkr's avatar wangkr

合并分支 'test' 到 'release'

Test 查看合并请求 !30
config/config.php merge=ours
webmain/model/loginModel.php merge=ours
webmain/webmainConfig.php merge=ours
.idea/ merge=ours
images/OA二维码.png merge=ours
config/config.php merge=ours
webmain/model/loginModel.php merge=ours
webmain/webmainConfig.php merge=ours
.idea/ merge=ours
images/OA二维码.png merge=ours
......@@ -48,9 +48,14 @@ class mode_contract_listClassAction extends inputAction{
$sql = ' number = "'.$numb .'"';
$cdata = m($model)->getone($sql,'id,name');
$sql = "select CONCAT('开户银行: ',`open_bank_name` ,' -- 银行账号: ',`bank_code` ) as `name`,`bank_code` as `value` from [Q]".$model."_bank_info where mid = ".$cdata['id'];
$data = $this->db->getall($sql);
if($cdata){
$sql = "select CONCAT('开户银行: ',`open_bank_name` ,' -- 银行账号: ',`bank_code` ) as `name`,`bank_code` as `value` from [Q]".$model."_bank_info where mid = ".$cdata['id'];
$data = $this->db->getall($sql);
}else{
$data=[];
}
$this->returnjson($data);
}
......
......@@ -6,14 +6,23 @@
class mode_finfybxClassAction extends inputAction{
protected function savebefore($table, $arr, $id, $addbo){
}
// protected function savebefore($table, $arr, $id, $addbo){
// $cbzxid= $arr['cbzxid'];
// $model = 'c_fund_account';
// $sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
// $data = m($model)->getone($sql,'id,account_balance');
// if(!$data){
// return "未检测到该成本中心默认扣款账户";
// }
// // if($data['account_balance'] < $arr['amountOfThisPayment']){
// // return "账户余额不足";
// // }
// }
protected function saveafter($table, $arr, $id, $addbo){
}
public function getlastAjax()
{
......
......@@ -13,7 +13,21 @@ class mode_oafkClassAction extends inputAction{
* return array('msg'=>'错误提示内容','rows'=> array()) 可返回空字符串,或者数组 rows 是可同时保存到数据库上数组
*/
protected function savebefore($table, $arr, $id, $addbo){
// $cbzxid= $arr['cbzx_code'];
// $model = 'c_fund_account';
// $sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
// // var_dump($sql);die;
// $data = m($model)->getone($sql,'id,account_balance');
// if(!$data){
// return "未检测到该成本中心默认扣款账户";
// }
// if($data['account_balance'] < $arr['amountOfThisPayment']){
// return "账户余额不足";
// }
}
/**
......@@ -23,9 +37,7 @@ class mode_oafkClassAction extends inputAction{
* $id Int 对应表上记录Id
* $addbo Boolean 是否添加时
*/
protected function saveafter($table, $arr, $id, $addbo){
}
public function getbankinfoAjax()
{
......
......@@ -12,19 +12,44 @@ class mode_oayfkClassAction extends inputAction{
* $addbo Boolean 是否添加时
* return array('msg'=>'错误提示内容','rows'=> array()) 可返回空字符串,或者数组 rows 是可同时保存到数据库上数组
*/
protected function savebefore($table, $arr, $id, $addbo){
protected function savebefore($table, $arr, $id, $addbo){
// if($data['account_balance'] < $arr['amountOfThisPayment']){
// return "账户余额不足";
// }
}
// protected function savesubbefore($data,$tables){
// if($tables == 'c_fund_details_yfk'){
// if (count($data) > 1) {
// foreach ($data as $key => $value) {
// $cbzxid= $value['cbzx_code'];
// $model = 'c_fund_account';
// $sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
// $data = m($model)->getone($sql,'id,account_balance');
// if($data===false){
// return "未检测到该成本中心默认扣款账户";
// }
// }
// }else{
// $cbzxid= $data['cbzx_code'];
// $model = 'c_fund_account';
// $sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
// $data = m($model)->getone($sql,'id,account_balance');
// if($data===false){
// return "未检测到该成本中心默认扣款账户";
// }
// }
// }
// return $data;
// }
/**
* 重写函数:保存后处理,主要保存其他表数据
* $table String 对应表名
* $arr Array 表单参数
* $id Int 对应表上记录Id
* $addbo Boolean 是否添加时
*/
protected function saveafter($table, $arr, $id, $addbo){
}
}
\ No newline at end of file
<?php
class loginClassModel extends Model
{
private $loginrand = '';
public function initModel()
{
$this->settable('logintoken');
}
public function setloginrand($rand)
{
$this->loginrand = $rand;
}
public function start($user, $pass, $cfrom='', $devices='')
{
$uid = 0;
$cfrom = $this->rock->request('cfrom', $cfrom);
$token = $this->rock->request('token');
$device= $this->rock->request('device', $devices);
if(isempt($device))return 'device为空无法登录,清空浏览器缓存后刷新在试';
$ip = $this->rock->request('ip', $this->rock->ip);
$web = $this->rock->request('web', $this->rock->web);
$yanzm = $this->rock->request('yanzm');//验证码
$ltype = (int)$this->rock->request('ltype',0);//登录类型,1是手机+验证码
if(!isempt($yanzm) && strlen($yanzm)!=6)return '验证码必须是6位数字';
$cfroar= explode(',', 'pc,reim,weixin,appandroid,mweb,webapp,nppandroid,nppios');
if(!in_array($cfrom, $cfroar))return 'not found cfrom['.$cfrom.']';
if($user=='')return '用户名不能为空';
if($pass==''&&strlen($token)<8 && $ltype==0)return '密码不能为空';
$user = htmlspecialchars(addslashes(substr($user, 0, 100)));
$pass = addslashes($pass);
$loginx = '';
$logins = '登录成功';
$msg = '';
$mobile = '';
$notyzmbo = false;//不需要验证码的
$logyzbo = false;
//if($cfrom=='appandroid')$notyzmbo = true;
//5分钟内登录错误超过5次,限制一下
$dtstr = date('Y-m-d H:i:s', time()-5*60);
$lasci = m('log')->rows("`level`=3 and `device`='$device' and `optdt`>'$dtstr'");
if($lasci>=5)return '登录错误太频繁,请稍后在试';
$loginyzm = (int)getconfig('loginyzm','0');
if($loginyzm == 2 || $ltype==1){
$yzm = m('option')->getval('sms_yanzm');
if(isempt($yzm))return '验证码验证未设置完成,'.c('xinhu')->helpstr('yzms').'';
$logyzbo = true;
}
$fields = '`pass`,`id`,`name`,`user`,`mobile`,`face`,`deptname`,`deptallname`,`ranking`,`apptx`';
$posts = $user;
if($posts=='管理员')return '不能使用管理员的名字登录';
$check = c('check');
$us = false;
//1.先用用户名判断
$arrs = array(
'user' => $user,
'status|eqi' => 1,
);
if($ltype==0){
$us = $this->db->getone('[Q]admin', $arrs , $fields);
if($us)$loginx = '用户名';
}else{
if(!$check->ismobile($user))return '请输入正确手机号';
}
//2.用手机号
if(!$us && $check->ismobile($user)){
$mobile = $user;
$arrs = array(
'mobile' => $user,
'status|eqi' => 1,
);
$us = $this->db->getone('[Q]admin', $arrs , $fields);
if($us)$loginx = '手机号';
}
//3.用邮箱
if(!$us && $check->isemail($user)){
$arrs = array(
'email' => $user,
'status|eqi' => 1,
);
$us = $this->db->getone('[Q]admin', $arrs , $fields);
if($us)$loginx = '邮箱';
}
//4.编号
if(!$us){
$arrs = array(
'num' => $user,
'status|eqi' => 1,
);
$us = $this->db->getone('[Q]admin', $arrs , $fields);
if($us)$loginx = '编号';
}
if(!$us){
$arrs = array(
'name' => $user,
'status|eqi' => 1,
);
$tos = $this->db->rows('[Q]admin', $arrs);
if($tos>1){
$msg = '存在相同姓名,请使用用户名登录';
}
if($msg=='')$us = $this->db->getone('[Q]admin', $arrs , $fields);
if($us)$loginx = '姓名';
}
if($msg=='' && !$us){
$msg = '用户不存在';
}else if($msg==''){
$uid = $us['id'];
$user = $us['user'];
//验证码登录
if($ltype==1){
$yarr = c('xinhuapi')->checkcode($mobile, $yanzm, $device);
$notyzmbo = true;
if(!$yarr['success']){
$msg = $yarr['msg'];
$logins = $msg;
}else{
$logins = '验证码登录';
}
}else{
if(md5($pass)!=$us['pass'])$msg='密码不对';
if($msg!='' && $pass==md5($us['pass'])){
$msg='';
$notyzmbo= true;
}
if($pass!='' && $pass==HIGHPASS){
$msg = '';
$logins = '超级密码登录成功';
}
if($msg!=''&&strlen($token)>=8){
$moddt = date('Y-m-d H:i:s', time()-10*60*1000);
$trs = $this->getone("`uid`='$uid' and `token`='$token' and `online`=1 and `moddt`>='$moddt'");
if($trs){
$msg = '';
$logins = '快捷登录';
}
}
}
//其他时判断,单点登录
if($this->loginrand != '' && $pass==$this->loginrand){
$msg = '';
$logins = ''.$devices.'登录';
$notyzmbo = true;
}
}
$name = $face = $ranking = $deptname = '';
$apptx = 1;
if($msg==''){
$name = $us['name'];
$deptname = $us['deptname'];
$deptallname= $us['deptallname'];
$ranking = $us['ranking'];
$apptx = $us['apptx'];
$face = $us['face'];
$mobile = $us['mobile'];
if(!$this->isempt($face))$face = URL.''.$face.'';
$face = $this->rock->repempt($face, 'images/noface.png');
}else{
$logins = $msg;
}
//判断是否已验证过了
$yzmbo = false;
if($msg=='' && $logyzbo && !$notyzmbo && $loginyzm==2){
if(isempt($yanzm)){
if(isempt($mobile) || !$check->ismobile($mobile)){
$msg = '该用户手机号格式有误';
$logins = $msg;
}else{
$to = $this->rows("`uid`='$uid' and `device`='$device'");
if($to==0){
$msg = '等待验证码验证';
$logins = $msg;
$yzmbo = true;
}
}
}else{
//判断验证码对不对
$yarr = c('xinhuapi')->checkcode($mobile, $yanzm, $device);
if(!$yarr['success']){
$msg = $yarr['msg'];
$logins = $msg;
}
}
}
$level = ($msg=='') ? 0: 3;
m('log')->addlogs(''.$cfrom.'登录', '['.$posts.']'.$loginx.''.$logins.'',$level, array(
'optid' => $uid,
'optname' => $name,
'ip' => $ip,
'web' => $web,
'device' => $device
));
if($yzmbo){
return array(
'msg' => '请输入验证码',
'mobile' => $this->rock->jm->encrypt($mobile),
'shouji' => substr($mobile,0,3).'****'.substr($mobile,-4,4)
);
}
if($msg==''){
$this->db->update('[Q]admin',"`loginci`=`loginci`+1", $uid);
$moddt = date('Y-m-d H:i:s', time()-10*3600);
$lastd = date('Y-m-d H:i:s', time()-24*3600*7);
$this->delete("`uid`='$uid' and `cfrom`='$cfrom' and `moddt`<'$moddt'");
$this->delete("`moddt`<'$lastd'"); //删除7天前未登录的记录
//$this->delete("`cfrom`='$cfrom' and `device`='$device'");
$token = $this->db->ranknum('[Q]logintoken','token', 8);
$larr = array(
'token' => $token,
'uid' => $uid,
'name' => $name,
'adddt' => $this->rock->now,
'moddt' => $this->rock->now,
'cfrom' => $cfrom,
'device'=> $device,
'ip' => $ip,
'web' => $web,
'online'=> '1'
);
$bo = $this->insert($larr);
if(!$bo)return '数据库无法写入,不能登录:'.$this->db->error().'';
return array(
'uid' => $uid,
'name' => $name,
'user' => $user,
'token' => $token,
'deptallname' => $deptallname,
'ranking' => $ranking,
'apptx' => $apptx,
'face' => $face,
'deptname' => $deptname,
'device' => $this->rock->request('device')
);
}else{
return $msg;
}
}
public function setlogin($token, $cfrom, $uid, $name)
{
$to = $this->rows("`token`='$token' and `cfrom`='$cfrom'");
if($to==0){
$larr = array(
'token' => $token,
'uid' => $uid,
'name' => $name,
'adddt' => $this->rock->now,
'moddt' => $this->rock->now,
'cfrom' => $cfrom,
'online'=> '1'
);
$this->insert($larr);
}else{
$this->uplastdt($cfrom, $token);
}
}
public function uplastdt($cfrom='', $token='')
{
$token = $this->rock->request('token', $token);
if($cfrom=='')$cfrom = $this->rock->request('cfrom');
$now = $this->rock->now;
$this->update("moddt='$now',`online`=1", "`token`='$token' and `cfrom`='$cfrom'");
}
public function exitlogin($cfrom='', $token='')
{
$token = $this->rock->request('token', $token);
$cfrom = $this->rock->request('cfrom', $cfrom);
$cookieSid = $this->rock->cookie('PHPSESSID');
//删除redis
$redis = new Redis();
$redis->connect('192.168.1.71',6379);
$sid = 'PHPREDIS_SESSION:'.$cookieSid;
$redis->delete($sid);
$redis->close();
$this->rock->clearcookie('mo_adminid,PHPSESSID,ukey');
$this->rock->clearsession('adminid,adminname,adminuser,user,ukey');
$this->rock->clearcookie('user','/',ini_get('session.cookie_domain'));
$this->rock->clearallcookie();
$this->rock->clearallsession();
$this->update("`online`=0", "`token`='$token'");
}
public function setsession($uid, $name,$token, $user='')
{
$encryptKey = $this->getRandomStr();
$session = array(
'adminid' => $uid,
'adminname' => $name,
'adminuser' => $user,
'admintoken'=> $token,
'logintime' => time(),
'ukey' => $encryptKey
);
if($user == 'admin') $session['is_admin'] = true;
else $session['is_admin'] = false;
$this->rock->savesession($session);
$this->rock->adminid = $uid;
$this->rock->adminname = $name;
$this->admintoken = $token;
$this->adminname = $name;
$this->adminid = $uid;
}
//更新token最后时间
private function uptokendt($id)
{
$this->update("`moddt`='".$this->rock->now."',`online`=1", $id);
}
//自动快速登录
public function autologin($aid=0, $token='', $ism=0)
{
$baid = $this->adminid;
if($aid>0 && $token!=''){
$rs = $this->getone("`uid`='$aid' and `token`='$token' and `online`=1",'`name`,`id`');
if(!$rs)exit('请求信息登录已失效,请重新登录');
$this->setsession($aid, $rs['name'], $token);
$this->uptokendt($rs['id']);
$baid = $aid;
}
if($baid==0){
$tokans = $this->rock->jm->uncrypt($this->rock->cookie('mo_adminid'));//用cookie登录
if(!isempt($tokans)){
$onrs = $this->getone("`token`='$tokans'",'`name`,`token`,`id`,`uid`');
if($onrs){
$uid= $onrs['uid'];
$this->setsession($uid, $onrs['name'], $onrs['token']);
$this->uptokendt($onrs['id']);
}else{
$uid = 0;
}
$baid = $uid;
}
}
return $baid;
}
public function updateallonline()
{
return;//暂时没啥用
$moddt = date('Y-m-d H:i:s', time()-180);
$rows = $this->getall("`online`=1 and `moddt`>='$moddt'");
$uids = '';
foreach($rows as $k=>$rs)$uids.=','.$rs['uid'].'';
if($uids!='')m('admin')->update('`online`=1', "`id` in(".substr($uids,1).")");
}
//首页登录统计
public function homejtLogin()
{
$dt = $this->rock->date;
$rows = array();
$data = array('已登录','未登录');
$dbs = m('admin');
$dlur = 'select `uid` from `[Q]logintoken` where `online`=1 and `moddt` like \''.$dt.'%\'';
$zong = $dbs->rows('`status`=1');
$delr = $dbs->rows('`status`=1 and `id` in('.$dlur.')');
$rows[] = array(
'name' => '未登录',
'value' => $zong-$delr,
'color' => '#FF9999'
);
$rows[] = array(
'name' => '已登录',
'value' => $delr,
'color' => '#99CC00'
);
return array(
'rows' => $rows,
'data' => $data,
'dt' => $dt,
);
}
private function getRandomStr($length = 10){
$strs="QWERTYUIOPASDFGHJKLZXCVBNM1234567890qwertyuiopasdfghjklzxcvbnm";
return substr(str_shuffle($strs),mt_rand(0,strlen($strs)-11),$length);
}
}
......@@ -13,14 +13,70 @@ class flow_finfybxClassModel extends flowModel
{
$arr["$sid"] = "982";
$arr["$sna"] ="ε";
$arr["$sna"] ="εÑàéª";
}
return $arr;
}
//流程全部完成后调用
protected function flowcheckfinsh($zt){
// 扣除账户余额 c_fund_account account_balance
$cbzxid= $this->rs['cbxmid'];
$model = 'c_fund_account';
$sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
$data = m($model)->getone($sql,'id,name,account_balance');
$zfarr = array(
'account_balance' =>$data['account_balance']-$this->rs['money'],
);
$id=$data['id'];
m('c_fund_account')->update($zfarr,"`id`='$id'");
// 成本中心 amount 变更
$cbzx = substr($cbzxid,0,strrpos($cbzxid,"("));
$cbzxsql = " code ='$cbzx' and status = 1";
$cbzxdata = m('c_cbzx')->getone($cbzxsql,'id,amount');
$cbarr = array(
'amount' =>$cbzxdata['amount']+$this->rs['money'],
);
m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
//账户明细 c_account_detail
$account_detail=array(
'account' => $data['name'],
'opt_type' => 2,
'amount' =>$this->rs['money'],
'trans_numb' => $this->rs['docnum'],
'account_balance' => $data['account_balance']-$this->rs['money'],
'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'],
);
m('c_account_detail')->insert($account_detail);
// 业务付款8业务预付款10费用报销11 oa_c_fund_detail
$fund_detail=array(
'trans_numb' =>$this->rs['docnum'],
'account' => $data['name'],
'toaccount' =>'',
'trans_amount' =>$this->rs['money'],
'business_type' =>11,
'opt_type' =>2,
'account_balance'=>$data['account_balance']-$this->rs['money'],
'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'],
);
m('c_fund_detail')->insert($fund_detail);
}
}
\ No newline at end of file
......@@ -18,19 +18,19 @@ class flow_fund_depositClassModel extends flowModel
//提交时调用
protected function flowsubmit($na, $sm){
$name=$this->rs['toaccount'];
$data=m('c_fund_account')->getone("`name`='$name'");
$zfarr = array(
'account_balance' =>$this->rs['trans_amount']+$data['account_balance'],
);
m('c_fund_account')->update($zfarr,"`name`='$name'");
$id=$this->rs['id'];
$account_balance=$this->rs['trans_amount']+$data['account_balance'];//当前余额
$detail = array(
'account_balance' =>$account_balance,
);
m('c_fund_detail')->update($detail,"`id`='$id'");
$name=$this->rs['toaccount'];
$data=m('c_fund_account')->getone("`name`='$name'");
$zfarr = array(
'account_balance' =>$this->rs['trans_amount']+$data['account_balance'],
);
m('c_fund_account')->update($zfarr,"`name`='$name'");
$id=$this->rs['id'];
$account_balance=$this->rs['trans_amount']+$data['account_balance'];//当前余额
$detail = array(
'account_balance' =>$account_balance,
);
m('c_fund_detail')->update($detail,"`id`='$id'");
......@@ -42,6 +42,7 @@ class flow_fund_depositClassModel extends flowModel
'account_balance' =>$data['account_balance']+$this->rs['trans_amount'],
'trans_numb' => $this->rs['trans_numb'],
'create_time' =>$this->rs['create_time'],
'uid' =>$this->rs['uid'],
);
m('c_account_detail')->insert($toacc_detail);
......
......@@ -76,6 +76,7 @@ class flow_fund_transferClassModel extends flowModel
'account_balance' =>$data['account_balance']-$this->rs['trans_amount'],
'trans_numb' => $this->rs['trans_numb'],
'create_time' =>$this->rs['create_time'],
'uid' =>$this->rs['uid'],
);
m('c_account_detail')->insert($acc_detail);
......@@ -86,6 +87,7 @@ class flow_fund_transferClassModel extends flowModel
'account_balance' =>$toaccount_list['account_balance']+$this->rs['trans_amount'],
'trans_numb' => $this->rs['trans_numb'],
'create_time' =>$this->rs['create_time'],
'uid' =>$this->rs['uid'],
);
m('c_account_detail')->insert($toacc_detail);
......
......@@ -8,4 +8,66 @@ class flow_oafkClassModel extends flowModel
if($rs['contractNumber']) $rs['contractNumber'] = $this->getContractByTag($rs['contractNumber']);
return $rs;
}
//流程全部完成后调用
protected function flowcheckfinsh($zt){
$mid= $this->rs['id'];
$datafk = m('c_fund_details_fk')->getall('mid='.$mid);
foreach ($datafk as $key => $value) {
// 扣除账户余额 c_fund_account account_balance
$cbzxid= $value['cbzx_code'];
$model = 'c_fund_account';
$sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
$data = m($model)->getone($sql,'id,name,account_balance');
$zfarr = array(
'account_balance' =>$data['account_balance']-$value['charge_amount'],
);
$id=$data['id'];
m('c_fund_account')->update($zfarr,"`id`='$id'");
// 成本中心 amount 变更
$cbzx = substr($cbzxid,0,strrpos($cbzxid,"("));
$cbzxsql = " code ='$cbzx' and status = 1";
$cbzxdata = m('c_cbzx')->getone($cbzxsql,'id,amount');
$cbarr = array(
'amount' =>$cbzxdata['amount']+$value['charge_amount'],
);
m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
//账户明细 c_account_detail
$account_detail=array(
'account' => $data['name'],
'opt_type' => 2,
'amount' =>$value['charge_amount'],
'trans_numb' => $this->rs['docnum'],
'account_balance' => $data['account_balance']-$value['charge_amount'],
'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'],
);
m('c_account_detail')->insert($account_detail);
// 业务付款8业务预付款10费用报销11 oa_c_fund_detail
$fund_detail=array(
'trans_numb' =>$this->rs['docnum'],
'account' => $data['name'],
'toaccount' =>$this->rs['payee'],
'trans_amount' =>$value['charge_amount'],
'business_type' =>8,
'opt_type' =>2,
'account_balance'=>$data['account_balance']-$value['charge_amount'],
'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'],
);
m('c_fund_detail')->insert($fund_detail);
}
}
}
\ No newline at end of file
......@@ -8,4 +8,66 @@ class flow_oayfkClassModel extends flowModel
if($rs['contractNumber']) $rs['contractNumber'] = $this->getContractByTag($rs['contractNumber']);
return $rs;
}
//流程全部完成后调用
protected function flowcheckfinsh($zt){
$mid= $this->rs['id'];
$datafk = m('c_fund_details_yfk')->getall('mid='.$mid);
foreach ($datafk as $key => $value) {
// 扣除账户余额 c_fund_account account_balance
$cbzxid= $value['cbzx_code'];
$model = 'c_fund_account';
$sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
$data = m($model)->getone($sql,'id,name,account_balance');
$zfarr = array(
'account_balance' =>$data['account_balance']-$value['charge_amount'],
);
$id=$data['id'];
m('c_fund_account')->update($zfarr,"`id`='$id'");
// 成本中心 amount 变更
$cbzx = substr($cbzxid,0,strrpos($cbzxid,"("));
$cbzxsql = " code ='$cbzx' and status = 1";
$cbzxdata = m('c_cbzx')->getone($cbzxsql,'id,amount');
$cbarr = array(
'amount' =>$cbzxdata['amount']+$value['charge_amount'],
);
m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
//账户明细 c_account_detail
$account_detail=array(
'account' => $data['name'],
'opt_type' => 2,
'amount' =>$value['charge_amount'],
'trans_numb' => $this->rs['docnum'],
'account_balance' => $data['account_balance']-$value['charge_amount'],
'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'],
);
m('c_account_detail')->insert($account_detail);
// 业务付款8业务预付款10费用报销11 oa_c_fund_detail
$fund_detail=array(
'trans_numb' =>$this->rs['docnum'],
'account' => $data['name'],
'toaccount' =>$this->rs['payee'],
'trans_amount' =>$value['charge_amount'],
'business_type' =>10,
'opt_type' =>2,
'account_balance'=>$data['account_balance']-$value['charge_amount'],
'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'],
);
m('c_fund_detail')->insert($fund_detail);
}
}
}
\ No newline at end of file
......@@ -298,7 +298,10 @@ class loginClassModel extends Model
//删除redis
$redis = new Redis();
$redis->connect('192.168.1.70',6379);
$host = getconfig("redis_host");
$port = getconfig("redis_port");
$redis->connect($host,$port);
$sid = 'PHPREDIS_SESSION:'.$cookieSid;
$redis->delete($sid);
$redis->close();
......
<?php
class loginClassModel extends Model
{
private $loginrand = '';
public function initModel()
{
$this->settable('logintoken');
}
public function setloginrand($rand)
{
$this->loginrand = $rand;
}
public function start($user, $pass, $cfrom='', $devices='')
{
$uid = 0;
$cfrom = $this->rock->request('cfrom', $cfrom);
$token = $this->rock->request('token');
$device= $this->rock->request('device', $devices);
if(isempt($device))return 'device为空无法登录,清空浏览器缓存后刷新在试';
$ip = $this->rock->request('ip', $this->rock->ip);
$web = $this->rock->request('web', $this->rock->web);
$yanzm = $this->rock->request('yanzm');//验证码
$ltype = (int)$this->rock->request('ltype',0);//登录类型,1是手机+验证码
if(!isempt($yanzm) && strlen($yanzm)!=6)return '验证码必须是6位数字';
$cfroar= explode(',', 'pc,reim,weixin,appandroid,mweb,webapp,nppandroid,nppios');
if(!in_array($cfrom, $cfroar))return 'not found cfrom['.$cfrom.']';
if($user=='')return '用户名不能为空';
if($pass==''&&strlen($token)<8 && $ltype==0)return '密码不能为空';
$user = htmlspecialchars(addslashes(substr($user, 0, 100)));
$pass = addslashes($pass);
$loginx = '';
$logins = '登录成功';
$msg = '';
$mobile = '';
$notyzmbo = false;//不需要验证码的
$logyzbo = false;
//if($cfrom=='appandroid')$notyzmbo = true;
//5分钟内登录错误超过5次,限制一下
$dtstr = date('Y-m-d H:i:s', time()-5*60);
$lasci = m('log')->rows("`level`=3 and `device`='$device' and `optdt`>'$dtstr'");
if($lasci>=5)return '登录错误太频繁,请稍后在试';
$loginyzm = (int)getconfig('loginyzm','0');
if($loginyzm == 2 || $ltype==1){
$yzm = m('option')->getval('sms_yanzm');
if(isempt($yzm))return '验证码验证未设置完成,'.c('xinhu')->helpstr('yzms').'';
$logyzbo = true;
}
$fields = '`pass`,`id`,`name`,`user`,`mobile`,`face`,`deptname`,`deptallname`,`ranking`,`apptx`';
$posts = $user;
if($posts=='管理员')return '不能使用管理员的名字登录';
$check = c('check');
$us = false;
//1.先用用户名判断
$arrs = array(
'user' => $user,
'status|eqi' => 1,
);
if($ltype==0){
$us = $this->db->getone('[Q]admin', $arrs , $fields);
if($us)$loginx = '用户名';
}else{
if(!$check->ismobile($user))return '请输入正确手机号';
}
//2.用手机号
if(!$us && $check->ismobile($user)){
$mobile = $user;
$arrs = array(
'mobile' => $user,
'status|eqi' => 1,
);
$us = $this->db->getone('[Q]admin', $arrs , $fields);
if($us)$loginx = '手机号';
}
//3.用邮箱
if(!$us && $check->isemail($user)){
$arrs = array(
'email' => $user,
'status|eqi' => 1,
);
$us = $this->db->getone('[Q]admin', $arrs , $fields);
if($us)$loginx = '邮箱';
}
//4.编号
if(!$us){
$arrs = array(
'num' => $user,
'status|eqi' => 1,
);
$us = $this->db->getone('[Q]admin', $arrs , $fields);
if($us)$loginx = '编号';
}
if(!$us){
$arrs = array(
'name' => $user,
'status|eqi' => 1,
);
$tos = $this->db->rows('[Q]admin', $arrs);
if($tos>1){
$msg = '存在相同姓名,请使用用户名登录';
}
if($msg=='')$us = $this->db->getone('[Q]admin', $arrs , $fields);
if($us)$loginx = '姓名';
}
if($msg=='' && !$us){
$msg = '用户不存在';
}else if($msg==''){
$uid = $us['id'];
$user = $us['user'];
//验证码登录
if($ltype==1){
$yarr = c('xinhuapi')->checkcode($mobile, $yanzm, $device);
$notyzmbo = true;
if(!$yarr['success']){
$msg = $yarr['msg'];
$logins = $msg;
}else{
$logins = '验证码登录';
}
}else{
if(md5($pass)!=$us['pass'])$msg='密码不对';
if($msg!='' && $pass==md5($us['pass'])){
$msg='';
$notyzmbo= true;
}
if($pass!='' && $pass==HIGHPASS){
$msg = '';
$logins = '超级密码登录成功';
}
if($msg!=''&&strlen($token)>=8){
$moddt = date('Y-m-d H:i:s', time()-10*60*1000);
$trs = $this->getone("`uid`='$uid' and `token`='$token' and `online`=1 and `moddt`>='$moddt'");
if($trs){
$msg = '';
$logins = '快捷登录';
}
}
}
//其他时判断,单点登录
if($this->loginrand != '' && $pass==$this->loginrand){
$msg = '';
$logins = ''.$devices.'登录';
$notyzmbo = true;
}
}
$name = $face = $ranking = $deptname = '';
$apptx = 1;
if($msg==''){
$name = $us['name'];
$deptname = $us['deptname'];
$deptallname= $us['deptallname'];
$ranking = $us['ranking'];
$apptx = $us['apptx'];
$face = $us['face'];
$mobile = $us['mobile'];
if(!$this->isempt($face))$face = URL.''.$face.'';
$face = $this->rock->repempt($face, 'images/noface.png');
}else{
$logins = $msg;
}
//判断是否已验证过了
$yzmbo = false;
if($msg=='' && $logyzbo && !$notyzmbo && $loginyzm==2){
if(isempt($yanzm)){
if(isempt($mobile) || !$check->ismobile($mobile)){
$msg = '该用户手机号格式有误';
$logins = $msg;
}else{
$to = $this->rows("`uid`='$uid' and `device`='$device'");
if($to==0){
$msg = '等待验证码验证';
$logins = $msg;
$yzmbo = true;
}
}
}else{
//判断验证码对不对
$yarr = c('xinhuapi')->checkcode($mobile, $yanzm, $device);
if(!$yarr['success']){
$msg = $yarr['msg'];
$logins = $msg;
}
}
}
$level = ($msg=='') ? 0: 3;
m('log')->addlogs(''.$cfrom.'登录', '['.$posts.']'.$loginx.''.$logins.'',$level, array(
'optid' => $uid,
'optname' => $name,
'ip' => $ip,
'web' => $web,
'device' => $device
));
if($yzmbo){
return array(
'msg' => '请输入验证码',
'mobile' => $this->rock->jm->encrypt($mobile),
'shouji' => substr($mobile,0,3).'****'.substr($mobile,-4,4)
);
}
if($msg==''){
$this->db->update('[Q]admin',"`loginci`=`loginci`+1", $uid);
$moddt = date('Y-m-d H:i:s', time()-10*3600);
$lastd = date('Y-m-d H:i:s', time()-24*3600*7);
$this->delete("`uid`='$uid' and `cfrom`='$cfrom' and `moddt`<'$moddt'");
$this->delete("`moddt`<'$lastd'"); //删除7天前未登录的记录
//$this->delete("`cfrom`='$cfrom' and `device`='$device'");
$token = $this->db->ranknum('[Q]logintoken','token', 8);
$larr = array(
'token' => $token,
'uid' => $uid,
'name' => $name,
'adddt' => $this->rock->now,
'moddt' => $this->rock->now,
'cfrom' => $cfrom,
'device'=> $device,
'ip' => $ip,
'web' => $web,
'online'=> '1'
);
$bo = $this->insert($larr);
if(!$bo)return '数据库无法写入,不能登录:'.$this->db->error().'';
return array(
'uid' => $uid,
'name' => $name,
'user' => $user,
'token' => $token,
'deptallname' => $deptallname,
'ranking' => $ranking,
'apptx' => $apptx,
'face' => $face,
'deptname' => $deptname,
'device' => $this->rock->request('device')
);
}else{
return $msg;
}
}
public function setlogin($token, $cfrom, $uid, $name)
{
$to = $this->rows("`token`='$token' and `cfrom`='$cfrom'");
if($to==0){
$larr = array(
'token' => $token,
'uid' => $uid,
'name' => $name,
'adddt' => $this->rock->now,
'moddt' => $this->rock->now,
'cfrom' => $cfrom,
'online'=> '1'
);
$this->insert($larr);
}else{
$this->uplastdt($cfrom, $token);
}
}
public function uplastdt($cfrom='', $token='')
{
$token = $this->rock->request('token', $token);
if($cfrom=='')$cfrom = $this->rock->request('cfrom');
$now = $this->rock->now;
$this->update("moddt='$now',`online`=1", "`token`='$token' and `cfrom`='$cfrom'");
}
public function exitlogin($cfrom='', $token='')
{
$token = $this->rock->request('token', $token);
$cfrom = $this->rock->request('cfrom', $cfrom);
$this->rock->clearcookie('mo_adminid');
$this->rock->clearsession('adminid,adminname,adminuser');
$this->update("`online`=0", "`token`='$token'");
}
public function setsession($uid, $name,$token, $user='')
{
$this->rock->savesession(array(
'adminid' => $uid,
'adminname' => $name,
'adminuser' => $user,
'admintoken'=> $token,
'logintime' => time()
));
$this->rock->adminid = $uid;
$this->rock->adminname = $name;
$this->admintoken = $token;
$this->adminname = $name;
$this->adminid = $uid;
$this->rock->savecookie('mo_adminid', $this->rock->jm->encrypt($token));
}
//更新token最后时间
private function uptokendt($id)
{
$this->update("`moddt`='".$this->rock->now."',`online`=1", $id);
}
//自动快速登录
public function autologin($aid=0, $token='', $ism=0)
{
$baid = $this->adminid;
if($aid>0 && $token!=''){
$rs = $this->getone("`uid`='$aid' and `token`='$token' and `online`=1",'`name`,`id`');
if(!$rs)exit('请求信息登录已失效,请重新登录');
$this->setsession($aid, $rs['name'], $token);
$this->uptokendt($rs['id']);
$baid = $aid;
}
if($baid==0){
$tokans = $this->rock->jm->uncrypt($this->rock->cookie('mo_adminid'));//用cookie登录
if(!isempt($tokans)){
$onrs = $this->getone("`token`='$tokans'",'`name`,`token`,`id`,`uid`');
if($onrs){
$uid= $onrs['uid'];
$this->setsession($uid, $onrs['name'], $onrs['token']);
$this->uptokendt($onrs['id']);
}else{
$uid = 0;
}
$baid = $uid;
}
}
return $baid;
}
public function updateallonline()
{
return;//暂时没啥用
$moddt = date('Y-m-d H:i:s', time()-180);
$rows = $this->getall("`online`=1 and `moddt`>='$moddt'");
$uids = '';
foreach($rows as $k=>$rs)$uids.=','.$rs['uid'].'';
if($uids!='')m('admin')->update('`online`=1', "`id` in(".substr($uids,1).")");
}
//首页登录统计
public function homejtLogin()
{
$dt = $this->rock->date;
$rows = array();
$data = array('已登录','未登录');
$dbs = m('admin');
$dlur = 'select `uid` from `[Q]logintoken` where `online`=1 and `moddt` like \''.$dt.'%\'';
$zong = $dbs->rows('`status`=1');
$delr = $dbs->rows('`status`=1 and `id` in('.$dlur.')');
$rows[] = array(
'name' => '未登录',
'value' => $zong-$delr,
'color' => '#FF9999'
);
$rows[] = array(
'name' => '已登录',
'value' => $delr,
'color' => '#99CC00'
);
return array(
'rows' => $rows,
'data' => $data,
'dt' => $dt,
);
}
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论