提交 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
差异被折叠。
......@@ -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
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论