feat: 支持币种
This commit is contained in:
@@ -9,6 +9,23 @@ const { deriveNewAccount } = require('../../utils/account');
|
||||
const actionFilter = 'id type amount detail op createdAt';
|
||||
const { inject } = require('../../common/Provider');
|
||||
|
||||
const depositCoinsList = [{
|
||||
id: 'usdtBTC',
|
||||
label: 'usdtBTC',
|
||||
}, {
|
||||
id: 'usdtETH',
|
||||
label: 'usdtETH',
|
||||
}];
|
||||
const withdrawCoinsList = [{
|
||||
id: 'vic',
|
||||
label: 'vic',
|
||||
fee: 0.005
|
||||
}, {
|
||||
id: 'usdt',
|
||||
label: 'usdt',
|
||||
fee: 0.005
|
||||
}];
|
||||
|
||||
module.exports = {
|
||||
async getFundDetail (req, res) {
|
||||
const { userId } = res.locals.user;
|
||||
@@ -59,24 +76,9 @@ module.exports = {
|
||||
},
|
||||
async getSupportCoinsList (req, res) {
|
||||
// eslint-disable-next-line no-undef
|
||||
let coinList;
|
||||
try {
|
||||
// eslint-disable-next-line no-undef
|
||||
coinList = await Provider.getModule('System').getValue('supportCoins');
|
||||
} catch (error) {
|
||||
coinList = [{
|
||||
id: 'vic',
|
||||
label: 'vic',
|
||||
fee: 0.005
|
||||
}, {
|
||||
id: 'usdt',
|
||||
label: 'usdt',
|
||||
fee: 0.005
|
||||
}];
|
||||
}
|
||||
return res.json({
|
||||
code: 0,
|
||||
data: coinList
|
||||
data: depositCoinsList
|
||||
});
|
||||
},
|
||||
async withdraw (req, res) {
|
||||
@@ -163,7 +165,18 @@ module.exports = {
|
||||
});
|
||||
};
|
||||
}),
|
||||
|
||||
async getWithdrawCoinsList (req, res) {
|
||||
const { userId } = res.locals.user;
|
||||
const userFund = await Fund.findOne({userId}).exec();
|
||||
const asset = userFund.asset;
|
||||
const list = [];
|
||||
(asset['vic'] >= 1000) && list.push(withdrawCoinsList[0]);
|
||||
(!userFund.lastWithdraw.usdt || (new Date() - new Date(userFund.lastWithdraw.usdt)) / (1000 * 3600 * 24 * 7) >= 1) && list.push(withdrawCoinsList[1]);
|
||||
return res.json({
|
||||
code: 0,
|
||||
data: list
|
||||
});
|
||||
},
|
||||
// 查询资金,直接拉数据库,区块链的查询交给定时任务
|
||||
async refreshFund (req, res) {
|
||||
// todo: 要求刷新程序去刷新
|
||||
|
||||
Reference in New Issue
Block a user