2024-12-21 21:33:07 +03:00
|
|
|
const router = require('express').Router()
|
2025-01-18 23:02:45 +03:00
|
|
|
const { OrderModel } = require('./model/order')
|
2024-12-21 21:33:07 +03:00
|
|
|
|
2025-01-19 10:23:48 +03:00
|
|
|
router.post('/orders', async (req, res, next) => {
|
2025-01-19 11:29:11 +03:00
|
|
|
const {startDate, endDate} = req.body
|
|
|
|
|
|
|
|
if (!startDate || !endDate) {
|
|
|
|
throw new Error('startDate and endDate are required')
|
|
|
|
}
|
|
|
|
|
|
|
|
const orders = await OrderModel.find({
|
|
|
|
$or: [
|
|
|
|
{startWashTime: { $gte: new Date(startDate), $lte: new Date(endDate) }},
|
|
|
|
{endWashTime: { $gte: new Date(startDate), $lte: new Date(endDate) }},
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
2025-01-18 23:02:45 +03:00
|
|
|
res.status(200).send({ success: true, body: orders })
|
2024-12-21 21:33:07 +03:00
|
|
|
})
|
|
|
|
|
2025-01-19 10:23:48 +03:00
|
|
|
module.exports = router
|