提交 686074ef authored 作者: wangkr's avatar wangkr

Merge branch 'test' into release

Conflicts: .gitignore application/admin/view/staff/role.html config/admin.php public/page/fonts/element-icons.535877f5.woff public/page/fonts/element-icons.732389de.ttf public/page/fonts/iconfont.0208023e.0208023e.eot public/page/fonts/iconfont.d8583a84.d8583a84.ttf public/page/fonts/iconfont.e9caaa06.e9caaa06.woff public/page/img/bpmn.deea5c90.svg public/page/img/icon-ext.ba81b24c.ba81b24c.png public/page/img/icon.551539f8.551539f8.png public/page/img/iconfont.5d06b488.5d06b488.svg public/page/img/loading-0.a72011cc.a72011cc.gif 修改: application/admin/controller/Base.php 删除: application/admin/controller/Excel(1).php 修改: application/admin/controller/SingleSign.php 修改: application/admin/model/PermissionModel.php 新文件: application/admin/validate/FkAddValidate.php 修改: application/admin/view/basestation/base_region.html 修改: application/admin/view/permission/index.html 修改: application/admin/view/staff/role.html 修改: application/admin/view/staff/role1.html 修改: application/api/common.php 新文件: application/api/controller/v2/common/Payment.php 新文件: application/api/controller/v2/common/Project.php 修改: application/em/common.php 修改: application/em/controller/Account.php 修改: application/em/controller/Em.php 修改: application/em/controller/Invoice.php 修改: application/em/controller/Payment.php 新文件: application/em/controller/Receipt.php 修改: application/em/controller/Region.php 修改: application/em/controller/Useage.php 删除: application/em/controller/Useage.php.bak 新文件: application/em/controller/WriteOff.php 修改: application/em/model/Em.php 新文件: application/em/model/EmAccountAmount.php 修改: application/em/model/EmCheckBill.php 修改: application/em/model/EmInvoice.php 修改: application/em/model/EmPayment.php 新文件: application/em/model/EmPaymentAccount.php 新文件: application/em/model/EmPaymentFk.php 新文件: application/em/model/EmPaymentMonthly.php 删除: application/em/model/Invoice.php 修改: application/em/model/Staff.php 新文件: application/em/validate/AddFkInfoDetailsValidate.php 新文件: application/em/validate/AddFkInfoValidate.php 修改: application/em/validate/UseageGeneralInfoValidate.php 修改: application/em/view/em/index.html 删除: application/em/view/invoice/Invoice.php 修改: application/em/view/invoice/detail.html 修改: application/em/view/invoice/index.html 删除: application/em/view/invoice/index_back.html 修改: application/em/view/invoice/merge_list.html 修改: application/em/view/payment/create.html 删除: application/em/view/payment/create2.html 删除: application/em/view/payment/create3.html 修改: application/em/view/payment/detail.html 修改: application/em/view/payment/index.html 新文件: application/em/view/payment/pay_oa.html 修改: application/em/view/region/region_list.html 新文件: application/em/view/region/region_list1.html 修改: application/em/view/useage/default.html 修改: application/em/view/useage/detail.html 修改: application/em/view/useage/detail_special.html 修改: application/em/view/useage/update.html 新文件: config/admin.php 新文件: config/oafk.php 新文件: public/page/css/app.96f2bf7e.css 新文件: public/page/favicon.ico 新文件: public/page/fonts/bpmn.499c9aa3.eot 新文件: public/page/fonts/bpmn.9b84e8c8.ttf 新文件: public/page/fonts/bpmn.b5d0cc49.woff 新文件: public/page/fonts/bpmn.f3d4b5d1.woff2 新文件: public/page/fonts/element-icons.535877f5.woff 新文件: public/page/fonts/element-icons.732389de.ttf 新文件: public/page/fonts/iconfont.0208023e.0208023e.eot 新文件: public/page/fonts/iconfont.d8583a84.d8583a84.ttf 新文件: public/page/fonts/iconfont.e9caaa06.e9caaa06.woff 新文件: public/page/img/bpmn.deea5c90.svg 新文件: public/page/img/icon-ext.ba81b24c.ba81b24c.png 新文件: public/page/img/icon.551539f8.551539f8.png 新文件: public/page/img/iconfont.5d06b488.5d06b488.svg 新文件: public/page/img/loading-0.a72011cc.a72011cc.gif 新文件: public/page/index.html 新文件: public/page/js/app.7eaa479e.js 新文件: public/page/js/app.7eaa479e.js.LICENSE 新文件: public/page/js/app.81004bd3.js 新文件: public/page/js/app.81004bd3.js.LICENSE 新文件: public/page1/css/app.7ad51aae.css 新文件: public/page1/css/app.f5cc36b7.css 新文件: public/page1/css/chunk-vendors.b27c2f9a.css 新文件: public/page1/favicon.ico 新文件: public/page1/fonts/bpmn.499c9aa3.eot 新文件: public/page1/fonts/bpmn.9b84e8c8.ttf 新文件: public/page1/fonts/bpmn.b5d0cc49.woff 新文件: public/page1/fonts/bpmn.f3d4b5d1.woff2 新文件: public/page1/fonts/element-icons.535877f5.woff 新文件: public/page1/fonts/element-icons.732389de.ttf 新文件: public/page1/fonts/iconfont.0208023e.0208023e.eot 新文件: public/page1/fonts/iconfont.d8583a84.d8583a84.ttf 新文件: public/page1/fonts/iconfont.e9caaa06.e9caaa06.woff 新文件: public/page1/img/bpmn.deea5c90.svg 新文件: public/page1/img/icon-ext.ba81b24c.ba81b24c.png 新文件: public/page1/img/icon.551539f8.551539f8.png 新文件: public/page1/img/iconfont.5d06b488.5d06b488.svg 新文件: public/page1/img/loading-0.a72011cc.a72011cc.gif 新文件: public/page1/index.html 新文件: public/page1/js/app.aa6907c3.js 新文件: public/page1/js/app.aa6907c3.js.LICENSE 新文件: public/page1/js/app.bc5c248b.js 新文件: public/page1/js/chunk-vendors.a06d51ef.js 修改: public/static/admin/css/style.css 修改: public/static/xadmin/lib/layui/lay/modules/tree.js 修改: route/admin.php 修改: route/api.php
...@@ -14,10 +14,16 @@ ...@@ -14,10 +14,16 @@
/config/database.php /config/database.php
/config/cache.php /config/cache.php
/config/session.php /config/session.php
<<<<<<< HEAD
/config/admin.php /config/admin.php
=======
/config/cookie.php
/config/jz.php
>>>>>>> test
/public/dist /public/dist
/public/dist2 /public/dist2
/public/static/uploads /public/static/uploads
/public/static/xadmin /public/static/xadmin
/application/admin/view/staff/role.html
/config/jz.php /config/jz.php
/config/cookie.php /config/cookie.php
...@@ -5,6 +5,7 @@ use app\admin\model\StaffRoleModel; ...@@ -5,6 +5,7 @@ use app\admin\model\StaffRoleModel;
use think\Controller; use think\Controller;
use think\facade\Cookie; use think\facade\Cookie;
use think\facade\Request; use think\facade\Request;
use think\facade\Session;
/** /**
* 控制器基类 * 控制器基类
...@@ -16,13 +17,18 @@ use think\facade\Request; ...@@ -16,13 +17,18 @@ use think\facade\Request;
class Base extends Controller class Base extends Controller
{ {
protected $uid ;
protected $user = [];
//登录检测 //登录检测
protected function initialize(){ protected function initialize(){
$this->user = Session::get('user');
$this->uid = $this->user['user_id'];
$this->check(); $this->check();
} }
private function check(){ private function check(){
$single = new SingleSign(); $single = new SingleSign();
try { try {
$user = $single->getUserInfo(); $user = $single->getUserInfo();
Cookie::set('user',$user['ukey']); Cookie::set('user',$user['ukey']);
......
...@@ -9,6 +9,7 @@ namespace app\admin\controller; ...@@ -9,6 +9,7 @@ namespace app\admin\controller;
use app\admin\model\StaffModel; use app\admin\model\StaffModel;
use think\Exception; use think\Exception;
use think\facade\Cookie; use think\facade\Cookie;
use think\facade\Session;
class SingleSign { class SingleSign {
public $instence = null; public $instence = null;
...@@ -19,6 +20,8 @@ class SingleSign { ...@@ -19,6 +20,8 @@ class SingleSign {
if($res) $this->instence = $redis; if($res) $this->instence = $redis;
else throw new Exception("redis connect faild"); else throw new Exception("redis connect faild");
} }
$sid = Cookie::get('PHPSESSID');
if(!empty($sid)) Cookie::set('PHPSESSID',$sid,['expire'=>time()+3600]);
} }
//获取session //获取session
...@@ -37,15 +40,14 @@ class SingleSign { ...@@ -37,15 +40,14 @@ class SingleSign {
$isAdmin = substr($str,$pos,1); $isAdmin = substr($str,$pos,1);
$user['is_admin'] = $isAdmin; $user['is_admin'] = $isAdmin;
if($user['is_admin'] == true) {
$user['username'] = 'gonnadmin';
} else {
preg_match('/adminuser\|s\:(\d+)\:/',$str,$match); preg_match('/adminuser\|s\:(\d+)\:/',$str,$match);
if($match){ if($match){
$pos = stripos($str,'adminuser|s:') + strlen('adminuser|s:'); $pos = stripos($str,'adminuser|s:') + strlen('adminuser|s:');
$pos += strlen($match[1]) + 2; $pos += strlen($match[1]) + 2;
$user['username'] = substr($str,$pos,$match[1]+0); $user['username'] = substr($str,$pos,$match[1]+0);
} }
if($user['is_admin'] == true && $user['username'] == 'admin') {
$user['username'] = 'gonnadmin';
} }
$pos = stripos($str,'ukey|s:10:') + 11; $pos = stripos($str,'ukey|s:10:') + 11;
...@@ -81,6 +83,8 @@ class SingleSign { ...@@ -81,6 +83,8 @@ class SingleSign {
public function clear($prex = 'PHPREDIS_SESSION:'){ public function clear($prex = 'PHPREDIS_SESSION:'){
$sid = Cookie::get('PHPSESSID'); $sid = Cookie::get('PHPSESSID');
$sid = $prex.$sid; $sid = $prex.$sid;
Cookie::delete($sid);
if($this->instence->set($sid,'')) return true; if($this->instence->set($sid,'')) return true;
return false; return false;
} }
......
...@@ -11,7 +11,7 @@ class PermissionModel extends BaseModel ...@@ -11,7 +11,7 @@ class PermissionModel extends BaseModel
protected $deleteTime = 'delete_time'; protected $deleteTime = 'delete_time';
protected $table = 'permission'; protected $table = 'permission';
private $fields = 'id,title,pid,model_name,controller_name,method_name,params,is_nav,sort,status,update_time'; private $fields = '*';
private $ids = []; private $ids = [];
private function getPermissionTree($fields = '',$isNav = false) private function getPermissionTree($fields = '',$isNav = 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 @@ ...@@ -20,9 +20,7 @@
<option value="1" {if $search_type eq 1 } selected {/if}>站名</option> <option value="1" {if $search_type eq 1 } selected {/if}>站名</option>
<option value="2" {if $search_type eq 2 } 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="3" {if $search_type eq 3 } selected {/if}>项目编号</option>
<option value="4" {if $search_type eq 4 } selected {/if}>机房二维码</option> <option value="4" {if $search_type eq 4 } selected {/if}>机房二维码</option>
</select> </select>
</div> </div>
<div class="layui-input-inline layui-show-xs-block"> <div class="layui-input-inline layui-show-xs-block">
...@@ -44,11 +42,9 @@ ...@@ -44,11 +42,9 @@
{if $region.level == 0} {if $region.level == 0}
<option disabled='disabled' class='layui-disabled' >{$region.region_name}</option> <option disabled='disabled' class='layui-disabled' >{$region.region_name}</option>
{else /} {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} {/if}
{/volist} {/volist}
</select> </select>
</div> </div>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<tr> <tr>
<th>菜单编号</th> <th>菜单编号</th>
<th>名称</th> <th>名称</th>
<th>规则</th> <th>路由</th>
<th>导航</th> <th>导航</th>
<th>排序</th> <th>排序</th>
<th>状态</th> <th>状态</th>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<tr> <tr>
<td>{$item.id}</td> <td>{$item.id}</td>
<td>{$item.name}</td> <td>{$item.name}</td>
<td>{$item.model_name}/{$item.controller_name}/{$item.method_name}/{$item.params}</td> <td>{$item.nav_url ?: '-'}</td>
<td>{if $item.is_nav == 1}是{else /}否{/if}</td> <td>{if $item.is_nav == 1}是{else /}否{/if}</td>
<td>{$item.sort}</td> <td>{$item.sort}</td>
<td class="td-status"> <td class="td-status">
...@@ -97,7 +97,6 @@ ...@@ -97,7 +97,6 @@
var a='<span class="layui-btn layui-btn-normal layui-btn-mini">正常</span>' var a='<span class="layui-btn layui-btn-normal layui-btn-mini">正常</span>'
$('#setstatus'+id).html(a); $('#setstatus'+id).html(a);
return false; return false;
} }
}, },
error : function (XMLHttpRequest, textStatus, errorThrow ) { error : function (XMLHttpRequest, textStatus, errorThrow ) {
......
...@@ -60,7 +60,12 @@ ...@@ -60,7 +60,12 @@
<script src="dist/js/md5.js"></script> <script src="dist/js/md5.js"></script>
<script src="dist/js/sha1.js"></script> <script src="dist/js/sha1.js"></script>
<script src="dist/js/util.js"></script> <script src="dist/js/util.js"></script>
<<<<<<< HEAD
<!--<script src="dist/js/getUserToken.js"></script>--> <!--<script src="dist/js/getUserToken.js"></script>-->
=======
<script src="dist/js/getUserToken.js"></script>
>>>>>>> test
<script> <script>
layui.use(['laydate','form','upload'], function(){ layui.use(['laydate','form','upload'], function(){
upload = layui.upload; upload = layui.upload;
......
File mode changed from 100755 to 100644
<?php <?php
use app\admin\model\PermissionModel;
use app\admin\model\StaffRoleModel;
use think\db;
use think\facade\Session;
function check_data(){
$user = session('user');
//查找数据权限规则表
$map=[];
$permission=db::name('permission_data')->field('permission_ids')->where(['s_id'=>$user['user_id']])->find();
$arr= json_decode($permission['permission_ids'],true);
if($arr['department_id']){
$department_ids=strpos($arr['department_id'],',');
if($department_ids===false){
$map[]=['department_id','=', $arr['department_id']];
}else{
$map[]=['department_id','in',$arr['department_id']];
}
}
if($arr['region_id']){
$area_ids=strpos($arr['region_id'],',');
if($area_ids===false){
$map[]=['area_id','=', $arr['region_id']];
}else{
$map[]=['area_id','in',$arr['region_id']];
}
}
if($arr['business_id']){
$business_ids=strpos($arr['business_id'],',');
if($business_ids===false){
$map[]=['business_line_id','=', $arr['business_id']];
}else{
$map[]=['business_line_id','in',$arr['business_id']];
}
}
//如果数据规则表不存在数据信息 ,默认返回此用户的部门id
if(!$map){
$staff = db::name('staff')->field('d_id')->where(['id'=>$user['user_id']])->find();
if($staff && $staff['d_id']!==0){
$map[]=['department_id','=',$staff['d_id']];
}
}
return $map;
}
function loginlog($name,$id,$desc,$status){
$login['staff_id']=$id;
$login['name']=$name;
$login['description']=$desc;
$login['ip']=\think\facade\Request::ip();
$login['status']=$status;
$login['create_time']=time();
db::name('loginlog')->insert($login);
}
function activity_log($name,$desc,$type){
$login['name']=$name;
$login['description']=$desc;
$login['type']=$type;
$login['create_time']=time();
db::name('activity_log')->insert($login);
}
function curlGet($url=''){
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
$tmpInfo = curl_exec($curl); //返回api的json对象
//关闭URL请求
curl_close($curl);
return $tmpInfo; //返回json对象
}
function httpPOST($url , $post_data = array()){
$headers = array('Content-Type: application/x-www-form-urlencoded');
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_data)); // Post提交的数据包
curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($curl); // 执行操作
if (curl_errno($curl)) {
echo 'Errno'.curl_error($curl);//捕抓异常
}
curl_close($curl); // 关闭CURL会话
return $result;
}
function decrypt ($pass) {
return md5($pass.config('admin.passwd_salt'));
}
//生成10位的随机密码
function createPass(){
return substr(md5(config('admin.passwd_salt').time()),0,10);
}
/**
* 基站状态递归实现无限极分类
* @param $array 分类数据
* @param $pid 父ID
* @param $level 分类级别
* @return $list 分好类的数组 直接遍历即可 $level可以用来遍历缩进
*/
function getTreeStatus($array, $pid =0, $level = 0){
//声明静态数组,避免递归调用时,多次声明导致数组覆盖
static $list = [];
foreach ($array as $key => $value){
//第一次遍历,找到父节点为根节点的节点 也就是pid=0的节点
if ($value['pid'] == $pid){
//父节点为根节点的节点,级别为0,也就是第一级
$value['level'] = $level;
//把数组放到list中
$list[] = $value;
//把这个节点从数组中移除,减少后续递归消耗
unset($array[$key]);
//开始递归,查找父ID为该节点ID的节点,级别则为原级别+1
getTreeStatus($array, $value['cate_id'], $level+1);
}
}
return $list;
}
/**
* 递归实现无限极分类
* @param $array 分类数据
* @param $pid 父ID
* @param $level 分类级别
* @return $list 分好类的数组 直接遍历即可 $level可以用来遍历缩进
*/
function getTree($array, $pid =0, $level = 0){ function getTree($array, $pid =0, $level = 0){
//声明静态数组,避免递归调用时,多次声明导致数组覆盖 //声明静态数组,避免递归调用时,多次声明导致数组覆盖
static $list = []; static $list = [];
...@@ -17,3 +157,205 @@ function getTree($array, $pid =0, $level = 0){ ...@@ -17,3 +157,205 @@ function getTree($array, $pid =0, $level = 0){
} }
return $list; return $list;
} }
function getNodesTree($array,$pid=0){
$list = [];
foreach ($array as $k => $v) {
if ($v['pid'] == $pid) {
$v['children'] = getNodesTree($array, $v['id']);
$list[] = $v;
}
}
return $list;
}
function getNodeIds($data,$pid=0){
static $nodes = [];
if(empty($nodes)){
$nodes[] = $pid;
}
foreach ($data as $k=>$v){
if ($v['pid'] == $pid){
$nodes [] = $v['id'];
getNodesTree($data,$v['id']);
unset($data[$k]);
}
}
return $nodes;
}
function jsonSuc($message,$data=''){
if(!empty($data)){
return json([
'status' => 1,
'message' => $message,
'data' => $data
]);
} else {
return json([
'status' => 1,
'message' => $message
]);
}
}
function jsonErr($err){
return json([
'status' => 0,
'message' => $err
]);
}
function dd($mix)
{
echo "<pre/>";
var_dump($mix);
die;
}
function zero($num){
if(!is_numeric($num)) return '';
$len = strlen($num);
$str = str_repeat('0',5-$len).$num;
return $str;
}
//解析账单状态
function parseStatus($stauts,$type=0,$return=0){
$msg = [];
$arr = [];
for ($i=0;$i<strlen($stauts);$i++){
$arr[$i] = $stauts[$i];
}
switch ($arr[0]){
case 0:
$msg[] = '未缴费';
break;
case 1:
$msg[] = '部分缴费';
break;
case 2:
$msg[] = '已缴费';
break;
}
if($type == 1 && $return == 0) return $msg[0];
if($type == 1 && $return == 1) return $arr[0];
switch ($arr[1]){
case 0:
$msg[] = '未结算';
break;
case 1:
$msg[] = '部分结算';
break;
case 2:
$msg[] = '已结算';
break;
}
if($type == 1 && $return == 0) return $msg[1];
if($type == 1 && $return == 1) return $arr[1];
switch ($arr[2]){
case 0:
$msg[] = '未确收';
break;
case 1:
$msg[] = '确收中';
break;
case 2:
$msg[] = '已确收';
break;
}
if($type == 2 && $return == 0) return $msg[2];
if($type == 2 && $return == 1) return $arr[2];
return implode(' ',$msg);
}
/**
* 设置账单状态
* @param $statusCode
* @param $index
* @param $value
*/
function setInvoiceStatus($statusCode,$value,$index=0){
return substr_replace($statusCode,$value,$index,1);
}
/**
* 读取账单状态
* @param $statusCode
* @param $index
* @param $value
*/
function getInvoiceStatus($statusCode,$index=0){
return substr($statusCode,$index,1);
}
function getInvoicesStatusName($statusCode,$index=0){
$status = getInvoiceStatus($statusCode,$index);
if($index == 0){
switch ($status){
case 0:
return '未缴费';
break;
case 1:
return '部分缴费';
break;
case 2:
return '已缴清';
break;
}
}
elseif ($index == 1){
switch ($status){
case 0:
return '未结算';
break;
case 1:
return '部分结算';
break;
case 2:
return '已结算';
break;
}
} else {
switch ($status){
case 0:
return '未确收';
break;
case 1:
return '确收中';
break;
case 2:
return '已确收';
break;
}
}
}
//检测元素与按钮权限
function check_ele_permission($path){
$user = Session::get('user');
//获取当前用户的所有权限id
$permissions = StaffRoleModel::getStaffRolesById($user['user_id']);
$permissions = explode(',',$permissions);
//查询$path所对应id
$permission = PermissionModel::field('id,nav_url')->get(['nav_url'=>$path]);
if(isset($permission->id)){
if(!in_array($permission->id,$permissions) || $permission == null){
return false;
}
return true;
}
return false;
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: chouchou
* Date: 2020-6-21
* Time: 18:52
*/
namespace app\api\controller\v2\common;
use app\em\controller\Account;
use app\em\controller\WriteOff;
use app\em\model\EmInvoice;
use app\em\model\EmPayment;
use app\em\model\EmPaymentFk;
use app\em\model\EmPaymentInvoice;
use think\facade\Log;
class Payment
{
public function index()
{
$data = request()->get();
$res = $this->checkKey($data['key']);
if ($res !== true) return json([
'code' => 201,
'message' => $res,
'data' => ''
]);
if ($data['action'] == 1) {
Log::record(date('Y-m-d H:i:s').' OA单号:'.$data['numb'].' 接口操作:单据状态更新');
return $this->update($data['numb'],$data['status'],$data['mes']);
} else {
return $this->dropNumb($data['numb'],$data['status']);
}
}
//更新payment状态
private function update($numb,$status,$mes='')
{
$paymentFk = (new EmPaymentFk())->get(['oafk_numb' => $numb]);
$payment = (new EmPayment())->get(['payment_id' => $paymentFk->payment_id]);
//更新账户余额
if($payment->account_id != ''){
(new Account())->computerAmountFromPay($payment->account_id,$payment->amount);
}
$res = (new WriteOff())->writeOffFromPayment($payment->payment_id);
$payment->status = $status;
$payment->pay_date = time();
$payment->save();
Log::record(date('Y-m-d H:i:s').' OA单号:'.$numb . $res);
return json([
'code' => 201,
'message' => $res,
'data' => ''
]);
}
//作废单据
private function dropNumb($numb,$status)
{
$paymentFk = (new EmPaymentFk())->get(['oafk_numb' => $numb,'status'=>1]);
$payment = (new EmPayment())->get(['payment_id' => $paymentFk->payment_id]);
$paymentFk->status = 0;
$paymentFk->save();
$payment->status = 9;
$payment->save();
//删除payment_invoice表
$delNum = (new EmPaymentInvoice())->where('payment_id', '=', $payment->payment_id)->delete();
Log::record(date('Y-m-d H:i:s').' OA单号:'.$numb. '缴费单已作废');
return json(
[
'code' => 201,
'message' => json_encode($payment->toArray()),
'data' => ''
]);
}
private function checkKey($key)
{
if (empty($key)) {
return '秘钥不能为空';
}
$baseKey = substr(md5(config('oafk.oa_key') . date('Y-m-d')), 0, 12);
if ($key != $baseKey) {
return '秘钥错误';
}
return true;
}
public function setInvoiceStatus($statusCode, $value, $index = 0)
{
return substr_replace($statusCode, $value, $index, 1);
}
public function test(){
$data = request()->get();
if ($data['action'] == 1) {
Log::record(date('Y-m-d H:i:s').' OA单号:'.$data['numb'].' 接口操作:单据状态更新');
return $this->update($data['numb'],$data['status'],$data['mes']);
} else {
return $this->dropNumb($data['numb'],$data['status']);
}
}
public function commonCheckKey($key){
return $this->checkKey($key);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: chouchou
* Date: 2020-6-21
* Time: 18:52
*/
namespace app\api\controller\v2\common;
use think\Controller;
use think\Db;
class Project extends Controller
{
public $jzdb;
public function initialize()
{
$this->jzdb = Db::connect([
'type' => config('jz.jztype'),
'hostname' => config('jz.jzhostname'),
'database' => config('jz.jzdatabase'),
'username' => config('jz.jzusername'),
'password' => config('jz.jzpassword'),
'hostport' => config('jz.jzhostport'),
'charset' => config('jz.jzcharset'),
]);
}
public function project_list()
{
$data = request()->get() ?: [];
if(!array_key_exists('key',$data)){
json([
'code' => 201,
'message' => 'request params not found!',
'data' => ''
]);
} else {
$res = (new Payment())->commonCheckKey($data['key']);
}
if ($res !== true) return json([
'code' => 201,
'message' => $res,
'data' => ''
]);
$project_code = $data['project_code'];
if (empty($project_code)) {
return json([
'code' => 202,
'message' => 'Not valid parameter',
]);
}
$map[] = ['project_code', '=', $project_code];
$datalist = $this->jzdb->table('jz_message')->field('project_code,jz_cur_dept')->where($map)->select();
return json([
'code' => 200,
'message' => 'SUCCESS',
'data' => $datalist,
]);
}
}
\ No newline at end of file
...@@ -107,12 +107,6 @@ function createPass(){ ...@@ -107,12 +107,6 @@ function createPass(){
return substr(md5(config('admin.passwd_salt').time()),0,10); return substr(md5(config('admin.passwd_salt').time()),0,10);
} }
//生成10位的随机密码
//将密码返回给控制器
//控制器通过MD加密之后存储到数据库
/** /**
* 基站状态递归实现无限极分类 * 基站状态递归实现无限极分类
* @param $array 分类数据 * @param $array 分类数据
......
<?php <?php
namespace app\em\controller; namespace app\em\controller;
use app\admin\controller\Base;
use app\em\model\EmAccount; use app\em\model\EmAccount;
use app\em\model\EmAccountAmount;
use think\Controller;
/** /**
* 电表账户 * 电表账户
* Class Acount * Class Acount
* @package app\em\controller * @package app\em\controller
*/ */
class Account extends Base class Account extends Controller
{ {
//账户初始化 //账户初始化
private function init($em_id){ private function init($em_id){
...@@ -93,4 +94,34 @@ class Account extends Base ...@@ -93,4 +94,34 @@ class Account extends Base
} }
return $account->save(); return $account->save();
} }
public function computerAmountFromInv($em_id,$balance,$invoice_id = ''){
//更新账户余额
$account = (new EmAccount())->get(['em_id'=>$em_id]);
$account->amount -= $balance;
if($res = $account->save()){
$this->recordAmount($invoice_id,'抄表单',$balance);
}
return $res;
}
public function computerAmountFromPay($account_id,$balance){
//更新账户余额
$account = (new EmAccount())->get(['account_id'=>$account_id]);
$account->amount += $balance;
if($res = $account->save()){
$this->recordAmount($account_id,'缴费单',$balance);
}
return $res;
}
protected function recordAmount($numb,$type,$amount){
$record = new EmAccountAmount();
$record->numb = $numb;
$record->amount = $amount;
$record->type = $type;
return $record->save();
}
} }
\ No newline at end of file
...@@ -40,40 +40,28 @@ class Em extends Base ...@@ -40,40 +40,28 @@ class Em extends Base
if($search_text){ if($search_text){
switch ($search_type) { switch ($search_type) {
case '1': case '1':
$this->assign('search_text',$search_text);
$map[]=['s.station_name','like',"%$search_text%"]; $map[]=['s.station_name','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break; break;
case '2': case '2':
$this->assign('search_text',$search_text);
$map[]=['s.station_sp_code','like',"%$search_text%"]; $map[]=['s.station_sp_code','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break; break;
case '3': case '3':
$this->assign('search_text',$search_text);
$map[]=['s.proj_number','like',"%$search_text%"]; $map[]=['s.proj_number','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break; break;
case '4': case '4':
$this->assign('search_text',$search_text);
$map[]=['em.em_numb','like',"%$search_text%"]; $map[]=['em.em_numb','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break; break;
case '5': case '5':
$this->assign('search_text',$search_text);
$map[]=['em.qrcode','like',"%$search_text%"]; $map[]=['em.qrcode','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break; break;
case '6': case '6':
$this->assign('search_text',$search_text);
$map[]=['d.rent','like',"%$search_text%"]; $map[]=['d.rent','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break; break;
} }
}else{
$this->assign('search_type','');
$this->assign('search_text','');
} }
$this->assign('search_type',$search_type ?: '');
$this->assign('search_text',$search_text ?: '');
$operator = Request::param('operator'); $operator = Request::param('operator');
if($operator){ if($operator){
$map[] = ['s.original_sp_id','=',$operator]; $map[] = ['s.original_sp_id','=',$operator];
...@@ -88,8 +76,8 @@ class Em extends Base ...@@ -88,8 +76,8 @@ class Em extends Base
}else{ }else{
$this->assign('area_id',''); $this->assign('area_id','');
} }
$page =Request::param('page')?Request::param('page'):1; $page =Request::param('page')?:1;
$limit = Request::param('limit')?Request::param('limit'):10; $limit = Request::param('limit')?:10;
$emModel = new EmList(); $emModel = new EmList();
$list = $emModel->getEmList($map,$page,$limit); $list = $emModel->getEmList($map,$page,$limit);
...@@ -98,7 +86,6 @@ class Em extends Base ...@@ -98,7 +86,6 @@ class Em extends Base
return ['code'=>0,'msg'=>'','count'=>$emCount,'data'=>$list]; return ['code'=>0,'msg'=>'','count'=>$emCount,'data'=>$list];
} }
$region=new ElectricMeter(); $region=new ElectricMeter();
$operator=new OperatorModel();
$operators = OperatorModel::field('operator_id,operator_name')->where('operator_state','=',1)->select()->toArray(); $operators = OperatorModel::field('operator_id,operator_name')->where('operator_state','=',1)->select()->toArray();
$this->assign('regions',getTree($region->regions())); $this->assign('regions',getTree($region->regions()));
$this->assign('operators',$operators); $this->assign('operators',$operators);
......
<?php
namespace app\em\controller;
use app\admin\controller\Base;
use app\em\model\EmInvoice;
use app\em\model\EmPaymentReceipt;
use app\em\model\EmReceiptType;
use app\em\validate\AddReceiptValidate;
use think\facade\Request;
/**
* 缴费发票
* Class Receipt
* @package app\em\controller
*/
class Receipt extends Base
{
//显示缴费凭证表单
public function create(){
$payment_id = Request::param('payment_id');
//将缴费应缴金额传递给模板
$balance = (new EmInvoice())->alias('ei')
->leftJoin(['em_payment_invoice'=>'epi'],'epi.invoice_id=ei.invoice_id')
->where('epi.payment_id','=',$payment_id)
->where('ei.payment_balance','>',0)
->sum('ei.payment_balance');
$this->assign('balance',$balance?:0);
$this->assign('payment_id',$payment_id);
$types = EmReceiptType::select();
$this->assign('types',$types);
return $this->fetch();
}
public function store(){
$data = Request::post();
$validata = new AddReceiptValidate();
if(!$validata->check($data)){
return json(['status'=>0,'message'=>$validata->getError()]);
}
//获取certId
$data['receipt_id'] = $this->createReceiptId();
//保存凭证
$receiptModel = new EmPaymentReceipt();
if($receiptModel->save($data)){
//更新缴费单状态
return json(['status'=>1,'message'=>'上传发票成功']);
} else {
return json(['status'=>0,'message'=>'添加发票失败']);
}
}
//查看列表
public function receipts(){
$payment_id = Request::param('payment_id');
$list = EmPaymentReceipt::with('file,types')->where('payment_id','=',$payment_id)->order('receipt_id asc')->select();
foreach ($list as &$item){
if(!empty($item->file->src)){
$item->file->src = ltrim($item->file->src,'.');
}
}
$this->assign('data',$list);
return $this->fetch('list');
}
//创建凭证id
private function createReceiptId(){
$epr = EmPaymentReceipt::field('id')->order('id desc,create_time desc')->find();
if(!$epr) $id = 1;
else $id = $epr->id + 1;
return "RT".date('Ymd').zero($id);
}
}
\ No newline at end of file
...@@ -6,12 +6,8 @@ ...@@ -6,12 +6,8 @@
namespace app\em\controller; namespace app\em\controller;
use app\admin\controller\Base; use app\admin\controller\Base;
use app\admin\model\DepartmentModel;
use app\admin\model\ElectricMeter; use app\admin\model\ElectricMeter;
use app\admin\model\ElectricMeterType;
use app\admin\model\OperatorModel; use app\admin\model\OperatorModel;
use app\admin\model\StaffModel;
use app\admin\model\BaseStationModel;
use think\db; use think\db;
use think\Exception; use think\Exception;
use think\facade\Request; use think\facade\Request;
......
...@@ -9,7 +9,6 @@ use app\em\model\Staff; ...@@ -9,7 +9,6 @@ use app\em\model\Staff;
use app\em\model\Station; use app\em\model\Station;
use app\em\model\UseageDetail; use app\em\model\UseageDetail;
use app\em\validate\UseageGeneralInfoValidate; use app\em\validate\UseageGeneralInfoValidate;
use think\Db;
use think\facade\Request; use think\facade\Request;
use think\facade\Session; use think\facade\Session;
...@@ -94,14 +93,14 @@ class Useage extends Base ...@@ -94,14 +93,14 @@ class Useage extends Base
} }
//生成抄表单 //生成抄表单
public function create($detail=false){ public function create(){
$em_id = Request::param('id'); $em_id = Request::param('id');
if(!(new Em())->checkEmComplete($em_id)){ if(!(new Em())->checkEmComplete($em_id)){
$this->error('电表信息不完整,需要补充基础信息','/em'); $this->error('电表信息不完整,需要补充基础信息','/em');
} }
$em = (new \app\em\model\Em)->getEmUseageInfoById($em_id,$detail); $em = (new \app\em\model\Em)->getEmUseageInfoById($em_id,false);
//基站信息 //基站信息
$station_info = Station::getBaseInfoById($em->station_id); $station_info = Station::getBaseInfoById($em->station_id);
...@@ -115,7 +114,7 @@ class Useage extends Base ...@@ -115,7 +114,7 @@ class Useage extends Base
$this->assign('staffs',(new Staff())->getStaffs($user['is_admin'],'','useage')); $this->assign('staffs',(new Staff())->getStaffs($user['is_admin'],'','useage'));
$this->assign('em',$em); $this->assign('em',$em);
$this->assign('detail',$detail); $this->assign('detail',false);
return $this->fetch('default'); return $this->fetch('default');
} }
...@@ -152,7 +151,12 @@ class Useage extends Base ...@@ -152,7 +151,12 @@ class Useage extends Base
//数据验证 //数据验证
$validate = new UseageGeneralInfoValidate(); $validate = new UseageGeneralInfoValidate();
//根据计量模式 验证去表单数据 //根据计量模式 验证去表单数据
if(!$validate->scene('s1')->check($data)){
$sence = 's1';
if($data['pricing_type'] == 2){
$sence = 's2';
}
if(!$validate->scene($sence)->check($data)){
return json(['status'=>0,'message'=>$validate->getError()]); return json(['status'=>0,'message'=>$validate->getError()]);
} }
//获取电表基本信息 //获取电表基本信息
...@@ -161,15 +165,15 @@ class Useage extends Base ...@@ -161,15 +165,15 @@ class Useage extends Base
if(empty($useage_id)) { if(empty($useage_id)) {
$uModel = new \app\em\model\Useage(); $uModel = new \app\em\model\Useage();
$uModel->useage_id = $this->getUId(); $uModel->useage_id = $this->getUId();
$user = Session::get('user'); $uModel->uid = $this->uid;
$uModel->uid = $user['user_id'];
$uModel->last_sum_numb = $data['last_numb']; $uModel->last_sum_numb = $data['last_numb'];
$uModel->last_date = $data['last_date']; $uModel->last_date = $data['last_date'];
$uModel->em_id = $data['em_id']; $uModel->em_id = $data['em_id'];
$uModel->amount = isset($data['amount']) ? $data['amount'] : 0;
//峰谷类型 //峰谷类型
$uModel->type = $data['pricing_type']; $uModel->type = $data['pricing_type'];
} } else {
else {
$this->checkEnd($useage_id); $this->checkEnd($useage_id);
$action = '修改'; $action = '修改';
$uModel = (new \app\em\model\Useage())->get(['useage_id' => $useage_id]); $uModel = (new \app\em\model\Useage())->get(['useage_id' => $useage_id]);
...@@ -226,9 +230,8 @@ class Useage extends Base ...@@ -226,9 +230,8 @@ class Useage extends Base
$useage->save(); $useage->save();
//触发销账逻辑 //触发销账逻辑
$result = (new Invoice())->writeOffFromInvoice($inv->invoice_id,$inv->account_id); $result = (new WriteOff())->writeOffFromInvoice($inv->invoice_id);
return json(['status'=>1,'message'=>"已审核,并生成账单,$result"]); return json(['status'=>1,'message'=>"已审核,并生成账单,$result"]);
//return json(['status'=>1,'message'=>"已审核,并生成账单"]);
} }
//获取单号 //获取单号
...@@ -310,16 +313,9 @@ class Useage extends Base ...@@ -310,16 +313,9 @@ class Useage extends Base
return true; return true;
} }
//审核 //审核
public function verify($usage_id,$status=2){ public function verify($usage_id,$status=2){
$user = Session::get('user'); $user = Session::get('user');
$cModel = new EmCheckBill(); (new EmCheckBill)->check(Request::param('refuseInfo'),$user['user_id'],Request::controller(),$usage_id,$status);
$cModel->info = Request::param('refuseInfo');
$cModel->uid = $user['user_id'];
$cModel->mode = 'useage';
$cModel->mode_id = $usage_id;
$cModel->status = $status;
$cModel->save();
} }
} }
\ No newline at end of file
<?php
namespace app\em\controller;
use app\em\model\EmInvoice;
use app\em\model\EmPayment;
use app\em\model\EmPaymentInvoice;
use app\em\model\EmPaymentInvoiceBalance;
use think\Controller;
use think\facade\Log;
class WriteOff extends Controller
{
public function writeOffFromPayment($payment_id){
Log::info('触发销账:{$payment_id}');
//获取缴费单对象
$payment = EmPayment::where('payment_id','=',$payment_id)->find();
$invModel = new EmInvoice();
//获取关联的账单对象
$invs = $invModel->alias('a')->field('a.invoice_id')
->join(['em_payment_invoice'=>'b'],'b.invoice_id = a.invoice_id')
->where('b.payment_id','=',$payment_id)
->where('a.payment_balance','neq',0)
->order('a.invoice_id asc')
->select();
$invsArr = [];
$payments_balance = 0;
//如果存在账单关联对象
if(!$invs->isEmpty()){
foreach ($invs as $inv){
$invsArr[] = $inv->invoice_id;
}
//查询可消的额度
$payments_balance = $invModel->where('invoice_id','in',$invsArr)->sum('payment_balance');
}
if($payment->balance > $payments_balance) {
//如果可以完全销账 则继续销账
$invss = $invModel->field('invoice_id')
->where('account_id', '=', $payment->account_id)
->where('payment_balance', 'neq', 0)
->whereNotIn('invoice_id', $invsArr)
->order('invoice_id asc')
->select();
if (!$invss->isEmpty()) {
foreach ($invss as $inv) {
$invsArr[] = $inv->invoice_id;
}
}
}
$paymentIds[] = $payment->payment_id;
//销账日志
$logMsg = date('Y-m-d H-i-s').'paymentIds :' .implode('-',$paymentIds) .'invoiceIds :' .implode('-',$invsArr);
Log::info($logMsg);
//处理账户金额
return $this->writeOff($paymentIds,$invsArr);
}
/**
* 账单触发销账,invoice_id 1:n payment_id
* @param $account_id
* @param $invoice_id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @return mixed
*/
public function writeOffFromInvoice($invoice_id){
//获取账单对象
$invoice = EmInvoice::field('id,invoice_id,account_id,payment_amount,payment_balance')
->where('invoice_id','=',$invoice_id)->find();
//查询关系表中与当前invoice_id相关联的payment_id
$model = new EmPaymentInvoice;
$payments = $model->alias('epi')->field('epi.payment_id')
->leftJoin(['em_payment'=>'ep'],'epi.payment_id = ep.payment_id')
->leftJoin(['em_payment_invoice_balance'=>'epib'],'epib.invoice_id=epi.invoice_id')
->where('epib.balance','>',0)
->where('epi.invoice_id','=',$invoice_id)->select();
//如果没有找到记录 证明并没有形成对应关系
if($payments->isEmpty()){
//查询是否有未缴费的缴费单存在
$payments = EmPayment::field('payment_id')->where('account_id','=',$invoice->account_id)
->where('balance','>',0)
->whereIn('status','3,4,5')
->order('payment_id asc')
->select();
if($payments->isEmpty()) return '没有找到可销账的缴费单!';
}
$paymentIds = [];
foreach ($payments as $payment){
$paymentIds[] = $payment->payment_id;
}
$invsIds = [
'invoice_id' => $invoice->invoice_id
];
//销账日志
$logMsg = date('Y-m-d H-i-s').'paymentIds :' .implode('-',$paymentIds) .'invoiceIds :' .implode('-',$invsIds);
Log::info($logMsg);
//开始销账
return $this->writeOff($paymentIds,$invsIds);
}
/**
* @param $account_id
* @param $invoiceIds
* @param $paymentIds
* @return mixed
*/
private function writeOff($paymentIds,$invoiceIds){
Log::info('执行销账:');
//获取可销账缴费单
$payments = EmPayment::where('payment_id','in',$paymentIds)->order('payment_id asc')->select();
//获取可销账账单
$invs = EmInvoice::where('invoice_id','in',$invoiceIds)->order('invoice_id asc')->select();
$result = 0;
foreach ($payments as $key => $payment){
if($payment->balance == 0) continue;
foreach ($invs as $index => $inv) {
if ($inv->payment_balance == 0) continue;
$balanceMode = new EmPaymentInvoiceBalance();
$balanceMode->payment_id = $payment->payment_id;
$balanceMode->invoice_id = $inv->invoice_id;
//如果该缴费单可以完全消除当前账单额度
if ($payment->balance >= $inv->payment_balance) {
//单笔销账多少
$balanceMode->balance = $inv->payment_balance;
$payment->balance = $payment->balance - $inv->payment_balance;
//账单额度变化
$inv->payment_balance = 0;
//更新账户status 首字母 = 2
$inv->status = setInvoiceStatus($inv->status, 2);
} else {
//单笔销账多少
$balanceMode->balance = $payment->balance;
//账单额度变化
$inv->status = setInvoiceStatus($inv->status, 1);
$inv->payment_balance = $inv->payment_balance - $payment->balance;
//缴费额度变化
$payment->balance = 0;
}
//更新账单状态
$inv->save();
//更新缴费状态
$payment->save();
//查找是否已经存在相关联的账单关系
$model = (new EmPaymentInvoice())->where(['payment_id'=>$payment->payment_id,'invoice_id'=>$inv->invoice_id])->find();
if(!$model){
$model = new EmPaymentInvoice();
$model->payment_id = $payment->payment_id;
$model->invoice_id = $inv->invoice_id;
$model->save();
}
$result++;
$balanceMode->isUpdate(false)->save();
// if($inv->is_pay != 1) $this->computerAmount($inv->account_id,$dk_balance);
}
}
$msg = $result == 0 ? '已审核,没有找到可销账的缴费单.' : '已审核,成功销账 '.$result.' 笔账单.';
return $msg;
}
}
\ No newline at end of file
...@@ -54,19 +54,20 @@ class Em extends Base ...@@ -54,19 +54,20 @@ class Em extends Base
//最后一次抄表记录 //最后一次抄表记录
if($curr == false){ if($curr == false){
$ue = Useage::order('create_time desc,id desc')->get(['em_id'=>$id]); $ue = Useage::order('create_time desc,id desc')->get(['em_id'=>$id]);
} else {
$ue = Useage::with('photo')->order('create_time desc,id desc')->get(['em_id'=>$id]);
} }
//如果没有超过表 不论是峰谷表还是普通表 都是空的 //如果没有超过表 不论是峰谷表还是普通表 都是空的
if(!$ue) { if(!$ue) {
$ue = new Useage(); $ue = new Useage();
$ue->last_date = $em->init_date; $ue->last_date = $em->init_date;
$ue->last_sum_numb = $em->init_numb ?: 0; $ue->last_sum_numb = $em->init_numb ?: 0;
$ue->amount = 0;
} else { } else {
if($curr == false){ if($curr == false){
$ue->last_sum_numb = $ue->current_sum_numb; $ue->last_sum_numb = $ue->current_sum_numb;
$ue->last_date = $ue->current_date; $ue->last_date = $ue->current_date;
} }
$ue->amount = 0;
} }
$ue->price = $em->rule->pricing_type==1 ? $em->rule->pay_price : ''; $ue->price = $em->rule->pricing_type==1 ? $em->rule->pay_price : '';
$em->useage = $ue; $em->useage = $ue;
...@@ -76,7 +77,7 @@ class Em extends Base ...@@ -76,7 +77,7 @@ class Em extends Base
//获取电表信息与station信息 //获取电表信息与station信息
public function getBaseInfo($em_id){ public function getBaseInfo($em_id){
$data = self::field('em.id,em.em_numb,em.em_type_id,em.rate') $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') ->field('et.name as typeName')
->leftJoin(['station_info'=>'s'],'s.station_id=em.station_id') ->leftJoin(['station_info'=>'s'],'s.station_id=em.station_id')
->leftJoin(['em_type'=>'et'],'et.id=em.em_type_id') ->leftJoin(['em_type'=>'et'],'et.id=em.em_type_id')
......
<?php
namespace app\em\model;
class EmAccountAmount extends Base
{
protected $table = 'em_account_amount';
}
\ No newline at end of file
<?php <?php
namespace app\em\model; namespace app\em\model;
class EmCheckBill extends Base class EmCheckBill extends Base
{ {
public function check($info,$uid,$mode,$mode_id,$status){
$this->info = $info;
$this->uid = $uid;
$this->mode = $mode;
$this->mode_id = $mode_id;
$this->status = $status;
$this->save();
}
} }
\ No newline at end of file
...@@ -32,7 +32,7 @@ class EmInvoice extends Base ...@@ -32,7 +32,7 @@ class EmInvoice extends Base
public function getInvoiceList($map,$Nowpage,$limits){ public function getInvoiceList($map,$Nowpage,$limits){
$data = self::alias('inv') $data = self::alias('inv')
->field('inv.*') ->field('inv.*')
->field('station.station_name,em.em_numb') ->field('station.station_name,em.em_numb,em.em_type_id')
->field('eu.last_sum_numb,eu.current_sum_numb,eu.current_date,FROM_UNIXTIME(eu.current_date,"%Y-%m-%d %H:%i:%S") as now_date,eu.em_id') ->field('eu.last_sum_numb,eu.current_sum_numb,eu.current_date,FROM_UNIXTIME(eu.current_date,"%Y-%m-%d %H:%i:%S") as now_date,eu.em_id')
->join(['em_invoice_useage'=>'eiu'],'eiu.invoice_id = inv.invoice_id') ->join(['em_invoice_useage'=>'eiu'],'eiu.invoice_id = inv.invoice_id')
->join(['em_useage'=>'eu'],'eu.useage_id = eiu.useage_id') ->join(['em_useage'=>'eu'],'eu.useage_id = eiu.useage_id')
...@@ -87,12 +87,13 @@ class EmInvoice extends Base ...@@ -87,12 +87,13 @@ class EmInvoice extends Base
$data = self::alias('inv') $data = self::alias('inv')
->field('inv.*') ->field('inv.*')
->field('station.station_name') ->field('station.station_name')
->field('em.em_numb') ->field('em.em_numb,em.em_type_id')
->join(['em_account'=>'ea'],'ea.account_id = inv.account_id') ->join(['em_account'=>'ea'],'ea.account_id = inv.account_id')
->join(['em'],'em.id=ea.em_id') ->join(['em'],'em.id=ea.em_id')
->join(['station_info'=>'station'],'station.station_id=em.station_id') ->join(['station_info'=>'station'],'station.station_id=em.station_id')
->where(['inv.invoice_id'=>$ids]) ->where(['inv.invoice_id'=>$ids])
// ->where('inv.payment_balance','neq',0) ->whereNotIn('em.em_type_id','2,4')
->where('inv.payment_balance','neq',0)
->select(); ->select();
return $data; return $data;
} }
...@@ -116,7 +117,7 @@ class EmInvoice extends Base ...@@ -116,7 +117,7 @@ class EmInvoice extends Base
$eiu = EmInvoiceUseage::where(['invoice_id'=>$inv->invoice_id])->find(); $eiu = EmInvoiceUseage::where(['invoice_id'=>$inv->invoice_id])->find();
//查询抄表信息 //查询抄表信息
$useage = Useage::get(['useage_id'=>$eiu->useage_id]); $useage = Useage::with('photo')->get(['useage_id'=>$eiu->useage_id]);
if($useage->photo_id) { if($useage->photo_id) {
$receipt = Receipt::get(['id'=>$useage->photo_id]); $receipt = Receipt::get(['id'=>$useage->photo_id]);
......
<?php <?php
namespace app\em\model; namespace app\em\model;
use app\em\controller\Payment;
class EmPayment extends Base class EmPayment extends Base
{ {
protected $table = 'em_payment'; protected $table = 'em_payment';
public function getPayDateAttr($val){ public function getPayDateAttr($val){
if($val =='' || $val == 0){
return '尚未付款';
}
return date('Y-m-d H:i:s',$val); return date('Y-m-d H:i:s',$val);
} }
public function setPayDateAttr($val){ public function setPayDateAttr($val){
if(is_int($val) && strlen($val) >= 10) return $val;
if(date('Y-m-d H:i:s',strtotime($val)) == $val){
return strtotime($val); return strtotime($val);
} }
return 0;
}
//缴费单+search //缴费单+search
public function getPaymentList($map,$Nowpage,$limits){ public function getPaymentList($map,$Nowpage,$limits){
...@@ -18,31 +26,53 @@ class EmPayment extends Base ...@@ -18,31 +26,53 @@ class EmPayment extends Base
//先找到账单 //先找到账单
$data = self::alias('pay') $data = self::alias('pay')
->field('pay.*') ->field('pay.*')
->field('case pay.status
when 0 then "未缴费"
when 1 then "已缴费"
when 2 then "已上传发票"
when 3 then "凭证完整"
when 4 then "已审核"
end as status')
->field('epi.invoice_id') ->field('epi.invoice_id')
->field('em.em_numb') ->field('em.em_numb')
->field('r.region_name,station.station_name') ->field('r.region_name,station.station_name')
->leftJoin(['em_account'=>'ea'],'ea.account_id=pay.account_id')
->leftJoin(['em_payment_invoice'=>'epi'],'epi.payment_id = pay.payment_id') ->leftJoin(['em_payment_invoice'=>'epi'],'epi.payment_id = pay.payment_id')
->leftJoin(['em_invoice'=>'ei'],'ei.invoice_id=epi.invoice_id')
->leftJoin(['em_account'=>'ea'],'ea.account_id=ei.account_id')
->leftJoin(['em'],'em.id=ea.em_id')
->leftJoin(['station_info'=>'station'],'station.station_id=em.station_id')
->leftJoin(['region'=>'r'],'station.area_id = r.id')
->where($map)
->order('pay.id desc')
->group('pay.payment_id')
->page($Nowpage, $limits)
->select()
->toarray();
$arr = [];
foreach ($data as $v){
$arr[] = $v['payment_id'];
}
$data2 = self::alias('pay')
->field('pay.*')
->field('em.em_numb,r.region_name,station.station_name')
->leftJoin(['em_account'=>'ea'],'ea.account_id=pay.account_id')
->leftJoin(['em'],'em.id=ea.em_id') ->leftJoin(['em'],'em.id=ea.em_id')
->leftJoin(['station_info'=>'station'],'station.station_id=em.station_id') ->leftJoin(['station_info'=>'station'],'station.station_id=em.station_id')
->leftJoin(['region'=>'r'],'station.area_id = r.id') ->leftJoin(['region'=>'r'],'station.area_id = r.id')
->where($map) ->where($map)
->whereNotIn('pay.payment_id',$arr)
->order('pay.id desc') ->order('pay.id desc')
->group('pay.payment_id')
->page($Nowpage, $limits) ->page($Nowpage, $limits)
->select() ->select()
->toarray(); ->toarray();
$data = array_merge($data,$data2);
$sortKey = [];
foreach ($data as $k=>$item){ foreach ($data as $k=>$item){
$data[$k]['amount'] = round($data[$k]['amount'],3); $data[$k]['amount'] = round($data[$k]['amount'],2);
$data[$k]['status'] = Payment::PAYMENT_STATUS[$item['status']];
$data[$k]['payment_type'] = Payment::PAYMENT_TYPE[$item['payment_type']];
$sortKey[$k] = $item['create_time'];
} }
array_multisort($sortKey, SORT_DESC, $data);
return $data; return $data;
} }
public function getPaymentCount($map){ public function getPaymentCount($map){
...@@ -50,16 +80,29 @@ class EmPayment extends Base ...@@ -50,16 +80,29 @@ class EmPayment extends Base
//先找到账单 //先找到账单
$data = self::alias('pay') $data = self::alias('pay')
->field('pay.*') ->field('pay.*')
->field('epi.invoice_id')
->field('em.em_numb') ->field('em.em_numb')
->field('r.region_name') ->field('r.region_name,station.station_name')
->join(['em_account'=>'ea'],'ea.account_id=pay.account_id')
->leftJoin(['em_payment_invoice'=>'epi'],'epi.payment_id = pay.payment_id') ->leftJoin(['em_payment_invoice'=>'epi'],'epi.payment_id = pay.payment_id')
->join(['em'],'em.id=ea.em_id') ->leftJoin(['em_invoice'=>'ei'],'ei.invoice_id=epi.invoice_id')
->join(['station_info'=>'station'],'station.station_id=em.station_id') ->leftJoin(['em_account'=>'ea'],'ea.account_id=ei.account_id')
->join(['region'=>'r'],'station.area_id = r.id') ->leftJoin(['em'],'em.id=ea.em_id')
->leftJoin(['station_info'=>'station'],'station.station_id=em.station_id')
->leftJoin(['region'=>'r'],'station.area_id = r.id')
->where($map) ->where($map)
->count(); ->count();
return $data;
$data2 = self::alias('pay')
->field('pay.*')
->field('em.em_numb,r.region_name,station.station_name')
->leftJoin(['em_account'=>'ea'],'ea.account_id=pay.account_id')
->leftJoin(['em'],'em.id=ea.em_id')
->leftJoin(['station_info'=>'station'],'station.station_id=em.station_id')
->leftJoin(['region'=>'r'],'station.area_id = r.id')
->where($map)
->count();
return intval($data + $data2);
} }
//通过缴费单id返回缴费单关联账单信息 //通过缴费单id返回缴费单关联账单信息
public function getinvsInfo($payment_id){ public function getinvsInfo($payment_id){
...@@ -74,7 +117,7 @@ class EmPayment extends Base ...@@ -74,7 +117,7 @@ class EmPayment extends Base
$invModel = new EmInvoice(); $invModel = new EmInvoice();
$invs = $invModel->alias('inv') $invs = $invModel->alias('inv')
->field('inv.*') ->field('inv.*')
->field('station.station_name') ->field('station.station_name,station.proj_number')
->field('em.em_numb') ->field('em.em_numb')
->leftJoin(['em_invoice_useage'=>'eiu'],'eiu.invoice_id=inv.invoice_id') ->leftJoin(['em_invoice_useage'=>'eiu'],'eiu.invoice_id=inv.invoice_id')
->leftJoin(['em_useage'=>'eu'],'eu.useage_id = eiu.useage_id') ->leftJoin(['em_useage'=>'eu'],'eu.useage_id = eiu.useage_id')
......
<?php
/**
* Created by PhpStorm.
* User: chouchou
* Date: 2020-3-31
* Time: 0:54
*/
namespace app\em\model;
class EmPaymentAccount extends Base
{
}
\ No newline at end of file
<?php
namespace app\em\model;
class EmPaymentFk extends Base
{
protected $table = 'em_payment_fk';
}
\ No newline at end of file
<?php
namespace app\em\model;
class EmPaymentMonthly extends Base
{
public function getCurrentMonthly($em_id){
$data = self::field('month')->where('em_id','=',$em_id)->order('id desc')->find();
return isset($data->month) ? $data->month : 0;
}
}
\ No newline at end of file
差异被折叠。
...@@ -12,7 +12,16 @@ class Staff extends Base ...@@ -12,7 +12,16 @@ class Staff extends Base
public function getStaffs($is_admin=false,$staff_id='',$filter=false){ public function getStaffs($is_admin=false,$staff_id='',$filter=false){
if($is_admin){ if($is_admin){
if($staff_id == ''){
$staffs = StaffModel::field('id,name')->select()->toArray(); $staffs = StaffModel::field('id,name')->select()->toArray();
} else {
$staff = StaffModel::where('id','=',$staff_id)->find();
$dIds = (new DepartmentModel)->getNodeIds($staff['d_id']);
$staffs = StaffModel::field('id,name')
->where('d_id','in',$dIds)
->select()->toArray();
}
} else { } else {
if($staff_id == ''){ if($staff_id == ''){
$user = \think\facade\Session::get('user'); $user = \think\facade\Session::get('user');
......
<?php
namespace app\em\validate;
use think\Validate;
class AddFkInfoDetailsValidate extends Validate
{
protected $rule = [
'cbzxid' => 'require',
'amount' => 'require'
];
protected $message = [
'cbzxid.require' => '成本中心编码不存在',
'amount.require' => '付款金额不能为空'
];
}
\ No newline at end of file
<?php
namespace app\em\validate;
use think\Validate;
class AddFkInfoValidate extends Validate
{
protected $rule = [
'title' => 'require',
'info' => 'require',
'date' => 'require|date'
];
protected $message = [
'title.require' => '标题不能为空',
'info.require' => '付款信息不能为空,请选择收款方之后自动补充付款信息,如果选择收款方之后付款信息依然为空,则需要通过OA补充收款方的付款信息',
'date.require' => '日期不能为空',
'date.date' => '日期格式不正确'
];
}
\ No newline at end of file
...@@ -13,7 +13,7 @@ class UseageGeneralInfoValidate extends Validate ...@@ -13,7 +13,7 @@ class UseageGeneralInfoValidate extends Validate
'photo_id' => 'require', 'photo_id' => 'require',
'staff_id' => 'require', 'staff_id' => 'require',
'price' => 'require', 'price' => 'require',
'amount' =>'require' 'amount' =>'require|checkAmount'
]; ];
protected $message = [ protected $message = [
...@@ -26,12 +26,12 @@ class UseageGeneralInfoValidate extends Validate ...@@ -26,12 +26,12 @@ class UseageGeneralInfoValidate extends Validate
'photo_id.require' => '请上传电表照片', 'photo_id.require' => '请上传电表照片',
'staff_id.require' => '请选择抄表员', 'staff_id.require' => '请选择抄表员',
'price' => '单价必填且只能是数字或小数', 'price' => '单价必填且只能是数字或小数',
'amount.require' =>'缴费金额未填写' 'amount.require' =>'实缴电费未填写'
]; ];
protected $scene = [ protected $scene = [
's1' => 'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id,price', 's1' => 'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id,price',
's2' => 'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id,price', 's2' => 'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id,price,amount',
]; ];
protected function checkDate($value,$rule,$data=[]){ protected function checkDate($value,$rule,$data=[]){
...@@ -45,4 +45,8 @@ class UseageGeneralInfoValidate extends Validate ...@@ -45,4 +45,8 @@ class UseageGeneralInfoValidate extends Validate
return $value > $data['last_numb'] ? true : '本次抄表度数必须大于上次抄表度数'; return $value > $data['last_numb'] ? true : '本次抄表度数必须大于上次抄表度数';
} }
protected function checkAmount($value,$rule,$data=[]){
return $value > 0 ? true : '实缴电费未填写';
}
} }
\ No newline at end of file
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
<th lay-data="{field:'region_name',sort: true} ">区域</th> <th lay-data="{field:'region_name',sort: true} ">区域</th>
<th lay-data="{field:'operator_name',sort: true}">运营商</th> <th lay-data="{field:'operator_name',sort: true}">运营商</th>
<th lay-data="{field:'proj_number'}">项目编号</th> <th lay-data="{field:'proj_number'}">项目编号</th>
<th lay-data="{templet: '#account'}">插卡表余额</th>
<th lay-data="{field:'create_time',sort: true}">创建时间</th> <th lay-data="{field:'create_time',sort: true}">创建时间</th>
<th lay-data="{fixed: 'right', width:'180', align:'center', toolbar: '#barDemo'}">操作</th> <th lay-data="{fixed: 'right', width:'180', align:'center', toolbar: '#barDemo'}">操作</th>
</tr> </tr>
...@@ -81,11 +82,24 @@ ...@@ -81,11 +82,24 @@
<script type="text/html" id="em_numb"> <script type="text/html" id="em_numb">
<a class="layui-link" href="/em_edit/{{d.id}}">{{d.em_numb}}</a> <a class="layui-link" href="/em_edit/{{d.id}}">{{d.em_numb}}</a>
</script> </script>
<script type="text/html" id="account">
{{#
if(d.em_type_id == 2 || d.em_type_id == 4){
if(d.account.amount != null ) {
return d.account.amount;
} else {
return 0;
}
} else {
return '/';
};
}}
</script>
<script type="text/html" id="barDemo"> <script type="text/html" id="barDemo">
<div class="layui-text-left"> <div class="layui-text-left">
<button title="抄表" class="layui-btn layui-btn-sm" lay-filter="check" lay-submit="" data-id="{{d.id}}">抄表</button> <button title="抄表" class="layui-btn layui-btn-sm" lay-filter="check" lay-submit="" data-id="{{d.id}}">抄表</button>
{{# if(d.em_type_id == 2 || d.em_type_id == 4){ }} {{# if(d.em_type_id == 2 || d.em_type_id == 4){ }}
<a href="/payment/pay/{{d.id}}" class="layui-btn layui-btn-sm">缴费</a> <a href="/payment/pay/{{d.id}}" class="layui-btn layui-btn-sm">充值</a>
{{# } }} {{# } }}
<a title="编辑" class="layui-btn layui-btn-sm" href="/em_edit/{{d.id}}"> <a title="编辑" class="layui-btn layui-btn-sm" href="/em_edit/{{d.id}}">
编辑 编辑
......
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论