提交 84979d8d authored 作者: chengye's avatar chengye

Merge branch 'test' of ssh://39.155.253.71:33222/PHP/OA into test

...@@ -32,7 +32,6 @@ class flow_emfkClassModel extends flowModel ...@@ -32,7 +32,6 @@ class flow_emfkClassModel extends flowModel
$this->sendMess(0,9); $this->sendMess(0,9);
} }
} }
/** /**
* @param int $messType 动作 * @param int $messType 动作
* @param int $status 状态 * @param int $status 状态
...@@ -52,4 +51,188 @@ class flow_emfkClassModel extends flowModel ...@@ -52,4 +51,188 @@ class flow_emfkClassModel extends flowModel
m('log')->addlog('电费付款','接口返回信息:' .$res); m('log')->addlog('电费付款','接口返回信息:' .$res);
} }
} static function dept($data)
\ No newline at end of file {
$sql=" id= '$data'";
$cbzxid = m('tmp_department')->getone($sql, 'id,cost');//查询账户表成本中心id
return $data;
}
static function project($project_code){
$url = getconfig('base_url'). 'v2/project/list?key=';
$key = substr(md5(getconfig('openkey').date('Y-m-d')),0,12);
$url = $url.$key;
$url .= '&project_code='.$project_code;
$res = json_decode(curlGet($url),true);
return $res;
}
//二级 或一级审批同意之后进行预扣款
protected function flowcheckbefore($zt, $sm){
$id=$this->rs['id'];
$sql = " mid ='$id' and `table`='c_emfk' ";
$flow_bill = m('flow_bill')->getone($sql,'allcheckid');
$allcheckid=explode(',',$flow_bill['allcheckid']);
$option = m('option')->getall('pid = 1497 and num =1 order by sort desc','num,name,value,sort');
foreach ($option as $key => $value) {
if(in_array($value['value'], $allcheckid)){
$checkid= $value['value'];
break;
}
}
if(empty($checkid)){
$option = m('option')->getall('pid = 1497 and num =2 order by sort desc','num,name,value,sort,`explain`');
foreach ($option as $key => $value) {
if(in_array($value['value'], $allcheckid)){
$checkid= $value['value'];
break;
}
}
}
//zt 1代表同意
if($zt==1){
$flowid=$this->getflow();
if($flowid['nowcheckid']==$checkid){
$data = m('c_emfk_details')->getall('mid='.$this->rs['id'], 'id,cbzxid,amount');
foreach ($data as $key => $vo) {
$project=self::project($vo['cbzxid']);
$cbzx_code= self::dept($project['data'][0]['jz_cur_dept']);
echo "<pre>";
$sql = " cost_id='$cbzx_code' and status = 1 and is_default=1";
$cost = m('c_fund_account')->getone($sql, 'id,type,freeze_amount,account_balance');//查询账户表成本中心id
if($cost['type']=='1'){
if(($cost['account_balance']-$cost['freeze_amount'])<$vo['amount']){
return "账户余额不足";die;
}
}
$id=$cost['id'];
$c_withhold = array(
'fund_account_id' => $id,
'docnum' => $this->rs['docnum'],
'cost_id' => $vo['cbzxid'],
'amount' => $vo['amount'],
'status' => 1,
'create_time' => date("Y-m-d H:i:s"),
'uid' => $this->rs['uid'],
);
m('c_withhold_emfk')->insert($c_withhold);
//修改冻结余额
$freeze = array(
'freeze_amount' => $cost['freeze_amount'] + $vo['amount'],
);
m('c_fund_account')->update($freeze, "`id`='$id'");
}
}
}else{
$docnum=$this->rs['docnum'];
//将单据状态作废余额
$withhold_cost = m('c_withhold_emfk')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount');
foreach ($withhold_cost as $key => $vo) {
//减去冻结金额
$cost_id=$vo['cost_id'];
$sql = " cost_id='$cost_id' and status = 1 and is_default=1";
$fund_account_cost = m('c_fund_account')->getone($sql, 'id,freeze_amount');
$id=$fund_account_cost['id'];
$freeze = array(
'freeze_amount' => $fund_account_cost['freeze_amount'] - $vo['amount'],
);
m('c_fund_account')->update($freeze, "`id`='$id'");
}
$status = array(
'status' => 0,
);
m('c_withhold_emfk')->update($status, "docnum='$docnum'");
}
}
//流程全部完成后调用
// protected function flowcheckfinsh($zt){
//
// $docnum=$this->rs['docnum'];
// $withhold_cost = m('c_withhold_emfk')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount');
//
// foreach ($withhold_cost as $key => $vo) {
// // 扣除账户余额 c_fund_account account_balance
//
// $cbzxid= $vo['cost_id'];
// $model = 'c_fund_account';
// $sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
// $data = m($model)->getone($sql,'id,name,account_balance,freeze_amount');
//
// $zfarr = array(
// 'account_balance' =>$data['account_balance']-$vo['amount'],
// );
// $id=$data['id'];
// m('c_fund_account')->update($zfarr,"`id`='$id'");
//
// $freeze = array(
// 'freeze_amount' => $data['freeze_amount'] - $vo['amount'],
// );
//
// m('c_fund_account')->update($freeze, "`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']+$vo['amount'],
// );
// m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
// //账户明细 c_account_detail
// $account_detail=array(
// 'account' => $data['name'],
// 'opt_type' => 2,
// 'amount' =>$vo['amount'],
// 'trans_numb' => $this->rs['docnum'],
// 'account_balance' => $data['account_balance']-$vo['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['applicant'],
// 'trans_amount' =>$vo['amount'],
// 'business_type' =>12,
// 'opt_type' =>2,
// 'account_balance'=>$data['account_balance']-$vo['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
...@@ -12,11 +12,8 @@ class flow_finfybxClassModel extends flowModel ...@@ -12,11 +12,8 @@ class flow_finfybxClassModel extends flowModel
return $arr; return $arr;
} }
//提交时调用
protected function flowsubmit($na, $sm){
//二级 或一级审批同意之后进行预扣款
protected function flowcheckbefore($zt, $sm){
if($this->rs['dikouid']){ if($this->rs['dikouid']){
$dikouid = $this->rs['dikouid']; $dikouid = $this->rs['dikouid'];
...@@ -38,57 +35,61 @@ class flow_finfybxClassModel extends flowModel ...@@ -38,57 +35,61 @@ class flow_finfybxClassModel extends flowModel
$fininfom_jk = m('c_fininfom_jk')->getone($sql,'balance');//金额 $fininfom_jk = m('c_fininfom_jk')->getone($sql,'balance');//金额
$docnum=$this->rs['docnum']; $docnum=$this->rs['docnum'];
if($this->rs['money'] >= $fininfom_jk['balance']){ if($this->rs['money'] >= $fininfom_jk['balance']){
$jkbalance = array(
'balance' => 0,
);
$dk_amount=$fininfom_jk['balance'];
}else{ $dk_amount=$fininfom_jk['balance'];
$jkbalance = array(
'balance' => $fininfom_jk['balance']-$this->rs['money'],
);
$dk_amount=$this->rs['money'];
}
$this->rs['money']=$this->rs['money']-$dk_amount; }else{
m('c_fininfom_jk')->update($jkbalance, "`docnum`='$jk_num'"); $dk_amount=$this->rs['money'];
}
$this->rs['money']=$this->rs['money']-$dk_amount;
$deduct_detail = array(
'jk_num' => $jk_num,
'bx_num' => $docnum, $deduct_detail = array(
'dk_amount' =>$dk_amount, 'jk_num' => $jk_num,
'status' =>0, 'bx_num' => $docnum,
'create_time' => date("Y-m-d H:i:s"), 'dk_amount' =>$dk_amount,
); 'status' =>0,
m('c_deduct_detail')->insert($deduct_detail); 'create_time' => date("Y-m-d H:i:s"),
);
m('c_deduct_detail')->insert($deduct_detail);
} }
echo 11;
}else{ }else{
$jk_num=substr($dikouid,0,strrpos($dikouid,'金')); $jk_num=substr($dikouid,0,strrpos($dikouid,'金'));
} $sql = " docnum ='$jk_num' ";
$fininfom_jk = m('c_fininfom_jk')->getone($sql,'balance');//金额
$docnum=$this->rs['docnum'];
if($this->rs['money'] >= $fininfom_jk['balance']){
$dk_amount=$fininfom_jk['balance'];
}else{
$dk_amount=$this->rs['money'];
}
// m('c_fininfom_jk')->update($jkbalance, "`docnum`='$jk_num'");
// if($this->rs['money'] <= $fininfom_jk['amount']) {
// }
// if($this->rs['money'] > $fininfom_jk['amount']){
//
// }
$deduct_detail = array(
'jk_num' => $jk_num,
'bx_num' => $docnum,
'dk_amount' =>$dk_amount,
'status' =>0,
'create_time' => date("Y-m-d H:i:s"),
);
m('c_deduct_detail')->insert($deduct_detail);
}
} }
}
//二级 或一级审批同意之后进行预扣款
protected function flowcheckbefore($zt, $sm){
$id=$this->rs['id']; $id=$this->rs['id'];
...@@ -497,69 +498,133 @@ class flow_finfybxClassModel extends flowModel ...@@ -497,69 +498,133 @@ class flow_finfybxClassModel extends flowModel
//流程全部完成后调用 //流程全部完成后调用
protected function flowcheckfinsh($zt){ protected function flowcheckfinsh($zt){
// $docnum=$this->rs['docnum']; $docnum=$this->rs['docnum'];
// $withhold_cost = m('c_withhold_fininform')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount'); $withhold_cost = m('c_withhold_fininform')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount');
//
// foreach ($withhold_cost as $key => $vo) { foreach ($withhold_cost as $key => $vo) {
// // 扣除账户余额 c_fund_account account_balance // 扣除账户余额 c_fund_account account_balance
//
// $cbzxid= $vo['cost_id']; $cbzxid= $vo['cost_id'];
// $model = 'c_fund_account'; $model = 'c_fund_account';
// $sql = " cost_id ='$cbzxid' and status = 1 and is_default=1"; $sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
// $data = m($model)->getone($sql,'id,name,account_balance,freeze_amount'); $data = m($model)->getone($sql,'id,name,account_balance,freeze_amount');
//
// $zfarr = array( $zfarr = array(
// 'account_balance' =>$data['account_balance']-$vo['amount'], 'account_balance' =>$data['account_balance']-$vo['amount'],
// ); );
// $id=$data['id']; $id=$data['id'];
// m('c_fund_account')->update($zfarr,"`id`='$id'"); m('c_fund_account')->update($zfarr,"`id`='$id'");
//
// $freeze = array( $freeze = array(
// 'freeze_amount' => $data['freeze_amount'] - $vo['amount'], 'freeze_amount' => $data['freeze_amount'] - $vo['amount'],
// ); );
//
// m('c_fund_account')->update($freeze, "`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']+$vo['amount'],
// );
// m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
// //账户明细 c_account_detail
// $account_detail=array(
// 'account' => $data['name'],
// 'opt_type' => 2,
// 'amount' =>$vo['amount'],
// 'trans_numb' => $this->rs['docnum'],
// 'account_balance' => $data['account_balance']-$vo['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['applicant'],
// 'trans_amount' =>$vo['amount'],
// 'business_type' =>11,
// 'opt_type' =>2,
// 'account_balance'=>$data['account_balance']-$vo['amount'],
// 'create_time' =>date("Y-m-d H:i:s"),
// 'uid' =>$this->rs['uid'],
// );
// m('c_fund_detail')->insert($fund_detail);
// }
m('c_fund_account')->update($freeze, "`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']+$vo['amount'],
);
m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
//账户明细 c_account_detail
$account_detail=array(
'account' => $data['name'],
'opt_type' => 2,
'amount' =>$vo['amount'],
'trans_numb' => $this->rs['docnum'],
'account_balance' => $data['account_balance']-$vo['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['applicant'],
'trans_amount' =>$vo['amount'],
'business_type' =>11,
'opt_type' =>2,
'account_balance'=>$data['account_balance']-$vo['amount'],
'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'],
);
m('c_fund_detail')->insert($fund_detail);
}
if($this->rs['dikouid']){
$dikouid = $this->rs['dikouid'];
if(strpos($dikouid,',') !== false){
$jk_num=explode(",",$dikouid);
foreach ($jk_num as $key => $value ){
if($this->rs['money'] ==0 ){
break;
}
$jk_num=substr($value,0,strrpos($value,'金'));
$sql = " docnum ='$jk_num' ";
$fininfom_jk = m('c_fininfom_jk')->getone($sql,'balance');//金额
$docnum=$this->rs['docnum'];
if($this->rs['money'] >= $fininfom_jk['balance']){
$jkbalance = array(
'balance' => 0,
);
}else{
$jkbalance = array(
'balance' => $fininfom_jk['balance']-$this->rs['money'],
);
}
$this->rs['money']=$this->rs['money']-$fininfom_jk['balance'];
m('c_fininfom_jk')->update($jkbalance, "`docnum`='$jk_num'");
$deduct_status = array(
'status' => 1,
);
m('c_deduct_detail')->update($deduct_status, "`bx_num`='$docnum' and status=0");
}
}else{
$docnum=$this->rs['docnum'];
$jk_num=substr($dikouid,0,strrpos($dikouid,'金'));
$sql = " docnum ='$jk_num' ";
$fininfom_jk = m('c_fininfom_jk')->getone($sql,'balance');//金额
$docnum=$this->rs['docnum'];
if($this->rs['money'] >= $fininfom_jk['balance']){
$jkbalance = array(
'balance' => 0,
);
}else{
$jkbalance = array(
'balance' => $fininfom_jk['balance']-$this->rs['money'],
);
}
m('c_fininfom_jk')->update($jkbalance, "`docnum`='$jk_num'");
$deduct_status = array(
'status' => 1,
'update_time' =>date("Y-m-d H:i:s"),
);
m('c_deduct_detail')->update($deduct_status, "`bx_num`='$docnum' and status=0");
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论