|
|
@@ -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();
|
|
|
}
|