PFM63
This commit is contained in:
parent
90abfe05b2
commit
a98e839248
|
@ -14,29 +14,30 @@ func NewPFM63PricingService() (*PFM63PricingService, error) {
|
|||
}
|
||||
|
||||
func (s *PFM63PricingService) Prices(vars map[string]any) (map[string]Price, error) {
|
||||
journey_type, err := mapreader.StrErr(vars, "journet_type")
|
||||
journey_type, err := mapreader.StrErr(vars, "journey_type")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parameter not found : %v", err)
|
||||
return nil, fmt.Errorf("journey_type parameter not found : %v", err)
|
||||
}
|
||||
fmt.Println(journey_type)
|
||||
passenger_priority, err := mapreader.BoolErr(vars, "passenger.priority")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parameter not found : %v", err)
|
||||
return nil, fmt.Errorf("passenger_priority parameter not found : %v", err)
|
||||
}
|
||||
passenger_history, err := mapreader.IntErr(vars, "passenger.history")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parameter not found : %v", err)
|
||||
return nil, fmt.Errorf("passenger_history parameter not found : %v", err)
|
||||
}
|
||||
destination_postcode, err := mapreader.StrErr(vars, "journey.passenger_drop.properties.postcode")
|
||||
destination_locality, err := mapreader.StrErr(vars, "journey.passenger_drop.properties.locality")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parameter not found : %v", err)
|
||||
return nil, fmt.Errorf("destination_locality parameter not found : %v", err)
|
||||
}
|
||||
driver_distance, err := mapreader.IntErr(vars, "journey.driver_distance")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parameter not found : %v", err)
|
||||
return nil, fmt.Errorf("driver_distance parameter not found : %v", err)
|
||||
}
|
||||
passenger_distance, err := mapreader.IntErr(vars, "journey.passenger_distance")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parameter not found : %v", err)
|
||||
return nil, fmt.Errorf("passenger_distance parameter not found : %v", err)
|
||||
}
|
||||
|
||||
pricing := 0.0
|
||||
|
@ -45,7 +46,7 @@ func (s *PFM63PricingService) Prices(vars map[string]any) (map[string]Price, err
|
|||
pricing = 0
|
||||
} else if passenger_priority && passenger_distance <= 5 {
|
||||
pricing = 0
|
||||
} else if slices.Contains([]string{"15300", "63000", "63100", "63200", "63015"}, destination_postcode) {
|
||||
} else if slices.Contains([]string{"Clermont-Ferrand", "Ussel", "Aubusson", "Riom"}, destination_locality) {
|
||||
pricing = 5
|
||||
} else if passenger_distance < 15 {
|
||||
pricing = 2
|
||||
|
@ -67,6 +68,8 @@ func (s *PFM63PricingService) Prices(vars map[string]any) (map[string]Price, err
|
|||
pricing = 17
|
||||
}
|
||||
|
||||
fmt.Println(pricing)
|
||||
|
||||
kmCompensation := 0.2
|
||||
if journey_type == "carpool" {
|
||||
kmCompensation = 0.09
|
||||
|
|
Loading…
Reference in New Issue