Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
financial-system
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xianyang
financial-system
Commits
a2b3e008
Commit
a2b3e008
authored
Apr 06, 2023
by
xianyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
账户增加用户,背包,公会第四层查询
parent
dd1f2011
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
7 deletions
+58
-7
crud.py
app/api/account/crud.py
+50
-0
views.py
app/api/account/views.py
+8
-6
views.py
app/api/statement/views.py
+0
-1
No files found.
app/api/account/crud.py
View file @
a2b3e008
...
@@ -355,3 +355,53 @@ class AccountStatistics(object):
...
@@ -355,3 +355,53 @@ class AccountStatistics(object):
return
res
,
total
,
float
(
amount_total
)
return
res
,
total
,
float
(
amount_total
)
else
:
else
:
return
res
return
res
class
SpecificAccountQuery
(
object
):
"""账户用户,背包,公会第四层查询"""
def
__init__
(
self
,
page
,
size
,
uuid
,
start_time
,
end_time
,
type
,
reference_type
):
self
.
page
=
page
self
.
size
=
size
self
.
uuid
=
uuid
self
.
start_time
=
start_time
self
.
end_time
=
end_time
self
.
type
=
type
self
.
reference_type
=
reference_type
self
.
total_list
=
[]
def
condition_query
(
self
,
date
,
cond_list
):
sql
=
f
"select uuid,type,cast(amount as decimal(20,6))/1000 as amount,reference_type,create_time,amount_type from {date} WHERE {' and '.join(cond_list)} ORDER BY create_time DESC"
result
=
LinkMysql
(
env
.
DB_HISTORY
)
.
query_mysql
(
sql
)
return
result
def
business_logic
(
self
):
condition
=
[]
condition
.
append
(
f
" uuid='{self.uuid}'"
)
condition
.
append
(
f
" create_time >= {time_str_to_timestamp(self.start_time + ' 00:00:00')}"
)
end_time
=
time_str_to_timestamp
(
self
.
end_time
+
' 00:00:00'
)
+
86400
# 结束时间那天包含在内,固小于第二天凌晨
condition
.
append
(
f
" create_time < {end_time}"
)
month
,
last_month
,
before_last_month
=
get_last_month
()
with
ThreadPoolExecutor
(
max_workers
=
3
)
as
pool
:
future1
=
pool
.
submit
(
self
.
condition_query
,
'assets_log_'
+
month
,
condition
)
future2
=
pool
.
submit
(
self
.
condition_query
,
'assets_log_'
+
last_month
,
condition
)
future3
=
pool
.
submit
(
self
.
condition_query
,
'assets_log_'
+
before_last_month
,
condition
)
month_data
=
future1
.
result
()
last_data
=
future2
.
result
()
before_last_data
=
future3
.
result
()
if
month_data
:
self
.
total_list
=
self
.
total_list
+
month_data
if
month_data
[
0
][
'uuid'
]
else
self
.
total_list
if
last_data
:
self
.
total_list
=
self
.
total_list
+
last_data
if
last_data
[
0
][
'uuid'
]
else
self
.
total_list
if
before_last_data
:
self
.
total_list
=
self
.
total_list
+
before_last_data
if
before_last_data
[
0
][
'uuid'
]
else
self
.
total_list
total
=
len
(
self
.
total_list
)
res
=
self
.
total_list
[
int
(
self
.
page
-
1
)
*
self
.
size
:
self
.
page
*
self
.
size
]
if
not
res
:
return
[],
0
,
0
for
i
in
res
:
i
[
'reference_name'
]
=
TYPE_NAME
[
i
[
'reference_type'
]]
if
TYPE_NAME
.
get
(
i
[
'reference_type'
])
else
i
[
'reference_type'
]
data_pd
=
pd
.
DataFrame
(
self
.
total_list
)
amount_total
=
data_pd
[
'amount'
]
.
sum
()
return
res
,
total
,
float
(
amount_total
)
app/api/account/views.py
View file @
a2b3e008
...
@@ -3,7 +3,7 @@ from fastapi import Depends, APIRouter, Request, Query
...
@@ -3,7 +3,7 @@ from fastapi import Depends, APIRouter, Request, Query
from
sqlalchemy.orm
import
Session
from
sqlalchemy.orm
import
Session
from
app
import
get_db
from
app
import
get_db
from
app.api.account
import
schemas
,
crud
from
app.api.account
import
schemas
,
crud
from
app.api.account.crud
import
AccountStatistics
from
app.api.account.crud
import
AccountStatistics
,
SpecificAccountQuery
from
app.api.statement
import
crud
as
statement_crud
from
app.api.statement
import
crud
as
statement_crud
from
libs.result_format
import
HttpResultResponse
,
HttpMessage
from
libs.result_format
import
HttpResultResponse
,
HttpMessage
from
libs.token_verify
import
login_required
from
libs.token_verify
import
login_required
...
@@ -106,12 +106,14 @@ def finance_fourth_info(page: int,
...
@@ -106,12 +106,14 @@ def finance_fourth_info(page: int,
start_time
:
Optional
[
str
]
=
""
,
start_time
:
Optional
[
str
]
=
""
,
end_time
:
Optional
[
str
]
=
""
,
end_time
:
Optional
[
str
]
=
""
,
type
:
Optional
[
int
]
=
None
,
type
:
Optional
[
int
]
=
None
,
amount
_type
:
Optional
[
str
]
=
""
,
reference
_type
:
Optional
[
str
]
=
""
,
token
=
Depends
(
login_required
)):
token
=
Depends
(
login_required
)):
"""账户财务明细第四层"""
"""账户财务明细 第四层"""
# res, total, count = AccountStatistics.get_finance_details(page, size, uuid, start_time, end_time, type,
if
not
all
([
uuid
,
start_time
,
end_time
]):
# amount_type, l)
return
HttpResultResponse
(
code
=
500
,
msg
=
"缺少必传参数"
)
# return HttpResultResponse(total=total, data=res, count=count)
res
,
total
,
count
=
SpecificAccountQuery
(
page
,
size
,
uuid
,
start_time
,
end_time
,
type
,
reference_type
)
.
business_logic
()
return
HttpResultResponse
(
total
=
total
,
data
=
res
,
count
=
count
)
@
router
.
get
(
"/type"
)
@
router
.
get
(
"/type"
)
...
...
app/api/statement/views.py
View file @
a2b3e008
...
@@ -242,7 +242,6 @@ def menu_delte(id: Optional[int] = '',db: Session = Depends(get_db),page: Option
...
@@ -242,7 +242,6 @@ def menu_delte(id: Optional[int] = '',db: Session = Depends(get_db),page: Option
return
HttpResultResponse
(
code
=
200
,
msg
=
HttpMessage
.
SUCCESS
)
return
HttpResultResponse
(
code
=
200
,
msg
=
HttpMessage
.
SUCCESS
)
@
router
.
get
(
"/menu/config"
)
@
router
.
get
(
"/menu/config"
)
def
menu_list
(
db
:
Session
=
Depends
(
get_db
),
menu_type
:
Optional
[
int
]
=
""
):
def
menu_list
(
db
:
Session
=
Depends
(
get_db
),
menu_type
:
Optional
[
int
]
=
""
):
"""菜单配置下拉"""
"""菜单配置下拉"""
...
...
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