|
|
@@ -28,6 +28,19 @@ const gandartCollectionCateLstKey = 'lkGandartCollectionCateLst';
|
|
|
|
|
|
let gandartToken = lk.getVal(gandartTokenKey, '');
|
|
|
|
|
|
+const GCommonGandartHeads = {
|
|
|
+ 'Accept' : `application/json, text/plain, */*`,
|
|
|
+ 'Origin' : `https://www.gandart.com`,
|
|
|
+ 'Accept-Encoding' : `gzip, deflate, br`,
|
|
|
+ 'Content-Type' : `application/x-www-form-urlencoded;charset=UTF-8`,
|
|
|
+ 'Connection' : `keep-alive`,
|
|
|
+ 'Host' : `api2.gandart.com`,
|
|
|
+ 'User-Agent' : `Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Mobile/15E148 Safari/604.1`,
|
|
|
+ 'Referer' : `https://www.gandart.com/`,
|
|
|
+ 'Accept-Language' : `zh-CN,zh-Hans;q=0.9`,
|
|
|
+ 'token' : gandartToken
|
|
|
+};
|
|
|
+
|
|
|
if(!lk.isExecComm) {
|
|
|
if (lk.isRequest()) {
|
|
|
getInfo();
|
|
|
@@ -201,7 +214,7 @@ function checkAppendCollectionItemsDiff(cLst, pageLst){
|
|
|
|
|
|
function getCollectionNameById(castingId) {
|
|
|
let name = '未获取';
|
|
|
- let clst = JSON.parse(lk.getVal(gandartCollectionCateLstKey, []));
|
|
|
+ let clst = JSON.parse(lk.getVal(gandartCollectionCateLstKey, "[]"));
|
|
|
for (const d of clst) {
|
|
|
if(d.castingId == castingId){
|
|
|
name = d.collectionName;
|
|
|
@@ -211,6 +224,11 @@ function getCollectionNameById(castingId) {
|
|
|
return name;
|
|
|
}
|
|
|
|
|
|
+function getCurCollectionName() {
|
|
|
+ let collectionName = lk.setVal(gardartCollectionNameKey, "");
|
|
|
+ return collectionName;
|
|
|
+}
|
|
|
+
|
|
|
async function all() {
|
|
|
let hasNeedSendNotify = true;
|
|
|
if (gandartToken == '') {
|
|
|
@@ -245,18 +263,7 @@ async function all() {
|
|
|
function refreshLstOnSale(castingId, price) {
|
|
|
return new Promise((resolve, _reject) => {
|
|
|
try {
|
|
|
- const headers = {
|
|
|
- 'Accept' : `application/json, text/plain, */*`,
|
|
|
- 'Origin' : `https://www.gandart.com`,
|
|
|
- 'Accept-Encoding' : `gzip, deflate, br`,
|
|
|
- 'Content-Type' : `application/x-www-form-urlencoded;charset=UTF-8`,
|
|
|
- 'Connection' : `keep-alive`,
|
|
|
- 'Host' : `api2.gandart.com`,
|
|
|
- 'User-Agent' : `Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Mobile/15E148 Safari/604.1`,
|
|
|
- 'Referer' : `https://www.gandart.com/`,
|
|
|
- 'Accept-Language' : `zh-CN,zh-Hans;q=0.9`,
|
|
|
- 'token' : gandartToken
|
|
|
- };
|
|
|
+ const headers = GCommonGandartHeads;
|
|
|
let signData = getSign();
|
|
|
signData.castingId = castingId;
|
|
|
signData.page = 1;
|
|
|
@@ -269,21 +276,27 @@ function refreshLstOnSale(castingId, price) {
|
|
|
headers: headers,
|
|
|
body: body
|
|
|
};
|
|
|
- lk.log(`请求寄售列表:${body}`);
|
|
|
+ let collectionName = getCollectionNameById(castingId)
|
|
|
+ lk.log(`请求产品[${collectionName}(${castingId})]寄售列表:${body}`);
|
|
|
lk.post(url, async (error, _response, data) => {
|
|
|
let retItem;
|
|
|
try {
|
|
|
if (error) {
|
|
|
+ lk.log(`获取寄售列表信息发生错误`);
|
|
|
lk.execFail();
|
|
|
lk.appendNotifyInfo(`❌获取寄售列表失败,请稍后再试`);
|
|
|
} else {
|
|
|
- let ret = JSON.parse(data)
|
|
|
+ let ret = JSON.parse(data);
|
|
|
+ let minPrice = 9999999;
|
|
|
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){
|
|
|
retItem = d;
|
|
|
lk.appendNotifyInfo(`🎉成功匹配产品[${d.collectionName}#${d.viewSort}],价格:${d.resalePrice}`);
|
|
|
@@ -291,11 +304,15 @@ function refreshLstOnSale(castingId, price) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if(!retItem){
|
|
|
+ lk.log(`无匹配的价格,当前[${collectionName}]最低价:${minPrice}`);
|
|
|
+ }
|
|
|
} else {
|
|
|
lk.execFail();
|
|
|
}
|
|
|
}
|
|
|
} catch (e) {
|
|
|
+ lk.log(`获取寄售列表信息失败`);
|
|
|
lk.logErr(e);
|
|
|
lk.execFail();
|
|
|
} finally {
|
|
|
@@ -303,6 +320,7 @@ function refreshLstOnSale(castingId, price) {
|
|
|
}
|
|
|
});
|
|
|
} catch (e) {
|
|
|
+ lk.log(`获取寄售列表信息发生错误`);
|
|
|
lk.logErr(e);
|
|
|
resolve();
|
|
|
}
|
|
|
@@ -313,32 +331,24 @@ function checkToBuy(data){
|
|
|
return new Promise((resolve, _reject) => {
|
|
|
try {
|
|
|
const id = data.id;
|
|
|
- const headers = {
|
|
|
- 'Accept' : `application/json, text/plain, */*`,
|
|
|
- 'Origin' : `https://www.gandart.com`,
|
|
|
- 'Accept-Encoding' : `gzip, deflate, br`,
|
|
|
- 'Content-Type' : `application/x-www-form-urlencoded;charset=UTF-8`,
|
|
|
- 'Connection' : `keep-alive`,
|
|
|
- 'Host' : `api.gandart.com`,
|
|
|
- 'User-Agent' : `Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Mobile/15E148 Safari/604.1`,
|
|
|
- 'Referer' : `https://www.gandart.com/`,
|
|
|
- 'Accept-Language' : `zh-CN,zh-Hans;q=0.9`,
|
|
|
- 'token' : gandartToken
|
|
|
- };
|
|
|
+ const viewSort = data.viewSort || 0;
|
|
|
+ const headers = GCommonGandartHeads;
|
|
|
const body = `transactionRecordId=${id}`;
|
|
|
let url = {
|
|
|
url: `https://api.gandart.com/base/v2/resaleManage/resale/buy/v2`,
|
|
|
headers: headers,
|
|
|
body: body
|
|
|
};
|
|
|
- lk.log(`请求购买产品=${body}`);
|
|
|
+ lk.log(`请求购买产品[${data.collectionName}#${viewSort}]=${body}`);
|
|
|
// resolve(1);
|
|
|
+ const collectionName = data.collectionName;
|
|
|
lk.post(url, async (error, _response, data) => {
|
|
|
let retItem;
|
|
|
try {
|
|
|
if (error) {
|
|
|
- lk.execFail()
|
|
|
- lk.appendNotifyInfo(`❌购买失败,请稍后再试`)
|
|
|
+ lk.log(`无法下单产品[${collectionName}#${viewSort}]`);
|
|
|
+ lk.execFail();
|
|
|
+ lk.appendNotifyInfo(`❌购买失败,请稍后再试`);
|
|
|
} else {
|
|
|
let ret = JSON.parse(data)
|
|
|
if (ret.success) {
|
|
|
@@ -346,13 +356,16 @@ function checkToBuy(data){
|
|
|
let orderNum = obj.orderNum;
|
|
|
if(orderNum && orderNum.length > 0){
|
|
|
retItem = ret;
|
|
|
- lk.appendNotifyInfo(`🎉成功下单产品[${obj.collectionName}],订单号:${obj.orderNum}`);
|
|
|
+ lk.log(`成功下单产品[${obj.collectionName}#${viewSort}],订单号:${obj.orderNum}`);
|
|
|
+ lk.appendNotifyInfo(`🎉成功下单产品[${obj.collectionName}#${viewSort}],订单号:${obj.orderNum}`);
|
|
|
}
|
|
|
} else {
|
|
|
+ lk.log(`产品[${collectionName}#${viewSort}]下单失败`);
|
|
|
lk.execFail();
|
|
|
}
|
|
|
}
|
|
|
} catch (e) {
|
|
|
+ lk.log(`下单产品[${collectionName}#${viewSort}]发生错误`);
|
|
|
lk.logErr(e);
|
|
|
lk.execFail();
|
|
|
} finally {
|
|
|
@@ -360,6 +373,7 @@ function checkToBuy(data){
|
|
|
}
|
|
|
});
|
|
|
} catch (e) {
|
|
|
+ lk.log(`下单产品[${data.collectionName}#${data.viewSort}]发生错误`);
|
|
|
lk.logErr(e);
|
|
|
resolve();
|
|
|
}
|