|
@@ -250,10 +250,34 @@ async function tryExecuteAfkTask() {
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (retConfig.data.hasNotice) {
|
|
|
|
|
- magicJS.notification.appendNotifyInfo(retConfig.data.noticeContent);
|
|
|
|
|
|
|
+ let configData = retConfig.data;
|
|
|
|
|
+ if (configData.hasNotice) {
|
|
|
|
|
+ magicJS.notification.appendNotifyInfo(configData.noticeContent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ let monitorTip = ``;
|
|
|
|
|
+ if (configData.runStatus == 1) {
|
|
|
|
|
+ if (configData.maxQuantity && configData.maxQuantity > 0) {
|
|
|
|
|
+ monitorTip = `${configData.occNodeNum}个账号正在监控中, 当前1号${configData.maxQuantity || 0}单`;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ monitorTip = `${configData.occNodeNum}个账号正在监控中`;
|
|
|
|
|
+ }
|
|
|
|
|
+ magicJS.logger.info(monitorTip);
|
|
|
|
|
+ magicJS.notification.appendNotifyInfo(monitorTip);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ monitorTip = `当前未开启监控`;
|
|
|
|
|
+ magicJS.logger.info(monitorTip);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (configData.runStatus == 1 && configData.occNodeNum >= configData.xmNodeNum) {
|
|
|
|
|
+ magicJS.logger.info(`检测是否存在待支付订单...`);
|
|
|
|
|
+ await checkExistOrderNoPay();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ magicJS.logger.info(`检测启动最大账号数监控任务...`);
|
|
|
|
|
+ await checkAutoStartMonitorTask(configData);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function checkAutoStartMonitorTask(configData) {
|
|
|
let retAccList = await listValidXmAccount();
|
|
let retAccList = await listValidXmAccount();
|
|
|
if (!retAccList || retAccList.code != 0) {
|
|
if (!retAccList || retAccList.code != 0) {
|
|
|
magicJS.logger.info(`获取账号列表数据失败!`);
|
|
magicJS.logger.info(`获取账号列表数据失败!`);
|
|
@@ -265,10 +289,11 @@ async function tryExecuteAfkTask() {
|
|
|
await checkAutoRefreshAddress();
|
|
await checkAutoRefreshAddress();
|
|
|
|
|
|
|
|
let accountList = retAccList.data;
|
|
let accountList = retAccList.data;
|
|
|
|
|
+ accountList.reverse();
|
|
|
accountList.sort((a, b) => {
|
|
accountList.sort((a, b) => {
|
|
|
return a.orderedQuantity - b.orderedQuantity;
|
|
return a.orderedQuantity - b.orderedQuantity;
|
|
|
});
|
|
});
|
|
|
- magicJS.logger.info(`账号列表:\n` + JSON.stringify(accountList, null, 4));
|
|
|
|
|
|
|
+ magicJS.logger.info(`可用账号列表:\n` + JSON.stringify(accountList, null, 4));
|
|
|
let taskAccIds = [];
|
|
let taskAccIds = [];
|
|
|
let maxTaskCount = retConfig?.data?.xmNodeNum || 3;
|
|
let maxTaskCount = retConfig?.data?.xmNodeNum || 3;
|
|
|
let lastEndInex = Math.min(maxTaskCount, accountList.length);
|
|
let lastEndInex = Math.min(maxTaskCount, accountList.length);
|
|
@@ -277,7 +302,8 @@ async function tryExecuteAfkTask() {
|
|
|
let notLoingLst = [];
|
|
let notLoingLst = [];
|
|
|
for (let i = 0; i < lastEndInex; i++) {
|
|
for (let i = 0; i < lastEndInex; i++) {
|
|
|
let accountInfo = accountList[i];
|
|
let accountInfo = accountList[i];
|
|
|
- if (accountInfo.realTimeStatus) {
|
|
|
|
|
|
|
+ if (accountInfo.realTimeStatus && accountInfo.oldLink != 1) {
|
|
|
|
|
+ // oldLink: 选择了红色字体标记的账号,可能会没单,因为当前有这种账号最近下过单的老链接在,会被平台限购
|
|
|
startedLst.push(accountInfo);
|
|
startedLst.push(accountInfo);
|
|
|
} else {
|
|
} else {
|
|
|
if (accountInfo.enable == 1 && (accountInfo.loginStatus != 1 && accountInfo.loginStatus != 2)) {
|
|
if (accountInfo.enable == 1 && (accountInfo.loginStatus != 1 && accountInfo.loginStatus != 2)) {
|
|
@@ -307,19 +333,25 @@ async function tryExecuteAfkTask() {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- let retStart = await startTask(taskAccIds);
|
|
|
|
|
- if (retStart && retStart.code == 0) {
|
|
|
|
|
- startedLst = startedLst.concat(willStartLst);
|
|
|
|
|
- let resData = retStart.data;
|
|
|
|
|
- let taskRetText = `任务结果概览:\n`;
|
|
|
|
|
- taskRetText += `新增:${resData.addCount}\n`;
|
|
|
|
|
- taskRetText += `关闭:${resData.closeCount}\n`;
|
|
|
|
|
- taskRetText += `失败:${resData.failCount}\n`;
|
|
|
|
|
- taskRetText += `现存账号数:${resData.occNodeNum}\n`;
|
|
|
|
|
- magicJS.logger.info(taskRetText);
|
|
|
|
|
- msgTipsText = taskRetText + '\n';
|
|
|
|
|
|
|
+ let nowTimeStr = magicJS.formatDate(new Date(), 'HH:mm:ss');
|
|
|
|
|
+ if (nowTimeStr >= configData.startTime && nowTimeStr <= configData.endTime) {
|
|
|
|
|
+ let retStart = await startTask(taskAccIds);
|
|
|
|
|
+ if (retStart && retStart.code == 0) {
|
|
|
|
|
+ startedLst = startedLst.concat(willStartLst);
|
|
|
|
|
+ let resData = retStart.data;
|
|
|
|
|
+ let taskRetText = `任务结果概览:\n`;
|
|
|
|
|
+ taskRetText += `新增:${resData.addCount}\n`;
|
|
|
|
|
+ taskRetText += `关闭:${resData.closeCount}\n`;
|
|
|
|
|
+ taskRetText += `失败:${resData.failCount}\n`;
|
|
|
|
|
+ taskRetText += `现存账号数:${resData.occNodeNum}\n`;
|
|
|
|
|
+ magicJS.logger.info(taskRetText);
|
|
|
|
|
+ msgTipsText = taskRetText + '\n';
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msgTipsText += `当前时间不在运行时间段内,不执行任务!\n`;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
let retFastData = await getCommonFastTrackAccount();
|
|
let retFastData = await getCommonFastTrackAccount();
|
|
|
if (!retFastData || retFastData.code != 0) {
|
|
if (!retFastData || retFastData.code != 0) {
|
|
|
magicJS.logger.info(`获取神秘空间账号列表数据失败!`);
|
|
magicJS.logger.info(`获取神秘空间账号列表数据失败!`);
|
|
@@ -338,14 +370,19 @@ async function tryExecuteAfkTask() {
|
|
|
}
|
|
}
|
|
|
let retSet = await setCommonFastTrackAccount(accountInfo.xmAccount);
|
|
let retSet = await setCommonFastTrackAccount(accountInfo.xmAccount);
|
|
|
if (retSet && retSet.code == 0) {
|
|
if (retSet && retSet.code == 0) {
|
|
|
|
|
+ msgTipsText += `账号[${accountInfo.xmAccount}}]神秘空间添加成功\n`;
|
|
|
left -= 1;
|
|
left -= 1;
|
|
|
if (left <= 0) {
|
|
if (left <= 0) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msgTipsText += `账号[${accountInfo.xmAccount}}]神秘空间添加失败\n`;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- magicJS.notification.appendNotifyInfo(msgTipsText);
|
|
|
|
|
|
|
+ if (msgTipsText.length > 0) {
|
|
|
|
|
+ magicJS.notification.appendNotifyInfo(msgTipsText);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function doLogin(username, password) {
|
|
async function doLogin(username, password) {
|
|
@@ -469,6 +506,33 @@ async function startTask(ids) {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+async function saveGroupAccountChild(groupId, idArray) {
|
|
|
|
|
+ const url = `https://mo.10coo.com/saveGroupAccountChild`;
|
|
|
|
|
+ let reqData = {
|
|
|
|
|
+ groupId: groupId,
|
|
|
|
|
+ xmAccountIds: idArray.join(','),
|
|
|
|
|
+ };
|
|
|
|
|
+ let options = {
|
|
|
|
|
+ url: url,
|
|
|
|
|
+ headers: gCommonHeaders,
|
|
|
|
|
+ body: magicJS.objToQueryStr(reqData),
|
|
|
|
|
+ };
|
|
|
|
|
+ let result = await magicJS.http.post(options).then(response => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ let rspData = response.body;
|
|
|
|
|
+ magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
|
|
|
+ return rspData;
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ magicJS.logger.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ const msg = `提交动态调整设置异常\n${JSON.stringify(err)}`;
|
|
|
|
|
+ magicJS.logger.error(msg);
|
|
|
|
|
+ });
|
|
|
|
|
+ return result;
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
async function getCommonFastTrackAccount() {
|
|
async function getCommonFastTrackAccount() {
|
|
|
const url = `https://mo.10coo.com/getCommonFastTrackAccount`;
|
|
const url = `https://mo.10coo.com/getCommonFastTrackAccount`;
|
|
@@ -826,6 +890,46 @@ async function editAccount(xmAccountId, xmAccount, xmPassword, alias) {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+function expireDateFormat(date) {
|
|
|
|
|
+ if (!date) {
|
|
|
|
|
+ return "未知";
|
|
|
|
|
+ }
|
|
|
|
|
+ let currentTime = new Date();
|
|
|
|
|
+ // 获取订单时间
|
|
|
|
|
+ let orderTime = new Date(date);
|
|
|
|
|
+ // 将当前时间增加30分钟
|
|
|
|
|
+ let expirationTime = new Date(orderTime.getTime() + 30 * 60 * 1000);
|
|
|
|
|
+ // 计算剩余时间(以毫秒为单位)
|
|
|
|
|
+ let remainingTime = expirationTime - currentTime;
|
|
|
|
|
+ // 将剩余时间转换为分钟和秒数
|
|
|
|
|
+ let remainingMinutes = Math.floor(remainingTime / 1000 / 60);
|
|
|
|
|
+ let remainingSeconds = Math.floor((remainingTime / 1000) % 60);
|
|
|
|
|
+ if (remainingSeconds < 0) {
|
|
|
|
|
+ return "可能已过期";
|
|
|
|
|
+ }
|
|
|
|
|
+ // 输出剩余时间
|
|
|
|
|
+ if (remainingMinutes === 0) {
|
|
|
|
|
+ return remainingSeconds + "秒后过期";
|
|
|
|
|
+ }
|
|
|
|
|
+ return remainingMinutes + "分" + remainingSeconds + "秒后过期";
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function checkExistOrderNoPay() {
|
|
|
|
|
+ let retOrderList = await queryToBePaidStatusOrderList();
|
|
|
|
|
+ if (retOrderList && retOrderList.code == 0) {
|
|
|
|
|
+ let orderList = retOrderList.data;
|
|
|
|
|
+ for (let i = 0; i < orderList.length; i++) {
|
|
|
|
|
+ let d = list[i];
|
|
|
|
|
+ let xmAccount = d.xmAccount;
|
|
|
|
|
+ let alias = d.alias ? "(" + d.alias + ")" : "";
|
|
|
|
|
+ let expireStr = (d.orderTime ? expireDateFormat(d.orderTime) : expireDateFormat(d.createTime));
|
|
|
|
|
+ let goodsStr = d.goodsName + d.skuStr;
|
|
|
|
|
+ let priceStr = `¥${d.amount}`;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
async function queryToBePaidStatusOrderList() {
|
|
async function queryToBePaidStatusOrderList() {
|
|
|
const url = `https://mo.10coo.com/order/queryToBePaidStatusOrderList`;
|
|
const url = `https://mo.10coo.com/order/queryToBePaidStatusOrderList`;
|
|
|
let options = {
|
|
let options = {
|
|
@@ -848,6 +952,65 @@ async function queryToBePaidStatusOrderList() {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+async function doPayResultCheck(id) {
|
|
|
|
|
+ let ret = await queryOfficialStatus(id);
|
|
|
|
|
+ if (ret && ret.code == 0) {
|
|
|
|
|
+ ret = await checkPayResult(id);
|
|
|
|
|
+ return ret;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function queryOfficialStatus(id) {
|
|
|
|
|
+ const url = `https://mo.10coo.com/order/queryOfficialStatus?orderId=${id}`;
|
|
|
|
|
+ let options = {
|
|
|
|
|
+ url: url,
|
|
|
|
|
+ headers: gCommonHeaders,
|
|
|
|
|
+ body: ``,
|
|
|
|
|
+ };
|
|
|
|
|
+ let result = await magicJS.http.get(options).then(response => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ let rspData = response.body;
|
|
|
|
|
+ magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
|
|
|
+ return rspData;
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ magicJS.logger.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ const msg = `检测支付结果异常\n${JSON.stringify(err)}`;
|
|
|
|
|
+ magicJS.logger.error(msg);
|
|
|
|
|
+ });
|
|
|
|
|
+ return result;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function checkPayResult(id) {
|
|
|
|
|
+ const url = `https://mo.10coo.com/order/batchQueryOrderStatus?orderIds=${id}`;
|
|
|
|
|
+ let options = {
|
|
|
|
|
+ url: url,
|
|
|
|
|
+ headers: gCommonHeaders,
|
|
|
|
|
+ body: ``,
|
|
|
|
|
+ };
|
|
|
|
|
+ let result = await magicJS.http.get(options).then(response => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ let rspData = response.body;
|
|
|
|
|
+ magicJS.logger.info(`rspData=${JSON.stringify(rspData)}`);
|
|
|
|
|
+ if (rspData.data[0][1] == 1 || rspData.data[0][1] == 2 || rspData.data[0][1] == 3 || rspData.data[0][1] == 4) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else if (rspData.data[0][1] == -3 || rspData.data[0][1] == 0) {
|
|
|
|
|
+ magicJS.logger.info(`未检测到支付`);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ magicJS.logger.error(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ const msg = `检测支付结果异常\n${JSON.stringify(err)}`;
|
|
|
|
|
+ magicJS.logger.error(msg);
|
|
|
|
|
+ });
|
|
|
|
|
+ return result;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
Main().catch((e) => magicJS.logger.log(`-\n ${e}`)).finally(() => magicJS.done());
|
|
Main().catch((e) => magicJS.logger.log(`-\n ${e}`)).finally(() => magicJS.done());
|
|
|
|
|
|
|
|
|
|
|