Initial commit including .env

This commit is contained in:
2026-06-22 17:43:40 +05:30
commit c577d47b75
286 changed files with 85878 additions and 0 deletions

116
models/audit.go Normal file
View File

@@ -0,0 +1,116 @@
package models
import (
"time"
)
type Pricing struct {
Pricingid int `json:"pricingid" gorm:"primaryKey;column:pricingid"`
Tenantid int `json:"tenantid" gorm:"column:tenantid"`
Applocationid int `json:"applocationid" gorm:"column:applocationid"`
Vehicletype string `json:"vehicletype" gorm:"column:vehicletype"`
Baseprice float64 `json:"baseprice" gorm:"column:baseprice;not null"`
Baseweight float64 `json:"baseweight" gorm:"column:baseweight;not null"`
Priceperkg float64 `json:"priceperkg" gorm:"column:priceperkg;not null"`
Basedistance float64 `json:"basedistance" gorm:"column:basedistance;not null"`
Priceperkm float64 `json:"priceperkm" gorm:"column:priceperkm;not null"`
Handlingcharges float64 `json:"handlingcharges" gorm:"column:handlingcharges;default:0.00"`
Effectivefrom time.Time `json:"effectivefrom" gorm:"column:effectivefrom;not null"`
Effectiveto time.Time `json:"effectiveto" gorm:"column:effectiveto;not null"`
Currency string `json:"currency" gorm:"column:currency;default:INR"`
Priority int `json:"priority" gorm:"column:priority;default:0"`
Status string `json:"status" gorm:"column:status;default:Active"` // Active, InActive
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
Createdby int `json:"createdby" gorm:"column:createdby"`
Updatedby int `json:"updatedby" gorm:"column:updatedby"`
Deletedat *time.Time `json:"deletedat,omitempty" gorm:"column:deletedat"`
}
func (Pricing) TableName() string {
return "pricing"
}
type Consignment struct {
Consignmentid int `json:"consignmentid" gorm:"primaryKey;column:consignmentid"`
Trackingno string `json:"trackingno" gorm:"column:trackingno;unique;not null"`
Orderheaderid *int `json:"orderheaderid" gorm:"column:orderheaderid"`
Tenantid int `json:"tenantid" gorm:"column:tenantid"`
Senderid *int `json:"senderid" gorm:"column:senderid"`
Receiverid *int `json:"receiverid" gorm:"column:receiverid"`
Pickuplocationid *int `json:"pickuplocationid" gorm:"column:pickuplocationid"`
Deliverylocationid *int `json:"deliverylocationid" gorm:"column:deliverylocationid"`
Originhubid *int `json:"originhubid" gorm:"column:originhubid"`
Currenthubid *int `json:"currenthubid" gorm:"column:currenthubid"`
Destinationhubid *int `json:"destinationhubid" gorm:"column:destinationhubid"`
Pickuppincode string `json:"pickuppincode" gorm:"column:pickuppincode"`
Deliverypincode string `json:"deliverypincode" gorm:"column:deliverypincode"`
Pickuplatitude float64 `json:"pickuplatitude" gorm:"column:pickuplatitude"`
Pickuplongitude float64 `json:"pickuplongitude" gorm:"column:pickuplongitude"`
Deliverylatitude float64 `json:"deliverylatitude" gorm:"column:deliverylatitude"`
Deliverylongitude float64 `json:"deliverylongitude" gorm:"column:deliverylongitude"`
Length float64 `json:"length" gorm:"column:length"`
Width float64 `json:"width" gorm:"column:width"`
Height float64 `json:"height" gorm:"column:height"`
Deadweight float64 `json:"deadweight" gorm:"column:deadweight;not null"`
Volumetricweight float64 `json:"volumetricweight" gorm:"column:volumetricweight"`
Chargeableweight float64 `json:"chargeableweight" gorm:"column:chargeableweight;not null"`
Codamount float64 `json:"codamount" gorm:"column:codamount;default:0.00"`
Codcollected float64 `json:"codcollected" gorm:"column:codcollected;default:0.00"`
Paymentmode string `json:"paymentmode" gorm:"column:paymentmode"` // Prepaid, COD, To_Pay
Billingstatus string `json:"billingstatus" gorm:"column:billingstatus;default:Unbilled"` // Unbilled, Billed, Paid, Settled
Status string `json:"status" gorm:"column:status;default:Created"` // Created, Inwarded_at_Hub, Tripsheet_Loaded, In_Transit, Out_for_Delivery, Delivered, RTO_Initiated, Returned_to_Sender, Missing, Damaged
Attemptcount int `json:"attemptcount" gorm:"column:attemptcount;default:0"`
Estimateddeliveryat *time.Time `json:"estimateddeliveryat" gorm:"column:estimateddeliveryat"`
Sladueat *time.Time `json:"sladueat" gorm:"column:sladueat"`
Returnreason string `json:"returnreason" gorm:"column:returnreason"`
Returninitiatedat *time.Time `json:"returninitiatedat" gorm:"column:returninitiatedat"`
Returndeliveredat *time.Time `json:"returndeliveredat" gorm:"column:returndeliveredat"`
Parentconsignmentid *int `json:"parentconsignmentid" gorm:"column:parentconsignmentid"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
Createdby int `json:"createdby" gorm:"column:createdby"`
Updatedby int `json:"updatedby" gorm:"column:updatedby"`
Deletedat *time.Time `json:"deletedat,omitempty" gorm:"column:deletedat"`
}
func (Consignment) TableName() string {
return "consignments"
}
type ConsignmentHistory struct {
Historyid int `json:"historyid" gorm:"primaryKey;column:historyid"`
Consignmentid int `json:"consignmentid" gorm:"column:consignmentid"`
Tripsheetid *int `json:"tripsheetid" gorm:"column:tripsheetid"`
Hubid *int `json:"hubid" gorm:"column:hubid"`
Userid *int `json:"userid" gorm:"column:userid"`
Eventstatus string `json:"eventstatus" gorm:"column:eventstatus;not null"`
Remarks string `json:"remarks" gorm:"column:remarks"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
}
func (ConsignmentHistory) TableName() string {
return "consignmenthistory"
}
type ConsignmentException struct {
Exceptionid int `json:"exceptionid" gorm:"primaryKey;column:exceptionid"`
Consignmentid int `json:"consignmentid" gorm:"column:consignmentid"`
Tripsheetid *int `json:"tripsheetid" gorm:"column:tripsheetid"`
Hubid *int `json:"hubid" gorm:"column:hubid"`
Reportedbyuserid *int `json:"reportedbyuserid" gorm:"column:reportedbyuserid"`
Exceptiontype string `json:"exceptiontype" gorm:"column:exceptiontype;not null"` // Lost, Damaged, Misrouted, Receiver_Refused, Missing_Contents, Undeliverable
Severity string `json:"severity" gorm:"column:severity;default:Medium"` // Low, Medium, High, Critical
Description string `json:"description" gorm:"column:description"`
Resolution string `json:"resolution" gorm:"column:resolution"`
Status string `json:"status" gorm:"column:status;default:Open"` // Open, Under_Investigation, Resolved, Closed
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
Createdby int `json:"createdby" gorm:"column:createdby"`
Updatedby int `json:"updatedby" gorm:"column:updatedby"`
Deletedat *time.Time `json:"deletedat,omitempty" gorm:"column:deletedat"`
}
func (ConsignmentException) TableName() string {
return "consignmentexceptions"
}

131
models/booking.go Normal file
View File

@@ -0,0 +1,131 @@
package models
import (
"time"
)
type PickupBooking struct {
Bookingid int `json:"bookingid" gorm:"primaryKey;column:bookingid"`
Bookingno string `json:"bookingno" gorm:"column:bookingno;unique;not null"`
Appcustomerid int `json:"appcustomerid" gorm:"column:appcustomerid"`
Pickuplocationid *int `json:"pickuplocationid" gorm:"column:pickuplocationid"`
Pickupaddress string `json:"pickupaddress" gorm:"column:pickupaddress;not null"`
Pickuppincode string `json:"pickuppincode" gorm:"column:pickuppincode;not null"`
Pickuplatitude float64 `json:"pickuplatitude" gorm:"column:pickuplatitude;not null"`
Pickuplongitude float64 `json:"pickuplongitude" gorm:"column:pickuplongitude;not null"`
Deliveryaddress string `json:"deliveryaddress" gorm:"column:deliveryaddress;not null"`
Deliverypincode string `json:"deliverypincode" gorm:"column:deliverypincode;not null"`
Deliverylatitude float64 `json:"deliverylatitude" gorm:"column:deliverylatitude;not null"`
Deliverylongitude float64 `json:"deliverylongitude" gorm:"column:deliverylongitude;not null"`
Deliverycity string `json:"deliverycity" gorm:"column:deliverycity"`
Nearesthubid *int `json:"nearesthubid" gorm:"column:nearesthubid"`
Bookingsource string `json:"bookingsource" gorm:"column:bookingsource;default:Customer_App"`
Providercompany string `json:"providercompany" gorm:"column:providercompany"`
Providerlocation string `json:"providerlocation" gorm:"column:providerlocation"`
Notes string `json:"notes" gorm:"column:notes"`
Status string `json:"status" gorm:"column:status;default:Created"` // Created, Miler_Assigned, Pickup_Scheduled, Picked_Up, Converted_To_Consignment, Cancelled
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"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
// Relations
Parcels []BookingParcel `json:"parcels" gorm:"foreignKey:Bookingid"`
ServiceOptions []BookingServiceOption `json:"serviceoptions" gorm:"foreignKey:Bookingid"`
Payments []BookingPayment `json:"payments" gorm:"foreignKey:Bookingid"`
}
func (PickupBooking) TableName() string {
return "pickupbookings"
}
type BookingParcel struct {
Bookingparcelid int `json:"bookingparcelid" gorm:"primaryKey;column:bookingparcelid"`
Bookingid int `json:"bookingid" gorm:"column:bookingid"`
Itemcategory string `json:"itemcategory" gorm:"column:itemcategory"`
Itemdescription string `json:"itemdescription" gorm:"column:itemdescription"`
Declaredvalue float64 `json:"declaredvalue" gorm:"column:declaredvalue"`
Weight float64 `json:"weight" gorm:"column:weight"`
Length float64 `json:"length" gorm:"column:length"`
Width float64 `json:"width" gorm:"column:width"`
Height float64 `json:"height" gorm:"column:height"`
Isfragile bool `json:"isfragile" gorm:"column:isfragile;default:false"`
Needsinsurance bool `json:"needsinsurance" gorm:"column:needsinsurance;default:false"`
Insuranceamount float64 `json:"insuranceamount" gorm:"column:insuranceamount;default:0.00"`
Requireslargevehicle bool `json:"requireslargevehicle" gorm:"column:requireslargevehicle;default:false"`
Suggestedvehicletype string `json:"suggestedvehicletype" gorm:"column:suggestedvehicletype"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
}
func (BookingParcel) TableName() string {
return "bookingparcels"
}
type BookingServiceOption struct {
Bookingserviceid int `json:"bookingserviceid" gorm:"primaryKey;column:bookingserviceid"`
Bookingid int `json:"bookingid" gorm:"column:bookingid"`
Servicetype string `json:"servicetype" gorm:"column:servicetype"` // Normal, Fast, Superfast
Estimatedprice float64 `json:"estimatedprice" gorm:"column:estimatedprice"`
Estimateddeliveryat *time.Time `json:"estimateddeliveryat" gorm:"column:estimateddeliveryat"`
Sladueat *time.Time `json:"sladueat" gorm:"column:sladueat"`
Pricingid *int `json:"pricingid" gorm:"column:pricingid"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
}
func (BookingServiceOption) TableName() string {
return "bookingserviceoptions"
}
type BookingPayment struct {
Bookingpaymentid int `json:"bookingpaymentid" gorm:"primaryKey;column:bookingpaymentid"`
Bookingid int `json:"bookingid" gorm:"column:bookingid"`
Amount float64 `json:"amount" gorm:"column:amount;not null"`
Paymentmode string `json:"paymentmode" gorm:"column:paymentmode"` // Cash, UPI, Card, Wallet
Paymentstatus string `json:"paymentstatus" gorm:"column:paymentstatus;default:Pending"` // Pending, Paid, Failed, Refunded
Collectedbyuserid *int `json:"collectedbyuserid" gorm:"column:collectedbyuserid"`
Transactionref string `json:"transactionref" gorm:"column:transactionref"`
Paidat *time.Time `json:"paidat" gorm:"column:paidat"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
}
func (BookingPayment) TableName() string {
return "bookingpayments"
}
type BookingAssignment struct {
Bookingassignmentid int `json:"bookingassignmentid" gorm:"primaryKey;column:bookingassignmentid"`
Bookingid int `json:"bookingid" gorm:"column:bookingid"`
Mileruserid int `json:"mileruserid" gorm:"column:mileruserid"`
Assignedbyuserid *int `json:"assignedbyuserid" gorm:"column:assignedbyuserid"`
Assignmentstatus string `json:"assignmentstatus" gorm:"column:assignmentstatus;default:Assigned"` // Assigned, Accepted, Rejected, Reassigned, Completed, Cancelled
Assignedat time.Time `json:"assignedat" gorm:"column:assignedat;default:CURRENT_TIMESTAMP"`
Acceptedat *time.Time `json:"acceptedat" gorm:"column:acceptedat"`
Completedat *time.Time `json:"completedat" gorm:"column:completedat"`
Remarks string `json:"remarks" gorm:"column:remarks"`
}
func (BookingAssignment) TableName() string {
return "bookingassignments"
}
type BookingVehicleRequirement struct {
Requirementid int `json:"requirementid" gorm:"primaryKey;column:requirementid"`
Bookingid int `json:"bookingid" gorm:"column:bookingid"`
Requiredvehicletype string `json:"requiredvehicletype" gorm:"column:requiredvehicletype;not null"`
Reason string `json:"reason" gorm:"column:reason"`
Nearesthubid *int `json:"nearesthubid" gorm:"column:nearesthubid"`
Scheduledpickupfrom *time.Time `json:"scheduledpickupfrom" gorm:"column:scheduledpickupfrom"`
Scheduledpickupto *time.Time `json:"scheduledpickupto" gorm:"column:scheduledpickupto"`
Assignedvehicleid *int `json:"assignedvehicleid" gorm:"column:assignedvehicleid"`
Assigneddriveruserid *int `json:"assigneddriveruserid" gorm:"column:assigneddriveruserid"`
Status string `json:"status" gorm:"column:status;default:Required"` // Required, Scheduled, Assigned, Arrived, Picked_Up, Cancelled
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
}
func (BookingVehicleRequirement) TableName() string {
return "bookingvehiclerequirements"
}

72
models/client.go Normal file
View File

@@ -0,0 +1,72 @@
package models
import (
"time"
"gorm.io/gorm"
)
type DoormileClient struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
// Core identity
FirstName string `gorm:"size:100;not null" json:"first_name"`
LastName string `gorm:"size:100" json:"last_name"`
Phone string `gorm:"uniqueIndex;size:20;not null" json:"phone"`
// Location
Address string `gorm:"type:text" json:"address"`
City string `gorm:"size:100" json:"city"`
State string `gorm:"size:100" json:"state"`
Neighbourhood string `gorm:"size:100" json:"neighbourhood"`
Pincode string `gorm:"size:20" json:"pincode"`
// GPS survey data
SurveyLat float64 `gorm:"column:surveylat" json:"survey_lat"`
SurveyLong float64 `gorm:"column:surveylong" json:"survey_long"`
SurveyAddress string `gorm:"type:text" json:"survey_address"`
SurveyZone string `gorm:"size:100" json:"survey_zone"`
SurveyPincode string `gorm:"size:20" json:"survey_pincode"`
// Business profile (both consent levels)
BusinessType string `gorm:"size:50" json:"business_type"`
Status string `gorm:"size:50;default:'newClient'" json:"status"`
ShippingFrequency string `gorm:"size:50" json:"shipping_frequency"`
LogisticsSegment string `gorm:"size:50" json:"logistics_segment"`
TransitFrom string `gorm:"size:100" json:"transit_from"`
TransitTo string `gorm:"size:100" json:"transit_to"`
// Full-consent-only fields (zeroed for basicOnly)
ParcelVolume float64 `json:"parcel_volume"`
ActiveContracts int `json:"active_contracts"`
LogisticsProvider string `gorm:"size:100" json:"logistics_provider"`
ProviderEfficiency string `gorm:"size:100" json:"provider_efficiency"`
Notes string `gorm:"type:text" json:"notes"`
// Consent & registration tracking
DataConsent string `gorm:"size:20;default:'full'" json:"data_consent"`
RegistrationSource string `gorm:"size:50" json:"registration_source"`
RegisteredByID uint64 `json:"registered_by_id"`
}
func (DoormileClient) TableName() string {
return "doormile_clients"
}
type DoormileAuth struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
ClientID *uint64 `gorm:"default:null" json:"client_id"`
Client DoormileClient `gorm:"foreignKey:ClientID" json:"client"`
Email string `gorm:"uniqueIndex;size:255;not null" json:"email"`
PasswordHash string `gorm:"not null" json:"-"`
Role string `gorm:"default:'user'" json:"role"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (DoormileAuth) TableName() string {
return "doormile_auth"
}

View File

@@ -0,0 +1,27 @@
package models
import "time"
// Zone values: Local | Interstate | OtherState
// Category values: General | Documents | Electronics | Clothing | Fragile | Medical | Automotive | Food
// ServiceType: Normal | Express
type DoormilePricing struct {
Doormile_pricing_id int `json:"doormile_pricing_id" gorm:"primaryKey;column:doormile_pricing_id"`
Zone string `json:"zone" gorm:"column:zone;not null"`
Category string `json:"category" gorm:"column:category;not null"`
Servicetype string `json:"servicetype" gorm:"column:servicetype;not null"`
Minweight float64 `json:"min_weight" gorm:"column:min_weight;not null"`
Maxweight float64 `json:"max_weight" gorm:"column:max_weight;not null"`
Minprice float64 `json:"min_price" gorm:"column:min_price;not null"`
Maxprice float64 `json:"max_price" gorm:"column:max_price;not null"`
Currency string `json:"currency" gorm:"column:currency;default:INR"`
Status string `json:"status" gorm:"column:status;default:Active"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
Deletedat *time.Time `json:"deletedat,omitempty" gorm:"column:deletedat"`
}
func (DoormilePricing) TableName() string {
return "doormile_pricing"
}

51
models/enquiry.go Normal file
View File

@@ -0,0 +1,51 @@
package models
import (
"time"
"gorm.io/gorm"
)
// CompetitorBranch is a field-surveyed branch of a competing courier company.
type CompetitorBranch struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
CreatedBy uint64 `json:"created_by"`
UpdatedBy uint64 `json:"updated_by"`
Company string `gorm:"size:255;not null;index" json:"company"`
Area string `gorm:"size:255" json:"area"`
Phone string `gorm:"size:30" json:"phone"`
PlusCode string `gorm:"size:100" json:"plus_code"`
Address string `gorm:"type:text" json:"address"`
Pincodes string `gorm:"type:text" json:"pincodes"` // Comma-separated list of pincodes served
RatePerKg string `gorm:"size:255" json:"rate_per_kg"`
OffersPickup string `gorm:"size:255" json:"offers_pickup"`
OffersDrop string `gorm:"size:255" json:"offers_drop"`
TimeInDays string `gorm:"size:255" json:"time_in_days"`
PackingCharge string `gorm:"size:255" json:"packing_charge"`
Frequency string `gorm:"size:255" json:"frequency"`
}
func (CompetitorBranch) TableName() string { return "competitor_branches" }
// CarrierPricing holds per-company, per-weight-slab, per-zone rate ranges.
type CarrierPricing struct {
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy uint64 `json:"created_by"`
UpdatedBy uint64 `json:"updated_by"`
Company string `gorm:"size:255;not null;index" json:"company"`
WeightSlab string `gorm:"size:60" json:"weight_slab"`
ServiceType string `gorm:"size:120" json:"service_type"`
Zone string `gorm:"size:120" json:"zone"`
Rate string `gorm:"size:60" json:"rate"`
DeliveryTime string `gorm:"size:60" json:"delivery_time"`
}
func (CarrierPricing) TableName() string { return "carrier_pricing" }

62
models/external.go Normal file
View File

@@ -0,0 +1,62 @@
package models
import "time"
// Tenant represents the pre-existing 'tenants' table
type Tenant struct {
Tenantid int `json:"tenantid" gorm:"primaryKey;column:tenantid"`
Tenantname string `json:"tenantname" gorm:"column:tenantname"`
Primaryemail string `json:"primaryemail" gorm:"column:primaryemail"`
Primarycontact string `json:"primarycontact" gorm:"column:primarycontact"`
Status string `json:"status" gorm:"column:status;default:Active"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
}
func (Tenant) TableName() string {
return "tenants"
}
// Customer represents the pre-existing 'customers' table
type Customer struct {
Customerid int `json:"customerid" gorm:"primaryKey;column:customerid"`
Firstname string `json:"firstname" gorm:"column:firstname"`
Lastname string `json:"lastname" gorm:"column:lastname"`
Contactno string `json:"contactno" gorm:"column:contactno"`
Email string `json:"email" gorm:"column:email"`
Status int `json:"status" gorm:"column:status"`
Createdat time.Time `json:"createdat" gorm:"column:createdat"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat"`
}
func (Customer) TableName() string {
return "customers"
}
// CustomerLocation represents the pre-existing 'customerlocations' table
type CustomerLocation struct {
Locationid int `json:"locationid" gorm:"primaryKey;column:locationid"`
Customerid int `json:"customerid" gorm:"column:customerid"`
Address string `json:"address" gorm:"column:address"`
City string `json:"city" gorm:"column:city"`
State string `json:"state" gorm:"column:state"`
Postcode string `json:"postcode" gorm:"column:postcode"`
Latitude string `json:"latitude" gorm:"column:latitude"`
Longitude string `json:"longitude" gorm:"column:longitude"`
Status int `json:"status" gorm:"column:status"`
}
func (CustomerLocation) TableName() string {
return "customerlocations"
}
// AppLocation represents the pre-existing 'applocations' table
type AppLocation struct {
Applocationid int `json:"applocationid" gorm:"primaryKey;column:applocationid"`
Applocationname string `json:"applocationname" gorm:"column:applocationname"`
Status string `json:"status" gorm:"column:status"`
}
func (AppLocation) TableName() string {
return "applocations"
}

49
models/redis.go Normal file
View File

@@ -0,0 +1,49 @@
package models
type MilerLog struct {
UserID int `json:"userid"`
Username string `json:"username"`
LogDate string `json:"logdate"`
Latitude string `json:"latitude"`
Longitude string `json:"longitude"`
Speed string `json:"speed"`
Heading string `json:"heading"`
Accuracy string `json:"accuracy"`
Status string `json:"status"`
OrderID string `json:"orderid"`
Battery string `json:"battery"`
IsCharging bool `json:"is_charging"`
Connection string `json:"connection"`
LocationService string `json:"location_service"`
IsBackground bool `json:"is_background"`
}
type MilerStatus struct {
UserID int `json:"userid"`
Status string `json:"status"`
}
type ConsignmentLog struct {
ConsignmentID int `json:"consignmentid"`
UserID int `json:"userid"`
LogDate string `json:"logdate"`
Latitude string `json:"latitude"`
Longitude string `json:"longitude"`
Speed string `json:"speed"`
Heading string `json:"heading"`
Status string `json:"status"`
Remarks string `json:"remarks"`
Battery string `json:"battery"`
IsBackground bool `json:"is_background"`
}
type CachedUser struct {
UserID int `json:"userid"`
Username string `json:"username"`
FirstName string `json:"firstname"`
LastName string `json:"lastname"`
ContactNo string `json:"contactno"`
UserFCMToken string `json:"userfcmtoken"`
AppVersion string `json:"app_version"`
DeviceInfo string `json:"device_info"`
}

62
models/transit.go Normal file
View File

@@ -0,0 +1,62 @@
package models
import (
"time"
)
type Tripsheet struct {
Tripsheetid int `json:"tripsheetid" gorm:"primaryKey;column:tripsheetid"`
Tripsheetno string `json:"tripsheetno" gorm:"column:tripsheetno;unique;not null"`
Sourcehubid int `json:"sourcehubid" gorm:"column:sourcehubid;not null"`
Destinationhubid int `json:"destinationhubid" gorm:"column:destinationhubid;not null"`
Vehicleid *int `json:"vehicleid" gorm:"column:vehicleid"`
Driveruserid *int `json:"driveruserid" gorm:"column:driveruserid"`
Dispatchtime *time.Time `json:"dispatchtime" gorm:"column:dispatchtime"`
Arrivaltime *time.Time `json:"arrivaltime" gorm:"column:arrivaltime"`
Status string `json:"status" gorm:"column:status;default:Draft"` // Draft, Dispatched, Arrived, Cancelled
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
Createdby int `json:"createdby" gorm:"column:createdby"`
Updatedby int `json:"updatedby" gorm:"column:updatedby"`
Deletedat *time.Time `json:"deletedat,omitempty" gorm:"column:deletedat"`
}
func (Tripsheet) TableName() string {
return "tripsheets"
}
type TripsheetItem struct {
Tripsheetitemid int `json:"tripsheetitemid" gorm:"primaryKey;column:tripsheetitemid"`
Tripsheetid int `json:"tripsheetid" gorm:"column:tripsheetid;not null"`
Consignmentid int `json:"consignmentid" gorm:"column:consignmentid;not null"`
Scanstatus string `json:"scanstatus" gorm:"column:scanstatus;default:Pending"` // Pending, Loaded, Unloaded, Discrepancy
Scannedat *time.Time `json:"scannedat" gorm:"column:scannedat"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
Createdby int `json:"createdby" gorm:"column:createdby"`
Updatedby int `json:"updatedby" gorm:"column:updatedby"`
Deletedat *time.Time `json:"deletedat,omitempty" gorm:"column:deletedat"`
}
func (TripsheetItem) TableName() string {
return "tripsheetitems"
}
type DeliveryProof struct {
Proofid int `json:"proofid" gorm:"primaryKey;column:proofid"`
Consignmentid int `json:"consignmentid" gorm:"column:consignmentid;unique;not null"`
Tripsheetid *int `json:"tripsheetid" gorm:"column:tripsheetid"`
Deliveredat time.Time `json:"deliveredat" gorm:"column:deliveredat;not null"`
Deliveredtoname string `json:"deliveredtoname" gorm:"column:deliveredtoname;not null"`
Receiversignatureurl string `json:"receiversignatureurl" gorm:"column:receiversignatureurl"`
Photourl string `json:"photourl" gorm:"column:photourl"`
Otpverified bool `json:"otpverified" gorm:"column:otpverified;default:false"`
Geolatitude float64 `json:"geolatitude" gorm:"column:geolatitude"`
Geolongitude float64 `json:"geolongitude" gorm:"column:geolongitude"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Createdby int `json:"createdby" gorm:"column:createdby"`
}
func (DeliveryProof) TableName() string {
return "deliveryproofs"
}

171
models/users.go Normal file
View File

@@ -0,0 +1,171 @@
package models
import (
"time"
)
type PartnerInfo struct {
Partnerid int `json:"partnerid" gorm:"primaryKey;column:partnerid"`
Partnername string `json:"partnername" gorm:"column:partnername;not null"`
Partnertypeid int `json:"partnertypeid" gorm:"column:partnertypeid"`
Contactno string `json:"contactno" gorm:"column:contactno"`
Status string `json:"status" gorm:"column:status;default:Active"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
}
func (PartnerInfo) TableName() string {
return "partnerinfo"
}
type Hub struct {
Hubid int `json:"hubid" gorm:"primaryKey;column:hubid"`
Hubname string `json:"hubname" gorm:"column:hubname;not null"`
Hubtype string `json:"hubtype" gorm:"column:hubtype;not null"` // sorting_center, delivery_hub
Applocationid int `json:"applocationid" gorm:"column:applocationid"`
Contactno string `json:"contactno" gorm:"column:contactno"`
Address string `json:"address" gorm:"column:address"`
Latitude float64 `json:"latitude" gorm:"column:latitude"`
Longitude float64 `json:"longitude" gorm:"column:longitude"`
Pincode string `json:"pincode" gorm:"column:pincode"`
Status string `json:"status" gorm:"column:status;default:Active"` // Active, InActive
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
Createdby int `json:"createdby" gorm:"column:createdby"`
Updatedby int `json:"updatedby" gorm:"column:updatedby"`
Deletedat *time.Time `json:"deletedat,omitempty" gorm:"column:deletedat"`
}
func (Hub) TableName() string {
return "hubs"
}
type Vehicle struct {
Vehicleid int `json:"vehicleid" gorm:"primaryKey;column:vehicleid"`
Vehicleno string `json:"vehicleno" gorm:"primaryKey;column:vehicleno;unique;not null"`
Vehicletype string `json:"vehicletype" gorm:"column:vehicletype;not null"`
Maxweight float64 `json:"maxweight" gorm:"column:maxweight;not null"`
Maxvolume float64 `json:"maxvolume" gorm:"column:maxvolume;not null"`
Partnerid *int `json:"partnerid" gorm:"column:partnerid"`
Batterypercentage int `json:"batterypercentage" gorm:"column:batterypercentage"`
Status string `json:"status" gorm:"column:status;default:Available"` // Available, In_Transit, Maintenance, InActive
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
Createdby int `json:"createdby" gorm:"column:createdby"`
Updatedby int `json:"updatedby" gorm:"column:updatedby"`
Deletedat *time.Time `json:"deletedat,omitempty" gorm:"column:deletedat"`
}
func (Vehicle) TableName() string {
return "vehicles"
}
type AppUser struct {
Userid int `json:"userid" gorm:"primaryKey;column:userid"`
Authname string `json:"authname" gorm:"column:authname;not null"`
Email string `json:"email" gorm:"column:email;unique;not null"`
Contactno string `json:"contactno" gorm:"column:contactno;not null"`
Password string `json:"-" gorm:"column:password;not null"`
Roleid int `json:"roleid" gorm:"column:roleid;not null"`
Hubid *int `json:"hubid" gorm:"column:hubid"`
Applocationid int `json:"applocationid" gorm:"column:applocationid"`
Partnerid *int `json:"partnerid" gorm:"column:partnerid"`
Tenantid int `json:"tenantid" gorm:"column:tenantid"`
Configid int `json:"configid" gorm:"column:configid;default:1"`
Onduty int `json:"onduty" gorm:"column:onduty;default:0"`
Status string `json:"status" gorm:"column:status;default:Active"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
}
func (AppUser) TableName() string {
return "appusers"
}
type MilerProfile struct {
Milerprofileid int `json:"milerprofileid" gorm:"primaryKey;column:milerprofileid"`
Userid int `json:"userid" gorm:"column:userid;unique;not null"`
Applocationid int `json:"applocationid" gorm:"column:applocationid;default:1"`
Displayname string `json:"displayname" gorm:"column:displayname;not null"`
Phone string `json:"phone" gorm:"column:phone;not null"`
Profilephotourl string `json:"profilephotourl" gorm:"column:profilephotourl"`
Vehicleid *int `json:"vehicleid" gorm:"column:vehicleid"`
Defaultvehicletype string `json:"defaultvehicletype" gorm:"column:defaultvehicletype"`
Currentlatitude float64 `json:"currentlatitude" gorm:"column:currentlatitude"`
Currentlongitude float64 `json:"currentlongitude" gorm:"column:currentlongitude"`
Currentpincode string `json:"currentpincode" gorm:"column:currentpincode"`
Availabilitystatus string `json:"availabilitystatus" gorm:"column:availabilitystatus;default:Offline"` // Offline, Available, Assigned, On_Pickup, At_Customer, Picked_Up, On_Delivery, Break, Blocked
Rating float64 `json:"rating" gorm:"column:rating;default:5.00"`
Totalcompletedpickups int `json:"totalcompletedpickups" gorm:"column:totalcompletedpickups;default:0"`
Totalcancelledpickups int `json:"totalcancelledpickups" gorm:"column:totalcancelledpickups;default:0"`
Lastlocationupdatedat *time.Time `json:"lastlocationupdatedat" gorm:"column:lastlocationupdatedat"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
}
func (MilerProfile) TableName() string {
return "milerprofiles"
}
type AppCustomer struct {
Appcustomerid int `json:"appcustomerid" gorm:"primaryKey;column:appcustomerid"`
Firstname string `json:"firstname" gorm:"column:firstname;not null"`
Lastname string `json:"lastname" gorm:"column:lastname"`
Phone string `json:"phone" gorm:"column:phone;unique;not null"`
Email string `json:"email" gorm:"column:email"`
Loginpinhash string `json:"-" gorm:"column:loginpinhash"`
Defaultlatitude float64 `json:"defaultlatitude" gorm:"column:defaultlatitude"`
Defaultlongitude float64 `json:"defaultlongitude" gorm:"column:defaultlongitude"`
Defaultpincode string `json:"defaultpincode" gorm:"column:defaultpincode"`
Status string `json:"status" gorm:"column:status;default:Active"` // Active, Blocked, Deleted
Configid int `json:"configid" gorm:"column:configid;default:1"`
Lastloginat *time.Time `json:"lastloginat" gorm:"column:lastloginat"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
}
func (AppCustomer) TableName() string {
return "appcustomers"
}
type AppCustomerLocation struct {
Appcustomerlocationid int `json:"appcustomerlocationid" gorm:"primaryKey;column:appcustomerlocationid"`
Appcustomerid int `json:"appcustomerid" gorm:"column:appcustomerid"`
Label string `json:"label" gorm:"column:label;default:Home"`
Receivername string `json:"receivername" gorm:"column:receivername"`
Receiverphone string `json:"receiverphone" gorm:"column:receiverphone"`
Address string `json:"address" gorm:"column:address;not null"`
Landmark string `json:"landmark" gorm:"column:landmark"`
City string `json:"city" gorm:"column:city"`
State string `json:"state" gorm:"column:state"`
Pincode string `json:"pincode" gorm:"column:pincode;not null"`
Latitude float64 `json:"latitude" gorm:"column:latitude;not null"`
Longitude float64 `json:"longitude" gorm:"column:longitude;not null"`
Isdefault bool `json:"isdefault" gorm:"column:isdefault;default:false"`
Status string `json:"status" gorm:"column:status;default:Active"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
}
func (AppCustomerLocation) TableName() string {
return "appcustomerlocations"
}
type TenantLocation struct {
Tenantlocationid int `json:"tenantlocationid" gorm:"primaryKey;column:tenantlocationid"`
Tenantid int `json:"tenantid" gorm:"column:tenantid;not null"`
Address string `json:"address" gorm:"column:address;not null"`
City string `json:"city" gorm:"column:city;not null"`
State string `json:"state" gorm:"column:state;not null"`
Pincode string `json:"pincode" gorm:"column:pincode;not null"`
Latitude float64 `json:"latitude" gorm:"column:latitude;not null"`
Longitude float64 `json:"longitude" gorm:"column:longitude;not null"`
Isprimary bool `json:"isprimary" gorm:"column:isprimary;default:false"`
Status string `json:"status" gorm:"column:status;default:Active"`
Createdat time.Time `json:"createdat" gorm:"column:createdat;default:CURRENT_TIMESTAMP"`
Updatedat time.Time `json:"updatedat" gorm:"column:updatedat;default:CURRENT_TIMESTAMP"`
}
func (TenantLocation) TableName() string {
return "tenantlocations"
}