Commit 6f79f66b authored by ml's avatar ml

systemTrigger cron 修改

parent 7787904b
...@@ -80,23 +80,24 @@ export const getExPairUnTriggers = async function () { ...@@ -80,23 +80,24 @@ export const getExPairUnTriggers = async function () {
} }
export const doExPairTrigger = async function (trigId: any, pair: string, action: any) { export const doExPairTrigger = async function (trigId: any, pair: string, action: any) {
let rtn:any = false; let rtn: any = false;
try { try {
let dbPair:any; let dbPair: any;
if (pair.endsWith("_SWAP")){ if (pair.endsWith("_SWAP")) {
dbPair = await contractPairs.prototype.findOne({ dbPair = await contractPairs.prototype.findOne({
where:{ where: {
symbol:pair symbol: pair
}, },
raw:true raw: true
}) ; });
}else { }
else {
dbPair = await spotPairs.prototype.findOne({ dbPair = await spotPairs.prototype.findOne({
where:{ where: {
symbol:pair symbol: pair
}, },
raw:true raw: true
}) ; });
} }
if (!dbPair) { if (!dbPair) {
...@@ -131,18 +132,19 @@ export const doExPairTrigger = async function (trigId: any, pair: string, action ...@@ -131,18 +132,19 @@ export const doExPairTrigger = async function (trigId: any, pair: string, action
try { try {
console.log('start transaction'); console.log('start transaction');
t = await ormDB.transaction(); t = await ormDB.transaction();
if (pair.endsWith("_SWAP")){ if (pair.endsWith("_SWAP")) {
await contractPairs.prototype.update(target_value,{ await contractPairs.prototype.update(target_value, {
where:{ where: {
id:dbPair.id id: dbPair.id
}, },
}) ; });
}else { }
await contractPairs.prototype.update(target_value,{ else {
where:{ await contractPairs.prototype.update(target_value, {
id:dbPair.id where: {
id: dbPair.id
}, },
}) ; });
} }
await systemTrigger.prototype.update({ status: TRIGGER_STATUS_SUCCESS }, { where: { id: trigId, status: 0 }, transaction: t }); await systemTrigger.prototype.update({ status: TRIGGER_STATUS_SUCCESS }, { where: { id: trigId, status: 0 }, transaction: t });
await t.commit(); await t.commit();
...@@ -237,8 +239,42 @@ export const doCoinTypeTrigger = async function (trigId: any, coinSymbol: any, a ...@@ -237,8 +239,42 @@ export const doCoinTypeTrigger = async function (trigId: any, coinSymbol: any, a
export const updateRedisPairs = async function () { export const updateRedisPairs = async function () {
console.log('updateRedisPairs'); console.log('updateRedisPairs');
try { try {
//let list = await exPair.prototype.findAll({ where: { is_active: 1 } }); let task1 = spotPairs.prototype.findAll({
// redisUtilsCommon.writeSync(KEY_PAIR_LIST, JSON.stringify(list)); where: {
is_active: 1
},
raw: true,
});
let task2 = contractPairs.prototype.findAll({
where: {
is_active: 1
},
raw: true,
});
let [spotList, contractList] = await Promise.all([task1, task2]);
let list: any = [];
for (let item of spotList) {
let temp = {
id: item.id,
pair: item.symbol,
is_hide: item.is_hide,
decimal: item.price_scale,
amount_scale: item.quantity_scale,
}
list.push(temp);
}
for (let item of contractList) {
let temp = {
id: item.id,
pair: item.symbol,
is_hide: item.is_hide,
decimal: item.price_scale,
amount_scale: item.quantity_scale,
}
list.push(temp);
}
redisUtilsCommon.writeSync(KEY_PAIR_LIST, JSON.stringify(list));
} }
catch (e) { catch (e) {
console.error(e); console.error(e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment