diff --git a/src/controllers/supplierOrderController.js b/src/controllers/supplierOrderController.js index adf428a2..d342dc92 100644 --- a/src/controllers/supplierOrderController.js +++ b/src/controllers/supplierOrderController.js @@ -619,7 +619,7 @@ exports.getAllOrderaccepted = async (req, reply) => { const customerId = req.params.customerId; try { - const orders = await Tankerbooking.find({ customerId: customerId, orderStatus: "accepted" }) + const orders = await Tankerbooking.find({ customerId: customerId, orderStatus: "pending" }) .limit(limit) .skip(startindex) .exec(); @@ -666,9 +666,10 @@ exports.getAllOrderreject = 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({ orderStatus: ["rejected"]}) + await Tankerbooking.find({ customerId: customerId,orderStatus: ["rejected"]}) .limit(limit) .skip(startindex) .exec() @@ -680,6 +681,46 @@ exports.getAllOrderreject = async (req, reply) => { } }; + +exports.getAllOrdersoutfordelivery = 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: ["out_for_delivery"]}) + .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.getAllOrdersdeliveryboyasigned = 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: ["delivery_boy_assigned"]}) + .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.getCustomerOrderreject = async (req, reply) => { const limit = parseInt(req.query.limit) || 100; const page = parseInt(req.query.page) || 1; diff --git a/src/routes/supplierOrdersRoutes.js b/src/routes/supplierOrdersRoutes.js index bc00ab2d..c2cbdb48 100644 --- a/src/routes/supplierOrdersRoutes.js +++ b/src/routes/supplierOrdersRoutes.js @@ -468,23 +468,26 @@ module.exports = function (fastify, opts, next) { handler:supplierOrderController.getAllOrderaccepted, }); + + + fastify.route({ method: "GET", - url: "/api/allrejected", + url: "/api/allrejected/:customerId", schema: { tags: ["Supplier-Order"], description:"This is for Get All order cancelled", summary: "This is for Get All order cancelled", - // params: { - // required: ["customerId"], - // type: "object", - // properties: { - // customerId: { - // type: "string", - // description: "customerId", - // }, - // }, - // }, + params: { + required: ["customerId"], + type: "object", + properties: { + customerId: { + type: "string", + description: "customerId", + }, + }, + }, security: [ { @@ -495,6 +498,65 @@ module.exports = function (fastify, opts, next) { }, handler:supplierOrderController.getAllOrderreject, + }); + + + fastify.route({ + method: "GET", + url: "/api/getAllOrdersoutfordelivery/:customerId", + schema: { + tags: ["Supplier-Order"], + description:"This is for Get All order out for delivery", + summary: "This is for Get All out for delivery", + params: { + required: ["customerId"], + type: "object", + properties: { + customerId: { + type: "string", + description: "customerId", + }, + }, + }, + + security: [ + { + basicAuth: [], + }, + ], + + }, + handler:supplierOrderController.getAllOrdersoutfordelivery, + + }); + + fastify.route({ + method: "GET", + url: "/api/getAllOrdersdeliveryboyasigned/:customerId", + schema: { + tags: ["Supplier-Order"], + description:"This is for Get All orders for delivery boy assigned", + summary: "This is for Get All out for delivery boy assigned", + params: { + required: ["customerId"], + type: "object", + properties: { + customerId: { + type: "string", + description: "customerId", + }, + }, + }, + + security: [ + { + basicAuth: [], + }, + ], + + }, + handler:supplierOrderController.getAllOrdersdeliveryboyasigned, + }); fastify.route({