Commit 7787904b authored by ml's avatar ml

systemTrigger cron 修改

parent f84ae4ca
'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')
......@@ -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;
try {
//TODO:目前交易对 没有激活 隐藏相关字段了 之后有的话 再补充
//let pair = await exPair.prototype.findOne({ where: { pair: ex_pair }, raw: true });
let pair = null;
if (!pair) {
let dbPair:any;
if (pair.endsWith("_SWAP")){
dbPair = await contractPairs.prototype.findOne({
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 } });
rtn = false;
......@@ -117,8 +131,19 @@ export const doExPairTrigger = async function (trigId: any, ex_pair: any, action
try {
console.log('start transaction');
t = await ormDB.transaction();
//TODO: 目前交易对 没有激活 隐藏相关字段了 之后有的话 再补充
//await exPair.prototype.update(target_value, { where: { pair: ex_pair }, transaction: t });
if (pair.endsWith("_SWAP")){
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 t.commit();
rtn = true;
......@@ -212,7 +237,6 @@ export const doCoinTypeTrigger = async function (trigId: any, coinSymbol: any, a
export const updateRedisPairs = async function () {
console.log('updateRedisPairs');
try {
//TODO:没有了
//let list = await exPair.prototype.findAll({ where: { is_active: 1 } });
// 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