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
a39871ce
Commit
a39871ce
authored
Mar 28, 2023
by
confusion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改创建PCF账单接口
parent
83f2d5ac
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
19 deletions
+10
-19
bill.py
api/bill.py
+5
-7
bill.py
schema/bill.py
+3
-0
bill.py
service/bill.py
+2
-12
No files found.
api/bill.py
View file @
a39871ce
...
...
@@ -27,7 +27,6 @@ async def create_pcf(
fund_collect
:
AgnosticCollection
=
Depends
(
get_fund_collect
),
bill_collect
:
AgnosticCollection
=
Depends
(
get_bill_collect
),
):
assert
item
.
bill_type
==
PCFBillType
.
sub
or
item
.
bill_type
==
PCFBillType
.
redemption
,
"枚举错误"
query
=
{
"id"
:
item
.
fund_id
,
"user_id"
:
user
.
id
}
fund
=
await
fund_collect
.
find_one
(
query
)
assert
fund
,
NotFundError
()
...
...
@@ -40,10 +39,10 @@ async def create_pcf(
else
:
update
=
{
"$push"
:
{
"assets"
:
{
"currency"
:
item
.
currency
,
"volume"
:
item
.
volume
}}}
await
fund_collect
.
update_one
(
query
,
update
)
market_value
=
item
.
volume
*
item
.
price
p
rc
=
PCFBill
(
user_id
=
user
.
id
,
fund_share
=
market_value
/
fund
[
"nav"
],
market_value
=
market_value
,
**
item
.
dict
())
await
bill_collect
.
insert_one
(
p
rc
.
dict
())
return
Response
[
PCFBill
](
data
=
p
rc
.
dict
())
p
cf
=
PCFBill
(
user_id
=
user
.
id
,
**
item
.
dict
())
await
bill_collect
.
insert_one
(
p
cf
.
dict
())
return
Response
[
PCFBill
](
data
=
p
cf
.
dict
())
@
router
.
post
(
'/exchange/'
,
...
...
@@ -120,10 +119,9 @@ async def create_adjust(
async
def
create_staking_api
(
item
:
CreateStakingBill
,
user
:
User
=
Depends
(
get_current_user
),
fund_collect
:
AgnosticCollection
=
Depends
(
get_fund_collect
),
bill_collect
:
AgnosticCollection
=
Depends
(
get_bill_collect
),
):
staking_bill
=
await
create_staking
(
item
,
user
.
id
,
fund_collect
,
bill_collect
)
staking_bill
=
await
create_staking
(
item
,
user
.
id
,
bill_collect
)
response
=
Response
[
StakingBill
](
data
=
staking_bill
.
dict
())
return
response
...
...
schema/bill.py
View file @
a39871ce
...
...
@@ -48,6 +48,9 @@ class StakingBillStatus(str, Enum):
# 创建申购赎回记录
class
CreatePCFBill
(
BaseModel
):
fund_id
:
str
=
Field
(
...
,
description
=
'基金id'
)
fund_share
:
float
=
Field
(
...
,
description
=
"基金份额"
)
market_value
:
float
=
Field
(
...
,
description
=
"市值"
)
email
:
str
=
Field
(
...
,
description
=
'客户邮箱'
)
bill_type
:
PCFBillType
=
Field
(
...
,
description
=
'账目类型'
)
currency
:
str
=
Field
(
...
,
description
=
'币种'
)
...
...
service/bill.py
View file @
a39871ce
...
...
@@ -15,19 +15,8 @@ DataT = TypeVar('DataT')
async
def
create_staking
(
item
:
CreateStakingBill
,
user_id
,
fund_collect
:
AgnosticCollection
,
bill_collect
:
AgnosticCollection
,
):
# query = {"id": item.fund_id, "user_id": user_id}
# fund = await fund_collect.find_one(query)
# assert fund, NotFundError()
# filter_asset = list(filter(lambda x: x["currency"] == item.currency, fund["assets"]))
# if filter_asset:
# update = {"$inc": {"assets.$.volume": -item.volume}}
# await fund_collect.update_one({**query, "assets.currency": item.currency}, update)
# else:
# update = {"$push": {"assets": {"currency": item.currency, "volume": -item.volume}}}
# await fund_collect.update_one(query, update)
staking_bill
=
StakingBill
(
user_id
=
user_id
,
**
item
.
dict
())
await
bill_collect
.
insert_one
(
staking_bill
.
dict
())
return
staking_bill
...
...
@@ -43,7 +32,8 @@ async def update_bill(
db_update_data
.
update
({
"update_time"
:
int
(
datetime
.
datetime
.
utcnow
()
.
timestamp
())
})
data
=
await
bill_collect
.
find_one_and_update
({
'id'
:
bill_id
,
"fund_id"
:
fund_id
},
{
'$set'
:
db_update_data
},
data
=
await
bill_collect
.
find_one_and_update
({
'id'
:
bill_id
,
"fund_id"
:
fund_id
},
{
'$set'
:
db_update_data
},
return_document
=
ReturnDocument
.
AFTER
)
assert
data
,
NotFundError
()
response
=
Response
[
DataT
](
data
=
res_model
(
**
data
))
...
...
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