提交 636c1dd7 authored 作者: chengye's avatar chengye

初始化 test

......@@ -70,7 +70,7 @@ class Login extends Controller
session(null);
cookie(null);
(new SingleSign())->clear();
$this->redirect('/login');
$this->redirect('/index');
}
private function checkStaff(){
......
......@@ -9,6 +9,7 @@ namespace app\admin\controller;
use app\admin\model\StaffModel;
use think\Exception;
use think\facade\Cookie;
use think\facade\Session;
class SingleSign {
public $instence = null;
......@@ -19,6 +20,8 @@ class SingleSign {
if($res) $this->instence = $redis;
else throw new Exception("redis connect faild");
}
$sid = Cookie::get('PHPSESSID');
if(!empty($sid)) Cookie::set('PHPSESSID',$sid,['expire'=>time()+3600]);
}
//获取session
......@@ -37,15 +40,14 @@ class SingleSign {
$isAdmin = substr($str,$pos,1);
$user['is_admin'] = $isAdmin;
if($user['is_admin'] == true) {
preg_match('/adminuser\|s\:(\d+)\:/',$str,$match);
if($match){
$pos = stripos($str,'adminuser|s:') + strlen('adminuser|s:');
$pos += strlen($match[1]) + 2;
$user['username'] = substr($str,$pos,$match[1]+0);
}
if($user['is_admin'] == true && $user['username'] == 'admin') {
$user['username'] = 'gonnadmin';
} else {
preg_match('/adminuser\|s\:(\d+)\:/',$str,$match);
if($match){
$pos = stripos($str,'adminuser|s:') + strlen('adminuser|s:');
$pos += strlen($match[1]) + 2;
$user['username'] = substr($str,$pos,$match[1]+0);
}
}
$pos = stripos($str,'ukey|s:10:') + 11;
......@@ -81,6 +83,8 @@ class SingleSign {
public function clear($prex = 'PHPREDIS_SESSION:'){
$sid = Cookie::get('PHPSESSID');
$sid = $prex.$sid;
Cookie::delete($sid);
if($this->instence->set($sid,'')) return true;
return false;
}
......
<?php
namespace app\admin\validate;
use think\Validate;
class FkAddValidate extends Validate
{
protected $rule = [
'title' => 'require',
'payee' => 'require',
'payOrg' => 'require',
'date' => 'require|date',
'fkinfo' => 'require'
];
protected $message = [
'title.require' => '标题必填',
'payee.require' => '收款方必填',
'payOrg.require' => '付款组织必填',
'date.require' => '日期必填',
'date.date' => '日期格式错误'
];
}
\ No newline at end of file
......@@ -20,9 +20,7 @@
<option value="1" {if $search_type eq 1 } selected {/if}>站名</option>
<option value="2" {if $search_type eq 2 } selected {/if}>站号</option>
<option value="3" {if $search_type eq 3 } selected {/if}>项目编号</option>
<option value="4" {if $search_type eq 4 } selected {/if}>机房二维码</option>
</select>
</div>
<div class="layui-input-inline layui-show-xs-block">
......@@ -44,11 +42,9 @@
{if $region.level == 0}
<option disabled='disabled' class='layui-disabled' >{$region.region_name}</option>
{else /}
<option value="{$region.id}" {if $area_id eq $region.id } selected {/if} >&nbsp;&nbsp;&nbsp;&nbsp;{$region.region_name}</option>
<option value="{$region.id}" {if $area_id eq $region.id } selected {/if} >{$region.region_name}</option>
{/if}
{/volist}
</select>
</div>
......
......@@ -60,7 +60,8 @@
<script src="dist/js/md5.js"></script>
<script src="dist/js/sha1.js"></script>
<script src="dist/js/util.js"></script>
<!--<script src="dist/js/getUserToken.js"></script>-->
<script src="dist/js/getUserToken.js"></script>
<script>
layui.use(['laydate','form','upload'], function(){
upload = layui.upload;
......
......@@ -107,12 +107,6 @@ function createPass(){
return substr(md5(config('admin.passwd_salt').time()),0,10);
}
//生成10位的随机密码
//将密码返回给控制器
//控制器通过MD加密之后存储到数据库
/**
* 基站状态递归实现无限极分类
* @param $array 分类数据
......
......@@ -5,18 +5,19 @@
*/
namespace app\em\controller;
use app\admin\controller\Base;
use app\admin\model\DepartmentModel;
use app\admin\model\ElectricMeter;
use app\em\model\EmAccount;
use app\em\model\EmCert;
use app\em\model\EmInvoice;
use app\em\model\EmInvoiceHistory;
use app\em\model\EmPayment;
use app\em\model\EmPaymentFk;
use app\em\model\EmPaymentInvoice;
use app\em\model\EmPaymentInvoiceBalance;
use app\em\model\EmPaymentReceipt;
use app\em\model\Staff;
use app\em\model\Station;
use app\em\validate\AddPaymentValidate;
use function Sodium\library_version_major;
use think\Exception;
use think\facade\Request;
use think\facade\Session;
......@@ -219,60 +220,6 @@ class Payment extends Base
return $this->fetch();
}
//更新缴费数据 即保存缴费 记录一次缴费
// public function update(){
// $data = Request::post();
//
// //更新缴费信息
// $payment = EmPayment::get(['payment_id'=>$data['payment_id']]);
// $payment->amount = $data['paid_totle']; //记录凭证金额
// $payment->staff_id = $data['staff_id'];
// //等待审核1,2已审核 1阶段暂忽略
// //$payment->status = 1;
// $payment->status = 2;
// $payment->save();
//
// //更新账单状态
// //1.查询所有账单
// $invArr = [];
// foreach ($data['paid'] as $key => $item) {
// $invArr['invoice_id'] = $key;
// $invArr['paid_amount'] = $item['paid_amount'];
// }
// /*
// * 循环查询账单 并计算balance的数值 更新balance,并将当前的状态,同步到历史数据一份进行销账的追踪
// * 通过与balance的计算结果比较 如果balance=0,则账单状态更新为已缴费 如果不为0则更新为部分缴费
// * 账单与缴费凭证关系的建立 通过缴费单与凭证的关联关系获取,显示在账单详情中
// */
// foreach ($invArr as $item){
// $inv = EmInvoice::get(['invoice_id'=>$item['invoice_id']]);
//
// $balance = $inv->payment_balance - $inv['paid_amount'];
//
// //计算状态
// if($balance == 0){
// $inv->status = setInvoiceStatus($inv->status,self::PAYMENT_FULL_CODE,self::PAYMENT_STATUS_INDEX);
// } else {
// $inv->status = setInvoiceStatus($inv->status,self::PAYMENT_PARTIAL_CODE,self::PAYMENT_STATUS_INDEX);
// }
//
// $inv->payment_balance = $balance;
//
// //更新账单信息
// $inv->save();
// //保存销账明细,复制当前对象数据 到history表
//
// $invHistory = new EmInvoiceHistory();
//
// if(!$invHistory->save($inv->toarray())){
// throw new Exception('保存销账明细错误!');
// } else {
// return json(['status'=>1,'message'=>'缴费成功!']);
// }
// }
//
// }
//缴费单详情
public function detail(){
$payment_id = Request::param('payment_id');
......@@ -280,6 +227,16 @@ class Payment extends Base
//查询缴费单基本信息
$payment = $epModel->where('payment_id','=',$payment_id)->find();
if(isset($payment->status_fk) && $payment->status_fk != 0){
$fkModel = EmPaymentFk::get(['payment_id'=>$payment->payment_id]);
$fkModel->link = config('oafk.base_url').config('oafk.link') . $fkModel->oafk_id;
} else {
$fkModel = new EmPaymentFk();
$fkModel->oafk_numb = '';
$fkModel->link = '';
}
$this->assign('fk',$fkModel);
switch ($payment->status){
case 0:
$payment->statusTitle = '未缴费';
......@@ -443,4 +400,165 @@ class Payment extends Base
$this->assign('data',$eibs);
return $this->fetch();
}
public function payoa(){
$payment_id = Request::param('payment_id');
$user = Session::get('user');
if($user['is_admin'] == 1){
if($user['username'] == 'admin' || $user['username'] == 'gonnadmin'){
$staff = [];
} else {
$staff = Staff::get(['name'=>$user['name']]);
}
} else {
$staff = Staff::get($user['user_id']);
}
$this->assign('payment_id',$payment_id);
$this->assign('payee',$this->getGys($staff->email));
$this->assign('payOrg',$this->getFkInfo(2));
$this->assign('payType',$this->getFkInfo(1));
return $this->fetch('pay_oa');
}
public function docnumb(){
$user = Session::get('user');
$staff = Staff::get($user['user_id']);
$dept = DepartmentModel::get($staff->d_id);
$post = Request::post();
$payment = EmPayment::get(['payment_id'=>$post['payment_id']]);
if($this->checkFkStatus($post['payment_id'])) return json(['status'=>0,'message'=>'该缴费单已经创建付款单无法再次创建.']);
if($user['is_admin']) $staffName = 'admin';
else $staffName = substr($staff->email,0,strpos($staff->email,'@'));
$invs = (new EmPayment())->getinvsInfo($payment->payment_id);
$details = [];
foreach ($invs as $k => $inv){
$details[$k]['chargeType'] = "维护电费";
if($inv->payment_balance == 0){
$details[$k]['amount'] = 0;
} else if($inv->payment_amount == $inv->payment_balance){
$details[$k]['amount'] = $inv->payment_amount;
} else {
$details[$k]['amount'] = $inv->payment_amount - $inv->payment_balance;
}
$details[$k]['projectNumber'] = $this->getDetailsFields($inv->account_id);
$details[$k]['contractNumber'] = $this->getDetailsFields($inv->account_id,true);
$details[$k]['receipt'] = '';
}
$data = [
'title'=>$post['title'],
'uname'=>$staffName,
'payType'=>$post['payType'],
'dept'=>$dept->name,
'payee'=>$post['payee'],
'payOrg'=>$post['payOrg'],
'fkinfo'=>$post['fkinfo'],
'remarks'=>$post['remark'],
'type'=>2,
'date'=>$post['date'],
'details'=> $details
];
foreach ($data as $k => $v){
if($k != 'remarks'){
switch ($k){
case 'fkinfo':
$msg = '付款信息';
break;
case 'date':
$msg = '付款日期';
break;
case 'title':
$msg = '单据抬头';
break;
}
if(empty($v)) return json(['status'=>0,'message'=>'字段值'.$msg.'必填,请检查']);
}
if($k == 'details') {
foreach ($v as $a=>$b){
foreach ($b as $aa => $bb){
if($aa != 'receipt' && $aa != 'contractNumber'){
if(empty($bb)) return json(['status'=>0,'message'=>'金额为0,或成本中心编码不存在']);
}
}
}
}
}
$res = $this->createFkNumb($data);
$result = false;
if(!empty($res['data'])){
$payment->status_fk = 1;
$fkModel = new EmPaymentFk();
$fkModel->payment_id = $payment->payment_id;
$fkModel->oafk_id = $res['data']['id'];
$fkModel->oafk_numb = $res['data']['numb'];
$result = $payment->save() && $fkModel->save();
}
if($result) return json(['status'=>1,'message'=>'创建单据成功']);
else return json(['status'=>0,'message'=>'创建单据失败']);
}
public function apiKey(){
return md5(config('oafk.oa_key'));
}
public function getGys($email)
{
$url = config('oafk.base_url').config('oafk.gys') . $this->apiKey();
$url .= '&email='.$email;
$res = curlGet($url);
$res = json_decode($res,true);
foreach ($res['data'] as $k => $v){
if(!empty($v['bank_info'])){
foreach ($v['bank_info'] as $a => $b){
$temp[$a] = '银行名称: '.$b['open_bank_name']. '账号: '.$b['bank_code'];
}
$res['data'][$k]['bankInfo'] = json_encode($temp);
}
}
return $res['data'];
}
public function getFkInfo($type){
$url = config('oafk.base_url').config('oafk.type') . $this->apiKey();
$data = ['type'=>$type];
$res = httpPOST($url, $data);
$res = json_decode($res,true);
return $res['data'];
}
public function createFkNumb($data){
$url = config('oafk.base_url').config('oafk.fk') . $this->apiKey();
$res = httpPOST($url, ['data'=>json_encode($data)]);
dd($res);
$res = json_decode($res,true);
return $res;
}
public function checkFkStatus($payment_id){
$res = (new EmPaymentFk())->get(['payment_id'=>$payment_id]);
return $res ? true : false;
}
public function getDetailsFields($account_id,$contract=false){
$account = EmAccount::get(['account_id'=>$account_id]);
$em = \app\em\model\Em::get($account->em_id);
if($contract === true){
if(!$em) return json(['status'=>0,'message'=>'没有找到所属电表']);
return $em->contract_numb ?: '';
}
$station = Station::get(['station_id'=>$em->station_id]);
if(!$station) return json(['status'=>0,'message'=>'没有找到所属基站']);
return $station->proj_number ?: '';
}
}
\ No newline at end of file
......@@ -76,7 +76,7 @@ class Em extends Base
//获取电表信息与station信息
public function getBaseInfo($em_id){
$data = self::field('em.id,em.em_numb,em.em_type_id,em.rate')
->field('s.station_sp_code,s.station_name')
->field('s.station_sp_code,s.station_name,s.proj_number')
->field('et.name as typeName')
->leftJoin(['station_info'=>'s'],'s.station_id=em.station_id')
->leftJoin(['em_type'=>'et'],'et.id=em.em_type_id')
......
<?php
namespace app\em\model;
class EmPaymentFk extends Base
{
protected $table = 'em_payment_fk';
}
\ No newline at end of file
......@@ -64,17 +64,13 @@
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label layui-text-left">
缴费凭证:
</label>
<div class="layui-input-inline">
<a class="layui-btn layui-btn-normal layui-right" lay-submit lay-filter="showCert" οnclick="return false;">查看</a>
{if $payment.status <= 3}
<button class="layui-btn layui-btn-normal layui-right" lay-submit lay-filter="addCert" οnclick="return false;"><i class="layui-icon layui-icon-add-circle-fine"></i></button>
{/if}
<a href="{$fk.link}">{$fk.oafk_numb|default='无'}</a>
</div>
</div>
</div>
......@@ -85,9 +81,9 @@
发票凭证:
</label>
<div class="layui-input-inline">
<a class="layui-btn layui-btn-normal layui-right" lay-submit lay-filter="showReceipt" οnclick="return false;">查看</a>
<a class="layui-btn layui-btn-normal layui-right" lay-submit lay-filter="showReceipt" onclick="return false;">查看</a>
{if $payment.status <= 3}
<button class="layui-btn layui-btn-normal layui-right" lay-submit lay-filter="addReceipt" οnclick="return false;"><i class="layui-icon layui-icon-add-circle-fine"></i></button>
<button class="layui-btn layui-btn-normal layui-right" lay-submit lay-filter="addReceipt" onclick="return false;"><i class="layui-icon layui-icon-add-circle-fine"></i></button>
{/if}
</div>
</div>
......@@ -131,7 +127,6 @@
</div>
{/if}
<div class="layui-form-item layui-col-md-offset4">
{if $payment.status <= 3}
<button class="layui-btn" lay-filter="save" lay-submit="">提交</button>
......@@ -141,6 +136,11 @@
审核
</button>
{/if}
{if $fk.oafk_numb == ''}
<button class="layui-btn" lay-filter="pay" lay-submit="">
创建付款
</button>
{/if}
</div>
</div>
</div>
......@@ -178,8 +178,6 @@
time: time,
});
}
form.on('submit(submit)',
function (data) {
$.ajax({
......@@ -235,6 +233,14 @@
}
);
form.on('submit(pay)',
function (data) {
$url = '/payment/payoa/{$payment.payment_id}'
xadmin.open('补充付款信息',$url)
return false;
}
);
//保存信息
form.on('submit(save)',
function (data) {
......@@ -278,7 +284,6 @@
return false;
});
//上传电表照片
var upPhoto = upload.render({
elem: '#up_photo' ,
......
{extend name="public:base" /}
{block name="body"}
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<form class="layui-form">
<!--添加结算凭证-->
<div class="layui-form-box">
<div class="layui-form-body">
<div class="layui-row">
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label layui-text-left">
缴费单号:
</label>
<div class="layui-input-inline">
<input type="text" name="payment_id" autocomplete="off"
class="layui-input" value="{$payment_id}" disabled="disabled">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label layui-text-left">
单据抬头:
</label>
<div class="layui-input-inline">
<input type="text" name="title" autocomplete="off"
class="layui-input" value="电费付款">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label layui-text-left">
汇款方式:
</label>
<div class="layui-input-inline">
<select name="payType" id="payType">
{volist name="payType" id="item"}
<option value="{$item.name}">{$item.name}</option>
{/volist}
</select>
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label layui-text-left">
收款方:
</label>
<div class="layui-input-inline">
<select name="payee" id="payee" lay-filter="change">
{volist name="payee" id="item"}
<option value="{$item.name}" data-info='{$item.bankInfo|default='
'}'>{$item.name}</option>
{/volist}
</select>
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label layui-text-left">
付款组织:
</label>
<div class="layui-input-inline">
<select name="payOrg" id="payOrg">
{volist name="payOrg" id="item"}
<option value="{$item.name}">{$item.name}</option>
{/volist}
</select>
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label layui-text-left">
付款日期:
</label>
<div class="layui-input-inline">
<input type="text" name="date" id="date" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label layui-text-left">
付款信息:
</label>
<div class="layui-input-inline">
<textarea class="layui-textarea" name="fkinfo" id="fkinfo"></textarea>
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label layui-text-left">
备注:
</label>
<div class="layui-input-inline">
<textarea class="layui-textarea" name="remark" id="remark"></textarea>
</div>
</div>
</div>
</div>
<div class="layui-form-item layui-col-md-offset4">
<button class="layui-btn" lay-filter="submit" lay-submit="">
创建
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
{/block}
{block name="js"}
<script type="text/javascript">
//初始化Layui控件
layui.use(['form', 'layer', 'laydate', 'upload'],
function () {
$ = layui.jquery;
var form = layui.form,
layer = layui.layer,
laydate = layui.laydate;
form.on('select(change)', function (data) {
var that = $(data.elem);
var info = that.find('option:selected').data('info');
$("#fkinfo").text(info);
});
laydate.render({
elem: '#date',
trigger: 'click',
});
//消息提示
function layMsg(msg, type = 6, time = 1000) {
layer.msg(msg, {
icon: type,
time: time,
});
}
//生成缴费单
form.on('submit(submit)',
function (data) {
$.ajax({
url: '/payment/docnumb',
method: "POST",
data: data.field,
dataType: "json",
success: function (data) {
if (data.status == 1) {
layer.msg(data.message, {icon: 6, time: 3000}, function () {
xadmin.close();
// 可以对父窗口进行刷新
xadmin.father_reload();
})
} else {
layer.msg(data.message, {icon: 5, time: 3000})
}
}
});
return false;
});
});
</script>
{/block}
差异被折叠。
<?php
return [
'oa_key' => '5bdfcedb618e1e03abf18e391278c1f4',
'base_url' => 'http://oa-test.gonn.tech',
'gys' => '/api.php?m=opensupplier&a=list&openkey=',
'type' => '/api.php?m=openfkinfo&a=fkinfor&openkey=',
'fk' => '/api.php?m=openfk&a=create&openkey=',
'link'=>'/task.php?a=p&num=oayfk&mid='
];
......@@ -168,6 +168,8 @@ Route::post('payment/createAll','em/payment/createAll');
Route::post('payment/update','em/payment/update');
Route::post('payment/save','em/payment/store');
Route::post('payment/confirm','em/payment/confirm');
Route::get('payment/payoa/:payment_id','em/payment/payoa');
Route::post('payment/docnumb','em/payment/docnumb');
//结算
Route::get('settle','em/settle/index');
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论