Commit a3d3346d authored by 陈涛's avatar 陈涛

质押节点接口增加手续费fee字段

parent 31a6c4c7
import datetime
from typing import Optional
import pytz
from fastapi import APIRouter, Depends, Query, Body
from fastapi.background import BackgroundTasks
from motor.core import AgnosticCollection
......@@ -50,8 +52,8 @@ async def create_nav(
fund_collect: AgnosticCollection = Depends(get_fund_collect),
nav_collect: AgnosticCollection = Depends(get_nav_collect),
):
fund_data = await fund_collect.find({"id": fund_id})
fund_nav = build_fund_nav(fund_data, record_date, fund_share, nav)
fund_data = await fund_collect.find_one({"id": fund_id})
fund_nav = build_fund_nav(fund_data, record_date.replace(hour=0, minute=0, second=0, microsecond=0, tzinfo=pytz.UTC), fund_share, nav)
insert = await nav_collect.insert_one(fund_nav)
response = Response(data=insert.acknowledged)
return response
......@@ -69,7 +71,7 @@ async def update_nav(
):
update_result = await nav_collect.update_one(
{"id": nav_id, "fund_id": fund_id},
{"$set": {"record_date": record_date, "nav": nav, "fund_share": fund_share}}
{"$set": {"record_date": record_date.replace(hour=0, minute=0, second=0, microsecond=0, tzinfo=pytz.UTC), "nav": nav, "fund_share": fund_share}}
)
response = Response(data=update_result.modified_count)
return response
......
......@@ -79,6 +79,7 @@ class CreateStakingBill(BaseModel):
pub_key: str = Field(..., description='节点key')
remark: str = Field(default="", description="备注")
record_time: int = Field(default_factory=lambda: utc_now_timestamp(), description='记录时间')
fee: float = Field(0, description="手续费")
class CreateAdjustBill(BaseModel):
......
......@@ -30,7 +30,7 @@ async def create_staking(
if not assets or assets[0]["volume"] < create_bill.volume >= 0:
raise APIError(message="余额不足")
assets[0]['volume'] -= create_bill.volume
assets[0]['volume'] -= create_bill.volume + create_bill.fee
pending_asset = list(filter(lambda x: x["currency"] == create_bill.currency, fund.get('pending_assets', [])))
if pending_asset:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment