提交 2e420dd1 authored 作者: fengzy's avatar fengzy

费用报销脚本

上级 64ad16b5
<?php
class flow_finfybxClassModel extends flowModel
{
public function flowcheckname($num)
{
$arr = [];
if ($num == 'abc')
{
$arr["$sid"] = "982";
$arr["$sna"] = "εÑàéª";
}
return $arr;
}
// public function flowcheckname($num)
// {
// $arr = [];
// if ($num == 'abc')
// {
// $arr["$sid"] = "982";
// $arr["$sna"] = "εÑàéª";
// }
// return $arr;
// }
protected function flowcheckafter($zt, $sm){
......@@ -149,22 +149,12 @@ class flow_finfybxClassModel extends flowModel
$post_content = self::create_postdata($data);
$result = self::invoke_add($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
if($array['Result']['ResponseStatus']['IsSuccess']){
$num=$array['Result']['Number'];
if($array['Result']['ResponseStatus']['IsSuccess']){
$this->update("`fbillno`='$num'", $this->rs['id']);
$this->erplog($this->rs['docnum'],'fininfom','保存成功',json_encode($array),date("Y-m-d H:i:s"),2,$num,$array['Result']['Id'],1);
if($this->fybx_submit($cloudUrl,$cookie_jar,$array['Result']['Id'],$array['Result']['Number'])){
$this->erplog($this->rs['docnum'],'fininfom','提交成功',json_encode($array),date("Y-m-d H:i:s"),2,$num,$array['Result']['Id'],2);
}else{
$this->erplog($this->rs['docnum'],'fininfom','提交失败',json_encode($array),date("Y-m-d H:i:s"),1,$num,$array['Result']['Id'],2);
}
}else{
$this->erplog($this->rs['docnum'],'fininfom','保存失败',json_encode($array),date("Y-m-d H:i:s"),1,$num,$array['Result']['Id'],1);
}
......@@ -241,7 +231,16 @@ class flow_finfybxClassModel extends flowModel
if($flowid['nowcheckid']==$checkid && $flowid['nowcourseid']==$explain){
$data = m('fininfom')->getall('id='.$this->rs['id'], 'id,cbxmid,money');
foreach ($data as $key => $vo) {
foreach($data as $v){
if(!isset($ret[$v['cbxmid']])){
$ret[$v['cbxmid']] = $v;
}else{
$ret[$v['cbxmid']]['money'] += $v['money'];
}
}
$ret = array_values($ret);
foreach ($ret as $key => $vo) {
$cbzx_code=$vo['cbxmid'];
$sql = " cost_id='$cbzx_code' and status = 1 and is_default=1";
$cost = m('c_fund_account')->getone($sql, 'id,type,name,freeze_amount,account_balance');//查询账户表成本中心
......@@ -250,13 +249,18 @@ class flow_finfybxClassModel extends flowModel
return $cost['name']."余额不足";die;
}
$id=$cost['id'];
}
foreach ($data as $ky => $va) {
$cbzx_code=$va['cbxmid'];
$sql = " cost_id='$cbzx_code' and status = 1 and is_default=1";
$cost = m('c_fund_account')->getone($sql, 'id,type,name,freeze_amount,account_balance');//查询账户表成本中心
$id=$cost['id'];
$c_withhold = array(
'fund_account_id' => $id,
'docnum' => $this->rs['docnum'],
'cost_id' => $vo['cbxmid'],
'amount' => $vo['money'],
'cost_id' => $va['cbxmid'],
'amount' => $va['money'],
'status' => 1,
'create_time' => date("Y-m-d H:i:s"),
'uid' => $this->rs['uid'],
......@@ -265,7 +269,7 @@ class flow_finfybxClassModel extends flowModel
//修改冻结余额
$freeze = array(
'freeze_amount' => $cost['freeze_amount'] + $vo['money'],
'freeze_amount' => $cost['freeze_amount'] + $va['money'],
);
m('c_fund_account')->update($freeze, "`id`='$id'");
......@@ -274,23 +278,32 @@ class flow_finfybxClassModel extends flowModel
}else{
if($flowid['nowcheckid']==$checkid){
$data = m('fininfom')->getall('id='.$this->rs['id'], 'id,cbxmid,money');
foreach($data as $v){
if(!isset($ret[$v['cbxmid']])){
$ret[$v['cbxmid']] = $v;
}else{
$ret[$v['cbxmid']]['money'] += $v['money'];
}
}
foreach ($data as $key => $vo) {
$cbzx_code=$vo['cbxmid'];
$sql = " cost_id='$cbzx_code' and status = 1 and is_default=1";
$cost = m('c_fund_account')->getone($sql, 'id,type,name,freeze_amount,account_balance');//查询账户表成本中心
if(($cost['account_balance']-$cost['freeze_amount'])<$vo['money']){
return $cost['name']."余额不足";die;
}
}
foreach ($data as $ky => $va) {
$cbzx_code=$va['cbxmid'];
$sql = " cost_id='$cbzx_code' and status = 1 and is_default=1";
$cost = m('c_fund_account')->getone($sql, 'id,type,name,freeze_amount,account_balance');//查询账户表成本中心
$id=$cost['id'];
$c_withhold = array(
'fund_account_id' => $id,
'docnum' => $this->rs['docnum'],
'cost_id' => $vo['cbxmid'],
'amount' => $vo['money'],
'cost_id' => $va['cbxmid'],
'amount' => $va['money'],
'status' => 1,
'create_time' => date("Y-m-d H:i:s"),
'uid' => $this->rs['uid'],
......@@ -299,7 +312,7 @@ class flow_finfybxClassModel extends flowModel
//修改冻结余额
$freeze = array(
'freeze_amount' => $cost['freeze_amount'] + $vo['money'],
'freeze_amount' => $cost['freeze_amount'] + $va['money'],
);
m('c_fund_account')->update($freeze, "`id`='$id'");
......@@ -504,9 +517,9 @@ class flow_finfybxClassModel extends flowModel
$post_content = self::create_postdata($data);
$result = self::invoke_add($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
$num=$array['Result']['Number'];
if($array['Result']['ResponseStatus']['IsSuccess']){
$num=$array['Result']['Number'];
$this->update("`fsrcbillno`='$num'", $this->rs['id']);
$this->erplog($this->rs['docnum'],'fininfom','保存成功',json_encode($array),date("Y-m-d H:i:s"),2,$num,$array['Result']['Id'],1);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论