Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Automat
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
1
Merge Requests
1
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
冯佳佳
Automat
Commits
9043de60
Commit
9043de60
authored
Feb 24, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
0dcc9fc3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
myapps/pc_management/api/rent_portal.py
+9
-7
No files found.
myapps/pc_management/api/rent_portal.py
View file @
9043de60
...
@@ -369,7 +369,8 @@ def run_day_bill():
...
@@ -369,7 +369,8 @@ def run_day_bill():
end_date
=
json_data
.
get
(
"endDate"
,
None
)
end_date
=
json_data
.
get
(
"endDate"
,
None
)
now
=
datetime
.
datetime
.
now
()
.
date
()
now
=
datetime
.
datetime
.
now
()
.
date
()
select_sql
=
" SELECT sum(real_total) as real_total, bill_date "
select_sql
=
""" select SUM(tab1.real_total) AS real_total, tab1.bill_date, ifnull(draw_record.status,-2) as draw_status,
ifnull(draw_record.real_total,0) as drawed_total """
count_sql
=
" select count(1) as total_count"
count_sql
=
" select count(1) as total_count"
from_sql
=
"""
from_sql
=
"""
FROM
FROM
...
@@ -392,17 +393,17 @@ def run_day_bill():
...
@@ -392,17 +393,17 @@ def run_day_bill():
GROUP BY DATE_FORMAT(rent.created_at, '
%
Y-
%
m-
%
d') , rent.business_id) AS tab1
GROUP BY DATE_FORMAT(rent.created_at, '
%
Y-
%
m-
%
d') , rent.business_id) AS tab1
"""
.
format
(
now
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
g
.
user
.
id
)
"""
.
format
(
now
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
g
.
user
.
id
)
where_sql
=
"""
where_sql
=
"""
where real_total > '0'
left join draw_record on draw_record.bill_date = tab1.bill_date and draw_record.status != -1
where tab1.real_total > '0'
"""
"""
if
start_date
is
not
None
:
if
start_date
is
not
None
:
where_sql
+=
" and bill_date >= '{}'"
.
format
(
start_date
)
where_sql
+=
" and
tab1.
bill_date >= '{}'"
.
format
(
start_date
)
if
end_date
is
not
None
:
if
end_date
is
not
None
:
where_sql
+=
" and bill_date <= '{}'"
.
format
(
end_date
)
where_sql
+=
" and
tab1.
bill_date <= '{}'"
.
format
(
end_date
)
group_sql
=
"""group by tab1.bill_date """
group_sql
=
"""group by tab1.bill_date """
order_sql
=
" ORDER BY tab1.bill_date DESC "
order_sql
=
" ORDER BY tab1.bill_date DESC "
limit_sql
=
" LIMIT {offset} , {page_size}"
.
format
(
offset
=
(
page
-
1
)
*
page_size
,
page_size
=
page_size
)
limit_sql
=
" LIMIT {offset} , {page_size}"
.
format
(
offset
=
(
page
-
1
)
*
page_size
,
page_size
=
page_size
)
print
(
count_sql
+
from_sql
+
where_sql
+
group_sql
)
count_result
=
db
.
session
.
execute
(
count_sql
+
from_sql
+
where_sql
)
.
fetchone
()
count_result
=
db
.
session
.
execute
(
count_sql
+
from_sql
+
where_sql
)
.
fetchone
()
if
not
count_result
:
if
not
count_result
:
...
@@ -410,14 +411,15 @@ def run_day_bill():
...
@@ -410,14 +411,15 @@ def run_day_bill():
else
:
else
:
total_count
=
count_result
.
total_count
total_count
=
count_result
.
total_count
print
(
select_sql
+
from_sql
+
where_sql
+
group_sql
+
order_sql
+
limit_sql
)
result
=
db
.
session
.
execute
(
select_sql
+
from_sql
+
where_sql
+
group_sql
+
order_sql
+
limit_sql
)
.
fetchall
()
result
=
db
.
session
.
execute
(
select_sql
+
from_sql
+
where_sql
+
group_sql
+
order_sql
+
limit_sql
)
.
fetchall
()
return_data
=
[]
return_data
=
[]
if
result
:
if
result
:
for
info
in
result
:
for
info
in
result
:
tmp
=
{
tmp
=
{
"real_total"
:
int
(
info
.
real_total
),
"bill_date"
:
info
.
bill_date
,
"total"
:
float
(
info
.
real_total
)
"real_total"
:
int
(
info
.
real_total
),
"bill_date"
:
info
.
bill_date
,
"total"
:
float
(
info
.
real_total
),
"draw_status"
:
info
.
draw_status
,
"drawed_total"
:
info
.
drawed_total
,
}
}
return_data
.
append
(
tmp
)
return_data
.
append
(
tmp
)
...
...
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