package models type RiderInfo struct { Userid int `json:"userid"` Authname string `json:"authname"` Configid int `json:"configid"` Authmode int `json:"authmode"` Roleid int `json:"roleid"` Firstname string `json:"firstname"` Lastname string `json:"lastname"` Fullname string `json:"fullname"` Password string `json:"password"` Email string `json:"email"` Contactno string `json:"contactno"` Address string `json:"address"` Suburb string `json:"suburb"` City string `json:"city"` State string `json:"state"` Postcode string `json:"postcode"` Userfcmtoken string `json:"userfcmtoken"` Pin int `json:"pin"` Partnerid int `json:"partnerid"` Identificationno string `json:"identificationno"` Vehiclename string `json:"vehiclename"` Vehicleno string `json:"vehicleno"` Licenseno string `json:"licenseno"` Insuranceno string `json:"insoranceno"` Insurancedate string `json:"insurancedate"` Shiftid int `json:"shiftid"` Starttime string `json:"starttime"` Endtime string `json:"endtime"` Shifthours float32 `json:"shifthours"` Basefare float32 `json:"basefare"` Additionalcharges float32 `json:"additionalcharges"` Orders int `json:"orders"` Fuelcharge float32 `json:"fuelcharge"` Logdate string `json:"logdate"` Applocationid int `json:"applocationid"` Applocation string `json:"applocation"` Logseconds int `json:"logseconds"` Riderid int `json:"riderid"` Status string `json:"status"` Tenantid int `json:"tenantid"` } type Partnerinfo struct { Partnerid int `json:"partnerid" gorm:"Primary_Key"` Partnertypeid int `json:"partnertypeid"` Applocationid int `json:"applocationid"` Partnername string `json:"partnername"` Registrationno string `json:"registrationno"` Primarycontact string `json:"primartcontact"` Primaryemail string `json:"primaryemail"` Contactno string `json:"contactno"` Bizcategoryid int `json:"bizcategoryid"` Bizsubcategoryid int `json:"bizsubcategoryid"` Adderss string `json:"address"` Suburb string `json:"suburb"` State string `json:"state"` City string `json:"city"` Postcode string `json:"postcode"` Partnerinfo string `json:"partnerinfo"` Partnerimage string `json:"partnerimage"` // Read back so a directory can show who the partner is and whether they // are trading. Both columns have always been on the table; the struct had // no field for them, so `getpartners` could not report either. Companyname string `json:"companyname"` Status string `json:"status"` // Every region this partner covers, from `partnerlocations`. A partner is // not confined to the one city on their own row — that column records where // they were set up, and the link table records where they actually work. Locations []PartnerLocation `json:"locations" gorm:"-"` } type Ridershifts struct { Shiftid int `json:"shiftid" gorm:"Primary_Key"` // The region this shift belongs to. The column has always been on the table // — `GetRiderShifts` filters on it — but there was no field for it here, so // nothing could write one. That is why shifts could only ever be read. Applocationid int `json:"applocationid"` Shiftdate string `json:"shiftdate"` Starttime string `json:"starttime"` Endtime string `json:"endtime"` Shifthours float32 `json:"shifthours"` Basefare float32 `json:"basefare"` Additionalkm float32 `json:"additionalkm"` Additionalcharges float32 `json:"additionalcharges"` Orders int `json:"orders"` Fuelcharge float32 `json:"fuelcharge"` Shiftname string `json:"shiftname" gorm:"<-:false"` } type Locationconfigs struct { Applocationid int `json:"applocationid"` Configid int `json:"configid"` Locationname string `json:"locationname"` Latitude string `json:"latitude"` Longitude string `json:"longitude"` Status string `json:"status"` } type FleetCounts struct { Totalriders int `json:"totalriders"` Activeriders int `json:"activeriders"` Ridersworked int `json:"ridersworked"` Totallogins int `json:"totallogins"` } type FleetRiderSummary struct { Userid int `json:"userid"` Fullname string `json:"fullname"` Contactno string `json:"contactno"` Partnerid int `json:"partnerid"` Status string `json:"status"` Vehicleno string `json:"vehicleno"` Vehiclename string `json:"vehiclename"` Dayslogged int `json:"dayslogged"` Totalworkhours float32 `json:"totalworkhours"` Totalshorthours float32 `json:"totalshorthours"` Totalbreakhours float32 `json:"totalbreakhours"` } type FleetSummary struct { Counts FleetCounts `json:"counts"` Riders []FleetRiderSummary `json:"riders"` } type RiderlogDetails struct { Logid int `json:"logid"` Logdate string `json:"logdate"` Userid int `json:"userid"` Username string `json:"username"` Partnerid int `json:"partnerid"` Shiftid int `json:"shiftid"` Shifthours float32 `json:"shifthours"` Login string `json:"login"` Logout string `json:"logout"` Latitude string `json:"latitude"` Longitude string `json:"longitude"` Workhours float32 `json:"workhours"` Shorthours float32 `json:"shorthours"` Breakhours float32 `json:"breakhours"` Logstatus int `json:"logstatus"` } // NewRider is one rider being onboarded, as the console sends it. // // A rider is three rows, not one. `app_users` holds the person, `ridersettings` // the vehicle and licence, and `app_userpools` their place in the availability // pool — and `getriders` INNER JOINs all three, so a rider missing any of them // is not a partial rider, they are no rider at all. The flat shape here is // deliberate: the caller should not have to know the table layout to hire // somebody. // // `Tenantid` is filled in by the controller from the caller's scope, never read // from the body — a store admin must not be able to put a rider on another // merchant's books by editing a payload. type NewRider struct { Userid int `json:"userid"` Firstname string `json:"firstname"` Lastname string `json:"lastname"` Contactno string `json:"contactno"` Email string `json:"email"` Password string `json:"password"` Address string `json:"address"` Suburb string `json:"suburb"` City string `json:"city"` State string `json:"state"` Postcode string `json:"postcode"` // Whose rider they are, where they ride, and who they ride for. // // Tenantid and Partnerid are exclusive: a rider belongs to a shop or to a // delivery partner, never to both and never to neither. The controller // refuses either mistake. // // Locationid is the branch an OWN rider works out of. It is meaningless for // a partner's rider — a partner supplies several merchants and is not tied // to any one shop's outlet — so it is only ever set alongside a tenantid. Tenantid int `json:"tenantid"` Locationid int `json:"locationid"` Applocationid int `json:"applocationid"` Partnerid int `json:"partnerid"` Shiftid int `json:"shiftid"` // The vehicle half — `ridersettings`. Identificationno string `json:"identificationno"` Vehiclename string `json:"vehiclename"` Vehicleno string `json:"vehicleno"` Licenseno string `json:"licenseno"` Registrationno string `json:"registrationno"` Status string `json:"status"` } // RiderRosterRow is one rider in the directory. // // Distinct from RiderInfo, which is the ON-DUTY read: that one requires a // riderlog stamped today, which is right for an assignment picker and wrong for // a staff list, where somebody who has not started their shift must still // appear. This carries the last log rather than requiring one. type RiderRosterRow struct { Userid int `json:"userid"` Firstname string `json:"firstname"` Lastname string `json:"lastname"` Fullname string `json:"fullname"` Contactno string `json:"contactno"` Email string `json:"email"` Tenantid int `json:"tenantid"` Locationid int `json:"locationid"` Locationname string `json:"locationname"` Applocationid int `json:"applocationid"` Applocation string `json:"applocation"` Partnerid int `json:"partnerid"` Partnername string `json:"partnername"` Shiftid int `json:"shiftid"` Shiftname string `json:"shiftname"` Identificationno string `json:"identificationno"` Vehiclename string `json:"vehiclename"` Vehicleno string `json:"vehicleno"` Licenseno string `json:"licenseno"` Registrationno string `json:"registrationno"` // Duty state, as facts rather than as a filter. Onduty int `json:"onduty"` Lastlogdate string `json:"lastlogdate"` // True when there is a log dated today with logstatus 0 — on shift right now. Isonduty bool `json:"isonduty"` Status string `json:"status"` } // Ridersettings is the vehicle-and-licence half of a rider. // // `riderid` is DELIBERATELY ABSENT. It is a GENERATED ALWAYS identity column, // and including it makes GORM send a zero, which Postgres rejects outright: // "cannot insert a non-DEFAULT value into column riderid". Leaving it off the // struct is what keeps the insert to the columns that are actually ours to set. type Ridersettings struct { Userid int `json:"userid"` Partnerid int `json:"partnerid"` Shiftid int `json:"shiftid"` Identificationno string `json:"identificationno"` Vehiclename string `json:"vehiclename"` Vehicleno string `json:"vehicleno"` Licenseno string `json:"licenseno"` Registrationno string `json:"registrationno"` } // Appuserpools is a rider's place in the availability pool. // // `poolid` is absent for the same reason as `riderid` above — same identity // column, same rejection. // // `Onduty` means "may be given work", not "on shift right now". The second // question is answered by riderlogs, which the rider's own app writes. type Appuserpools struct { Userid int `json:"userid"` Partnerid int `json:"partnerid"` Onduty int `json:"onduty"` Status string `json:"status"` } // PartnerLocation is one region a partner covers — a row of `partnerlocations`. type PartnerLocation struct { Partnerlocationid int `json:"partnerlocationid" gorm:"column:partnerlocationid"` Partnerid int `json:"partnerid" gorm:"column:partnerid"` Applocationid int `json:"applocationid" gorm:"column:applocationid"` Applocation string `json:"applocation" gorm:"column:applocation"` } // NewPartner is everything the console collects to onboard a delivery partner. // // Separate from `Partnerinfo`, which is the READ shape. Binding a create to the // read model is how a caller ends up able to set columns nobody meant to expose // — `allocationid`, `partnertypeid`, the billing links — because a form happened // to send them. // // A partner is a company that supplies riders. It is onboarded by the platform, // never by a merchant: the merchant's side of this is being ASSIGNED one, which // is `AssignPartner` on the tenant. type NewPartner struct { Partnerid int `json:"partnerid"` Partnername string `json:"partnername"` Companyname string `json:"companyname"` Registrationno string `json:"registrationno"` Primarycontact string `json:"primarycontact"` Primaryemail string `json:"primaryemail"` Contactno string `json:"contactno"` Address string `json:"address"` Suburb string `json:"suburb"` City string `json:"city"` State string `json:"state"` Postcode int `json:"postcode"` Partnerinfo string `json:"partnerinfo"` Partnerimage string `json:"partnerimage"` Status string `json:"status"` /* Where they work — ONE district, not a set. `Applocationid` is the home region and goes on the partner row itself, because the rider app reads it. The same region is also written to `partnerlocations`, which is the table that may hold SEVERAL — a partner routinely serves more than one city, and that is why the link table exists, and partners with two are live — partner 44 covers regions 1 and 2. Nothing on THIS path creates one: `regionsOf` returns this single field and the console's form offers one district, never a set. So a multi-region partner can be read and must be handled, but cannot yet be made here. `GetPartners` reads the link table rather than this field, for two reasons. It is the column allowed to grow, so a partner who covers a second city will be found there without another change. And `partnerinfo` is shared with another product that writes no link rows, so having one is what marks a partner as ours. */ Applocationid int `json:"applocationid"` /* The district by NAME, for one that is not open yet. Nearle runs three of Tamil Nadu's thirty-eight districts, and a partner could only be placed in those three because `partnerinfo.applocationid` has to point at an `app_location` row. Sending the name instead opens the district — see `EnsureRegion` — so the form can offer all 38 and mean it. Ignored when `Applocationid` is set, which is the ordinary case. */ District string `json:"district"` }