提交 22009fa8 authored 作者: wangkr's avatar wangkr

Merge branch 'test' into release

......@@ -4,6 +4,7 @@ namespace app\admin\controller;
use app\admin\model\AdminModel;
use app\admin\model\StaffModel;
use think\Config;
use think\Controller;
use think\facade\Cache;
use think\facade\Session;
......@@ -20,7 +21,8 @@ class Login extends Controller
{
public function index()
{
echo '<script type="text/javascript">top.location.href="http://oa.gonn.com.cn/";</script>';
$baseUrl = config('admin.base_url');
echo '<script type="text/javascript">top.location.href="'.$baseUrl.'";</script>';
}
public function login(Request $request,LoginValidate $validate)
......
......@@ -212,7 +212,7 @@ class Invoice extends Base
//缴费信息
$inv->payment_amount = $inv->payment_balance = $amount * $uData['rate'];
//结算信息
$inv->settle_amount = $inv->settle_balance = $repo_numb * $uData['settle_price'];
$inv->settle_amount = $inv->settle_balance = $repo_numb * $uData['rate'] *$uData['settle_price'];
$inv->status = '000';
$inv->invoice_id = $this->getInvoiceId();
......
......@@ -99,7 +99,6 @@ class Useage extends Base
if(!(new Em())->checkEmComplete($em_id)){
$this->error('电表信息不完整,需要补充基础信息','/em');
}
$em = (new \app\em\model\Em)->getEmUseageInfoById($em_id,$detail);
//基站信息
......@@ -114,14 +113,8 @@ class Useage extends Base
$this->assign('staffs',(new Staff())->getStaffs($user['is_admin'],'','useage'));
$this->assign('em',$em);
if($em->rule->pricing_type == 1){
$template = 'default';
} else {
$template = 'special';
}
$this->assign('detail',$detail);
return $this->fetch($template);
return $this->fetch('default');
}
//保存抄表单
......@@ -131,65 +124,29 @@ class Useage extends Base
//数据验证
$validate = new UseageGeneralInfoValidate();
//根据计量模式 验证去表单数据
if(!$validate->scene('s'.$data['pricing_type'])->check($data)){
if(!$validate->scene('s1')->check($data)){
return json(['status'=>0,'message'=>$validate->getError()]);
}
//获取电表基本信息
$em = (new \app\em\model\Em)->getEmInfoById(['id'=>$data['em_id']],'rule');
//保存抄表单
$uModel = new \app\em\model\Useage();
//如果是普通计量模式
if($data['pricing_type'] != 1){
$data['current_sum_numb'] = $data['current_numb'];
$data['last_sum_numb'] = $data['last_numb'];
}
//生成抄表单ID
$data['useage_id'] = $this->getUId();
$uModel->save($data);
//抄表详情更新
$data['last_sum_numb'] = $data['last_numb'];
$data['current_sum_numb'] = $data['current_numb'];
//保存用户ID
$user = Session::get('user');
$data['uid'] = $user['user_id'];
//峰谷类型
$data['type'] = $data['pricing_type'];
//单价
$data['price'] = $data['pricing_type'] == 1 ? $em->rule->pay_price : $data['price'];
$uModel->save($data); //保存抄表记录
$data['type'] = $data['type'] == 1 ? 5 : 6;
$udModel = new UseageDetail(); //抄表详情模型
//如果是普通计量模式
if($data['pricing_type'] == 1){
//添加抄表详情记录
$data['type'] = 5; //保存详情类型 5->default
$udModel->save($data);
//更新主表
$data['type'] = $data['pricing_type']; //保存峰谷信息
$data['last_sum_numb'] = $data['last_numb'];
$data['current_sum_numb'] = $data['current_numb'];
$uModel->save($data);
} else {
$typeArr = [];
$data['last_sum_numb'] = 0;
$data['current_sum_numb'] = 0;
for ($i=0;$i<4;$i++){
$temp = $data;
$last_key = 'uType'.($i+1).'_last_numb';
$curr_key = 'uType'.($i+1).'_current_numb';
$price_key = 'uType'.($i+1).'_price';
//组装峰谷信息
$temp['type'] = $i+1;
$temp['last_numb'] = $data[$last_key];
$temp['current_numb'] = $data[$curr_key];
$temp['price'] = $data[$price_key];
//抄表汇总记录
$data['last_sum_numb'] += $temp['last_numb'];
$data['current_sum_numb'] += $temp['current_numb'];
$typeArr[] = $temp;
}
$udModel->saveAll($typeArr);
//更新主表
$data['type'] = $data['pricing_type']; //保存峰谷信息
$uModel->save($data);
}
$udModel->save($data);
return json(['status'=>1,'message'=>'添加抄表记录成功']);
}
......@@ -232,55 +189,30 @@ class Useage extends Base
$useage = (new \app\em\model\Useage)->alias('u')
->field('u.*,em.rate')
->field('emr.pricing_type')
->field('emr.pricing_type,emr.pay_price')
->leftJoin(['em'],'em.id=u.em_id')
->leftJoin(['em_rule'=>'emr'],'emr.em_id=em.id')
->where('u.useage_id','=',$uid)
->find();
$em = (new \app\em\model\Em())->getBaseInfo($useage->em_id);
$user = Session::get('user');
if($useage){
$this->assign('staffs',(new Staff())->getStaffs($user['is_admin'],$useage->staff_id));
} else {
$this->assign('staffs',(new Staff())->getStaffs($user['is_admin']));
}
$useage->price = $useage->pricing_type == 1 ? $useage->pay_price : $useage->price;
$useage->repo_numb = round(round($useage->current_sum_numb - $useage->last_sum_numb,2) * $useage->rate,2);
$this->assign('em',$em);
$this->assign('useage',$useage);
//判断是否是峰谷表
if($useage->pricing_type == 2){
//获取峰谷表详情
$useage_detail = (new UseageDetail())->where('useage_id','=',$uid)->select()->toArray();
foreach ($useage_detail as &$ud){
switch ($ud['type']){
case 1:
$ud['typeName'] = '尖峰段';
break;
case 2:
$ud['typeName'] = '峰段';
break;
case 3:
$ud['typeName'] = '谷段';
break;
case 4:
$ud['typeName'] = '平段';
break;
default:
$ud['typeName'] = '普通';
break;
}
}
$this->assign('useage_detail',$useage_detail);
return $this->fetch('detail_special');
} else {
return $this->fetch('detail');
}
return $this->fetch('detail');
}
......
......@@ -59,54 +59,17 @@ class Em extends Base
}
//如果没有超过表 不论是峰谷表还是普通表 都是空的
if(!$ue) {
//如果不是详情页
$em->last_date = $em->init_date;
$em->last_numb = $em->init_numb;
//如果是峰谷表 初始化
if($em->rule->pricing_type == 2) {
$em->last_sum_numb = 0;
$ulist[] = ['typeName' => '尖峰段', 'last_numb' => 0, 'current_numb' => ''];
$ulist[] = ['typeName' => '峰段', 'last_numb' => 0, 'current_numb' => ''];
$ulist[] = ['typeName' => '谷段', 'last_numb' => 0, 'current_numb' => ''];
$ulist[] = ['typeName' => '平段', 'last_numb' => 0, 'current_numb' => ''];
} else {
$ulist[] = ['typeName' => '普通', 'last_numb' => 0, 'current_numb' => ''];
$em->last_sum_numb = $em->init_numb;
}
$em->useage = $ulist;
//历史抄表
if($em->rule->settle_type==1){
$em->is_history = 1;
}
$ue = new Useage();
$ue->last_date = $em->init_date;
$ue->last_sum_numb = $em->init_numb ?: 0;
} else {
$em->last_date = $ue->current_date;
$em->last_sum_numb = $ue->current_sum_numb;
$fields = 'last_numb,current_numb,price';
if($em->rule->pricing_type == 2){
$ulist = UseageDetail
::field('case type
when 1 then "尖峰段"
when 2 then "峰段"
when 3 then "谷段"
when 4 then "平段"
else "普通" end as typeName
')
->field($fields)
->where(['useage_id'=>$ue->useage_id])->select();
foreach ($ulist as &$u){
$u->last_numb = $u->current_numb;
$u->current_numb = '';
$u->price = '';
}
$em->useage = $ulist;
if($curr == false){
$ue->last_sum_numb = $ue->current_sum_numb;
$ue->last_date = $ue->current_date;
}
$em->photo = $ue->photo;
}
$ue->price = $em->rule->pricing_type==1 ? $em->rule->pay_price : '';
$em->useage = $ue;
return $em;
}
......
差异被折叠。
......@@ -12,11 +12,8 @@ class UseageGeneralInfoValidate extends Validate
'current_date' => 'require|date|checkDate',
'photo_id' => 'require',
'staff_id' => 'require',
'uType1_current_numb' => 'require', //波峰
'uType2_current_numb' => 'require', //峰
'uType3_current_numb' => 'require', //谷
'amount' =>'require' //账单金额
'price' => 'require',
'amount' =>'require'
];
protected $message = [
......@@ -28,15 +25,13 @@ class UseageGeneralInfoValidate extends Validate
'current_date.date' => '本次抄表日期格式不正确',
'photo_id.require' => '请上传电表照片',
'staff_id.require' => '请选择抄表员',
'uType1_current_numb.require' => '请填写波峰数据',
'uType2_current_numb.require' => '请填写峰数据',
'uType3_current_numb.require' => '请填写波谷数据',
'price' => '单价必填且只能是数字或小数',
'amount.require' =>'缴费金额未填写'
];
protected $scene = [
's1' => 'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id',
's2' => 'em_id,photo_id,staff_id,uType1_current_numb,uType2_current_numb,uType3_current_numb',
's2' => 'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id,price',
];
protected function checkDate($value,$rule,$data=[]){
......
......@@ -151,7 +151,19 @@
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
单价
</label>
<div class="layui-input-inline">
<input type="text" id="price" name="price" autocomplete="off" class="layui-input" disabled="disabled" value="{$useage.price}">
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
......@@ -215,8 +227,6 @@
$ = layui.jquery;
var form = layui.form,
layer = layui.layer;
//消息提示
function layMsg(msg,type=6,time=1000){
layer.msg(msg,{
......@@ -225,6 +235,7 @@
});
}
//保存抄表单,并且返回列表
form.on('submit(check)',
function (data) {
......@@ -241,7 +252,7 @@
window.location.href='/useage';
})
} else {
layer.msg(data.msg,{icon: 5,time: 1000 })
layer.msg(data.message || data.msg,{icon: 5,time: 1000 })
}
}
});
......
......@@ -151,6 +151,20 @@
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
单价
</label>
<div class="layui-input-inline">
<input type="text" id="price" name="price" autocomplete="off" class="layui-input" disabled="disabled" value="{$useage.price}">
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
......@@ -182,28 +196,7 @@
</div>
</div>
</div>
<div class="layui-col-md10" style="padding:0 130px 0 30px;margin-bottom: 20px;">
<table class="layui-table layui-form">
<thead>
<tr>
<th>阶段</th>
<th>上期表数</th>
<th>本期表数</th>
<th>单价</th>
</thead>
<tbody>
{volist name="useage_detail" id="item"}
<tr>
<td>{$item.typeName}</td>
<td><input type="text" class="no-border" name="uType{$i}_last_numb" value="{$item.last_numb}" disabled="disabled"></td>
<td><input type="text" class="no-border current_numb" name="uType{$i}_current_numb" value="{$item.current_numb|default=''}" disabled="disabled"></td>
<td><input type="text" class="no-border" name="uType{$i}_price" value="{$item.price|default=''}" disabled="disabled"></td>
</tr>
{/volist}
</tbody>
</table>
</div>
</div>
</div>
</div>
......
......@@ -95,7 +95,7 @@
</label>
<div class="layui-input-inline">
<input type="text" id="last_date" name="last_date"
autocomplete="off" class="layui-input" value="{if isset($em.last_date)}{$em.last_date}{/if}" disabled="disabled">
autocomplete="off" class="layui-input" value="{$em.useage.last_date}" disabled="disabled">
</div>
</div>
</div>
......@@ -107,7 +107,7 @@
</label>
<div class="layui-input-inline">
<input type="text" id="current_date" name="current_date"
autocomplete="off" class="layui-input" value="{if isset($em.current_date)}{$em.current_date}{/if}">
autocomplete="off" class="layui-input" value="{$em.useage.current_date|date='Y:m:d'}">
</div>
</div>
</div>
......@@ -119,7 +119,7 @@
</label>
<div class="layui-input-inline">
<input type="text" id="last_numb" name="last_numb"
autocomplete="off" class="layui-input" disabled="disabled" value="{$em.last_sum_numb}" >
autocomplete="off" class="layui-input" disabled="disabled" value="{$em.useage.last_sum_numb}" >
</div>
<div class="layui-form-mid layui-word-aux">
......@@ -134,7 +134,7 @@
</label>
<div class="layui-input-inline">
<input type="text" id="current_numb" name="current_numb"
autocomplete="off" class="layui-input" disabled="disabled">
autocomplete="off" class="layui-input" value="{$em.useage.current_numb|default=''}">
</div>
<div class="layui-form-mid layui-word-aux">
......@@ -155,6 +155,21 @@
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
单价
</label>
<div class="layui-input-inline">
<input type="text" id="price" name="price" autocomplete="off" class="layui-input" value="">
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
......@@ -186,29 +201,6 @@
</div>
</div>
</div>
<div class="layui-col-md10" style="padding:0 130px 0 30px;margin-bottom: 20px;">
<table class="layui-table layui-form">
<thead>
<tr>
<th>阶段</th>
<th>上期表数</th>
<th>本期表数</th>
<th>单价</th>
</thead>
<tbody>
{volist name="em.useage" id="item"}
<tr>
<td>{$item.typeName}</td>
<td><input type="text" class="no-border" name="uType{$i}_last_numb" value="{$item.last_numb}" disabled="disabled"></td>
<td><input type="text" class="no-border current_numb" name="uType{$i}_current_numb" value="{$item.current_numb|default=''}"></td>
<td><input type="text" class="no-border" name="uType{$i}_price" value="{$item.price|default=''}"></td>
</tr>
{/volist}
</tbody>
</table>
</div>
</div>
</div>
</div>
......@@ -261,7 +253,6 @@
trigger:'click',
})
//保存抄表单,并且返回列表
form.on('submit(save)',
function (data) {
......@@ -307,24 +298,18 @@
}
}
});
$('#current_numb').change(function(){
$leve = 100000;
var $rNum = $(this).val()*$leve - $('#last_numb').val()*$leve;
if($rNum < 0){
layMsg('本次抄表必须大于上次抄表读数',5);
$('#current_numb').focus();
} else{
$('#repo_numb').val( $rNum/$leve )
//总度数实时更新
$sum = $('#current_numb');
$('.current_numb').change(function(){
var $sum_numb = 0;
for (var i = 0; i < $('.current_numb').length; i++) {
$temp_numb = $('.current_numb').eq(i).val();
if($temp_numb != 'undefind' && $temp_numb != ''){
$sum_numb += Number($temp_numb)
}
}
$sum.val($sum_numb);
var nm = Number($('#rate').val()) * $sum_numb;
$('#repo_numb').val(nm);
})
});
</script>
{/block}
\ No newline at end of file
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | 会话设置
// +----------------------------------------------------------------------
return [
'id' => '',
// SESSION_ID的提交变量,解决flash上传跨域
'var_session_id' => '',
// SESSION 前缀
'prefix' => 'think',
// 驱动方式 支持redis memcache memcached
'type' => '',
// 是否自动开启 SESSION
'auto_start' => false,
];
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论