status updated

This commit is contained in:
2026-10-09 16:27:51 +05:30
parent ed32a2620e
commit f0361d8343
12 changed files with 559 additions and 23 deletions

View File

@@ -12,10 +12,17 @@ import (
type DeliverySlotController struct {
service services.DeliverySlotService
// Asked whether the shop is trading at all. Held here rather than inside
// the slot service, which answers one question — is this window still
// running — and should not also have to know about shop closures.
tenants services.TenantService
}
func NewDeliverySlotController(service services.DeliverySlotService) *DeliverySlotController {
return &DeliverySlotController{service: service}
func NewDeliverySlotController(
service services.DeliverySlotService,
tenants services.TenantService,
) *DeliverySlotController {
return &DeliverySlotController{service: service, tenants: tenants}
}
/*
@@ -128,6 +135,28 @@ func (ctl *DeliverySlotController) AvailableDeliverySlots(c *fiber.Ctx) error {
})
}
/*
A shut shop offers nothing.
Without this, a branch closed for the day still hands the app tomorrow
morning — and the shopper picks it, reaches checkout, and is refused by
the closed-shop guard in order creation with no warning anything was
wrong. The empty list is already the app's "no windows here" path, so
this needs nothing new on their side.
The reason rides along so the app can say WHY rather than just showing
nothing, on an endpoint it is already calling.
*/
if reason := ctl.tenants.StoreClosedReason(tenantID, locationID); reason != "" {
return c.Status(http.StatusOK).JSON(fiber.Map{
"code": http.StatusOK,
"message": "Success",
"status": true,
"details": []models.AvailableDeliverySlot{},
"closedreason": reason,
})
}
slots, err := ctl.service.Available(tenantID, locationID)
if err != nil {
return c.Status(http.StatusInternalServerError).JSON(fiber.Map{