Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tour_business
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
魏强
tour_business
Commits
e2191e7e
Commit
e2191e7e
authored
Jun 11, 2020
by
魏强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步check_fee;
parent
f01a18bf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
13 deletions
+59
-13
Controller/RentController.py
+1
-1
Model/Machine/MachineModel.py
+1
-0
Model/Rent/FeeMinuteModel.py
+17
-0
Service/RentService.py
+40
-12
No files found.
Controller/RentController.py
View file @
e2191e7e
...
...
@@ -158,7 +158,7 @@ def rent_refund():
rent
=
info
.
Rent
fee
=
RentService
.
check_fee
(
rent
.
pay_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
),
str
(
back_time
),
rent
.
one_day_price
,
rent
.
free_time
)
rent
.
free_time
,
production_info
.
Machine
.
id
,
production_info
.
Machine
.
price_type
)
total
=
fee
[
'total'
]
if
fee
[
'total'
]
<
rent
.
deposit
else
rent
.
deposit
refund_money
=
rent
.
deposit
-
total
...
...
Model/Machine/MachineModel.py
View file @
e2191e7e
...
...
@@ -13,6 +13,7 @@ class Machine(BaseModel):
mac_no
=
Column
(
String
(
16
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'机柜编号'
)
he_cloud_device_id
=
Column
(
String
(
191
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'机柜号对应的波所的编号'
)
one_day_price
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'日租金'
)
price_type
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'收费类型 1:按天收费 2:按时收费'
)
deposit
=
Column
(
Integer
,
nullable
=
False
,
server_default
=
FetchedValue
(),
comment
=
'押金'
)
free_time
=
Column
(
Integer
,
nullable
=
False
,
server_default
=
FetchedValue
(),
comment
=
'免费时间'
)
position
=
Column
(
NullType
,
comment
=
'机柜位置坐标'
)
...
...
Model/Rent/FeeMinuteModel.py
0 → 100644
View file @
e2191e7e
# -*- coding: utf-8 -*-
__author__
=
'weiqiang'
__date__
=
'2020/6/11 13:55'
from
sqlalchemy
import
Column
,
Integer
,
String
,
DateTime
,
FetchedValue
from
Model.Base
import
db
,
BaseModel
class
FeeMinuteModel
(
BaseModel
):
__tablename__
=
'fee_minute'
id
=
Column
(
Integer
,
primary_key
=
True
)
machine_id
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'机柜id'
)
index
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'收费顺序'
)
minute
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'收费时间'
)
price
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'价格'
)
status
=
Column
(
Integer
,
nullable
=
False
,
comment
=
'状态-1删除 1正常'
)
Service/RentService.py
View file @
e2191e7e
...
...
@@ -9,6 +9,7 @@ from Model.Base import db
from
Model.Customer.CustomerModel
import
Customer
from
Model.Machine.MachineModel
import
Machine
from
Model.Production.ProductionModel
import
Production
from
Model.Rent.FeeMinuteModel
import
FeeMinuteModel
from
Model.Rent.RentModel
import
Rent
from
Model.Rent.RentRefundModel
import
RentRefund
from
Model.Spot.SpotModel
import
Spot
...
...
@@ -254,7 +255,7 @@ class RentService():
return
data
@staticmethod
def
check_fee
(
rent_time
,
back_time
,
one_day_price
,
free_time
):
def
check_fee
(
rent_time
,
back_time
,
one_day_price
,
free_time
,
machine_id
,
price_type
):
'''
计算租借费用
:param rent_time:
...
...
@@ -263,17 +264,44 @@ class RentService():
:param free_time:
:return:
'''
back_time_date
=
datetime
.
datetime
.
strptime
(
back_time
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
rent_time_date
=
datetime
.
datetime
.
strptime
(
rent_time
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
use_time
=
(
back_time_date
-
rent_time_date
)
.
total_seconds
()
total
=
0
use_m
=
round
(
use_time
/
60
,
2
)
if
use_time
>
free_time
*
60
:
days
=
(
datetime
.
datetime
(
back_time_date
.
year
,
back_time_date
.
month
,
back_time_date
.
day
)
-
datetime
.
datetime
(
rent_time_date
.
year
,
rent_time_date
.
month
,
rent_time_date
.
day
))
.
days
total
=
one_day_price
*
(
days
+
1
)
return
{
'total'
:
total
,
'use_m'
:
use_m
}
if
price_type
==
1
:
back_time_date
=
datetime
.
datetime
.
strptime
(
back_time
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
rent_time_date
=
datetime
.
datetime
.
strptime
(
rent_time
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
use_time
=
(
back_time_date
-
rent_time_date
)
.
total_seconds
()
total
=
0
use_m
=
round
(
use_time
/
60
,
2
)
if
use_time
>
free_time
*
60
:
days
=
(
datetime
.
datetime
(
back_time_date
.
year
,
back_time_date
.
month
,
back_time_date
.
day
)
-
datetime
.
datetime
(
rent_time_date
.
year
,
rent_time_date
.
month
,
rent_time_date
.
day
))
.
days
total
=
one_day_price
*
(
days
+
1
)
return
{
'total'
:
total
,
'use_m'
:
use_m
}
elif
price_type
==
2
:
back_time_date
=
datetime
.
datetime
.
strptime
(
back_time
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
rent_time_date
=
datetime
.
datetime
.
strptime
(
rent_time
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
use_time
=
(
back_time_date
-
rent_time_date
)
.
total_seconds
()
total
=
0
use_m
=
round
(
use_time
/
60
,
2
)
if
use_time
>
free_time
*
60
:
days
=
(
datetime
.
datetime
(
back_time_date
.
year
,
back_time_date
.
month
,
back_time_date
.
day
)
-
datetime
.
datetime
(
rent_time_date
.
year
,
rent_time_date
.
month
,
rent_time_date
.
day
))
.
days
# 超过一天的,按天收费,天数*25
if
days
>=
1
:
total
=
(
days
+
1
)
*
one_day_price
else
:
price_parts
=
FeeMinuteModel
.
query
.
filter_by
(
machine_id
=
machine_id
,
status
=
1
)
.
order_by
(
FeeMinuteModel
.
index
.
asc
())
.
all
()
for
tmp
in
price_parts
:
# 60分钟以内,不收费
if
use_time
>
tmp
.
minute
*
60
:
total
=
tmp
.
price
return
{
'total'
:
total
,
'use_m'
:
use_m
}
else
:
return
None
@classmethod
def
check_fee_liuyuan
(
cls
,
rent_time
,
back_time
,
one_day_price
,
free_time
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment