|
|
|
@ -593,24 +593,107 @@ exports.tankerAccounts = async (req, reply) => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// exports.getAllOrderaccepted = async (req, reply) => {
|
|
|
|
|
// const limit = parseInt(req.query.limit) || 100;
|
|
|
|
|
// const page = parseInt(req.query.page) || 1;
|
|
|
|
|
// const startindex = (page - 1) * limit;
|
|
|
|
|
// const customerId = req.params.customerId
|
|
|
|
|
// try {
|
|
|
|
|
// await Tankerbooking.find({ customerId: customerId, orderStatus: ["accepted"]})
|
|
|
|
|
// .limit(limit)
|
|
|
|
|
// .skip(startindex)
|
|
|
|
|
// .exec()
|
|
|
|
|
// .then((docs) => {
|
|
|
|
|
// reply.send({ status_code: 200, data: docs, count: docs.length });
|
|
|
|
|
// })
|
|
|
|
|
// } catch (err) {
|
|
|
|
|
// reply.status(400).send({ message: err.message });
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getAllOrderaccepted = async (req, reply) => {
|
|
|
|
|
const limit = parseInt(req.query.limit) || 100;
|
|
|
|
|
const page = parseInt(req.query.page) || 1;
|
|
|
|
|
const startindex = (page - 1) * limit;
|
|
|
|
|
const customerId = req.params.customerId
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await Tankerbooking.find({ customerId: customerId, orderStatus: ["accepted"]})
|
|
|
|
|
const orders = await Tankerbooking.find({ customerId: customerId, orderStatus: "accepted" })
|
|
|
|
|
.limit(limit)
|
|
|
|
|
.skip(startindex)
|
|
|
|
|
.exec()
|
|
|
|
|
.then((docs) => {
|
|
|
|
|
reply.send({ status_code: 200, data: docs, count: docs.length });
|
|
|
|
|
.exec();
|
|
|
|
|
|
|
|
|
|
const ordersWithDeliveryBoyLocation = await Promise.all(
|
|
|
|
|
orders.map(async (order) => {
|
|
|
|
|
const deliveryBoy = await DeliveryBoy.findOne({ phone: order.delivery_agent_mobile });
|
|
|
|
|
return {
|
|
|
|
|
...order.toJSON(),
|
|
|
|
|
deliveryBoyLocation: deliveryBoy ? { deliveryboy_latitude: deliveryBoy.latitude, deliveryboy_longitude: deliveryBoy.longitude } : null,
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
reply.send({ status_code: 200, data: ordersWithDeliveryBoyLocation, count: orders.length });
|
|
|
|
|
} catch (err) {
|
|
|
|
|
reply.status(400).send({ message: err.message });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// exports.getAllOrderaccepted = async (req, reply) => {
|
|
|
|
|
// const customerId = req.params.customerId;
|
|
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
// const order = await Tankerbooking.findOne({ customerId: customerId, orderStatus: "accepted" }).exec();
|
|
|
|
|
|
|
|
|
|
// if (!order) {
|
|
|
|
|
// reply.status(404).send({ message: "No order found" });
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// const deliveryBoy = await DeliveryBoy.findOne({ phone: order.delivery_agent_mobile });
|
|
|
|
|
|
|
|
|
|
// const orderWithDeliveryBoyLocation = {
|
|
|
|
|
// ...order.toJSON(),
|
|
|
|
|
// deliveryBoyLocation: deliveryBoy ? { deliveryboy_latitude: deliveryBoy.latitude, deliveryboy_longitude: deliveryBoy.longitude } : null,
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// reply.send({ status_code: 200, data: orderWithDeliveryBoyLocation });
|
|
|
|
|
// } catch (err) {
|
|
|
|
|
// reply.status(400).send({ message: err.message });
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// exports.getAllOrderaccepted = async (req, reply) => {
|
|
|
|
|
// const limit = parseInt(req.query.limit) || 100;
|
|
|
|
|
// const page = parseInt(req.query.page) || 1;
|
|
|
|
|
// const startindex = (page - 1) * limit;
|
|
|
|
|
// const customerId = req.params.customerId;
|
|
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
// const orders = await Tankerbooking.find({ customerId: customerId, orderStatus: "accepted" })
|
|
|
|
|
// .limit(limit)
|
|
|
|
|
// .skip(startindex)
|
|
|
|
|
// .exec();
|
|
|
|
|
|
|
|
|
|
// const order = orders[0];
|
|
|
|
|
|
|
|
|
|
// if (order) {
|
|
|
|
|
// const deliveryBoy = await DeliveryBoy.findOne({ phone: order.delivery_agent_mobile });
|
|
|
|
|
// const orderWithDeliveryBoyLocation = {
|
|
|
|
|
// ...order.toJSON(),
|
|
|
|
|
// deliveryBoyLocation: deliveryBoy ? { deliveryboy_latitude: deliveryBoy.latitude, deliveryboy_longitude: deliveryBoy.longitude } : null,
|
|
|
|
|
// };
|
|
|
|
|
// reply.send({ status_code: 200, data: orderWithDeliveryBoyLocation });
|
|
|
|
|
// } else {
|
|
|
|
|
// reply.status(404).send({ message: "No orders found" });
|
|
|
|
|
// }
|
|
|
|
|
// } catch (err) {
|
|
|
|
|
// reply.status(400).send({ message: err.message });
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getAllOrderdelivered = async (req, reply) => {
|
|
|
|
|
const limit = parseInt(req.query.limit) || 100;
|
|
|
|
|
const page = parseInt(req.query.page) || 1;
|
|
|
|
|