stock update

This commit is contained in:
2026-07-21 16:17:51 +05:30
parent b7af245910
commit 5e998a54eb
3 changed files with 126 additions and 6 deletions

View File

@@ -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,
})