This commit is contained in:
Hamza Aleghwairyeen
2024-04-07 23:59:49 +03:00
parent 5d9538f744
commit 6a4a549211
48 changed files with 129 additions and 70 deletions

View File

@@ -28,7 +28,7 @@ class HomeCaptainController extends GetxController {
late double kazan;
double latePrice = 0;
double heavyPrice = 0;
double comfortPrice = 0, speedPrice = 0, deliveryPrice = 0, freePrice = 0;
double comfortPrice = 0, speedPrice = 0, deliveryPrice = 0, mashwariPrice = 0;
double naturePrice = 0;
bool isCallOn = false;
String totalMoneyToday = '0';
@@ -255,7 +255,7 @@ class HomeCaptainController extends GetxController {
speedPrice = double.parse(jsonDecode(res)['message'][0]['speedPrice']);
deliveryPrice =
double.parse(jsonDecode(res)['message'][0]['deliveryPrice']);
freePrice = double.parse(jsonDecode(res)['message'][0]['freePrice']);
mashwariPrice = double.parse(jsonDecode(res)['message'][0]['freePrice']);
}
}

View File

@@ -298,30 +298,12 @@ class MapDriverController extends GetxController {
'rideTimeStart': DateTime.now().toString(),
'status': 'Begin',
});
await CRUD().post(link: AppLink.addDriverpayment, payload: {
'rideId': rideId,
'amount': paymentAmount,
'payment_method': paymentMethod,
'passengerID': passengerId,
'driverID': box.read(BoxName.driverID).toString(),
});
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
rideIsBeginPassengerTimer();
double pointsSubstraction = 0;
pointsSubstraction = double.parse(paymentAmount) *
(-1) *
double.parse(kazan) /
100; // for eygpt /100
var res =
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
'paymentID': 'rideId$rideId',
'amount': (pointsSubstraction).toString(),
'paymentMethod': paymentMethod,
'driverID': box.read(BoxName.driverID).toString(),
});
var d = jsonDecode(res);
// var d = jsonDecode(res);
update();
// Start updating location and moving camera
@@ -443,7 +425,7 @@ class MapDriverController extends GetxController {
isRideFinished = true;
isRideStarted = false;
isPriceWindow = false;
totalCost = carType == 'Comfort' || carType == 'Free Ride'
totalCost = carType == 'Comfort' || carType == 'Mashwari'
? price.toStringAsFixed(1)
: totalPassenger;
paymentAmount = totalCost;
@@ -461,6 +443,13 @@ class MapDriverController extends GetxController {
'balance': ((-1) * double.parse(paymentAmount)).toString()
});
}
await CRUD().post(link: AppLink.addDriverpayment, payload: {
'rideId': rideId,
'amount': paymentAmount,
'payment_method': paymentMethod,
'passengerID': passengerId,
'driverID': box.read(BoxName.driverID).toString(),
});
print('passengerWalletBurc bef ${double.parse(passengerWalletBurc)}');
if (double.parse(passengerWalletBurc) < 0) {
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
@@ -469,11 +458,22 @@ class MapDriverController extends GetxController {
});
print('passengerWalletBurc aft ${double.parse(passengerWalletBurc)}');
}
double pointsSubstraction = 0;
pointsSubstraction = double.parse(paymentAmount) *
(-1) *
double.parse(kazan) /
100; // for eygpt /100
var res = await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
'paymentID': 'rideId$rideId',
'amount': (pointsSubstraction).toString(),
'paymentMethod': paymentMethod,
'driverID': box.read(BoxName.driverID).toString(),
});
Future.delayed(const Duration(milliseconds: 300));
FirebaseMessagesController().sendNotificationToPassengerToken(
'Driver Finish Trip',
'you will pay to Driver'.tr +
' ${carType == 'Comfort' || carType == 'Free Ride' ? price.toStringAsFixed(1) : totalPassenger} \$'
' ${carType == 'Comfort' || carType == 'Mashwari' ? price.toStringAsFixed(2) : totalPassenger} \$'
.tr,
tokenPassenger,
[
@@ -597,7 +597,7 @@ class MapDriverController extends GetxController {
: (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>()
.freePrice); // $1 for each minute + $4 for each km
.mashwariPrice); // $1 for each minute + $4 for each km
price = (price * .10) + price; // Add 10% tax
speed = Get.find<LocationController>().speed * 3.6;
progressTimerRideBegin = i / durationOfRide;