From 9412ed0e06c92b869dfb81f52329d22df5caede5 Mon Sep 17 00:00:00 2001 From: Hamza Aleghwairyeen Date: Fri, 12 Apr 2024 16:32:18 +0300 Subject: [PATCH] 4/11/11 --- .../home/map_passenger_controller.dart | 54 +++++++++++++------ 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index a01dc65..cb1a01d 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -2319,26 +2319,38 @@ class MapPassengerController extends GetxController { DateTime currentTime = DateTime.now(); newTime = currentTime.add(durationToAdd); averageDuration = (durationToRide / 60) / distance; - costDuration = (durationToRide / 60) * averageDuration * 0.016; + // costDuration = (durationToRide / 60) * averageDuration * 0.016; + costDuration = (durationToRide / 60).floorToDouble(); print('costDuration----- $costDuration'); print('costDistance----- $costDistance'); print( 'passengerWalletTotal----- ${box.read(BoxName.passengerWalletTotal)}'); - + double costComfort, costSpeed, costDelivery, costMashwari = 0; update(); if (currentTime.hour >= 22 && currentTime.hour < 5) { - costDistance = distance * latePrice; + // costDistance = distance * latePrice; + costComfort = (distance * comfortPrice) + costDuration * latePrice; + costMashwari = (distance * mashwariPrice) + costDuration * latePrice; + costSpeed = (distance * speedPrice) + costDuration * latePrice; + costDelivery = (distance * deliveryPrice) + costDuration * latePrice; + update(); } else if (currentTime.hour >= 13 && currentTime.hour <= 16) { - if (averageDuration > 2.5) { - costDistance = distance * heavyPrice; - update(); - } else { - costDistance = distance * naturePrice; - update(); - } + // if (averageDuration > 2.5) { + // costDistance = distance * heavyPrice; + costComfort = (distance * comfortPrice) + costDuration * heavyPrice; + costMashwari = (distance * mashwariPrice) + costDuration * heavyPrice; + costSpeed = (distance * speedPrice) + costDuration * heavyPrice; + costDelivery = (distance * deliveryPrice) + costDuration * heavyPrice; + + update(); + // } / } else { - costDistance = distance * (naturePrice - .1); + // costDistance = distance * (naturePrice - .1); + costComfort = (distance * comfortPrice) + costDuration; + costMashwari = (distance * mashwariPrice) + costDuration; + costSpeed = (distance * speedPrice) + costDuration; + costDelivery = (distance * deliveryPrice) + costDuration; update(); } //print('cost $cost'); @@ -2353,16 +2365,16 @@ class MapPassengerController extends GetxController { // } var totalDriver1 = costDistance + costDuration; totalCostPassenger = totalDriver1 + (totalDriver1 * kazan / 100); - totalPassenger = totalCostPassenger; - totalPassengerComfort = totalCostPassenger + (totalCostPassenger * .2); + totalPassenger = costSpeed + (costSpeed * kazan / 100); + totalPassengerComfort = costComfort + (costComfort * kazan / 100); + // totalPassengerComfort = totalCostPassenger + (totalCostPassenger * .2); totalPassengerComfortDiscount = totalPassengerComfort + totalPassengerComfort * (kazan - 4) / 100; - totalPassengerMotoDelivery = - totalCostPassenger - (totalCostPassenger * .35); + totalPassengerMotoDelivery = costDelivery + (costDelivery * kazan / 100); totalDriver = totalDriver1 + (totalDriver1 * kazan / 100); tax = totalCostPassenger * kazan / 100; totalME = totalCostPassenger - tax; - costForDriver = fuelPrice * 12; + costForDriver = fuelPrice * (20 / 210) * distance; if (totalCostPassenger < 20) { // for eygpt 20 le open ride @@ -2477,6 +2489,10 @@ class MapPassengerController extends GetxController { } double passengerRate = 5; + double comfortPrice = 8; + double speedPrice = 4; + double mashwariPrice = 4; + double deliveryPrice = 1.2; getKazanPercent() async { var res = await CRUD().get( link: AppLink.getKazanPercent, @@ -2489,6 +2505,12 @@ class MapPassengerController extends GetxController { heavyPrice = double.parse(jsonDecode(res)['message'][0]['heavyPrice']); latePrice = double.parse(jsonDecode(res)['message'][0]['latePrice']); fuelPrice = double.parse(jsonDecode(res)['message'][0]['fuelPrice']); + comfortPrice = + double.parse(jsonDecode(res)['message'][0]['comfortPrice']); + speedPrice = double.parse(jsonDecode(res)['message'][0]['speedPrice']); + mashwariPrice = double.parse(jsonDecode(res)['message'][0]['freePrice']); + deliveryPrice = + double.parse(jsonDecode(res)['message'][0]['deliveryPrice']); } }