fix: 订单重复发货处理
This commit is contained in:
parent
b0d882e3d3
commit
effbbc5f77
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name MCBBS自动售卖机
|
// @name MCBBS自动售卖机
|
||||||
// @namespace https://miaowoo.cc/
|
// @namespace https://miaowoo.cc/
|
||||||
// @version 0.7.2
|
// @version 0.8.0
|
||||||
// @description 自动售卖道具
|
// @description 自动售卖道具
|
||||||
// @author MiaoWoo
|
// @author MiaoWoo
|
||||||
// @match https://www.mcbbs.net/home.php?mod=magic**
|
// @match https://www.mcbbs.net/home.php?mod=magic**
|
||||||
@ -36,12 +36,14 @@
|
|||||||
}
|
}
|
||||||
async function main() {
|
async function main() {
|
||||||
params = location.href.split('?')[1].split('&').map(s => s.split('=')).reduce((pre, cur, index) => { pre[cur[0]] = cur[1]; return pre }, {})
|
params = location.href.split('?')[1].split('&').map(s => s.split('=')).reduce((pre, cur, index) => { pre[cur[0]] = cur[1]; return pre }, {})
|
||||||
if (!params.nodeType) { return console.log('nodeType is undefined skip...') }
|
let errorh1 = document.getElementsByTagName('h1')[0]
|
||||||
if (!params.action) { return refresh() }
|
if (errorh1 && errorh1.innerText.startsWith(50)) {
|
||||||
if (document.getElementsByTagName('h1')[0].innerText.startsWith(504)) {
|
|
||||||
return refresh()
|
return refresh()
|
||||||
}
|
}
|
||||||
|
let taskId = setTimeout(refresh, 60000)
|
||||||
createMenu()
|
createMenu()
|
||||||
|
if (!params.nodeType) { return console.log('nodeType is undefined skip...') }
|
||||||
|
if (!params.action) { return refresh() }
|
||||||
console.log(params)
|
console.log(params)
|
||||||
try {
|
try {
|
||||||
storeUsername = document.getElementsByClassName('username')[0].innerText
|
storeUsername = document.getElementsByClassName('username')[0].innerText
|
||||||
@ -52,6 +54,7 @@
|
|||||||
} else {
|
} else {
|
||||||
updateStatus('')
|
updateStatus('')
|
||||||
}
|
}
|
||||||
|
clearTimeout(taskId)
|
||||||
switch (params.nodeType) {
|
switch (params.nodeType) {
|
||||||
case "master":
|
case "master":
|
||||||
master(params)
|
master(params)
|
||||||
@ -135,9 +138,6 @@
|
|||||||
async function clearOrderCache(order_id) {
|
async function clearOrderCache(order_id) {
|
||||||
await fetch('https://reward.yumc.pw/mcbbs/clearOrderCache/order_id/' + order_id).then(r => r.json())
|
await fetch('https://reward.yumc.pw/mcbbs/clearOrderCache/order_id/' + order_id).then(r => r.json())
|
||||||
}
|
}
|
||||||
async function duplicateNotify(order_id, goods_amount) {
|
|
||||||
await fetch(`https://reward.yumc.pw/mcbbs/duplicateNotify/order_id/${order_id}/goods_amount/${goods_amount}`).then(r => r.json())
|
|
||||||
}
|
|
||||||
async function handleLowStock(order, stock) {
|
async function handleLowStock(order, stock) {
|
||||||
if (order.allowAutoBuy) {
|
if (order.allowAutoBuy) {
|
||||||
await clearOrderCache(order.order_id)
|
await clearOrderCache(order.order_id)
|
||||||
@ -209,8 +209,23 @@
|
|||||||
clearTimeout(timeoutTask)
|
clearTimeout(timeoutTask)
|
||||||
return setTimeout(() => sendOrderAction(openFn), 2000)
|
return setTimeout(() => sendOrderAction(openFn), 2000)
|
||||||
}
|
}
|
||||||
try { openFn() } catch (ex) { }
|
|
||||||
let order = result.data
|
let order = result.data
|
||||||
|
if (store.getItem(lastOrderKey) == order.order_id) {
|
||||||
|
let finish = await fetch('https://reward.yumc.pw/mcbbs/updateOrder', {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
"order_id": order.order_id,
|
||||||
|
"status": 2,
|
||||||
|
"remark": "当前订单可能重复发货 如未到帐 请联系管理员!"
|
||||||
|
})
|
||||||
|
}).then(r => r.json())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try { openFn() } catch (ex) { }
|
||||||
if (!order || !order.order_id) { return setTimeout(() => sendOrderAction(openFn), 2000) }
|
if (!order || !order.order_id) { return setTimeout(() => sendOrderAction(openFn), 2000) }
|
||||||
console.log(`开始发送订单 ${order.order_id}`)
|
console.log(`开始发送订单 ${order.order_id}`)
|
||||||
let username = undefined
|
let username = undefined
|
||||||
@ -228,7 +243,6 @@
|
|||||||
amount.value = order.goods_amount
|
amount.value = order.goods_amount
|
||||||
let remark = username.parentNode.parentNode.nextElementSibling.nextElementSibling.childNodes[3].childNodes[0]
|
let remark = username.parentNode.parentNode.nextElementSibling.nextElementSibling.childNodes[3].childNodes[0]
|
||||||
remark.value = `圈云盒子 自动发货订单: ${order.order_id} 物品: ${order.goods_name} 数量: ${order.goods_amount} 发货账号: ${storeUsername}`
|
remark.value = `圈云盒子 自动发货订单: ${order.order_id} 物品: ${order.goods_name} 数量: ${order.goods_amount} 发货账号: ${storeUsername}`
|
||||||
store.setItem(lastOrderKey, order.order_id)
|
|
||||||
await sleep(300)
|
await sleep(300)
|
||||||
jq('#operatesubmit').click()
|
jq('#operatesubmit').click()
|
||||||
await sleep(500)
|
await sleep(500)
|
||||||
@ -250,6 +264,9 @@
|
|||||||
await handleLowStock(order, stock)
|
await handleLowStock(order, stock)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (!info && !error) {
|
||||||
|
store.setItem(lastOrderKey, order.order_id)
|
||||||
|
}
|
||||||
let finish = await fetch('https://reward.yumc.pw/mcbbs/updateOrder', {
|
let finish = await fetch('https://reward.yumc.pw/mcbbs/updateOrder', {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
Loading…
Reference in New Issue
Block a user