shawenguan před 2 roky
rodič
revize
a58fdf5d92

+ 15 - 1
BoxJsSub/JoJo_BoxJs.json

@@ -148,6 +148,20 @@
           "desc": "默认关闭锁定"
         },
         {
+          "id": "lkGandartIsCollectionMaxNumLimit",
+          "name": "开启/关闭检查未支付单数限制",
+          "val": false,
+          "type": "boolean",
+          "desc": "默认关闭锁定"
+        },
+        {
+          "id": "lkGandartCollectionLockMaxNum",
+          "name": "最大允许未支付单数",
+          "val": 6,
+          "type": "number",
+          "desc": "最大允许未支付单数"
+        },
+        {
           "id": "lkGandartPrivWalletListInUse",
           "name": "付款钱包",
           "val": "A,B,C",
@@ -200,7 +214,7 @@
           "id": "lkGandartCollectionCateLst",
           "name": "产品列表",
           "val": "[]",
-          "autoGrow": true,
+          "autoGrow": false,
           "type": "textarea",
           "desc": "产品列表"
         }

+ 3 - 3
Scripts/gandart/gandartLock.js

@@ -179,7 +179,7 @@ async function refreshLstOnSale(castingId, viewSort, pageSize = 15, page = 1) {
                 };
                 try {
                     if (error) {
-                        lk.log(`获取寄售列表信息发生错误`);
+                        lk.log(`获取寄售列表数据发生错误`);
                         lk.execFail();
                         lk.appendNotifyInfo(`❌获取寄售列表失败,请稍后再试`);
                     } else {
@@ -204,7 +204,7 @@ async function refreshLstOnSale(castingId, viewSort, pageSize = 15, page = 1) {
                         }
                     }
                 } catch (e) {
-                    lk.log(`获取寄售列表信息发生错误`);
+                    lk.log(`获取寄售列表数据发生错误`);
                     lk.logErr(e);
                     lk.execFail();
                 } finally {
@@ -212,7 +212,7 @@ async function refreshLstOnSale(castingId, viewSort, pageSize = 15, page = 1) {
                 }
             });
         } catch (e) {
-            lk.log(`获取寄售列表信息发生错误`);
+            lk.log(`获取寄售列表数据发生错误`);
             lk.logErr(e);
             resolve();
         }

+ 94 - 26
Scripts/gandart/gandartOrder.js

@@ -33,6 +33,9 @@ const GandartConstKey = {
     FloatPriceIntaval: 'lkGandartFloatPriceIntaval',
     IsCollectionWatchLocked: 'lkIsGandartCollectionWatchLocked',
     PrivWalletListInUse: 'lkGandartPrivWalletListInUse',
+
+    IsCollectionMaxNumLimit: 'lkGandartIsCollectionMaxNumLimit',
+    CollectionLockMaxNum: 'lkGandartCollectionLockMaxNum',
 };
 
 let gandartToken = lk.getVal(GandartConstKey.Token, '');
@@ -82,29 +85,62 @@ function getCollectionNameById(castingId) {
     return name;
 }
 
+function isCollectionMaxNumLimitEnable() {
+    let isEnabled = lk.getVal(GandartConstKey.IsCollectionMaxNumLimit);
+    isEnabled = lk.isEmpty(isEnabled) ? false : JSON.parse(isEnabled);
+    return isEnabled;
+}
+
+function getCollectionLockMaxNum() {
+    let num = lk.getVal(GandartConstKey.CollectionLockMaxNum, 6);
+    return Number(num);
+}
+
+function getCurWalletListInUse() {
+    let str = lk.getVal(GandartConstKey.PrivWalletListInUse);
+    let ret = 'A,B,C';
+    if (!lk.isEmpty(str)) {
+        ret = str;
+    }
+    return ret;
+}
+
 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 {
-            gandartWalletList = getCurWalletListInUse();
-            let itemLst = await refreshLstOnSale(castingId, price);
-            if (itemLst && itemLst.length > 0) {
-                hasNeedSendNotify = await checkToBuyAll(itemLst);
+        let isPass = true;
+        if (isCollectionMaxNumLimitEnable()) {
+            let maxLockNum = getCollectionLockMaxNum();
+            let curPayingNum = await getNftOrderList(0);
+            if (curPayingNum >= maxLockNum) {
+                lk.log('当前未支付订单达到预设的限制单量');
+                lk.prependNotifyInfo(`⚠️当前未支付订单达到限制${maxLockNum}单`);
+                isPass = false;
+                hasNeedSendNotify = true;
+            }
+        }
+        if (isPass) {
+            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 {
-                hasNeedSendNotify = false;
+                gandartWalletList = getCurWalletListInUse();
+                let itemLst = await refreshLstOnSale(castingId, price);
+                if (itemLst && itemLst.length > 0) {
+                    hasNeedSendNotify = await checkToBuyAll(itemLst);
+                } else {
+                    hasNeedSendNotify = false;
+                }
             }
         }
     }
@@ -114,13 +150,45 @@ async function all() {
     lk.done();
 }
 
-function getCurWalletListInUse() {
-    let str = lk.getVal(GandartConstKey.PrivWalletListInUse);
-    let ret = 'A,B,C';
-    if (!lk.isEmpty(str)) {
-        ret = str;
-    }
-    return ret;
+async function getNftOrderList(status, orderType = 0, page = 1, pageSize = 6) {
+    return new Promise((resolve, _reject) => {
+        try {
+            const headers = GCommonGandartHeads;
+            headers.Host = "api.gandart.com";
+            // status 0:进行中 1:已完成 2:已取消
+            let body = `orderNo=&status=${status}&orderType=${orderType}&page=${page}&pageSize=${pageSize}`;
+            let url = {
+                url: `${config.BASE_API}/order/nftorder/list`,
+                headers: headers,
+                body: body
+            };
+            lk.post(url, async (error, _response, data) => {
+                let rows;
+                let total = 0;
+                try {
+                    if (error) {
+                        lk.log(`获取订单列表数据发生错误`);
+                        lk.execFail();
+                        // lk.appendNotifyInfo(`❌获取订单列表失败,请稍后再试`);
+                    } else {
+                        let ret = JSON.parse(data);
+                        rows = ret.rows;
+                        total = ret.total || ret.recordsTotal;
+                    }
+                } catch (e) {
+                    lk.log(`获取订单列表数据发生错误`);
+                    lk.logErr(e);
+                    lk.execFail();
+                } finally {
+                    resolve(total);
+                }
+            });
+        } catch (e) {
+            lk.log(`获取订单列表数据发生错误`);
+            lk.logErr(e);
+            resolve(0);
+        }
+    });
 }
 
 async function refreshLstOnSale(castingId, price, pageSize = 15, page = 1) {
@@ -146,7 +214,7 @@ async function refreshLstOnSale(castingId, price, pageSize = 15, page = 1) {
                 let retItemLst = [];
                 try {
                     if (error) {
-                        lk.log(`获取寄售列表信息发生错误`);
+                        lk.log(`获取寄售列表数据发生错误`);
                         lk.execFail();
                         lk.appendNotifyInfo(`❌获取寄售列表失败,请稍后再试`);
                     } else {
@@ -177,7 +245,7 @@ async function refreshLstOnSale(castingId, price, pageSize = 15, page = 1) {
                         }
                     }
                 } catch (e) {
-                    lk.log(`获取寄售列表信息发生错误`);
+                    lk.log(`GandartLocker发生错误`);
                     lk.logErr(e);
                     lk.execFail();
                 } finally {
@@ -185,7 +253,7 @@ async function refreshLstOnSale(castingId, price, pageSize = 15, page = 1) {
                 }
             });
         } catch (e) {
-            lk.log(`获取寄售列表信息发生错误`);
+            lk.log(`获取寄售列表数据发生错误`);
             lk.logErr(e);
             resolve();
         }