Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
Jz-Php
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
PHP
Jz-Php
Commits
22009fa8
提交
22009fa8
authored
4月 23, 2020
作者:
wangkr
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'test' into release
上级
a6334760
60408556
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
139 行增加
和
1369 行删除
+139
-1369
Login.php
application/admin/controller/Login.php
+3
-1
Invoice.php
application/em/controller/Invoice.php
+1
-1
Useage.php
application/em/controller/Useage.php
+19
-87
Em.php
application/em/model/Em.php
+8
-45
Invoice.php
application/em/model/Invoice.php
+0
-558
UseageGeneralInfoValidate.php
application/em/validate/UseageGeneralInfoValidate.php
+4
-9
Invoice.php
application/em/view/invoice/Invoice.php
+0
-531
default.html
application/em/view/useage/default.html
+48
-43
detail.html
application/em/view/useage/detail.html
+15
-4
detail_special.html
application/em/view/useage/detail_special.html
+14
-21
special.html
application/em/view/useage/special.html
+27
-43
session.php.bak
config/session.php.bak
+0
-26
没有找到文件。
application/admin/controller/Login.php
浏览文件 @
22009fa8
...
@@ -4,6 +4,7 @@ namespace app\admin\controller;
...
@@ -4,6 +4,7 @@ namespace app\admin\controller;
use
app\admin\model\AdminModel
;
use
app\admin\model\AdminModel
;
use
app\admin\model\StaffModel
;
use
app\admin\model\StaffModel
;
use
think\Config
;
use
think\Controller
;
use
think\Controller
;
use
think\facade\Cache
;
use
think\facade\Cache
;
use
think\facade\Session
;
use
think\facade\Session
;
...
@@ -20,7 +21,8 @@ class Login extends Controller
...
@@ -20,7 +21,8 @@ class Login extends Controller
{
{
public
function
index
()
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
)
public
function
login
(
Request
$request
,
LoginValidate
$validate
)
...
...
application/em/controller/Invoice.php
浏览文件 @
22009fa8
...
@@ -212,7 +212,7 @@ class Invoice extends Base
...
@@ -212,7 +212,7 @@ class Invoice extends Base
//缴费信息
//缴费信息
$inv
->
payment_amount
=
$inv
->
payment_balance
=
$amount
*
$uData
[
'rate'
];
$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
->
status
=
'000'
;
$inv
->
invoice_id
=
$this
->
getInvoiceId
();
$inv
->
invoice_id
=
$this
->
getInvoiceId
();
...
...
application/em/controller/Useage.php
浏览文件 @
22009fa8
...
@@ -99,7 +99,6 @@ class Useage extends Base
...
@@ -99,7 +99,6 @@ class Useage extends Base
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
,
$detail
);
//基站信息
//基站信息
...
@@ -114,14 +113,8 @@ class Useage extends Base
...
@@ -114,14 +113,8 @@ 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
);
if
(
$em
->
rule
->
pricing_type
==
1
){
$template
=
'default'
;
}
else
{
$template
=
'special'
;
}
$this
->
assign
(
'detail'
,
$detail
);
$this
->
assign
(
'detail'
,
$detail
);
return
$this
->
fetch
(
$template
);
return
$this
->
fetch
(
'default'
);
}
}
//保存抄表单
//保存抄表单
...
@@ -131,65 +124,29 @@ class Useage extends Base
...
@@ -131,65 +124,29 @@ class Useage extends Base
//数据验证
//数据验证
$validate
=
new
UseageGeneralInfoValidate
();
$validate
=
new
UseageGeneralInfoValidate
();
//根据计量模式 验证去表单数据
//根据计量模式 验证去表单数据
if
(
!
$validate
->
scene
(
's
'
.
$data
[
'pricing_type'
]
)
->
check
(
$data
)){
if
(
!
$validate
->
scene
(
's
1'
)
->
check
(
$data
)){
return
json
([
'status'
=>
0
,
'message'
=>
$validate
->
getError
()]);
return
json
([
'status'
=>
0
,
'message'
=>
$validate
->
getError
()]);
}
}
//获取电表基本信息
//获取电表基本信息
$em
=
(
new
\app\em\model\Em
)
->
getEmInfoById
([
'id'
=>
$data
[
'em_id'
]],
'rule'
);
$em
=
(
new
\app\em\model\Em
)
->
getEmInfoById
([
'id'
=>
$data
[
'em_id'
]],
'rule'
);
//保存抄表单
//保存抄表单
$uModel
=
new
\app\em\model\Useage
();
$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
//生成抄表单ID
$data
[
'useage_id'
]
=
$this
->
getUId
();
$data
[
'useage_id'
]
=
$this
->
getUId
();
$uModel
->
save
(
$data
);
//抄表详情更新
$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
[
'last_sum_numb'
]
=
$data
[
'last_numb'
];
$data
[
'current_sum_numb'
]
=
$data
[
'current_numb'
];
$data
[
'current_sum_numb'
]
=
$data
[
'current_numb'
];
$uModel
->
save
(
$data
);
//保存用户ID
}
else
{
$user
=
Session
::
get
(
'user'
);
$typeArr
=
[];
$data
[
'uid'
]
=
$user
[
'user_id'
];
$data
[
'last_sum_numb'
]
=
0
;
//峰谷类型
$data
[
'current_sum_numb'
]
=
0
;
$data
[
'type'
]
=
$data
[
'pricing_type'
];
for
(
$i
=
0
;
$i
<
4
;
$i
++
){
//单价
$temp
=
$data
;
$data
[
'price'
]
=
$data
[
'pricing_type'
]
==
1
?
$em
->
rule
->
pay_price
:
$data
[
'price'
];
$last_key
=
'uType'
.
(
$i
+
1
)
.
'_last_numb'
;
$uModel
->
save
(
$data
);
//保存抄表记录
$curr_key
=
'uType'
.
(
$i
+
1
)
.
'_current_numb'
;
$price_key
=
'uType'
.
(
$i
+
1
)
.
'_price'
;
$data
[
'type'
]
=
$data
[
'type'
]
==
1
?
5
:
6
;
$udModel
=
new
UseageDetail
();
//抄表详情模型
//组装峰谷信息
$udModel
->
save
(
$data
);
$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
);
}
return
json
([
'status'
=>
1
,
'message'
=>
'添加抄表记录成功'
]);
return
json
([
'status'
=>
1
,
'message'
=>
'添加抄表记录成功'
]);
}
}
...
@@ -232,55 +189,30 @@ class Useage extends Base
...
@@ -232,55 +189,30 @@ class Useage extends Base
$useage
=
(
new
\app\em\model\Useage
)
->
alias
(
'u'
)
$useage
=
(
new
\app\em\model\Useage
)
->
alias
(
'u'
)
->
field
(
'u.*,em.rate'
)
->
field
(
'u.*,em.rate'
)
->
field
(
'emr.pricing_type'
)
->
field
(
'emr.pricing_type
,emr.pay_price
'
)
->
leftJoin
([
'em'
],
'em.id=u.em_id'
)
->
leftJoin
([
'em'
],
'em.id=u.em_id'
)
->
leftJoin
([
'em_rule'
=>
'emr'
],
'emr.em_id=em.id'
)
->
leftJoin
([
'em_rule'
=>
'emr'
],
'emr.em_id=em.id'
)
->
where
(
'u.useage_id'
,
'='
,
$uid
)
->
where
(
'u.useage_id'
,
'='
,
$uid
)
->
find
();
->
find
();
$em
=
(
new
\app\em\model\Em
())
->
getBaseInfo
(
$useage
->
em_id
);
$em
=
(
new
\app\em\model\Em
())
->
getBaseInfo
(
$useage
->
em_id
);
$user
=
Session
::
get
(
'user'
);
$user
=
Session
::
get
(
'user'
);
if
(
$useage
){
if
(
$useage
){
$this
->
assign
(
'staffs'
,(
new
Staff
())
->
getStaffs
(
$user
[
'is_admin'
],
$useage
->
staff_id
));
$this
->
assign
(
'staffs'
,(
new
Staff
())
->
getStaffs
(
$user
[
'is_admin'
],
$useage
->
staff_id
));
}
else
{
}
else
{
$this
->
assign
(
'staffs'
,(
new
Staff
())
->
getStaffs
(
$user
[
'is_admin'
]));
$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
);
$useage
->
repo_numb
=
round
(
round
(
$useage
->
current_sum_numb
-
$useage
->
last_sum_numb
,
2
)
*
$useage
->
rate
,
2
);
$this
->
assign
(
'em'
,
$em
);
$this
->
assign
(
'em'
,
$em
);
$this
->
assign
(
'useage'
,
$useage
);
$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'
);
}
}
}
...
...
application/em/model/Em.php
浏览文件 @
22009fa8
...
@@ -59,54 +59,17 @@ class Em extends Base
...
@@ -59,54 +59,17 @@ class Em extends Base
}
}
//如果没有超过表 不论是峰谷表还是普通表 都是空的
//如果没有超过表 不论是峰谷表还是普通表 都是空的
if
(
!
$ue
)
{
if
(
!
$ue
)
{
//如果不是详情页
$ue
=
new
Useage
();
$em
->
last_date
=
$em
->
init_date
;
$ue
->
last_date
=
$em
->
init_date
;
$em
->
last_numb
=
$em
->
init_numb
;
$ue
->
last_sum_numb
=
$em
->
init_numb
?:
0
;
//如果是峰谷表 初始化
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
;
}
}
else
{
}
else
{
$em
->
last_date
=
$ue
->
current_date
;
if
(
$curr
==
false
){
$em
->
last_sum_numb
=
$ue
->
current_sum_numb
;
$ue
->
last_sum_numb
=
$ue
->
current_sum_numb
;
$fields
=
'last_numb,current_numb,price'
;
$ue
->
last_date
=
$ue
->
current_date
;
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
;
}
}
$em
->
photo
=
$ue
->
photo
;
}
}
$ue
->
price
=
$em
->
rule
->
pricing_type
==
1
?
$em
->
rule
->
pay_price
:
''
;
$em
->
useage
=
$ue
;
return
$em
;
return
$em
;
}
}
...
...
application/em/model/Invoice.php
deleted
100755 → 0
浏览文件 @
a6334760
<?php
/**
* v2 账单模块
*/
namespace
app\em\controller
;
use
app\admin\controller\Base
;
use
app\em\model\EmInvoice
;
use
app\em\model\EmInvoiceHistory
;
use
app\em\model\EmInvoiceUseage
;
use
app\em\model\EmPayment
;
use
app\em\model\EmPaymentHistory
;
use
app\em\model\EmPaymentInvoice
;
use
app\em\model\EmPaymentInvoiceBalance
;
use
app\em\model\EmSettle
;
use
app\em\model\EmSettleInvoice
;
use
app\em\model\EmSettleInvoiceBalance
;
use
app\em\model\UseageDetail
;
use
think\facade\Request
;
use
think\facade\Session
;
class
Invoice
extends
Base
{
//账单列表
public
function
index
(){
$map
=
[];
//权限检测
$user
=
Session
::
get
(
'user'
);
if
(
!
$user
[
'is_admin'
]){
$permissionData
=
check_data
();
if
(
$permissionData
){
$map
[]
=
$permissionData
;
}
}
$search_text
=
Request
::
get
(
'search_text'
);
$search_type
=
Request
::
get
(
'search_type'
);
if
(
$search_text
){
switch
(
$search_type
)
{
case
'1'
:
$this
->
assign
(
'search_text'
,
$search_text
);
$map
[]
=
[
'inv.invoice_id'
,
'like'
,
"%
$search_text
%"
];
$this
->
assign
(
'search_type'
,
$search_type
);
break
;
case
'2'
:
$this
->
assign
(
'search_text'
,
$search_text
);
$map
[]
=
[
'station.station_name'
,
'like'
,
"%
$search_text
%"
];
$this
->
assign
(
'search_type'
,
$search_type
);
break
;
case
'3'
:
$this
->
assign
(
'search_text'
,
$search_text
);
$map
[]
=
[
'em.em_numb'
,
'like'
,
"%
$search_text
%"
];
$this
->
assign
(
'search_type'
,
$search_type
);
break
;
}
}
else
{
$this
->
assign
(
'search_type'
,
''
);
$this
->
assign
(
'search_text'
,
''
);
}
$page
=
Request
::
param
(
'page'
)
?
Request
::
param
(
'page'
)
:
1
;
$limit
=
Request
::
param
(
'limit'
)
?
Request
::
param
(
'limit'
)
:
10
;
$data
=
(
new
EmInvoice
)
->
getInvoiceList
(
$map
,
$page
,
$limit
);
foreach
(
$data
as
$key
=>
&
$v
)
{
$v
[
'status'
]
=
parseStatus
(
$v
[
'status'
]);
}
$InvoiceCount
=
(
new
EmInvoice
)
->
getInvoiceCount
(
$map
);
if
(
Request
::
param
(
'page'
)){
return
[
'code'
=>
0
,
'msg'
=>
''
,
'count'
=>
$InvoiceCount
,
'data'
=>
$data
];
}
return
$this
->
fetch
();
// $data = (new EmInvoice)->getList();
//
// $page = $data->render();
//
// $this->assign('data',$data);
// $this->assign('page',$page);
// return $this->fetch();
}
//查看账单信息
public
function
detail
(){
$inv_id
=
Request
::
param
(
'id'
);
$invInfo
=
(
new
EmInvoice
)
->
getInvoiceDetail
(
$inv_id
);
$this
->
assign
(
'inv'
,
$invInfo
);
return
$this
->
fetch
();
}
//创建一个账单
public
function
createInvoice
(
$useage_id
){
$um
=
(
new
\app\em\model\Useage
)
->
getEmInfoByUseageId
(
$useage_id
)
->
toArray
();
return
$this
->
create
(
$um
);
}
//创建账单
public
function
create
(
$um
){
/// 如果是普通表 则
if
(
$um
[
'pricing_type'
]
==
1
){
return
$this
->
createInvoiceStdType
(
$um
);
}
else
if
(
$um
[
'pricing_type'
]
==
2
){
return
$this
->
createInvoiceSpecialType
(
$um
);
}
}
/**
* 生成账单号
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private
function
getInvoiceId
(){
$inv
=
EmInvoice
::
field
(
'id'
)
->
order
(
'id desc,create_time desc'
)
->
find
();
if
(
!
$inv
)
$id
=
1
;
else
$id
=
$inv
->
id
+
1
;
return
"ZD"
.
date
(
'Ymd'
)
.
zero
(
$id
);
}
//普通读表生成账单
public
function
createInvoiceStdType
(
$uData
){
$inv
=
new
EmInvoice
();
$inv
->
type
=
4
;
$inv
->
rate
=
$uData
[
'rate'
];
$inv
->
repo_numb
=
(
$uData
[
'current_sum_numb'
]
-
$uData
[
'last_sum_numb'
])
*
$uData
[
'rate'
];
$inv
->
payment_amount
=
$inv
->
payment_balance
=
$inv
->
repo_numb
*
$uData
[
'pay_price'
];
//结算信息
$inv
->
settle_amount
=
$inv
->
settle_balance
=
$inv
->
repo_numb
*
$uData
[
'settle_price'
];
$inv
->
status
=
'000'
;
$inv
->
invoice_id
=
$this
->
getInvoiceId
();
//获取账户ID
$inv
->
account_id
=
(
new
Account
())
->
getAccountId
(
$uData
[
'em_id'
]);
//保存 并且更新抄表单与账单关联表
if
(
$inv
->
save
()){
$eiu
=
new
EmInvoiceUseage
();
$eiu
->
invoice_id
=
$inv
->
invoice_id
;
$eiu
->
useage_id
=
$uData
[
'useage_id'
];
$eiu
->
save
();
}
//更新电表账户
$useage
=
\app\em\model\Useage
::
get
([
'useage_id'
=>
$uData
[
'useage_id'
]]);
$account
=
new
Account
();
$account
->
updateAmount
(
$useage
->
em_id
,
$inv
->
payment_amount
,
0
);
return
$inv
;
}
//峰谷表生成账单
public
function
createInvoiceSpecialType
(
$uData
){
$inv
=
new
EmInvoice
();
$inv
->
type
=
1
;
$inv
->
rate
=
$uData
[
'rate'
];
//获取峰谷表抄表明细
$uds
=
UseageDetail
::
where
([
'useage_id'
=>
$uData
[
'useage_id'
]])
->
select
()
->
toArray
();
//计算总价信息
//需要计算4个属性 各分段上一次 档次 repo amount
$last_numb
=
0
;
$curr_numb
=
0
;
$amount
=
0
;
$repo_numb
=
0
;
foreach
(
$uds
as
$v
){
$last_numb
+=
$v
[
'last_numb'
];
$curr_numb
+=
$v
[
'current_numb'
];
$amount
+=
(
int
)(
$v
[
'current_numb'
]
-
$v
[
'last_numb'
])
*
$v
[
'price'
];
$repo_numb
+=
(
int
)(
$v
[
'current_numb'
]
-
$v
[
'last_numb'
]);
}
//曝移动电量
$inv
->
repo_numb
=
(
$curr_numb
-
$last_numb
)
*
$uData
[
'rate'
];
//缴费信息
$inv
->
payment_amount
=
$inv
->
payment_balance
=
$amount
*
$uData
[
'rate'
];
//结算信息
$inv
->
settle_amount
=
$inv
->
settle_balance
=
$repo_numb
*
$uData
[
'settle_price'
];
$inv
->
status
=
'000'
;
$inv
->
invoice_id
=
$this
->
getInvoiceId
();
$inv
->
account_id
=
(
new
Account
())
->
getAccountId
(
$uData
[
'em_id'
]);
//更新抄表单的status
$useage
=
\app\em\model\Useage
::
get
([
'useage_id'
=>
$uData
[
'useage_id'
]]);
$useage
->
status
=
2
;
$useage
->
save
();
$inv
->
cert_id
=
$useage
->
photo_id
;
//保存 并且更新抄表单与账单关联表
if
(
$inv
->
save
()){
$eiu
=
new
EmInvoiceUseage
();
$eiu
->
invoice_id
=
$inv
->
invoice_id
;
$eiu
->
useage_id
=
$uData
[
'useage_id'
];
$eiu
->
save
();
}
return
$inv
;
}
public
function
updatePayment
(){
$data
=
Request
::
param
();
$inv
=
EmInvoice
::
get
([
'id'
=>
$data
[
'id'
]]);
if
(
!
$inv
)
return
json
([
'status'
=>
0
,
'message'
=>
'不存在抄表单ID,无法更新缴费金额'
]);
if
(
$data
[
'amount'
]
>
0
&&
$inv
->
is_add_condition
!=
1
){
$inv
->
payment_amount
=
$data
[
'amount'
];
$inv
->
payment_balance
=
$data
[
'amount'
];
$inv
->
is_add_condition
=
1
;
}
if
(
$inv
->
save
()){
return
json
([
'status'
=>
1
,
'message'
=>
'缴费金额已经更新'
]);
}
}
//账单合并列表
public
function
mergeList
(){
$ids
=
Request
::
param
(
'ids'
);
$idsArr
=
[];
if
(
!
empty
(
$ids
)){
$idsArr
=
explode
(
'_'
,
$ids
);
}
$data
=
(
new
EmInvoice
)
->
getListByInvIds
(
$idsArr
);
$payment_amount
=
0
;
$settle_amount
=
0
;
foreach
(
$data
as
$v
){
$v
->
settle_amount
=
$v
->
settle_amount
?:
0
$payment_amount
+=
$v
->
payment_amount
;
$settle_amount
+=
$v
->
settle_amount
;
}
$this
->
assign
(
'data'
,
$data
);
$this
->
assign
(
'payment_amount'
,
$payment_amount
);
$this
->
assign
(
'settle_amount'
,
$settle_amount
);
return
$this
->
fetch
(
'merge_list'
);
}
/**
* 账单触发销账,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
,
$account_id
){
$paymentIdsArr
=
[];
//获取账单对象
$invoice
=
EmInvoice
::
field
(
'id,invoice_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
())
return
'账单未缴费'
;
$paymentIdsArr
=
$payments
->
toArray
();
//查询可消的额度
$payments_balance
=
(
new
EmPayment
)
->
whereIn
(
'payment_id'
,
array_values
(
$paymentIdsArr
))
->
sum
(
'balance'
);
//如果该账单可以完全被缴费单销账
if
(
$payments_balance
<
$invoice
->
payment_balance
){
$payments
=
EmPayment
::
field
(
'payment_id'
)
->
where
(
'account_id'
,
'='
,
$account_id
)
->
where
(
'balance'
,
'neq'
,
0
)
->
order
(
'payment_id asc'
)
->
select
();
if
(
!
$payments
->
isEmpty
())
$paymentIdsArr
=
array_merge
(
$paymentIdsArr
,
$payments
->
toArray
());
}
foreach
(
$paymentIdsArr
as
$payment
){
$paymentIds
[]
=
[
'payment_id'
=>
$payment
->
payment_id
];
}
$invsIds
=
[
'invoice_id'
=>
$invoice
->
invoice_id
];
//开始销账
return
$this
->
writeOff
(
$paymentIds
,
$invsIds
,
$account_id
);
}
//从缴费单消账单
public
function
writeOffFromPayment
(
$account_id
,
$payment_id
){
//获取缴费单对象
$payment
=
EmPayment
::
where
(
'payment_id'
,
'='
,
$payment_id
)
->
find
();
//获取关联的账单对象
$invs
=
(
new
EmInvoice
())
->
alias
(
'ei'
)
->
field
(
'ei.invoice_id'
)
->
leftJoin
([
'em_payment_invoice'
=>
'epi'
],
'epi.invoice_id = ei.invoice_id'
)
->
where
(
'epi.payment_id'
,
'='
,
$payment_id
)
->
where
(
'ei.payment_balance'
,
'neq'
,
0
)
->
order
(
'ei.invoice_id asc'
)
->
select
();
$invsArr
=
[];
if
(
!
$invs
->
isEmpty
())
{
foreach
(
$invs
as
$inv
){
$invsArr
[]
=
$inv
->
invoice_id
;
}
}
//查询可消的额度
$payments_balance
=
(
new
EmInvoice
)
->
where
(
'invoice_id'
,
'in'
,
$invsArr
)
->
sum
(
'payment_balance'
);
//如果可以完全销账 则继续销账
if
(
$payment
->
balance
>
$payments_balance
){
$invs
=
(
new
EmInvoice
())
->
field
(
'invoice_id'
)
->
where
(
'account_id'
,
'='
,
$account_id
)
->
where
(
'payment_balance'
,
'neq'
,
0
)
->
order
(
'invoice_id asc'
)
->
select
();
if
(
!
$invs
->
isEmpty
())
{
foreach
(
$invs
as
$inv
){
$invsArr
[]
=
$inv
->
invoice_id
;
}
}
}
$paymentIds
[]
=
$payment
->
payment_id
;
//处理账户金额
return
$this
->
writeOff
(
$paymentIds
,
$invsArr
);
}
/**
* @param $account_id
* @param $invoiceIds
* @param $paymentIds
* @return mixed
*/
private
function
writeOff
(
$paymentIds
,
$invoiceIds
){
//获取可销账缴费单
$payments
=
EmPayment
::
where
(
'payment_id'
,
'in'
,
$paymentIds
)
->
select
();
//获取可销账账单
$invs
=
EmInvoice
::
where
(
'invoice_id'
,
'in'
,
$invoiceIds
)
->
select
();
$result
=
0
;
foreach
(
$payments
as
$key
=>
$payment
){
if
(
$payment
->
balance
==
0
)
continue
;
foreach
(
$invs
as
$index
=>
$inv
)
{
$balanceMode
=
new
EmPaymentInvoiceBalance
();
$balanceMode
->
payment_id
=
$payment
->
payment_id
;
if
(
$inv
->
payment_balance
==
0
)
continue
;
$balanceMode
->
invoice_id
=
$inv
->
invoice_id
;
//如果该缴费单可以完全消除当前账单额度
if
(
$payment
->
balance
>=
$inv
->
payment_balance
)
{
//单笔销账多少
$balanceMode
->
balance
=
$inv
->
payment_balance
;
//缴费额度变化
if
((
$payment
->
balance
-
$inv
->
payment_balance
)
==
0
){
$payment
->
status
=
4
;
}
else
{
$payment
->
status
=
4
;
//缴费部分销账
}
$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
;
$payment
->
status
=
4
;
//缴费已经完全销账
}
$result
++
;
//更新账单状态
$inv
->
save
();
//todo::history; 保存历史记录
$invData
=
$inv
->
toArray
();
$invData
[
'id'
]
=
null
;
$invData
[
'create_time'
]
=
strtotime
(
$invData
[
'create_time'
]);
$invData
[
'update_time'
]
=
strtotime
(
$invData
[
'update_time'
]);
//EmInvoiceHistory::create($invData);
unset
(
$invs
[
$index
]);
//从结果集中去掉无效的数据
//更新状态
$payment
->
save
();
//todo::history;保存历史记录
$payData
=
$payment
->
toArray
();
$payData
[
'id'
]
=
null
;
$payData
[
'create_time'
]
=
strtotime
(
$payData
[
'create_time'
]);
$payData
[
'update_time'
]
=
strtotime
(
$payData
[
'update_time'
]);
$payData
[
'pay_date'
]
=
strtotime
(
$payData
[
'pay_date'
]);
//EmPaymentHistory::create($payData);
unset
(
$payments
[
$key
]);
$balanceMode
->
isUpdate
(
false
)
->
save
();
}
}
$msg
=
$result
==
0
?
'已审核,没有可销账的账单.'
:
'已审核,成功销账 '
.
$result
.
' 笔账单.'
;
return
$msg
;
}
public
function
writeOffFromSettle
(
$account_id
,
$settle_id
){
//获取缴费单对象
$settle
=
EmSettle
::
where
(
'settle_id'
,
'='
,
$settle_id
)
->
find
();
//获取关联的账单对象
$invs
=
(
new
EmInvoice
())
->
alias
(
'ei'
)
->
field
(
'ei.invoice_id'
)
->
leftJoin
([
'em_settle_invoice'
=>
'esi'
],
'esi.invoice_id = ei.invoice_id'
)
->
where
(
'esi.settle_id'
,
'='
,
$settle_id
)
->
where
(
'ei.settle_balance'
,
'neq'
,
0
)
->
order
(
'ei.invoice_id asc'
)
->
select
();
$invsArr
=
[];
if
(
!
$invs
->
isEmpty
())
{
foreach
(
$invs
as
$inv
){
$invsArr
[]
=
$inv
->
invoice_id
;
}
}
//查询可消的额度
$settles_balance
=
(
new
EmInvoice
)
->
where
(
'invoice_id'
,
'in'
,
$invsArr
)
->
sum
(
'settle_balance'
);
//如果可以完全销账 则继续销账
if
(
$settle
->
balance
>
$settles_balance
){
$invs
=
(
new
EmInvoice
())
->
field
(
'invoice_id'
)
->
where
(
'account_id'
,
'='
,
$account_id
)
->
where
(
'settle_balance'
,
'neq'
,
0
)
->
order
(
'invoice_id asc'
)
->
select
();
if
(
!
$invs
->
isEmpty
())
{
foreach
(
$invs
as
$inv
){
$invsArr
[]
=
$inv
->
invoice_id
;
}
}
}
$settleIds
[]
=
$settle
->
settle_id
;
//处理账户金额
return
$this
->
writeOffSettle
(
$settleIds
,
$invsArr
);
}
private
function
writeOffSettle
(
$settleIds
,
$invoiceIds
,
$associate
=
false
){
//获取可销账结算单
$settles
=
EmSettle
::
where
(
'settle_id'
,
'in'
,
$settleIds
)
->
select
();
//获取可销账账单
$invs
=
EmInvoice
::
where
(
'invoice_id'
,
'in'
,
$invoiceIds
)
->
select
();
$result
=
0
;
foreach
(
$settles
as
$key
=>
$settle
){
if
(
$settle
->
balance
==
0
)
continue
;
foreach
(
$invs
as
$index
=>
$inv
)
{
$balanceMode
=
new
EmSettleInvoiceBalance
();
$balanceMode
->
settle_id
=
$settle
->
settle_id
;
if
(
$inv
->
settle_balance
==
0
)
continue
;
$balanceMode
->
invoice_id
=
$inv
->
invoice_id
;
//如果该结算单可以完全消除当前账单额度
if
(
$settle
->
balance
>=
$inv
->
settle_balance
)
{
//单笔销账多少
$balanceMode
->
balance
=
$inv
->
settle_balance
;
//结算额度变化
if
((
$settle
->
balance
-
$inv
->
settle_balance
)
==
0
){
$settle
->
status
=
4
;
}
else
{
$settle
->
status
=
4
;
//结算部分销账
}
$settle
->
balance
=
$settle
->
balance
-
$inv
->
settle_balance
;
//账单额度变化
$inv
->
settle_balance
=
0
;
//更新账户status 首字母 = 2
$inv
->
status
=
setInvoiceStatus
(
$inv
->
status
,
2
,
1
);
}
else
{
//单笔销账多少
$balanceMode
->
balance
=
$settle
->
balance
;
//账单额度变化
$inv
->
status
=
setInvoiceStatus
(
$inv
->
status
,
1
,
1
);
$inv
->
settle_balance
=
$inv
->
settle_balance
-
$settle
->
balance
;
//结算额度变化
$settle
->
balance
=
0
;
$settle
->
status
=
3
;
//结算已经完全销账
}
if
(
$associate
==
true
){
$model
=
new
EmSettleInvoice
();
$model
->
settle_id
=
$settle
->
settle_id
;
$model
->
invoice_id
=
$inv
->
invoice_id
;
$model
->
save
();
}
$result
++
;
//更新账单状态
$inv
->
save
();
//todo::history; 保存历史记录
$invData
=
$inv
->
toArray
();
$invData
[
'id'
]
=
null
;
$invData
[
'create_time'
]
=
strtotime
(
$invData
[
'create_time'
]);
$invData
[
'update_time'
]
=
strtotime
(
$invData
[
'update_time'
]);
//EmInvoiceHistory::create($invData);
unset
(
$invs
[
$index
]);
//从结果集中去掉无效的数据
//更新状态
$settle
->
save
();
//todo::history;保存历史记录
$payData
=
$settle
->
toArray
();
$payData
[
'id'
]
=
null
;
$payData
[
'create_time'
]
=
strtotime
(
$payData
[
'create_time'
]);
$payData
[
'update_time'
]
=
strtotime
(
$payData
[
'update_time'
]);
$payData
[
'settle_date'
]
=
strtotime
(
$payData
[
'settle_date'
]);
//EmSettleHistory::create($payData);
unset
(
$settles
[
$key
]);
$balanceMode
->
isUpdate
(
false
)
->
save
();
}
}
$msg
=
$result
==
0
?
'没有结算成功'
:
'成功结算: '
.
$result
.
'笔'
;
return
$msg
;
}
}
\ No newline at end of file
application/em/validate/UseageGeneralInfoValidate.php
浏览文件 @
22009fa8
...
@@ -12,11 +12,8 @@ class UseageGeneralInfoValidate extends Validate
...
@@ -12,11 +12,8 @@ class UseageGeneralInfoValidate extends Validate
'current_date'
=>
'require|date|checkDate'
,
'current_date'
=>
'require|date|checkDate'
,
'photo_id'
=>
'require'
,
'photo_id'
=>
'require'
,
'staff_id'
=>
'require'
,
'staff_id'
=>
'require'
,
'uType1_current_numb'
=>
'require'
,
//波峰
'price'
=>
'require'
,
'uType2_current_numb'
=>
'require'
,
//峰
'amount'
=>
'require'
'uType3_current_numb'
=>
'require'
,
//谷
'amount'
=>
'require'
//账单金额
];
];
protected
$message
=
[
protected
$message
=
[
...
@@ -28,15 +25,13 @@ class UseageGeneralInfoValidate extends Validate
...
@@ -28,15 +25,13 @@ class UseageGeneralInfoValidate extends Validate
'current_date.date'
=>
'本次抄表日期格式不正确'
,
'current_date.date'
=>
'本次抄表日期格式不正确'
,
'photo_id.require'
=>
'请上传电表照片'
,
'photo_id.require'
=>
'请上传电表照片'
,
'staff_id.require'
=>
'请选择抄表员'
,
'staff_id.require'
=>
'请选择抄表员'
,
'uType1_current_numb.require'
=>
'请填写波峰数据'
,
'price'
=>
'单价必填且只能是数字或小数'
,
'uType2_current_numb.require'
=>
'请填写峰数据'
,
'uType3_current_numb.require'
=>
'请填写波谷数据'
,
'amount.require'
=>
'缴费金额未填写'
'amount.require'
=>
'缴费金额未填写'
];
];
protected
$scene
=
[
protected
$scene
=
[
's1'
=>
'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id'
,
'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
=
[]){
protected
function
checkDate
(
$value
,
$rule
,
$data
=
[]){
...
...
application/em/view/invoice/Invoice.php
deleted
100755 → 0
浏览文件 @
a6334760
<?php
/**
* v2 账单模块
*/
namespace
app\em\controller
;
use
app\admin\controller\Base
;
use
app\em\model\EmInvoice
;
use
app\em\model\EmInvoiceHistory
;
use
app\em\model\EmInvoiceUseage
;
use
app\em\model\EmPayment
;
use
app\em\model\EmPaymentHistory
;
use
app\em\model\EmPaymentInvoice
;
use
app\em\model\EmPaymentInvoiceBalance
;
use
app\em\model\EmSettle
;
use
app\em\model\EmSettleInvoice
;
use
app\em\model\EmSettleInvoiceBalance
;
use
app\em\model\UseageDetail
;
use
think\facade\Request
;
class
Invoice
extends
Base
{
//账单列表
public
function
index
(){
$data
=
(
new
EmInvoice
)
->
getList
();
$page
=
$data
->
render
();
$this
->
assign
(
'data'
,
$data
);
$this
->
assign
(
'page'
,
$page
);
return
$this
->
fetch
();
}
//查看账单信息
public
function
detail
(){
$inv_id
=
Request
::
param
(
'id'
);
$invInfo
=
(
new
EmInvoice
)
->
getInvoiceDetail
(
$inv_id
);
$this
->
assign
(
'inv'
,
$invInfo
);
return
$this
->
fetch
();
}
//创建一个账单
public
function
createInvoice
(
$useage_id
){
$um
=
(
new
\app\em\model\Useage
)
->
getEmInfoByUseageId
(
$useage_id
)
->
toArray
();
return
$this
->
create
(
$um
);
}
//创建账单
public
function
create
(
$um
){
/// 如果是普通表 则
if
(
$um
[
'pricing_type'
]
==
1
){
return
$this
->
createInvoiceStdType
(
$um
);
}
else
if
(
$um
[
'pricing_type'
]
==
2
){
return
$this
->
createInvoiceSpecialType
(
$um
);
}
}
/**
* 生成账单号
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private
function
getInvoiceId
(){
$inv
=
EmInvoice
::
field
(
'id'
)
->
order
(
'id desc,create_time desc'
)
->
find
();
if
(
!
$inv
)
$id
=
1
;
else
$id
=
$inv
->
id
+
1
;
return
"ZD"
.
date
(
'Ymd'
)
.
zero
(
$id
);
}
//普通读表生成账单
public
function
createInvoiceStdType
(
$uData
){
$inv
=
new
EmInvoice
();
$inv
->
type
=
4
;
$inv
->
rate
=
$uData
[
'rate'
];
$inv
->
repo_numb
=
(
$uData
[
'current_sum_numb'
]
-
$uData
[
'last_sum_numb'
])
*
$uData
[
'rate'
];
$inv
->
payment_amount
=
$inv
->
payment_balance
=
$inv
->
repo_numb
*
$uData
[
'pay_price'
];
//结算信息
$inv
->
settle_amount
=
$inv
->
settle_balance
=
$inv
->
repo_numb
*
$uData
[
'settle_price'
];
$inv
->
status
=
'000'
;
$inv
->
invoice_id
=
$this
->
getInvoiceId
();
//获取账户ID
$inv
->
account_id
=
(
new
Account
())
->
getAccountId
(
$uData
[
'em_id'
]);
//保存 并且更新抄表单与账单关联表
if
(
$inv
->
save
()){
$eiu
=
new
EmInvoiceUseage
();
$eiu
->
invoice_id
=
$inv
->
invoice_id
;
$eiu
->
useage_id
=
$uData
[
'useage_id'
];
$eiu
->
save
();
}
//更新电表账户
$useage
=
\app\em\model\Useage
::
get
([
'useage_id'
=>
$uData
[
'useage_id'
]]);
$account
=
new
Account
();
$account
->
updateAmount
(
$useage
->
em_id
,
$inv
->
payment_amount
,
0
);
return
$inv
;
}
//峰谷表生成账单
public
function
createInvoiceSpecialType
(
$uData
){
$inv
=
new
EmInvoice
();
$inv
->
type
=
1
;
$inv
->
rate
=
$uData
[
'rate'
];
//获取峰谷表抄表明细
$uds
=
UseageDetail
::
where
([
'useage_id'
=>
$uData
[
'useage_id'
]])
->
select
()
->
toArray
();
//计算总价信息
//需要计算4个属性 各分段上一次 档次 repo amount
$last_numb
=
0
;
$curr_numb
=
0
;
$amount
=
0
;
$repo_numb
=
0
;
foreach
(
$uds
as
$v
){
$last_numb
+=
$v
[
'last_numb'
];
$curr_numb
+=
$v
[
'current_numb'
];
$amount
+=
(
int
)(
$v
[
'current_numb'
]
-
$v
[
'last_numb'
])
*
$v
[
'price'
];
$repo_numb
+=
(
int
)(
$v
[
'current_numb'
]
-
$v
[
'last_numb'
]);
}
//曝移动电量
$inv
->
repo_numb
=
(
$curr_numb
-
$last_numb
)
*
$uData
[
'rate'
];
//缴费信息
$inv
->
payment_amount
=
$inv
->
payment_balance
=
$amount
*
$uData
[
'rate'
];
//结算信息
$inv
->
settle_amount
=
$inv
->
settle_balance
=
$repo_numb
*
$uData
[
'settle_price'
];
$inv
->
status
=
'000'
;
$inv
->
invoice_id
=
$this
->
getInvoiceId
();
$inv
->
account_id
=
(
new
Account
())
->
getAccountId
(
$uData
[
'em_id'
]);
//更新抄表单的status
$useage
=
\app\em\model\Useage
::
get
([
'useage_id'
=>
$uData
[
'useage_id'
]]);
$useage
->
status
=
2
;
$useage
->
save
();
$inv
->
cert_id
=
$useage
->
photo_id
;
//保存 并且更新抄表单与账单关联表
if
(
$inv
->
save
()){
$eiu
=
new
EmInvoiceUseage
();
$eiu
->
invoice_id
=
$inv
->
invoice_id
;
$eiu
->
useage_id
=
$uData
[
'useage_id'
];
$eiu
->
save
();
}
return
$inv
;
}
public
function
updatePayment
(){
$data
=
Request
::
param
();
$inv
=
EmInvoice
::
get
([
'id'
=>
$data
[
'id'
]]);
if
(
!
$inv
)
return
json
([
'status'
=>
0
,
'message'
=>
'不存在抄表单ID,无法更新缴费金额'
]);
if
(
$data
[
'amount'
]
>
0
&&
$inv
->
is_add_condition
!=
1
){
$inv
->
payment_amount
=
$data
[
'amount'
];
$inv
->
payment_balance
=
$data
[
'amount'
];
$inv
->
is_add_condition
=
1
;
}
if
(
$inv
->
save
()){
return
json
([
'status'
=>
1
,
'message'
=>
'缴费金额已经更新'
]);
}
}
//账单合并列表
public
function
mergeList
(){
$ids
=
Request
::
param
(
'ids'
);
$idsArr
=
[];
if
(
!
empty
(
$ids
)){
$idsArr
=
explode
(
'_'
,
$ids
);
}
$data
=
(
new
EmInvoice
)
->
getListByInvIds
(
$idsArr
);
$payment_amount
=
0
;
$settle_amount
=
0
;
foreach
(
$data
as
$v
){
$payment_amount
+=
$v
->
payment_amount
;
$settle_amount
+=
$v
->
settle_amount
;
}
$this
->
assign
(
'data'
,
$data
);
$this
->
assign
(
'payment_amount'
,
$payment_amount
);
$this
->
assign
(
'settle_amount'
,
$settle_amount
);
return
$this
->
fetch
(
'merge_list'
);
}
/**
* 账单触发销账,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
,
$account_id
){
$paymentIdsArr
=
[];
//获取账单对象
$invoice
=
EmInvoice
::
field
(
'id,invoice_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()) return '账单未缴费';
//如果没有找到挂起的账单,则找相同账户下的缴费单
$associate
=
false
;
if
(
$payments
->
isEmpty
()){
$payments
=
(
new
EmPayment
())
->
field
(
'payment_id'
)
->
where
(
'account_id'
,
'='
,
$account_id
)
->
where
(
'balance'
,
'gt'
,
0
)
->
order
(
'id asc,create_time asc'
)
->
select
();
if
(
$payments
->
isEmpty
())
return
'账单未缴费'
;
else
$associate
=
true
;
}
//$paymentIdsArr = $payments->toArray();
foreach
(
$payments
as
$p
){
$paymentIdsArr
[]
=
$p
[
'payment_id'
];
}
//查询可消的额度
$payments_balance
=
(
new
EmPayment
)
->
where
(
'payment_id'
,
'in'
,
$paymentIdsArr
)
->
sum
(
'balance'
);
//如果该账单可以完全被缴费单销账
if
(
$payments_balance
<
$invoice
->
payment_balance
){
$payments
=
EmPayment
::
field
(
'payment_id'
)
->
where
(
'account_id'
,
'='
,
$account_id
)
->
where
(
'balance'
,
'neq'
,
0
)
->
order
(
'payment_id asc'
)
->
select
();
if
(
!
$payments
->
isEmpty
())
foreach
(
$payments
as
$payment
){
$paymentIdsArr
[]
=
$payment
->
payment_id
;
}
}
$paymentIds
=
$paymentIdsArr
;
$invsIds
[]
=
$invoice
->
invoice_id
;
//开始销账
return
$this
->
writeOff
(
$paymentIds
,
$invsIds
,
$associate
);
}
//从缴费单消账单
public
function
writeOffFromPayment
(
$account_id
,
$payment_id
){
//获取缴费单对象
$payment
=
EmPayment
::
where
(
'payment_id'
,
'='
,
$payment_id
)
->
find
();
//获取关联的账单对象
$invs
=
(
new
EmInvoice
())
->
alias
(
'ei'
)
->
field
(
'ei.invoice_id'
)
->
leftJoin
([
'em_payment_invoice'
=>
'epi'
],
'epi.invoice_id = ei.invoice_id'
)
->
where
(
'epi.payment_id'
,
'='
,
$payment_id
)
->
where
(
'ei.payment_balance'
,
'neq'
,
0
)
->
order
(
'ei.invoice_id asc'
)
->
select
();
$invsArr
=
[];
if
(
!
$invs
->
isEmpty
())
{
foreach
(
$invs
as
$inv
){
$invsArr
[]
=
$inv
->
invoice_id
;
}
}
//查询可消的额度
$payments_balance
=
(
new
EmInvoice
)
->
where
(
'invoice_id'
,
'in'
,
$invsArr
)
->
sum
(
'payment_balance'
);
//如果可以完全销账 则继续销账
if
(
$payment
->
balance
>
$payments_balance
){
$invs
=
(
new
EmInvoice
())
->
field
(
'invoice_id'
)
->
where
(
'account_id'
,
'='
,
$account_id
)
->
where
(
'payment_balance'
,
'neq'
,
0
)
->
order
(
'invoice_id asc'
)
->
select
();
if
(
!
$invs
->
isEmpty
())
{
foreach
(
$invs
as
$inv
){
$invsArr
[]
=
$inv
->
invoice_id
;
}
}
}
$paymentIds
[]
=
$payment
->
payment_id
;
//处理账户金额
return
$this
->
writeOff
(
$paymentIds
,
$invsArr
,
true
);
}
public
function
writeOffFromSettle
(
$account_id
,
$settle_id
){
//获取缴费单对象
$settle
=
EmSettle
::
where
(
'settle_id'
,
'='
,
$settle_id
)
->
find
();
//获取关联的账单对象
$invs
=
(
new
EmInvoice
())
->
alias
(
'ei'
)
->
field
(
'ei.invoice_id'
)
->
leftJoin
([
'em_settle_invoice'
=>
'esi'
],
'esi.invoice_id = ei.invoice_id'
)
->
where
(
'esi.settle_id'
,
'='
,
$settle_id
)
->
where
(
'ei.settle_balance'
,
'neq'
,
0
)
->
order
(
'ei.invoice_id asc'
)
->
select
();
$invsArr
=
[];
if
(
!
$invs
->
isEmpty
())
{
foreach
(
$invs
as
$inv
){
$invsArr
[]
=
$inv
->
invoice_id
;
}
}
//查询可消的额度
$settles_balance
=
(
new
EmInvoice
)
->
where
(
'invoice_id'
,
'in'
,
$invsArr
)
->
sum
(
'settle_balance'
);
//如果可以完全销账 则继续销账
if
(
$settle
->
balance
>
$settles_balance
){
$invs
=
(
new
EmInvoice
())
->
field
(
'invoice_id'
)
->
where
(
'account_id'
,
'='
,
$account_id
)
->
where
(
'settle_balance'
,
'neq'
,
0
)
->
order
(
'invoice_id asc'
)
->
select
();
if
(
!
$invs
->
isEmpty
())
{
foreach
(
$invs
as
$inv
){
$invsArr
[]
=
$inv
->
invoice_id
;
}
}
}
$settleIds
[]
=
$settle
->
settle_id
;
//处理账户金额
return
$this
->
writeOffSettle
(
$settleIds
,
$invsArr
);
}
/**
* 销账逻辑,并选择是否构建关联关系
* @param $paymentIds
* @param $invoiceIds
* @param bool $associate
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private
function
writeOff
(
$paymentIds
,
$invoiceIds
,
$associate
=
false
){
//获取可销账缴费单
$payments
=
EmPayment
::
where
(
'payment_id'
,
'in'
,
$paymentIds
)
->
select
();
//获取可销账账单
$invs
=
EmInvoice
::
where
(
'invoice_id'
,
'in'
,
$invoiceIds
)
->
select
();
$result
=
0
;
foreach
(
$payments
as
$key
=>
$payment
){
if
(
$payment
->
balance
==
0
)
continue
;
foreach
(
$invs
as
$index
=>
$inv
)
{
$balanceMode
=
new
EmPaymentInvoiceBalance
();
$balanceMode
->
payment_id
=
$payment
->
payment_id
;
if
(
$inv
->
payment_balance
==
0
)
continue
;
$balanceMode
->
invoice_id
=
$inv
->
invoice_id
;
//如果该缴费单可以完全消除当前账单额度
if
(
$payment
->
balance
>=
$inv
->
payment_balance
)
{
//单笔销账多少
$balanceMode
->
balance
=
$inv
->
payment_balance
;
//缴费额度变化
if
((
$payment
->
balance
-
$inv
->
payment_balance
)
==
0
){
$payment
->
status
=
2
;
}
else
{
$payment
->
status
=
1
;
//缴费部分销账
}
$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
;
$payment
->
status
=
2
;
//缴费已经完全销账
}
//关联关系
if
(
$associate
==
true
){
$model
=
new
EmPaymentInvoice
();
$data
[
'payment_id'
]
=
$payment
->
payment_id
;
$data
[
'invoice_id'
]
=
$inv
->
invoice_id
;
$mod
=
$model
->
where
(
$data
)
->
find
();
if
(
!
$mod
){
$model
->
payment_id
=
$payment
->
payment_id
;
$model
->
invoice_id
=
$inv
->
invoice_id
;
$model
->
save
();
}
}
$result
++
;
//更新账单状态
$inv
->
save
();
//todo::history; 保存历史记录
$invData
=
$inv
->
toArray
();
$invData
[
'id'
]
=
null
;
$invData
[
'create_time'
]
=
strtotime
(
$invData
[
'create_time'
]);
$invData
[
'update_time'
]
=
strtotime
(
$invData
[
'update_time'
]);
//EmInvoiceHistory::create($invData);
unset
(
$invs
[
$index
]);
//从结果集中去掉无效的数据
//更新状态
$payment
->
save
();
//todo::history;保存历史记录
$payData
=
$payment
->
toArray
();
$payData
[
'id'
]
=
null
;
$payData
[
'create_time'
]
=
strtotime
(
$payData
[
'create_time'
]);
$payData
[
'update_time'
]
=
strtotime
(
$payData
[
'update_time'
]);
$payData
[
'pay_date'
]
=
strtotime
(
$payData
[
'pay_date'
]);
//EmPaymentHistory::create($payData);
unset
(
$payments
[
$key
]);
$balanceMode
->
isUpdate
(
false
)
->
save
();
}
}
$msg
=
$result
==
0
?
'已审核,没有可销账的账单.'
:
'已审核,成功销账 '
.
$result
.
' 笔账单.'
;
return
$msg
;
}
private
function
writeOffSettle
(
$settleIds
,
$invoiceIds
,
$associate
=
false
){
//获取可销账结算单
$settles
=
EmSettle
::
where
(
'settle_id'
,
'in'
,
$settleIds
)
->
select
();
//获取可销账账单
$invs
=
EmInvoice
::
where
(
'invoice_id'
,
'in'
,
$invoiceIds
)
->
select
();
$result
=
0
;
foreach
(
$settles
as
$key
=>
$settle
){
if
(
$settle
->
balance
==
0
)
continue
;
foreach
(
$invs
as
$index
=>
$inv
)
{
$balanceMode
=
new
EmSettleInvoiceBalance
();
$balanceMode
->
settle_id
=
$settle
->
settle_id
;
if
(
$inv
->
settle_balance
==
0
)
continue
;
$balanceMode
->
invoice_id
=
$inv
->
invoice_id
;
//如果该结算单可以完全消除当前账单额度
if
(
$settle
->
balance
>=
$inv
->
settle_balance
)
{
//单笔销账多少
$balanceMode
->
balance
=
$inv
->
settle_balance
;
//结算额度变化
if
((
$settle
->
balance
-
$inv
->
settle_balance
)
==
0
){
$settle
->
status
=
2
;
}
else
{
$settle
->
status
=
1
;
//结算部分销账
}
$settle
->
balance
=
$settle
->
balance
-
$inv
->
settle_balance
;
//账单额度变化
$inv
->
settle_balance
=
0
;
//更新账户status 首字母 = 2
$inv
->
status
=
setInvoiceStatus
(
$inv
->
status
,
2
,
1
);
}
else
{
//单笔销账多少
$balanceMode
->
balance
=
$settle
->
balance
;
//账单额度变化
$inv
->
status
=
setInvoiceStatus
(
$inv
->
status
,
1
,
1
);
$inv
->
settle_balance
=
$inv
->
settle_balance
-
$settle
->
balance
;
//结算额度变化
$settle
->
balance
=
0
;
$settle
->
status
=
2
;
//结算已经完全销账
}
if
(
$associate
==
true
){
$model
=
new
EmSettleInvoice
();
$model
->
settle_id
=
$settle
->
settle_id
;
$model
->
invoice_id
=
$inv
->
invoice_id
;
$model
->
save
();
}
$result
++
;
//更新账单状态
$inv
->
save
();
//todo::history; 保存历史记录
$invData
=
$inv
->
toArray
();
$invData
[
'id'
]
=
null
;
$invData
[
'create_time'
]
=
strtotime
(
$invData
[
'create_time'
]);
$invData
[
'update_time'
]
=
strtotime
(
$invData
[
'update_time'
]);
//EmInvoiceHistory::create($invData);
unset
(
$invs
[
$index
]);
//从结果集中去掉无效的数据
//更新状态
$settle
->
save
();
//todo::history;保存历史记录
$payData
=
$settle
->
toArray
();
$payData
[
'id'
]
=
null
;
$payData
[
'create_time'
]
=
strtotime
(
$payData
[
'create_time'
]);
$payData
[
'update_time'
]
=
strtotime
(
$payData
[
'update_time'
]);
$payData
[
'settle_date'
]
=
strtotime
(
$payData
[
'settle_date'
]);
//EmSettleHistory::create($payData);
unset
(
$settles
[
$key
]);
$balanceMode
->
isUpdate
(
false
)
->
save
();
}
}
$msg
=
$result
==
0
?
'没有结算成功'
:
'成功结算: '
.
$result
.
'笔'
;
return
$msg
;
}
}
\ No newline at end of file
application/em/view/useage/default.html
浏览文件 @
22009fa8
...
@@ -90,49 +90,53 @@
...
@@ -90,49 +90,53 @@
<div
class=
"layui-col-md5"
>
<div
class=
"layui-col-md5"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
<label
class=
"layui-form-label"
>
上
期表数
上
次抄表日期
</label>
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
id=
"last_numb"
name=
"last_numb"
autocomplete=
"off"
class=
"layui-input"
value=
"{$em.last_sum_numb}"
disabled=
"disabled"
>
<input
type=
"text"
id=
"last_date"
name=
"last_date"
</div>
autocomplete=
"off"
class=
"layui-input"
value=
"{$em.useage.last_date}"
disabled=
"disabled"
>
<div
class=
"layui-form-mid layui-word-aux"
>
度
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"layui-col-md5"
>
<div
class=
"layui-col-md5"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
<label
class=
"layui-form-label"
>
上
次抄表日期
本
次抄表日期
</label>
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
id=
"
last_date"
name=
"las
t_date"
<input
type=
"text"
id=
"
current_date"
name=
"curren
t_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.current_date|date='Y:m:d'}
"
>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"layui-col-md5"
>
<div
class=
"layui-col-md5"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
<label
class=
"layui-form-label"
>
<span
class=
"x-red"
>
*
</span>
本期表
数
<span
class=
"x-red"
>
*
</span>
上期度
数
</label>
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
id=
"current_numb"
name=
"current_numb"
<input
type=
"text"
id=
"last_numb"
name=
"last_numb"
lay-verify=
"required"
autocomplete=
"off"
class=
"layui-input"
lay-verType=
"tips"
autocomplete=
"off"
class=
"layui-input"
disabled=
"disabled"
value=
"{$em.useage.last_sum_numb}"
>
value=
""
>
</div>
</div>
<div
class=
"layui-form-mid layui-word-aux"
>
<div
class=
"layui-form-mid layui-word-aux"
>
度
度
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"layui-col-md5"
>
<div
class=
"layui-col-md5"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
<label
class=
"layui-form-label"
>
本次查表日期
<span
class=
"x-red"
>
*
</span>
本期度数
</label>
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
id=
"current_date"
name=
"current_date"
autocomplete=
"off"
class=
"layui-input"
lay-verType=
"tips"
value=
""
>
<input
type=
"text"
id=
"current_numb"
name=
"current_numb"
autocomplete=
"off"
class=
"layui-input"
value=
"{$em.useage.current_numb|default=''}"
>
</div>
<div
class=
"layui-form-mid layui-word-aux"
>
度
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -151,7 +155,19 @@
...
@@ -151,7 +155,19 @@
</div>
</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"
{
if
$
em
.
useage
.
price
}
disabled=
"disabled"
{/
if
}
value=
"{$em.useage.price|default=''}"
>
</div>
<div
class=
"layui-form-mid layui-word-aux"
>
元
</div>
</div>
</div>
<div
class=
"layui-col-md5"
>
<div
class=
"layui-col-md5"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
...
@@ -159,10 +175,9 @@
...
@@ -159,10 +175,9 @@
<span
class=
"x-red"
>
*
</span>
抄表员
<span
class=
"x-red"
>
*
</span>
抄表员
</label>
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<select
name=
"staff_id"
>
<select
name=
"staff_id"
{
if
$
detail=
=true}
disabled=
"disabled"
{/
if
}
>
{foreach $staffs as $u}
{foreach $staffs as $u}
<option
value=
"{$u['id']}"
{
if
$
u
['
id
']
==
$
uid
}
selected
{/
if
}
>
{$u['name']}
</option>
<option
value=
"{$u['id']}"
{
if
$
u
['
id
']
==
$
uid
}
selected
{/
if
}
>
{$u['name']}
</option>
}
{/foreach}
{/foreach}
</select>
</select>
</div>
</div>
...
@@ -178,8 +193,8 @@
...
@@ -178,8 +193,8 @@
<button
type=
"button"
class=
"layui-btn"
id=
"up_photo"
>
<button
type=
"button"
class=
"layui-btn"
id=
"up_photo"
>
<i
class=
"layui-icon"
>
</i>
上传
<i
class=
"layui-icon"
>
</i>
上传
</button>
</button>
<input
type=
"hidden"
name=
"photo_id"
value=
"
{$em.photo.id|default=''}
"
>
<input
type=
"hidden"
name=
"photo_id"
value=
""
>
<a
href=
"
{if isset($em.photo.src)}{$em.photo.src|default='#'}{/if}
"
target=
"_blank"
class=
"layui-btn layui-hide"
>
<a
href=
""
target=
"_blank"
class=
"layui-btn layui-hide"
>
<i
class=
"layui-icon"
>

</i>
预览
<i
class=
"layui-icon"
>

</i>
预览
</a>
</a>
</div>
</div>
...
@@ -231,12 +246,12 @@
...
@@ -231,12 +246,12 @@
});
});
}
}
laydate
.
render
({
laydate
.
render
({
elem
:
'#current_date'
,
elem
:
'#current_date'
,
trigger
:
'click'
,
trigger
:
'click'
,
})
})
//保存抄表单,并且返回列表
//保存抄表单,并且返回列表
form
.
on
(
'submit(save)'
,
form
.
on
(
'submit(save)'
,
function
(
data
)
{
function
(
data
)
{
...
@@ -263,8 +278,9 @@
...
@@ -263,8 +278,9 @@
elem
:
'#up_photo'
,
elem
:
'#up_photo'
,
url
:
'/upFile'
,
url
:
'/upFile'
,
field
:
'up_file'
,
field
:
'up_file'
,
size
:
10240
,
accept
:
'file'
,
accept
:
'file'
,
size
:
10240
,
done
:
function
(
res
)
{
done
:
function
(
res
)
{
if
(
res
.
status
==
1
){
if
(
res
.
status
==
1
){
layMsg
(
res
.
message
)
layMsg
(
res
.
message
)
...
@@ -281,29 +297,19 @@
...
@@ -281,29 +297,19 @@
}
}
}
}
});
});
$
(
'#current_numb'
).
change
(
function
(){
var
$level
=
100000
;
var
$rate
=
$
(
'#rate'
).
val
();
var
$baseNum
=
$level
*
$rate
;
var
$rNum
=
$
(
this
).
val
()
*
$baseNum
-
$
(
'#last_numb'
).
val
()
*
$baseNum
;
if
(
$rNum
<
0
){
var
ln
=
$
(
'#last_numb'
);
layMsg
(
'本次抄表必须大于上次抄表读数'
,
5
);
var
cn
=
$
(
'#current_numb'
);
$
(
'#current_numb'
).
focus
();
}
else
{
ln
.
change
(
function
(){
$
(
'#repo_numb'
).
val
(
$rNum
/
$level
)
calRn
()
})
cn
.
change
(
function
(){
calRn
()
})
function
calRn
(){
var
rn
=
$
(
'#repo_numb'
);
var
lNv
=
Number
(
$
(
'#last_numb'
).
val
());
var
cNv
=
Number
(
$
(
'#current_numb'
).
val
());
if
(
cNv
>
lNv
){
var
reN
=
(
cNv
-
lNv
)
*
Number
(
$
(
'#rate'
).
val
());
rn
.
val
(
reN
)
}
else
{
rn
.
val
(
''
)
}
}
}
})
});
});
</script>
</script>
{/block}
{/block}
\ No newline at end of file
application/em/view/useage/detail.html
浏览文件 @
22009fa8
...
@@ -151,7 +151,19 @@
...
@@ -151,7 +151,19 @@
</div>
</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"
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-col-md5"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
...
@@ -215,8 +227,6 @@
...
@@ -215,8 +227,6 @@
$
=
layui
.
jquery
;
$
=
layui
.
jquery
;
var
form
=
layui
.
form
,
var
form
=
layui
.
form
,
layer
=
layui
.
layer
;
layer
=
layui
.
layer
;
//消息提示
//消息提示
function
layMsg
(
msg
,
type
=
6
,
time
=
1000
){
function
layMsg
(
msg
,
type
=
6
,
time
=
1000
){
layer
.
msg
(
msg
,{
layer
.
msg
(
msg
,{
...
@@ -225,6 +235,7 @@
...
@@ -225,6 +235,7 @@
});
});
}
}
//保存抄表单,并且返回列表
//保存抄表单,并且返回列表
form
.
on
(
'submit(check)'
,
form
.
on
(
'submit(check)'
,
function
(
data
)
{
function
(
data
)
{
...
@@ -241,7 +252,7 @@
...
@@ -241,7 +252,7 @@
window
.
location
.
href
=
'/useage'
;
window
.
location
.
href
=
'/useage'
;
})
})
}
else
{
}
else
{
layer
.
msg
(
data
.
msg
,{
icon
:
5
,
time
:
1000
})
layer
.
msg
(
data
.
m
essage
||
data
.
m
sg
,{
icon
:
5
,
time
:
1000
})
}
}
}
}
});
});
...
...
application/em/view/useage/detail_special.html
浏览文件 @
22009fa8
...
@@ -151,6 +151,20 @@
...
@@ -151,6 +151,20 @@
</div>
</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"
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-col-md5"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
<label
class=
"layui-form-label"
>
...
@@ -183,27 +197,6 @@
...
@@ -183,27 +197,6 @@
</div>
</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>
</div>
</div>
</div>
...
...
application/em/view/useage/special.html
浏览文件 @
22009fa8
...
@@ -95,7 +95,7 @@
...
@@ -95,7 +95,7 @@
</label>
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
id=
"last_date"
name=
"last_date"
<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>
</div>
</div>
</div>
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
</label>
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
id=
"current_date"
name=
"current_date"
<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>
</div>
</div>
</div>
...
@@ -119,7 +119,7 @@
...
@@ -119,7 +119,7 @@
</label>
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
id=
"last_numb"
name=
"last_numb"
<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>
<div
class=
"layui-form-mid layui-word-aux"
>
<div
class=
"layui-form-mid layui-word-aux"
>
度
度
...
@@ -134,7 +134,7 @@
...
@@ -134,7 +134,7 @@
</label>
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
id=
"current_numb"
name=
"current_numb"
<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>
<div
class=
"layui-form-mid layui-word-aux"
>
<div
class=
"layui-form-mid layui-word-aux"
>
度
度
...
@@ -155,6 +155,21 @@
...
@@ -155,6 +155,21 @@
</div>
</div>
</div>
</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-col-md5"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
<label
class=
"layui-form-label"
>
...
@@ -186,29 +201,6 @@
...
@@ -186,29 +201,6 @@
</div>
</div>
</div>
</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>
</div>
</div>
</div>
...
@@ -261,7 +253,6 @@
...
@@ -261,7 +253,6 @@
trigger
:
'click'
,
trigger
:
'click'
,
})
})
//保存抄表单,并且返回列表
//保存抄表单,并且返回列表
form
.
on
(
'submit(save)'
,
form
.
on
(
'submit(save)'
,
function
(
data
)
{
function
(
data
)
{
...
@@ -307,24 +298,18 @@
...
@@ -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>
</script>
{/block}
{/block}
\ No newline at end of file
config/session.php.bak
deleted
100755 → 0
浏览文件 @
a6334760
<?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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论