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
022014ed
Commit
022014ed
authored
Apr 04, 2023
by
xupeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增财务类型
parent
acd77a5f
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
208 additions
and
38 deletions
+208
-38
financial-system.iml
.idea/financial-system.iml
+1
-1
schemas.py
app/api/account/schemas.py
+2
-0
crud.py
app/api/statement/crud.py
+104
-19
schemas.py
app/api/statement/schemas.py
+16
-0
views.py
app/api/statement/views.py
+54
-9
login_verification.py
app/api/users/login_verification.py
+1
-1
orm.py
libs/orm.py
+1
-0
result_format.py
libs/result_format.py
+2
-1
token_verify.py
libs/token_verify.py
+7
-4
main.py
main.py
+2
-2
__init__.py
models/__init__.py
+2
-1
menuconfig.py
models/menuconfig.py
+16
-0
No files found.
.idea/financial-system.iml
View file @
022014ed
...
...
@@ -6,7 +6,7 @@
<excludeFolder
url=
"file://$MODULE_DIR$/fs-env"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/venv"
/>
</content>
<orderEntry
type=
"jdk"
jdkName=
"Python 3.8 (financial
-
system)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"jdk"
jdkName=
"Python 3.8 (financial
_
system)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
<component
name=
"PyDocumentationSettings"
>
...
...
app/api/account/schemas.py
View file @
022014ed
...
...
@@ -91,3 +91,5 @@ class RecoveryTable(BaseModel):
class
RecoveryupdateTable
(
RecoveryTable
):
id
:
int
app/api/statement/crud.py
View file @
022014ed
This diff is collapsed.
Click to expand it.
app/api/statement/schemas.py
View file @
022014ed
...
...
@@ -131,3 +131,19 @@ class CreateBill(BaseModel):
# if not v:
# raise ValueError('缺少必传参数remark')
# return v
class
MenuAdd
(
BaseModel
):
menu_name
:
str
menu_label
:
str
menu_type
:
int
remark
:
Optional
[
str
]
=
None
class
MenuEdit
(
BaseModel
):
id
:
str
menu_name
:
str
menu_label
:
str
menu_type
:
int
remark
:
Optional
[
str
]
=
None
app/api/statement/views.py
View file @
022014ed
...
...
@@ -7,12 +7,12 @@ from app.api.account import schemas as acc_schemas
from
app
import
get_db
from
fastapi
import
Depends
,
APIRouter
,
File
,
Request
from
sqlalchemy.orm
import
Session
from
app.api.statement.crud
import
RechargeStatement
,
WithdrawStatement
from
app.api.statement.crud
import
RechargeStatement
,
WithdrawStatement
,
get_menu_list
,
get_menu_config
from
app.api.statement.guild
import
GuildSet
,
paymentset_guild_data
,
outon_account_data
,
accout_list_data
,
\
query_uuid_or_user_number
,
account_money
,
transfer_money
,
transfer_query
from
app.api.statement.schemas
import
PaymentWithdrawalList
,
PaymentAdd
,
PaymentAccountlList
,
UserNumber
,
CreateBill
from
libs.img_code
import
new_upload_file
,
random_number
from
libs.result_format
import
HttpResultResponse
from
libs.result_format
import
HttpResultResponse
,
HttpMessage
from
libs.token_verify
import
login_required
from
models.recharge
import
Fitransferlog
from
models.account
import
Account
...
...
@@ -21,9 +21,9 @@ router = APIRouter()
@
router
.
get
(
"/recharge/list"
)
def
statement_recharge_list
(
page
:
Optional
[
int
]
=
0
,
size
:
Optional
[
int
]
=
10
,
order_number
:
Optional
[
str
]
=
""
,
uuid
:
Optional
[
int
]
=
""
,
sid
:
Optional
[
str
]
=
""
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
types
:
Optional
[
str
]
=
""
,
reference_type
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
token
=
Depends
(
login_required
)
):
def
statement_recharge_list
(
db
:
Session
=
Depends
(
get_db
),
page
:
Optional
[
int
]
=
1
,
size
:
Optional
[
int
]
=
10
,
order_number
:
Optional
[
str
]
=
""
,
uuid
:
Optional
[
str
]
=
""
,
sid
:
Optional
[
str
]
=
""
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
types
:
Optional
[
str
]
=
""
,
menu_id
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
):
"""充值报表列表"""
total
,
statement_list
,
money
=
RechargeStatement
()
.
query_data
(
page
,
size
,
order_number
,
uuid
,
sid
,
start_time
,
end_time
,
types
,
reference_type
,
month_type
)
total
,
statement_list
,
money
=
RechargeStatement
()
.
query_data
(
db
,
page
,
size
,
order_number
,
uuid
,
sid
,
start_time
,
end_time
,
types
,
menu_id
,
month_type
)
return
HttpResultResponse
(
total
=
total
,
count
=
float
(
money
),
data
=
statement_list
)
...
...
@@ -36,21 +36,21 @@ def statement_derive_excel(data: schemas.StatementList, request: Request, db: Se
@
router
.
get
(
"/userWithdrawal/list"
)
def
user_withdrawal_list
(
page
:
Optional
[
int
]
=
0
,
size
:
Optional
[
int
]
=
10
,
uuid
:
Optional
[
int
]
=
''
,
status
:
Optional
[
int
]
=
''
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
token
=
Depends
(
login_required
)):
def
user_withdrawal_list
(
db
:
Session
=
Depends
(
get_db
),
page
:
Optional
[
int
]
=
1
,
size
:
Optional
[
int
]
=
10
,
uuid
:
Optional
[
str
]
=
''
,
status
:
Optional
[
int
]
=
''
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
menu_id
:
Optional
[
str
]
=
""
,
token
=
Depends
(
login_required
)):
"""用户提现列表"""
total
,
statement_list
,
money
=
WithdrawStatement
()
.
get_user_withdraw_cash
(
page
,
size
,
uuid
,
status
,
start_time
,
end_time
,
month_type
)
total
,
statement_list
,
money
=
WithdrawStatement
()
.
get_user_withdraw_cash
(
db
,
page
,
size
,
uuid
,
status
,
start_time
,
end_time
,
month_type
,
menu_id
)
return
HttpResultResponse
(
total
=
total
,
count
=
float
(
money
),
data
=
statement_list
)
@
router
.
get
(
"/guildWithdrawal/list"
)
def
guild_withdrawal_list
(
page
:
Optional
[
int
]
=
0
,
size
:
Optional
[
int
]
=
10
,
guild_id
:
Optional
[
int
]
=
''
,
status
:
Optional
[
int
]
=
''
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
token
=
Depends
(
login_required
)):
def
guild_withdrawal_list
(
db
:
Session
=
Depends
(
get_db
),
page
:
Optional
[
int
]
=
1
,
size
:
Optional
[
int
]
=
10
,
guild_id
:
Optional
[
int
]
=
''
,
status
:
Optional
[
int
]
=
''
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
month_type
:
Optional
[
int
]
=
""
,
menu_id
:
Optional
[
str
]
=
""
,
token
=
Depends
(
login_required
)):
"""公会提现列表 暂无"""
total
,
statement_list
,
money
=
WithdrawStatement
()
.
get_guild_withdraw_cash
(
page
,
size
,
guild_id
,
status
,
start_time
,
end_time
,
month_type
)
total
,
statement_list
,
money
=
WithdrawStatement
()
.
get_guild_withdraw_cash
(
db
,
page
,
size
,
guild_id
,
status
,
start_time
,
end_time
,
month_type
,
menu_id
)
return
HttpResultResponse
(
total
=
total
,
count
=
float
(
money
),
data
=
statement_list
)
@
router
.
get
(
"/guild/settlement"
)
def
guild_settlement_list
(
page
:
Optional
[
int
]
=
0
,
size
:
Optional
[
int
]
=
10
,
status
:
Optional
[
int
]
=
''
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
guild_id
:
Optional
[
str
]
=
""
,
token
=
Depends
(
login_required
)):
def
guild_settlement_list
(
page
:
Optional
[
int
]
=
1
,
size
:
Optional
[
int
]
=
10
,
status
:
Optional
[
int
]
=
''
,
start_time
:
Optional
[
str
]
=
''
,
end_time
:
Optional
[
str
]
=
""
,
guild_id
:
Optional
[
str
]
=
""
,
token
=
Depends
(
login_required
)):
"""公会结算"""
guild_list
,
total
=
GuildSet
()
.
get_guild_data
(
page
,
size
,
status
,
start_time
,
end_time
,
guild_id
)
return
HttpResultResponse
(
total
=
total
,
data
=
guild_list
)
...
...
@@ -188,3 +188,48 @@ def recovery_fix(data: acc_schemas.RecoveryupdateTable, token=Depends(login_requ
if
res
:
return
HttpResultResponse
(
code
=
500
,
msg
=
res
)
return
HttpResultResponse
()
@
router
.
post
(
"/menu/add"
)
def
menu_add
(
data
:
schemas
.
MenuAdd
,
db
:
Session
=
Depends
(
get_db
),
token
=
Depends
(
login_required
)):
"""新增财务菜单配置"""
db_user
=
crud
.
get_menu_name
(
db
,
menu_name
=
data
.
menu_name
)
if
db_user
:
return
HttpResultResponse
(
code
=
400
,
msg
=
HttpMessage
.
TYPE_NAME
)
res
=
crud
.
create_menu
(
db
=
db
,
menu
=
data
)
if
not
res
:
return
HttpResultResponse
(
code
=
500
,
msg
=
HttpMessage
.
LOSE
)
return
HttpResultResponse
(
data
=
res
.
id
)
@
router
.
get
(
"/menu/list"
)
def
menu_list
(
db
:
Session
=
Depends
(
get_db
),
page
:
Optional
[
int
]
=
1
,
size
:
Optional
[
int
]
=
10
,
menu_name
:
Optional
[
str
]
=
""
,
menu_type
:
Optional
[
int
]
=
""
,
menu_label
:
Optional
[
str
]
=
""
,
token
=
Depends
(
login_required
)):
"""菜单配置列表"""
menu_list
,
total
=
get_menu_list
(
db
,
page
,
size
,
menu_name
,
menu_label
,
menu_type
)
return
HttpResultResponse
(
total
=
total
,
data
=
menu_list
)
@
router
.
post
(
"/menu/edit"
)
def
menu_edit
(
data
:
schemas
.
MenuEdit
,
db
:
Session
=
Depends
(
get_db
),
page
:
Optional
[
int
]
=
1
,
size
:
Optional
[
int
]
=
10
,
menu_name
:
Optional
[
str
]
=
""
,
menu_type
:
Optional
[
int
]
=
""
,
menu_label
:
Optional
[
str
]
=
""
,
token
=
Depends
(
login_required
)):
"""修改配置列表"""
db_menu
=
crud
.
get_menu_id
(
db
,
id
=
data
.
id
)
if
db_menu
:
db_menu
=
crud
.
get_menu_update
(
db
,
data
)
else
:
return
HttpResultResponse
(
code
=
400
,
msg
=
HttpMessage
.
MENU_NOT_EXIST
)
return
HttpResultResponse
(
data
=
db_menu
)
@
router
.
delete
(
"/menu/delete"
)
def
menu_delte
(
id
:
Optional
[
int
]
=
''
,
db
:
Session
=
Depends
(
get_db
),
page
:
Optional
[
int
]
=
1
,
size
:
Optional
[
int
]
=
10
,
menu_name
:
Optional
[
str
]
=
""
,
menu_type
:
Optional
[
int
]
=
""
,
menu_label
:
Optional
[
str
]
=
""
,
token
=
Depends
(
login_required
)):
"""删除菜单配置"""
crud
.
get_menu_delete
(
db
,
id
)
return
HttpResultResponse
(
code
=
200
,
msg
=
HttpMessage
.
SUCCESS
)
@
router
.
get
(
"/menu/config"
)
def
menu_list
(
db
:
Session
=
Depends
(
get_db
),
menu_type
:
Optional
[
int
]
=
""
):
"""菜单配置下拉"""
menu_list
=
get_menu_config
(
db
,
menu_type
)
return
HttpResultResponse
(
data
=
menu_list
)
\ No newline at end of file
app/api/users/login_verification.py
View file @
022014ed
...
...
@@ -34,7 +34,7 @@ def create_access_token(data: dict, expires_delta: Optional[timedelta] = None):
expire
=
datetime
.
utcnow
()
+
expires_delta
else
:
# 否则的话,就默认用15分钟
expire
=
datetime
.
utcnow
()
+
timedelta
(
minutes
=
60
)
expire
=
datetime
.
utcnow
()
+
timedelta
(
minutes
=
15
)
to_encode
.
update
({
'exp'
:
expire
})
# 编码,至此 JWT tokens诞生
encoded_jwt
=
jwt
.
encode
(
to_encode
,
env
.
SECRET_KEY
,
algorithm
=
env
.
ALGORITHM
)
...
...
libs/orm.py
View file @
022014ed
...
...
@@ -59,6 +59,7 @@ class QueryAllData:
self
.
db
.
session
.
commit
()
return
self
def
direct_update_
(
self
):
"""直接更新"""
self
.
db
.
session
.
commit
()
...
...
libs/result_format.py
View file @
022014ed
...
...
@@ -10,6 +10,7 @@ class HttpMessage(object):
SUCCESS
=
"操作成功"
USER_EXIST
=
"用户已存在"
USER_NOT_EXIST
=
"用户不存在"
MENU_NOT_EXIST
=
"菜单不存在"
LOGIN_SUCCESS
=
"登录成功"
ROLE_EXIST
=
"角色已存在"
...
...
@@ -17,6 +18,7 @@ class HttpMessage(object):
ACCOUNT_EXIST
=
"账号已存在"
TYPE_EXIST
=
"类目标识已存在"
TYPE_NAME
=
'类型已存在'
DELETE_LOSE
=
'删除失败'
LOSE
=
'操作失败'
...
...
@@ -39,7 +41,6 @@ class HttpResultResponse(Response):
'msg'
:
msg
if
msg
else
HttpMessage
.
SUCCESS
,
}
result_dict
=
{
**
result_dict
,
**
kwargs
}
print
(
result_dict
)
super
()
.
__init__
(
content
=
json
.
dumps
(
result_dict
,
cls
=
DecimalEncoder
),
media_type
=
"application/json"
,
...
...
libs/token_verify.py
View file @
022014ed
import
datetime
import
json
import
time
from
asyncio.log
import
logger
from
jose.exceptions
import
JWEError
,
ExpiredSignatureError
from
sqlalchemy.orm
import
Session
from
fastapi
import
Depends
,
HTTPException
,
status
from
fastapi
import
Depends
,
HTTPException
,
status
,
FastAPI
from
fastapi.security
import
OAuth2PasswordBearer
from
jose
import
jwt
,
JWTError
from
werkzeug
import
Request
from
app
import
get_db
from
app.api.role.crud
import
get_id_to_authority
from
app.api.users
import
crud
from
app.api.users.login_verification
import
get_user
from
app.api.users.login_verification
import
get_user
,
create_access_token
from
core.config.env
import
env
from
libs.functions
import
md5
...
...
@@ -35,6 +38,8 @@ def auth_token(token: str = Depends(oauth2_scheme)):
return
''
def
get_current_user
(
db
:
Session
,
token
:
str
=
Depends
(
oauth2_scheme
)):
"""
获取当前用户信息,实际上是一个解密token的过程
...
...
@@ -76,8 +81,6 @@ def judgeToken(token):
user_data
=
get_user
(
db
,
username
=
payload
.
get
(
"username"
))
old_password
=
md5
(
payload
[
"password"
])
if
old_password
==
user_data
.
hashed_password
:
print
(
md5
(
payload
[
"password"
]))
print
(
user_data
.
hashed_password
)
return
True
else
:
print
(
"token 身份错误"
)
...
...
main.py
View file @
022014ed
...
...
@@ -28,13 +28,13 @@ app.add_middleware(
@
app
.
middleware
(
"http"
)
async
def
add_process_time_header
(
request
:
Request
,
call_next
):
hs
=
request
.
headers
token
=
hs
.
get
(
"authorization"
)
.
replace
(
'Bearer'
,
''
)
.
replace
(
' '
,
''
)
token
=
hs
.
get
(
"authorization"
)
start_time
=
time
.
time
()
response
=
await
call_next
(
request
)
process_time
=
time
.
time
()
-
start_time
response
.
headers
[
"X-Process-Time"
]
=
str
(
process_time
)
if
token
:
payload
=
jwt
.
decode
(
token
,
env
.
SECRET_KEY
,
algorithms
=
[
env
.
ALGORITHM
])
payload
=
jwt
.
decode
(
token
.
replace
(
'Bearer'
,
''
)
.
replace
(
' '
,
''
)
,
env
.
SECRET_KEY
,
algorithms
=
[
env
.
ALGORITHM
])
timestamp
=
payload
.
get
(
"exp"
)
access_token_expires
=
timedelta
(
hours
=
time_format
(
timestamp
))
create_access_token
({
'username'
:
payload
.
get
(
"xup"
),
'password'
:
payload
.
get
(
"password"
)},
expires_delta
=
access_token_expires
)
#更新token时间
...
...
models/__init__.py
View file @
022014ed
from
core.storage.db
import
engine
from
models
import
users
,
roles
,
recharge
,
account
,
margin
,
guild
,
export
from
models
import
users
,
roles
,
recharge
,
account
,
margin
,
guild
,
export
,
menuconfig
# 映射模型表
users
.
Base
.
metadata
.
create_all
(
bind
=
engine
)
...
...
@@ -9,3 +9,4 @@ account.Base.metadata.create_all(bind=engine)
margin
.
Base
.
metadata
.
create_all
(
bind
=
engine
)
guild
.
Base
.
metadata
.
create_all
(
bind
=
engine
)
export
.
Base
.
metadata
.
create_all
(
bind
=
engine
)
menuconfig
.
Base
.
metadata
.
create_all
(
bind
=
engine
)
models/menuconfig.py
0 → 100644
View file @
022014ed
from
sqlalchemy
import
Column
,
Integer
,
String
,
DateTime
,
Text
from
core.storage.db
import
Base
from
sqlalchemy_serializer
import
SerializerMixin
class
Menuconfig
(
Base
,
SerializerMixin
):
__tablename__
=
"menuconfig"
id
=
Column
(
Integer
,
primary_key
=
True
,
index
=
True
)
menu_name
=
Column
(
String
(
100
),
unique
=
True
,
index
=
True
,
comment
=
"菜单类型名"
)
menu_label
=
Column
(
String
(
100
),
unique
=
True
,
index
=
True
,
comment
=
"菜单类型别名"
)
menu_type
=
Column
(
Integer
,
comment
=
"1是充值 2是消费"
)
remark
=
Column
(
Text
,
comment
=
"备注"
)
create_time
=
Column
(
DateTime
,
comment
=
"创建时间"
)
__table_args__
=
{
'comment'
:
'财务菜单配置表'
}
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