/* 组队瓜分beta v2.0.1 https://cjhy-isv.isvjcloud.com/wxTeam/activity?activityId=6d08fc8fad484372a99351bcf60e87ac https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10033&templateId=2021062190900zdgf081&activityId=1717808855827406850&nodeId=101001&prd=cjwx https://hdb-isv.isvjcloud.com/h5/pages/partitionTeam/partitionTeam?id=5f1c0796be4f651574e9e0f5a7e8f8af&userId=182482 https://jingyun-rc.isvjcloud.com/h5/pages/partitionTeam/partitionTeam?id=ef8d69fd0410fe9da216f1c964c54c3f&userId=13082769 https://jinggeng-isv.isvjcloud.com/ql/front/showPartition?id=9e80802f8a49b510018a4a5422db2b78&user_id=172541 export B_WX_TEAM_URL="" export B_TEAM_LEADER_NUM="10" //车头数量 默认10 cron: 7 7 7 7 7 * const $ = new Env("组队瓜分beta"); */ let mode = __dirname.includes('bear'); let activityUrl = decodeURIComponent(process.argv.splice(2)?.[0] || process.env.M_WX_TEAM_URL); if (mode) { activityUrl = "https://cjhy-isv.isvjcloud.com/wxTeam/activity?activityId=6d08fc8fad484372a99351bcf60e87ac"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10033&templateId=2021062190900zdgf081&activityId=1717808855827406850&nodeId=101001&prd=cjwx"; activityUrl = "https://cjhydz-isv.isvjcloud.com/wxTeam/activity?activityId=54e4903a3bfc4e10a6ecdeaa58abaed1"; activityUrl = "https://jingyun-rc.isvjcloud.com/h5/pages/partitionTeam/partitionTeam?id=ef8d69fd0410fe9da216f1c964c54c3f&userId=13082769"; activityUrl = "https://jingyun-rc.isvjcloud.com/h5/pages/partitionTeam/partitionTeam?id=b44c5677f7363015af66dea0a932dd4f&userId=1000451545"; activityUrl = "https://hdb-isv.isvjcloud.com/h5/pages/partitionTeam/partitionTeam?id=5f1c0796be4f651574e9e0f5a7e8f8af&userId=182482"; activityUrl = "https://jinggeng-isv.isvjcloud.com/ql/front/showPartition?id=9e80802f8a49b510018a4a5422db2b78&user_id=172541"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/?activityType=10033&templateId=2021062190900zdgf081&activityId=1730058154674954241&nodeId=101001&prd=cjwx&shareuserid4minipg=BbrGRKytrjDMjC1fQeEoy2pCfN5ZmfvMwbWBLt73u98ENlAanVdw4/1A%207yG9wzk&shopid=1000102709&shopid=1000102709&shopid=1000102709&shopid=1000102709&shopid=1000102709&shopid=1000102709&shopid=1000102709&=&=&=&=&=&&shareUserId=1730262436920238081&shopid=1000102709"; activityUrl = "https://jingyun-rc.isvjcloud.com/h5/pages/partitionTeam/partitionTeam?id=4641a455f3611a88d3538d86f403e317&userId=13082769"; activityUrl = "https://cjhydz-isv.isvjcloud.com/wxTeam/activity?activityId=31a27ba5e17344e2a35f9d1eb9a8a826"; activityUrl = "https://cjhydz-isv.isvjcloud.com/wxTeam/activity?activityId=8827e30a920a41119f5d07f55a7e1060"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10033&templateId=2021062190900zdgf081&activityId=1744920180164960258&prd=cjwx"; activityUrl = "https://jingyun-rc.isvjcloud.com/h5/pages/partitionTeam/partitionTeam?id=34ccb6e412f39d0e620012efef471549&userId=61627"; activityUrl = "https://jingyun-rc.isvjcloud.com/h5/pages/partitionTeam/partitionTeam?id=db8e1dee18da0e3a784873fa62f579a8&userId=13082769&teamId=db8e1dee18da0e3a784873fa62f579a886"; activityUrl = "https://cjhydz-isv.isvjcloud.com/wxTeam/activity?activityId=6fb5fd5ab88e4c87be19ae8571052957"; activityUrl = "https://cjhydz-isv.isvjcloud.com/wxTeam/activity?activityId=982597cea4ec4ea1997f7c69e5f7143e"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interaction/v1/index?activityType=10033&activityId=1776856935890481154&templateId=2021062190900zdgf08&nodeId=101001&prd=crm"; activityUrl = "https://jingyun-rc.isvjcloud.com/h5/pages/partitionTeam/partitionTeam?id=d9e4888b159f560683efa86734d8a0b3&userId=1000007503&actForm=single&teamId=d9e4888b159f560683efa86734d8a0b31218"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10033&templateId=2021062190900zdgf081&activityId=1782628595081019394&nodeId=101001&prd=cjwx"; activityUrl = "https://cjhydz-isv.isvjcloud.com/wxTeam/activity?activityId=f47d2818bc8140d181844044f2aeb1d5"; activityUrl = "https://cjhydz-isv.isvjcloud.com/wxTeam/activity?activityId=644a01191a234c729066967c9cfb9877"; activityUrl = "https://cjhydz-isv.isvjcloud.com/wxTeam/activity?activityId=434e32054d3d4744a9caee80ffa70cce"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10033&activityId=1796452463138701313&templateId=2021062190900zdgf081&nodeId=101001&prd=cjwx"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10033&templateId=10202401041003302zdgfjp&activityId=1798545988361469954&nodeId=101001&prd=cjwx"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10033&activityId=1789853943779532801&templateId=2021062190900zdgf081&nodeId=101001&prd=cjwx"; activityUrl = "https://jinggeng-isv.isvjcloud.com/ql/front/showPartition?id=9e808086900394930190064ac05e41f7&user_id=1000003065"; activityUrl = "https://jingyun-rc.isvjcloud.com/h5/pages/partitionTeam/partitionTeam?id=ce4e9365871c0fd4ac075f00f1a01f69&userId=1000007503&actForm=single&teamId=ce4e9365871c0fd4ac075f00f1a01f691789"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/?activityType=10033&templateId=10202401031003302zdgfjp&activityId=1805130307891695618&nodeId=101001&prd=cjwx"; } const { RunMode: aa, UserMode: ab, baseCommonEnv: ac, baseCommonEnvKey: ad } = require("./bear"); aa.envInfo = { "name": "组队瓜分beta", "runName": "jd_wx_team", "env": "M_WX_TEAM_URL", "version": "2.0.1" }; ac.leaderNum = parseInt(process.env.B_TEAM_LEADER_NUM || 17); ad.B_TEAM_LEADER_NUM = "leaderNum"; class ae extends ab { async ["saveCaptain"](e = true) { let g = await this.wxApi(this.type + "/saveCaptain", { "activityId": this.activityId, "pin": this.secretPin, "venderId": this.venderId, "pinImg": "https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg" }); this.debug(g); if (g && g.result) { this.signUuid = g.data?.["signUuid"]; this.log("助力码[" + this.signUuid + "]"); this.putMsg("建队"); return; } let h = g?.["errorMessage"] ?? ""; if (h.includes("店铺会员") && ab.activity.openCard && e) { await this.bindWithVender(); if (this.canNotOpenCard) return this.reseCookieStatus(); return await this.saveCaptain(false); } else h.includes("活动未开始") && (ab.activity.noStart = true, this.stop()); this.log(h); await this.wxStopSync(h); this.needHelp = false; } async ["saveMember"](e = true) { let g = await this.wxApi(this.type + "/saveMember", { "activityId": this.activityId, "pin": this.secretPin, "venderId": this.venderId, "pinImg": "https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg", "signUuid": this.toHelpUser.signUuid }); this.debug(g); if (g && g.result) { this.log("加入[" + this.toHelpUser.pin + "]成功"); this.toHelpUser.helpedCount += 1; if (this.toHelpUser.helpedCount >= ab.activity.maxHelpCount) { this.toHelpUser.needHelp = false; this.toHelpUser.putMsg("已组满"); await this.toHelpUser.writeLongCache(); } await this.writeLongCache(this.activityId + "_invite"); return; } let h = g?.["errorMessage"] ?? ""; if (h.includes("满员")) { this.toHelpUser.needHelp = false; await this.toHelpUser.writeLongCache(); this.reseInviteStatus(); return; } else { if (h.includes("已经加入")) this.canHelp = false, await this.writeLongCache(this.activityId + "_invite");else { if (h.includes("店铺会员") && ab.activity.openCard && e) { await this.bindWithVender(); if (this.canNotOpenCard) return this.reseCookieStatus(); return await this.saveMember(false); } } } this.canHelp = false; this.log(h); await this.wxStopSync(h); } async ["getActContent"]() { let f = await this.activityContent(); if (!f?.["result"] || !f?.["data"]) { this.putMsg(f?.["errorMessage"]); return; } this.signUuid = f.data?.["signUuid"]; let g = f.data?.["active"] ?? {}, h = g?.["maxGroup"] ?? 5, { prizeType: i, startTime: j, endTime: k } = g; ab.activity.startTime = j; ab.activity.endTime = k; i == 6 && (ab.activity.openCard = true); ab.activity.maxHelpCount = h * 4; let l = f.data?.["successRetList"] ?? [], m = f.data?.["list"] ?? [], n = f.data?.["joinMap"]?.["memberList"] ?? []; if (n.length > 0) { this.canHelp = false; await this.writeLongCache(this.activityId + "_invite"); } this.helpedCount = Math.abs(Math.max(l?.["length"] * 4 + (m?.["length"] > 0 ? m.length - 1 : 0), 0)); this.debug(this.helpedCount); const o = this.formatDate(j, "yyyy-MM-dd HH:mm:ss") + "至" + this.formatDate(k, "yyyy-MM-dd HH:mm:ss"); ab.activity.timeStr = o; if (j && j > Date.now()) { let s = j - Date.now(); s < 60 * 1000 * 4 ? (this.log("活动即将开始,等待" + s / 1000 + "s"), await this.sleep(s)) : (this.putMsg("活动未开始"), i == 6 && (ab.activity.noStart = true), this.stop()); } k && k < Date.now() && (this.putMsg("活动已结束"), await this.writeLongCacheByStop(), this.stop()); if (this.helpedCount >= ab.activity.maxHelpCount) { this.needHelp = false; this.putMsg("已组满"); await this.writeLongCache(); return; } this.signUuid ? this.log("助力码[" + this.signUuid + "]") : await this.saveCaptain(); } async ["activityInfo"]() { let f = await this.lzkjApi("api/task/" + this.type + "/activity", { "shareUserId": this.shareUserId || "" }); if (f && f.resp_code === 0) { let i = f.data?.["groupNumber"] ?? 5; ab.activity.maxHelpCount = i * 4; this.helpedCount = 0; let j = f.data?.["captainList"] ?? []; this.createTeamNum = i - j.length; let k = f.data?.["prizeType"] ?? 0; k == 1 && (ab.activity.openCard = true); ab.activity.customThread = 1; if (j.length > 0) { this.teamId = j[j.length - 1].id; let m = j[j.length - 1]?.["teamList"] ?? []; this.helpedCount = m.length > 0 ? m.length - 1 : 0; } let l = f.data?.["captain"]; l && (await this.writeLongCache(this.activityId + "_invite"), this.canHelp = false); if (this.createTeamNum === 0 && this.helpedCount === 4) { this.putMsg("已组满"); this.needHelp = false; await this.writeLongCache(); this.exit(); } return; } let g = f?.["resp_msg"]; this.log(g); } async ["saveCaptain100"](e = true) { let g = await this.lzkjApi("api/task/" + this.type + "/saveCaptain"); this.debug(g); if (g && g.resp_code === 0) { this.putMsg("建队"); this.createTeamNum -= 1; this.helpedCount = 0; return; } let h = g?.["resp_msg"]; if (h?.["includes"]("会员") && ab.activity.openCard && e) { await this.bindWithVender(); if (this.canNotOpenCard) return this.reseCookieStatus(); return await this.login(false), await this.saveCaptain100(false); } this.log(h); await this.wxStopSync(h); } async ["saveMember100"](e = true, f = 0) { let h = await this.lzkjApi("api/task/" + this.type + "/saveMember", { "shareUserId": this.toHelpUser.shareUserId, "teamId": this.toHelpUser.teamId }); this.debug(h); if (h && h.resp_code === 0) { let j = h.data?.["canSend"]; switch (j) { case undefined: break; case 4: return this.putMsg("今日奖品已发完"), this.stop(); case 5: case 6: return this.putMsg("活动奖品已发完"), this.stop(); case 8: case 9: f++, this.log("活动人气爆棚", "retry:" + f); if (f > 10) return this.putMsg("活动人气爆棚"), this.exit(); return await this.saveMember100(e, f); default: this.putMsg("canSend:" + j); break; } if (h.data == true) { this.toHelpUser.putMsg("已组满"); this.toHelpUser.needHelp = false; await this.toHelpUser.writeLongCache(); this.reseInviteStatus(); return; } else { if (h.data?.["memberList"]) { this.log("加入[" + this.toHelpUser.pin + "]成功"); await this.writeLongCache(this.activityId + "_invite"); this.toHelpUser.helpedCount += 1; if (this.toHelpUser.helpedCount >= ab.activity.maxHelpCount) { if (this.toHelpUser.createTeamNum > 0) { return; } this.toHelpUser.needHelp = false; this.toHelpUser.putMsg("已组满"); await this.toHelpUser.writeLongCache(); } return; } else { if (JSON.stringify(h.data) == "{}") { this.canHelp = false; this.log("已加入或不能参加"); await this.writeLongCache(this.activityId + "_invite"); } } } return; } let i = h?.["resp_msg"]; if (i?.["includes"]("会员") && ab.activity.openCard && e) { await this.bindWithVender(); if (this.canNotOpenCard) return this.reseCookieStatus(); return await this.login(false), await this.saveMember100(false); } if (i?.["includes"]("已加入其他队伍")) { await this.writeLongCache(this.activityId + "_invite"); } this.canHelp = false; this.log(i); await this.wxStopSync(i); } async ["getTeamInfo"]() { await this.getUserId(); if (!this.teamId) { await this.activityInfo(); } } async ["loadPartitionTeamSetting"]() { let f = await this.hdbApi("loadPartitionTeamSetting"); this.debug(f); if (f && f?.["succ"]) { let { surPlusTeamNum: h, hasInviteTeam: i, hasJoinTeam: j, partitionTeamSetting = {}, myTeamLog = {} } = f.result; if (j > 0) { this.canHelp = false; } let { inviterTimes: k, teamCondition: l } = partitionTeamSetting, { teamMemberNum = 0, teamId = "" } = myTeamLog ?? {}; ab.activity.maxHelpCount = l - 1; this.helpedCount = Math.abs(Math.max(teamMemberNum - 1, 0)); this.createTeamNum = h; this.log(this.helpedCount, ab.activity.maxHelpCount); if (h <= 0) { this.putMsg("已组满"); await this.writeLongCache(); this.needHelp = false; return; } if (!teamId) return await this.startPartitionTeam(); if (teamMemberNum >= l) { await this.startPartitionTeam(); return; } else this.teamId = teamId; this.debug("helpedCount", this.helpedCount, this.createTeamNum, this.teamId, ab.activity.maxHelpCount); return; } let g = f?.["message"]; this.log(g); this.needHelp = false; } async ["startPartitionTeam"](e = true) { let g = await this.hdbApi("startPartitionTeam"); this.debug(g); if (g && g?.["succ"]) { this.teamId = g.result.teamId; this.putMsg("建队"); this.createTeamNum -= 1; this.helpedCount = 0; return; } let h = g?.["message"]; if (h?.["includes"]("关注店铺") && (await this.follow())) return await this.sleep(1000), await this.startPartitionTeam(); if (h?.["includes"]("会员") && e) { await this.bindWithVender(); if (this.canNotOpenCard) return this.reseCookieStatus(); return await this.sleep(1000), await this.startPartitionTeam(false); } this.needHelp = false; this.log(h); } async ["joinPartitionTeam"](e = true) { let g = await this.hdbApi("joinPartitionTeam", { "teamId": this.toHelpUser.teamId, "tidaType": "joinPartitionTeam" }); this.debug(g); if (g && g?.["succ"]) { this.log("加入[" + this.toHelpUser.pin + "]成功"); this.toHelpUser.helpedCount += 1; if (this.toHelpUser.helpedCount >= ab.activity.maxHelpCount) { if (this.toHelpUser.createTeamNum > 0) return await this.toHelpUser.startPartitionTeam(); this.toHelpUser.needHelp = false; this.toHelpUser.putMsg("已组满"); await this.toHelpUser.writeLongCache(); } await this.writeLongCache(this.activityId + "_invite"); return; } let h = g?.["message"]; if (h?.["includes"]("关注店铺") && (await this.follow())) return await this.sleep(1000), await this.joinPartitionTeam(); if (h?.["includes"]("会员") && e) { await this.bindWithVender(); if (this.canNotOpenCard) return this.reseCookieStatus(); return await this.sleep(1000), await this.joinPartitionTeam(false); } if (h?.["includes"]("已满员")) { await this.toHelpUser.writeLongCache(); this.reseInviteStatus(); return; } this.canHelp = false; this.log(h); await this.wxStopSync(h); } async ["postPartition"](e = true) { let g = await this.jinggengApi("postPartition"); this.debug(g); if (g && (g?.["succ"] || g?.["msg"]?.["includes"]("请先完成现有组队") || g?.["msg"]?.["includes"]("机会用完了"))) { let i = g.data?.["partitionSetting"]?.["creatTeamNum"] ?? 0, j = g.data?.["partitionSetting"]?.["teamNum"] ?? 0, k = g.data?.["partitionTeamLogParams"] ?? []; this.teamId = k[0].jdCombatTeamLogs[0].teamId; this.createTeamNum = i - k.length; ab.activity.maxHelpCount = j - 1; this.helpedCount = Math.abs(Math.max(k[0].jdCombatTeamLogs.length - 1, 0)); this.debug("helpedCount", this.helpedCount, this.createTeamNum, this.teamId, ab.activity.maxHelpCount); if (this.createTeamNum <= 0 && this.helpedCount >= ab.activity.maxHelpCount) { this.needHelp = false; this.putMsg("已组满"); await this.writeLongCache(); return; } this.putMsg("建队"); return; } let h = g?.["msg"] || "建队失败"; if (h?.["includes"]("关注店铺") && e) return await this.taskPost("front/followShop", { "userId": this.userId }), await this.sleep(1000), await this.postPartition(false); this.putMsg(h); await this.wxStopSync(h); this.needHelp = false; return; } async ["postPartitionJoin"](e = true) { let g = await this.jinggengApi("postPartition", { "teamId": this.toHelpUser.teamId }); if (g && g?.["succ"]) { this.log("加入[" + this.toHelpUser.pin + "]成功"); this.toHelpUser.helpedCount += 1; if (this.toHelpUser.helpedCount >= ab.activity.maxHelpCount) { if (this.toHelpUser.createTeamNum > 0) return await this.toHelpUser.postPartition(); this.toHelpUser.needHelp = false; this.toHelpUser.putMsg("已组满"); await this.toHelpUser.writeLongCache(); } await this.writeLongCache(this.activityId + "_invite"); return; } let h = g?.["msg"] || "入队失败"; if (h?.["includes"]("满员")) { this.toHelpUser.needHelp = false; await this.toHelpUser.writeLongCache(); this.reseInviteStatus(); return; } if (h?.["includes"]("关注店铺") && e) return await this.taskPost("front/followShop", { "userId": this.userId }), await this.postPartitionJoin(false); h?.["includes"]("组队机会已用完") && (await this.writeLongCache(this.activityId + "_invite")); this.canHelp = false; this.log(h); await this.wxStopSync(h); } async ["inviteTask"](e) { await this.hitCache(this.activityId + "_invite", this.pin, "已加入队伍", true); this.retryCount = 2; this.proxyRetryCount = 5; this.toHelpUser = e; if (!this.toHelpUser.needHelp) return; await this.isvObfuscator(); if (this.mode === "jinggeng") { await this.setMixNick(); await this.postPartitionJoin(); return; } if (this.mode == "hdb") { const h = await this.login(); if (!(h && h.code)) return; await this.loadFrontAct(); await this.reportPVUV(); await this.joinPartitionTeam(); return; } await this.getDefenseUrls(); if (["10033"].includes(this.activityType)) { await this.login(); if (["1005", "1006", "1002"].includes(this.joinCode)) { if (!ab.activity.openCard) return this.log(this.joinDes), this.reseCookieStatus(); await this.bindWithVender(); if (this.canNotOpenCard) return this.log(this.joinDes), this.reseCookieStatus(); await this.login(false); } await this.toHelpUser.activityInfo(); await this.saveMember100(); return; } await this.wxCommonInfo(); await this.getSimpleActInfoVo(); this.defenseUrls.length === 0 ? await this.getMyPing() : await this.initPinToken(); await this.accessLog(); await this.saveMember(); } async ["userTask"]() { await this.hitCache(); this.inviteMode = 2; if (this.index >= ac.leaderNum) return this.stop(); await this.isvObfuscator(); if (this.mode === "jinggeng") { await this.setMixNick(); await this.postPartition(); return; } if (this.mode == "hdb") { const g = await this.login(); if (!(g && g.code)) return; await this.loadFrontAct(); await this.reportPVUV(); await this.loadPartitionTeamSetting(); return; } await this.getDefenseUrls(); if (["10033"].includes(this.activityType)) { await this.login(); await this.activityInfo(); if (["1005", "1006", "1002"].includes(this.joinCode)) { if (!ab.activity.openCard) return this.log(this.joinDes), this.reseCookieStatus(); await this.bindWithVender(); if (this.canNotOpenCard) return this.log(this.joinDes), this.reseCookieStatus(); await this.login(false); } this.debug(this.createTeamNum, this.helpedCount); !this.teamId && (await this.saveCaptain100()); await this.getTeamInfo(); !this.teamId && (this.needHelp = false); return; } await this.wxCommonInfo(); await this.getSimpleActInfoVo(); this.defenseUrls.length === 0 ? await this.getMyPing() : await this.initPinToken(); await this.accessLog(); await this.getActContent(); } } aa.activity = { "activityUrl": activityUrl }; aa.TaskClass = ae; aa.run({ "whitelist": ["1-20000"], "thread": 50, "main_thread": 20, "inviteTask": true });