shawenguan 1 рік тому
батько
коміт
050058e23f
1 змінених файлів з 26 додано та 21 видалено
  1. 26 21
      Scripts/mangguo/nenMoScript.js

+ 26 - 21
Scripts/mangguo/nenMoScript.js

@@ -212,8 +212,14 @@ function handleOrderList() {
 }
 
 async function tryExecuteAfkTask() {
+    let username = '10191';
+    let password = 'Sjojo510520';
+    await doExecuteUserAfkTask(username, password);
+}
+
+async function doExecuteUserAfkTask(username, password) {
     let needReLogin = false;
-    let cookieStr = magicJS.data.read(MoConstKey.Cookie, ``);
+    let cookieStr = magicJS.data.read(`${MoConstKey.Cookie}#${username}`, ``);
     // magicJS.logger.info(`cookieStr:${cookieStr}`);
     if (cookieStr && cookieStr.length > 0) {
         let cookieDict = magicJS.parseCookies(cookieStr);
@@ -233,8 +239,7 @@ async function tryExecuteAfkTask() {
     } else {
         needReLogin = true;
     }
-    let username = '10191';
-    let password = 'Sjojo510520';
+    gCommonHeaders['Cookie'] = cookieStr;
     if (needReLogin) {
         let retLogin = await doLogin(username, password);
         if (!retLogin || retLogin.code != 0) {
@@ -283,18 +288,18 @@ async function tryExecuteAfkTask() {
     let nowTimeStr = magicJS.formatDate(new Date(), 'HH:mm:ss');
     if (configData.runStatus == 1 && (configData.occNodeNum >= configData.xmNodeNum || nowTimeStr >= configData.endTime)) {
         magicJS.logger.info(`正在检测是否存在待支付订单...`);
-        await checkExistOrderNoPay();
+        await checkExistOrderNoPay(username);
     } else {
         magicJS.logger.info(`正在启动最大账号数监控任务...`);
-        await checkAutoStartMonitorTask(configData);
+        await checkAutoStartMonitorTask(username, configData);
     }
 }
 
-async function checkAutoStartMonitorTask(configData) {
+async function checkAutoStartMonitorTask(username, configData) {
     let retAccList = await listValidXmAccount();
     if (!retAccList || retAccList.code != 0) {
-        magicJS.logger.info(`获取账号列表数据失败!`);
-        magicJS.notification.appendNotifyInfo(`获取账号列表数据失败!`);
+        magicJS.logger.info(`嫩模[${username}]获取账号列表数据失败!`);
+        magicJS.notification.appendNotifyInfo(`嫩模[${username}]获取账号列表数据失败!`);
         return;
     }
 
@@ -306,7 +311,7 @@ async function checkAutoStartMonitorTask(configData) {
     accountList.sort((a, b) => {
         return a.orderedQuantity - b.orderedQuantity;
     });
-    magicJS.logger.info(`可用账号列表:\n` + JSON.stringify(accountList, null, 4));
+    magicJS.logger.info(`嫩模[${username}]下可用账号列表:\n` + JSON.stringify(accountList, null, 4));
     let taskAccIds = [];
     let maxTaskCount = configData.xmNodeNum || 3;
     let lastEndInex = Math.min(maxTaskCount, accountList.length);
@@ -335,19 +340,19 @@ async function checkAutoStartMonitorTask(configData) {
     if (taskAccIds.length > 0) {
         let retCheck = await preStartTask();
         if (!retCheck) {
-            magicJS.notification.appendNotifyInfo(`任务启动环境检查失败!`);
+            magicJS.notification.appendNotifyInfo(`嫩模[${username}]任务启动环境检查失败!`);
             return;
         }
         if (retCheck) {
             if (retCheck.code == 0) {
-                magicJS.logger.info(`任务启动环境检查成功!`);
+                magicJS.logger.info(`嫩模[${username}]任务启动环境检查成功!`);
             } else {
-                magicJS.logger.info(retCheck.message);
-                magicJS.notification.appendNotifyInfo(retCheck.message);
+                magicJS.logger.info(`嫩模[${username}]${retCheck.message}`);
+                magicJS.notification.appendNotifyInfo(`嫩模[${username}]${retCheck.message}`);
                 return;
             }
         }
-        htmlContent += `<h1><strong><span style="text-align: center;">监控信息</span></strong></h1>`;
+        htmlContent += `<h1><strong><span style="text-align: center;">嫩模[${username}]的监控信息</span></strong></h1>`;
         let nowTimeStr = magicJS.formatDate(new Date(), 'HH:mm:ss');
         if (nowTimeStr >= configData.startTime && nowTimeStr <= configData.endTime) {
             let retStart = await startTask(taskAccIds);
@@ -367,7 +372,7 @@ async function checkAutoStartMonitorTask(configData) {
                 taskRetText += `失败:${resData.failCount}\n`;
                 taskRetText += `现存账号数:${resData.occNodeNum}\n`;
                 magicJS.logger.info(taskRetText);
-                msgTipsText += taskRetText + '\n';
+                msgTipsText += `嫩模[${username}]` + taskRetText + '\n';
 
                 htmlContent += `<p style="margin-bottom: 10px;">账号监控任务启动结果概览:</p>`;
                 htmlContent += `<p style="margin-bottom: 10px;">新增:${resData.addCount}</p>`;
@@ -382,7 +387,7 @@ async function checkAutoStartMonitorTask(configData) {
 
     let retFastData = await getCommonFastTrackAccount();
     if (!retFastData || retFastData.code != 0) {
-        magicJS.logger.info(`获取神秘空间账号列表数据失败!`);
+        magicJS.logger.info(`嫩模[${username}]获取神秘空间账号列表数据失败!`);
         return;
     }
     let left = retFastData.data.left;
@@ -391,7 +396,7 @@ async function checkAutoStartMonitorTask(configData) {
         if (retFastData.data.account) {
             fastAccountIds = retFastData.data.account.split(',');
         }
-        msgTipsText += `神秘空间剩余可用名额:${left},启动结果如下:\n`;
+        msgTipsText += `嫩模[${username}]神秘空间剩余可用名额:${left},启动结果如下:\n`;
         htmlContent += `<p style="margin-bottom: 10px;">神秘空间剩余可用名额:${left},启动结果如下:</p>`;
         for (let i = 0; i < startedLst.length; i++) {
             let accountInfo = startedLst[i];
@@ -993,14 +998,14 @@ function expireDateFormat(date) {
     return remainingMinutes + "分" + remainingSeconds + "秒后过期";
 }
 
-async function checkExistOrderNoPay() {
+async function checkExistOrderNoPay(username) {
     let retOrderList = await queryToBePaidStatusOrderList();
     if (retOrderList && retOrderList.code == 0) {
         let msgTipsText = '';
         let nopayCount = 0;
         let orderList = retOrderList.data;
 
-        let htmlContent = `<h1><strong><span style="text-align: center;">订单信息</span></strong></h1>`;
+        let htmlContent = `<h1><strong><span style="text-align: center;">嫩模[${username}]订单信息</span></strong></h1>`;
         for (let i = 0; i < orderList.length; i++) {
             let d = orderList[i];
             let orderId = d.id;
@@ -1012,7 +1017,7 @@ async function checkExistOrderNoPay() {
             let priceStr = `¥${d.amount}`;
             let payStatus = await doPayResultCheck(orderId);
             if (payStatus) {
-                msgTipsText += `账号[${xmAccount}](${alias})下的订单:\n${goodsStr}(${priceStr})已付款,无需处理\n`;
+                msgTipsText += `嫩模[${username}]账号[${xmAccount}](${alias})下的订单:\n${goodsStr}(${priceStr})已付款,无需处理\n`;
                 htmlContent += `<p style="margin-bottom: 10px; font-weight: bold;">账号[${xmAccount}](${alias})下的订单:</p>`;
                 htmlContent += `<p style="margin-bottom: 10px;">订单产品:${goodsStr}(${priceStr})</p>`;
                 htmlContent += `<p style="margin-bottom: 10px;">订单状态:已付款,无需处理</p>`;
@@ -1035,7 +1040,7 @@ async function checkExistOrderNoPay() {
                     };
                     let officialStatus = data.officialStatus;
                     magicJS.logger.info(`订单状态:${statusMap[officialStatus] || `未知状态[${officialStatus}]`},订单号:${orderId}`);
-                    msgTipsText += `账号[${xmAccount}]${alias}下的订单:\n${goodsStr}(${priceStr})${statusMap[officialStatus]},请尽快去处理!过期时间:${expireStr}\n`;
+                    msgTipsText += `嫩模[${username}]账号[${xmAccount}]${alias}下的订单:\n${goodsStr}(${priceStr})${statusMap[officialStatus]},请尽快去处理!过期时间:${expireStr}\n`;
                     htmlContent += `<p style="margin-bottom: 10px;">账号[${xmAccount}](${alias})下的订单:</p>`;
                     htmlContent += `<p style="margin-bottom: 10px;">订单产品:${goodsStr}(${priceStr})</p>`;
                     htmlContent += `<p style="margin-bottom: 10px;">订单状态:${expireStr}</p>`;