feat: miler lifecycle — expose reachedat, arrival-fact reached, PATCH addresses

- GET /miler/bookings now returns reachedat + arrivallatitude/arrivallongitude
  on every row, so the app reconstructs "Arrived" (Pickup_Scheduled + reachedat)
  after a restart with no new status.
- reached records arrival as a FACT (timestamp + GPS) and no longer flips the
  booking to Arrived_At_Pickup — the status stays Pickup_Scheduled, matching the
  rider app's derive-from-reachedat model and dropping the console mapping need.
- New PATCH /miler/bookings/:id/addresses: partial pickup/delivery address,
  pincode, coords, city correction before pickup-complete (INVALID_STATE after).
- pickupbookings gains nullable arrivedat/arrivallatitude/arrivallongitude
  (AutoMigrate, additive).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WRaFH5hMRqmUQvVPQsyjZD
This commit is contained in:
Suriyakumarvijayanayagam
2026-08-25 17:49:59 +05:30
parent b0f733ae38
commit aeb859d80b
4 changed files with 134 additions and 16 deletions

View File

@@ -43,7 +43,14 @@ type PickupBooking struct {
Preferredpickupfrom *time.Time `json:"preferredpickupfrom" gorm:"column:preferredpickupfrom"`
Preferredpickupto *time.Time `json:"preferredpickupto" gorm:"column:preferredpickupto"`
Assignedmileruserid *int `json:"assignedmileruserid" gorm:"column:assignedmileruserid"`
Consignmentid *int `json:"consignmentid" gorm:"column:consignmentid"`
// Arrival trace: written by the reached action when the rider is at the
// pickup point. Nullable — a booking that was never reached has no arrival.
// arrivallatitude/longitude are the rider's actual GPS at the moment they
// tapped "arrived", kept as a durable record separate from live telemetry.
Arrivedat *time.Time `json:"arrivedat" gorm:"column:arrivedat"`
Arrivallatitude *float64 `json:"arrivallatitude" gorm:"column:arrivallatitude"`
Arrivallongitude *float64 `json:"arrivallongitude" gorm:"column:arrivallongitude"`
Consignmentid *int `json:"consignmentid" gorm:"column:consignmentid"`
// Consignmentstatus is not a column — it is filled in by handlers that want
// the live consignment status alongside the booking (e.g. the admin bookings
// list, so a "Converted_To_Consignment" booking can still show