提交 ce8b4fa0 authored 作者: fengzy's avatar fengzy

oa付款单

上级 5c3f21a9
......@@ -145,68 +145,442 @@ class flow_finfybxClassModel extends flowModel
// //流程全部完成后调用
protected function flowcheckfinsh($zt){
// protected function flowcheckfinsh($zt){
// $docnum=$this->rs['docnum'];
// $withhold_cost = m('c_withhold_fininform')->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' =>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);
// }
// }
//审核完成后调用
protected function flowcheckafter($zt, $sm,$nowcourse){
$flowid=$this->getflow();
$docnum=$this->rs['docnum'];
$withhold_cost = m('c_withhold_fininform')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount');
$cloudUrl = "http://36.110.39.211/k3cloud/";
//登陆参数
$data = array(
'5d8acc5a26042d',//帐套Id
'Administrator',//用户名
'kJyGjIQ5DW0tpd@B',//密码
'2052'//语言标识359010087
);
//定义记录Cloud服务端返回的Session
$cookie_jar = tempnam('/tmp','CloudSession');
$post_content = self::create_postdata($data);
$result = self::invoke_login($cloudUrl,$post_content,$cookie_jar);
header("Content-type: text/html; charset=utf8");
$starttime = microtime(true);
$applicant=$this->rs['applicant'];//申请人
$FCREATORID=$this->db->getone('oa_personfile',"name='".$this->rs['applicant']."'");
$gonncode=$FCREATORID['gonncode']; //申请人编号
$applicationdpt=$this->rs['applicationdpt'];//申请部门
$applydt=$this->rs['optdt'];//申请日期
$amountOfThisPayment=$this->rs['amountOfThisPayment'];//金额
$contractNumber=$this->rs['contractNumber'];//合同编号
$contracta=(strpos($contractNumber, "("));
$contractb=(strrpos($contractNumber, ")"));
$b = mb_strpos($contractNumber,"(") + mb_strlen("(");
$e = mb_strpos($contractNumber, ")") - $b;
$contractNumber=mb_substr($contractNumber,$b,$e);
$contract = $this->db->getone('oa_c_contract', 'numb = "' . $contractNumber . '"');
if($contract['receive']==2){
$suppliername= $contract['partb_name'];//供应商名称
}else{
$suppliername= $contract['parta_name'];//供应商名称
}
$sql = 'bank_code = ' .$contract['bankcode'];
$data = $this->db->getone('oa_supplier_bank_info', $sql);
$paymentMethod=$this->rs['paymentMethod'];//付款方式
$cbxmid=$this->rs['cbzxid'];//成本中心
$cbxmid=substr($cbxmid,0,strpos($cbxmid, "("));
// $data_model='{
// "Creator": "",
// "NeedUpDateFields": [],
// "NeedReturnFields": [],
// "IsDeleteEntry": "true",
// "SubSystemId": "",
// "IsVerifyBaseDataField": "false",
// "IsEntryBatchFill": "true",
// "ValidateFlag": "true",
// "NumberSearch": "true",
// "InterationFlags": "",
// "IsAutoSubmitAndAudit": "false",
// "Model": {
// "FID": 0,
// "FBILLTYPEID": {
// "FNUMBER": "FKSQ008"
// },
// "FCREATORID": {
// "FNUMBER": ""
// },
// "FDATE": "2020-03-02 00:00:00",
// "FCONTACTUNITTYPE": "BD_Supplier",
// "FCONTACTUNIT": {
// "FNumber": "GSGYS-0005"
// },
// "FRECTUNITTYPE": "BD_Supplier",
// "FRECTUNIT": {
// "FNumber": "GSGYS-0005"
// },
// "FCURRENCYID": {
// "FNumber": "PRE001"
// },
// "FAPPLYORGID": {
// "FNumber": "1000"
// },
// "FPAYORGID": {
// "FNumber": "1000"
// },
// "FSETTLEORGID": {
// "FNumber": "1000"
// },
// "FPURCHASEORGID": {
// "FNumber": "1000"
// },
// "FDOCUMENTSTATUS": "Z",
// "FCANCELSTATUS": "A",
// "FMAINBOOKID": {
// "FNUMBER": "PRE001"
// },
// "FIsCredit": false,
// "FSETTLECUR": {
// "FNUMBER": "PRE001"
// },
// "FISCARRYRATE": false,
// "F_PAEZ_Cbzx": {
// "FNUMBER": "GS.BJ.B01.02"
// }
// }
// }';
$data_model= '{
"Creator": "",
"NeedUpDateFields": [],
"NeedReturnFields": [],
"IsDeleteEntry": "true",
"SubSystemId": "",
"IsVerifyBaseDataField": "false",
"IsEntryBatchFill": "true",
"ValidateFlag": "true",
"NumberSearch": "true",
"InterationFlags": "",
"IsAutoSubmitAndAudit": "false",
"Model": {
"FID": 0,
"FBillTypeID": {
"FNUMBER": "FKDLX08"
},
"FDATE": "2020-06-24 00:00:00",
"FCONTACTUNITTYPE": "BD_Supplier",
"FCONTACTUNIT": {
"FNumber": "GDGYS-0002"
},
"FRECTUNITTYPE": "BD_Supplier",
"FDepartment": {
"FNumber": "05.01"
},
"FISINIT": false,
"FCURRENCYID": {
"FNumber": "PRE001"
},
"FEXCHANGERATE": 1.0,
"FSETTLERATE": 1.0,
"FSETTLEORGID": {
"FNumber": "1000"
},
"FDOCUMENTSTATUS": "Z",
"FCancelStatus": "A",
"FPAYORGID": {
"FNumber": "1000"
},
"FISSAMEORG": true,
"FIsCredit": false,
"FSETTLECUR": {
"FNUMBER": "PRE001"
},
"FIsWriteOff": false,
"FREALPAY": false,
"F_ZHname": "无",
"FORDate": "2017-04-01 00:00:00",
"FISCARRYRATE": false,
"FSETTLEMAINBOOKID": {
"FNUMBER": "PRE001"
},
"FPAYBILLENTRY": [
{
"F_XM_ID": {
"FNUMBER": " WLFX-3-TTTZ-19017"
},
"FContractID": {
"FNUMBER": "HT-SK-XXXW-2-16213"
},
"FCostType": {
"FNUMBER": "CBLX0001"
},
"FCostModel": {
"FNUMBER": "CBMS0001"
},
"F_KXType": {
"FNUMBER": "009"
},
"FSETTLETYPEID": {
"FNumber": "JSFS02_SYS"
},
"FPURPOSEID": {
"FNumber": "SFKYT002"
},
"FPAYTOTALAMOUNTFOR": 30000.0,
"FPAYAMOUNTFOR_E": 30000.0,
"FSETTLEPAYAMOUNTFOR": 30000.0,
"FREALPAYAMOUNTFOR_D": 30000.0,
"FACCOUNTID": {
"FNumber": "01090879400120105061427"
},
"FRecType": "1",
"FPAYAMOUNT_E": 30000.0,
"FPOSTDATE": "2020-06-24 00:00:00",
"FPayType": "A",
"FRuZhangType": "1"
}
]
}
}';
// $arr['FPAYAPPLYENTRY'][0]['FENDDATE']=$this->rs['applydt'].' 00:00:00';
// $arr['FPAYAPPLYENTRY'][0]['FEXPECTPAYDATE']=$this->rs['applydt'].' 00:00:00';
// $arr['FPAYAPPLYENTRY'][0]['FAPPLYAMOUNTFOR']=intval($amountOfThisPayment);
// $arr['FPAYAPPLYENTRY'][0]['FEACHBANKACCOUNT']=$data['bank_code'];
// $arr['FPAYAPPLYENTRY'][0]['FEACHCCOUNTNAME']=$data['bank_holder'];
// $arr['FPAYAPPLYENTRY'][0]['FEACHBANKNAME']=$data['open_bank_name'];
// $model=json_decode($data_model,true);
// $model['Model']['F_PAEZ_Cbzx']['FNUMBER']=$cbxmid;
// $model['Model']['FCREATORID']['FNUMBER']=$gonncode;
// $model['Model']['FDATE']=$applydt;
// $model['Model']['FCONTACTUNIT']['FNumber']=$suppliername;
// $model['Model']['FRECTUNIT']['FNumber']=$suppliername;
// $model['Model']['FPAYAPPLYENTRY']=$arr['FPAYAPPLYENTRY'];
// $data_model=json_encode($model);
$data = array(
'CN_PAYAPPLY',//业务对象标识FormId
$data_model//具体Json字串
);
foreach ($withhold_cost as $key => $vo) {
// 扣除账户余额 c_fund_account account_balance
$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'];
// $this->update("`fbillno`='$num'", $this->rs['id']);
var_dump($this->supplier_submit($cloudUrl,$cookie_jar,$array['Result']['Id'],$array['Result']['Number']));
var_dump($this->supplier_audit($cloudUrl,$cookie_jar,$array['Result']['Id'],$array['Result']['Number']));
$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'],
public function supplier_submit($cloudUrl,$cookie_jar,$id,$number){
$start_time = microtime(true);
$data_model ="{
'CreateOrgId': 0,
'Numbers': [],
'Ids': $id,
'SelectedPostId': 0
}";
$data = array(
'CN_PAYAPPLY',//业务对象标识FormId
$data_model//具体Json字串
);
$id=$data['id'];
m('c_fund_account')->update($zfarr,"`id`='$id'");
$freeze = array(
'freeze_amount' => $data['freeze_amount'] - $vo['amount'],
);
$post_content = self::create_postdata($data);
$result = self::invoke_submit($cloudUrl,$post_content,$cookie_jar);
m('c_fund_account')->update($freeze, "`id`='$id'");
// 成本中心 amount 变更
$cbzx = substr($cbzxid,0,strrpos($cbzxid,"("));
$cbzxsql = " code ='$cbzx' and status = 1";
$array = json_decode($result,true);
$cbzxdata = m('c_cbzx')->getone($cbzxsql,'id,amount');
$cbarr = array(
'amount' =>$cbzxdata['amount']+$vo['amount'],
return $array;
}
public function supplier_audit($cloudUrl,$cookie_jar,$id,$number){
$data_model ="{
'CreateOrgId': 0,
'Numbers': [],
'Ids': $id,
'InterationFlags': ''
}";
$data = array(
'CN_PAYAPPLY',//业务对象标识FormId
$data_model//具体Json字串
);
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'],
$post_content = self::create_postdata($data);
$result = self::invoke_audit($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
return $array;
}
//登陆
static function invoke_login($cloudUrl,$post_content,$cookie_jar)
{
$loginurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
return self::invoke_post($loginurl,$post_content,$cookie_jar,TRUE);
}
//查询
static function invoke_save($cloudUrl,$post_content,$cookie_jar)
{
$invokeurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc';
return self::invoke_post($invokeurl,$post_content,$cookie_jar,FALSE);
}
//添加
static function invoke_add($cloudUrl,$post_content,$cookie_jar)
{
$invokeurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc';
return self::invoke_post($invokeurl,$post_content,$cookie_jar,FALSE);
}
//提交
static function invoke_submit($cloudUrl,$post_content,$cookie_jar)
{
$invokeurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit.common.kdsvc';
return self::invoke_post($invokeurl,$post_content,$cookie_jar,FALSE);
}
//审核
static function invoke_audit($cloudUrl,$post_content,$cookie_jar)
{
$invokeurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit.common.kdsvc';
return self::invoke_post($invokeurl,$post_content,$cookie_jar,FALSE);
}
static function invoke_post($url,$post_content,$cookie_jar,$isLogin)
{
$ch = curl_init($url);
$this_header = array(
'Content-Type: application/json',
'Content-Length: '.strlen($post_content)
);
m('c_account_detail')->insert($account_detail);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if($isLogin){
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
}
else{
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
// 业务付款8业务预付款10费用报销11 oa_c_fund_detail
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
static function getbxlx($name)
{
if($name=='现金'){
return 'JSFS01_SYS';
}else{
return 'JSFS04_SYS';
}
}
$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'],
//构造Web API请求格式
static function create_postdata($args) {
$postdata = array(
'format'=>1,
'useragent'=>'ApiClient',
'rid'=>self::create_guid(),
'parameters'=>$args,
'timestamp'=>date('Y-m-d'),
'v'=>'1.0'
);
m('c_fund_detail')->insert($fund_detail);
return json_encode($postdata);
}
//生成guid
static function create_guid() {
$charid = strtoupper(md5(uniqid(mt_rand(), true)));
$hyphen = chr(45);// "-"
$uuid = chr(123)// "{"
.substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12)
.chr(125);// "}"
return $uuid;
}
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论