Skip to content

Commit

Permalink
get pending order
Browse files Browse the repository at this point in the history
  • Loading branch information
augustus281 committed Apr 1, 2024
1 parent ee2a2f2 commit d707ac0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions server/src/controllers/order.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const { sortObject } = require("../utils/payment")
let querystring = require('qs');
const crypto = require('crypto');
const Cart = require("../models/cart.model");
const { error } = require("console");

const tmnCode = process.env.vnp_TmnCode;
const secretKey = process.env.vnp_HashSecret;
Expand Down Expand Up @@ -232,6 +233,27 @@ class OrderController {
}
}

getPendingOrderByUser = async (req, res, next) => {
try {
const user_id = req.params.user_id;

const order = await Order.findAll({
where: { user_id: user_id, status: StatusOrder.PENDING }
})

if (!order)
return res.status(404).json({ message: "You haven't complete order"})

return res.status(200).json({
message: "Get pending order successfully!",
pending_orders: order
})
} catch (error) {
return res.status(500).json({ message: error.message })
}

}

getCompleteOrderByUser = async (req, res, next) => {
const user_id = req.params.user_id;

Expand Down

0 comments on commit d707ac0

Please sign in to comment.