stock update
This commit is contained in:
@@ -322,8 +322,12 @@ func (ctl *OrderController) CreateOrderv3(c *fiber.Ctx) error {
|
||||
order, err := ctl.orderService.CreateOrder(data)
|
||||
if err != nil {
|
||||
log.Println("CreateOrder service error:", err)
|
||||
return c.Status(http.StatusInternalServerError).JSON(fiber.Map{
|
||||
"code": http.StatusInternalServerError,
|
||||
statusCode := http.StatusInternalServerError
|
||||
if strings.Contains(strings.ToLower(err.Error()), "insufficient stock") {
|
||||
statusCode = http.StatusConflict
|
||||
}
|
||||
return c.Status(statusCode).JSON(fiber.Map{
|
||||
"code": statusCode,
|
||||
"message": err.Error(),
|
||||
"status": false,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user