|
|
@@ -16,6 +16,8 @@ const scriptName = `嫩模助手`;
|
|
|
const magicJS = MagicJS(scriptName, "INFO");
|
|
|
const MoConstKey = {
|
|
|
Cookie: `mo_cookie`,
|
|
|
+ OrderZfbPayUrlData: `mo_orderZfbPayUrlData`,
|
|
|
+ OrderWxPayUrlData: `mo_orderWxPayUrlData`,
|
|
|
};
|
|
|
|
|
|
const gUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1`;
|
|
|
@@ -381,7 +383,25 @@ async function checkAutoStartMonitorTask(configData) {
|
|
|
break;
|
|
|
}
|
|
|
} else {
|
|
|
- msgTipsText += `账号[${accountInfo.xmAccount}]添加失败\n`;
|
|
|
+ msgTipsText += `账号[${accountInfo.xmAccount}]添加失败,原因:${retSet?.message}\n`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ retFastData = await getCommonFastTrackAccount();
|
|
|
+ if (retFastData && retFastData.code == 0) {
|
|
|
+ if (retFastData.data.compensateSeniority &&
|
|
|
+ (!retFastData.data.compensateAccount || retFastData.data.compensateAccount.length === 0) &&
|
|
|
+ retFastData.data.account) {
|
|
|
+ magicJS.logger.info(`设置可添加补偿的账号`);
|
|
|
+ let accountArr = retFastData.data.account.split(",");
|
|
|
+ if (accountArr.length > 0) {
|
|
|
+ let randAccount = accountArr[Math.floor(Math.random() * accountArr.length)];
|
|
|
+ let retCompensate = await setCompensateFastTrackAccount(randAccount);
|
|
|
+ if (retCompensate && retCompensate.code == 0) {
|
|
|
+ msgTipsText += `账号[${randAccount}]设置为补偿的账号成功\n`;
|
|
|
+ } else {
|
|
|
+ msgTipsText += `账号[${randAccount}]设置为补偿的账号失败,原因:${retCompensate?.message}\n`;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -584,6 +604,31 @@ async function setCommonFastTrackAccount(account) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+async function setCompensateFastTrackAccount(account) {
|
|
|
+ const url = `https://mo.10coo.com/setCompensateFastTrackAccount`;
|
|
|
+ let reqData = {
|
|
|
+ account: account,
|
|
|
+ };
|
|
|
+ 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 checkAutoLoginTask() {
|
|
|
let resData = await listXmAccount();
|
|
|
if (!resData.data || !resData.code != 0) {
|
|
|
@@ -936,8 +981,55 @@ async function checkExistOrderNoPay() {
|
|
|
if (payStatus) {
|
|
|
msgTipsText += `账号[${xmAccount}]${alias}下的订单:\n${goodsStr}(${priceStr})已付款,无需处理\n`;
|
|
|
} else {
|
|
|
- msgTipsText += `账号[${xmAccount}]${alias}下的订单:\n${goodsStr}(${priceStr})未付款,请尽快去付款!过期时间:${expireStr}\n`;
|
|
|
nopayCount += 1;
|
|
|
+ let retDetail = await queryOrderDetail(orderId);
|
|
|
+ if (retDetail && retDetail.code == 0) {
|
|
|
+ let data = retDetail.data;
|
|
|
+ let statusMap = {
|
|
|
+ [-4]: "待更新",
|
|
|
+ [-3]: "未知或待支付",
|
|
|
+ [-2]: "已关闭",
|
|
|
+ [-1]: "已取消",
|
|
|
+ [0]: "待支付",
|
|
|
+ [1]: "已支付",
|
|
|
+ [2]: "待签收",
|
|
|
+ [3]: "已签收",
|
|
|
+ [4]: "已签收",
|
|
|
+ [8]: "已删除",
|
|
|
+ };
|
|
|
+ let officialStatus = data.officialStatus;
|
|
|
+ magicJS.logger.info(`订单状态:${statusMap[officialStatus] || `未知状态[${officialStatus}]`},订单号:${id}`);
|
|
|
+ msgTipsText += `账号[${xmAccount}]${alias}下的订单:\n${goodsStr}(${priceStr})${[officialStatus]},请尽快去处理!过期时间:${expireStr}\n`;
|
|
|
+
|
|
|
+ if (officialStatus === -3 || officialStatus === 0) {
|
|
|
+ let wxKey = `${MoConstKey.OrderWxPayUrlData}#${orderId}`;
|
|
|
+ let wxPayUrl = magicJS.data.read(wxKey, null);
|
|
|
+ if (!wxPayUrl) {
|
|
|
+ wxPayUrl = await getWxPayUrl(orderId);
|
|
|
+ if (wxPayUrl) {
|
|
|
+ magicJS.data.write(wxKey, wxPayUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (wxPayUrl) {
|
|
|
+ msgTipsText += `微信支付链接,请在微信内打开进行支付:\n${wxPayUrl}\n`;
|
|
|
+ }
|
|
|
+
|
|
|
+ let zfbKey = `${MoConstKey.OrderZfbPayUrlData}#${orderId}`;
|
|
|
+ let zfbPayUrl = magicJS.data.read(zfbKey, null);
|
|
|
+ if (!zfbPayUrl) {
|
|
|
+ zfbPayUrl = await getZFBPayUrl(orderId);
|
|
|
+ if (zfbPayUrl) {
|
|
|
+ magicJS.data.write(zfbKey, zfbPayUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (zfbPayUrl) {
|
|
|
+ msgTipsText += `支付宝支付链接,请浏览器打开跳转支付宝支付:\n${zfbPayUrl}\n`;
|
|
|
+ }
|
|
|
+ msgTipsText += `\n`;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ msgTipsText += `账号[${xmAccount}]${alias}下的订单:\n${goodsStr}(${priceStr})未付款,请尽快去处理!过期时间:${expireStr}\n`;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
magicJS.logger.info(msgTipsText);
|
|
|
@@ -989,8 +1081,8 @@ async function queryToBePaidStatusOrderList() {
|
|
|
async function doPayResultCheck(id) {
|
|
|
let ret = await queryOfficialStatus(id);
|
|
|
if (ret && ret.code == 0) {
|
|
|
- ret = await checkPayResult(id);
|
|
|
- return ret;
|
|
|
+ let isExist = await checkPayResult(id);
|
|
|
+ return isExist;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
@@ -1029,6 +1121,7 @@ async function checkPayResult(id) {
|
|
|
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(`未检测到支付`);
|
|
|
@@ -1045,6 +1138,78 @@ async function checkPayResult(id) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+async function queryOrderDetail(id) {
|
|
|
+ const url = `https://mo.10coo.com/order/queryOrderDetail?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 getZFBPayUrl(id) {
|
|
|
+ const url = `https://mo.10coo.com/zPay?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)}`);
|
|
|
+ if (rspData.code === 0 && rspData.data.code === 200) {
|
|
|
+ return rspData.data.data.data.url;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ } catch (e) {
|
|
|
+ magicJS.logger.error(e);
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ const msg = `生成支付宝支付链接异常\n${JSON.stringify(err)}`;
|
|
|
+ magicJS.logger.error(msg);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+async function getWxPayUrl(id) {
|
|
|
+ const url = `https://mo.10coo.com/wPay?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)}`);
|
|
|
+ if (rspData.code === 0 && rspData.data.code === 200) {
|
|
|
+ return rspData.data.data.openlink;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ } 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());
|
|
|
|
|
|
|