shawenguan 2 年之前
父节点
当前提交
88b841a408

+ 75 - 21
BoxJsSub/JoJo_BoxJs.json

@@ -18,24 +18,21 @@
       ],
       "scripts": [
         {
-          "name": "极速购买",
-          "script": "https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Scripts/gandart/gandartHelper.js"
+          "name": "极速下单",
+          "script": "https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Scripts/gandart/gandartOrder.js"
         },
         {
           "name": "极速合成",
-          "script": "https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Scripts/gandart/gandartHelper.js"
+          "script": "https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Scripts/gandart/gandartComposite.js"
         },
         {
           "name": "极速置换",
-          "script": "https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Scripts/gandart/gandartHelper.js"
+          "script": "https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Scripts/gandart/gandartExchange.js"
         }
       ],
       "keys": [
         "lkGandartToken",
-        "lkGandartCastingId",
-        "lkGandartTransactionRecordId",
-        "lkGandartLimitPrice",
-        "lkGandartCollectionName"
+        "lkGandartCollectionCateLst"
       ],
       "settings": [
         {
@@ -74,6 +71,70 @@
           "desc": "授权token"
         },
         {
+          "id": "lkGandartCollectionCateLst",
+          "name": "产品列表",
+          "val": "[]",
+          "type": "textarea",
+          "desc": "产品列表"
+        }
+      ]
+    },
+    {
+      "id": "lkGandartOrderer",
+      "name": "光予下单",
+      "author": "@jojo",
+      "repo": "https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Scripts/gandart/gandartOrder.js",
+      "script": "https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Scripts/gandart/gandartOrder.js",
+      "icons": [
+        "https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Images/gandart.png",
+        "https://git.jojo21.cf/shawenguan/Quantumult-X/raw/master/Images/gandart.png"
+      ],
+      "scripts": [],
+      "keys": [
+        "lkGandartToken",
+        "lkGandartCastingId",
+        "lkGandartCollectionName",
+        "lkGandartLimitPrice",
+        "lkGandartFloatPriceIntaval",
+        "lkIsGandartCollectionWatchLocked"
+      ],
+      "settings": [
+        {
+          "id": "lkIsEnableLogGandartOrdererCheckIn",
+          "name": "开启/关闭日志",
+          "val": true,
+          "type": "boolean",
+          "desc": "默认开启"
+        },
+        {
+          "id": "lkNotifyOnlyFailGandartOrdererCheckIn",
+          "name": "只当执行失败才通知",
+          "val": false,
+          "type": "boolean",
+          "desc": "默认关闭"
+        },
+        {
+          "id": "lkIsEnableTgNotifyGandartOrdererCheckIn",
+          "name": "开启/关闭通知",
+          "val": false,
+          "type": "boolean",
+          "desc": "默认关闭"
+        },
+        {
+          "id": "lkTgNotifyUrlGandartOrdererCheckIn",
+          "name": "通知地址",
+          "val": "",
+          "type": "text",
+          "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",
           "name": "产品铸造品类ID",
           "val": "",
@@ -81,18 +142,18 @@
           "desc": "产品铸造品类ID"
         },
         {
-          "id": "lkGandartTransactionRecordId",
-          "name": "产品记录ID",
+          "id": "lkGandartCollectionName",
+          "name": "产品名称",
           "val": "",
           "type": "text",
-          "desc": "产品记录ID(非编号)"
+          "desc": "产品名称"
         },
         {
           "id": "lkGandartLimitPrice",
-          "name": "捡漏最价格",
+          "name": "捡漏最价格",
           "val": 0,
-          "type": "number",
-          "desc": "捡漏最价格"
+          "type": "text",
+          "desc": "捡漏最价格"
         },
         {
           "id": "lkGandartFloatPriceIntaval",
@@ -102,13 +163,6 @@
           "desc": "价格浮动限制"
         },
         {
-          "id": "lkGandartCollectionName",
-          "name": "产品名称",
-          "val": "",
-          "type": "text",
-          "desc": "产品名称"
-        },
-        {
           "id": "lkGandartCollectionCateLst",
           "name": "产品列表",
           "val": "[]",

+ 0 - 0
Scripts/gandart/gandartComposite.js


+ 0 - 0
Scripts/gandart/gandartExchange.js


+ 12 - 177
Scripts/gandart/gandartHelper.js

@@ -48,8 +48,6 @@ if (!lk.isExecComm) {
     if (lk.isRequest()) {
         checkHanldeRequest();
         lk.done();
-    } else {
-        all();
     }
 }
 
@@ -58,7 +56,6 @@ function checkHanldeRequest() {
     const path = $request.path;
     lk.log(`请求url=${url}#${$request.method}`);
     lk.log(`请求body=${lk.getRequestBody()}`);
-    lk.log(`path=${path}`);
     if ($request && $request.method != 'OPTIONS') {
         switch (path) {
             case '/base/auth/verifyCodeLogin':
@@ -88,7 +85,7 @@ function handleVerifyCodeLogin() {
         if (!data) {
             return;
         }
-        lk.log(`开始获取Token`);
+        lk.log(`正在获取Token`);
         data = JSON.parse(data);
         if (data.success) {
             let jwktoken = data.obj.token;
@@ -111,7 +108,7 @@ function handleFindAllIsOpenResale() {
         if (!data) {
             return;
         }
-        lk.log(`获取最新产品开放在售列表`);
+        lk.log(`获取产品在售列表`);
         data = JSON.parse(data);
         if (data.success) {
             let obj = data.obj;
@@ -135,7 +132,7 @@ function handleSelectRecord() {
         if (!data) {
             return;
         }
-        lk.log(`获取收藏的产品列表`);
+        lk.log(`获取产品收藏列表`);
         data = JSON.parse(data);
         if (data.success) {
             let obj = data.obj;
@@ -182,15 +179,19 @@ function handleTradingMarket() {
 }
 
 function checkFixLimitPrice(castingId, info, lastCastingId) {
-    // 检查预设价格
+    // 检查预设捡漏价格
+    let resalePrice = Number(info.resalePrice);
     if (lastCastingId == castingId) {
         let floatInterval = lk.getVal(GandartConstKey.FloatPriceIntaval, 5);
         let price = Number(lk.getVal(GandartConstKey.LimitPrice, 0));
-        if (price - floatInterval > Number(info.resalePrice)) {
+        if (resalePrice > 0 && price - floatInterval > resalePrice) {
             lk.setVal(GandartConstKey.LimitPrice, info.resalePrice);
         }
     } else {
-        lk.setVal(GandartConstKey.LimitPrice, info.resalePrice);
+        if (resalePrice > 0) {
+            resalePrice -= 10;
+        }
+        lk.setVal(GandartConstKey.LimitPrice, String(resalePrice));
     }
 }
 
@@ -200,7 +201,7 @@ function handleCollectionDetailsByCastingId() {
         if (!data) {
             return;
         }
-        lk.log(`开始获取产品信息`);
+        lk.log(`获取产品详情信息`);
         data = JSON.parse(data);
         if (data.success) {
             let obj = data.obj;
@@ -277,6 +278,7 @@ function checkAppendCollectionItemsDiff(cLst, pageLst) {
     }
     return newLst;
 }
+
 function getCollectionMInfoById(castingId) {
     let ret;
     try {
@@ -302,173 +304,6 @@ function getCollectionNameById(castingId) {
     return name;
 }
 
-async function all() {
-    let hasNeedSendNotify = true;
-    if (gandartToken == '') {
-        lk.execFail();
-        lk.appendNotifyInfo(`⚠️请先打开光予登录获取token`);
-    } else {
-        let castingId = lk.getVal(GandartConstKey.CastingId, 0);
-        castingId = Number(castingId);
-        let price = lk.getVal(GandartConstKey.LimitPrice, 0);
-        price = Number(price);
-        if (castingId <= 0) {
-            lk.prependNotifyInfo('⚠️请设置产品品类');
-            hasNeedSendNotify = true;
-        } else if (price <= 0) {
-            lk.prependNotifyInfo('⚠️请设置监控价格');
-            hasNeedSendNotify = true;
-        } else {
-            let itemLst = await refreshLstOnSale(castingId, price);
-            if (itemLst && itemLst.length > 0) {
-                hasNeedSendNotify = await checkToBuyAll(itemLst);
-            } else {
-                hasNeedSendNotify = false;
-            }
-        }
-    }
-    if (hasNeedSendNotify) {
-        lk.msg(``);
-    }
-    lk.done();
-}
-
-async function refreshLstOnSale(castingId, price) {
-    return new Promise((resolve, _reject) => {
-        try {
-            const headers = GCommonGandartHeads;
-            headers.Host = "api2.gandart.com";
-            let signData = getSign();
-            signData.castingId = castingId;
-            signData.page = 1;
-            signData.pageSize = 15;
-            signData.sort = 2;// 1=编号,2=价格
-            signData.transactionStatus = 2;
-            let body = lk.objToQueryStr(signData);
-            let url = {
-                url: `${config.RESALE_API_V2}/resaleManage/resale/onSale`,
-                headers: headers,
-                body: body
-            };
-            let collectionName = getCollectionNameById(castingId)
-            lk.log(`请求产品[${collectionName}(${castingId})]寄售列表:${body}`);
-            lk.post(url, async (error, _response, data) => {
-                let retItemLst = [];
-                try {
-                    if (error) {
-                        lk.log(`获取寄售列表信息发生错误`);
-                        lk.execFail();
-                        lk.appendNotifyInfo(`❌获取寄售列表失败,请稍后再试`);
-                    } else {
-                        let ret = JSON.parse(data);
-                        let minPrice = 99999;
-                        if (ret.success) {
-                            let obj = ret.obj;
-                            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 (retItemLst.length > 0) {
-                                const one = retItemLst[0];
-                                lk.appendNotifyInfo(`🎉成功匹配产品[${one.collectionName}#${one.viewSort}](<=${price}),数量: ${retItemLst.length},最低价格:${one.resalePrice}`);
-                            } else {
-                                lk.log(`无匹配的价格(<=${price}),当前[${collectionName}]最低价:${minPrice}`);
-                            }
-                        } else {
-                            lk.execFail();
-                        }
-                    }
-                } catch (e) {
-                    lk.log(`获取寄售列表信息失败`);
-                    lk.logErr(e);
-                    lk.execFail();
-                } finally {
-                    resolve(retItemLst);
-                }
-            });
-        } catch (e) {
-            lk.log(`获取寄售列表信息发生错误`);
-            lk.logErr(e);
-            resolve();
-        }
-    });
-}
-
-async function checkToBuyAll(itemLst) {
-    let ret = false;
-    let count = Math.min(1, itemLst.length);
-    for (let i = 0; i < count; i++) {
-        let succItem = await checkToBuyCollection(itemLst[i]);
-        if (succItem) {
-            ret = true;
-        }
-    }
-    return ret;
-}
-
-function checkToBuyCollection(item) {
-    return new Promise((resolve, _reject) => {
-        try {
-            const id = item.id;
-            const viewSort = item.viewSort || 0;
-            const headers = GCommonGandartHeads;
-            headers.Host = "api.gandart.com";
-            const body = `transactionRecordId=${id}`;
-            let url = {
-                url: `${config.BASE_API}/v2/resaleManage/resale/buy/v2`,
-                headers: headers,
-                body: body
-            };
-            lk.log(`请求购买产品[${item.collectionName}#${viewSort}]=${body}`);
-            // resolve(1);
-            const collectionName = item.collectionName;
-            lk.post(url, async (error, _response, data) => {
-                let retItem;
-                try {
-                    if (error) {
-                        lk.log(`无法下单产品[${collectionName}#${viewSort}]`);
-                        lk.execFail();
-                        lk.appendNotifyInfo(`❌购买失败,请稍后再试`);
-                    } else {
-                        lk.log(data);
-                        let retBuyInfo = JSON.parse(data);
-                        if (retBuyInfo.success) {
-                            let obj = retBuyInfo.obj;
-                            let orderNum = obj.orderNum;
-                            if (orderNum && orderNum.length > 0) {
-                                retItem = retBuyInfo;
-                                lk.log(`成功下单产品[${obj.collectionName}#${viewSort}],价格:${item.resalePrice},订单号:${obj.orderNum}`);
-                                lk.appendNotifyInfo(`🎉成功下单产品[${obj.collectionName}#${viewSort}],价格:${item.resalePrice},订单号:${obj.orderNum}`);
-                            }
-                        } else {
-                            lk.log(`产品[${collectionName}#${viewSort}]下单失败`);
-                            lk.execFail();
-                        }
-                    }
-                } catch (e) {
-                    lk.log(`下单产品[${collectionName}#${viewSort}]发生错误`);
-                    lk.logErr(e);
-                    lk.execFail();
-                } finally {
-                    resolve(retItem);
-                }
-            });
-        } catch (e) {
-            lk.log(`下单产品[${item.collectionName}#${item.viewSort}]发生错误`);
-            lk.logErr(e);
-            resolve();
-        }
-    });
-}
-
 function getSign() {
     const now = new Date().getTime();
     const s1 = now - 20000;

文件差异内容过多而无法显示
+ 268 - 0
Scripts/gandart/gandartOrder.js


部分文件因为文件数量过多而无法显示