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
85090e3c
Commit
85090e3c
authored
Aug 10, 2020
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加list接口分页
parent
8adc1df9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
18 deletions
+33
-18
Controller/RentController.py
+16
-11
Service/RentService.py
+17
-7
No files found.
Controller/RentController.py
View file @
85090e3c
...
...
@@ -46,26 +46,31 @@ def rent_list():
if
data_type
==
0
:
start_time
,
end_time
=
Helper
.
getTodayDate
()
info
=
RentService
.
get_rent_production_info
(
spot_id
,
start_time
,
end_time
)
info
,
total_count
=
RentService
.
get_rent_production_info
(
spot_id
,
start_time
,
end_time
,
page
,
limit
)
total_income
,
total_rent
=
IndexService
.
get_total_production
(
spot_id
,
start_time
,
end_time
)
return
jsonify
({
'error_code'
:
200
,
'error_message'
:
'Success'
,
'data'
:
info
,
'detail'
:
{
'total_income'
:
total_income
,
'total_rent'
:
total_rent
}})
return
jsonify
(
{
'error_code'
:
200
,
'error_message'
:
'Success'
,
'data'
:
info
,
'total_count'
:
total_count
,
'page'
:
page
,
'limit'
:
limit
,
'detail'
:
{
'total_income'
:
total_income
,
'total_rent'
:
total_rent
}})
elif
data_type
==
1
:
start_time
,
end_time
=
Helper
.
getYesterdayDate
()
info
=
RentService
.
get_rent_production_all
(
spot_id
,
start_time
,
end_time
,
page
,
limit
)
info
,
total_count
=
RentService
.
get_rent_production_all
(
spot_id
,
start_time
,
end_time
,
page
,
limit
)
total_income
,
total_rent
=
IndexService
.
get_total_production
(
spot_id
,
start_time
,
end_time
)
return
jsonify
({
'error_code'
:
200
,
'error_message'
:
'Success'
,
'data'
:
info
,
'detail'
:
{
'total_income'
:
total_income
,
'total_rent'
:
total_rent
}})
return
jsonify
(
{
'error_code'
:
200
,
'error_message'
:
'Success'
,
'data'
:
info
,
'total_count'
:
total_count
,
'page'
:
page
,
'limit'
:
limit
,
'detail'
:
{
'total_income'
:
total_income
,
'total_rent'
:
total_rent
}})
elif
data_type
==
2
:
start_time
,
end_time
=
Helper
.
getSevenDate
()
info
=
RentService
.
get_rent_production_all
(
spot_id
,
start_time
,
end_time
,
page
,
limit
)
info
,
total_count
=
RentService
.
get_rent_production_all
(
spot_id
,
start_time
,
end_time
,
page
,
limit
)
total_income
,
total_rent
=
IndexService
.
get_total_production
(
spot_id
,
start_time
,
end_time
)
return
jsonify
({
'error_code'
:
200
,
'error_message'
:
'Success'
,
'data'
:
info
,
'detail'
:
{
'total_income'
:
total_income
,
'total_rent'
:
total_rent
}})
return
jsonify
(
{
'error_code'
:
200
,
'error_message'
:
'Success'
,
'data'
:
info
,
'total_count'
:
total_count
,
'page'
:
page
,
'limit'
:
limit
,
'detail'
:
{
'total_income'
:
total_income
,
'total_rent'
:
total_rent
}})
else
:
start_time
,
end_time
=
Helper
.
getMonthDate
()
info
=
RentService
.
get_not_return_production
(
spot_id
,
start_time
,
end_time
)
return
jsonify
(
BASE_RESPONSE
(
data
=
info
)
.
to_dict
())
info
,
total_count
=
RentService
.
get_not_return_production
(
spot_id
,
start_time
,
end_time
,
page
,
limit
)
return
jsonify
(
{
'error_code'
:
200
,
'error_message'
:
'Success'
,
'data'
:
info
,
'total_count'
:
total_count
,
'page'
:
page
,
'limit'
:
limit
,
})
@route_rent.route
(
'/detail'
,
methods
=
[
'GET'
,
'POST'
])
...
...
Service/RentService.py
View file @
85090e3c
...
...
@@ -23,6 +23,8 @@ class RentService():
Production
.
created_at
>=
start_time
,
Production
.
created_at
<=
end_time
}
total_count
=
db
.
session
.
query
(
Rent
,
Production
)
.
join
(
Production
,
Production
.
rent_id
==
Rent
.
id
)
.
filter
(
*
where
)
.
count
()
rent_info
=
db
.
session
.
query
(
Rent
,
Production
)
.
join
(
Production
,
Production
.
rent_id
==
Rent
.
id
)
.
filter
(
*
where
)
.
order_by
(
Production
.
created_at
.
desc
())
.
slice
(
page
*
limit
,
(
page
+
1
)
*
limit
)
.
all
()
data
=
[]
...
...
@@ -42,10 +44,10 @@ class RentService():
else
:
cur_info
[
'status'
]
=
0
data
.
append
(
cur_info
)
return
data
return
data
,
total_count
@staticmethod
def
get_not_return_production
(
spot_id
,
start_time
,
end_time
):
def
get_not_return_production
(
spot_id
,
start_time
,
end_time
,
page
,
limit
):
where
=
{
Rent
.
spot_id
==
spot_id
,
Production
.
is_out
==
1
,
...
...
@@ -53,8 +55,11 @@ class RentService():
Production
.
created_at
>=
start_time
,
Production
.
created_at
<=
end_time
}
total_count
=
db
.
session
.
query
(
Rent
,
Production
)
.
join
(
Production
,
Production
.
rent_id
==
Rent
.
id
)
.
filter
(
*
where
)
.
count
()
rent_info
=
db
.
session
.
query
(
Rent
,
Production
)
.
join
(
Production
,
Production
.
rent_id
==
Rent
.
id
)
.
filter
(
*
where
)
.
order_by
(
Production
.
created_at
.
desc
())
.
all
()
*
where
)
.
order_by
(
Production
.
created_at
.
desc
())
.
slice
(
page
*
limit
,
(
page
+
1
)
*
limit
)
.
all
()
data
=
[]
for
info
in
rent_info
:
tmp
=
{
...
...
@@ -64,17 +69,22 @@ class RentService():
'status'
:
0
}
data
.
append
(
tmp
)
return
data
return
data
,
total_count
@staticmethod
def
get_rent_production_info
(
spot_id
,
start_time
,
end_time
):
def
get_rent_production_info
(
spot_id
,
start_time
,
end_time
,
page
,
limit
):
where
=
{
Rent
.
spot_id
==
spot_id
,
Production
.
created_at
>=
start_time
,
Production
.
created_at
<=
end_time
}
total_count
=
db
.
session
.
query
(
Rent
,
Production
)
.
join
(
Production
,
Production
.
rent_id
==
Rent
.
id
)
.
filter
(
*
where
)
.
count
()
rent_info
=
db
.
session
.
query
(
Rent
,
Production
)
.
join
(
Production
,
Production
.
rent_id
==
Rent
.
id
)
.
filter
(
*
where
)
.
order_by
(
Production
.
created_at
.
desc
())
.
all
()
*
where
)
.
order_by
(
Production
.
created_at
.
desc
())
.
slice
(
page
*
limit
,
(
page
+
1
)
*
limit
)
.
all
()
data
=
[]
for
info
in
rent_info
:
cur_info
=
{}
...
...
@@ -92,7 +102,7 @@ class RentService():
else
:
cur_info
[
'status'
]
=
0
data
.
append
(
cur_info
)
return
data
return
data
,
total_count
@staticmethod
def
get_no_production_detail
(
rent_no
):
...
...
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