|
|
@@ -112,8 +112,14 @@ async function Main() {
|
|
|
function checkHandleRequest() {
|
|
|
}
|
|
|
|
|
|
-function setRechargeDiscReqData(id, paramStr) {
|
|
|
- let data = magicJS.data.read(UnicomConstKey.RechargeDiscData, null);
|
|
|
+function setRechargeDiscReqData(paramStr) {
|
|
|
+ let tmpArr = paramStr.split('?');
|
|
|
+ // encTaskId可能一样
|
|
|
+ let encTaskId = tmpArr[0];
|
|
|
+ // queryData['p']就不一样
|
|
|
+ let queryData = magicJS.parseQueryStr(tmpArr[1]);
|
|
|
+
|
|
|
+ let data = magicJS.data.read(UnicomConstKey.RechargeDiscData, null)
|
|
|
let nowDateStr = magicJS.formatDate(new Date(), 'yyyy/MM/dd');
|
|
|
if (!data || data.date != nowDateStr) {
|
|
|
data = {
|
|
|
@@ -122,8 +128,10 @@ function setRechargeDiscReqData(id, paramStr) {
|
|
|
}
|
|
|
}
|
|
|
data.dict = data.dict || {};
|
|
|
- data.dict[id] = paramStr;
|
|
|
+ data.dict[paramStr] = paramStr;
|
|
|
magicJS.data.write(UnicomConstKey.RechargeDiscData, data);
|
|
|
+ magicJS.logger.info(`更新${paramStr}`);
|
|
|
+ magicJS.notification.appendNotifyInfo(`🎉话费券抢购采集成功-${paramStr}`);
|
|
|
}
|
|
|
|
|
|
function deleteRechargeDiscReqData(id) {
|
|
|
@@ -195,7 +203,19 @@ async function doGrabByNormal() {
|
|
|
const url = urlMap[id];
|
|
|
magicJS.logger.info(`${id} ${url}`);
|
|
|
magicJS.logger.info(`${JSON.stringify(task)}`);
|
|
|
- // let result = await grabDiscCoupon(url);
|
|
|
+ let result = await grabDiscCoupon(url);
|
|
|
+ if (result) {
|
|
|
+ let paramStr = url.split('/').pop();
|
|
|
+ switch (result.status) {
|
|
|
+ case '0000':
|
|
|
+ case '1004'://库存不足
|
|
|
+ deleteRechargeDiscReqData(paramStr);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ tipsText += `优惠折扣券[${taks.taskName}]${result.msg}\n`;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -209,17 +229,18 @@ async function doGrabByCacheQuery() {
|
|
|
let tipsText = ``;
|
|
|
for (let id in taskQueryData) {
|
|
|
let paramStr = taskQueryData[id];
|
|
|
- let result = await grabDiscCoupon(null, id, paramStr);
|
|
|
+ let url = `https://m.client.10010.com/AppMonthly/appMonth/dddddddddd/${paramStr}`;
|
|
|
+ let result = await grabDiscCoupon(url);
|
|
|
if (result) {
|
|
|
switch (result.status) {
|
|
|
case '0000':
|
|
|
case '1004'://库存不足
|
|
|
- deleteRechargeDiscReqData(id);
|
|
|
+ deleteRechargeDiscReqData(paramStr);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- tipsText += `优惠折扣券[${id}]${result.msg}\n`;
|
|
|
+ tipsText += `优惠折扣券[${paramStr}]${result.msg}\n`;
|
|
|
}
|
|
|
}
|
|
|
if (tipsText.length > 0) {
|
|
|
@@ -320,8 +341,7 @@ async function doOnline(token_online) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-async function grabDiscCoupon(url, id, paramStr) {
|
|
|
- url = url || `https://m.client.10010.com/AppMonthly/appMonth/dddddddddd/${id}?p=${paramStr}`;
|
|
|
+async function grabDiscCoupon(url) {
|
|
|
let headers = { ...gCommonHeaders };
|
|
|
|
|
|
let options = {
|