feat: 支持币种
This commit is contained in:
@@ -9,6 +9,23 @@ const { deriveNewAccount } = require('../../utils/account');
|
|||||||
const actionFilter = 'id type amount detail op createdAt';
|
const actionFilter = 'id type amount detail op createdAt';
|
||||||
const { inject } = require('../../common/Provider');
|
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 = {
|
module.exports = {
|
||||||
async getFundDetail (req, res) {
|
async getFundDetail (req, res) {
|
||||||
const { userId } = res.locals.user;
|
const { userId } = res.locals.user;
|
||||||
@@ -59,24 +76,9 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
async getSupportCoinsList (req, res) {
|
async getSupportCoinsList (req, res) {
|
||||||
// eslint-disable-next-line no-undef
|
// 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({
|
return res.json({
|
||||||
code: 0,
|
code: 0,
|
||||||
data: coinList
|
data: depositCoinsList
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async withdraw (req, res) {
|
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) {
|
async refreshFund (req, res) {
|
||||||
// todo: 要求刷新程序去刷新
|
// todo: 要求刷新程序去刷新
|
||||||
|
|||||||
@@ -42,6 +42,13 @@ const FundSchema = new mongoose.Schema({
|
|||||||
lastDeposit: {
|
lastDeposit: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
|
lastWithdraw: {
|
||||||
|
type: {},
|
||||||
|
default: {
|
||||||
|
usdt: '',
|
||||||
|
vic: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
option: {
|
option: {
|
||||||
type: {}
|
type: {}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ const services = [
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
controller: controller.getActionDetail
|
controller: controller.getActionDetail
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
url: '/withdrawCoins',
|
||||||
|
method: 'GET',
|
||||||
|
controller: controller.getWithdrawCoinsList
|
||||||
|
},
|
||||||
{
|
{
|
||||||
url: '/depositCoins',
|
url: '/depositCoins',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
|||||||
Reference in New Issue
Block a user