Commit 7787904b authored by ml's avatar ml

systemTrigger cron 修改

parent f84ae4ca
'use strict'; 'use strict';
import { ormDB, coinType, systemTrigger } from "@madex/ex-ts-dao"; import { ormDB, coinType, systemTrigger, contractPairs, spotPairs } from "@madex/ex-ts-dao";
let { redisUtilsCommon } = require('@madex/ex-js-common') let { redisUtilsCommon } = require('@madex/ex-js-common')
...@@ -79,13 +79,27 @@ export const getExPairUnTriggers = async function () { ...@@ -79,13 +79,27 @@ export const getExPairUnTriggers = async function () {
} }
export const doExPairTrigger = async function (trigId: any, ex_pair: any, action: any) { export const doExPairTrigger = async function (trigId: any, pair: string, action: any) {
let rtn:any = false; let rtn:any = false;
try { try {
//TODO:目前交易对 没有激活 隐藏相关字段了 之后有的话 再补充 let dbPair:any;
//let pair = await exPair.prototype.findOne({ where: { pair: ex_pair }, raw: true }); if (pair.endsWith("_SWAP")){
let pair = null; dbPair = await contractPairs.prototype.findOne({
if (!pair) { where:{
symbol:pair
},
raw:true
}) ;
}else {
dbPair = await spotPairs.prototype.findOne({
where:{
symbol:pair
},
raw:true
}) ;
}
if (!dbPair) {
//交易对不存在,标记触发失败 //交易对不存在,标记触发失败
await systemTrigger.prototype.update({ status: TRIGGER_STATUS_FAIL }, { where: { id: trigId, status: 0 } }); await systemTrigger.prototype.update({ status: TRIGGER_STATUS_FAIL }, { where: { id: trigId, status: 0 } });
rtn = false; rtn = false;
...@@ -117,8 +131,19 @@ export const doExPairTrigger = async function (trigId: any, ex_pair: any, action ...@@ -117,8 +131,19 @@ export const doExPairTrigger = async function (trigId: any, ex_pair: any, action
try { try {
console.log('start transaction'); console.log('start transaction');
t = await ormDB.transaction(); t = await ormDB.transaction();
//TODO: 目前交易对 没有激活 隐藏相关字段了 之后有的话 再补充 if (pair.endsWith("_SWAP")){
//await exPair.prototype.update(target_value, { where: { pair: ex_pair }, transaction: t }); await contractPairs.prototype.update(target_value,{
where:{
id:dbPair.id
},
}) ;
}else {
await contractPairs.prototype.update(target_value,{
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();
rtn = true; rtn = true;
...@@ -212,7 +237,6 @@ export const doCoinTypeTrigger = async function (trigId: any, coinSymbol: any, a ...@@ -212,7 +237,6 @@ 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 {
//TODO:没有了
//let list = await exPair.prototype.findAll({ where: { is_active: 1 } }); //let list = await exPair.prototype.findAll({ where: { is_active: 1 } });
// redisUtilsCommon.writeSync(KEY_PAIR_LIST, JSON.stringify(list)); // redisUtilsCommon.writeSync(KEY_PAIR_LIST, JSON.stringify(list));
} }
......
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