|
|
@@ -9,24 +9,25 @@
|
|
|
const scriptName = `华文数交首发`;
|
|
|
const magicJS = MagicJS(scriptName, "INFO");
|
|
|
const HbcpreConstKey = {
|
|
|
+ // 基础数据
|
|
|
+ decryptionEnabled: 'HbcpreDecryptionEnabled',
|
|
|
token: 'HbcpreUserToken',
|
|
|
userPhone: 'HbcpreUserPhoneNum',
|
|
|
userId: 'HbcpreUserId',
|
|
|
userInfo: 'HbcpreUserInfo',
|
|
|
- orderFastModeEnabled: 'HbcpreOrderFastModeEnabled',
|
|
|
- collectionClassList: 'HbcpreCollectionClassList',
|
|
|
- collectionMaxNumLimit: 'HbcpreCollectionMaxNumLimit',
|
|
|
- collectionLockMaxNum: 'HbcpreCollectionLockMaxNum',
|
|
|
- castingId: 'HbcpreCastingId',
|
|
|
- collectionName: 'HbcpreCollectionName',
|
|
|
- orderLimitPrice: 'HbcpreOrderLimitPrice',
|
|
|
- floatPriceIntaval: 'HbcpreFloatPriceIntaval',
|
|
|
- itemCntRwData: 'HbcpreItemCntRwData',
|
|
|
- walletPayPassword: 'HbcpreWalletPayPassword',
|
|
|
-
|
|
|
+ walletPayPassword: 'HbcpreWalletPayPassword',// 钱包支付密码
|
|
|
+ myOwnSeriesCntFakeData: 'HbcpreMyOwnSeriesCntFakeData', // 资产的伪装数据
|
|
|
+ myOwnSeriesListDict: 'HbcpreMyOwnSeriesList',
|
|
|
+ myOwnSeriesDetail: 'HbcpreMyOwnSeriesDetail',
|
|
|
+
|
|
|
+ // 首发相关的
|
|
|
+ homeSeriesDataGrabEnabled: 'HbcpreHomeSeriesDataGrabEnabled',
|
|
|
+ homeSeriesOpenTimeOffset: 'HbcpreOpeningTimeOffset',
|
|
|
homeSeriesList: 'HbcpreHomeSeriesList',
|
|
|
+ homeSeriesInfo: 'HbcpreHomeSeriesInfo',
|
|
|
homeSeriesId: 'HbcpreHomeSeriesId',
|
|
|
homeSeriesName: 'HbcpreHomeSeriesName',
|
|
|
+ homeSeriesLimitBuy: 'HbcpreHomeSeriesLimitBuy',
|
|
|
};
|
|
|
|
|
|
const gUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1`;
|
|
|
@@ -101,46 +102,39 @@ async function tryGrabNew() {
|
|
|
magicJS.logger.info(`缺少首发产品信息`);
|
|
|
return;
|
|
|
}
|
|
|
- let itemList = magicJS.data.read(HbcpreConstKey.homeSeriesList, []);
|
|
|
-
|
|
|
- let willPrice = Number(magicJS.data.read(HbcpreConstKey.orderLimitPrice, 99999));
|
|
|
- let priceFloatInterval = Number(magicJS.data.read(HbcpreConstKey.floatPriceIntaval, 0));
|
|
|
+ let onlyUseCacheData = true;
|
|
|
let willBuyList = [];
|
|
|
- if (itemId.length > 0 && itemId > 0) {
|
|
|
- magicJS.logger.info(`通过产品系列号来进行匹配`);
|
|
|
- for (let i = 0; i < itemList.length; i++) {
|
|
|
- const iData = itemList[i];
|
|
|
- const seriesId = iData.seriesId;
|
|
|
- const price = parseFloat(iData.amount || 99999.99);
|
|
|
- if (seriesId == itemId) {
|
|
|
- if (price <= willPrice + priceFloatInterval) {
|
|
|
- willBuyList.push(iData);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (willBuyList.length == 0 && itemName) {
|
|
|
- magicJS.logger.info(`通过产品名称来进行匹配`);
|
|
|
- for (let i = 0; i < itemList.length; i++) {
|
|
|
- const iData = itemList[i];
|
|
|
- const seriesName = iData.seriesName;
|
|
|
- const price = parseFloat(iData.amount || 99999.99);
|
|
|
- if (seriesName.indexOf(itemName) > -1) {
|
|
|
- if (price <= willPrice + priceFloatInterval) {
|
|
|
- willBuyList.push(iData);
|
|
|
- }
|
|
|
- break;
|
|
|
+ let seriesSimple = getHomeSeriesCache(itemId, itemName);
|
|
|
+ if(seriesSimple){
|
|
|
+ willBuyList.push(seriesSimple);
|
|
|
+ } else {
|
|
|
+ if(!onlyUseCacheData){
|
|
|
+ seriesSimple = await filterStableSeriesData(itemId, itemName);
|
|
|
+ if(seriesSimple){
|
|
|
+ willBuyList.push(seriesSimple);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (willBuyList.length == 0) {
|
|
|
magicJS.logger.info(`没有匹配符合要求的产品`);
|
|
|
}
|
|
|
for (let i = 0; i < willBuyList.length; i++) {
|
|
|
const iData = willBuyList[i];
|
|
|
- magicJS.logger.info(`开始进行【${iData.seriesName}#${iData.amount || iData.price}】快捷下单`);
|
|
|
- let buyRet = await primOrder(iData.seriesId, 1);
|
|
|
+ magicJS.logger.info(`开始进行【${iData.seriesName}】首发抢购`);
|
|
|
+ let seriesInfo = getHomeSeriesInfoCache(iData.seriesId);
|
|
|
+ let limitBuyNum = magicJS.data.read(HbcpreConstKey.homeSeriesLimitBuy, 1);
|
|
|
+ if(seriesInfo){
|
|
|
+ limitBuyNum = seriesInfo.limitBuy;
|
|
|
+ } else {
|
|
|
+ if(!onlyUseCacheData){
|
|
|
+ seriesInfo = await getSeriesInfo(iData.seriesId);
|
|
|
+ if(seriesInfo){
|
|
|
+ limitBuyNum = seriesInfo.limitBuy;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let buyRet = await primOrder(iData.seriesId, limitBuyNum || 1);
|
|
|
if (buyRet) {
|
|
|
if (buyRet.code == 200) {
|
|
|
// magicJS.notification.appendNotifyInfo(`🎉产品【${iData.seriesName}】快捷下单成功`);
|
|
|
@@ -176,6 +170,92 @@ async function tryGrabNew() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function getHomeSeriesCache(seriesId, seriesName) {
|
|
|
+ let dataList = magicJS.data.read(HbcpreConstKey.homeSeriesList, []);
|
|
|
+ if(seriesId != void 0){
|
|
|
+ for (let i = 0; i < dataList.length; i++) {
|
|
|
+ if (seriesId == dataList[i].seriesId) {
|
|
|
+ return dataList[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(seriesName != void 0){
|
|
|
+ for (let i = 0; i < dataList.length; i++) {
|
|
|
+ if (dataList[i].seriesName.indexOf(seriesName) > -1) {
|
|
|
+ return dataList[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+}
|
|
|
+
|
|
|
+function getHomeSeriesInfoCache(seriesId){
|
|
|
+ let storeKey = `${HbcpreConstKey.homeSeriesInfo}#${seriesId}`;
|
|
|
+ return magicJS.data.read(storeKey, null);
|
|
|
+}
|
|
|
+
|
|
|
+async function filterStableSeriesData(seriesId, seriesName) {
|
|
|
+ let pageNum = 1;
|
|
|
+ let retMateItem = null;
|
|
|
+ while (pageNum < 100) {
|
|
|
+ let pageDataRet = await getHomeSeries(pageNum, 10);
|
|
|
+ if (!pageDataRet) {
|
|
|
+ await magicJS.utils.sleep(500);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(pageDataRet.code == 217){
|
|
|
+ // token失效
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(pageDataRet.code != 200){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ let itemList = pageDataRet.data.list;
|
|
|
+ for (let i = 0; i < itemList.length; i++) {
|
|
|
+ if (seriesId && itemList[i].seriesId == seriesId) {
|
|
|
+ retMateItem = itemList[i];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (seriesName && itemList[i].seriesName.indexOf(seriesName) > -1){
|
|
|
+ retMateItem = itemList[i];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (retMateItem) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (pageData.hashNext != 1) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ pageNum += 1;
|
|
|
+ await magicJS.utils.sleep(500);
|
|
|
+ }
|
|
|
+ return retMateItem;
|
|
|
+}
|
|
|
+
|
|
|
+async function getHomeSeries(page, pageSize = 10){
|
|
|
+ let reqData = {
|
|
|
+ page: page,
|
|
|
+ pageSize: pageSize,
|
|
|
+ };
|
|
|
+ let result = await hbRequest({ API: '/mall/home/series', METHOD: 'get' }, reqData);
|
|
|
+ if(result.code == 200){
|
|
|
+ return result.data;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+}
|
|
|
+
|
|
|
+async function getSeriesInfo(seriesId){
|
|
|
+ let reqData = {
|
|
|
+ seriesId: seriesId,
|
|
|
+ };
|
|
|
+ let result = await hbRequest({ API: '/mall/series/seriesInfo', METHOD: 'get' }, reqData);
|
|
|
+ if(result.code == 200){
|
|
|
+ return result.data;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+}
|
|
|
+
|
|
|
function shallowClone(obj) {
|
|
|
let clone = {};
|
|
|
for (let key in obj) {
|
|
|
@@ -201,19 +281,6 @@ async function primOrder(seriesId, buyNum) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-async function normalOrder(worksItem) {
|
|
|
- let reqData = {
|
|
|
- seriesType: worksItem.seriesType,
|
|
|
- seriesId: worksItem.seriesId,
|
|
|
- worksId: worksItem.worksId,
|
|
|
- worksNo: worksItem.worksNo,
|
|
|
- amount: String(parseInt(worksItem.priceCny)),
|
|
|
- };
|
|
|
- let result = await hbRequest({ API: '/mall/sell/order', METHOD: 'post' }, reqData);
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
async function getMarketWorksData(seriesId, status, sort, pageSize, pageNum) {
|
|
|
// sort 1=价格顺序 3=价格倒序 0=编号顺序 2=编号倒序
|
|
|
let reqData = {
|