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
4fe1640e
Commit
4fe1640e
authored
Feb 24, 2023
by
xianyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
公会保证金接口
parent
0327d8ed
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
11 deletions
+100
-11
crud.py
app/api/account/crud.py
+38
-5
schemas.py
app/api/account/schemas.py
+16
-0
views.py
app/api/account/views.py
+12
-5
account.py
models/account.py
+34
-1
No files found.
app/api/account/crud.py
View file @
4fe1640e
from
datetime
import
datetime
from
datetime
import
datetime
from
fastapi
import
HTTPException
,
status
from
sqlalchemy
import
and_
from
sqlalchemy.orm
import
Session
from
sqlalchemy.orm
import
Session
from
app.api.account
import
schemas
from
app.api.account
import
schemas
from
libs.functions
import
wrapper_out
from
libs.functions
import
wrapper_out
from
models
import
account
as
models
from
models
import
account
as
models
from
models.account
import
AccountFinance
,
AccountFinanceDetails
def
get_account
(
db
:
Session
,
name
:
str
):
def
get_account
(
db
:
Session
,
name
:
str
):
...
@@ -92,7 +94,38 @@ def update_account_info(db: Session, old_data):
...
@@ -92,7 +94,38 @@ def update_account_info(db: Session, old_data):
db
.
commit
()
db
.
commit
()
def
get_finance_info
(
db
:
Session
,
role_id
:
int
):
def
get_finance_info
(
db
,
data
):
"""账户财务信息"""
db
.
query
(
models
.
Account
)
.
filter
(
models
.
Account
.
id
==
role_id
)
.
delete
()
finance_condition
=
[]
return
True
finance_condition
.
append
(
AccountFinance
.
account_id
==
data
.
aid
)
if
data
.
start_time
:
finance_condition
.
append
(
AccountFinance
.
create_time
>=
data
.
start_time
)
if
data
.
end_time
:
finance_condition
.
append
(
AccountFinance
.
create_time
<=
data
.
end_time
)
if
not
finance_condition
:
query_res
=
db
.
query
(
AccountFinance
)
.
all
()
return
[
i
.
to_dict
()
for
i
in
query_res
][::
-
1
]
else
:
get_user_orm_sql
=
db
.
query
(
AccountFinance
)
.
filter
(
and_
(
*
finance_condition
))
query_res
=
db
.
execute
(
get_user_orm_sql
)
.
fetchall
()
return
[
i
[
0
]
.
to_dict
()
for
i
in
query_res
][::
-
1
]
def
get_finance_details
(
db
,
data
):
"""账户财务明细"""
finance_condition
=
[]
if
data
.
type
or
data
.
type
==
0
:
finance_condition
.
append
(
AccountFinanceDetails
.
type
==
data
.
type
)
if
data
.
gift_type
:
finance_condition
.
append
(
AccountFinanceDetails
.
gift_type
==
data
.
gift_type
)
if
data
.
start_time
:
finance_condition
.
append
(
AccountFinanceDetails
.
create_time
>=
data
.
start_time
)
if
data
.
end_time
:
finance_condition
.
append
(
AccountFinanceDetails
.
create_time
<=
data
.
end_time
)
if
not
finance_condition
:
query_res
=
db
.
query
(
AccountFinanceDetails
)
.
all
()
return
[
i
.
to_dict
()
for
i
in
query_res
][::
-
1
]
else
:
get_user_orm_sql
=
db
.
query
(
AccountFinanceDetails
)
.
filter
(
and_
(
*
finance_condition
))
query_res
=
db
.
execute
(
get_user_orm_sql
)
.
fetchall
()
return
[
i
[
0
]
.
to_dict
()
for
i
in
query_res
][::
-
1
]
app/api/account/schemas.py
View file @
4fe1640e
...
@@ -2,6 +2,13 @@ from typing import Optional
...
@@ -2,6 +2,13 @@ from typing import Optional
from
pydantic
import
BaseModel
from
pydantic
import
BaseModel
class
PublicModel
(
BaseModel
):
page
:
Optional
[
int
]
=
None
size
:
Optional
[
int
]
=
None
start_time
:
Optional
[
str
]
=
""
end_time
:
Optional
[
str
]
=
""
class
AccountCreate
(
BaseModel
):
class
AccountCreate
(
BaseModel
):
name
:
str
name
:
str
remark
:
Optional
[
str
]
=
None
remark
:
Optional
[
str
]
=
None
...
@@ -23,3 +30,12 @@ class AccountUpdate(BaseModel):
...
@@ -23,3 +30,12 @@ class AccountUpdate(BaseModel):
remark
:
str
remark
:
str
income
:
list
income
:
list
output
:
list
output
:
list
class
FinanceInfo
(
PublicModel
):
aid
:
int
class
FinanceDetails
(
PublicModel
):
type
:
Optional
[
int
]
=
None
gift_type
:
Optional
[
int
]
=
None
app/api/account/views.py
View file @
4fe1640e
...
@@ -40,8 +40,15 @@ def read_account(data: schemas.AccountUpdate, db: Session = Depends(get_db)):
...
@@ -40,8 +40,15 @@ def read_account(data: schemas.AccountUpdate, db: Session = Depends(get_db)):
return
HttpResultResponse
()
return
HttpResultResponse
()
@
router
.
post
(
"/finance/info/{aid}"
)
@
router
.
post
(
"/finance/info"
)
def
finance_information
(
aid
,
db
:
Session
=
Depends
(
get_db
)):
def
finance_information
(
data
:
schemas
.
FinanceInfo
,
db
:
Session
=
Depends
(
get_db
)):
"""财务信息"""
"""账户财务信息"""
crud
.
get_finance_info
(
db
,
aid
)
res
=
crud
.
get_finance_info
(
db
,
data
)
return
HttpResultResponse
()
return
HttpResultResponse
(
total
=
len
(
res
),
data
=
res
[
int
(
data
.
page
-
1
)
*
data
.
size
:
data
.
page
*
data
.
size
])
@
router
.
post
(
"/finance/details"
)
def
finance_details
(
data
:
schemas
.
FinanceDetails
,
db
:
Session
=
Depends
(
get_db
)):
"""账户财务明细"""
res
=
crud
.
get_finance_details
(
db
,
data
)
return
HttpResultResponse
(
total
=
len
(
res
),
data
=
res
[
int
(
data
.
page
-
1
)
*
data
.
size
:
data
.
page
*
data
.
size
])
models/account.py
View file @
4fe1640e
from
sqlalchemy
import
Column
,
Integer
,
String
,
Text
,
DateTime
,
Index
from
sqlalchemy
import
Column
,
Integer
,
String
,
Text
,
DateTime
,
Float
from
core.storage.db
import
Base
from
core.storage.db
import
Base
from
sqlalchemy_serializer
import
SerializerMixin
from
sqlalchemy_serializer
import
SerializerMixin
...
@@ -37,3 +37,36 @@ class AccountType(Base, SerializerMixin):
...
@@ -37,3 +37,36 @@ class AccountType(Base, SerializerMixin):
create_time
=
Column
(
DateTime
,
comment
=
"创建时间"
)
create_time
=
Column
(
DateTime
,
comment
=
"创建时间"
)
__table_args__
=
{
'comment'
:
'礼物类型配置'
}
__table_args__
=
{
'comment'
:
'礼物类型配置'
}
class
AccountFinance
(
Base
,
SerializerMixin
):
"""账号财务数据(单位:天)"""
__tablename__
=
"account_finance"
id
=
Column
(
Integer
,
primary_key
=
True
,
index
=
True
)
account_id
=
Column
(
Integer
,
comment
=
"账户id"
)
account_tag
=
Column
(
String
(
255
),
comment
=
"账户标识"
)
account_uuid
=
Column
(
String
(
100
),
comment
=
"账户uuid"
)
balance
=
Column
(
String
(
255
),
comment
=
"当日余额"
)
income
=
Column
(
Float
,
comment
=
"当日入账"
)
output
=
Column
(
Float
,
comment
=
"当日出账"
)
create_time
=
Column
(
DateTime
,
comment
=
"创建时间"
)
__table_args__
=
{
'comment'
:
'账号财务数据表'
}
class
AccountFinanceDetails
(
Base
,
SerializerMixin
):
"""账号财务数据详情"""
__tablename__
=
"account_finance_details"
id
=
Column
(
Integer
,
primary_key
=
True
,
index
=
True
)
account_id
=
Column
(
Integer
,
comment
=
"账户id"
)
account_tag
=
Column
(
String
(
255
),
comment
=
"账户标识"
)
account_uuid
=
Column
(
String
(
100
),
comment
=
"账户uuid"
)
order_number
=
Column
(
String
(
255
),
comment
=
"订单号"
)
gift_type
=
Column
(
String
(
255
),
comment
=
"礼物类型"
)
type
=
Column
(
Integer
,
comment
=
"方式:0出账,1:入账"
)
amount
=
Column
(
Float
,
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