|
|
@@ -27,10 +27,10 @@ hostname=app.moutai519.com.cn,h5.moutai519.com.cn
|
|
|
const lk = new ToolKit(`i茅台`, `IMouTaiHelper`);
|
|
|
|
|
|
|
|
|
-let G_P_C_MAP = {};
|
|
|
-
|
|
|
+let G_SHOP_PC_MAP = {}; //{[province:string]:{[city:string]=shopId}};
|
|
|
+let G_SHOP_SRC_MAP = {};//{[shopId:string]: any};
|
|
|
let G_MT_VERSION = '1.6.2'; // MT版本
|
|
|
-let G_MT_R = 'clips_OlU6TmFRag5rCXwbNAQ/Tz1SKlN8THcecBp/HGhHdw==';
|
|
|
+let G_MT_R = 'clips_OlU6TmFRag5rCXwbNAQ/Tz1SKlN8THcecBp/HGhHdw==';// 非必填
|
|
|
|
|
|
let G_USER_AGENT = 'iOS;16.6.1;Apple;?unrecognized?';
|
|
|
|
|
|
@@ -45,13 +45,14 @@ const iMT_Products = {
|
|
|
};
|
|
|
|
|
|
const iMT_Location = {
|
|
|
- "province": "广东省",
|
|
|
- "city": "广州市",
|
|
|
- "lat": "23.121952",
|
|
|
- "lng": "113.392636",
|
|
|
+ province: "广东省", // 省份
|
|
|
+ city: "广州市", // 城市
|
|
|
+ district: "天河区|海珠区", // 需要申购的区域,多个区域以 | 隔开,留空为随机申购全市所有门店
|
|
|
+ lat: "23.121952",
|
|
|
+ lng: "113.392636",
|
|
|
};
|
|
|
|
|
|
-const iMT_BuyItemCodes = ["10941", "10942"];
|
|
|
+const iMT_BuyItemCodes = ["10941", "10942"]; // 申购商品ID名单列表
|
|
|
|
|
|
|
|
|
let retBody;
|
|
|
@@ -82,8 +83,8 @@ async function main() {
|
|
|
G_USER_AGENT = userData.userAgent;
|
|
|
let mapDataRet = await getProvinceCityMapData();
|
|
|
// lk.log(`mapDataRet=${JSON.stringify(mapDataRet)}`);
|
|
|
- G_P_C_MAP = mapDataRet[0];
|
|
|
- let sourceData = mapDataRet[1];
|
|
|
+ G_SHOP_PC_MAP = mapDataRet[0];
|
|
|
+ G_SHOP_SRC_MAP = mapDataRet[1];
|
|
|
|
|
|
let nowDate = parseInt((new Date().getTime() / 1000).toString()); // 当前时间戳
|
|
|
let zeroTimeStamp = (nowDate - (nowDate % 86400) - 3600 * 8) * 1000; // 今日零点时间戳
|
|
|
@@ -111,7 +112,7 @@ async function main() {
|
|
|
for(let i=0; i < itemCodes.length;i++){
|
|
|
const itemId = itemCodes[i];
|
|
|
lk.log(`#############${itemId}#############`);
|
|
|
- let maxShopId = await getShopItem(sessionId,itemId,userData.token,userData.deviceId,province,city,zeroTimeStamp);
|
|
|
+ let maxShopId = await getShopItem(sessionId,itemId,userData.token,userData.deviceId,province,city,iMT_Location.district||'',zeroTimeStamp);
|
|
|
if(!maxShopId || maxShopId == '0'){
|
|
|
continue;
|
|
|
}
|
|
|
@@ -289,6 +290,80 @@ function getUserData() {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+// 获取Appstore应用版本
|
|
|
+async function getAppVersion(id='1600482450') {
|
|
|
+ return new Promise((resolve, _reject) => {
|
|
|
+ try {
|
|
|
+ const headers = {};
|
|
|
+ const body = ``;
|
|
|
+ const url = `https://itunes.apple.com/cn/lookup?id=${id}`;
|
|
|
+ let options = {
|
|
|
+ url: url,
|
|
|
+ headers: headers,
|
|
|
+ body: body
|
|
|
+ };
|
|
|
+ lk.get(options, async (error, _response, data) => {
|
|
|
+ let ret;
|
|
|
+ try {
|
|
|
+ if (error) {
|
|
|
+ lk.execFail();
|
|
|
+ } else {
|
|
|
+ const obj = JSON.parse(data);
|
|
|
+ if(obj.resultCount > 0){
|
|
|
+ ret = obj.results[0].version;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ lk.logErr(e);
|
|
|
+ lk.execFail();
|
|
|
+ } finally {
|
|
|
+ resolve(ret);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ lk.logErr(e);
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 获取Appstore应用版本
|
|
|
+async function getAppVersion2(name='i茅台', id='1600482450') {
|
|
|
+ return new Promise((resolve, _reject) => {
|
|
|
+ try {
|
|
|
+ const headers = {};
|
|
|
+ const body = ``;
|
|
|
+ const url = `https://apps.apple.com/cn/app/${encodeURIComponent(name)}/id1600482450`;
|
|
|
+ let options = {
|
|
|
+ url: url,
|
|
|
+ headers: headers,
|
|
|
+ body: body
|
|
|
+ };
|
|
|
+ lk.get(options, async (error, _response, data) => {
|
|
|
+ let ret;
|
|
|
+ try {
|
|
|
+ if (error) {
|
|
|
+ lk.execFail();
|
|
|
+ } else {
|
|
|
+ let version = data.match(/whats-new__latest__version">版本 ([\d\.]+)/)[1];
|
|
|
+ if(version){
|
|
|
+ ret = version;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ lk.logErr(e);
|
|
|
+ lk.execFail();
|
|
|
+ } finally {
|
|
|
+ resolve(ret);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ lk.logErr(e);
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
async function getMtv(deviceId, mtVersion) {
|
|
|
return new Promise((resolve, _reject) => {
|
|
|
try {
|
|
|
@@ -508,7 +583,7 @@ function checkShopItemIdIndex(shopObj, itemId){
|
|
|
return retIndex;
|
|
|
}
|
|
|
|
|
|
-async function getShopItem(sessionId, itemId, token, deviceId, province, city, zeroTimeStamp) {
|
|
|
+async function getShopItem(sessionId, itemId, token, deviceId, province, city, district, zeroTimeStamp) {
|
|
|
return new Promise((resolve, _reject) => {
|
|
|
try {
|
|
|
const headers = {
|
|
|
@@ -535,7 +610,11 @@ async function getShopItem(sessionId, itemId, token, deviceId, province, city, z
|
|
|
headers: headers,
|
|
|
body: body
|
|
|
};
|
|
|
- lk.log(`获取[${province + city}]门店库存`);
|
|
|
+ if(lk.isEmpty(district)){
|
|
|
+ lk.log(`获取[${province + city}]门店库存`);
|
|
|
+ }else{
|
|
|
+ lk.log(`获取[${province + city}-${district}]门店库存`);
|
|
|
+ }
|
|
|
// lk.log(url);
|
|
|
lk.get(options, async (error, _response, data) => {
|
|
|
let ret;
|
|
|
@@ -544,21 +623,28 @@ async function getShopItem(sessionId, itemId, token, deviceId, province, city, z
|
|
|
lk.execFail();
|
|
|
} else {
|
|
|
const jsonRetObj = JSON.parse(data);
|
|
|
- if (jsonRetObj.code == 2000) {
|
|
|
- const rspData = jsonRetObj.data || {};
|
|
|
- const shops = rspData.shops || [];
|
|
|
- const shopIds = G_P_C_MAP[province][city];
|
|
|
- // lk.log(`data=${JSON.stringify(shopIds)}`);
|
|
|
- for (let i = 0; i < shops.length; i++) {
|
|
|
- const shopObj = shops[i];
|
|
|
- if(shopIds.indexOf(shopObj.shopId) > -1){
|
|
|
- if (checkShopItemIdIndex(shopObj, itemId) > -1) {
|
|
|
- lk.log(`shopObj=${JSON.stringify(shopObj)}`);
|
|
|
- ret = shopObj.shopId;
|
|
|
- break;
|
|
|
+ const shopIds = G_SHOP_PC_MAP[province][city];
|
|
|
+ if (shopIds) {
|
|
|
+ if (jsonRetObj.code == 2000) {
|
|
|
+ const rspData = jsonRetObj.data || {};
|
|
|
+ const shops = rspData.shops || [];
|
|
|
+ // lk.log(`data=${JSON.stringify(shopIds)}`);
|
|
|
+ for (let i = 0; i < shops.length; i++) {
|
|
|
+ const shopId = shops[i].shopId;
|
|
|
+ const items = shops[i].items;
|
|
|
+ const shopInfo = shops[i];
|
|
|
+ if(shopIds.indexOf(shopId) > -1){
|
|
|
+ if (checkShopItemIdIndex(shopInfo, itemId) > -1) {
|
|
|
+ lk.log(`shopDetail=${JSON.stringify(G_SHOP_SRC_MAP[shopId])}`);
|
|
|
+ lk.log(`shopInfo=${JSON.stringify(shopInfo)}`);
|
|
|
+ ret = shopId;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }else {
|
|
|
+ lk.log(`[${province + city}]不存在门店`);
|
|
|
}
|
|
|
}
|
|
|
} catch (e) {
|