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

@@ -20,15 +20,21 @@ type OrderController struct {
// than reimplemented, so the app's list and this check can never disagree
// about where a window ends.
deliverySlotService services.DeliverySlotService
// Asked whether the shop is trading. Same reasoning: the customer-facing
// store list and this check run the same rule, so a shop shown as open is
// never refused here.
tenantService services.TenantService
}
func NewOrderController(
orderService services.OrderService,
deliverySlotService services.DeliverySlotService,
tenantService services.TenantService,
) *OrderController {
return &OrderController{
orderService: orderService,
deliverySlotService: deliverySlotService,
tenantService: tenantService,
}
}
@@ -358,6 +364,24 @@ func (ctl *OrderController) CreateOrderv3(c *fiber.Ctx) error {
data.Deliverytime = time.Now().Format("2006-01-02 15:04:05")
}
/*
Is the shop even trading?
Checked HERE and not only in the app, because /v1/mob/* carries no
session: anything arriving is a claim. The ordinary case is innocent and
still has to be caught — a shopper with the app open when the shopkeeper
closes, or a stale screen from this morning.
409 with the shop's own reason, written to be shown as-is.
*/
if reason := ctl.tenantService.StoreClosedReason(data.Tenantid, data.Locationid); reason != "" {
return c.Status(http.StatusConflict).JSON(fiber.Map{
"code": http.StatusConflict,
"message": reason,
"status": false,
})
}
// The chosen delivery window, re-decided here.
//
// The app sends back what /v1/mob/deliveryslots/available handed it, but