<?php
class flow_finfybxClassModel extends flowModel
{
	
 
  public  function flowcheckname($num){
   	    
   	 
	      
	      $arr =  [];
   	   
   	   if($num == 'abc')
   	   {
   	   	
   	   	$arr["$sid"]  = "982";
   	   	$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);

     
      
   }
	

}