我为我们在 AWS Lambda 上运行的网络商店提供了一个 API 集成,以根据客户地址返回实时交付报价,然后在发票完成(已支付)时创建交付订单给作为服务提供商的第三方交付。
我能够为周一至周六添加时间限制,但周日有不同的时间并且不工作。以下是相关代码:
'use strict'
/**
* This function is use to generate qoutes to client 1st warehouse
*/
exports.handler = function (event, context, callback) {
console.log('-------------------EVENT OBJECT--------------------------')
// console.log(event.body.shipping_address)
console.log(event)
try {
const app = require('./app')
const EventEmitter = require('events').EventEmitter
const _bus = new EventEmitter()
let date = new Date()
if (date.getDay() == 0) {
if (!(date.getHours() >= 17 && date.getHours() <= 22) || !(date.getHours() < 3)) {
callback(null, {
message: 'The store is closed'
})
}
} else {
if (date.getHours() >= 3 && date.getHours() <= 15) {
callback(null, {
message: 'The store is closed'
})
}
}
let _shipmentReturn = []
let _shipmentReturnError = []
}
catch(e) {
}
}