Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PyFund
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
陈涛
PyFund
Commits
12405512
Commit
12405512
authored
Mar 30, 2023
by
杨明橙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改swagger
parent
5e4af2f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
49 deletions
+45
-49
__init__.py
api/__init__.py
+1
-1
bill.py
api/bill.py
+44
-48
No files found.
api/__init__.py
View file @
12405512
...
@@ -3,7 +3,7 @@ from api import bill, nav, fund, group, node, scheduler, price
...
@@ -3,7 +3,7 @@ from api import bill, nav, fund, group, node, scheduler, price
api_router
=
APIRouter
()
api_router
=
APIRouter
()
api_router
.
include_router
(
bill
.
router
,
prefix
=
"/bill"
,
tags
=
[
"账单"
]
)
api_router
.
include_router
(
bill
.
router
,
prefix
=
"/bill"
)
api_router
.
include_router
(
nav
.
router
,
prefix
=
"/nav"
,
tags
=
[
"净值"
])
api_router
.
include_router
(
nav
.
router
,
prefix
=
"/nav"
,
tags
=
[
"净值"
])
api_router
.
include_router
(
fund
.
router
,
prefix
=
"/fund"
,
tags
=
[
"基金"
])
api_router
.
include_router
(
fund
.
router
,
prefix
=
"/fund"
,
tags
=
[
"基金"
])
api_router
.
include_router
(
node
.
router
,
prefix
=
"/node"
,
tags
=
[
"节点"
])
api_router
.
include_router
(
node
.
router
,
prefix
=
"/node"
,
tags
=
[
"节点"
])
...
...
api/bill.py
View file @
12405512
from
typing
import
Union
,
List
,
Any
from
typing
import
Union
,
List
,
Any
from
loguru
import
logger
from
fastapi
import
APIRouter
,
Depends
,
Query
from
fastapi
import
APIRouter
,
Depends
,
Query
from
motor.core
import
AgnosticCollection
from
motor.core
import
AgnosticCollection
from
pymongo.operations
import
UpdateOne
from
dependencies
import
get_current_user
,
get_fund_collect
,
get_bill_collect
from
dependencies
import
get_current_user
,
get_fund_collect
,
get_bill_collect
from
exception.api
import
APIError
from
exception.db
import
NotFundError
from
model
import
Response
,
Page
,
PageResponse
,
SortParams
,
FilterTime
from
model
import
Response
,
Page
,
PageResponse
,
SortParams
,
FilterTime
from
model.bill
import
PCFBill
,
ExchangeBill
,
AdjustBill
,
StakingBill
from
model.bill
import
PCFBill
,
ExchangeBill
,
AdjustBill
,
StakingBill
from
schema.bill
import
CreatePCFBill
,
PCFBillType
,
CreateExchangeBill
,
CreateAdjustBill
,
CreateStakingBill
,
\
from
schema.bill
import
CreatePCFBill
,
PCFBillType
,
CreateExchangeBill
,
CreateAdjustBill
,
CreateStakingBill
,
\
UpdatePCFBill
,
UpdateExchangeBill
,
UpdateStakingBill
,
UpdateAdjustBill
,
AllBillType
UpdatePCFBill
,
UpdateExchangeBill
,
UpdateStakingBill
,
UpdateAdjustBill
,
AllBillType
from
schema.fund
import
FundStatus
from
schema.fund
import
FundStatus
from
service.bill
import
update_bill
,
create_staking
from
service.bill
import
update_bill
from
service.fund
import
query_fund_assets
,
update_assets
from
service.fund
import
query_fund_assets
,
update_assets
from
tools.jwt_tools
import
User
from
tools.jwt_tools
import
User
...
@@ -21,23 +17,23 @@ router = APIRouter()
...
@@ -21,23 +17,23 @@ router = APIRouter()
@
router
.
post
(
'/pcf/'
,
@
router
.
post
(
'/pcf/'
,
response_model
=
Response
[
PCFBill
],
response_model
=
Response
[
PCFBill
],
tags
=
[
'
新增
'
],
tags
=
[
'
[申购/赎回]
'
],
summary
=
'
添加[申购/赎回]账目
'
,
summary
=
'
[添加]
'
,
description
=
'
添加
申购赎回账目'
)
description
=
'
[添加]
申购赎回账目'
)
async
def
create_pcf
(
async
def
create_pcf
(
item
:
CreatePCFBill
,
create_pcf_bill
:
CreatePCFBill
,
user
:
User
=
Depends
(
get_current_user
),
user
:
User
=
Depends
(
get_current_user
),
fund_collect
:
AgnosticCollection
=
Depends
(
get_fund_collect
),
fund_collect
:
AgnosticCollection
=
Depends
(
get_fund_collect
),
bill_collect
:
AgnosticCollection
=
Depends
(
get_bill_collect
),
bill_collect
:
AgnosticCollection
=
Depends
(
get_bill_collect
),
):
):
inc
=
item
.
volume
if
item
.
bill_type
==
PCFBillType
.
sub
else
-
item
.
volume
inc
=
create_pcf_bill
.
volume
if
create_pcf_bill
.
bill_type
==
PCFBillType
.
sub
else
-
create_pcf_bill
.
volume
assets
,
adjust_assets
,
pending_assets
,
staking_assets
=
await
query_fund_assets
(
fund_collect
,
item
.
fund_id
,
user
.
id
,
assets
,
adjust_assets
,
pending_assets
,
staking_assets
=
await
query_fund_assets
(
fund_collect
,
create_pcf_bill
.
fund_id
,
user
.
id
,
FundStatus
.
active
)
FundStatus
.
active
)
assets
.
setdefault
(
item
.
currency
,
0
)
assets
.
setdefault
(
create_pcf_bill
.
currency
,
0
)
# 如果是赎回 判断余额是否够
# 如果是赎回 判断余额是否够
assert
assets
[
item
.
currency
]
+
inc
>=
0
,
"余额不足"
assert
assets
[
create_pcf_bill
.
currency
]
+
inc
>=
0
,
"余额不足"
assets
[
item
.
currency
]
+=
inc
assets
[
create_pcf_bill
.
currency
]
+=
inc
# if item.currency in assets:
# if item.currency in assets:
# inc = item.volume if item.bill_type == PCFBillType.sub else -item.volume
# inc = item.volume if item.bill_type == PCFBillType.sub else -item.volume
...
@@ -46,17 +42,17 @@ async def create_pcf(
...
@@ -46,17 +42,17 @@ async def create_pcf(
# else:
# else:
# assert item.bill_type == PCFBillType.sub, "余额不足"
# assert item.bill_type == PCFBillType.sub, "余额不足"
# assets.update({item.currency: item.volume})
# assets.update({item.currency: item.volume})
await
update_assets
(
fund_collect
,
item
.
fund_id
,
assets
=
assets
)
await
update_assets
(
fund_collect
,
create_pcf_bill
.
fund_id
,
assets
=
assets
)
pcf
=
PCFBill
(
user_id
=
user
.
id
,
**
item
.
dict
())
pcf
=
PCFBill
(
user_id
=
user
.
id
,
**
create_pcf_bill
.
dict
())
await
bill_collect
.
insert_one
(
pcf
.
dict
())
await
bill_collect
.
insert_one
(
pcf
.
dict
())
return
Response
[
PCFBill
](
data
=
pcf
.
dict
())
return
Response
[
PCFBill
](
data
=
pcf
.
dict
())
@
router
.
post
(
'/exchange/'
,
@
router
.
post
(
'/exchange/'
,
response_model
=
Response
[
ExchangeBill
],
response_model
=
Response
[
ExchangeBill
],
tags
=
[
'
新增
'
],
tags
=
[
'
置换币种
'
],
summary
=
'
添加置换币账目
'
,
summary
=
'
[添加]
'
,
description
=
'
添加
置换币账目'
)
description
=
'
[添加]
置换币账目'
)
async
def
create_exchange
(
async
def
create_exchange
(
create_exchange_bill
:
CreateExchangeBill
,
create_exchange_bill
:
CreateExchangeBill
,
user
:
User
=
Depends
(
get_current_user
),
user
:
User
=
Depends
(
get_current_user
),
...
@@ -107,9 +103,9 @@ async def create_exchange(
...
@@ -107,9 +103,9 @@ async def create_exchange(
@
router
.
post
(
'/adjust/'
,
@
router
.
post
(
'/adjust/'
,
response_model
=
Response
[
AdjustBill
],
response_model
=
Response
[
AdjustBill
],
tags
=
[
'
新增
'
],
tags
=
[
'
调整
'
],
summary
=
'
添加调整账目
'
,
summary
=
'
[添加]
'
,
description
=
'
添加
调整账目'
)
description
=
'
[添加]
调整账目'
)
async
def
create_adjust
(
async
def
create_adjust
(
create_adjust_bill
:
CreateAdjustBill
,
create_adjust_bill
:
CreateAdjustBill
,
user
:
User
=
Depends
(
get_current_user
),
user
:
User
=
Depends
(
get_current_user
),
...
@@ -144,9 +140,9 @@ async def create_adjust(
...
@@ -144,9 +140,9 @@ async def create_adjust(
@
router
.
post
(
'/staking/'
,
@
router
.
post
(
'/staking/'
,
response_model
=
Response
[
StakingBill
],
response_model
=
Response
[
StakingBill
],
tags
=
[
'
新增
'
],
tags
=
[
'
质押
'
],
summary
=
'
添加质押账目
'
,
summary
=
'
[添加]
'
,
description
=
'
添加
质押账目'
)
description
=
'
[添加]
质押账目'
)
async
def
create_staking_api
(
async
def
create_staking_api
(
create_staking_bill
:
CreateStakingBill
,
create_staking_bill
:
CreateStakingBill
,
user
:
User
=
Depends
(
get_current_user
),
user
:
User
=
Depends
(
get_current_user
),
...
@@ -173,10 +169,10 @@ async def create_staking_api(
...
@@ -173,10 +169,10 @@ async def create_staking_api(
@
router
.
put
(
'/pcf/{fund_id}/'
,
@
router
.
put
(
'/pcf/{fund_id}/'
,
tags
=
[
'
更新
'
],
tags
=
[
'
[申购/赎回]
'
],
response_model
=
Response
[
PCFBill
],
response_model
=
Response
[
PCFBill
],
summary
=
'
更新申购赎回记录
'
,
summary
=
'
[更新]
'
,
description
=
''
)
description
=
'
[更新]申购赎回记录
'
)
async
def
update_pcf_bill
(
async
def
update_pcf_bill
(
bill_id
:
str
,
bill_id
:
str
,
fund_id
:
str
,
fund_id
:
str
,
...
@@ -198,10 +194,10 @@ async def update_pcf_bill(
...
@@ -198,10 +194,10 @@ async def update_pcf_bill(
@
router
.
put
(
'/exchange/{fund_id}/'
,
@
router
.
put
(
'/exchange/{fund_id}/'
,
tags
=
[
'
更新
'
],
tags
=
[
'
置换币种
'
],
response_model
=
Response
[
ExchangeBill
],
response_model
=
Response
[
ExchangeBill
],
summary
=
'
更新置换记录
'
,
summary
=
'
[更新]
'
,
description
=
''
)
description
=
'
[更新]置换币种记录
'
)
async
def
update_exchange_bill
(
async
def
update_exchange_bill
(
bill_id
:
str
,
bill_id
:
str
,
fund_id
:
str
,
fund_id
:
str
,
...
@@ -222,15 +218,15 @@ async def update_exchange_bill(
...
@@ -222,15 +218,15 @@ async def update_exchange_bill(
return
response
return
response
@
router
.
put
(
'/
staking
/{fund_id}/'
,
@
router
.
put
(
'/
adjust
/{fund_id}/'
,
tags
=
[
'
更新
'
],
tags
=
[
'
调整
'
],
response_model
=
Response
[
Staking
Bill
],
response_model
=
Response
[
Adjust
Bill
],
summary
=
'
更新质押记录
'
,
summary
=
'
[更新]
'
,
description
=
''
)
description
=
'
[更新]调整记录
'
)
async
def
update_
staking
_bill
(
async
def
update_
adjust
_bill
(
bill_id
:
str
,
bill_id
:
str
,
fund_id
:
str
,
fund_id
:
str
,
update_item
:
Update
Staking
Bill
,
update_item
:
Update
Adjust
Bill
,
user
:
User
=
Depends
(
get_current_user
),
user
:
User
=
Depends
(
get_current_user
),
fund_collect
:
AgnosticCollection
=
Depends
(
get_fund_collect
),
fund_collect
:
AgnosticCollection
=
Depends
(
get_fund_collect
),
bill_collect
:
AgnosticCollection
=
Depends
(
get_bill_collect
),
bill_collect
:
AgnosticCollection
=
Depends
(
get_bill_collect
),
...
@@ -242,20 +238,20 @@ async def update_staking_bill(
...
@@ -242,20 +238,20 @@ async def update_staking_bill(
update_data
=
update_item
,
update_data
=
update_item
,
fund_collect
=
fund_collect
,
fund_collect
=
fund_collect
,
bill_collect
=
bill_collect
,
bill_collect
=
bill_collect
,
res_model
=
Staking
Bill
res_model
=
Adjust
Bill
)
)
return
response
return
response
@
router
.
put
(
'/
adjust
/{fund_id}/'
,
@
router
.
put
(
'/
staking
/{fund_id}/'
,
tags
=
[
'
更新
'
],
tags
=
[
'
质押
'
],
response_model
=
Response
[
Adjust
Bill
],
response_model
=
Response
[
Staking
Bill
],
summary
=
'
更新调整记录
'
,
summary
=
'
[更新]
'
,
description
=
''
)
description
=
'
[更新]质押记录
'
)
async
def
update_
adjust
_bill
(
async
def
update_
staking
_bill
(
bill_id
:
str
,
bill_id
:
str
,
fund_id
:
str
,
fund_id
:
str
,
update_item
:
Update
Adjust
Bill
,
update_item
:
Update
Staking
Bill
,
user
:
User
=
Depends
(
get_current_user
),
user
:
User
=
Depends
(
get_current_user
),
fund_collect
:
AgnosticCollection
=
Depends
(
get_fund_collect
),
fund_collect
:
AgnosticCollection
=
Depends
(
get_fund_collect
),
bill_collect
:
AgnosticCollection
=
Depends
(
get_bill_collect
),
bill_collect
:
AgnosticCollection
=
Depends
(
get_bill_collect
),
...
@@ -267,13 +263,13 @@ async def update_adjust_bill(
...
@@ -267,13 +263,13 @@ async def update_adjust_bill(
update_data
=
update_item
,
update_data
=
update_item
,
fund_collect
=
fund_collect
,
fund_collect
=
fund_collect
,
bill_collect
=
bill_collect
,
bill_collect
=
bill_collect
,
res_model
=
Adjust
Bill
res_model
=
Staking
Bill
)
)
return
response
return
response
@
router
.
get
(
'/{fund_id}/'
,
@
router
.
get
(
'/{fund_id}/'
,
tags
=
[
"查询"
],
tags
=
[
"查询
账目
"
],
response_model
=
PageResponse
[
Union
[
PCFBill
,
ExchangeBill
,
StakingBill
,
AdjustBill
]],
response_model
=
PageResponse
[
Union
[
PCFBill
,
ExchangeBill
,
StakingBill
,
AdjustBill
]],
summary
=
'查询账单记录'
,
summary
=
'查询账单记录'
,
description
=
'查询账单记录'
)
description
=
'查询账单记录'
)
...
...
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