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
0d260465
Commit
0d260465
authored
Jun 21, 2023
by
陈涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改解绑节点账单
parent
3e3e20dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
bill.py
api/bill.py
+11
-3
scheduler.py
service/scheduler.py
+1
-1
No files found.
api/bill.py
View file @
0d260465
...
...
@@ -8,7 +8,8 @@ from model import Response, Page, PageResponse, SortParams, FilterTime
from
model.bill
import
PCFBill
,
ExchangeBill
,
AdjustBill
,
StakingBill
from
model.node
import
BaseNode
from
schema.bill
import
CreatePCFBill
,
PCFBillType
,
CreateExchangeBill
,
CreateAdjustBill
,
CreateStakingBill
,
\
UpdatePCFBill
,
UpdateExchangeBill
,
UpdateStakingBill
,
UpdateAdjustBill
,
AllBillType
,
StakingDirection
,
BillType
UpdatePCFBill
,
UpdateExchangeBill
,
UpdateStakingBill
,
UpdateAdjustBill
,
AllBillType
,
StakingDirection
,
BillType
,
\
StakingBillStatus
from
schema.fund
import
FundStatus
from
schema.node
import
BindNode
from
service.beacon
import
BeaconChaService
...
...
@@ -194,7 +195,7 @@ async def create_staking_api(
fund_id
=
create_staking_bill
.
fund_id
,
fund_status
=
FundStatus
.
active
)
assets
,
pending_assets
,
nodes
=
fund_data
[
"assets"
],
fund_data
[
"pending_assets"
],
fund_data
[
"node
s"
]
assets
,
pending_assets
,
nodes
,
staking_assets
=
fund_data
[
"assets"
],
fund_data
[
"pending_assets"
],
fund_data
[
"nodes"
],
fund_data
[
"staking_asset
s"
]
if
create_staking_bill
.
direction
==
StakingDirection
.
bind
:
assert
assets
.
get
(
create_staking_bill
.
currency
,
0
)
>=
create_staking_bill
.
volume
+
create_staking_bill
.
fee
,
'余额不足'
assets
[
create_staking_bill
.
currency
]
-=
create_staking_bill
.
volume
+
create_staking_bill
.
fee
...
...
@@ -210,15 +211,22 @@ async def create_staking_api(
else
:
nodes
[
bind_node
.
pub_key
]
=
db_data
.
dict
()
else
:
# 将所有该基金pubkey的账单置为finish
await
bill_collect
.
update_many
(
{
"fund_id"
:
create_staking_bill
.
fund_id
,
"pub_key"
:
create_staking_bill
.
pub_key
},
{
"$set"
:
{
"status"
:
StakingBillStatus
.
finish
}}
)
assets
[
create_staking_bill
.
currency
]
+=
create_staking_bill
.
volume
-
create_staking_bill
.
fee
# 检查pending_assets里面的值
for
key
,
value
in
pending_assets
.
items
():
assets
.
setdefault
(
key
,
0
)
assets
[
key
]
+=
value
pending_assets
[
key
]
-=
value
for
key
,
value
in
staking_assets
.
items
():
staking_assets
[
key
]
-=
value
del
nodes
[
create_staking_bill
.
pub_key
]
await
update_fund
(
fund_collect
,
create_staking_bill
.
fund_id
,
pending_assets
=
pending_assets
,
assets
=
assets
,
nodes
=
nodes
)
nodes
=
nodes
,
staking_assets
=
staking_assets
)
# 添加账目
staking_bill
=
StakingBill
(
user_id
=
user
.
id
,
**
create_staking_bill
.
dict
())
...
...
service/scheduler.py
View file @
0d260465
...
...
@@ -69,7 +69,7 @@ async def calculate_nav_task(fund_id=None):
async
def
update_staking_node_status_task
(
beacon_service
:
BeaconChaService
,
mongodb_manager
:
AioMongodbManager
):
bill_collect
=
get_bill_collect
(
mongodb_manager
)
data
=
bill_collect
.
find
({
'bill_type'
:
AllBillType
.
staking
,
"status"
:
StakingBillStatus
.
pending
})
data
=
bill_collect
.
find
({
'bill_type'
:
AllBillType
.
staking
,
"status"
:
StakingBillStatus
.
pending
,
"direction"
:
"bind"
})
staking_bill_list
=
await
data
.
to_list
(
length
=
None
)
for
bill_item
in
staking_bill_list
:
bill_item
=
StakingBill
(
**
bill_item
)
...
...
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