Commit fa83afe1 authored by 陈涛's avatar 陈涛

净值修改

parent 857d86e6
...@@ -34,14 +34,14 @@ bill_type_to_permission = { ...@@ -34,14 +34,14 @@ bill_type_to_permission = {
async def nav_handler(nav_collect, fund_id, record_time, settlement_time): async def nav_handler(nav_collect, fund_id, record_time, settlement_time):
record_date = timestamp_to_datetime(record_time) record_date = timestamp_to_datetime(record_time)
re_time = re.findall(r"(\d+):00", settlement_time)[0] re_time = int(re.findall(r"(\d+):00", settlement_time)[0])
if record_date.hour < re_time: if record_date.hour < re_time:
record_date += datetime.timedelta(days=-1) record_date += datetime.timedelta(days=-1)
start_date = record_date.replace(hour=0, minute=0, second=0, microsecond=0, tzinfo=pytz.UTC) start_date = record_date.replace(hour=0, minute=0, second=0, microsecond=0, tzinfo=pytz.UTC)
nav_record = await get_nav_record( nav_record = await get_nav_record(
nav_collect=nav_collect, nav_collect=nav_collect,
fund_id=fund_id, fund_id=fund_id,
query_data={"record_time": {"$gte": start_date}} query_data={"record_date": {"$gte": start_date}}
) )
return nav_record return nav_record
...@@ -85,7 +85,8 @@ async def create_pcf( ...@@ -85,7 +85,8 @@ async def create_pcf(
nav["assets"][create_pcf_bill.currency] += delta_volume nav["assets"][create_pcf_bill.currency] += delta_volume
bulk_list.append(UpdateOne({"_id": nav["_id"]}, {"$set": {"assets": nav["assets"]}})) bulk_list.append(UpdateOne({"_id": nav["_id"]}, {"$set": {"assets": nav["assets"]}}))
await update_fund(fund_collect, create_pcf_bill.fund_id, assets=assets) await update_fund(fund_collect, create_pcf_bill.fund_id, assets=assets)
await nav_collect.bulk_write(bulk_list) if bulk_list:
await nav_collect.bulk_write(bulk_list)
pcf = PCFBill(user_id=user.id, **create_pcf_bill.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())
...@@ -132,8 +133,8 @@ async def create_exchange( ...@@ -132,8 +133,8 @@ async def create_exchange(
nav["assets"][create_exchange_bill.output_currency] += create_exchange_bill.output_volume nav["assets"][create_exchange_bill.output_currency] += create_exchange_bill.output_volume
bulk_list.append(UpdateOne({"_id": nav["_id"]}, {"$set": {"assets": nav["assets"]}})) bulk_list.append(UpdateOne({"_id": nav["_id"]}, {"$set": {"assets": nav["assets"]}}))
await update_fund(fund_collect, create_exchange_bill.fund_id, assets=assets) await update_fund(fund_collect, create_exchange_bill.fund_id, assets=assets)
await nav_collect.bulk_write(bulk_list) if bulk_list:
await nav_collect.bulk_write(bulk_list)
input_value, output_value = create_exchange_bill.input_volume * create_exchange_bill.input_price, create_exchange_bill.output_volume * create_exchange_bill.output_price input_value, output_value = create_exchange_bill.input_volume * create_exchange_bill.input_price, create_exchange_bill.output_volume * create_exchange_bill.output_price
exchange_bill = ExchangeBill(user_id=user.id, input_value=input_value, output_value=output_value, exchange_bill = ExchangeBill(user_id=user.id, input_value=input_value, output_value=output_value,
profit=output_value - input_value, **create_exchange_bill.dict()) profit=output_value - input_value, **create_exchange_bill.dict())
...@@ -182,8 +183,8 @@ async def create_adjust( ...@@ -182,8 +183,8 @@ async def create_adjust(
bulk_list.append(UpdateOne({"_id": nav["_id"]}, {"$set": {"assets": nav["assets"]}})) bulk_list.append(UpdateOne({"_id": nav["_id"]}, {"$set": {"assets": nav["assets"]}}))
await update_fund(fund_collect, create_adjust_bill.fund_id, adjust_assets=adjust_assets) await update_fund(fund_collect, create_adjust_bill.fund_id, adjust_assets=adjust_assets)
await nav_collect.bulk_write(bulk_list) if bulk_list:
await nav_collect.bulk_write(bulk_list)
adjust_bill = AdjustBill(user_id=user.id, **create_adjust_bill.dict()) adjust_bill = AdjustBill(user_id=user.id, **create_adjust_bill.dict())
await bill_collect.insert_one(adjust_bill.dict()) await bill_collect.insert_one(adjust_bill.dict())
response = Response[AdjustBill](data=adjust_bill.dict()) response = Response[AdjustBill](data=adjust_bill.dict())
......
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