瀏覽代碼

增加编号锁单脚本

shawenguan 2 年之前
父節點
當前提交
717dfd3f55
共有 3 個文件被更改,包括 59 次插入45 次删除
  1. 5 19
      BoxJsSub/JoJo_BoxJs.json
  2. 52 24
      Scripts/gandart/gandartLock.js
  3. 2 2
      Scripts/gandart/gandartOrder.js

+ 5 - 19
BoxJsSub/JoJo_BoxJs.json

@@ -252,39 +252,25 @@
           "desc": "Tg的通知地址,如:https://api.telegram.org/bot-token/sendMessage?chat_id=-100140&parse_mode=Markdown&text="
         },
         {
-          "id": "lkIsGandartCollectionWatchLocked",
-          "name": "开启/关闭锁定监控产品",
-          "val": false,
-          "type": "boolean",
-          "desc": "默认关闭锁定"
-        },
-        {
-          "id": "lkGandartCastingId",
+          "id": "lkGandartLockCastingId",
           "name": "产品铸造品类ID",
           "val": "",
           "type": "text",
           "desc": "产品铸造品类ID"
         },
         {
-          "id": "lkGandartCollectionName",
+          "id": "lkGandartLockCollectionName",
           "name": "产品名称",
           "val": "",
           "type": "text",
           "desc": "产品名称"
         },
         {
-          "id": "lkGandartLimitPrice",
-          "name": "捡漏最高价格",
+          "id": "lkGandartLockViewSort",
+          "name": "产品编号",
           "val": 0,
           "type": "text",
-          "desc": "捡漏最高价格"
-        },
-        {
-          "id": "lkGandartFloatPriceIntaval",
-          "name": "价格浮动限制",
-          "val": 10,
-          "type": "number",
-          "desc": "价格浮动限制"
+          "desc": "产品编号"
         },
         {
           "id": "lkGandartCollectionCateLst",

+ 52 - 24
Scripts/gandart/gandartLock.js

@@ -99,6 +99,11 @@ async function all() {
         } else {
             viewSort = 0;
         }
+        let collectionName = '未知';
+        if (castingId > 0) {
+            collectionName = getCollectionNameById(castingId);
+            lk.setVal(GandartConstKey.LLockCollectionName, collectionName);
+        }
         if (castingId <= 0) {
             lk.prependNotifyInfo('⚠️请设置光予产品品类');
             hasNeedSendNotify = true;
@@ -106,10 +111,37 @@ async function all() {
             lk.prependNotifyInfo('⚠️请设置光予产品编号');
             hasNeedSendNotify = true;
         } else {
-            let itemLst = await refreshLstOnSale(castingId, price);
-            if (itemLst && itemLst.length > 0) {
-                hasNeedSendNotify = await checkToBuyAll(itemLst);
+            // 流通量
+            let collectionCirculation = 100000;
+            let pageSize = 15;
+            let totalPage = Math.ceil(collectionCirculation / pageSize);
+            let curPage = 1;
+            let collectionItem;
+            while (curPage <= totalPage) {
+                let ret = await refreshLstOnSale(castingId, viewSort);
+                if (ret && ret.success) {
+                    if (ret.collectionItem) {
+                        collectionItem = ret.collectionItem;
+                        break
+                    }
+                    totalPage = ret.totalPage;
+                    curPage += 1;
+                    if (curPage > totalPage) {
+                        break;
+                    }
+                } else {
+                    break;
+                }
+            }
+            if (collectionItem) {
+                if (collectionItem.transactionStatus == 2) {//2=可购买,4=支付中
+                    hasNeedSendNotify = await checkToBuyCollection(collectionItem);
+                } else {
+                    let tipsText = `产品${collectionItem.collectionName}#${collectionItem.viewSort}已被锁定,状态=${collectionItem.transactionStatus}`;
+                    lk.log(tipsText);
+                }
             } else {
+                lk.log(`请求锁定的产品[${collectionName}#${viewSort}]不在寄售中`);
                 hasNeedSendNotify = false;
             }
         }
@@ -120,17 +152,16 @@ async function all() {
     lk.done();
 }
 
-async function getItemOnSale(castingId, price, pageSize = 15) {
+async function refreshLstOnSale(castingId, viewSort, pageSize = 15, page = 1) {
     return new Promise((resolve, _reject) => {
         try {
-            let page = 1;
             const headers = GCommonGandartHeads;
             headers.Host = "api2.gandart.com";
             let signData = getSign();
             signData.castingId = castingId;
             signData.page = page;
             signData.pageSize = pageSize;
-            signData.sort = 1;// 1=编号,2=价格
+            signData.sort = 2;// 1=编号,2=价格
             signData.transactionStatus = 2;
             let body = lk.objToQueryStr(signData);
             let url = {
@@ -141,45 +172,42 @@ async function getItemOnSale(castingId, price, pageSize = 15) {
             let collectionName = getCollectionNameById(castingId);
             lk.log(`请求产品[${collectionName}(${castingId})]寄售列表:${body}`);
             lk.post(url, async (error, _response, data) => {
-                let retItemLst = [];
+                let finalRet = {
+                    success: false,
+                    collectionItem: null,
+                };
                 try {
                     if (error) {
                         lk.log(`获取寄售列表信息发生错误`);
                         lk.execFail();
                         lk.appendNotifyInfo(`❌获取寄售列表失败,请稍后再试`);
                     } else {
+                        finalRet.success = true;
                         let ret = JSON.parse(data);
-                        let minPrice = 99999;
                         if (ret.success) {
                             let obj = ret.obj;
+                            k.log(`获取到产品[${collectionName}]${obj.page}页寄售列表`);
+                            finalRet.totalPage = Math.floor(obj.total / obj.page_size);
                             let lst = obj.list;
                             for (let d of lst) {
-                                if (d.transactionStatus == 2) {//2=可购买,4=支付中
-                                    const resalePrice = Number(d.resalePrice);
-                                    if (minPrice > resalePrice) {
-                                        minPrice = resalePrice;
-                                    }
-                                    if (price >= resalePrice) {
-                                        retItemLst.push(d);
-                                    }
+                                if (d.viewSort == viewSort) {
+                                    finalRet.collectionItem = d;
                                 }
                             }
-                            if (retItemLst.length > 0) {
-                                const one = retItemLst[0];
-                                lk.appendNotifyInfo(`🎉成功匹配产品[${one.collectionName}#${one.viewSort}](<=${price}),数量: ${retItemLst.length},最低价格:${one.resalePrice}`);
-                            } else {
-                                lk.log(`无匹配的价格(<=${price}),当前[${collectionName}]最低价:${minPrice}`);
+                            if (finalRet.collectionItem) {
+                                lk.log(`搜寻到产品[${collectionName}#${viewSort}]`);
                             }
                         } else {
-
+                            lk.log(`获取寄售列表失败,响应:${data}`);
+                            finalRet.success = false;
                         }
                     }
                 } catch (e) {
-                    lk.log(`获取寄售列表信息失败`);
+                    lk.log(`获取寄售列表信息发生错误`);
                     lk.logErr(e);
                     lk.execFail();
                 } finally {
-                    resolve(retItemLst);
+                    resolve(finalRet);
                 }
             });
         } catch (e) {

+ 2 - 2
Scripts/gandart/gandartOrder.js

@@ -173,11 +173,11 @@ async function refreshLstOnSale(castingId, price, pageSize = 15, page = 1) {
                                 lk.log(`无匹配的价格(<=${price}),当前[${collectionName}]最低价:${minPrice}`);
                             }
                         } else {
-
+                            lk.log(`获取寄售列表失败,响应:${data}`);
                         }
                     }
                 } catch (e) {
-                    lk.log(`获取寄售列表信息失败`);
+                    lk.log(`获取寄售列表信息发生错误`);
                     lk.logErr(e);
                     lk.execFail();
                 } finally {