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
eebf3b2a
Commit
eebf3b2a
authored
Feb 24, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3d3d292f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
165 additions
and
41 deletions
+165
-41
models/models.py
+2
-6
myapps/pc_management/api/rent_portal.py
+163
-35
No files found.
models/models.py
View file @
eebf3b2a
...
@@ -164,7 +164,6 @@ class DrawDetail(Base):
...
@@ -164,7 +164,6 @@ class DrawDetail(Base):
open_id
=
Column
(
String
(
40
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
open_id
=
Column
(
String
(
40
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
draw_no
=
Column
(
VARCHAR
(
40
),
nullable
=
False
,
index
=
True
)
draw_no
=
Column
(
VARCHAR
(
40
),
nullable
=
False
,
index
=
True
)
payment_no
=
Column
(
VARCHAR
(
40
),
nullable
=
False
)
payment_no
=
Column
(
VARCHAR
(
40
),
nullable
=
False
)
business_id
=
Column
(
INTEGER
(
11
),
nullable
=
False
)
draw_month
=
Column
(
VARCHAR
(
7
))
draw_month
=
Column
(
VARCHAR
(
7
))
total
=
Column
(
INTEGER
(
11
))
total
=
Column
(
INTEGER
(
11
))
real_total
=
Column
(
INTEGER
(
11
))
real_total
=
Column
(
INTEGER
(
11
))
...
@@ -177,18 +176,15 @@ class DrawDetail(Base):
...
@@ -177,18 +176,15 @@ class DrawDetail(Base):
class
DrawRecord
(
Base
):
class
DrawRecord
(
Base
):
__tablename__
=
'draw_record'
__tablename__
=
'draw_record'
__table_args__
=
(
__table_args__
=
(
Index
(
'unique4draw_record_user_month'
,
'user_id'
,
'
draw_month'
,
'business_id
'
,
unique
=
True
),
Index
(
'unique4draw_record_user_month'
,
'user_id'
,
'
bill_date
'
,
unique
=
True
),
)
)
id
=
Column
(
INTEGER
(
10
),
primary_key
=
True
)
id
=
Column
(
INTEGER
(
10
),
primary_key
=
True
)
user_id
=
Column
(
INTEGER
(
11
),
nullable
=
False
)
user_id
=
Column
(
INTEGER
(
11
),
nullable
=
False
)
user_no
=
Column
(
String
(
25
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
user_no
=
Column
(
String
(
25
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
draw_no
=
Column
(
VARCHAR
(
40
),
nullable
=
False
,
index
=
True
)
draw_no
=
Column
(
VARCHAR
(
40
),
nullable
=
False
,
index
=
True
)
business_id
=
Column
(
INTEGER
(
11
))
bill_date
=
Column
(
VARCHAR
(
20
))
draw_month
=
Column
(
VARCHAR
(
7
))
total
=
Column
(
INTEGER
(
11
))
real_total
=
Column
(
INTEGER
(
11
))
real_total
=
Column
(
INTEGER
(
11
))
rate
=
Column
(
INTEGER
(
3
))
draw_time
=
Column
(
TIMESTAMP
)
draw_time
=
Column
(
TIMESTAMP
)
status
=
Column
(
TINYINT
(
1
),
nullable
=
False
,
server_default
=
text
(
"'0'"
))
status
=
Column
(
TINYINT
(
1
),
nullable
=
False
,
server_default
=
text
(
"'0'"
))
created_at
=
Column
(
TIMESTAMP
,
server_default
=
text
(
"CURRENT_TIMESTAMP"
))
created_at
=
Column
(
TIMESTAMP
,
server_default
=
text
(
"CURRENT_TIMESTAMP"
))
...
...
myapps/pc_management/api/rent_portal.py
View file @
eebf3b2a
...
@@ -356,51 +356,180 @@ def run_month_bill():
...
@@ -356,51 +356,180 @@ def run_month_bill():
return
BaseResponse
({
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
})
return
BaseResponse
({
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
})
@rent_route.route
(
"
apply_draw
"
,
methods
=
[
"POST"
])
@rent_route.route
(
"
day_bill
"
,
methods
=
[
"POST"
])
def
run_
apply_draw
():
def
run_
day_bill
():
"""
"""
:return:
:return:
"""
"""
json_data
=
request
.
get_json
()
json_data
=
request
.
get_json
()
draw_data
=
json_data
[
"draw_data"
]
page
=
json_data
.
get
(
"page"
,
1
)
page_size
=
json_data
.
get
(
"pageSize"
,
10
)
start_date
=
json_data
.
get
(
"startDate"
,
None
)
end_date
=
json_data
.
get
(
"endDate"
,
None
)
for
data
in
draw_data
:
now
=
datetime
.
datetime
.
now
()
.
date
()
business_id
=
int
(
data
[
"business_id"
])
select_sql
=
" SELECT sum(real_total) as real_total, bill_date "
month
=
datetime
.
datetime
.
strptime
(
data
[
"month"
],
"
%
Y-
%
M"
)
count_sql
=
" select count(1) as total_count"
select_sql
=
"""
from_sql
=
"""
select sum(rent.real_total) as total, rent.business_id,
FROM
DATE_FORMAT(rent.created_at,"
%
Y-
%
m") as rent_month,
(SELECT
admin_business.rate as rate, business.business_name as business_name
SUM(total * rate/100) AS real_total,
"""
rent.business_id,
DATE_FORMAT(rent.created_at, '
%
Y-
%
m-
%
d') AS bill_date,
admin_business.rate AS rate,
business.business_name AS business_name
FROM
rent
LEFT JOIN admin_business ON admin_business.business_id = rent.business_id
LEFT JOIN business ON business.id = rent.business_id
WHERE
0 = 0
AND rent.created_at < '{}'
AND admin_business.user_id = '{}'
AND admin_business.status = 1
AND admin_business.rate > 0
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
)
where_sql
=
"""
where real_total > '0'
"""
if
start_date
is
not
None
:
where_sql
+=
" and bill_date >= '{}'"
.
format
(
start_date
)
if
end_date
is
not
None
:
where_sql
+=
" and bill_date <= '{}'"
.
format
(
end_date
)
from_sql
=
"""
group_sql
=
"""group by tab1.bill_date """
FROM
order_sql
=
" ORDER BY tab1.bill_date DESC "
rent
limit_sql
=
" LIMIT {offset} , {page_size}"
.
format
(
offset
=
(
page
-
1
)
*
page_size
,
page_size
=
page_size
)
left join admin_business on admin_business.business_id = rent.business_id
print
(
count_sql
+
from_sql
+
where_sql
+
group_sql
)
left join business on business.id = rent.business_id
count_result
=
db
.
session
.
execute
(
count_sql
+
from_sql
+
where_sql
)
.
fetchone
()
"""
where_sql
=
""" WHERE rent.business_id = '{}' and DATE_FORMAT(rent.created_at,"
%
Y-
%
m") = '{}' """
.
format
(
if
not
count_result
:
business_id
,
data
[
"month"
])
return
BaseResponse
(
data
=
{
"list"
:
[],
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
0
})
else
:
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
()
return_data
=
[]
if
result
:
for
info
in
result
:
tmp
=
{
"total"
:
int
(
info
.
real_total
),
"bill_date"
:
info
.
bill_date
,
"total2"
:
info
.
real_total
,
}
return_data
.
append
(
tmp
)
return
BaseResponse
({
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
})
where_sql
+=
""" and admin_business.user_id = '{}' and admin_business.status = 1 and admin_business.rate > 0
"""
.
format
(
g
.
user
.
id
)
result
=
db
.
session
.
execute
(
select_sql
+
from_sql
+
where_sql
)
.
fetchone
()
@rent_route.route
(
"day_bill_detail"
,
methods
=
[
"POST"
])
def
run_day_bill_detail
():
"""
:return:
"""
json_data
=
request
.
get_json
()
page
=
json_data
.
get
(
"page"
,
1
)
page_size
=
json_data
.
get
(
"pageSize"
,
10
)
business_id
=
json_data
.
get
(
"business_id"
,
None
)
bill_date
=
json_data
[
"bill_date"
]
select_sql
=
"""
select sum(rent.real_total) as total, rent.business_id,
DATE_FORMAT(rent.created_at,"
%
Y-
%
m-
%
d") as bill_date,
admin_business.rate as rate, business.business_name as business_name
"""
count_sql
=
" select count(1) as total_count from ("
from_sql
=
"""
FROM
rent
left join admin_business on admin_business.business_id = rent.business_id
left join business on business.id = rent.business_id
"""
where_sql
=
""" WHERE 0=0 and DATE_FORMAT(rent.created_at,"
%
Y-
%
m-
%
d") = '{}'"""
.
format
(
bill_date
)
if
business_id
is
not
None
:
where_sql
+=
" and rent.business_id = '{}'"
.
format
(
business_id
)
where_sql
+=
""" and admin_business.user_id = '{}' and admin_business.status = 1 and admin_business.rate > 0
"""
.
format
(
g
.
user
.
id
)
group_sql
=
""" group by DATE_FORMAT(rent.created_at,"
%
Y-
%
m-
%
d") , rent.business_id """
order_sql
=
" ORDER BY rent.created_at DESC"
limit_sql
=
" LIMIT {offset} , {page_size}"
.
format
(
offset
=
(
page
-
1
)
*
page_size
,
page_size
=
page_size
)
count_result
=
db
.
session
.
execute
(
count_sql
+
select_sql
+
from_sql
+
where_sql
+
group_sql
+
") as ttb"
)
.
fetchone
()
if
not
count_result
:
return
BaseResponse
(
data
=
{
"list"
:
[],
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
0
})
else
:
total_count
=
count_result
.
total_count
result
=
db
.
session
.
execute
(
select_sql
+
from_sql
+
where_sql
+
group_sql
+
order_sql
+
limit_sql
)
.
fetchall
()
return_data
=
[]
if
result
:
for
info
in
result
:
tmp
=
{
"total"
:
int
(
info
.
total
),
"business_id"
:
info
.
business_id
,
"bill_date"
:
info
.
bill_date
,
"rate"
:
info
.
rate
,
"business_name"
:
info
.
business_name
,
}
return_data
.
append
(
tmp
)
return
BaseResponse
({
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
})
@rent_route.route
(
"apply_draw"
,
methods
=
[
"POST"
])
def
run_apply_draw
():
"""
:return:
"""
json_data
=
request
.
get_json
()
draw_data
=
json_data
[
"draw_data"
]
for
data
in
draw_data
:
bill_date
=
datetime
.
datetime
.
strptime
(
data
[
"bill_date"
],
"
%
Y-
%
m-
%
d"
)
.
strftime
(
"
%
Y-
%
m-
%
d"
)
sql
=
"""
SELECT
sum(real_total) as real_total, bill_date
FROM
(SELECT
SUM(total * rate / 100) AS real_total,
rent.business_id,
DATE_FORMAT(rent.created_at, '
%
Y-
%
m-
%
d') AS bill_date,
admin_business.rate AS rate,
business.business_name AS business_name
FROM
rent
LEFT JOIN admin_business ON admin_business.business_id = rent.business_id
LEFT JOIN business ON business.id = rent.business_id
WHERE
0 = 0
AND rent.created_at < '2022-02-24 00:00:00'
AND admin_business.user_id = '2'
AND admin_business.status = 1
AND admin_business.rate > 0
GROUP BY DATE_FORMAT(rent.created_at, '
%
Y-
%
m-
%
d') , rent.business_id) AS tab1
WHERE
real_total > '0'
and bill_date = '{}'
"""
.
format
(
bill_date
)
result
=
db
.
session
.
execute
(
sql
)
.
fetchone
()
if
result
:
if
result
:
tmp
=
DrawRecord
.
query
.
filter_by
(
user_id
=
g
.
user
.
id
,
business_id
=
result
[
"business_id"
],
tmp
=
DrawRecord
.
query
.
filter_by
(
user_id
=
g
.
user
.
id
,
bill_date
=
result
[
"bill_date"
])
.
first
()
draw_month
=
result
[
"rent_month"
])
.
first
()
if
tmp
:
if
tmp
:
continue
continue
model
=
DrawRecord
()
model
=
DrawRecord
()
model
.
user_id
=
g
.
user
.
id
model
.
user_id
=
g
.
user
.
id
model
.
user_no
=
g
.
user
.
user_no
model
.
user_no
=
g
.
user
.
user_no
model
.
business_id
=
result
[
"business_id"
]
model
.
bill_date
=
result
[
"bill_date"
]
model
.
draw_month
=
result
[
"rent_month"
]
model
.
real_total
=
int
(
result
[
"real_total"
])
model
.
total
=
result
[
"total"
]
model
.
real_total
=
result
[
"total"
]
*
result
[
"rate"
]
/
100
model
.
rate
=
result
[
"rate"
]
model
.
status
=
0
model
.
status
=
0
model
.
draw_no
=
RentService
.
create_order_no
(
prefix
=
"DR"
)
model
.
draw_no
=
RentService
.
create_order_no
(
prefix
=
"DR"
)
db
.
session
.
add
(
model
)
db
.
session
.
add
(
model
)
...
@@ -429,7 +558,7 @@ def run_draw_list():
...
@@ -429,7 +558,7 @@ def run_draw_list():
select_sql
=
"""
select_sql
=
"""
select draw_record.draw_no,
select draw_record.draw_no,
draw_record.business_id,
draw_record.business_id,
draw_record.
draw_month
,
draw_record.
bill_date
,
draw_record.total,
draw_record.total,
draw_record.real_total,
draw_record.real_total,
draw_record.rate,
draw_record.rate,
...
@@ -452,9 +581,9 @@ def run_draw_list():
...
@@ -452,9 +581,9 @@ def run_draw_list():
where_sql
=
" WHERE draw_record.status <> '-1' "
where_sql
=
" WHERE draw_record.status <> '-1' "
if
start_date
is
not
None
:
if
start_date
is
not
None
:
where_sql
+=
" and draw_record.
draw_month
> '{}'"
.
format
(
start_date
)
where_sql
+=
" and draw_record.
bill_date
> '{}'"
.
format
(
start_date
)
if
end_date
is
not
None
:
if
end_date
is
not
None
:
where_sql
+=
" and draw_record.
draw_month
<= '{}'"
.
format
(
end_date
)
where_sql
+=
" and draw_record.
bill_date
<= '{}'"
.
format
(
end_date
)
if
status
is
not
None
:
if
status
is
not
None
:
where_sql
+=
" and draw_record.status = '{}'"
.
format
(
status
)
where_sql
+=
" and draw_record.status = '{}'"
.
format
(
status
)
...
@@ -483,7 +612,7 @@ def run_draw_list():
...
@@ -483,7 +612,7 @@ def run_draw_list():
if
result
:
if
result
:
for
info
in
result
:
for
info
in
result
:
tmp
=
{
tmp
=
{
"business_id"
:
info
.
business_id
,
"
draw_month"
:
info
.
draw_month
,
"total"
:
info
.
total
,
"business_id"
:
info
.
business_id
,
"
bill_date"
:
info
.
bill_date
,
"total"
:
info
.
total
,
"real_total"
:
info
.
real_total
,
"rate"
:
info
.
rate
,
"status"
:
info
.
status
,
"real_total"
:
info
.
real_total
,
"rate"
:
info
.
rate
,
"status"
:
info
.
status
,
"business_name"
:
info
.
business_name
,
"id"
:
info
.
id
,
"business_name"
:
info
.
business_name
,
"id"
:
info
.
id
,
"create_time"
:
info
.
created_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"create_time"
:
info
.
created_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
...
@@ -532,7 +661,7 @@ def run_approve_draw():
...
@@ -532,7 +661,7 @@ def run_approve_draw():
"user_id"
:
open_id
,
"user_id"
:
open_id
,
"amount"
:
draw_money
,
"amount"
:
draw_money
,
"out_trade_no"
:
RentService
.
create_order_no
(
prefix
=
"DR"
),
"out_trade_no"
:
RentService
.
create_order_no
(
prefix
=
"DR"
),
"desc"
:
draw_record
.
draw_month
+
"月份
个人提现"
,
"desc"
:
draw_record
.
bill_date
+
"
个人提现"
,
"real_name"
:
real_name
"real_name"
:
real_name
}
}
result
=
WeChatPayService
(
app_id
=
platform_appid_config_list
[
2
],
result
=
WeChatPayService
(
app_id
=
platform_appid_config_list
[
2
],
...
@@ -550,7 +679,6 @@ def run_approve_draw():
...
@@ -550,7 +679,6 @@ def run_approve_draw():
dd
.
draw_no
=
result
[
"partner_trade_no"
]
dd
.
draw_no
=
result
[
"partner_trade_no"
]
dd
.
payment_no
=
result
[
"payment_no"
]
dd
.
payment_no
=
result
[
"payment_no"
]
dd
.
payment_time
=
result
[
"payment_time"
]
dd
.
payment_time
=
result
[
"payment_time"
]
dd
.
business_id
=
draw_record
.
business_id
dd
.
draw_month
=
draw_record
.
draw_month
dd
.
draw_month
=
draw_record
.
draw_month
dd
.
total
=
draw_record
.
real_total
dd
.
total
=
draw_record
.
real_total
dd
.
real_total
=
draw_money
dd
.
real_total
=
draw_money
...
...
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