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
ffec9a5d
Commit
ffec9a5d
authored
Jul 06, 2023
by
xianyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
充值报表增加字段,用户和公会提现增加导出功能
parent
db9598e3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
13 deletions
+95
-13
crud.py
app/api/statement/crud.py
+33
-0
views.py
app/api/statement/views.py
+46
-1
export.py
libs/export.py
+16
-12
No files found.
app/api/statement/crud.py
View file @
ffec9a5d
...
...
@@ -12,6 +12,7 @@ from starlette.responses import StreamingResponse
from
sqlalchemy.orm
import
Session
from
app.api.export
import
crud
from
core.config.env
import
env
from
libs
import
functions
from
libs.db_link
import
LinkMysql
from
libs.functions
import
time_str_to_timestamp
,
timestamp_to_time_str
,
get_month_last_month
,
get_date_list
from
libs.log_utils
import
Logger
...
...
@@ -614,3 +615,35 @@ def get_menu_config(db: Session, menu_type):
Menuconfig
.
id
.
desc
())
data
=
[
QueryAllData
.
serialization
(
item
,
remove
=
{
'create_time'
,
'remark'
})
for
item
in
querydata
]
return
data
def
user_data_handle
(
data
):
"""用户提现数据处理"""
for_mat
=
[]
for
i
in
data
:
ting
=
{}
ting
[
'reference_number'
]
=
i
.
get
(
'reference_number'
)
ting
[
'money'
]
=
i
.
get
(
'money'
)
ting
[
'reference_type'
]
=
i
.
get
(
'reference_type'
)
ting
[
'uuid'
]
=
i
.
get
(
'uuid'
)
ting
[
'amount_type'
]
=
i
.
get
(
'amount_type'
)
ting
[
'payment_time'
]
=
i
.
get
(
'payment_time'
)
for_mat
.
append
(
ting
)
return
for_mat
def
guild_data_handle
(
data
):
"""公会提现数据处理"""
guild_mat
=
[]
for
i
in
data
:
mat
=
{}
w_time
=
functions
.
timestamp_to_time_str
(
i
.
get
(
'withdrawal_time'
))
mat
[
'withdrawal_time'
]
=
w_time
if
w_time
else
''
mat
[
'payment_time'
]
=
i
.
get
(
'payment_time'
)
mat
[
'guild_id'
]
=
i
.
get
(
'guild_id'
)
mat
[
'guild_name'
]
=
i
.
get
(
'guild_name'
)
mat
[
'money'
]
=
i
.
get
(
'money'
)
mat
[
'dec_money'
]
=
i
.
get
(
'dec_money'
)
mat
[
'finalMoney'
]
=
i
.
get
(
'finalMoney'
)
guild_mat
.
append
(
mat
)
return
guild_mat
app/api/statement/views.py
View file @
ffec9a5d
...
...
@@ -274,3 +274,48 @@ def guild_modify(db: Session = Depends(get_db)):
"""公会结算同步"""
code
,
data
=
GuildSettlementmodify
(
db
)
return
HttpResultResponse
(
code
=
code
,
msg
=
HttpMessage
.
SUCCESS
)
@
router
.
get
(
"/userWithdrawal/excel"
)
def
user_withdrawal_excel
(
request
:
Request
,
db
:
Session
=
Depends
(
get_db
),
page
:
Optional
[
int
]
=
1
,
size
:
Optional
[
int
]
=
9999999
,
uuid
:
Optional
[
str
]
=
''
,
status
:
Optional
[
int
]
=
''
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
token
=
Depends
(
login_required
)):
"""用户提现列表导出"""
query_params
=
request
.
query_params
menu_id
=
query_params
.
getlist
(
"menu_id[]"
)
header_list
=
request
.
get
(
"headers"
)
to
,
statement_list
,
mo
,
re
=
WithdrawStatement
()
.
get_user_withdraw_cash
(
db
,
page
,
size
,
uuid
,
status
,
start_time
,
end_time
,
month_type
,
menu_id
)
field_list
=
[
"订单号"
,
"提现金额"
,
"业务类型"
,
"uuid"
,
"账户类型"
,
"提现时间"
]
res_data
=
crud
.
user_data_handle
(
statement_list
)
url
=
TableToFile
(
db
,
res_data
,
"用户提现"
,
header_list
,
field_list
)
.
main_method
()
return
HttpResultResponse
(
data
=
url
)
@
router
.
get
(
"/guildWithdrawal/excel"
)
def
guild_withdrawal_excel
(
request
:
Request
,
db
:
Session
=
Depends
(
get_db
),
page
:
Optional
[
int
]
=
1
,
size
:
Optional
[
int
]
=
9999999
,
guild_id
:
Optional
[
int
]
=
''
,
status
:
Optional
[
int
]
=
''
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
token
=
Depends
(
login_required
)):
"""公会提现导出"""
query_params
=
request
.
query_params
menu_id
=
query_params
.
getlist
(
"menu_id[]"
)
header_list
=
request
.
get
(
"headers"
)
res
=
WithdrawStatement
()
.
get_guild_withdraw_cash
(
db
,
page
,
size
,
guild_id
,
status
,
start_time
,
end_time
,
month_type
,
menu_id
)
field_list
=
[
"提现时间"
,
"处理时间"
,
"公会ID"
,
"公会名称"
,
"提现金额"
,
"扣除金额"
,
"实际到账金额"
]
res_data
=
crud
.
guild_data_handle
(
res
[
1
])
url
=
TableToFile
(
db
,
res_data
,
"公会提现"
,
header_list
,
field_list
)
.
main_method
()
return
HttpResultResponse
(
data
=
url
)
libs/export.py
View file @
ffec9a5d
...
...
@@ -258,6 +258,9 @@ class TableToFile(object):
write_data
=
bk
.
to_dict
(
orient
=
'records'
)
with
pd
.
ExcelWriter
(
f
'static/{self.name}.xlsx'
)
as
writer
:
# bk.to_excel(writer, sheet_name='Sheet1', index=False)
if
len
(
self
.
data
)
<
500
:
bk
.
to_excel
(
writer
,
sheet_name
=
'sheet'
,
index
=
False
)
else
:
threads
=
[]
rows_per_thread
=
math
.
ceil
(
len
(
write_data
)
/
5
)
for
i
in
range
(
5
):
...
...
@@ -278,5 +281,6 @@ class TableToFile(object):
Logger
()
.
logger
.
info
(
f
'导出异常:{str(e)}'
)
params
[
"status"
]
=
2
crud
.
create_export_data
(
self
.
db
,
params
,
user
)
return
None
return
f
"https://{env.TX_BUCKET}.cos.ap-guangzhou.myqcloud.com/finance/{self.name}.xlsx"
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