更新 ele/auto-meal-complete.user.js
This commit is contained in:
parent
f73c0cca17
commit
46a0696944
@ -13,6 +13,9 @@
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
function generateRandomString(length) {
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
var result = '';
|
||||
@ -28,7 +31,7 @@
|
||||
function convertSecondsToMinutesSeconds(seconds) {
|
||||
var minutes = Math.floor(seconds / 60);
|
||||
var remainingSeconds = seconds % 60;
|
||||
return minutes + "分" + remainingSeconds + "秒";
|
||||
return minutes + "分" + remainingSeconds.toFixed(2) + "秒";
|
||||
}
|
||||
function getShopId() {
|
||||
return parseInt(localStorage.shopId)
|
||||
@ -78,15 +81,19 @@
|
||||
// "queryType": "COOKING"
|
||||
})
|
||||
}
|
||||
async function mealComplete(orderId, cookTime) {
|
||||
async function mealComplete(order, cookTime) {
|
||||
let orderId = cook.id
|
||||
let daySn = cook.header.daySn
|
||||
let result = await request('ShipmentService', 'mealComplete', {
|
||||
"shopId": getShopId(),
|
||||
"orderId": orderId
|
||||
})
|
||||
debug('订单 ' + orderId + ' 上报出餐结束.')
|
||||
ele.submitOrders.push({ orderId, cookTime })
|
||||
if (ele.submitOrders.length > ele.maxLogOrderLength)
|
||||
debug('订单 #' + daySn + ' 上报出餐结束.')
|
||||
ele.submitOrders.push({ daySn, orderId, cookTime })
|
||||
if (ele.submitOrders.length > ele.maxLogOrderLength) {
|
||||
ele.submitOrders = ele.submitOrders.slice(ele.submitOrders.length - ele.maxLogOrderLength)
|
||||
}
|
||||
await sleep(5)
|
||||
await updateOrders()
|
||||
return result
|
||||
}
|
||||
@ -101,13 +108,15 @@
|
||||
if (cook.deliveryInfo.distTraceView.traceView.status == '骑士已到店'
|
||||
&& cook.mealPreparationInfo.minMealCompleteTimeCount < 0
|
||||
&& leftTime < ele.autoSubmitLeftTimeWhenOnShop) {
|
||||
debug('订单 ' + orderId + ' 骑手到店 且剩余时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 模拟提交出餐.')
|
||||
return mealComplete(orderId, cookTime)
|
||||
debug('订单 ' + orderId + ' 骑手到店.')
|
||||
debug('订单剩余时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 模拟提交出餐.')
|
||||
return mealComplete(cook, cookTime)
|
||||
}
|
||||
if (leftTime < ele.autoSubmitLeftTime) {
|
||||
// 大于最小上报时长 并且距离上报超时不足120秒 直接上报出餐
|
||||
debug('订单 ' + orderId + ' 骑手未到店 且剩余时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 模拟提交出餐.')
|
||||
return mealComplete(orderId, cookTime)
|
||||
debug('订单 ' + orderId + ' 骑手未到店.')
|
||||
debug('订单剩余时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 模拟提交出餐.')
|
||||
return mealComplete(cook, cookTime)
|
||||
}
|
||||
debug('订单 ' + orderId + ' 还剩 ' + cook.mealPreparationInfo.commonShowTime + 's 上报超时.')
|
||||
cook.mealPreparationInfo.minMealCompleteTimeCount -= 5
|
||||
@ -123,8 +132,9 @@
|
||||
function debug(msg) {
|
||||
try {
|
||||
ele.logs.push('[' + (new Date().toLocaleTimeString()) + '] ' + msg)
|
||||
if (ele.logs.length > ele.maxLogLength)
|
||||
if (ele.logs.length > ele.maxLogLength) {
|
||||
ele.logs = ele.logs.slice(ele.logs.length - ele.maxLogLength)
|
||||
}
|
||||
let title = '饿了么自动出餐 By MiaoWoo </br>'
|
||||
let configInfo = '当前配置: </br><div class="ant-alert-content">'
|
||||
+ '骑手到店 提前 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 出餐 '
|
||||
@ -137,7 +147,7 @@
|
||||
+ '</div>'
|
||||
let orderInfo = '进行中的订单信息: </br><div class="ant-alert-content">'
|
||||
+ (ele.processOrders.length
|
||||
? ele.processOrders.map(o => '订单: ' + o.id + ' 出餐状态 ' + (o.mealPreparationInfo.mealComplete ? '已出餐' : '未出餐') + ' 配送状态 ' + o.deliveryInfo.distTraceView.traceView.status).join('</br>')
|
||||
? ele.processOrders.map(o => ' 订单: #' + o.header.daySn + ' 出餐状态 ' + (o.mealPreparationInfo.mealComplete ? '已出餐' : '未出餐') + ' 配送状态 ' + o.deliveryInfo.distTraceView.traceView.status).join('</br>')
|
||||
: '当前没有进行中的订单.')
|
||||
+ '</div>'
|
||||
let logs = '运行日志: </br><div class="ant-alert-content">'
|
||||
@ -165,7 +175,7 @@
|
||||
updateOrders()
|
||||
}, 5000)
|
||||
setInterval(() => { checkCooking() }, 5000)
|
||||
setInterval(() => { updateOrders() }, 30000)
|
||||
setInterval(() => { updateOrders() }, 20000)
|
||||
}
|
||||
var ele = {
|
||||
logs: [],
|
||||
|
Loading…
Reference in New Issue
Block a user