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

费用报销脚本

上级 4b789bd2
......@@ -504,7 +504,7 @@ 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'];
$this->update("`fsrcbillno`='$num'", $this->rs['id']);
......
......@@ -320,26 +320,246 @@ class openfinfybxClassAction extends openapiAction
$dataarr = $this->db->getall($sql);
foreach ($dataarr as $key => $value) {
$fininfomlist = $this->db->getone('[Q]fininfom',"`docnum`='".$value['sericnum']."'");
echo '<pre>';
var_dump($fininfomlist);
$fininfomlist = $this->db->getone('[Q]fininfom',"`docnum`='".$value['sericnum']."'");
$cbxmid=substr($fininfomlist['cbxmid'],0,strpos($fininfomlist['cbxmid'], "("));
$data=$this->db->getone('oa_personfile',"name='".$fininfomlist['applicant']."'");
$gonncode=$data['gonncode'];
//明细
$oa_fininfos=$this->db->getrows('oa_fininfos',"mid='".$fininfomlist['id']."'");
$arr=[];
foreach ($oa_fininfos as $k=> $value) {
foreach ($value as $key => $val) {
switch ($key) {
case 'bxType':
$arr['FPAYAPPLYENTRY'][$k]['FCOSTID']['FNUMBER']=self::getbxlx($val);
break;
case 'money':
$arr['FPAYAPPLYENTRY'][$k]['FAPPLYAMOUNTFOR']=$val;
break;
case 'sm':
$arr['FPAYAPPLYENTRY'][$k]['FDescription']=$val;
break;
default:
$arr['FPAYAPPLYENTRY'][$k]['F_KXType']['FNUMBER']="00";
$arr['FPAYAPPLYENTRY'][$k]['F_PAEZ_CBZX1']['FNUMBER']=$cbxmid;
$arr['FPAYAPPLYENTRY'][$k]['FSETTLETYPEID']['FNumber']='JSFS04_SYS';
$arr['FPAYAPPLYENTRY'][$k]['FPAYPURPOSEID']['FNumber']='SFKYT10_SYS';
$arr['FPAYAPPLYENTRY'][$k]['FENDDATE']=$this->rs['applydt'].' 00:00:00';
$arr['FPAYAPPLYENTRY'][$k]['FEXPECTPAYDATE']=$this->rs['applydt'].' 00:00:00';
$arr['FPAYAPPLYENTRY'][$k]['FEACHBANKACCOUNT']=$data['pfbanknum'];
break;
}
}
}
$cloudUrl = "http://36.110.39.211/k3cloud/";
//登陆参数
$data = array(
'5e64f6ff0bd47f',//帐套Id
'Administrator',//用户名
'666666',//密码
'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");
$applicant=$fininfomlist['applicant'];//申请人
$applydt=$fininfomlist['applydt'];//申请日期
$data_model ='{
"Creator": "",
"NeedUpDateFields": [],
"NeedReturnFields": [],
"IsDeleteEntry": "true",
"SubSystemId": "",
"IsVerifyBaseDataField": "false",
"IsEntryBatchFill": "true",
"ValidateFlag": "true",
"NumberSearch": "true",
"InterationFlags": "",
"IsAutoSubmitAndAudit": "false",
"Model": {
"FID": 0,
"FBILLTYPEID": {
"FNUMBER": "FKSQ005_SYS"
},
"FDATE": "2020-02-11 00:00:00",
"FCONTACTUNITTYPE": "BD_Empinfo",
"FCONTACTUNIT": {
"FNumber": "GONN-0002"
},
"FRECTUNITTYPE": "BD_Empinfo",
"FRECTUNIT": {
"FNumber": "GONN-0002"
},
"FCURRENCYID": {
"FNumber": "PRE001"
},
"FPAYORGID": {
"FNumber": "1000"
},
"FSETTLEORGID": {
"FNumber": "1000"
},
"FDEPARTMENT": {
"FNumber": "GS.BM.08"
},
"F_PAEZ_OADJBH": "123321",
"FDOCUMENTSTATUS": "Z",
"FCANCELSTATUS": "A",
"FMAINBOOKID": {
"FNUMBER": "PRE001"
},
"FIsCredit": false,
"FAPPLYORGID": {
"FNumber": "1000"
},
"FSETTLECUR": {
"FNUMBER": "PRE001"
},
"FISCARRYRATE": false,
"F_PAEZ_CBZX1": {
"FNUMBER": " GS.BJ.B1"
}
}
}';
$model=json_decode($data_model,true);
$model['Model']['FDATE']=$applydt;
$model['Model']['FDEPARTMENT']['FNumber']=self::dept($fininfomlist['applicationdpt']);
$model['Model']['FCONTACTUNIT']['FNumber']=$gonncode;
$model['Model']['F_PAEZ_OADJBH']=$fininfomlist['docnum'];
$model['Model']['FRECTUNIT']['FNumber']=$gonncode;
$model['Model']['FPAYAPPLYENTRY']=$arr['FPAYAPPLYENTRY'];
$data_model=json_encode($model);
$data = array(
'CN_PAYAPPLY',//业务对象标识FormId
$data_model//具体Json字串
);
$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']){
$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);
if($this->apply_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);
}
if($this->apply_audit($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'],3);
}else{
$this->erplog($this->rs['docnum'],'fininfom','付款申请单审核失败',json_encode($array),date("Y-m-d H:i:s"),1,$num,$array['Result']['Id'],3);
}
}else{
$this->erplog($this->rs['docnum'],'fininfom','付款申请单保存失败',json_encode($array),date("Y-m-d H:i:s"),1,$num,$array['Result']['Id'],1);
}
}
}
//登陆
static function invoke_login($cloudUrl,$post_content,$cookie_jar)
public static function dept($data)
{
$loginurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
return self::invoke_post($loginurl,$post_content,$cookie_jar,TRUE);
$sql=" name= '$data'";
$data = m('tmp_department')->getone($sql, 'id,number');//查询账户表成本中心id
return $data['number'];
}
//表单查询
static function invoke_save($cloudUrl,$post_content,$cookie_jar)
public function apply_submit($cloudUrl,$cookie_jar,$id,$number){
$data_model ="{
'CreateOrgId': 0,
'Numbers': [],
'Ids': $id,
'SelectedPostId': 0
}";
$data = array(
'CN_PAYAPPLY',//业务对象标识FormId
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_submit($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
return $array;
}
public function apply_audit($cloudUrl,$cookie_jar,$id,$number){
$data_model ="{
'CreateOrgId': 0,
'Numbers': [],
'Ids': $id,
'InterationFlags': ''
}";
$data = array(
'CN_PAYAPPLY',//业务对象标识FormId
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_audit($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
return $array;
}
static function getbxlx($name)
{
$invokeurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc';
return self::invoke_post($invokeurl,$post_content,$cookie_jar,FALSE);
$data = m('c_bxlx')->getone("name='".$name."'", 'name,number');
return $data['number'];
}
//添加
//登陆
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)
{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论