更新 ele/auto-meal-complete.user.js
This commit is contained in:
parent
0829118cc7
commit
e92b138a30
@ -31,7 +31,7 @@
|
|||||||
function convertSecondsToMinutesSeconds(seconds) {
|
function convertSecondsToMinutesSeconds(seconds) {
|
||||||
var minutes = Math.floor(seconds / 60);
|
var minutes = Math.floor(seconds / 60);
|
||||||
var remainingSeconds = seconds % 60;
|
var remainingSeconds = seconds % 60;
|
||||||
return minutes + "分" + remainingSeconds.toFixed(2) + "秒";
|
return minutes + "分" + remainingSeconds.toFixed(0) + "秒";
|
||||||
}
|
}
|
||||||
function getShopId() {
|
function getShopId() {
|
||||||
return parseInt(localStorage.shopId)
|
return parseInt(localStorage.shopId)
|
||||||
@ -81,7 +81,7 @@
|
|||||||
// "queryType": "COOKING"
|
// "queryType": "COOKING"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
async function mealComplete(cook, cookTime) {
|
async function mealComplete(cook, cookTime, tip) {
|
||||||
let orderId = cook.id
|
let orderId = cook.id
|
||||||
let daySn = cook.header.daySn
|
let daySn = cook.header.daySn
|
||||||
let result = await request('ShipmentService', 'mealComplete', {
|
let result = await request('ShipmentService', 'mealComplete', {
|
||||||
@ -89,10 +89,11 @@
|
|||||||
"orderId": orderId
|
"orderId": orderId
|
||||||
})
|
})
|
||||||
debug('订单 #' + daySn + ' 上报出餐结束.')
|
debug('订单 #' + daySn + ' 上报出餐结束.')
|
||||||
ele.submitOrders.push({ daySn, orderId, cookTime })
|
ele.submitOrders.push({ completeTime: new Date().toLocaleTimeString(), daySn, orderId, tip, cookTime })
|
||||||
if (ele.submitOrders.length > ele.maxLogOrderLength) {
|
if (ele.submitOrders.length > ele.maxLogOrderLength) {
|
||||||
ele.submitOrders = ele.submitOrders.slice(ele.submitOrders.length - ele.maxLogOrderLength)
|
ele.submitOrders = ele.submitOrders.slice(ele.submitOrders.length - ele.maxLogOrderLength)
|
||||||
}
|
}
|
||||||
|
localStorage.setItem(SubmitOrdersKey, JSON.stringify(ele.submitOrders))
|
||||||
await sleep(5)
|
await sleep(5)
|
||||||
await updateOrders()
|
await updateOrders()
|
||||||
return result
|
return result
|
||||||
@ -109,12 +110,12 @@
|
|||||||
&& cook.mealPreparationInfo.minMealCompleteTimeCount < 0
|
&& cook.mealPreparationInfo.minMealCompleteTimeCount < 0
|
||||||
&& leftTime < ele.autoSubmitLeftTimeWhenOnShop) {
|
&& leftTime < ele.autoSubmitLeftTimeWhenOnShop) {
|
||||||
debug('订单 #' + daySn + ' 骑手到店 订单剩余时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 模拟提交出餐.')
|
debug('订单 #' + daySn + ' 骑手到店 订单剩余时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 模拟提交出餐.')
|
||||||
return mealComplete(cook, cookTime)
|
return mealComplete(cook, cookTime, '骑手到店出餐')
|
||||||
}
|
}
|
||||||
if (leftTime < ele.autoSubmitLeftTime) {
|
if (leftTime < ele.autoSubmitLeftTime) {
|
||||||
// 大于最小上报时长 并且距离上报超时不足120秒 直接上报出餐
|
// 大于最小上报时长 并且距离上报超时不足120秒 直接上报出餐
|
||||||
debug('订单 #' + daySn + ' 骑手未到店 订单剩余时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 模拟提交出餐.')
|
debug('订单 #' + daySn + ' 骑手未到店 订单剩余时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 模拟提交出餐.')
|
||||||
return mealComplete(cook, cookTime)
|
return mealComplete(cook, cookTime, '骑手未到店出餐')
|
||||||
}
|
}
|
||||||
debug('订单 #' + daySn + ' 还剩 ' + cook.mealPreparationInfo.commonShowTime + 's 上报超时.')
|
debug('订单 #' + daySn + ' 还剩 ' + cook.mealPreparationInfo.commonShowTime + 's 上报超时.')
|
||||||
cook.mealPreparationInfo.minMealCompleteTimeCount -= 5
|
cook.mealPreparationInfo.minMealCompleteTimeCount -= 5
|
||||||
@ -123,7 +124,6 @@
|
|||||||
}
|
}
|
||||||
async function updateOrders() {
|
async function updateOrders() {
|
||||||
let orders = await queryInProcessOrders()
|
let orders = await queryInProcessOrders()
|
||||||
ele.autoCheckTime = Date.now() / 1000
|
|
||||||
ele.processOrders = orders.result || []
|
ele.processOrders = orders.result || []
|
||||||
debug('更新订单数据 目前进行中订单: ' + ele.processOrders.length + '个')
|
debug('更新订单数据 目前进行中订单: ' + ele.processOrders.length + '个')
|
||||||
}
|
}
|
||||||
@ -140,7 +140,8 @@
|
|||||||
+ '</div>'
|
+ '</div>'
|
||||||
let submitInfo = '已自动出餐的订单信息: </br><div class="ant-alert-content">'
|
let submitInfo = '已自动出餐的订单信息: </br><div class="ant-alert-content">'
|
||||||
+ (ele.submitOrders.length
|
+ (ele.submitOrders.length
|
||||||
? ele.submitOrders.map(o => '订单: ' + o.orderId + ' 出餐用时 ' + convertSecondsToMinutesSeconds(o.cookTime)).join('</br>')
|
? ele.submitOrders.map(o => '[' + o.completeTime + '] 订单: #' + o.daySn
|
||||||
|
+ ' 出餐用时 ' + convertSecondsToMinutesSeconds(o.cookTime) + ' ' + o.tip).join('</br>')
|
||||||
: '当前没有自动出餐的订单.')
|
: '当前没有自动出餐的订单.')
|
||||||
+ '</div>'
|
+ '</div>'
|
||||||
let orderInfo = '进行中的订单信息: </br><div class="ant-alert-content">'
|
let orderInfo = '进行中的订单信息: </br><div class="ant-alert-content">'
|
||||||
@ -178,13 +179,14 @@
|
|||||||
setInterval(() => { checkCooking() }, 5000)
|
setInterval(() => { checkCooking() }, 5000)
|
||||||
setInterval(() => { updateOrders() }, 20000)
|
setInterval(() => { updateOrders() }, 20000)
|
||||||
}
|
}
|
||||||
|
var SubmitOrdersKey = 'AutoMealComplete:SubmitOrders'
|
||||||
var ele = {
|
var ele = {
|
||||||
logs: [],
|
logs: [],
|
||||||
maxLogLength: 15,
|
maxLogLength: 15,
|
||||||
maxLogOrderLength: 5,
|
maxLogOrderLength: 5,
|
||||||
orderStatus: {},
|
orderStatus: {},
|
||||||
processOrders: [],
|
processOrders: [],
|
||||||
submitOrders: [],
|
submitOrders: JSON.parse(localStorage.getItem(SubmitOrdersKey)),
|
||||||
autoCheckTask: undefined,
|
autoCheckTask: undefined,
|
||||||
autoSubmitLeftTime: 180,
|
autoSubmitLeftTime: 180,
|
||||||
autoSubmitLeftTimeWhenOnShop: 300,
|
autoSubmitLeftTimeWhenOnShop: 300,
|
||||||
|
Loading…
Reference in New Issue
Block a user