Commit 6f79f66b authored by ml's avatar ml

systemTrigger cron 修改

parent 7787904b
......@@ -80,23 +80,24 @@ export const getExPairUnTriggers = async function () {
}
export const doExPairTrigger = async function (trigId: any, pair: string, action: any) {
let rtn:any = false;
let rtn: any = false;
try {
let dbPair:any;
if (pair.endsWith("_SWAP")){
let dbPair: any;
if (pair.endsWith("_SWAP")) {
dbPair = await contractPairs.prototype.findOne({
where:{
symbol:pair
where: {
symbol: pair
},
raw:true
}) ;
}else {
raw: true
});
}
else {
dbPair = await spotPairs.prototype.findOne({
where:{
symbol:pair
where: {
symbol: pair
},
raw:true
}) ;
raw: true
});
}
if (!dbPair) {
......@@ -131,18 +132,19 @@ export const doExPairTrigger = async function (trigId: any, pair: string, action
try {
console.log('start transaction');
t = await ormDB.transaction();
if (pair.endsWith("_SWAP")){
await contractPairs.prototype.update(target_value,{
where:{
id:dbPair.id
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
});
}
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();
......@@ -237,8 +239,42 @@ export const doCoinTypeTrigger = async function (trigId: any, coinSymbol: any, a
export const updateRedisPairs = async function () {
console.log('updateRedisPairs');
try {
//let list = await exPair.prototype.findAll({ where: { is_active: 1 } });
// redisUtilsCommon.writeSync(KEY_PAIR_LIST, JSON.stringify(list));
let task1 = spotPairs.prototype.findAll({
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) {
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