From d3f1cf48ecb28ab4cdeb00f21926dc8729953b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9=E8=8E=AB=E7=88=B1=E5=B0=8F=E9=B8=9F?= <960365956@qq.com> Date: Sat, 5 Sep 2026 23:34:16 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B4=BD=E6=B4=BD=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E4=BF=B1=E4=B9=90=E9=83=A8=201.=E4=BF=AE=E6=94=B9=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E7=99=BB=E5=BD=95=E9=80=BB=E8=BE=91=202.=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=AD=BE=E5=88=B0=203.=E4=BF=AE=E6=94=B9=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=BC=93=E5=AD=98=E6=98=AF=E5=90=A6=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wxapp/qqhyjlb.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/wxapp/qqhyjlb.js b/wxapp/qqhyjlb.js index e30a9fb9..ed4c0050 100644 --- a/wxapp/qqhyjlb.js +++ b/wxapp/qqhyjlb.js @@ -120,13 +120,14 @@ class Task { if (res.status !== 200 || String(d.status) !== "0") throw new Error(`upms登录失败: ${d.msg || `HTTP ${res.status}`}`); const payload = (d.data && d.data.data) || d.data || {}; this.session.token = payload.token || this.session.token || ""; - this.session.userId = String(payload.loginId || (payload.account || {}).loginId || ""); - if (!this.session.userId) throw new Error(`upms未返回 loginId: ${short(d)}`); + this.session.loginId = String(payload.loginId || (payload.account || {}).loginId || ""); + this.session.userId = String(payload.userId || (payload.account || {}).userId || "c10cff02123a9e2697d875262612399d"); + if (!this.session.loginId) throw new Error(`upms未返回 loginId: ${short(d)}`); } async loginMobile() { const code = await this.getCode(); const res = await axios.post(`${MOBILE_BASE}/wechat/login`, - formBody({ code, userId: this.session.userId }), + formBody({ code, userId: "c10cff02123a9e2697d875262612399d" }), { headers: this.commonHeaders({ from_env: "app" }), timeout: 20000, validateStatus: () => true }); const d = res.data || {}; if (String(d.status) !== "0") { @@ -138,32 +139,36 @@ class Task { if (sid) this.session.sessionId = sid; const cust = (d.data || {}).customer || {}; if (!this.session.sessionId) throw new Error(`mobile登录未拿到 SESSION: ${short(d)}`); + this.log(`登录成功${cust.nickName ? `(${cust.nickName})` : ""}`); } async login() { - await this.loginUpms(); await this.loginMobile(); + await this.loginUpms(); + const cache = readCache(); cache[this.account.openid] = { ...this.session, updatedAt: new Date().toISOString() }; writeCache(cache); } async mobilePost(apiPath, data = {}) { if (!this.session.sessionId) throw new Error("缺少SESSION"); - const res = await axios.post(`${MOBILE_BASE}${apiPath}`, - formBody({ ...(data || {}), userId: this.session.userId }), + const res = await axios.post(`${VIP_BASE}${apiPath}`, + formBody({ ...(data || {}), uid: this.session.userId }), { headers: this.commonHeaders({ Cookie: `SESSION=${this.session.sessionId}`, Authorization: this.session.token || "", from_env: "app" }), timeout: 20000, validateStatus: () => true }); const sid = getSessionId(res.headers); if (sid) this.session.sessionId = sid; return res.data; } async sign() { - const list = (await this.mobilePost("/promotion/sign/list"))?.data || []; - const signedToday = Array.isArray(list) && list.some((it) => String(it?.signTime || "").slice(0, 10) === today()); + var yearMonth = $.time("yyyy-MM") + var dayMonth = $.time("d"); + const list = (await this.mobilePost("/vip/member/listUserSignLog", { "yearMonth": yearMonth, "tenantId": "1" }))?.data || []; + const signedToday = Array.isArray(list) && list.some((it) => it.dayMonth === dayMonth); if (signedToday) { const last = list[list.length - 1] || {}; - return this.log(`✅ 今日已签到,连续 ${last.signContinuousDay || 0} 天`); + return this.log(`✅ 今日已签到,连续 ${last.continueDays || 0} 天`); } - const res = await this.mobilePost("/promotion/sign/sign"); + const res = await this.mobilePost("/vip/member/sign", { "channel": "", "tenantId": "1" }); if (String(res?.status) === "0") { const point = (res.data || {}).point; return this.log(`✅ 签到成功${point ? `,积分+${point}` : ""}`); @@ -174,7 +179,7 @@ class Task { } async checkSession() { try { - const r = await this.mobilePost("/promotion/sign/list"); + const r = await this.mobilePost("/vip/member/getVipExtInfo", { "tenantId": "1" }); return String(r?.status) === "0" || Array.isArray(r?.data); } catch (e) { return false; From 350baeb3910878f32a7b34f639af9288f1455b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9=E8=8E=AB=E7=88=B1=E5=B0=8F=E9=B8=9F?= <960365956@qq.com> Date: Fri, 18 Sep 2026 09:32:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9ck=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=9C=89=E6=95=88=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wxapp/youzan.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wxapp/youzan.js b/wxapp/youzan.js index f741d7c1..2223a97c 100644 --- a/wxapp/youzan.js +++ b/wxapp/youzan.js @@ -198,7 +198,7 @@ class Task { async checkSession() { const res = await this.h5Get("/wscaccount/api/authorize/data.json"); - return isOk(res); + return res && res.data && res.data.userInfo && res.data.hasLogin; } async ensureLogin() { From 51a175f609523fb3d32046d81833314e3f285b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9=E8=8E=AB=E7=88=B1=E5=B0=8F=E9=B8=9F?= <960365956@qq.com> Date: Fri, 18 Sep 2026 09:56:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9C=89=E8=B5=9E=E4=BF=AE=E5=A4=8DCK?= =?UTF-8?q?=E6=9C=89=E6=95=88=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wxapp/youzan.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wxapp/youzan.js b/wxapp/youzan.js index 2223a97c..96456c45 100644 --- a/wxapp/youzan.js +++ b/wxapp/youzan.js @@ -198,7 +198,7 @@ class Task { async checkSession() { const res = await this.h5Get("/wscaccount/api/authorize/data.json"); - return res && res.data && res.data.userInfo && res.data.hasLogin; + return res && res.data && res.data.userInfo && res.data.userInfo.hasLogin; } async ensureLogin() { From 2e4615fac5c4e3ed5f4e0491a27bdf43b21ca6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9=E8=8E=AB=E7=88=B1=E5=B0=8F=E9=B8=9F?= <960365956@qq.com> Date: Mon, 21 Sep 2026 22:27:51 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B0=B7=E9=9B=A8=EF=BC=9A=201.=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=BC=93=E5=AD=98=E6=9C=BA=E5=88=B6=202.=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=AD=BE=E5=88=B0=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wxapp/guyu.js | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/wxapp/guyu.js b/wxapp/guyu.js index 2167e677..b5f0343f 100644 --- a/wxapp/guyu.js +++ b/wxapp/guyu.js @@ -6,6 +6,14 @@ @Date: 2024.06.07 19:15 @Description: cron: 30 9 * * 1 +------------------------------------------ +[更新日志] + +2026.09.21 +1.增加缓存机制 +2.修复签到报错问题 + + ------------------------------------------ #Notice: 谷雨 微信小程序 签到得积分 @@ -25,12 +33,15 @@ WeChatCodeServer 填写wx_server_url wx_auth 用于获取code const { Env } = require("../tools/env") -const $ = new Env("谷雨小程序"); +const $ = new Env("谷雨小程序", { + bucket: "guyu_token_cache.json" +}); const WeChatServer = require("./wcs.js"); let ckName = `guyu`; const strSplitor = "#"; const axios = require("axios"); const defaultUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.31(0x18001e31) NetType/WIFI Language/zh_CN miniProgram" + let wechat = new WeChatServer({ url: process.env.wx_server_url || 'https://xxx', appid: 'wxda948f3be0afc375', @@ -43,7 +54,6 @@ class Task { constructor(env) { this.index = $.userIdx++ this.user = env.split(strSplitor); - this.token = null this.wcsid = this.user[0] this.isSign = false this.shopId = '100186753' @@ -53,11 +63,24 @@ class Task { async run() { //随机延迟5-30s 模拟人工操作 - await $.wait(Math.floor(Math.random() * 20 + 5) * 1000); - let { data: codeRes } = await wechat.getCode(this.wcsid) - if (codeRes.status) { - await this.getUserToken(codeRes.data.code) + // await $.wait(Math.floor(Math.random() * 20 + 5) * 1000); + + const userData = await $.get(this.wcsid) + if (userData) { + $.log('使用缓存') + this.token = userData.mobileToken } + + if (this.token && await this.getUserPoints()) { + + } else { + $.log('缓存已失效,重新登录') + let { data: codeRes } = await wechat.getCode(this.wcsid) + if (codeRes.status) { + await this.getUserToken(codeRes.data.code) + } + } + if (!this.token) { $.log(`账号[${this.index}] 获取用户Token失败❌`) return @@ -94,6 +117,8 @@ class Task { let info = result.result || {} this.token = info.mobileToken if (info.shopId) this.shopId = "" + info.shopId + + $.set(this.wcsid, info) $.log(`🌸账号[${this.index}] 获取用户Token成功 门店:${info.shopName || this.shopId}`) } else { $.log(`🌸账号[${this.index}] 获取用户Token-失败:${result?.msg || result?.message}❌`) @@ -157,7 +182,7 @@ class Task { // 这里用两个只读查询接口动态拿当前可参与的签到活动(activityType=3) async findSignActivity() { try { - let { data: sys } = await this.request({ + let { data: sys } = await this.request({ method: 'GET', url: `https://mall-mobile-v6.vecrp.com/mobile/activity/common/queryIntegralSystemList`, params: { shopId: this.shopId, earnSpendType: 1 }, @@ -260,9 +285,11 @@ class Task { } = await this.request(options); if (result?.success) { $.log(`账号[${this.index}]` + `积分:${result.result[0].score}`); + return Promise.resolve(true) } else { $.log(`账号[${this.index}] 获取积分-失败:${result.msg}❌`) } + return Promise.resolve(false) }