提交 57f6ac2b authored 作者: fengzy's avatar fengzy

'调整费用报销与借款单逻辑'

上级 a3fce768
...@@ -59,99 +59,99 @@ __ ...@@ -59,99 +59,99 @@ __
var_dump($res);die; var_dump($res);die;
} }
//二级 或一级审批同意之后进行预扣款 // //二级 或一级审批同意之后进行预扣款
protected function flowcheckbefore($zt, $sm){ // protected function flowcheckbefore($zt, $sm){
$id=$this->rs['id']; // $id=$this->rs['id'];
$sql = " mid ='$id' and `table`='c_emfk' "; // $sql = " mid ='$id' and `table`='c_emfk' ";
$flow_bill = m('flow_bill')->getone($sql,'allcheckid'); // $flow_bill = m('flow_bill')->getone($sql,'allcheckid');
$allcheckid=explode(',',$flow_bill['allcheckid']); // $allcheckid=explode(',',$flow_bill['allcheckid']);
$option = m('option')->getall('pid = 1497 and num =1 order by sort desc','num,name,value,sort'); // $option = m('option')->getall('pid = 1497 and num =1 order by sort desc','num,name,value,sort');
foreach ($option as $key => $value) { // foreach ($option as $key => $value) {
if(in_array($value['value'], $allcheckid)){ // if(in_array($value['value'], $allcheckid)){
$checkid= $value['value']; // $checkid= $value['value'];
break; // break;
} // }
} // }
//
if(empty($checkid)){ // if(empty($checkid)){
$option = m('option')->getall('pid = 1497 and num =2 order by sort desc','num,name,value,sort,`explain`'); // $option = m('option')->getall('pid = 1497 and num =2 order by sort desc','num,name,value,sort,`explain`');
foreach ($option as $key => $value) { // foreach ($option as $key => $value) {
if(in_array($value['value'], $allcheckid)){ // if(in_array($value['value'], $allcheckid)){
$checkid= $value['value']; // $checkid= $value['value'];
break; // break;
} // }
} // }
} // }
//
//
//zt 1代表同意 // //zt 1代表同意
if($zt==1){ // if($zt==1){
$flowid=$this->getflow(); // $flowid=$this->getflow();
//
if($flowid['nowcheckid']==$checkid){ // if($flowid['nowcheckid']==$checkid){
$data = m('c_emfk_details')->getall('mid='.$this->rs['id'], 'id,cbzxid,amount'); // $data = m('c_emfk_details')->getall('mid='.$this->rs['id'], 'id,cbzxid,amount');
//
foreach ($data as $key => $vo) { // foreach ($data as $key => $vo) {
$cbzx_code=$vo['cbzxid']; // $cbzx_code=$vo['cbzxid'];
$cbzxid = m('tmp_department')->getone('', 'id,cost');//查询账户表成本中心id // $cbzxid = m('tmp_department')->getone('', 'id,cost');//查询账户表成本中心id
//
$sql = " cost_id='$cbzx_code' and status = 1 and is_default=1"; // $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 // $cost = m('c_fund_account')->getone($sql, 'id,type,freeze_amount,account_balance');//查询账户表成本中心id
if($cost['type']=='1'){ // if($cost['type']=='1'){
if(($cost['account_balance']-$cost['freeze_amount'])<$vo['amount']){ // if(($cost['account_balance']-$cost['freeze_amount'])<$vo['amount']){
return "账户余额不足";die; // return "账户余额不足";die;
} // }
} // }
$id=$cost['id']; // $id=$cost['id'];
//
$c_withhold = array( // $c_withhold = array(
'fund_account_id' => $id, // 'fund_account_id' => $id,
'docnum' => $this->rs['docnum'], // 'docnum' => $this->rs['docnum'],
'cost_id' => $vo['cbzxid'], // 'cost_id' => $vo['cbzxid'],
'amount' => $vo['amount'], // 'amount' => $vo['amount'],
'status' => 1, // 'status' => 1,
'create_time' => date("Y-m-d H:i:s"), // 'create_time' => date("Y-m-d H:i:s"),
'uid' => $this->rs['uid'], // 'uid' => $this->rs['uid'],
); // );
m('c_withhold_emfk')->insert($c_withhold); // m('c_withhold_emfk')->insert($c_withhold);
//
//修改冻结余额 // //修改冻结余额
$freeze = array( // $freeze = array(
'freeze_amount' => $cost['freeze_amount'] + $vo['amount'], // 'freeze_amount' => $cost['freeze_amount'] + $vo['amount'],
); // );
//
m('c_fund_account')->update($freeze, "`id`='$id'"); // m('c_fund_account')->update($freeze, "`id`='$id'");
} // }
} // }
//
}else{ // }else{
$docnum=$this->rs['docnum']; // $docnum=$this->rs['docnum'];
//将单据状态作废余额 // //将单据状态作废余额
//
$withhold_cost = m('c_withhold_emfk')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount'); // $withhold_cost = m('c_withhold_emfk')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount');
//
foreach ($withhold_cost as $key => $vo) { // foreach ($withhold_cost as $key => $vo) {
//减去冻结金额 // //减去冻结金额
$cost_id=$vo['cost_id']; // $cost_id=$vo['cost_id'];
$sql = " cost_id='$cost_id' and status = 1 and is_default=1"; // $sql = " cost_id='$cost_id' and status = 1 and is_default=1";
$fund_account_cost = m('c_fund_account')->getone($sql, 'id,freeze_amount'); // $fund_account_cost = m('c_fund_account')->getone($sql, 'id,freeze_amount');
//
$id=$fund_account_cost['id']; // $id=$fund_account_cost['id'];
$freeze = array( // $freeze = array(
'freeze_amount' => $fund_account_cost['freeze_amount'] - $vo['amount'], // 'freeze_amount' => $fund_account_cost['freeze_amount'] - $vo['amount'],
); // );
//
m('c_fund_account')->update($freeze, "`id`='$id'"); // m('c_fund_account')->update($freeze, "`id`='$id'");
//
} // }
//
//
$status = array( // $status = array(
'status' => 0, // 'status' => 0,
); // );
m('c_withhold_emfk')->update($status, "docnum='$docnum'"); // m('c_withhold_emfk')->update($status, "docnum='$docnum'");
} // }
} // }
//流程全部完成后调用 //流程全部完成后调用
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论