Fix 9 backend bugs: pricing, zones, geocoding, device tokens, assignment retry
- pricingid null: lookupDoormilePrice now returns matched rule ID; wired to BookingServiceOption.Pricingid - Zone rename: Interstate→Regional, OtherState→National throughout (code + DB migrated) - Zone from pincodes: CheckPrice now accepts pickup_pincode+delivery_pincode and auto-resolves zone - Delivery geocoding: pincodeToLatLon() maps 3-digit prefix to city coords when lat/lon are 0 - Device tokens: device_token field added to PinVerify DTOs; saved on both customer and miler login - Assignment retry: RejectMilerAssignment now re-triggers AssignCustomerMiler/AssignCRMMiler immediately - Provider empty B2C: defaults to Doormile when no pricing provider row matches - City gate 422→400: StatusUnprocessableEntity corrected to StatusBadRequest - Miler GPS 0,0: WS tracking falls back to MilerProfile DB coords when Redis key is expired Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -151,6 +151,9 @@ func VerifyCustomerPin(cfg *config.Config) fiber.Handler {
|
||||
|
||||
now := time.Now()
|
||||
customer.Lastloginat = &now
|
||||
if req.DeviceToken != "" {
|
||||
customer.Devicetoken = req.DeviceToken
|
||||
}
|
||||
db.DB.Save(&customer)
|
||||
|
||||
token, err := utils.GenerateToken(customer.Appcustomerid, customer.Phone, 9, 0, customer.Configid, cfg.JWTSecret)
|
||||
@@ -394,6 +397,14 @@ func CreateCustomerBooking(c *fiber.Ctx) error {
|
||||
return utils.BadRequest(c, "at least one parcel is required")
|
||||
}
|
||||
|
||||
// Geocode delivery pincode to lat/lon when the app doesn't supply coordinates.
|
||||
if req.Deliverylatitude == 0 && req.Deliverylongitude == 0 && req.Deliverypincode != "" {
|
||||
if lat, lon, ok := pincodeToLatLon(req.Deliverypincode); ok {
|
||||
req.Deliverylatitude = lat
|
||||
req.Deliverylongitude = lon
|
||||
}
|
||||
}
|
||||
|
||||
tx := db.DB.Begin()
|
||||
|
||||
booking := models.PickupBooking{
|
||||
@@ -464,8 +475,10 @@ func CreateCustomerBooking(c *fiber.Ctx) error {
|
||||
itemCategory := normalizePricingCategory(req.Parcels[0].Itemcategory)
|
||||
|
||||
var estimatedPrice float64
|
||||
if price, found := lookupDoormilePrice(zone, mapServiceTypeToPricing(serviceType), totalWeight, itemCategory); found {
|
||||
var pricingID *int
|
||||
if price, pid, found := lookupDoormilePrice(zone, mapServiceTypeToPricing(serviceType), totalWeight, itemCategory); found {
|
||||
estimatedPrice = price
|
||||
pricingID = pid
|
||||
} else {
|
||||
var distance float64
|
||||
if booking.Deliverylatitude != 0 && booking.Deliverylongitude != 0 {
|
||||
@@ -489,6 +502,7 @@ func CreateCustomerBooking(c *fiber.Ctx) error {
|
||||
Bookingid: booking.Bookingid,
|
||||
Servicetype: serviceType,
|
||||
Estimatedprice: estimatedPrice,
|
||||
Pricingid: pricingID,
|
||||
Estimateddeliveryat: &estDelivery,
|
||||
Sladueat: &slaDue,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user