提交 ba72f565 authored 作者: chengye's avatar chengye

电费付款接口调整

上级 fb2aa69a
<?php
/**
* 来自:信呼开发团队
* 作者:磐石(rainrock)
* 网址:http://www.rockoa.com/
* 系统默认配置文件,请不要去修改
* 要修改配置文件在:webmain/webmainConfig.php
*/
//调整session为redis
ini_set('session.save_handler', 'redis');
ini_set('session.save_path', 'tcp://192.168.1.71:6379');
ini_set('session.cookie_path', '/');
ini_set('session.cookie_domain', 'gonn.tech');
ini_set('session.cookie_lifetime', '7200');
@session_start();
if(function_exists('date_default_timezone_set'))date_default_timezone_set('Asia/Shanghai'); //设置默认时区
header('Content-Type:text/html;charset=utf-8');
define('ROOT_PATH',str_replace('\\','/',dirname(dirname(__FILE__)))); //系统跟目录路径
include_once(''.ROOT_PATH.'/include/rockFun.php');
include_once(''.ROOT_PATH.'/include/Chajian.php');
include_once(''.ROOT_PATH.'/include/class/rockClass.php');
$rock = new rockClass();
$db = null;
$smarty = false;
define('HOST', $rock->host);
define('REWRITE', 'true');
if(!defined('PROJECT'))define('PROJECT', $rock->get('p', 'webmain'));
if(!defined('ENTRANCE'))define('ENTRANCE', 'index');
$config = array(
'title' => '信呼',
'url' => '',
'urly' => 'http://www.rockoa.com/', //官网域名地址,修改后就无法提供在线升级了。
'db_host' => '127.0.0.1',
'db_user' => 'root',
'db_pass' => '',
'db_base' => '',
'perfix' => '',
'qom' => '',
'highpass' => '',
'install' => false,
'version' => require('version.php'),
'path' => 'index',
'updir' => 'upload',
'dbencrypt' => false,
'sqllog' => false,
'checksign' => false, //列表请求是否验证
'memory_limit' => '', //运行内存大小
'timeout' => -1, //抄送时间(秒),-1默认的
'db_drive' => 'mysqli', //数据库操作驱动
'db_engine' => 'MyISAM', //数据库默认引擎
'debug' => true, //默认debug模式
'reim_show' => true, //首页是否显示REIM
'mobile_show' => true, //首页是否显示手机版
'accesslogs' => false, //是否记录访问日志和限制IP
'upurl' => '', //上传文件附件地址(还不能使用)
'authorkey' => '', //系统授权的key,请联系官网获取
'companymode' => false, //是否开启多单位模式切换
'encrypt_key' => 'INJq4HXEGI',
'redis_host' => '192.168.1.71',
'redis_port' => 6379,
'base_url' => 'http://chengye-dev-jz.gonn.tech/'
);
//引入配置文件
$_confpath = $rock->strformat('?0/?1/?1Config.php', ROOT_PATH, PROJECT);
if(file_exists($_confpath)){
$_tempconf = require($_confpath);
foreach($_tempconf as $_tkey=>$_tvs)$config[$_tkey] = $_tvs;
if(isempt($config['url']))$config['url'] = $rock->url();
if(!isempt($config['memory_limit']) && function_exists('ini_set'))
ini_set('memory_limit', $config['memory_limit']);
if($config['timeout']>-1 && function_exists('set_time_limit'))set_time_limit($config['timeout']);
}
$_confpath = ''.ROOT_PATH.'/config/author.php';
if(file_exists($_confpath)){
$config['authorkey'] = require($_confpath);
}
define('DEBUG', $config['debug']);
error_reporting(DEBUG ? E_ALL : 0);
define('TITLE', $config['title']);
define('URL', $config['url']);
define('URLY', $config['urly']);
define('PATH', $config['path']);
define('DB_DRIVE', $config['db_drive']);
define('DB_HOST', $config['db_host']);
define('DB_USER', $config['db_user']);
define('DB_PASS', $config['db_pass']);
define('DB_BASE', $config['db_base']);
define('UPDIR', $config['updir']);
define('PREFIX', $config['perfix']);
define('QOM', $config['qom']);
define('VERSION', $config['version']);
define('HIGHPASS', $config['highpass']);
define('SYSURL', ''.URL.PATH.'.php');
define('UPURL', $config['upurl']);
define('ISMORECOM', $config['companymode']);
define('ENCRYPT_KEY',$config['encrypt_key']);
$_confpath = ''.ROOT_PATH.'/config/iplogs.php'; //这个用来限制IP访问的
if(file_exists($_confpath))include_once($_confpath);
$rock->initRock();
<?php
return
[
'encrypt_key'=>'INJq4HXEGI',
'base_url'=>'http://jz-test.gonn.tech/',
'redis_host'=>'192.168.1.71',
'redis_port'=>'6379',
'url'=>'http://oa-test.gonn.tech/',
'title'=>'广厦网络OA办公系统(测试-test)',
'apptitle'=>'广厦网络OA(测试-test)',
'db_host'=>'192.168.1.71',
'db_user'=>'root',
'db_pass'=>'aLN%4Jx7ZsmsoMlOB0XEd7',
'db_base'=>'oa',
];
\ No newline at end of file
<?php
return
[
'save_handler'=>'redis',
'save_path'=>'tcp://192.168.1.71:6379',
'cookie_path'=>'/',
'cookie_domain'=>'gonn.tech',
'cookie_lifetime'=>'7200',
];
\ No newline at end of file
<?php
return
[
'encrypt_key'=>'INJq4HXEGI',
'base_url'=>'http://chengye-dev-jz.gonn.tech/',
'redis_host'=>'192.168.1.71',
'redis_port'=>'6379',
'url' => 'http://chengye-dev.gonn.tech/', //系统URL'title' => '广厦网络OA办公系统(chengye-dev)', //系统默认标题
'apptitle' => '广厦网络OA(chengye-dev)', //APP上和手机网页版上的标题
'db_host' => '192.168.1.71:33336', //数据库地址
'db_user' => 'chengye', //数据库用户名
'db_pass' => 'chengye.123', //数据库密码
'db_base' => 'chengye_oa', //数据库名称
];
\ No newline at end of file
<?php
class emfkDetailsClassModel extends Model
{
public function initModel()
{
$this->settable('c_emfk_details');
}
}
\ No newline at end of file
<?php
class emfkClassModel extends Model
{
public function initModel()
{
$this->settable('c_emfk');
}
}
\ No newline at end of file
<?php
class flow_emfkClassModel extends flowModel
{
const PAYMENT_STATUS = [
0 => '待审核',
1 => '未提交',
2 => '审核中',
3 => '已付款',
4 => '已付款 缺发票',
5 => '已付款 发票已上传',
7 => '被驳回',
8 => '已确收',
9 => '审核失败',
];
protected function flowcheckfinsh($zt)
{
$this->sendMess(1,3);
}
/**
* 审核时触发
* @param $zt 1同意 2拒绝
* @param $sm
*/
protected function flowcheckafter($zt, $sm){
if($zt == 2) $this->sendMess(0,9);
$this->updatestatus(5);
}
/**
* @param int $messType 动作
* @param int $status 状态
*/
private function sendMess($messType = 0,$status = 3){
$url = 'http://chengye-dev-jz.gonn.tech/v2/payment?key=';
$key = substr(md5(getconfig('openkey').date('Y-m-d')),0,12);
$url = $url.$key.'&action='.$messType; //接口地址
$url .= '&numb='.$this->rs['docnum'];
$url .= '&status='.$status;
$url .= '&mes='.'';
$res = curlGet($url);
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -144,70 +144,5 @@ class flow_oayfkClassModel extends flowModel
m('c_fund_detail')->insert($fund_detail);
}
}
//流程全部完成后调用
protected function flowcheckfinsh($zt){
$mid= $this->rs['id'];
$datafk = m('c_fund_details_yfk')->getall('mid='.$mid);
foreach ($datafk as $key => $value) {
// 扣除账户余额 c_fund_account account_balance
$cbzxid= $value['cbzx_code'];
$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']-$value['charge_amount'],
);
$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']+$value['charge_amount'],
);
m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
//账户明细 c_account_detail
$account_detail=array(
'account' => $data['name'],
'opt_type' => 2,
'amount' =>$value['charge_amount'],
'trans_numb' => $this->rs['docnum'],
'account_balance' => $data['account_balance']-$value['charge_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['payee'],
'trans_amount' =>$value['charge_amount'],
'business_type' =>10,
'opt_type' =>2,
'account_balance'=>$data['account_balance']-$value['charge_amount'],
'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'],
);
m('c_fund_detail')->insert($fund_detail);
}
}
}
\ No newline at end of file
<?php
class flow_supplierClassModel extends flowModel
{
public function initModel()
{
$this->statearr = c('array')->strtoarray('停用|#888888,启用|green');
$this->statarr = c('array')->strtoarray('否|#888888,是|#ff6600');
}
//高级搜索下
public function flowsearchfields()
{
$arr[] = array('name'=>'所属人...','fields'=>'uid');
$arr[] = array('name'=>'创建人...','fields'=>'createid');
return $arr;
}
public function flowrsreplace($rs, $lx=0)
{
//详情时,移动端
if($lx==1 && $this->rock->ismobile()){
if(!isempt($rs['mobile']))$rs['mobile']='<a onclick="return callPhone(this)" href="tel:'.$rs['mobile'].'">'.$rs['mobile'].'</a>';
if(!isempt($rs['tel']))$rs['tel']='<a onclick="return callPhone(this)" href="tel:'.$rs['tel'].'">'.$rs['tel'].'</a>';
}
if($rs['supplier_group']){
$data=$this->db->getone('oa_option',"num='".$rs['supplier_group']."'");
$rs['supplier_group']=$data['name'];
}
if($rs['company_classify']){
$data=$this->db->getone('oa_option',"num='".$rs['company_classify']."'");
$rs['company_classify']=$data['name'];
}
if($rs['company_nature']){
$data=$this->db->getone('oa_option',"num='".$rs['company_nature']."'");
$rs['company_nature']=$data['name'];
}
if($rs['company_scale']){
$data=$this->db->getone('oa_option',"num='".$rs['company_scale']."'");
$rs['company_scale']=$data['name'];
}
if($rs['correspond_org_id']){
$data=$this->db->getone('oa_option',"num='".$rs['correspond_org_id']."'");
$rs['correspond_org_id']=$data['name'];
}
if($rs['pay_currency']){
$data=$this->db->getone('oa_option',"num='".$rs['pay_currency']."'");
$rs['pay_currency']=$data['name'];
}
if($rs['settle_type']){
$data=$this->db->getone('oa_option',"num='".$rs['settle_type']."'");
$rs['settle_type']=$data['name'];
}
if($rs['pay_condition']){
$data=$this->db->getone('oa_option',"num='".$rs['pay_condition']."'");
$rs['pay_condition']=$data['name'];
}
if($rs['tax_type']){
$data=$this->db->getone('oa_option',"num='".$rs['tax_type']."'");
$rs['tax_type']=$data['name'];
}
if($rs['tend_type']){
$data=$this->db->getone('oa_option',"num='".$rs['tend_type']."'");
$rs['tend_type']=$data['name'];
}
if($rs['tax_rate']){
$data=$this->db->getone('oa_option',"num='".$rs['tax_rate']."'");
$rs['tax_rate']=$data['name'];
}
if($rs['bank_currency']){
$data=$this->db->getone('oa_option',"num='".$rs['bank_currency']."'");
$rs['bank_currency']=$data['name'];
}
return $rs;
}
//提交时调用
protected function flowsubmit($na, $sm){
var_dump($sm);die;
}
//审核完成后调用
// protected function flowcheckafter($zt, $sm){
// $data=$this->db->getrows('oa_supplier_bank_info',"mid='".$this->rs['id']."'");
// $arr=[];
// foreach ($data as $k=> $value) {
// foreach ($value as $key => $val) {
// switch ($key) {
// case 'open_bank_name':
// $arr['FT_BD_CUSTBANK'][$k]['FOpenBankName']=$val;
// break;
// case 'bank_code':
// $arr['FT_BD_CUSTBANK'][$k]['FBANKCODE']=$val;
// break;
// case 'bank_holder':
// $arr['FT_BD_CUSTBANK'][$k]['FBankHolder']=$val;
// break;
// case 'open_address':
// $arr['FT_BD_CUSTBANK'][$k]['FOpenAddressRec']=$val;
// }
// }
// }
// $cloudUrl = "http://192.168.1.211/k3cloud/";
// //登陆参数
// $data = array(
// '5d64e2f4ecb139',//帐套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);
// $name=$this->rs['name'];//供应商名称
// $supply_classify=$this->rs['supply_classify'];//供应类别
// $supplier_group=$this->rs['supplier_group'];//供应商分组
// $company_classify=$this->rs['company_classify'];//公司类别
// $company_nature=$this->rs['company_nature'];//公司性质
// $company_scale=$this->rs['company_scale'];//公司规模
// $web_site=$this->rs['web_site'];//公司网址
// $settle_type=$this->rs['settle_type'];//结算方式
// $pay_condition=$this->rs['pay_condition'];// 付款条件
// $tend_type=$this->rs['tend_type'];// *经营类型
// $tax_type=$this->rs['tax_type'];// 税分类
// $pay_advance_amount=$this->rs['pay_advance_amount'];// 单次预付额度
// $tax_register_code=$this->rs['tax_register_code'];// 税务登记号
// $finance_desc=$this->rs['finance_desc'];// 描述
// $found_date=$this->rs['found_date'];// 创立日期
// $legal_person=$this->rs['legal_person'];// 法人代表
// $register_fund=$this->rs['register_fund'];// 注册资金(万元)
// $register_code=$this->rs['register_code'];// 工商登记号
// $tend_permit=$this->rs['tend_permit'];// 生产经营许可证
// $social_cre_code=$this->rs['social_cre_code'];// 统一社会信用代码
// $register_address=$this->rs['register_address'];// *注册地址
// $data_model ='{
// "Creator": "",
// "NeedUpDateFields": [],
// "NeedReturnFields": [],
// "IsDeleteEntry": "true",
// "SubSystemId": "",
// "IsVerifyBaseDataField": "false",
// "IsEntryBatchFill": "true",
// "ValidateFlag": "true",
// "NumberSearch": "true",
// "InterationFlags": "",
// "IsAutoSubmitAndAudit": "false",
// "Model": {
// "FSupplierId": 0,
// "FCreateOrgId": {
// "FNumber": "0000"
// },
// "FUseOrgId": {
// "FNumber": "0000"
// },
// "FName": "供应商名称",
// "FShortName": "供应商简称",
// "FBaseInfo": {
// "FWebSite": "",
// "FFoundDate": "2019-12-26 00:00:00",
// "FLegalPerson": "",
// "FRegisterFund": 100.0,
// "FRegisterCode": "2019gongshang",
// "FSOCIALCRECODE": "2019shehui",
// "FTendPermit": "2019shengchan",
// "FRegisterAddress": "注册地址",
// "FSupplyClassify": "CG",
// "FCompanyClassify": {
// "FNumber": "GSLL01_SYS"
// },
// "FCompanyNature": {
// "FNumber": "GSXZ001_SYS"
// },
// "FCompanyScale": {
// "FNumber": "GSGM01_SYS"
// }
// },
// "FBusinessInfo": {
// "FSettleTypeId": {
// "FNumber": "JSFS02_SYS"
// },
// "FVmiBusiness": false,
// "FEnableSL": false
// },
// "FFinanceInfo": {
// "FPayCurrencyId": {
// "FNumber": "PRE001"
// },
// "FPayCondition": {
// "FNumber": "FKTJ01_SYS"
// },
// "FPayAdvanceAmount": 1111.0,
// "FTaxType": {
// "FNumber": "SFL02_SYS"
// },
// "FTaxRegisterCode": "111111",
// "FInvoiceType": "1",
// "FTaxRateId": {
// "FNUMBER": "SL02_SYS"
// },
// "FFinanceDesc": "描述"
// }
// }
// }';
// $model=json_decode($data_model,true);
// // $supplier_group//供应商分组
// // // $tend_type// *经营类型
// $model['Model']['FBankInfo']=$arr['FT_BD_CUSTBANK'];
// $model['Model']['FName']=$name;
// $model['Model']['FShortName']=$name;
// // $model['Model']['FBaseInfo']['FSupplyClassify']=$supply_classify;
// $model['Model']['FBaseInfo']['FCompanyClassify']['FNumber']=isset($company_classify)?$company_classify:'';
// $model['Model']['FBaseInfo']['FCompanyNature']['FNumber']=isset($company_nature)?$company_nature:'';
// $model['Model']['FBaseInfo']['FCompanyScale']['FNumber']=isset($company_scale)?$company_scale:'';
// $model['Model']['FBaseInfo']['FWebSite']=isset($web_site)?$web_site:'';
// $model['Model']['FBusinessInfo']['FSettleTypeId']['FNumber']=isset($settle_type)?$settle_type:'';
// $model['Model']['FFinanceInfo']['FPayCondition']['FNumber']=isset($pay_condition)?$pay_condition:'';
// $model['Model']['FFinanceInfo']['FTaxType']['FNumber']=isset($tax_type)?$tax_type:'';
// $model['Model']['FFinanceInfo']['FPayAdvanceAmount']=isset($pay_advance_amount)?$pay_advance_amount:'';
// $model['Model']['FFinanceInfo']['FTaxRegisterCode']=isset($tax_register_code)?$tax_register_code:'';
// $model['Model']['FFinanceInfo']['FFinanceDesc']=isset($finance_desc)?$finance_desc:'';
// $model['Model']['FBaseInfo']['FFoundDate']=isset($found_date)?$found_date:'';
// $model['Model']['FBaseInfo']['FLegalPerson']=isset($legal_person)?$legal_person:'';
// $model['Model']['FBaseInfo']['FRegisterFund']=isset($register_fund)?$register_fund:'';
// $model['Model']['FBaseInfo']['FRegisterCode']=isset($register_code)?$register_code:'';
// $model['Model']['FBaseInfo']['FTendPermit']=isset($tend_permit)?$tend_permit:'';
// $model['Model']['FBaseInfo']['FSOCIALCRECODE']=isset($social_cre_code)?$social_cre_code:'';
// $model['Model']['FBaseInfo']['FRegisterAddress']=isset($register_address)?$register_address:'';
// $data_model=json_encode($model);
// $data = array(
// 'BD_Supplier',//业务对象标识FormId
// $data_model//具体Json字串
// );
// $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']){
// $endtime = microtime(true);
// $num=$array['Result']['Number'];
// $this->update("`number`='$num'", $this->rs['id']);
// $log='供应商编号:'.$array['Result']['Number'].'保存接口成功 '.'执行时间:'.($endtime-$starttime).' s'."\r\n";
// $file_write = file_put_contents('test.txt',$log,FILE_APPEND);
// $num=$array['Result']['Number'];
// $this->update("`contract_number`='$num'", $this->rs['id']);
// $this->supplier_submit($cloudUrl,$cookie_jar,$array['Result']['Id'],$array['Result']['Number']);
// $this->supplier_audit($cloudUrl,$cookie_jar,$array['Result']['Id'],$array['Result']['Number']);
// }else{
// $log='供应商名称:'.$name.'保存接口失败 '.$array['Result']['ResponseStatus']['Errors'][0]['Message'];
// $file_write = file_put_contents('supplier.txt',$log,FILE_APPEND);
// }
// }
public function supplier_submit($cloudUrl,$cookie_jar,$id,$number){
$start_time = microtime(true);
$data_model ="{
'CreateOrgId': 0,
'Numbers': [],
'Ids': $id,
'SelectedPostId': 0
}";
$data = array(
'BD_Supplier',//业务对象标识FormId
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_submit($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
$end_time = microtime(true);
if($array['Result']['ResponseStatus']['IsSuccess']){
$log='供应商编号:'.$number.'提交接口成功 '.' 执行时间:'.($end_time-$start_time).' s'."\r\n";
}else{
$log='供应商编号:'.$number.'提交接口失败 '.$array['Result']['ResponseStatus']['Errors'][0]['Message'];
}
$file_write = file_put_contents('supplier.txt',$log,FILE_APPEND);
}
public function supplier_audit($cloudUrl,$cookie_jar,$id,$number){
$start_time = microtime(true);
$data_model ="{
'CreateOrgId': 0,
'Numbers': [],
'Ids': $id,
'InterationFlags': ''
}";
$data = array(
'BD_Supplier',//业务对象标识FormId
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_audit($cloudUrl,$post_content,$cookie_jar);
$end_time = microtime(true);
$array = json_decode($result,true);
if($array['Result']['ResponseStatus']['IsSuccess']){
$log='供应商编号:'.$number.'审核接口成功 '.' 执行时间:'.($end_time-$start_time).' s'."\r\n";
}else{
$log='供应商编号:'.$number.'审核接口失败 '.$array['Result']['ResponseStatus']['Errors'][0]['Message'];
}
$file_write = file_put_contents('supplier.txt',$log,FILE_APPEND);
}
//登陆
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;
}
//构造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;
}
}
<?php
class flow_supplierClassModel extends flowModel
{
public function initModel()
{
$this->statearr = c('array')->strtoarray('停用|#888888,启用|green');
$this->statarr = c('array')->strtoarray('否|#888888,是|#ff6600');
}
//高级搜索下
public function flowsearchfields()
{
$arr[] = array('name'=>'所属人...','fields'=>'uid');
$arr[] = array('name'=>'创建人...','fields'=>'createid');
return $arr;
}
public function flowrsreplace($rs, $lx=0)
{
//详情时,移动端
if($lx==1 && $this->rock->ismobile()){
if(!isempt($rs['mobile']))$rs['mobile']='<a onclick="return callPhone(this)" href="tel:'.$rs['mobile'].'">'.$rs['mobile'].'</a>';
if(!isempt($rs['tel']))$rs['tel']='<a onclick="return callPhone(this)" href="tel:'.$rs['tel'].'">'.$rs['tel'].'</a>';
}
if($rs['supplier_group']){
$data=$this->db->getone('oa_option',"num='".$rs['supplier_group']."'");
$rs['supplier_group']=$data['name'];
}
if($rs['company_classify']){
$data=$this->db->getone('oa_option',"num='".$rs['company_classify']."'");
$rs['company_classify']=$data['name'];
}
if($rs['company_nature']){
$data=$this->db->getone('oa_option',"num='".$rs['company_nature']."'");
$rs['company_nature']=$data['name'];
}
if($rs['company_scale']){
$data=$this->db->getone('oa_option',"num='".$rs['company_scale']."'");
$rs['company_scale']=$data['name'];
}
if($rs['correspond_org_id']){
$data=$this->db->getone('oa_option',"num='".$rs['correspond_org_id']."'");
$rs['correspond_org_id']=$data['name'];
}
if($rs['pay_currency']){
$data=$this->db->getone('oa_option',"num='".$rs['pay_currency']."'");
$rs['pay_currency']=$data['name'];
}
if($rs['settle_type']){
$data=$this->db->getone('oa_option',"num='".$rs['settle_type']."'");
$rs['settle_type']=$data['name'];
}
if($rs['pay_condition']){
$data=$this->db->getone('oa_option',"num='".$rs['pay_condition']."'");
$rs['pay_condition']=$data['name'];
}
if($rs['tax_type']){
$data=$this->db->getone('oa_option',"num='".$rs['tax_type']."'");
$rs['tax_type']=$data['name'];
}
if($rs['tend_type']){
$data=$this->db->getone('oa_option',"num='".$rs['tend_type']."'");
$rs['tend_type']=$data['name'];
}
if($rs['tax_rate']){
$data=$this->db->getone('oa_option',"num='".$rs['tax_rate']."'");
$rs['tax_rate']=$data['name'];
}
if($rs['bank_currency']){
$data=$this->db->getone('oa_option',"num='".$rs['bank_currency']."'");
$rs['bank_currency']=$data['name'];
}
return $rs;
}
//提交时调用
protected function flowsubmit($na, $sm){
var_dump($sm);die;
}
//审核完成后调用
// protected function flowcheckafter($zt, $sm){
// $data=$this->db->getrows('oa_supplier_bank_info',"mid='".$this->rs['id']."'");
// $arr=[];
// foreach ($data as $k=> $value) {
// foreach ($value as $key => $val) {
// switch ($key) {
// case 'open_bank_name':
// $arr['FT_BD_CUSTBANK'][$k]['FOpenBankName']=$val;
// break;
// case 'bank_code':
// $arr['FT_BD_CUSTBANK'][$k]['FBANKCODE']=$val;
// break;
// case 'bank_holder':
// $arr['FT_BD_CUSTBANK'][$k]['FBankHolder']=$val;
// break;
// case 'open_address':
// $arr['FT_BD_CUSTBANK'][$k]['FOpenAddressRec']=$val;
// }
// }
// }
// $cloudUrl = "http://192.168.1.211/k3cloud/";
// //登陆参数
// $data = array(
// '5d64e2f4ecb139',//帐套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);
// $name=$this->rs['name'];//供应商名称
// $supply_classify=$this->rs['supply_classify'];//供应类别
// $supplier_group=$this->rs['supplier_group'];//供应商分组
// $company_classify=$this->rs['company_classify'];//公司类别
// $company_nature=$this->rs['company_nature'];//公司性质
// $company_scale=$this->rs['company_scale'];//公司规模
// $web_site=$this->rs['web_site'];//公司网址
// $settle_type=$this->rs['settle_type'];//结算方式
// $pay_condition=$this->rs['pay_condition'];// 付款条件
// $tend_type=$this->rs['tend_type'];// *经营类型
// $tax_type=$this->rs['tax_type'];// 税分类
// $pay_advance_amount=$this->rs['pay_advance_amount'];// 单次预付额度
// $tax_register_code=$this->rs['tax_register_code'];// 税务登记号
// $finance_desc=$this->rs['finance_desc'];// 描述
// $found_date=$this->rs['found_date'];// 创立日期
// $legal_person=$this->rs['legal_person'];// 法人代表
// $register_fund=$this->rs['register_fund'];// 注册资金(万元)
// $register_code=$this->rs['register_code'];// 工商登记号
// $tend_permit=$this->rs['tend_permit'];// 生产经营许可证
// $social_cre_code=$this->rs['social_cre_code'];// 统一社会信用代码
// $register_address=$this->rs['register_address'];// *注册地址
// $data_model ='{
// "Creator": "",
// "NeedUpDateFields": [],
// "NeedReturnFields": [],
// "IsDeleteEntry": "true",
// "SubSystemId": "",
// "IsVerifyBaseDataField": "false",
// "IsEntryBatchFill": "true",
// "ValidateFlag": "true",
// "NumberSearch": "true",
// "InterationFlags": "",
// "IsAutoSubmitAndAudit": "false",
// "Model": {
// "FSupplierId": 0,
// "FCreateOrgId": {
// "FNumber": "0000"
// },
// "FUseOrgId": {
// "FNumber": "0000"
// },
// "FName": "供应商名称",
// "FShortName": "供应商简称",
// "FBaseInfo": {
// "FWebSite": "",
// "FFoundDate": "2019-12-26 00:00:00",
// "FLegalPerson": "",
// "FRegisterFund": 100.0,
// "FRegisterCode": "2019gongshang",
// "FSOCIALCRECODE": "2019shehui",
// "FTendPermit": "2019shengchan",
// "FRegisterAddress": "注册地址",
// "FSupplyClassify": "CG",
// "FCompanyClassify": {
// "FNumber": "GSLL01_SYS"
// },
// "FCompanyNature": {
// "FNumber": "GSXZ001_SYS"
// },
// "FCompanyScale": {
// "FNumber": "GSGM01_SYS"
// }
// },
// "FBusinessInfo": {
// "FSettleTypeId": {
// "FNumber": "JSFS02_SYS"
// },
// "FVmiBusiness": false,
// "FEnableSL": false
// },
// "FFinanceInfo": {
// "FPayCurrencyId": {
// "FNumber": "PRE001"
// },
// "FPayCondition": {
// "FNumber": "FKTJ01_SYS"
// },
// "FPayAdvanceAmount": 1111.0,
// "FTaxType": {
// "FNumber": "SFL02_SYS"
// },
// "FTaxRegisterCode": "111111",
// "FInvoiceType": "1",
// "FTaxRateId": {
// "FNUMBER": "SL02_SYS"
// },
// "FFinanceDesc": "描述"
// }
// }
// }';
// $model=json_decode($data_model,true);
// // $supplier_group//供应商分组
// // // $tend_type// *经营类型
// $model['Model']['FBankInfo']=$arr['FT_BD_CUSTBANK'];
// $model['Model']['FName']=$name;
// $model['Model']['FShortName']=$name;
// // $model['Model']['FBaseInfo']['FSupplyClassify']=$supply_classify;
// $model['Model']['FBaseInfo']['FCompanyClassify']['FNumber']=isset($company_classify)?$company_classify:'';
// $model['Model']['FBaseInfo']['FCompanyNature']['FNumber']=isset($company_nature)?$company_nature:'';
// $model['Model']['FBaseInfo']['FCompanyScale']['FNumber']=isset($company_scale)?$company_scale:'';
// $model['Model']['FBaseInfo']['FWebSite']=isset($web_site)?$web_site:'';
// $model['Model']['FBusinessInfo']['FSettleTypeId']['FNumber']=isset($settle_type)?$settle_type:'';
// $model['Model']['FFinanceInfo']['FPayCondition']['FNumber']=isset($pay_condition)?$pay_condition:'';
// $model['Model']['FFinanceInfo']['FTaxType']['FNumber']=isset($tax_type)?$tax_type:'';
// $model['Model']['FFinanceInfo']['FPayAdvanceAmount']=isset($pay_advance_amount)?$pay_advance_amount:'';
// $model['Model']['FFinanceInfo']['FTaxRegisterCode']=isset($tax_register_code)?$tax_register_code:'';
// $model['Model']['FFinanceInfo']['FFinanceDesc']=isset($finance_desc)?$finance_desc:'';
// $model['Model']['FBaseInfo']['FFoundDate']=isset($found_date)?$found_date:'';
// $model['Model']['FBaseInfo']['FLegalPerson']=isset($legal_person)?$legal_person:'';
// $model['Model']['FBaseInfo']['FRegisterFund']=isset($register_fund)?$register_fund:'';
// $model['Model']['FBaseInfo']['FRegisterCode']=isset($register_code)?$register_code:'';
// $model['Model']['FBaseInfo']['FTendPermit']=isset($tend_permit)?$tend_permit:'';
// $model['Model']['FBaseInfo']['FSOCIALCRECODE']=isset($social_cre_code)?$social_cre_code:'';
// $model['Model']['FBaseInfo']['FRegisterAddress']=isset($register_address)?$register_address:'';
// $data_model=json_encode($model);
// $data = array(
// 'BD_Supplier',//业务对象标识FormId
// $data_model//具体Json字串
// );
// $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']){
// $endtime = microtime(true);
// $num=$array['Result']['Number'];
// $this->update("`number`='$num'", $this->rs['id']);
// $log='供应商编号:'.$array['Result']['Number'].'保存接口成功 '.'执行时间:'.($endtime-$starttime).' s'."\r\n";
// $file_write = file_put_contents('test.txt',$log,FILE_APPEND);
// $num=$array['Result']['Number'];
// $this->update("`contract_number`='$num'", $this->rs['id']);
// $this->supplier_submit($cloudUrl,$cookie_jar,$array['Result']['Id'],$array['Result']['Number']);
// $this->supplier_audit($cloudUrl,$cookie_jar,$array['Result']['Id'],$array['Result']['Number']);
// }else{
// $log='供应商名称:'.$name.'保存接口失败 '.$array['Result']['ResponseStatus']['Errors'][0]['Message'];
// $file_write = file_put_contents('supplier.txt',$log,FILE_APPEND);
// }
// }
public function supplier_submit($cloudUrl,$cookie_jar,$id,$number){
$start_time = microtime(true);
$data_model ="{
'CreateOrgId': 0,
'Numbers': [],
'Ids': $id,
'SelectedPostId': 0
}";
$data = array(
'BD_Supplier',//业务对象标识FormId
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_submit($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
$end_time = microtime(true);
if($array['Result']['ResponseStatus']['IsSuccess']){
$log='供应商编号:'.$number.'提交接口成功 '.' 执行时间:'.($end_time-$start_time).' s'."\r\n";
}else{
$log='供应商编号:'.$number.'提交接口失败 '.$array['Result']['ResponseStatus']['Errors'][0]['Message'];
}
$file_write = file_put_contents('supplier.txt',$log,FILE_APPEND);
}
public function supplier_audit($cloudUrl,$cookie_jar,$id,$number){
$start_time = microtime(true);
$data_model ="{
'CreateOrgId': 0,
'Numbers': [],
'Ids': $id,
'InterationFlags': ''
}";
$data = array(
'BD_Supplier',//业务对象标识FormId
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_audit($cloudUrl,$post_content,$cookie_jar);
$end_time = microtime(true);
$array = json_decode($result,true);
if($array['Result']['ResponseStatus']['IsSuccess']){
$log='供应商编号:'.$number.'审核接口成功 '.' 执行时间:'.($end_time-$start_time).' s'."\r\n";
}else{
$log='供应商编号:'.$number.'审核接口失败 '.$array['Result']['ResponseStatus']['Errors'][0]['Message'];
}
$file_write = file_put_contents('supplier.txt',$log,FILE_APPEND);
}
//登陆
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;
}
//构造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;
}
}
......@@ -7,43 +7,40 @@
* Time: 0:17
*/
class openEmfkClassAction extends openapiAction
class openemfkClassAction extends openapiAction
{
public $data = [];
public $subdata = [];
public $model = 'c_emfk';
public $per = 'OA-EM-FK-';
public $ext = 'oa';
public $model = '';
const MODEL_NAME = 'emfk';
const FK_NUMB_PREFIX = 'EM-FK-';
const TABLE_NAME = 'c_emfk';
const DETAILS_TABLE_NAME = 'c_emfk_details';
const DB_PREFIX = 'oa';
public function initAction()
{
//post方式接收接口数据
$data = json_decode($_POST['data'], true);
if (empty($data)) $this->showreturn([], $_POST['data'], '201');
if (!empty($data['docnum'])) $this->data['docnum'] = $data['docnum']; //如果是编辑则携带编码
$user = $this->getUser($data['uname']); //获取用户信息
$data['applicant'] = $data['optname'] = $user['name'];
$this->subdata = $this->getSubData($data['details']);
if ($data['type'] == 1) {
$this->model = 'emfk';
$this->data['applicationdpt'] = $data['dept'];
};
//构建主表
$this->data[$this->model . 'name'] = $data['title'];
$this->data['payee'] = $data['payee'];
$this->data['paymentMethod'] = $data['payType'];
$this->data['applicant'] = $user['name'];
$this->data['fkorg'] = $data['payOrg'];
$this->data['paymentBy'] = $data['remarks'];
$this->data['fkinfo'] = $data['fkinfo'];
$this->data['applydt'] = $this->data['optdt'] = $this->data['applydate'] = $data['date'] ?: date('Y-m-d');
unset($data['details']);
unset($data['uname']);
$this->data = $data;
//构建主表其他信息
$this->data['applydt'] = $this->data['optdt'] = $data['date'] ?: date('Y-m-d');
$this->data['uid'] = $this->data['optid'] = $user['id'];
$this->data['docnum'] = $this->data['docnum'] ?: $this->getDocNum();
$this->data['status'] = 0;
$this->subdata = $this->getSubData($data['details']);
$this->data['amountOfThisPayment'] = $this->AmountSum();
$this->data['amount'] = $this->AmountSum();
}
//返回不存在的接口方法
......@@ -56,19 +53,20 @@ class openEmfkClassAction extends openapiAction
//创建预付款单
public function createAction()
{
$id = m($this->model)->insert($this->data);
$model = m(self::TABLE_NAME);
$id =$model->insert($this->data);
if ($id) {
//插入子表数据
$smode = m($this->model . 'Detail');
$details = m(self::DETAILS_TABLE_NAME);
foreach ($this->subdata as $sub) {
$sub['mid'] = $id;
$sub['comid'] = 1;
$smode->insert($sub);
$details->insert($sub);
}
//启动流程
$this->goflow($id);
$this->showreturn(['numb' => $this->data['docnum'], 'id' => $id], '插入数据成功', '200');
} else $this->showreturn([], '插入数据失败', '201');
} else $this->showreturn([], $model->getLastSql(), '201');
}
public function updateAction()
......@@ -78,10 +76,10 @@ class openEmfkClassAction extends openapiAction
$where = 'id=' . $mid;
unset($this->data['docnum']);
$res = m($this->model)->update($this->data, $where);
$res = m(self::MODEL_NAME)->update($this->data, $where);
if (!$res) $this->showreturn([], '修改数据失败,数据字段异常或字段不匹配', '201');
$smode = m($this->model . 'Detail');
$details = m(self::DETAILS_TABLE_NAME);
//1.获取子表数据,子表数据必须要携带子表id
//2.查询所有子表ID 如果子表ID存在于 记录中则是修改 否则是新增
$scount = 0;
......@@ -89,15 +87,15 @@ class openEmfkClassAction extends openapiAction
if (empty($sub['id'])) { //插入操作
$sub['mid'] = $mid;
$sub['comid'] = 1;
$smode->insert($sub);
$details->insert($sub);
} else { //新增
//如果已经存在的子表数据则修改
if ($smode->getone('id=' . $sub['id'])) {
$smode->update($sub, 'id=' . $sub['id']);
if ($details->getone('id=' . $sub['id'])) {
$details->update($sub, 'id=' . $sub['id']);
} else {
$sub['mid'] = $mid;
$sub['comid'] = 1;
$smode->insert($sub);
$details->insert($sub);
}
}
$scount++;
......@@ -105,69 +103,66 @@ class openEmfkClassAction extends openapiAction
$this->showreturn([], '修改数据成功,子表数据成功修改' . $scount . '条记录', '200');
}
public function getUser($username)
private function getUser($username)
{
$where = "email='" . $username . "@gonn.com.cn'";
return $this->db->getone('oa_userinfo', $where);
}
public function getSubData($details = [])
private function getSubData($details = [])
{
$arr = [];
foreach ($details as $k => $d) {
if (!empty($d['id'])) $arr[$k]['id'] = $d['id'];
$arr[$k]['charge_type'] = $d['chargeType'];
$arr[$k]['charge_amount'] = $d['amount'];
$arr[$k]['cbzx_code'] = $d['projectNumber'];
$arr[$k]['contract_id'] = $d['contractNumber'];
$arr[$k]['receipt_id'] = $d['receipt'];
$arr[$k]['charge_type'] = $d['charge_type'];
$arr[$k]['amount'] = $d['amount'];
$arr[$k]['cbzxid'] = $d['cbzxid'];
}
return $arr;
}
//子表金额求和
public function AmountSum()
private function AmountSum()
{
$sum = 0;
foreach ($this->subdata as $v) {
$sum += $v['charge_amount'];
$sum += $v['amount'];
}
return $sum;
}
private function getDocNum()
{
$pre = 'OA-EM-FK-';
if ($this->model == 'yfk') $pre = 'OA-YFK-';
$cext = $pre . date("Ymd");
$where = "`docnum` like '%" . $cext . "%'";
$mode = m($this->model);
$ext = self::FK_NUMB_PREFIX . date("Ymd"); //编号前缀
$where = "`docnum` like '%" . $ext . "%'";
$mode = m(self::TABLE_NAME);
$data = $mode->getone($where, 'id,docnum', 'id desc');
$num = '001';
$num = '001'; //编号后缀
if ($data) {
$num = (int)substr($data['docnum'], strlen($cext)) + 1;
$num = (int)substr($data['docnum'], strlen($ext)) + 1;
if (strlen($num) == 2) {
$num = '0' . $num;
} else if (strlen($num) == 1) {
$num = '00' . $num;
}
}
return $cext . $num;
return $ext . $num;
}
private function getIdByDocNum($docnum)
{
$data = m($this->model)->getone("`docnum`='" . $docnum . "'", 'id,docnum');
$data = m(self::TABLE_NAME)->getone("`docnum`='" . $docnum . "'", 'id,docnum');
return $data['id'] ?: 0;
}
//启动流程
private function goflow($id)
{
$num = $this->ext . $this->model;
$mode = m("flow:" . $num);
$mode->initdata($num);
$mode = m("flow:" . self::MODEL_NAME);
$mode->initdata(self::MODEL_NAME);
$mode->loaddata($id);
$mode->submit();
}
......
......@@ -11,19 +11,15 @@ class openfkinfoClassAction extends openapiAction
return $this->showreturn([],$msg,'201');
}
public function listAction(){
$post = $_POST;
if($post){
$arr=$post['docnum'];
$arr=explode(',', $arr);
$str = " ' " . join("','", array_values($arr) ) . " ' "; // 使用需要的符号拼接
$str = " ' ".str_replace( ",","','", implode(',',$arr)); //使用需要的符号替换
$str = join( ', ',array_map(function( $v ){ return "'".$v."'";},$arr) );
$sql='select a.id,a.docnum,a.status,b.nowcheckname from oa_c_fininfom_oafk as a INNER JOIN oa_flow_bill as b on a.docnum=b.sericnum where a.docnum in '."(".$str.")";
$data = $this->db->getall($sql);
foreach ($data as $key => $value) {
......@@ -35,8 +31,6 @@ class openfkinfoClassAction extends openapiAction
}else{
$data = $this->db->getall('select * from oa_c_fininfom_oafk as a INNER JOIN oa_flow_bill as b on a.docnum=b.sericnum ');
foreach ($data as $key => $value) {
$info ='select * from [Q]c_fund_details_fk where mid='.$value['id'];
$info = $this->db->getall($info);
$data[$key]['info']=$info;
......@@ -44,33 +38,26 @@ class openfkinfoClassAction extends openapiAction
}
}
return $this->showreturn($data,'SUCCESS','200');
}
public function fkinforAction(){
$post = $_POST;
switch ($post['type']) {
case '1':
$sql='select o.name,o.num from oa_option as o where o.pid=516';
$data = $this->db->getall($sql);
$pid = 516;
break;
case '2':
$sql='select o.name,o.num from oa_option as o where o.pid=933';
$data = $this->db->getall($sql);
$pid = 933;
break;
case '3':
$sql='select o.name,o.num from oa_option as o where o.pid=678';
$data = $this->db->getall($sql);
break;
default:
return $this->showreturn([],'error','201');
$pid = 678;
break;
}
return $this->showreturn($data,'SUCCESS','200');
$sql='select o.name,o.num from oa_option as o where o.pid='.$pid;
$data = $this->db->getall($sql);
if($data)
return $this->showreturn($data,'SUCCESS','200');
else
return $this->showreturn([],'Error','201');
}
}
\ No newline at end of file
<?php
/**
网址管理后台控制处理
*/
require(ROOT_PATH.'/include/Action.php');
class Action extends mainAction
{
public $adminid = 0;
public $adminuser = '';
public $adminname = '';
public $admintoken = '';
public $companyid = 0;
public $loadci = 0;
public $flow;
protected $ajaxbool = 'false';
public function getlogin($lx=0)
{
$sid = $cookieSid = $this->rock->cookie('PHPSESSID');
$this->rock->savecookie('PHPSESSID',$sid,time()+3600);
$this->ajaxbool = $this->rock->jm->gettoken('ajaxbool', 'false');
$this->adminid = (int)$this->getsession('adminid',0);
$this->adminuser = $this->getsession('adminuser');
$this->adminname = $this->getsession('adminname');
$this->admintoken = $this->getsession('admintoken');
$this->companyid = $this->getsession('companyid');
$this->setNowUser($this->adminid, $this->adminname, $this->adminuser);
$agid = $this->rock->get('agentid');
if($agid!='')$this->rock->savesession(array('wxqyagentid' => $agid));
if($lx==0)$this->logincheck();
}
public function setNowUser($uid, $uname, $user='')
{
$this->rock->adminid = $uid;
$this->rock->adminname = $uname;
$this->rock->adminuser = $user;
}
//免登录验证,用于订阅报表的
private function loginsubscribe()
{
$subscribe_key = $this->post('subscribe_key');
$subscribe_post = $this->post('subscribe_post');
if(isempt($subscribe_key) || isempt($subscribe_post))return false;
$url = $this->rock->nowurl();
$time = time(); $time1 = $time+1;
$keyarr = array(md5($url.$time.$subscribe_post),md5($url.$time1.$subscribe_post));
if(!in_array($subscribe_key, $keyarr))return false;
$opkey = $this->option->getval('subscribe_key');
if(!in_array($opkey, $keyarr))return false;
$adminid = (int)$this->post('subscribe_adminid','0');
$this->setNowUser($adminid,'');
return true;
}
protected function loginnot($ismo=false)
{
if($this->loginsubscribe())return;//免验证
$uid = (int)$this->getsession('adminid',0);
if($uid==0){
$lurl = '?m=login';
if($this->rock->ismobile() || $ismo)$lurl='?d=we&m=login';
if(ENTRANCE != 'index')$lurl = 'index.php'.$lurl.'';
$backurl = $this->rock->jm->base64encode($this->rock->nowurl());
if($backurl!='' && M!='index')$lurl = $lurl.'&backurl='.$backurl.'';
if(!isajax())$this->rock->location($lurl); //不是ajax跳转到登录页面
echo '没有登录,去<a href="'.$lurl.'">[登录]</a>';
exit();
}
}
protected function logincheck()
{
$this->loginnot();
}
public function initProject()
{
$this->getlogin();
if($this->rock->get('ajaxbool')=='true')return;
$this->smartydata['adminid'] = $this->adminid;
$this->smartydata['adminuser'] = $this->adminuser;
$this->smartydata['adminname'] = $this->adminname;
$this->smartydata['logintime'] = $this->getsession('logintime');
}
private function iszclogin()
{
if($this->loginsubscribe())return;//免验证
$token = $this->admintoken;
if(isempt($token))exit('sorry1');
$lastt = date('Y-m-d H:i:s',time()-24*3600);
$rs = m('logintoken')->getone("`uid`='$this->adminid' and `token`='$token' and `online`=1 and `moddt`>='$lastt'",'`moddt`');
if(!$rs)$this->backmsg('登录失效,请重新登录');
}
public function backmsg($msg='', $demsg='保存成功', $da=array())
{
backmsg($msg,$demsg,$da);
}
public function limitRows($table,$fields='*',$wherea='1=1',$order='',$arr=array())
{
$where = $this->request('where');
$keywhere = $this->request('keywhere');
if(!isempt($where)){
$where = $this->jm->uncrypt($this->rock->iconvsql($where));
$where = $this->db->filterstr($this->rock->covexec($where));
}
if(!isempt($keywhere)){
$keywhere = $this->jm->uncrypt($this->rock->iconvsql($keywhere));
$keywhere = $this->db->filterstr($this->rock->covexec($keywhere));
}
$wherea .= " $where $keywhere";
$order = $this->getOrder($order);
$group = '';
if(isset($arr['group']) && !isempt($arr['group']))$group="GROUP BY ".$arr['group']." ";
$limitall = false;
if(isset($arr['all']))$limitall= $arr['all'];
if(isset($arr['sou'])){
$wherea = str_replace($arr['sou'],$arr['rep'],$wherea);
$order = str_replace($arr['sou'],$arr['rep'],$order);
}
$sql = "select[SQL_CALC] $fields from $table where $wherea $group $order ";
$total = 0;
if($group!=''){
$sql = str_replace('[SQL_CALC]', ' SQL_CALC_FOUND_ROWS', $sql);
}else{
$sql = str_replace('[SQL_CALC]','',$sql);
$total = $this->db->rows($table, $wherea);
}
if(!$limitall)$sql.=' '.$this->getLimit();
$rows = $this->db->getall($sql);
if($group!='')$total = $this->db->found_rows();
if(!is_array($rows))$rows = array();
return array(
'total' => $total,
'rows' => $rows,
'sql' => $this->db->nowsql
);
}
public function getLimit()
{
$start = (int)$this->rock->post('start',0);
$limit = (int)$this->rock->post('limit',15);
$str = '';
if($limit > 0)$str =" limit $start,$limit";
return $str;
}
public function getOrder($order='')
{
$sort = $this->rock->iconvsql($this->post('sort'),1);
$dir = strtolower($this->post('dir'));
$highorder = $this->rock->iconvsql($this->post('highorder'));
$asort = '';
if($sort != '' && $dir !=''){
if(!contain('ascdesc',$dir))$dir='desc';
$sorta = $sort;
$asort=' '.$sorta.' '.$dir.'';
}
if($asort != '')$order = $asort;
if($highorder != '')$order = $highorder;
if($order != '')$order=" order by $order ";
return $order;
}
public function publicdelAjax()
{
$this->iszclogin();
$id = c('check')->onlynumber($this->rock->post('id'));
$table = $this->rock->iconvsql($this->rock->post('table','',1),1);
$modenum= $this->rock->post('modenum');
if(getconfig('systype')=='demo')$this->showreturn('', '演示数据禁止删除', 201);
if($id=='')$this->showreturn('', 'sorry', 201);
$isadmin= (int)$this->getsession('isadmin');
$deltba = array('todo','option','menu','wouser');
if($modenum==''){
if($isadmin != 1 && $table!='todo')$this->showreturn('','只有管理员才能操作' , 201);
if(substr($table,0,5)=='flow_' || in_array($table, $deltba)){
m($table)->delete("`id` in($id)");
}else{
$this->showreturn('','未设置删除权限' , 201);
}
}else{
$aid = explode(',', $id);
foreach($aid as $mid){
$msg = m('flow')->deletebill($modenum, $mid, '');
if($msg != 'ok')$this->showreturn('', $msg, 201);
}
}
$this->showreturn('');
}
public function publicstoreAjax()
{
$this->iszclogin();
$table = $this->rock->xssrepstr($this->rock->iconvsql($this->request('tablename_abc','',1),1));
$fields = '*';
$group = '';
$order = $this->rock->iconvsql($this->request('defaultorder'));
$aftera = $this->request('storeafteraction');
$modenum = $this->post('modenum');
$atype = $this->post('atype');
$execldown = $this->request('execldown');
$this->loadci = (int)$this->request('loadci');
$where = '1=1 ';
$beforea = $this->request('storebeforeaction');
$tables = $this->T($table);
if($modenum != ''){
$this->flow = m('flow')->initflow($modenum);
$nas = $this->flow->billwhere($this->adminid, $atype);
$_wehs = $nas['where'];
if(!isempt($nas['order']))$order = $nas['order'];
if(!isempt($nas['fields']))$fields = $nas['fields'];
if(!isempt($this->rock->arrvalue($nas, 'group')))$group = $nas['group'];
if($_wehs!='')$where .= ' '.$_wehs.' ';
$_tabsk = $nas['table'];
if(contain($_tabsk,' ')){
$tables = $_tabsk;
}else{
$table = $_tabsk;
$tables = $this->T($table);
}
}
if($beforea != ''){
if(method_exists($this, $beforea)){
$nas = $this->$beforea($table);
if(is_array($nas)){
if(isset($nas['where']))$where .= $nas['where'];
if(isset($nas['order']))$order = $nas['order'];
if(isset($nas['fields']))$fields = $nas['fields'];
if(isset($nas['table']))$tables = $nas['table'];
if(isset($nas['group']))$group = $nas['group'];
}else{
$where .= $nas;
}
}
}
if($tables==PREFIX)exit('无效的访问');
$arr = $this->limitRows($tables, $fields, $where, $order, array(
'group' => $group
));
$total = $arr['total'];
$rows = $arr['rows'];
$bacarr = array(
'totalCount'=> $total,
'rows' => $rows
);
if(method_exists($this, $aftera)){
$narr = $this->$aftera($table, $rows);
if(is_array($narr)){
foreach($narr as $kv=>$vv)$bacarr[$kv]=$vv;
}
}
if($this->flow){
$rows = $bacarr['rows'];
foreach($rows as $k=>$rs){
if(isset($rs['status'])){
$rs['statustext'] = $this->flow->getstatus($rs,'','',1);
if($rs['status']==5)$rs['ishui'] = 1;
}
$rows[$k] = $this->flow->flowrsreplace($rs,2);
}
$bacarr['rows'] = $this->flow->daochusubtable($rows);
}
if($execldown == 'true'){
$this->exceldown($bacarr);
return;
}
$this->returnjson($bacarr);
}
/**
* 验证签名
*/
public function checksignature($table)
{
if(!getconfig('checksign'))return true;//不验证
$sign = $this->post('sys_signature');
$time = $this->post('sys_timeature');
$signs= md5($this->rock->nowurl().$table.$time.'_'.$this->adminid);
return ($sign==$signs);
}
/**
* 公共保存页面
*/
public function publicsaveAjax()
{
$this->iszclogin();
$msg = '';
$success= false;
$table = $this->rock->xssrepstr($this->rock->iconvsql($this->post('tablename_postabc','',1),1));
$id = (int)$this->post('id');
$oldrs = false;
if(isempt($table))return returnerror('错误表名');
if(!$this->checksignature($this->post('tablename_postabc')))return returnerror('无效请求');
$db = m($table);
$where = "`id`='$id'";
if($id==0)$where='';
$modenum = $this->post('sysmodenumabc');
$flow = null;
$msgerrortpl = $this->post('msgerrortpl');
$aftersavea = $this->post('aftersaveaction', 'publicaftersave');
$beforesavea = $this->post('beforesaveaction', 'publicbeforesave');
$submditfi = $this->rock->jm->base64decode($this->post('submitfields_postabc'));
$editrecord = $this->post('editrecord_postabc'); //是否保存修改记录
$fileid = $this->post('fileid', '0');
$isturn = (int)$this->post('isturn_postabc', '1');
$int_type = ','.$this->post('int_filestype').',';
$md5_type = ','.$this->post('md5_filestype').',';
if(isempt($submditfi))return returnerror('无效字段');
if($modenum!='')$flow = m('flow')->initflow($modenum);
$fields = explode(',', $submditfi);
$uaarr = array();
foreach($fields as $field){
$field = $this->rock->xssrepstr($field);
$val = $this->post(''.$field.'');
$type = $this->post(''.$field.'_fieldstype');
$boa = true;
if($this->contain($int_type, ','.$field.',')){
$val = (int)$val;
}
if($this->contain($md5_type, ','.$field.',')){
if($val=='')$boa=false;
$val = md5($val);
}
if($boa)$uaarr[$field]=$val;
}
$otherfields = $this->post('otherfields');
$addotherfields = $this->post('add_otherfields');
$editotherfields = $this->post('edit_otherfields');
if($id == 0)$otherfields.=','.$addotherfields.'';
if($id > 0)$otherfields.=','.$editotherfields.'';
if($otherfields != ''){
$otherfields = str_replace(array('{now}','{date}','{admin}','{adminid}'),array($this->now,date('Y-m-d'),$this->adminname,$this->adminid),$otherfields);
$fiarsse = explode(',', $otherfields);
foreach($fiarsse as $ffes){
if($ffes!=''){
$ssare = explode('=', $ffes);
$lea = substr($ssare[1],0,1);
if($lea == '['){
$uaarr[$ssare[0]]=$uaarr[substr($ssare[1],1,-1)];
}else{
$uaarr[$ssare[0]]=$ssare[1];
}
}
}
}
$ss = '';
if(!$this->isempt($beforesavea)){
if(method_exists($this, $beforesavea)){
$befa = $this->$beforesavea($table, $uaarr, $id);
if(is_string($befa)){
$ss = $befa;
}else{
if(isset($befa['msg']))$ss=$befa['msg'];
if(isset($befa['rows'])){
foreach($befa['rows'] as $bk=>$bv)$uaarr[$bk]=$bv;
}
}
}
}
$msg = $ss;
$idadd = false;
if($msg == ''){
if($id>0 && $editrecord=='true')$oldrs = $db->getone($id);
$sbo = $db->record($uaarr, $where);
if($sbo){
$msg = '处理成功';
$success= true;
if($id == 0){
$id = $this->db->insert_id();
$idadd = true;
}
if($fileid !='0')m('file')->addfile($fileid,$table,$id, $modenum);
if(!$this->isempt($aftersavea)){
if(method_exists($this, $aftersavea)){
$this->$aftersavea($table, $uaarr, $id, $idadd);
}
}
//保存修改记录
if($oldrs && $flow!=null){
$newrs = $db->getone($id);
m('edit')->recordstr($flow->fieldsarr,$flow->mtable, $id, $oldrs, $newrs, 2);
}
}else{
$msg = 'mysqlerr:'.$this->db->lasterror();
}
}
if($msg=='')$msg='处理失败';
$arr = array('success'=>$success,'msg'=>$msg,'id'=>$id);
echo json_encode($arr);
}
public function publicsavevalueAjax()
{
$this->iszclogin();
$table = $this->rock->xssrepstr($this->rock->iconvsql($this->post('tablename','',1),1));
if(!$this->checksignature($this->post('tablename')))return '无效请求';
$noupf = array('pass','user');
$id = c('check')->onlynumber($this->post('id', '0'));
$fields = $this->post('fieldname');
if(in_array(strtolower($fields), $noupf))return 'error';
$value = $this->post('value');
$where = "`id` in($id)";
m($table)->record(array($fields=>$value), $where);
$fiesa = $this->rock->request('fieldsafteraction');
if($fiesa!=''){
if(method_exists($this, $fiesa)){
$this->$fiesa($table, $fields, $value, $id);
}
}
echo 'success';
}
public function exceldown($arr)
{
$fields = explode(',', $this->post('excelfields','',1));
$header = explode(',', $this->post('excelheader','',1));
$title = $this->post('exceltitle','',1);
$rows = $arr['rows'];
$exceltype = $this->post('exceltype','xls'); //保存文件类型
if($exceltype!='doc')$exceltype = 'xls';
$headArr = array();
for($i=0; $i<count($fields); $i++){
$headArr[$fields[$i]] = $header[$i];
}
$url = c('html')->execltable($title, $headArr, $rows, $exceltype);
$this->returnjson(array(
'url' => $url,
'totalCount'=> $arr['totalCount'],
'downCount' => count($rows)
));
}
public function getoptionAjax()
{
$num = $this->get('num');
$arr = m('option')->getdata($num);
echo json_encode($arr);
}
}
class ActionNot extends Action
{
public function publicsavevalueAjax(){}
public function publicsaveAjax(){}
public function publicdelAjax(){}
public function publicstoreAjax(){}
public function publictreestoreAjax(){}
protected function logincheck(){}
/**
* 手机端/单据详情页判断有没有登录就根据cookie登录
*/
protected function mweblogin($lx=0, $ismo=false)
{
$uid = m('login')->autologin((int)$this->get('adminid','0'), $this->get('token'));
if($uid==0){
$this->loginnot($ismo);
}else{
$this->initProject(); //登录成功
}
$this->adminid = $uid;
return $uid;
}
}
\ No newline at end of file
<?php
if(!defined('HOST'))die('not access');
//[管理员]在2020-01-02 19:23:44通过[系统→系统工具→系统设置],保存修改了配置文件
return array(
'localurl' => '', //本地系统URL,用于服务器上浏览地址
'db_engine' => 'MyISAM',
'perfix' => 'oa_', //数据库表名前缀
# 'qom' => 'oa_', //session、cookie前缀
'qom' => '', //session、cookie前缀
'highpass' => '', //超级管理员密码,可用于登录任何帐号
'db_drive' => 'mysqli', //操作数据库驱动有mysql,mysqli,pdo三种
'randkey' => 'zbxmrnlidsugyohaqejkfvpctw', //系统随机字符串密钥
'asynkey' => 'ed42c6c72f7b5f9779e03921e335adc7', //这是异步任务key
'openkey' => '5bdfcedb618e1e03abf18e391278c1f4', //对外接口openkey
'updir' => 'upload',
'sqllog' => true, //是否记录sql日志保存upload/sqllog下
'asynsend' => '0', //是否异步发送提醒消息,0同步,1自己服务端异步,2官网VIP用户异步
'editpass' => '1', //用户登录修改密码:0不用修改,1强制用户必须修改
'install' => true, //已安装,不要去掉啊
'outurl' => '', //这个地址当你内网地址访问时向手机推送消息的地址
'reimtitle' => '', //REIM即时通信上标题
'qqmapkey' => '',
'xinhukey' => '9c204945d725d0766f9fcb0ead720515', //信呼官网key,用于在线升级使用
'bcolorxiang' => '', //单据详情页面上默认展示线条的颜色
'officeyl' => '0', //文档Excel.Doc预览类型,0自己部署插件,1使用官网支持任何平台
'useropt' => '1', //1记录用户操作保存到日志里,空不记录
'defstype' => '1', //PC后台主题皮肤,可以设置1到34
'debug' => true, //为true调试开发模式,false上线模式
'reim_show' => false, //首页是否显示REIM
'mobile_show' => true, //首页是否显示手机版
'companymode' => true, //多单位模式,true就是开启
'loginyzm' => '0', //登录方式:0仅使用帐号+密码,1帐号+密码/手机+验证码,2帐号+密码+验证码,3仅使用手机+验证码
);
$defaultConfig = require_once 'default_config.php';
return array_merge($config,$defaultConfig);
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论