/* 加购有礼beta v1.0.0 https://cjhy-isv.isvjcloud.com/wxCollectionActivity/activity?activityId=8d0f86f522d34fd6828e3c75fe4091f0 https://lzkj-isv.isvjd.com/wxCollectionActivity/activity2/0d5b8e8cb94a46bbbe4aff25dc1e9c0d?activityId=0d5b8e8cb94a46bbbe4aff25dc1e9c0d https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10024&templateId=20210518190900jgyl011&activityId=1740268731560538114&nodeId=101001&prd=cjwx https://hdb-isv.isvjcloud.com/h5/pages/plusGift/plusGift1?id=dffb05f66b3f1361ddec86a315c052e4&userId=1000461510 https://jingyun-rc.isvjcloud.com/h5/pages/plusGift/plusGift5?id=8e2fcea1fb4f64a11795ffbae977ba58&userId=1000350703 https://gzsl-isv.isvjcloud.com/wuxian/mobileForApp/dist/views/pages/extraGift.html?activityType=JG_1&activityId=644508 https://jinggeng-isv.isvjcloud.com/ql/front/showCart?id=9e8080b38b49247b018b4ab08b970281&user_id=1000453449 https://lzkj-isv.isvjcloud.com/prod/cc/interaction/v2/10024/1002/?activityId=1845743310249439233&shopId=1000014485 export M_WX_ADD_CART_URL="" export M_WX_ADD_CART_BEAN_NUM="2" # 超过这个数量才会开卡 默认值2 cron: 1 1 1 1 * const $ = new Env("加购有礼beta"); */ let mode = __dirname.includes("bear"), activityUrl = decodeURIComponent(process.argv.splice(2)?.[0] || process.env.M_WX_ADD_CART_URL); if (mode) { activityUrl = "https://cjhy-isv.isvjcloud.com/wxCollectionActivity/activity?activityId=8d0f86f522d34fd6828e3c75fe4091f0"; activityUrl = "https://lzkj-isv.isvjd.com/wxCollectionActivity/activity2/0d5b8e8cb94a46bbbe4aff25dc1e9c0d?activityId=0d5b8e8cb94a46bbbe4aff25dc1e9c0d"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10024&templateId=7f4116e9-34b2-4f6d-9684-d7ca7c4b3d69&activityId=1711295984027947010&nodeId=101001&prd=cjwx"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interaction/v1/index?activityType=10024&templateId=20210518190900jgyl01&activityId=1714916689487958018&nodeId=101001&prd=crm"; activityUrl = "https://jingyun-rc.isvjcloud.com/h5/pages/plusGift/plusGift5?id=8e2fcea1fb4f64a11795ffbae977ba58&userId=1000350703"; activityUrl = "https://hdb-isv.isvjcloud.com/h5/pages/plusGift/plusGift1?id=dffb05f66b3f1361ddec86a315c052e4&userId=1000461510"; activityUrl = "https://gzsl-isv.isvjcloud.com/wuxian/mobileForApp/dist/views/pages/extraGift.html?activityType=JG_1&activityId=644508"; activityUrl = "https://jinggeng-isv.isvjcloud.com/ql/front/showCart?id=9e8080b38b49247b018b4ab08b970281&user_id=1000453449"; activityUrl = "https://jinggeng-isv.isvjcloud.com/ql/front/showCart?id=9e8080348b68fabe018b7e9eb6a306d9&user_id=1000361845"; activityUrl = "https://lzkj-isv.isvjd.com/wxCollectionActivity/activity2?activityId=00175a1d132542c1a8d6321501cf3d3d"; activityUrl = "https://hdb-isv.isvjcloud.com/h5/pages/plusGift/plusGift3?id=755f118f0066f6ffe910fc7c849e3ff5&userId=1000111946"; activityUrl = "https://lzkj-isv.isvjd.com/wxCollectionActivity/activity2/d4f29769aea4402fbe787652f7210d1a?activityId=d4f29769aea4402fbe787652f7210d1a"; activityUrl = "https://lzkj-isv.isvjd.com/wxCollectionActivity/activity2/6bfcc3e5963e42f4a5a49a434668dd83?activityId=6bfcc3e5963e42f4a5a49a434668dd83"; activityUrl = "https://cjhy-isv.isvjcloud.com/wxCollectionActivity/activity?activityId=a13e2f5048f644e8abbfbc990f8034fb"; activityUrl = "https://lzkj-isv.isvjd.com/wxCollectionActivity/activity2/0a65517110924fb893dbcd469bc44ad2?activityId=0a65517110924fb893dbcd469bc44ad2"; activityUrl = "https://lzkj-isv.isvjd.com/wxCollectionActivity/activity2/fdc4d1c08a594a8d8769072c0452bf7e?activityId=fdc4d1c08a594a8d8769072c0452bf7e"; activityUrl = "https://cjhy-isv.isvjcloud.com/wxCollectionActivity/activity?activityId=891b965fba8a4c599a04ea6b00dbff1c"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10024&templateId=20210518190900jgyl011&activityId=1740268731560538114&nodeId=101001&prd=cjwx"; activityUrl = "https://cjhy-isv.isvjcloud.com/wxCollectionActivity/activity?activityId=8e61f7b04b184767836879c5d0030ddf"; activityUrl = "https://lzkj-isv.isvjcloud.com/prod/cc/interaction/v2/10024/1002/?activityId=1845743310249439233&shopId=1000014485"; } const II1Ill11 = parseInt(process.env.M_WX_ADD_CART_BEAN_NUM || 2), { RunMode: i11Iiii, UserMode: ilII1l1 } = require("./bear"); i11Iiii.envInfo = { "name": "M加购有礼", "runName": "m_jd_wx_addCart", "env": "M_WX_ADD_CART_URL", "version": "1.0.0" }; class iiilI111 extends ilII1l1 { constructor(il1iiii, lI1IiIl) { super(il1iiii, lI1IiIl); } async ["userTask"]() { await this.isvObfuscator(); if (this.mode === "v2") { await this.login(); let iiiiii = await this.v2Api("api/" + this.activityType + "/addInfo"); if (iiiiii && iiiiii.code === 200) { let llllll = iiiiii?.data ?? {}; ilII1l1.activity.prizeList = [llllll]; if (this.timestamp() < llllll?.["addStartTime"]) { this.putMsg("加购时间未开始"); this.stop(); return; } if (llllll?.["surplus"] > 0 && llllll?.["todayNum"] == 0){ this.putMsg("每日奖品数量不足"); this.stop(); return; } if (llllll?.["surplus"] == 0){ this.putMsg("垃圾或已领完"); this.stop(); return; } } let llllll = await this.v2Api("api/" + this.activityType + "/getExposureSku", { "pageNum": 1, "pageSize": 100, "type": 1 }); let skuIds = []; if (llllll && llllll.code === 200) { for(let i = 0; i < llllll.data.records.length; i++) { let id = llllll.data.records[i].skuId; skuIds.push(id); } } await this.v2Api("api/" + this.activityType + "/addClickLog", {"skuIds": skuIds}); await this.v2Api("api/" + this.activityType + "/addInfo"); let ililil = await this.v2Api("api/" + this.activityType + "/sendPrize"); if(ililil.code === 200) { this.putMsg(ililil.data.result.prizeName); return; } let lilili = ililil?.["message"]; this.putMsg(lilili); return; } if (this.mode === "gzsl") { let illliiii = await this.gzslApi("getGoodsGiftActivity", { "venderId": this.activityId }); this.debug(illliiii); if (illliiii && illliiii.status === "1") { let iIlII1I = illliiii.activity?.["startTime"], i1llllll = illliiii.activity?.["endTime"]; this.shopId = illliiii.activity?.["shopId"]; this.venderId = illliiii.activity?.["venderId"]; this.shopName = illliiii.activity?.["detail"]; ilII1l1.activity.shopId = this.shopId; ilII1l1.activity.venderId = this.venderId; ilII1l1.activity.shopName = this.shopName; ilII1l1.activity.startTime = iIlII1I; ilII1l1.activity.endTime = i1llllll; if (iIlII1I && iIlII1I > this.timestamp()) { this.putMsg("活动未开始"); this.stop(); return; } if (i1llllll && i1llllll < this.timestamp()) { this.putMsg("活动已结束"); this.stop(); return; } let Ii1iI111 = await this.gzslApi("getGoodsGiftPrizeAndWare", {}, true); this.debug(Ii1iI111); if (Ii1iI111 && Ii1iI111.status === "1") { this.putMsg(Ii1iI111.data || "空气"); return; } let ilIli1ii = Ii1iI111?.["msg"] || "领取失败"; this.putMsg(ilIli1ii); this.wxStop(ilIli1ii); return; } return; } if (this.mode === "jinggeng") { await this.setMixNick(); let lliiIiI = await this.jinggengShopInfo(), iiIi11Il = parseInt(lliiIiI(".lastnum").text()), I1IIIII1 = parseInt(lliiIiI("#addnum").text()); if (isNaN(iiIi11Il) || isNaN(I1IIIII1)) { let ii1iil1l = lliiIiI("#description").text(); this.debug("重匹规则", ii1iil1l); const lIliilIi = ii1iil1l.match(/加购(\d+)个宝贝/); if (!lIliilIi) { this.putMsg("未匹配到加购数量"); return; } iiIi11Il = parseInt(lIliilIi[1]); I1IIIII1 = lliiIiI(".btnState2").length; } this.debug("needCollectionSize:" + iiIi11Il, "hasCollectionSize:" + I1IIIII1); if (I1IIIII1 >= iiIi11Il) { this.putMsg("已领取过"); return; } const iiIIi1ll = lliiIiI(".btnState1").map((iiiiili, I1lI1l11) => lliiIiI(I1lI1l11).attr("id") || lliiIiI(I1lI1l11).attr("onclick")?.["match"](/\(([^)]+)\)/)?.[1]).get(); this.debug(iiIIi1ll); while (I1IIIII1 < iiIi11Il && iiIIi1ll.length > 0) { await this.sleep(2000); let IIiIIii1 = await this.jinggengApi("postAddCart", { "itemId": iiIIi1ll.shift() }); this.debug(IIiIIii1); if (IIiIIii1 && IIiIIii1.succ) { I1IIIII1++; let I1Il1lII = IIiIIii1.msg, Iii1Ii1I = this.parseJSON(I1Il1lII); if (Iii1Ii1I) { if (Iii1Ii1I?.["actLogDto"]?.["remark"]) { this.putMsg(Iii1Ii1I?.["actLogDto"]?.["remark"]); return; } } } else { this.putMsg(IIiIIii1?.["msg"] || "加购失败"); return; } } return; } if (this.mode == "hdb") { await this.login(); await this.reportPVUV(); await this.loadFrontAct(); await this.loadFrontAward(); let II1II1I = await this.hdbApi("loadAddCartSetting"); !(II1II1I && II1II1I.succ) && this.putMsg(II1II1I?.["message"]); if (II1II1I?.["result"]?.["hasReceiveAward"]) { this.putMsg("已领取"); return; } let llIiiI11 = II1II1I.result?.["addCartSetting"]?.["itemAmount"] ?? 5; if (this.openCard === 0 && this.prizeList && this.prizeList.filter(ili1iiIl => ["JD_MARKET"].includes(ili1iiIl.awardType)).length > 0) { await this.bindWithVender(); if (this.canNotOpenCard) return this.reseCookieStatus(); } let iii1iIIi = await this.hdbApi("loadFrontItems"); !(iii1iIIi && iii1iIIi.succ) && this.putMsg(iii1iIIi?.["message"]); let I11llIlI = iii1iIIi?.["result"] ?? [], l111ill1 = I11llIlI.filter(IiI1I1I1 => IiI1I1I1.isFinish == 1).length, l1il11li = I11llIlI.filter(ilIIliI1 => ilIIliI1.isFinish == 0); while (l111ill1 < llIiiI11 && l1il11li.length > 0) { let l1Il1lli = l1il11li.shift().skuId; this.debug("加购skuId:" + l1Il1lli); let iililIll = 4; while (iililIll-- > 0) { let iIIIi1l1 = await this.hdbApi("reportActionLog", { "skuId": l1Il1lli, "actionType": "addCart" }); if (iIIIi1l1 && iIIIi1l1.succ) { l111ill1++; await this.sleep(1000); break; } let Ii1li1Il = iIIIi1l1?.["message"]; if (Ii1li1Il?.["includes"]("关注店铺") && (await this.follow())) { await this.sleep(1000); continue; } if (Ii1li1Il?.["includes"]("会员") && retry) { await this.bindWithVender(); if (this.canNotOpenCard) return this.reseCookieStatus(); await this.sleep(1000); continue; } this.wxStop(Ii1li1Il); this.putMsg(Ii1li1Il); return; } } if (l111ill1 < llIiiI11) { this.log("加购数量不足,不领取"); return; } this.debug("加购完成 " + l111ill1 + " - " + llIiiI11); let iiilIii = 2; while (iiilIii-- > 0) { let lIIli11l = await this.hdbApi("postAddCartFrontAct"); this.debug(lIIli11l); if (lIIli11l && lIIli11l.succ) { if (lIIli11l.result.succ) { this.putMsg(lIIli11l.result?.["dmActivityLog"]?.["awardName"] || "空气"); return; } else this.putMsg(lIIli11l.result?.["errorMsg"] || lIIli11l.result?.["message"]); } let IilIIli1 = lIIli11l?.["message"]; if (IilIIli1?.["includes"]("关注店铺") && (await this.follow())) { await this.sleep(1000); continue; } this.putMsg(IilIIli1); this.wxStop(IilIIli1); return; } return; } await this.getDefenseUrls(); if (["10024"].includes(this.activityType)) { await this.login(); let iIIlIIil = await this.lzkjApi("api/prize/drawPrize"); if (iIIlIIil && iIIlIIil.resp_code === 0) { if (iIIlIIil.data?.["drawNumber"] > 0) { this.putMsg("已领取"); return; } let ilIIliIl = iIIlIIil.data?.["prizeInfo"] || []; ilIIliIl = ilIIliIl.filter(il1liI1i => il1liI1i.prizeType == 1); this.openCard = ilIIliIl.some(IillilIl => IillilIl.beanNum >= II1Ill11); } let liIli1ii = await this.lzkjApi("api/task/" + this.type + "/activity"); if (liIli1ii && liIli1ii.resp_code === 0) { let ili1lIIl = liIli1ii.data?.["addWares"] || {}, Il1llli = ili1lIIl?.["skuInfoVO"] || [], lllilliI = ili1lIIl?.["completeCount"] || 0, iil11i1l = ili1lIIl?.["finishNum"] || 0, I1l11Ill = ili1lIIl?.["oneClickPurchase"] || 0, Iiilllil = ili1lIIl?.["taskId"], iiiII11i = liIli1ii.data?.["prizeResultNum"] || 10; Il1llli = Il1llli.filter(iil11lI1 => iil11lI1.status === 0); if (iiiII11i <= 0) { this.putMsg("已领完"); this.stop(); return; } if (iil11i1l - lllilliI > Il1llli.length) { this.putMsg("加购商品数量错误"); this.stop(); return; } if (["1005", "1006", "1002"].includes(this.joinCode)) { if (!this.openCard) return this.putMsg(this.joinDes); await this.getShopOpenCardInfo(); await this.bindWithVender(); if (this.canNotOpenCard) return this.putMsg(this.joinDes); await this.login(false); } if (I1l11Ill === 0) { this.debug("一键加购"); let iIllill1 = await this.lzkjApi("api/task/" + this.type + "/toDo", { "taskId": Iiilllil, "skuId": "" }); if (iIllill1 && iIllill1.resp_code === 0) { this.putMsg(iIllill1.data?.["prizeName"]); return; } let iI1lIIl = iIllill1?.["resp_msg"]; this.putMsg(iI1lIIl); this.wxStop(iI1lIIl); return; } let ll11ili = 0; for (let ii11I1II = 0; ii11I1II < Il1llli.length; ii11I1II++) { let iilI1I1I = await this.lzkjApi("api/task/" + this.type + "/toDo", { "taskId": Iiilllil, "skuId": Il1llli[ii11I1II].skuId }); if (iilI1I1I && iilI1I1I.resp_code === 0) { if (iilI1I1I.data) { if (iilI1I1I.data?.canSend === 4) { this.putMsg("今日奖品已发完"); this.stop(); return; } this.putMsg(iilI1I1I.data?.["prizeName"]); return; } continue; } let illi11II = iilI1I1I?.["resp_msg"]; this.putMsg(illi11II); if (illi11II && illi11II.includes("会员等级不足")) return; ll11ili++; if (ll11ili > 3) return; this.wxStop(illi11II); } } else this.putMsg(liIli1ii?.["resp_msg"] || "获取任务错误"), this.wxStop(liIli1ii?.["resp_msg"]); return; } await this.wxCommonInfo(); await this.getSimpleActInfoVo(); this.index === 0 && (await this.getShopInfo()); this.defenseUrls.length === 0 ? await this.getMyPing() : await this.initPinToken(); await this.accessLog(); let II1IiIli = await this.activityContent(); if (!II1IiIli?.["result"] || !II1IiIli?.["data"]) { this.putMsg(II1IiIli?.["errorMessage"]); return; } let l1II1111 = II1IiIli.data?.["cpvos"] ?? [], ll111lII = II1IiIli.data?.["drawInfo"] ?? {}, liIllllI = II1IiIli.data?.["drawInfo"]?.["drawInfo"]?.["beanNum"], liiiIll = II1IiIli.data?.["needCollectionSize"], IlliIlIi = II1IiIli.data?.["hasCollectionSize"] ?? 0, i11I1iII = II1IiIli.data?.["oneKeyAddCart"] ?? 0, Ili11i1I = l1II1111.filter(l1Il111i => !l1Il111i.collection); if (![6, 7, 9, 13, 14, 15, 16].includes(ll111lII.drawInfoType)) { this.putMsg("垃圾或领完"); this.stop(); return; } if (liiiIll - IlliIlIi > Ili11i1I.length) { this.putMsg("加购商品数量错误"); this.stop(); return; } let l1111l1I = this.activityType === 6 ? "addCart" : "collection", ilI1I11I = this.domain.includes("cjhy") ? false : true; if (i11I1iII === 1) { let lil1I1iI = 5; while (lil1I1iI-- > 0) { let l1i1I11 = await this.wxApi("wxCollectionActivity/oneKeyAddCart", { "activityId": this.activityId, "pin": this.secretPin, "productIds": JSON.stringify(Ili11i1I.map(iiiiIII => iiiiIII.skuId)) }); this.debug(l1i1I11); if (l1i1I11 && l1i1I11.result) { IlliIlIi = liiiIll; break; } let i1lIII11 = l1i1I11?.["errorMessage"]; if (!i1lIII11) break; if (i1lIII11.includes("购物车已经满了")) continue; if (i1lIII11.includes("会员") && liIllllI && liIllllI >= II1Ill11) { await this.getShopOpenCardInfo(); let I1iiIli1 = await this.bindWithVender(); if (I1iiIli1 && I1iiIli1.success && ["0", "9003"].includes(I1iiIli1.busiCode)) continue; } this.putMsg(i1lIII11); this.wxStop(i1lIII11); return; } } else { if (Ili11i1I.length === 0 && ilI1I11I) { Ili11i1I.push(l1II1111[0]); } while ((ilI1I11I || IlliIlIi < liiiIll) && Ili11i1I.length > 0) { ilI1I11I = false; let ii1li1ii = Ili11i1I.shift().productId; this.debug("加购productId:" + ii1li1ii); let llI11I1I = 5; while (llI11I1I-- > 0) { let liIlil11 = await this.wxApi("wxCollectionActivity/" + l1111l1I, { "activityId": this.activityId, "pin": this.secretPin, "productId": ii1li1ii }); this.debug(liIlil11); if (liIlil11 && liIlil11.result) { IlliIlIi = liIlil11.data?.["hasAddCartSize"] ?? IlliIlIi + 1; break; } let IIll1ii = liIlil11?.["errorMessage"]; if (!IIll1ii) break; if (IIll1ii.includes("购物车已经满了")) continue; if (IIll1ii.includes("商品失效无法加购")) continue; if (IIll1ii.includes("加入购物车失败")) continue; if (IIll1ii.includes("会员") && liIllllI && liIllllI >= II1Ill11) { await this.getShopOpenCardInfo(); let l1IlIi1 = await this.bindWithVender(); if (l1IlIi1 && l1IlIi1.success && ["0", "9003"].includes(l1IlIi1.busiCode)) { continue; } } this.putMsg(IIll1ii); this.wxStop(IIll1ii); return; } } } if (IlliIlIi < liiiIll) { this.putMsg("加购数量不足,不领取"); return; } this.debug("加购完成 " + IlliIlIi + " - " + liiiIll); let i1liIlII = await this.wxApi("wxCollectionActivity/getPrize", { "activityId": this.activityId, "pin": this.secretPin }); this.debug(i1liIlII); if (i1liIlII && i1liIlII.result && i1liIlII.data?.["drawOk"]) { this.putMsg(i1liIlII.data.name); return; } let l1l1li11 = i1liIlII?.["errorMessage"] || i1liIlII?.["data"]?.["errorMessage"]; if (!l1l1li11) return; this.putMsg(l1l1li11); this.wxStop(l1l1li11); if (l1l1li11.includes("日奖品全部被领取")) {} } } i11Iiii.activity = { "activityUrl": activityUrl }; i11Iiii.TaskClass = iiilI111; i11Iiii.run({ "whitelist": ["1-200"], "main_thread": 3, "wxProxySmart": 2 });