Files
doormile_backend/constants/constants.go
Suriyakumarvijayanayagam f09efcaf59 feat: express-batch dispatch — manual trigger for the AI agent
Adds the backend half of the ExpressDispatchAgent flow. Express orders can now
be created batch by batch (bulk create only accumulates them, unassigned), then
an operator hits one endpoint to hand the whole pending set to the agent for
tenant-scoped assignment + road sequencing. The normal B2C flow is untouched.

- POST /admin/expressbooking/dispatch: manual trigger. Console-auth, tenant-
  scoped; gathers the tenant's pending unassigned express orders (or a chosen
  subset) and publishes express.dispatch_requested.
- internal API for the agent: GET /internal/express/riders (tenant's available
  riders), GET /internal/express/bookings, POST /internal/express/assign (writes
  the agent's decided assignments with their sequence; re-checks the already-
  assigned guard so the agent can't double-assign).
- booking_assignment_service.go: extracted a behavior-preserving assignMilerTx
  core; AssignMilerToBooking is unchanged in behavior. assignExpressStops writes
  a batch, one FCM per rider instead of one per stop.
- EXPRESS JetStream stream / express.dispatch_requested subject.
- Gated behind EXPRESS_AGENT_ENABLED (default off): deploying this changes
  nothing until the agent is confirmed running and the flag is flipped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-17 19:33:48 +05:30

115 lines
3.0 KiB
Go

package constants
// Miler Availability Statuses
const (
MilerOffline = "Offline"
MilerAvailable = "Available"
MilerAssigned = "Assigned"
MilerOnPickup = "On_Pickup"
MilerAtCustomer = "At_Customer"
MilerPickedUp = "Picked_Up"
MilerOnDelivery = "On_Delivery"
MilerBreak = "Break"
MilerBlocked = "Blocked"
)
// Booking sources — where a booking originated. Left as their stored literals:
// "CRM_Console" predates the outward express rename and is an existing DB value.
const (
BookingSourceCustomerApp = "Customer_App"
BookingSourceExpress = "CRM_Console"
)
// App (B2C) Customer Statuses
const (
CustomerStatusActive = "Active"
CustomerStatusBlocked = "Blocked"
CustomerStatusDeleted = "Deleted"
)
// Booking Statuses
const (
BookingPendingPickup = "Pending_Pickup" // customer requested pickup, delivery details not yet known
BookingCreated = "Created"
BookingMilerAssigned = "Miler_Assigned"
BookingPickupScheduled = "Pickup_Scheduled"
BookingPickedUp = "Picked_Up"
BookingConvertedConsignment = "Converted_To_Consignment"
BookingCancelled = "Cancelled"
)
// Consignment Statuses
const (
ConsignmentCreated = "Created"
ConsignmentInwardedAtHub = "Inwarded_at_Hub"
ConsignmentTripsheetLoaded = "Tripsheet_Loaded"
ConsignmentInTransit = "In_Transit"
ConsignmentOutForDelivery = "Out_for_Delivery"
ConsignmentDelivered = "Delivered"
ConsignmentRTOInitiated = "RTO_Initiated"
ConsignmentReturnedToSender = "Returned_to_Sender"
ConsignmentMissing = "Missing"
ConsignmentDamaged = "Damaged"
)
// Payment Modes
const (
PaymentModeCash = "Cash"
PaymentModeUPI = "UPI"
PaymentModeCard = "Card"
PaymentModeWallet = "Wallet"
)
// Payment Statuses
const (
PaymentStatusPending = "Pending"
PaymentStatusPaid = "Paid"
PaymentStatusFailed = "Failed"
PaymentStatusRefunded = "Refunded"
)
// Assignment Statuses
const (
AssignmentAssigned = "Assigned"
AssignmentAccepted = "Accepted"
AssignmentRejected = "Rejected"
AssignmentReassigned = "Reassigned"
AssignmentCompleted = "Completed"
AssignmentCancelled = "Cancelled"
)
// Tripsheet Statuses
const (
TripsheetDraft = "Draft"
TripsheetReady = "Ready"
TripsheetDispatched = "Dispatched"
TripsheetArrived = "Arrived"
TripsheetCancelled = "Cancelled"
)
// Scan Statuses
const (
ScanPending = "Pending"
ScanLoaded = "Loaded"
ScanUnloaded = "Unloaded"
ScanDiscrepancy = "Discrepancy"
)
// Exception Types
const (
ExceptionLost = "Lost"
ExceptionDamaged = "Damaged"
ExceptionMisrouted = "Misrouted"
ExceptionReceiverRefused = "Receiver_Refused"
ExceptionMissingContents = "Missing_Contents"
ExceptionUndeliverable = "Undeliverable"
)
// Exception Statuses
const (
ExceptionOpen = "Open"
ExceptionUnderInvestigation = "Under_Investigation"
ExceptionResolved = "Resolved"
ExceptionClosed = "Closed"
)