Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
ts-api-demo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
wmvm
ts-api-demo
Commits
102024c8
Commit
102024c8
authored
Jan 04, 2025
by
ml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产管理后台-特殊费率修改
parent
aec822ac
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
72 deletions
+48
-72
task.fee.rate.log.model.ts
cron/model/task.fee.rate.log.model.ts
+4
-2
commonUserFeeSetting.service.ts
src/functional/mvc/service/commonUserFeeSetting.service.ts
+44
-70
No files found.
cron/model/task.fee.rate.log.model.ts
View file @
102024c8
...
@@ -119,6 +119,7 @@ export const changeUserSpotFee = async function (user_id, symbol, fee_model, mak
...
@@ -119,6 +119,7 @@ export const changeUserSpotFee = async function (user_id, symbol, fee_model, mak
let
is_success
=
true
;
let
is_success
=
true
;
await
checkFeeModel
(
fee_model
);
await
checkFeeModel
(
fee_model
);
let
product_type
=
pair
==
'all'
?
'spot'
:
'single'
;
let
product_type
=
pair
==
'all'
?
'spot'
:
'single'
;
let
opt_market
=
product_type
;
//生效的费率 与要设置的费率 比对做校验 现在分不开 现货 合约 先不校验 之后分开了 再校验
//生效的费率 与要设置的费率 比对做校验 现在分不开 现货 合约 先不校验 之后分开了 再校验
let
feeExist
=
await
cancelIfFeeExist
(
user_id
,
product_type
,
symbol
,
maker_fee
,
taker_fee
);
let
feeExist
=
await
cancelIfFeeExist
(
user_id
,
product_type
,
symbol
,
maker_fee
,
taker_fee
);
if
(
feeExist
)
{
if
(
feeExist
)
{
...
@@ -149,7 +150,7 @@ export const changeUserSpotFee = async function (user_id, symbol, fee_model, mak
...
@@ -149,7 +150,7 @@ export const changeUserSpotFee = async function (user_id, symbol, fee_model, mak
await
sleep
(
1000
);
await
sleep
(
1000
);
//请求撮合 修改费率
//请求撮合 修改费率
let
res
=
await
changeTradingFee
(
pair
,
user_id
,
maker_fee
,
taker_fee
,
"spot"
);
let
res
=
await
changeTradingFee
(
pair
,
user_id
,
maker_fee
,
taker_fee
,
"spot"
,
opt_market
);
return
res
.
is_success
;
return
res
.
is_success
;
};
};
...
@@ -160,6 +161,7 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model,
...
@@ -160,6 +161,7 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model,
let
is_success
=
true
;
let
is_success
=
true
;
let
product_type
=
pair
==
'all'
?
'lpc'
:
'single'
;
let
product_type
=
pair
==
'all'
?
'lpc'
:
'single'
;
let
opt_market
=
product_type
;
let
feeExist
=
await
cancelIfFeeExist
(
user_id
,
product_type
,
symbol
,
maker_fee
,
taker_fee
);
let
feeExist
=
await
cancelIfFeeExist
(
user_id
,
product_type
,
symbol
,
maker_fee
,
taker_fee
);
if
(
feeExist
)
{
if
(
feeExist
)
{
return
is_success
;
return
is_success
;
...
@@ -193,7 +195,7 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model,
...
@@ -193,7 +195,7 @@ export const changeUserContractFee = async function (user_id, symbol, fee_model,
await
sleep
(
1000
);
await
sleep
(
1000
);
//请求撮合 修改费率
//请求撮合 修改费率
let
res
=
await
changeTradingFee
(
pair
,
user_id
,
maker_fee
,
taker_fee
,
"lpc"
);
let
res
=
await
changeTradingFee
(
pair
,
user_id
,
maker_fee
,
taker_fee
,
"lpc"
,
opt_market
);
return
res
.
is_success
;
return
res
.
is_success
;
};
};
...
...
src/functional/mvc/service/commonUserFeeSetting.service.ts
View file @
102024c8
...
@@ -153,36 +153,32 @@ export async function add(commonUserFeeVO: CommonUserFeeVO, currentUserId: any,
...
@@ -153,36 +153,32 @@ export async function add(commonUserFeeVO: CommonUserFeeVO, currentUserId: any,
let
pair
=
dbInfo
.
pair
;
let
pair
=
dbInfo
.
pair
;
let
type
=
dbInfo
.
type
;
let
type
=
dbInfo
.
type
;
let
now
=
new
Date
();
let
now
=
new
Date
();
let
insertDb
List
:
any
;
let
insertDb
One
:
any
;
let
rateLog
s
=
await
buildSubmitItems
(
pair
,
dbInfo
,
now
,
dbInfo
.
user_channel
);
let
rateLog
=
await
buildSubmitItem
(
pair
,
dbInfo
,
now
,
dbInfo
.
user_channel
);
//提交到log表
//提交到log表
if
(
type
==
FEE_TYPE
.
FEE_TYPE_SPOT
)
{
if
(
type
==
FEE_TYPE
.
FEE_TYPE_SPOT
)
{
insertDbList
=
await
feeRateSpotLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDbOne
=
await
feeRateSpotLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
,
transaction
:
tx
returning
:
true
});
});
}
}
else
if
(
type
==
FEE_TYPE
.
FEE_TYPE_BASE_COIN_CONTRACT
)
{
//币本位
else
if
(
type
==
FEE_TYPE
.
FEE_TYPE_BASE_COIN_CONTRACT
)
{
//币本位
insertDbList
=
await
feeRateBaseCoinContractLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDbOne
=
await
feeRateBaseCoinContractLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
,
transaction
:
tx
returning
:
true
});
});
}
}
else
{
//U本位
else
{
//U本位
insertDbList
=
await
feeRateContractLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDbOne
=
await
feeRateContractLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
,
transaction
:
tx
returning
:
true
});
});
}
}
let
idsList
=
insertDbList
.
map
(
item
=>
item
.
id
);
let
id
=
insertDbOne
.
id
;
let
ids
=
idsList
.
length
?
idsList
.
join
(
","
)
:
""
;
await
commonUserFeeSetting
.
prototype
.
update
({
await
commonUserFeeSetting
.
prototype
.
update
({
fee_log_ids
:
id
s
,
fee_log_ids
:
id
.
toString
()
,
update_time
:
new
Date
()
update_time
:
new
Date
()
},
{
},
{
where
:
{
where
:
{
...
@@ -229,35 +225,32 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
...
@@ -229,35 +225,32 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
let
tx
;
let
tx
;
try
{
try
{
tx
=
await
ormDB
.
transaction
();
tx
=
await
ormDB
.
transaction
();
let
feeLogId
s
:
any
;
let
feeLogId
:
any
;
//这四项修改需要 重新写入 rate_log
//这四项修改需要 重新写入 rate_log
if
(
Number
(
commonUserFeeVO
.
maker_fee
)
!=
Number
(
dbInfo
.
maker_fee
)
||
Number
(
commonUserFeeVO
.
taker_fee
)
!=
Number
(
dbInfo
.
taker_fee
)
if
(
Number
(
commonUserFeeVO
.
maker_fee
)
!=
Number
(
dbInfo
.
maker_fee
)
||
Number
(
commonUserFeeVO
.
taker_fee
)
!=
Number
(
dbInfo
.
taker_fee
)
||
datetimeUtils
.
trim
(
commonUserFeeVO
.
begin_time
,
's'
).
getTime
()
!=
datetimeUtils
.
trim
(
dbInfo
.
begin_time
,
's'
).
getTime
()
||
datetimeUtils
.
trim
(
commonUserFeeVO
.
begin_time
,
's'
).
getTime
()
!=
datetimeUtils
.
trim
(
dbInfo
.
begin_time
,
's'
).
getTime
()
||
datetimeUtils
.
trim
(
commonUserFeeVO
.
expire_time
,
's'
).
getTime
()
!=
datetimeUtils
.
trim
(
dbInfo
.
expire_time
,
's'
).
getTime
())
{
||
datetimeUtils
.
trim
(
commonUserFeeVO
.
expire_time
,
's'
).
getTime
()
!=
datetimeUtils
.
trim
(
dbInfo
.
expire_time
,
's'
).
getTime
())
{
let
insertDb
List
:
any
;
let
insertDb
One
:
any
;
let
rateLog
s
=
await
buildSubmitItems
(
pair
,
commonUserFeeVO
,
new
Date
(),
Number
(
commonUserFeeVO
.
user_channel
));
let
rateLog
=
await
buildSubmitItem
(
pair
,
commonUserFeeVO
,
new
Date
(),
Number
(
commonUserFeeVO
.
user_channel
));
//提交到log表
//提交到log表
if
(
type
==
FEE_TYPE
.
FEE_TYPE_SPOT
)
{
if
(
type
==
FEE_TYPE
.
FEE_TYPE_SPOT
)
{
insertDbList
=
await
feeRateSpotLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDbOne
=
await
feeRateSpotLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
,
transaction
:
tx
returning
:
true
});
});
}
}
else
if
(
type
==
FEE_TYPE
.
FEE_TYPE_BASE_COIN_CONTRACT
)
{
//币本位
else
if
(
type
==
FEE_TYPE
.
FEE_TYPE_BASE_COIN_CONTRACT
)
{
//币本位
insertDbList
=
await
feeRateBaseCoinContractLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDbOne
=
await
feeRateBaseCoinContractLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
,
transaction
:
tx
returning
:
true
});
});
}
}
else
{
//U本位
else
{
//U本位
insertDbList
=
await
feeRateContractLog
.
prototype
.
bulkCreate
(
rateLogs
,
{
insertDbOne
=
await
feeRateContractLog
.
prototype
.
create
(
rateLog
,
{
transaction
:
tx
,
transaction
:
tx
returning
:
true
});
});
}
}
let
idsList
=
insertDbList
.
map
(
item
=>
item
.
id
);
feeLogId
s
=
idsList
.
length
?
idsList
.
join
(
","
)
:
dbInfo
.
fee_log_ids
;
feeLogId
=
insertDbOne
.
id
;
}
}
...
@@ -272,7 +265,7 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
...
@@ -272,7 +265,7 @@ export async function update(commonUserFeeVO: CommonUserFeeVO, currentUserId: an
amount_require_usdt
:
commonUserFeeVO
.
amount_require_usdt
,
amount_require_usdt
:
commonUserFeeVO
.
amount_require_usdt
,
applicant
:
commonUserFeeVO
.
applicant
,
applicant
:
commonUserFeeVO
.
applicant
,
update_time
:
new
Date
(),
update_time
:
new
Date
(),
fee_log_ids
:
feeLogIds
,
fee_log_ids
:
feeLogId
?
feeLogId
.
toString
()
:
dbInfo
.
fee_log_id
s
,
},
{
},
{
where
:
{
where
:
{
id
:
Number
(
commonUserFeeVO
.
id
)
id
:
Number
(
commonUserFeeVO
.
id
)
...
@@ -469,27 +462,10 @@ async function getDbFeeSetting(user_id: number | any, type: number | any, user_c
...
@@ -469,27 +462,10 @@ async function getDbFeeSetting(user_id: number | any, type: number | any, user_c
return
dbInfo
;
return
dbInfo
;
}
}
async
function
buildSubmitItems
(
pair
:
string
,
dbInfo
:
any
,
now
:
Date
,
user_channel
:
number
)
{
async
function
buildSubmitItem
(
pair
:
string
,
dbInfo
:
any
,
now
:
Date
,
user_channel
:
number
)
{
let
type
=
Number
(
dbInfo
.
type
);
let
submitItems
:
any
=
[];
let
pairs
:
any
=
[];
//全部交易对时需要查询交易对表
if
(
pair
==
'all'
)
{
//现货
if
(
type
==
FEE_TYPE
.
FEE_TYPE_SPOT
)
{
pairs
=
await
getAllSpotPairs
();
}
else
{
//合约 这里目前查询的是 contract_pairs 如果之后 币本位的交易对有单独的表 需要修改此处代码
pairs
=
await
getAllContractPairs
();
}
}
else
{
pairs
.
push
(
pair
);
}
for
(
let
onePair
of
pairs
)
{
let
item
=
{
let
item
=
{
user_id
:
dbInfo
.
user_id
,
user_id
:
dbInfo
.
user_id
,
pair
:
oneP
air
,
pair
:
p
air
,
fee_model
:
FEE_MODEL_SPOT_DEFAULT
,
fee_model
:
FEE_MODEL_SPOT_DEFAULT
,
maker_fee
:
dbInfo
.
maker_fee
,
maker_fee
:
dbInfo
.
maker_fee
,
taker_fee
:
dbInfo
.
taker_fee
,
taker_fee
:
dbInfo
.
taker_fee
,
...
@@ -511,9 +487,7 @@ async function buildSubmitItems(pair: string, dbInfo: any, now: Date, user_chann
...
@@ -511,9 +487,7 @@ async function buildSubmitItems(pair: string, dbInfo: any, now: Date, user_chann
item
.
comment
=
COMMENT_USER_FEE_SUBMIT
item
.
comment
=
COMMENT_USER_FEE_SUBMIT
}
}
submitItems
.
push
(
item
);
return
item
;
}
return
submitItems
;
}
}
async
function
checkSpotPair
(
pair
:
string
)
{
async
function
checkSpotPair
(
pair
:
string
)
{
...
...
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