This commit is contained in:
Hamza-Ayed
2024-05-10 14:53:16 +03:00
parent c5ac5c2b22
commit 4192c1e471
9 changed files with 166 additions and 77 deletions

View File

@@ -215,6 +215,7 @@ class MapPassengerController extends GetxController {
late double totalCostPassenger = 0;
late double totalPassengerComfort = 0;
late double totalPassengerComfortDiscount = 0;
late double totalPassengerLadyDiscount = 0;
late double totalPassengerSpeedDiscount = 0;
late double totalPassengerMotoDelivery = 0;
late double totalDriver = 0;
@@ -1215,14 +1216,24 @@ class MapPassengerController extends GetxController {
carsLocationByPassenger = [];
LatLngBounds bounds = calculateBounds(
passengerLocation.latitude, passengerLocation.longitude, 7000);
var res =
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {
'southwestLat': bounds.southwest.latitude.toString(),
'southwestLon': bounds.southwest.longitude.toString(),
'northeastLat': bounds.northeast.latitude.toString(),
'northeastLon': bounds.northeast.longitude.toString(),
});
var res;
if (box.read(BoxName.carType) == 'Lady') {
res = await CRUD()
.get(link: AppLink.getFemalDriverLocationByPassenger, payload: {
'southwestLat': bounds.southwest.latitude.toString(),
'southwestLon': bounds.southwest.longitude.toString(),
'northeastLat': bounds.northeast.latitude.toString(),
'northeastLon': bounds.northeast.longitude.toString(),
});
} else {
res = await CRUD()
.get(link: AppLink.getCarsLocationByPassenger, payload: {
'southwestLat': bounds.southwest.latitude.toString(),
'southwestLon': bounds.southwest.longitude.toString(),
'northeastLat': bounds.northeast.latitude.toString(),
'northeastLon': bounds.northeast.longitude.toString(),
});
}
if (res == 'failure') {
noCarString = true;
dataCarsLocationByPassenger = res;
@@ -2358,6 +2369,7 @@ class MapPassengerController extends GetxController {
double costForDriver = 0;
double totalPassengerSpeed = 0;
double totalPassengerLady = 0;
Future bottomSheet() async {
if (data.isNotEmpty) {
durationToAdd = Duration(seconds: durationToRide);
@@ -2374,7 +2386,7 @@ class MapPassengerController extends GetxController {
print('costDistance----- $costDistance');
print(
'passengerWalletTotal----- ${box.read(BoxName.passengerWalletTotal)}');
double costComfort, costSpeed, costDelivery, costMashwari = 0;
double costComfort, costSpeed, costDelivery, costMashwari, costLady = 0;
update();
if (currentTime.hour >= 22 && currentTime.hour < 5) {
// costDistance = distance * latePrice;
@@ -2382,6 +2394,7 @@ class MapPassengerController extends GetxController {
costMashwari = (distance * mashwariPrice) + costDuration * latePrice;
costSpeed = (distance * speedPrice) + costDuration * latePrice;
costDelivery = (distance * deliveryPrice) + costDuration * latePrice;
costLady = (distance * comfortPrice + 2) + costDuration * latePrice;
update();
} else if (currentTime.hour >= 13 && currentTime.hour <= 16) {
@@ -2391,6 +2404,7 @@ class MapPassengerController extends GetxController {
costMashwari = (distance * mashwariPrice) + costDuration * heavyPrice;
costSpeed = (distance * speedPrice) + costDuration * heavyPrice;
costDelivery = (distance * deliveryPrice) + costDuration * heavyPrice;
costLady = (distance * comfortPrice + 2) + costDuration * heavyPrice;
update();
// } /
@@ -2400,6 +2414,7 @@ class MapPassengerController extends GetxController {
costMashwari = (distance * mashwariPrice) + costDuration;
costSpeed = (distance * speedPrice) + costDuration;
costDelivery = (distance * deliveryPrice) + costDuration;
costLady = (distance * comfortPrice + 2) + costDuration;
update();
}
//print('cost $cost');
@@ -2409,14 +2424,23 @@ class MapPassengerController extends GetxController {
totalPassenger = costSpeed + (costSpeed * kazan / 100);
totalPassengerComfort =
(costComfort + (costComfort * kazan / 100)).ceilToDouble();
totalPassengerLady = (costLady + (costLady * kazan / 100)).ceilToDouble();
totalPassengerSpeed =
(costSpeed + (costSpeed * kazan / 100)).ceilToDouble();
totalPassengerComfortDiscount =
totalPassengerComfort + totalPassengerComfort * (kazan - 0) / 100;
totalPassengerLadyDiscount =
totalPassengerLady + totalPassengerLady * (kazan - 0) / 100;
totalPassengerSpeedDiscount =
totalPassengerSpeed + totalPassengerSpeed * (kazan - 2) / 100;
totalPassengerMotoDelivery =
(costDelivery + (costDelivery * kazan / 100)).ceilToDouble();
totalPassengerComfort = totalPassengerComfortDiscount -
(totalPassengerComfortDiscount * kazan / 100);
totalPassengerSpeed = totalPassengerSpeedDiscount -
(totalPassengerSpeedDiscount * kazan / 100);
totalPassengerLady = totalPassengerLadyDiscount -
(totalPassengerLadyDiscount * kazan / 100);
totalDriver = totalDriver1 + (totalDriver1 * kazan / 100);
tax = totalCostPassenger * kazan / 100;
totalME = totalCostPassenger - tax;