提交 8fc33f9d authored 作者: chengye's avatar chengye

合并资金账户改动代码

......@@ -61,10 +61,21 @@ class mode_fund_transferClassAction extends inputAction{
$numb = $this->get('account');
$model = 'c_fund_account';
$sql = " id =$numb";
$cdata = m($model)->getone($sql,'id,name,level');
$level=$cdata['level'];
$levelto=$cdata['level']+1;
$sqla = " id !=$numb and level =$level or level =$levelto";
$cdata = m($model)->getone($sql,'id,name,pid,level');
if($cdata['level']==1){
$level=$cdata['level'];
$levelto=$cdata['level']+1;
$sqla = " id !=$numb and level =$level or level =$levelto";
}elseif($cdata['level']==2){
$sqla = " id !=$numb and (level =1 or level =2 or pid= $numb)";
}else{
$pid=$cdata['pid'];
$sqla = " id !=$numb and pid=$pid or id=$pid";
}
$data = m($model)->getall($sqla,'id as value,name');
$this->returnjson($data);
}
......
......@@ -152,4 +152,11 @@ class CommonClassModel extends Model
$data = m('assetm')->getall('state = 0', 'id as value, CONCAT(num, "(",title,")") as name');
return $data;
}
//借款单(已审核)
public function getfingrjkList()
{
$data = m('c_fininfom_jk')->getall('status = 1', 'id as value, CONCAT(docnum, "金额:(",amount,")") as name');
return $data;
}
}
......@@ -5,14 +5,18 @@ class flow_account_detailClassModel extends flowModel
public function flowrsreplace($rs)
{
$uid=$this->adminid;
$sql="account in ( select a.name from oa_c_fund_account as a where uid like concat({$uid},',%') or uid like concat('%,',{$uid}) or uid like concat('%,',{$uid},',%') )";
$fund_detail = m('c_fund_detail')->getall($sql,'account');
foreach ($fund_detail as $key => $value){
$allaccount[]=$value['account'];
}
foreach ($rs as $k => &$v) {
if($k=='business_type'){
if($v !==12){
$v="<a href='http://oa-test.gonn.tech/task.php?a=p&num=oafk&mid=44'>$v </a>";
}
}
switch ($k) {
case 'opt_type':
if($v == 1) {
......@@ -24,29 +28,62 @@ class flow_account_detailClassModel extends flowModel
$v = '';
}
break;
case 'trans_numb':
if($v == 1) {
$v = '收入';
} else if($v == 2) {
$v = '支出';
} else {
$v = '';
case 'trans_numb':
$arr=$this->getnums($v);
if($arr){
$num=$arr['num'];
$id=$arr['id'];
$name=$arr['name'];
$v= "<a href='javascript:;' onclick=openxiangs('$name','$num',$id)>$v</a>";
}else{
$v=$v;
}
break;
}
case 'account':
if(!in_array($v,$allaccount)){
$rs['account_balance']='***';
}else{
$rs['account_balance']=$rs['account_balance'];
}
break;
}
}
return $rs;
}
// http://oa-test.gonn.tech/task.php?a=p&num=oafk&mid=44
// case 'business_type':
// if($v !==12 ){
// $v="<a href='http://oa-test.gonn.tech/task.php?a=p&num=oafk&mid=44'>$v </a>";
// }
// break;
public function getnums($num){
if(strpos($num, 'OA-FK') !==false){
$ids = m('c_fininfom_oafk')->getone('docnum = "'.$num.'"','id');
$ids['num']='oafk';
$ids['name']='付款申请单';
// $ids['id']=$ids['id'];
}
if(strpos($num, 'OA-YFK') !==false){
$ids = m('c_fininfom_oayfk')->getone('docnum = "'.$num.'"','id');
$ids['num']='oayfk';
$ids['name']='预付款申请单';
}
if(strpos($num, 'OA-BX') !==false){
$ids = m('fininfom')->getone('docnum = "'.$num.'"','id');
$ids['num']='finfybx';
$ids['name']='费用报销';
}
if(strpos($num, 'FT') !==false){
$ids = m('c_fund_detail')->getone('trans_numb = "'.$num.'"','id');
$ids['num']='fund_transfer';
$ids['name']='资金划拨';
}
if(strpos($num, 'FS') !==false){
$ids = m('c_fund_detail')->getone('trans_numb = "'.$num.'"','id');
$ids['num']='fund_deposit';
$ids['name']='资金入账';
}
return $ids;
}
}
......@@ -6,18 +6,30 @@ class flow_account_listClassModel extends flowModel
public function flowrsreplace($rs)
{
if($rs['uid']){
$uid=explode(',',$rs['uid']);
$admin = m('admin')->getall('status = 1 ','id,name');
foreach ($admin as $key => $vo) {
if(in_array($vo['id'],$uid)){
$name[]=$vo['name'];
}
}
$rs['uid']= implode(",",$name);
}
if($rs['type']){
$data=$this->db->getone('oa_option',"num='".$rs['status']."' and pid=1366");
$data=$this->db->getone('oa_option',"num='".$rs['type']."' and pid=1366");
$rs['type']=$data['name'];
}
if($rs['level']){
$data=$this->db->getone('oa_option',"num='".$rs['level']."' and pid=1370");
$rs['level']=$data['name'];
}
if($rs['status']){
$data=$this->db->getone('oa_option',"num='".$rs['status']."' and pid=1374");
$rs['status']=$data['name'];
}
if($rs['currency_type']){
$data=$this->db->getone('oa_option',"num='".$rs['currency_type']."'");
......
......@@ -10,11 +10,17 @@ class flow_cost_centerClassModel extends flowModel
$data=$this->db->getone('oa_option',"num='".$rs['type']."' and pid=1377");
$rs['type']=$data['name'];
}
if($rs['status']){
$data=$this->db->getone('oa_option',"num='".$rs['status']."' and pid=1380");
$rs['status']=$data['name'];
}
if($rs['pid']){
$data=$this->db->getone('oa_c_cbzx',"id='".$rs['pid']."'");
$rs['pid']=$data['name'];
}
return $rs;
}
......
......@@ -205,10 +205,16 @@ class flowModel extends Model
//录入页上的标题
public function inputtitle()
{
return $this->moders['name'];
}
/**
public function getwhere($where = '')
{
return parent::getwhere($where); // TODO: Change the autogenerated stub
}
/**
* 列表上要搜索的的,此方法仅用到在:webmain/flow/input/inputAction.php 行607上返回,模块接口可重写这个方法
*/
public function flowsearchfields()
......
......@@ -5,19 +5,18 @@ class flow_fund_depositClassModel extends flowModel
public function flowrsreplace($rs)
{
if($rs['business_type']){
$data=$this->db->getone('oa_option',"num='".$rs['business_type']."' and pid=1350");
$rs['business_type']=$data['name'];
}
return $rs;
}
//提交时调用
protected function flowcheckfinsh($na, $sm){
protected function flowsubmit($na, $sm){
$name=$this->rs['toaccount'];
$data=m('c_fund_account')->getone("`name`='$name'");
$zfarr = array(
......@@ -29,12 +28,9 @@ class flow_fund_depositClassModel extends flowModel
$account_balance=$this->rs['trans_amount']+$data['account_balance'];//当前余额
$detail = array(
'account_balance' =>$account_balance,
'opt_type' => 1,
);
m('c_fund_detail')->update($detail,"`id`='$id'");
m('c_fund_detail')->update($detail,"`id`='$id'");
$toacc_detail = array(
'account' => $this->rs['toaccount'],
'opt_type' => 1,
......
......@@ -6,6 +6,14 @@ class flow_fund_transferClassModel extends flowModel
public function flowrsreplace($rs)
{
$uid=$this->adminid;
$sql="account in ( select a.name from oa_c_fund_account as a where uid like concat({$uid},',%') or uid like concat('%,',{$uid}) or uid like concat('%,',{$uid},',%') )";
$fund_detail = m('c_fund_detail')->getall($sql,'account');
foreach ($fund_detail as $key => $value){
$allaccount[]=$value['account'];
}
if($rs['business_type']){
......@@ -29,6 +37,14 @@ class flow_fund_transferClassModel extends flowModel
}
continue;
break;
case 'account':
if(!in_array($v,$allaccount)){
$rs['account_balance']='***';
}else{
$rs['account_balance']=$rs['account_balance'];
}
continue;
break;
}
}
......@@ -66,6 +82,7 @@ class flow_fund_transferClassModel extends flowModel
$account_balance=$data['account_balance']-$this->rs['trans_amount'];//当前余额
$detail = array(
'account_balance' =>$account_balance,
'opt_type' =>2,
);
m('c_fund_detail')->update($detail,"`id`='$id'");
......@@ -73,7 +90,7 @@ class flow_fund_transferClassModel extends flowModel
$acc_detail = array(
'account' => $this->rs['account'],
'opt_type' => 2,
'opt_type' =>2,
'amount' => $this->rs['trans_amount'],
'account_balance' =>$data['account_balance']-$this->rs['trans_amount'],
'trans_numb' => $this->rs['trans_numb'],
......@@ -84,7 +101,7 @@ class flow_fund_transferClassModel extends flowModel
$toacc_detail = array(
'account' => $this->rs['toaccount'],
'opt_type' => 1,
'opt_type' =>1,
'amount' => $this->rs['trans_amount'],
'account_balance' =>$toaccount_list['account_balance']+$this->rs['trans_amount'],
'trans_numb' => $this->rs['trans_numb'],
......
<?php
/**
* 费用报销接口
* Class opencatClassAction
*/
class openfinfybxClassAction extends openapiAction
{
public function __call($name, $arguments)
{
$msg = $name.' action not found';
return $this->showreturn([],$msg,'201');
}
//费用报销列表
public function listAction(){
$sql = 'select id,fbillno,status from [Q]fininfom where status=0 and fbillno is NOT null';
$dataarr = $this->db->getall($sql);
// echo "<pre>";
// var_dump($dataarr);die;
foreach ($dataarr as $key => $value) {
$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);
$data_model='{
"FormId": "AP_PAYBILL",
"FieldKeys": "FSRCBILLNO,FBillNo,FDOCUMENTSTATUS,FPAYTOTALAMOUNTFOR,FPOSTDATE ",
"FilterString": "",
"OrderString": "",
"TopRowCount": 0,
"StartRow": 0,
"Limit": 0
}';
$model=json_decode($data_model,true);
$model['FilterString']="FSRCBILLNO ="."'".$value['fbillno']."'";
$data_model=json_encode($model);
$data = array(
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_save($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
if(count($array)>1){
$key = ['FSRCBILLNO','FBillNo','FDOCUMENTSTATUS','FPAYTOTALAMOUNTFOR','FPOSTDATE' ];
$new_array = array();
foreach($array as $k=>$v) {
$new_array[$k] = array_combine($key,$v);
}
// 计算金钱
$sum = 0;
foreach($new_array as $ke =>$item){
if($item['FDOCUMENTSTATUS']=='C'){
$sum += (int)$item['FPAYTOTALAMOUNTFOR'];
$payflow = $this->db->getone('[Q]finybx_paymentflow',"`fbillno`='".$new_array[$ke]['FBillNo']."'",'id,fbillno');
$fbillno=$new_array['FSRCBILLNO'];
$datalist = $this->db->getone('[Q]fininfom',"`fbillno`='".$value['fbillno']."'",'id,fbillno,money');
if(!$payflow){
$paymentflow=array(
'fsrcbillno' =>$new_array[$ke]['FSRCBILLNO'],
'fbillno' =>$new_array[$ke]['FBillNo'],
'mid' =>$datalist['id'],
'fpaytotalamountfor' =>$new_array[$ke]['FPAYTOTALAMOUNTFOR'],
'date' =>substr($new_array[$ke]['FPOSTDATE'],0,strpos($new_array[$ke]['FPOSTDATE'], 'T'))
);
m('c_finybx_paymentflow')->insert($paymentflow);
}
}
}
if($datalist['money']==$sum){
m('fininfom')->update('`status`=1',$datalist['id']);
$zfarr = array(
'status' =>1,
'nowcourseid' => 0,
'nowcheckid' => NULL,
'nowcheckname' => NULL,
'nstatustext' => '尹再伟处理同意',
);
m('flow_bill')->update($zfarr,'mid='.$datalist['id'].'');
$addarr = array(
'table' => 'fininfom',
'mid' => $datalist['id'],
'status' => 1,
'statusname' => '同意',
'name' => '出纳付款',
'courseid' => 437,
'optdt' => date("Y-m-d H:i:s"),
'explain' => '系统自动确认',
'ip' => '0.0.0.0',
'web' =>'Chrome',
'checkname' =>'尹再伟',
'checkid' =>1085,
'modeid' =>11,
'color' =>'green',
'valid' =>1,
'step' =>4,
'qmimg' =>NULL,
'iszb' =>0
);
m('flow_log')->insert($addarr);
echo '成功';
}
}else{
$key = ['FSRCBILLNO','FBillNo','FDOCUMENTSTATUS','FPAYTOTALAMOUNTFOR','FPOSTDATE' ];
$new_array = array();
foreach($array as $k=>$v) {
$new_array= array_combine($key,$v);
}
if($new_array['FDOCUMENTSTATUS']=='C'){
$payflow = $this->db->getone('[Q]finybx_paymentflow',"`fbillno`='".$new_array['FBillNo']."'",'id,fbillno');
$fbillno=$new_array['FSRCBILLNO'];
$datalist = $this->db->getone('[Q]fininfom',"`fbillno`='".$fbillno."'",'id,fbillno,money');
if(!$payflow ){
$paymentflow=array(
'fsrcbillno' =>$new_array['FSRCBILLNO'],
'fbillno' =>$new_array['FBillNo'],
'mid' =>$datalist['id'],
'fpaytotalamountfor' =>$new_array['FPAYTOTALAMOUNTFOR'],
'date' =>substr($new_array['FPOSTDATE'],0,strpos($new_array['FPOSTDATE'], 'T'))
);
m('finybx_paymentflow')->insert($paymentflow);
}
if($datalist['money']==$new_array['FPAYTOTALAMOUNTFOR']){
m('fininfom')->update('`status`=1',$datalist['id']);
$zfarr = array(
'status' =>1,
'nowcourseid' => 0,
'nowcheckid' => NULL,
'nowcheckname' => NULL,
'nstatustext' => '尹再伟处理同意',
);
m('flow_bill')->update($zfarr,'mid='.$datalist['id'].'');
$addarr = array(
'table' => 'fininfom',
'mid' => $datalist['id'],
'status' => 1,
'statusname' => '同意',
'name' => '出纳付款',
'courseid' => 437,
'optdt' => date("Y-m-d H:i:s"),
'explain' => '系统自动确认',
'ip' => '0.0.0.0',
'web' =>'Chrome',
'checkname' =>'尹再伟',
'checkid' =>1085,
'modeid' =>11,
'color' =>'green',
'valid' =>1,
'step' =>4,
'qmimg' =>NULL,
'iszb' =>0
);
m('flow_log')->insert($addarr);
echo "成功1";
}
}
}
}
}
//登陆
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.ExecuteBillQuery.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;
}
//构造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
<?php
/**
* 付款申请接口
* Class opencatClassAction
*/
class openoafkClassAction extends openapiAction
{
public function __call($name, $arguments)
{
$msg = $name.' action not found';
return $this->showreturn([],$msg,'201');
}
//付款申请列表
public function listAction(){
$sql = 'select id,fbillno,status from [Q]c_fininfom_oafk where status=0 and fbillno is NOT null';
$dataarr = $this->db->getall($sql);
foreach ($dataarr as $key => $value) {
$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);
$data_model='{
"FormId": "AP_PAYBILL",
"FieldKeys": "FSRCBILLNO,FBillNo,FDOCUMENTSTATUS,FPAYTOTALAMOUNTFOR,FPOSTDATE ",
"FilterString": "",
"OrderString": "",
"TopRowCount": 0,
"StartRow": 0,
"Limit": 0
}';
$model=json_decode($data_model,true);
$model['FilterString']="FSRCBILLNO ="."'".$value['fbillno']."'";
$data_model=json_encode($model);
$data = array(
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_save($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
if(count($array)>1){
$key = ['FSRCBILLNO','FBillNo','FDOCUMENTSTATUS','FPAYTOTALAMOUNTFOR','FPOSTDATE' ];
$new_array = array();
foreach($array as $k=>$v) {
$new_array[$k] = array_combine($key,$v);
}
// 计算金钱
$sum = 0;
foreach($new_array as $ke =>$item){
if($item['FDOCUMENTSTATUS']=='C'){
$sum += (int)$item['FPAYTOTALAMOUNTFOR'];
$payflow = $this->db->getone('[Q]finifom_oafk_paymentflow',"`fbillno`='".$new_array[$ke]['FBillNo']."'",'id,fbillno');
$fbillno=$new_array['FSRCBILLNO'];
$datalist = $this->db->getone('[Q]c_fininfom_oafk',"`fbillno`='".$value['fbillno']."'",'id,fbillno,amountOfThisPayment');
if(!$payflow ){
$paymentflow=array(
'fsrcbillno' =>$new_array[$ke]['FSRCBILLNO'],
'fbillno' =>$new_array[$ke]['FBillNo'],
'fpaytotalamountfor' =>$new_array[$ke]['FPAYTOTALAMOUNTFOR'],
'mid' =>$datalist['id'],
'date' =>substr($new_array[$ke]['FPOSTDATE'],0,strpos($new_array[$ke]['FPOSTDATE'], 'T'))
);
m('finifom_oafk_paymentflow')->insert($paymentflow);
}
}
}
if($datalist['amountOfThisPayment']==$sum){
m('c_fininfom_oafk')->update('`status`=1',$datalist['id']);
$zfarr = array(
'status' =>1,
'nowcourseid' => 0,
'nowcheckid' => NULL,
'nowcheckname' => NULL,
'nstatustext' => '尹再伟处理同意',
);
m('flow_bill')->update($zfarr,'mid='.$datalist['id'].'');
$addarr = array(
'table' => 'c_fininfom_oafk',
'mid' => $datalist['id'],
'status' => 1,
'statusname' => '同意',
'name' => '出纳付款',
'courseid' => 176,
'optdt' => date("Y-m-d H:i:s"),
'explain' => '系统自动确认',
'ip' => '0.0.0.0',
'web' =>'Chrome',
'checkname' =>'尹再伟',
'checkid' =>1085,
'modeid' =>94,
'color' =>'green',
'valid' =>1,
'step' =>5,
'qmimg' =>NULL,
'iszb' =>0
);
m('flow_log')->insert($addarr);
echo '成功';
}
}else{
$key = ['FSRCBILLNO','FBillNo','FDOCUMENTSTATUS','FPAYTOTALAMOUNTFOR','FPOSTDATE' ];
$new_array = array();
foreach($array as $k=>$v) {
$new_array= array_combine($key,$v);
}
$fbillno=$new_array['FSRCBILLNO'];
$datalist = $this->db->getone('[Q]c_fininfom_oafk',"`fbillno`='".$fbillno."'",'id,fbillno,amountOfThisPayment');
if($new_array['FDOCUMENTSTATUS']=='C'){
$payflow = $this->db->getone('[Q]finifom_oafk_paymentflow',"`fbillno`='".$new_array['FBillNo']."'",'id,fbillno');
if(!$payflow ){
$paymentflow=array(
'fsrcbillno' =>$new_array['FSRCBILLNO'],
'fbillno' =>$new_array['FBillNo'],
'fpaytotalamountfor' =>$new_array['FPAYTOTALAMOUNTFOR'],
'mid' =>$datalist['id'],
'date' =>substr($new_array['FPOSTDATE'],0,strpos($new_array['FPOSTDATE'], 'T'))
);
m('finifom_oafk_paymentflow')->insert($paymentflow);
}
if($datalist['amountOfThisPayment']==$new_array['FPAYTOTALAMOUNTFOR']){
m('c_fininfom_oafk')->update('`status`=1',$datalist['id']);
$zfarr = array(
'status' =>1,
'nowcourseid' => 0,
'nowcheckid' => NULL,
'nowcheckname' => NULL,
'nstatustext' => '尹再伟处理同意',
);
m('flow_bill')->update($zfarr,'mid='.$datalist['id'].'');
$addarr = array(
'table' => 'c_fininfom_oafk',
'mid' => $datalist['id'],
'status' => 1,
'statusname' => '同意',
'name' => '出纳付款',
'courseid' => 176,
'optdt' => date("Y-m-d H:i:s"),
'explain' => '系统自动确认',
'ip' => '0.0.0.0',
'web' =>'Chrome',
'checkname' =>'尹再伟',
'checkid' =>1085,
'modeid' =>94,
'color' =>'green',
'valid' =>1,
'step' =>5,
'qmimg' =>NULL,
'iszb' =>0
);
m('flow_log')->insert($addarr);
echo "成功1";
}
}
}
}
}
//登陆
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.ExecuteBillQuery.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;
}
//构造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
<?php
/**
* 预付款申请接口
* Class opencatClassAction
*/
class openoayfkClassAction extends openapiAction
{
public function __call($name, $arguments)
{
$msg = $name.' action not found';
return $this->showreturn([],$msg,'201');
}
//预付款申请列表
public function listAction(){
$sql = 'select id,fbillno,status from [Q]c_fininfom_oayfk where status=0 and fbillno is NOT null';
$dataarr = $this->db->getall($sql);
foreach ($dataarr as $key => $value) {
$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);
$data_model='{
"FormId": "AP_PAYBILL",
"FieldKeys": "FSRCBILLNO,FBillNo,FDOCUMENTSTATUS,FPAYTOTALAMOUNTFOR,FPOSTDATE ",
"FilterString": "",
"OrderString": "",
"TopRowCount": 0,
"StartRow": 0,
"Limit": 0
}';
$model=json_decode($data_model,true);
$model['FilterString']="FSRCBILLNO ="."'".$value['fbillno']."'";
$data_model=json_encode($model);
$data = array(
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_save($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
if(count($array)>1){
$key = ['FSRCBILLNO','FBillNo','FDOCUMENTSTATUS','FPAYTOTALAMOUNTFOR','FPOSTDATE' ];
$new_array = array();
foreach($array as $k=>$v) {
$new_array[$k] = array_combine($key,$v);
}
// 计算金钱
$sum = 0;
foreach($new_array as $ke =>$item){
if($item['FDOCUMENTSTATUS']=='C'){
$sum += (int)$item['FPAYTOTALAMOUNTFOR'];
$payflow = $this->db->getone('[Q]finifom_oayfk_paymentflow',"`fbillno`='".$new_array[$ke]['FBillNo']."'",'id,fbillno');
$fbillno=$new_array['FSRCBILLNO'];
$datalist = $this->db->getone('[Q]c_fininfom_oayfk',"`fbillno`='".$value['fbillno']."'",'id,fbillno,amountOfThisPayment');
if(!$payflow ){
$paymentflow=array(
'fsrcbillno' =>$new_array[$ke]['FSRCBILLNO'],
'fbillno' =>$new_array[$ke]['FBillNo'],
'fpaytotalamountfor' =>$new_array[$ke]['FPAYTOTALAMOUNTFOR'],
'mid' =>$datalist['id'],
'date' =>substr($new_array[$ke]['FPOSTDATE'],0,strpos($new_array[$ke]['FPOSTDATE'], 'T'))
);
m('finifom_oayfk_paymentflow')->insert($paymentflow);
}
}
}
if($datalist['amountOfThisPayment']==$sum){
m('c_fininfom_oayfk')->update('`status`=1',$datalist['id']);
$zfarr = array(
'status' =>1,
'nowcourseid' => 0,
'nowcheckid' => NULL,
'nowcheckname' => NULL,
'nstatustext' => '尹再伟处理同意',
);
m('flow_bill')->update($zfarr,'mid='.$datalist['id'].'');
$addarr = array(
'table' => 'c_fininfom_oayfk',
'mid' => $datalist['id'],
'status' => 1,
'statusname' => '同意',
'name' => '出纳付款',
'courseid' => 310,
'optdt' => date("Y-m-d H:i:s"),
'explain' => '系统自动确认',
'ip' => '0.0.0.0',
'web' =>'Chrome',
'checkname' =>'尹再伟',
'checkid' =>1085,
'modeid' =>103,
'color' =>'green',
'valid' =>1,
'step' =>5,
'qmimg' =>NULL,
'iszb' =>0
);
m('flow_log')->insert($addarr);
echo '成功';
}
}else{
$key = ['FSRCBILLNO','FBillNo','FDOCUMENTSTATUS','FPAYTOTALAMOUNTFOR','FPOSTDATE' ];
$new_array = array();
foreach($array as $k=>$v) {
$new_array= array_combine($key,$v);
}
$fbillno=$new_array['FSRCBILLNO'];
$datalist = $this->db->getone('[Q]c_fininfom_oayfk',"`fbillno`='".$fbillno."'",'id,fbillno,amountOfThisPayment');
if($new_array['FDOCUMENTSTATUS']=='C'){
$payflow = $this->db->getone('[Q]finifom_oayfk_paymentflow',"`fbillno`='".$new_array['FBillNo']."'",'id,fbillno');
if(!$payflow ){
$paymentflow=array(
'fsrcbillno' =>$new_array['FSRCBILLNO'],
'fbillno' =>$new_array['FBillNo'],
'fpaytotalamountfor' =>$new_array['FPAYTOTALAMOUNTFOR'],
'mid' =>$datalist['id'],
'date' =>substr($new_array['FPOSTDATE'],0,strpos($new_array['FPOSTDATE'], 'T'))
);
m('finifom_oayfk_paymentflow')->insert($paymentflow);
}
if($datalist['amountOfThisPayment']==$new_array['FPAYTOTALAMOUNTFOR']){
m('c_fininfom_oayfk')->update('`status`=1',$datalist['id']);
$zfarr = array(
'status' =>1,
'nowcourseid' => 0,
'nowcheckid' => NULL,
'nowcheckname' => NULL,
'nstatustext' => '尹再伟处理同意',
);
m('flow_bill')->update($zfarr,'mid='.$datalist['id'].'');
$addarr = array(
'table' => 'c_fininfom_oayfk',
'mid' => $datalist['id'],
'status' => 1,
'statusname' => '同意',
'name' => '出纳付款',
'courseid' => 310,
'optdt' => date("Y-m-d H:i:s"),
'explain' => '系统自动确认',
'ip' => '0.0.0.0',
'web' =>'Chrome',
'checkname' =>'尹再伟',
'checkid' =>1085,
'modeid' =>103,
'color' =>'green',
'valid' =>1,
'step' =>5,
'qmimg' =>NULL,
'iszb' =>0
);
m('flow_log')->insert($addarr);
echo "成功1";
}
}
}
}
}
//登陆
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.ExecuteBillQuery.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;
}
//构造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
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论