From 93a4e921b4c56a85e7c74f0b646cfb1e915c84a8 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Sun, 6 Dec 2020 16:05:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=AC=E5=96=9C=E5=B7=A5?= =?UTF-8?q?=E5=8E=82=E8=84=9A=E6=9C=AC=E5=95=86=E5=93=81=E5=8F=AF=E5=85=91?= =?UTF-8?q?=E6=8D=A2=E6=97=B6=E7=9A=84=E9=80=9A=E7=9F=A5=E9=A2=91=E7=8E=87?= =?UTF-8?q?=20=E6=AF=94=E5=A6=82=E5=85=91=E6=8D=A2(=E8=B6=85=E6=97=B6)?= =?UTF-8?q?=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4=E6=98=AF2020/12/8=2009:20:?= =?UTF-8?q?04,=E7=8E=B0=E5=9C=A8=E6=97=B6=E9=97=B4=E6=98=AF2020/12/6=20?= =?UTF-8?q?=E4=B8=80:=E5=9C=A8=E5=85=91=E6=8D=A2=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E8=BF=99=E4=B8=80=E5=A4=A9(2020/12/8=2009:20:04)=E7=9A=84?= =?UTF-8?q?=E5=89=8D2=E5=B0=8F=E6=97=B6=E5=86=85=E9=80=9A=E7=9F=A5=20?= =?UTF-8?q?=E4=BA=8C:=E5=9C=A8=E5=85=91=E6=8D=A2=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=89=8D=E7=9A=84=E6=97=B6=E9=97=B4=E6=AF=8F?= =?UTF-8?q?=E5=A4=A9=E4=BB=85=E4=BB=85=E9=80=9A=E7=9F=A5=E4=B8=89=E6=AC=A1?= =?UTF-8?q?(2020/12/6=209,10,11=E7=82=B9,=E4=BB=A5=E5=8F=8A=E5=9C=A82020/1?= =?UTF-8?q?2/7=209,10,11=E7=82=B9=E5=90=84=E9=80=9A=E7=9F=A5=E4=B8=80?= =?UTF-8?q?=E6=AC=A1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_dreamFactory.js | 92 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 7 deletions(-) diff --git a/jd_dreamFactory.js b/jd_dreamFactory.js index e2e1eb50..1b13aa9d 100644 --- a/jd_dreamFactory.js +++ b/jd_dreamFactory.js @@ -32,7 +32,7 @@ const notify = $.isNode() ? require('./sendNotify') : ''; let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 const randomCount = $.isNode() ? 20 : 5; const tuanActiveId = `jfkcidGQavswLOBcAWljrw==`; - +const jxOpenUrl = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://wqsd.jd.com/pingou/dream_factory/index.html%22%20%7D`; let cookiesArr = [], cookie = '', message = ''; const inviteCodes = ['V5LkjP4WRyjeCKR9VRwcRX0bBuTz7MEK0-E99EJ7u0k=', 'PDPM257r_KuQhil2Y7koNw==', "gB99tYLjvPcEFloDgamoBw=="]; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; @@ -101,6 +101,7 @@ async function jdDreamFactory() { await stealFriend(); await tuanActivity(); await QueryAllTuan(); + await exchangeProNotify(); await showMsg(); } @@ -425,7 +426,7 @@ function QueryFriendList() { $.log(`【今日招工进度】${hireListToday.length}/${hireNumMax}`); message += `【招工进度】${hireListToday.length}/${hireNumMax}\n`; } else { - console.log(`异常:${JSON.stringify(data)}`) + console.log(`QueryFriendList异常:${JSON.stringify(data)}`) } } } @@ -493,7 +494,7 @@ function doTask(taskId) { if (data['ret'] === 0) { console.log("做任务完成!") } else { - console.log(`异常:${JSON.stringify(data)}`) + console.log(`DoTask异常:${JSON.stringify(data)}`) } } } @@ -521,6 +522,7 @@ function userInfo() { data = data['data']; $.unActive = true;//标记是否开启了京喜活动或者选购了商品进行生产 $.encryptPin = ''; + $.shelvesList = []; if (data.factoryList && data.productionList) { const production = data.productionList[0]; const factory = data.factoryList[0]; @@ -546,8 +548,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) { - $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}\n已生产完,请速去京喜APP->首页->好物0元造进行兑换`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://wqsd.jd.com/pingou/dream_factory/index.html%22%20%7D'}) - await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}\n已生产完,请速去京喜APP->首页->好物0元造进行兑换`) + $.log(`可以对方商品了`) + // await exchangeProNotify() } } else { $.unActive = false;//标记是否开启了京喜活动或者选购了商品进行生产 @@ -560,7 +562,7 @@ function userInfo() { } } } else { - console.log(`异常:${JSON.stringify(data)}`) + console.log(`GetUserInfo异常:${JSON.stringify(data)}`) } } } @@ -588,7 +590,39 @@ function GetCommodityDetails() { data = data['data']; $.productName = data['commodityList'][0].name; } else { - console.log(`异常:${JSON.stringify(data)}`) + console.log(`GetCommodityDetails异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +// 查询已完成商品 +function GetShelvesList(pageNo = 1) { + return new Promise(async resolve => { + $.get(taskurl('userinfo/GetShelvesList', `pageNo=${pageNo}&pageSize=12`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + const { shelvesList } = data; + if (shelvesList) { + $.shelvesList = [...$.shelvesList, ...shelvesList]; + pageNo ++ + GetShelvesList(pageNo); + } + } else { + console.log(`GetShelvesList异常:${JSON.stringify(data)}`) } } } @@ -1164,6 +1198,50 @@ function updateTuanIdsCDN(url = 'https://raw.fastgit.org/lxk0301/updateTeam/mast }) }) } +function checkExchange() { + +} +//商品可兑换时的通知 +async function exchangeProNotify() { + await GetShelvesList(); + let exchangeEndTime, exchangeEndHours, nowHours; + //脚本运行的UTC+8时区的时间戳 + let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); + if ($.shelvesList && $.shelvesList.length > 0) console.log(`\n 商品名 兑换状态`) + for (let shel of $.shelvesList) { + console.log(`${shel['name']} ${shel['exchangeStatus'] === 1 ? '未兑换' : shel['exchangeStatus'] === 2 ? '已兑换' : '兑换超时'}`) + if (shel['exchangeStatus'] === 1) { + exchangeEndTime = shel['exchangeEndTime'] * 1000; + $.picture = shel['picture']; + // 兑换截止时间点 + exchangeEndHours = new Date(exchangeEndTime + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).getHours(); + //兑换截止时间(年月日 时分秒) + $.exchangeEndTime = new Date(exchangeEndTime + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString('zh', {hour12: false}); + //脚本运行此时的时间点 + nowHours = nowTimes.getHours(); + } + } + if (exchangeEndTime) { + //比如兑换(超时)截止时间是2020/12/8 09:20:04,现在时间是2020/12/6 + if (nowTimes < exchangeEndTime) { + //还可以兑换 + // 一:在兑换超时这一天(2020/12/8 09:20:04)的前2小时内通知 + if ((exchangeEndTime - nowTimes) <= 3600000 * 2) { + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}${(exchangeEndTime - nowTimes) / 60*60*1000}分钟后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, {'open-url': jxOpenUrl, 'media-url': $.picture}) + await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}${(exchangeEndTime - nowTimes) / 60*60*1000}分钟后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, { url: jxOpenUrl }) + } + //二:在兑换超时日期前的时间一天通知三次(2020/12/6 9,10,11点,以及在2020/12/7 9,10,11点各通知一次) + if (nowHours === exchangeEndHours || nowHours === (exchangeEndHours + 1) || nowHours === (exchangeEndHours + 2)) { + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}已可兑换\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, {'open-url': jxOpenUrl, 'media-url': $.picture}) + await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}已可兑换\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, { url: jxOpenUrl }) + } + } else { + //兑换已超时 + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}兑换已超时,请重新选择商品生产\n【兑换截止时间】${$.exchangeEndTime}`, {'open-url': jxOpenUrl}) + await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}兑换已超时,请重新选择商品生产\n【兑换截止时间】${$.exchangeEndTime}`, { url: jxOpenUrl }) + } + } +} async function showMsg() { return new Promise(async resolve => { message += `【收取自己零件】${$.pickUpMyselfComponent ? `获得${$.pickEle}电力` : `今日已达上限`}\n`;