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

oa付款单

上级 71f75d7a
......@@ -208,4 +208,316 @@ class flow_oayfkClassModel extends flowModel
}
protected function flowcheckafter($zt, $sm, $nowcourse)
{
$flowid = $this->getflow();
if ($flowid['nowcheckid'] == 1085) {
$cloudUrl = "http://36.110.39.211/k3cloud/";
//登陆参数
$data = array(
'5ef2c166ad1afa',//帐套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");
$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, "("));
$oafk_details=$this->db->getrows('oa_c_fund_details_yfk',"mid='".$this->rs['id']."'");
$arr=[];
foreach ($oafk_details as $k=> $value) {
foreach ($value as $key => $val) {
switch ($key) {
case 'charge_amount':
$arr['FPAYAPPLYENTRY'][$k]['FAPPLYAMOUNTFOR']=$val;
break;
break;
default:
$arr['FPAYAPPLYENTRY'][$k]['FSETTLETYPEID']['FNumber']='JSFS04_SYS';
$arr['FPAYAPPLYENTRY'][$k]['FPAYPURPOSEID']['FNumber']='SFKYT09_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['bank_code'];
$arr['FPAYAPPLYENTRY'][$k]['FEACHCCOUNTNAME'] = $data['bank_holder'];
$arr['FPAYAPPLYENTRY'][$k]['FEACHBANKNAME'] = $data['open_bank_name'];
break;
}
}
}
$data_model = '{
"Creator": "",
"NeedUpDateFields": [],
"NeedReturnFields": [],
"IsDeleteEntry": "true",
"SubSystemId": "",
"IsVerifyBaseDataField": "false",
"IsEntryBatchFill": "true",
"ValidateFlag": "true",
"NumberSearch": "true",
"InterationFlags": "",
"IsAutoSubmitAndAudit": "false",
"Model": {
"FID": 0,
"FBILLTYPEID": {
"FNUMBER": "FKSQ009"
},
"FDATE": "2020-06-29 00:00:00",
"FCONTACTUNITTYPE": "BD_Supplier",
"FCONTACTUNIT": {
"FNumber": "GDGYS-0003"
},
"FRECTUNITTYPE": "BD_Supplier",
"FRECTUNIT": {
"FNumber": "GDGYS-0003"
},
"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"
},
"F_PAEZ_OADJBH": "213123213"
}
}';
$model = json_decode($data_model, true);
// $model['Model']['F_PAEZ_Cbzx']['FNUMBER'] = $cbxmid;
$model['Model']['FCREATORID']['FNUMBER'] = $gonncode;
$model['Model']['FDATE'] = $applydt;
$model['Model']['F_PAEZ_OADJBH'] = $this->rs['docnum'];;
// $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字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_add($cloudUrl, $post_content, $cookie_jar);
$array = json_decode($result, true);
var_dump($array);
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']));
}
}
}
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字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_submit($cloudUrl, $post_content, $cookie_jar);
$array = json_decode($result, true);
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字串
);
$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)
);
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);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
static function getbxlx($name)
{
if ($name == '现金') {
return 'JSFS01_SYS';
} else {
return 'JSFS04_SYS';
}
}
//构造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'
);
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
......@@ -26,7 +26,7 @@ foreach ($dataarr as $key => $value) {
$cloudUrl = "http://36.110.39.211/k3cloud/";
//登陆参数
$data = array(
'5d64e2f4ecb139',//帐套Id
'5ef2c166ad1afa',//帐套Id
'Administrator',//用户名
'666666',//密码
'2052'//语言标识359010087
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论