shawenguan преди 1 година
родител
ревизия
ebabf4f6f2
променени са 1 файла, в които са добавени 33 реда и са изтрити 31 реда
  1. 33 31
      Scripts/168/pksPlanHelper.js

+ 33 - 31
Scripts/168/pksPlanHelper.js

@@ -568,34 +568,43 @@ async function checkLastRecordPlanBuy() {
 	if (!lastBetRecord || lastBetRecord.drawIssue == void 0) {
 		return;
 	}
-	let pksInfoToken = magicJS.data.read('168_PksInfoToken', `tpM9v7lYiy0ctYv9AOlaztoyUcH9y/YR2Gt2jQT8dBd1edkFSV8Vuu%2BQ00/kNgeeksf`);
-	let lotteryRet = await getLotteryPksInfo(gLotteryCode, pksInfoToken);
+	let lotteryRet = await getLotteryPksInfo(gLotteryCode);
 	if (!lotteryRet) {
 		return;
 	}
-	if (lotteryRet.errorCode != 0) {
+	let planArr = lastBetRecord.planStr.split(',');
+	if (planArr.length > 3) {
 		return;
 	}
-	let finalDrawResult = lotteryRet.result;
-	if (finalDrawResult && lastBetRecord) {
-		if (lastBetRecord.drawIssue == finalDrawResult.preDrawIssue) {
-			if (checkHitPrize(finalDrawResult.preDrawCode, lastBetRecord.planStr, 0)) {
-				magicJS.data.write(`DIII_CaiLeYuan_Lottery_${gCaiLeLotteryType}#1`, `{}`);
-			} else {
-				let drawIssue = finalDrawResult.drawIssue;
-				let drawTime = finalDrawResult.drawTime;
-				let turnOneCost = lastBetRecord.betAmount * 2;
-				let tipsMsg = `推荐号码:${lastBetRecord.planStr} 单注:${turnOneCost} \n期号:${drawIssue} 开奖时间:${drawTime}`;
-				if (isPlanCEnabled() && isPlanLotteryAutoBet()) {
-					let maxBetAmount = getPlanLotteryMaxBetAmount();
-					let betRet = await tryDragonBetPoor(finalDrawResult.drawIssue, ranking, lastBetRecord.planStr, turnOneCost, maxBetAmount);
-				}
-				magicJS.logger.info(tipsMsg);
-				magicJS.notification.appendNotifyInfo(tipsMsg);
-			}
+	if (lotteryRet.preDrawIssue - lastBetRecord.drawIssue > 1) {
+		magicJS.logger.info(`最后期号${lastBetRecord.drawIssue}`);
+		magicJS.data.write(`DIII_CaiLeYuan_Lottery_${gCaiLeLotteryType}#${ranking}`, `{}`);
+		return;
+	}
+	if (lastBetRecord.drawIssue == String(lotteryRet.preDrawIssue)) {
+		if (checkHitPrize(lotteryRet.preDrawCode, lastBetRecord.planStr, 0)) {
+			magicJS.data.write(`DIII_CaiLeYuan_Lottery_${gCaiLeLotteryType}#${ranking}`, `{}`);
 		} else {
-			magicJS.data.write(`DIII_CaiLeYuan_Lottery_${gCaiLeLotteryType}#1`, `{}`);
+			let drawIssue = lotteryRet.drawIssue;
+			let drawTime = lotteryRet.drawTime;
+			let turnOneCost = lastBetRecord.betAmount * 2;
+			let turnNum = Math.log2(turnOneCost);
+			if (turnNum > 9) {
+				// 超过10期了
+				magicJS.notification.post(magicJS.scriptName, `⚠️追号失败 号码:${planStr} 单注:${turnOneCost}`);
+				magicJS.data.write(`DIII_CaiLeYuan_Lottery_${gCaiLeLotteryType}#${ranking}`, `{}`);
+				return;
+			}
+			let tipsMsg = `[尾末]推荐号码:${lastBetRecord.planStr} 单注:${turnOneCost} \n期号:${drawIssue} 开奖时间:${drawTime}`;
+			if (isPlanCEnabled() && isPlanLotteryAutoBet()) {
+				let maxBetAmount = getPlanLotteryMaxBetAmount();
+				let betRet = await tryDragonBetPoor(lotteryRet.drawIssue, ranking, lastBetRecord.planStr, turnOneCost, maxBetAmount);
+			}
+			magicJS.logger.info(tipsMsg);
+			magicJS.notification.appendNotifyInfo(tipsMsg);
 		}
+	} else {
+		magicJS.data.write(`DIII_CaiLeYuan_Lottery_${gCaiLeLotteryType}#${ranking}`, `{}`);
 	}
 }
 
@@ -1454,19 +1463,12 @@ async function getExpertsRecommendDetail(userId, lotCode, groupCode = 1, ranking
 	return result.result.data;
 }
 
-async function getLotteryPksInfo(lotCode, token) {
-	const reqData = {
-		iOSVersion: '2.1.65',
-		lotCode: lotCode,
-		token: token,
-		s: '168noadv',
-	};
-	const queryStr = magicJS.objToQueryStr(reqData);
-	const url = `https://${gExpertsRecommendHost}/pks/getLotteryPksInfo.do?${queryStr}`;
+async function getLotteryPksInfo(lotCode) {
+	const url = `https://${gBuyPlanHost}/api/pks/getLotteryPksInfo.do?lotCode=${lotCode}`;
 	magicJS.logger.info(url);
 	const myRequest = {
 		url: url,
-		headers: gExpertsRecommendHeaders,
+		headers: gBuyPlanHeaders,
 		body: ``
 	};
 	let result = await magicJS.http.get(myRequest).then(response => {