解决生产可兑换不通知的bug,收取好友地下零件只在每天1,12,19点进行。

This commit is contained in:
lxk0301
2021-04-02 11:32:20 +08:00
parent ad4291c2cf
commit 2ce0717cc6

View File

@@ -1,6 +1,6 @@
/*
京东京喜工厂
更新时间2021-3-31
更新时间2021-4-2
修复做任务、收集电力出现火爆不能完成任务重新计算h5st验证
参考自 https://www.orzlee.com/web-development/2021/03/03/lxk0301-jingdong-signin-scriptjingxi-factory-solves-the-problem-of-unable-to-signin.html
活动入口京东APP-游戏与互动-查看更多-京喜工厂
@@ -106,12 +106,13 @@ if ($.isNode()) {
}
await joinLeaderTuan();//参团
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1])
if ((cookiesArr && cookiesArr.length < $.tuanNum || 5) || !$.canHelp) return
console.log(`\n账号内部相互进团\n`);
for (let item of $.tuanIds) {
console.log(`\n${$.UserName} 去参加团 ${item}`);
if (!$.canHelp) break;
await JoinTuan(item);
if ((cookiesArr && cookiesArr.length >= ($.tuanNum || 5)) && $.canHelp) {
console.log(`\n账号内部相互进团\n`);
for (let item of $.tuanIds) {
console.log(`\n${$.UserName} 去参加团 ${item}`);
if (!$.canHelp) break;
await JoinTuan(item);
}
}
}
}
@@ -602,7 +603,8 @@ function userInfo() {
message += `【当前等级】${data.user.userIdentity} ${data.user.currentLevel}\n`;
message += `【生产进度】${((production.investedElectric / production.needElectric) * 100).toFixed(2)}%\n`;
if (production.investedElectric >= production.needElectric) {
$.log(`可以对方商品了`)
if (production['exchangeStatus'] === 1) $.log(`\n\n可以兑换商品了`)
if (production['exchangeStatus'] === 3) $.log(`\n\n商品兑换已超时`)
// await exchangeProNotify()
}
} else {
@@ -724,7 +726,7 @@ function DrawProductionStagePrize() {
}
async function PickUp(encryptPin = $.encryptPin, help = false) {
$.pickUpMyselfComponent = true;
const GetUserComponentRes = await GetUserComponent(encryptPin, 1300);
const GetUserComponentRes = await GetUserComponent(encryptPin, 1500);
if (GetUserComponentRes && GetUserComponentRes['ret'] === 0) {
const { componentList } = GetUserComponentRes['data'];
if (componentList && componentList.length <= 0) {
@@ -832,6 +834,8 @@ async function stealFriend() {
// $.log(`今日收取零件已达上限,偷好友零件也达到上限,故跳出`)
// return
// }
//调整只在每日1点12点19点尝试收取好友零件
if (new Date().getHours() !== 1 && new Date().getHours() !== 12 && new Date().getHours() !== 19) return
await getFriendList();
$.friendList = [...new Set($.friendList)].filter(vo => !!vo && vo['newFlag'] !== 1);
console.log(`查询好友列表完成,共${$.friendList.length}好友,下面开始拾取好友地下的零件\n`);
@@ -1220,30 +1224,26 @@ async function exchangeProNotify() {
$.exchangeEndTime = new Date(exchangeEndTime + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString('zh', {hour12: false});
//脚本运行此时的时间点
nowHours = nowTimes.getHours();
} else if (shel['exchangeStatus'] === 3) {
//兑换超时
}
}
if (exchangeEndTime) {
//比如兑换(超时)截止时间是2020/12/8 09:20:04,现在时间是2020/12/6
if (nowTimes < exchangeEndTime) {
//还可以兑换
// 一:在兑换超时这一天(2020/12/8 09:20:04)的前2小时内通知
if ((exchangeEndTime - nowTimes.getTime()) <= 3600000 * 2) {
let expiredTime = parseInt(((exchangeEndTime - nowTimes.getTime()) / (60*1000)).toFixed(0))
$.msg($.name, ``, `【京东账号${$.index}${$.nickName}\n【生产商品】${$.productName}${expiredTime}分钟后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, {'open-url': jxOpenUrl, 'media-url': $.picture})
// 一:在兑换超时这一天(2020/12/8 09:20:04)的前3小时内通知
if ((exchangeEndTime - nowTimes.getTime()) <= 3600000 * 3) {
let expiredTime = parseInt(((exchangeEndTime - nowTimes.getTime()) / (60*60*1000)).toFixed(1))
$.msg($.name, ``, `【京东账号${$.index}${$.nickName}\n【生产商品】${$.productName}${expiredTime}小时后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, {'open-url': jxOpenUrl, 'media-url': $.picture})
// if ($.isNode()) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}${(exchangeEndTime - nowTimes) / 60*60*1000}分钟后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, { url: jxOpenUrl })
if ($.isNode()) allMessage += `【京东账号${$.index}${$.nickName}\n【生产商品】${$.productName}${expiredTime}分钟后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换${$.index !== cookiesArr.length ? '\n\n' : ''}`
if ($.isNode()) allMessage += `【京东账号${$.index}${$.nickName}\n【生产商品】${$.productName}${expiredTime}小时后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换${$.index !== cookiesArr.length ? '\n\n' : ''}`
}
//二:在兑换超时日期前的时间一天通知次(2020/12/6 9,10,11点,以及在2020/12/7 9,10,11点各通知一次)
if (nowHours === exchangeEndHours || nowHours === (exchangeEndHours + 1) || nowHours === (exchangeEndHours + 2)) {
//二:在兑换的时候,一天通知2次(2020/12/6 10,11点,以及在2020/12/7 10,11点各通知一次)
if (nowHours === (exchangeEndHours + 1) || nowHours === (exchangeEndHours + 2)) {
$.msg($.name, ``, `【京东账号${$.index}${$.nickName}\n【生产商品】${$.productName}已可兑换\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, {'open-url': jxOpenUrl, 'media-url': $.picture})
// if ($.isNode()) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}已可兑换\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, { url: jxOpenUrl })
if ($.isNode()) allMessage += `【京东账号${$.index}${$.nickName}\n【生产商品】${$.productName}已可兑换\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换${$.index !== cookiesArr.length ? '\n\n' : ''}`
}
} else {
//兑换已超时
$.msg($.name, ``, `【京东账号${$.index}${$.nickName}\n【生产商品】${$.productName}兑换已超时,请重新选择商品生产\n【兑换截止时间】${$.exchangeEndTime}`, {'open-url': jxOpenUrl})
// if ($.isNode()) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}兑换已超时,请重新选择商品生产\n【兑换截止时间】${$.exchangeEndTime}`, { url: jxOpenUrl })
if ($.isNode()) allMessage += `【京东账号${$.index}${$.nickName}\n【生产商品】${$.productName}兑换已超时,请重新选择商品生产\n【兑换截止时间】${$.exchangeEndTime}${$.index !== cookiesArr.length ? '\n\n' : ''}`
}
}
}