feat: 支持币种

This commit is contained in:
chaosBreaking
2019-09-07 17:17:07 +08:00
parent 1326023832
commit 73d354f138
3 changed files with 42 additions and 17 deletions

View File

@@ -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: 要求刷新程序去刷新

View File

@@ -42,6 +42,13 @@ const FundSchema = new mongoose.Schema({
lastDeposit: {
type: String
},
lastWithdraw: {
type: {},
default: {
usdt: '',
vic: ''
}
},
option: {
type: {}
},

View File

@@ -17,6 +17,11 @@ const services = [
method: 'GET',
controller: controller.getActionDetail
},
{
url: '/withdrawCoins',
method: 'GET',
controller: controller.getWithdrawCoinsList
},
{
url: '/depositCoins',
method: 'GET',