fixed price cities
This commit is contained in:
parent
a98e839248
commit
b422c8adc3
|
@ -5,6 +5,7 @@ import (
|
|||
"slices"
|
||||
|
||||
"github.com/manterfield/go-mapreader"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type PFM63PricingService struct{}
|
||||
|
@ -23,6 +24,10 @@ func (s *PFM63PricingService) Prices(vars map[string]any) (map[string]Price, err
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("passenger_priority parameter not found : %v", err)
|
||||
}
|
||||
ret, err := mapreader.BoolErr(vars, "return")
|
||||
if err != nil {
|
||||
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("passenger_history parameter not found : %v", err)
|
||||
|
@ -31,6 +36,10 @@ func (s *PFM63PricingService) Prices(vars map[string]any) (map[string]Price, err
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("destination_locality parameter not found : %v", err)
|
||||
}
|
||||
// passenger_locality, err := mapreader.StrErr(vars, "passenger.locality")
|
||||
// if err != nil {
|
||||
// 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("driver_distance parameter not found : %v", err)
|
||||
|
@ -41,13 +50,18 @@ func (s *PFM63PricingService) Prices(vars map[string]any) (map[string]Price, err
|
|||
}
|
||||
|
||||
pricing := 0.0
|
||||
log.Debug().Str("destination loc", destination_locality).Msg("debuf pricing")
|
||||
|
||||
if passenger_history == 0 {
|
||||
pricing = 0
|
||||
} else if passenger_priority && passenger_distance <= 5 {
|
||||
pricing = 0
|
||||
} else if slices.Contains([]string{"Clermont-Ferrand", "Ussel", "Aubusson", "Riom"}, destination_locality) {
|
||||
pricing = 5
|
||||
if ret {
|
||||
pricing = 10
|
||||
} else {
|
||||
pricing = 5
|
||||
}
|
||||
} else if passenger_distance < 15 {
|
||||
pricing = 2
|
||||
} else if passenger_distance < 30 {
|
||||
|
|
Loading…
Reference in New Issue