6/15/1
This commit is contained in:
@@ -878,23 +878,9 @@ class MapDriverController extends GetxController {
|
||||
startNameLocation = Get.arguments['startNameLocation'];
|
||||
endNameLocation = Get.arguments['endNameLocation'];
|
||||
|
||||
// var coords = passengerLocation.toString().split(',');
|
||||
// var coordDestination = passengerDestination.toString().split(',');
|
||||
|
||||
// Parse to double
|
||||
latlng(passengerLocation, passengerDestination);
|
||||
// double latPassengerLocation =
|
||||
// double.parse(passengerLocation.toString().split(',')[0]);
|
||||
// double lngPassengerLocation =
|
||||
// double.parse(passengerLocation.toString().split(',')[1]);
|
||||
// double latPassengerDestination =
|
||||
// double.parse(passengerDestination.toString().split(',')[0]);
|
||||
// double lngPassengerDestination =
|
||||
// double.parse(passengerDestination.toString().split(',')[1]);
|
||||
// latLngPassengerLocation =
|
||||
// LatLng(latPassengerLocation, lngPassengerLocation);
|
||||
// latLngPassengerDestination =
|
||||
// LatLng(latPassengerDestination, lngPassengerDestination);
|
||||
|
||||
String lat = Get.find<LocationController>().myLocation.latitude.toString();
|
||||
String lng = Get.find<LocationController>().myLocation.longitude.toString();
|
||||
String origin = '$lat,$lng';
|
||||
|
||||
@@ -60,6 +60,7 @@ class OrderRequestController extends GetxController {
|
||||
countRefuse = results[0]['count'].toString();
|
||||
update();
|
||||
if (int.parse(countRefuse) > 3) {
|
||||
box.write(BoxName.statusDriverLocation, 'on');
|
||||
locationController.stopLocationUpdates();
|
||||
Get.defaultDialog(
|
||||
// backgroundColor: CupertinoColors.destructiveRed,
|
||||
@@ -73,6 +74,8 @@ class OrderRequestController extends GetxController {
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok , See you Tomorrow'.tr,
|
||||
onPressed: () => Get.back()));
|
||||
} else {
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error executing custom query: $e');
|
||||
@@ -142,7 +145,7 @@ class OrderRequestController extends GetxController {
|
||||
});
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': orderID,
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
// 'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
@@ -154,7 +157,7 @@ class OrderRequestController extends GetxController {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
}, TableName.driverOrdersRefuse);
|
||||
getRefusedOrderByCaptain();
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
|
||||
update();
|
||||
Get.back();
|
||||
// Get.offAll(HomeCaptain());
|
||||
|
||||
@@ -1,365 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
||||
|
||||
import '../../../constant/api_key.dart';
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
import 'home_captain_controller.dart';
|
||||
|
||||
class SpeedMapController extends GetxController {
|
||||
bool isLoading = true;
|
||||
final formKey1 = GlobalKey<FormState>();
|
||||
final sosEmergincyNumberCotroller = TextEditingController();
|
||||
List data = [];
|
||||
List dataDestination = [];
|
||||
LatLngBounds? boundsData;
|
||||
double mpg = 0;
|
||||
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor passengerIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor startIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor endIcon = BitmapDescriptor.defaultMarker;
|
||||
final List<LatLng> polylineCoordinates = [];
|
||||
final List<LatLng> polylineCoordinatesDestination = [];
|
||||
List<Polyline> polyLines = [];
|
||||
List<Polyline> polyLinesDestination = [];
|
||||
Set<Marker> markers = {};
|
||||
late String passengerLocation;
|
||||
late String passengerDestination;
|
||||
late String step0;
|
||||
late String step1;
|
||||
late String step2;
|
||||
late String step3;
|
||||
late String step4;
|
||||
late String passengerWalletBurc;
|
||||
late String timeOfOrder;
|
||||
late String duration;
|
||||
late String totalCost;
|
||||
late String distance;
|
||||
late String passengerName;
|
||||
late String passengerEmail;
|
||||
late String totalPassenger;
|
||||
late String passengerPhone;
|
||||
late String rideId;
|
||||
late String isHaveSteps;
|
||||
late String paymentAmount;
|
||||
late String paymentMethod;
|
||||
late String passengerId;
|
||||
late String driverId;
|
||||
late String tokenPassenger;
|
||||
late String durationToPassenger;
|
||||
late String walletChecked;
|
||||
late String direction;
|
||||
late String carType;
|
||||
late String kazan;
|
||||
late String startNameLocation;
|
||||
late String endNameLocation;
|
||||
late String durationOfRideValue;
|
||||
late String status;
|
||||
String stringRemainingTimeToPassenger = '';
|
||||
|
||||
String stringRemainingTimeWaitingPassenger = '';
|
||||
late Duration durationToAdd;
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
int timeWaitingPassenger = 5; //5 miniute
|
||||
bool isPassengerInfoWindow = false;
|
||||
bool isBtnRideBegin = false;
|
||||
bool isArrivedSend = true;
|
||||
bool isdriverWaitTimeEnd = false;
|
||||
bool isRideFinished = false;
|
||||
bool isRideStarted = false;
|
||||
bool isPriceWindow = false;
|
||||
double passengerInfoWindowHeight = Get.height * .38;
|
||||
double driverEndPage = 100;
|
||||
double progress = 0;
|
||||
double progressToPassenger = 0;
|
||||
double progressInPassengerLocationFromDriver = 0;
|
||||
bool isRideBegin = false;
|
||||
int progressTimerToShowPassengerInfoWindowFromDriver = 25;
|
||||
int remainingTimeToShowPassengerInfoWindowFromDriver = 25;
|
||||
int remainingTimeToPassenger = 60;
|
||||
int remainingTimeInPassengerLocatioWait = 60;
|
||||
bool isDriverNearPassengerStart = false;
|
||||
GoogleMapController? mapController;
|
||||
late LatLng myLocation;
|
||||
int remainingTimeTimerRideBegin = 60;
|
||||
String stringRemainingTimeRideBegin = '';
|
||||
String stringRemainingTimeRideBegin1 = '';
|
||||
double progressTimerRideBegin = 0;
|
||||
late Timer timer;
|
||||
String? mapAPIKEY;
|
||||
final zones = <Zone>[];
|
||||
String canelString = 'yet';
|
||||
late LatLng latLngPassengerLocation;
|
||||
late LatLng latLngPassengerDestination;
|
||||
void clearPolyline() {
|
||||
polyLines = [];
|
||||
polyLinesDestination = [];
|
||||
polylineCoordinates.clear();
|
||||
polylineCoordinatesDestination.clear();
|
||||
update();
|
||||
}
|
||||
|
||||
argumentLoading() async {
|
||||
passengerLocation = box.read(BoxName.rideArguments)['passengerLocation'];
|
||||
print(passengerLocation);
|
||||
passengerDestination =
|
||||
box.read(BoxName.rideArguments)['passengerDestination'];
|
||||
print(passengerDestination);
|
||||
duration = box.read(BoxName.rideArguments)['Duration'];
|
||||
totalCost = box.read(BoxName.rideArguments)['totalCost'];
|
||||
passengerId = box.read(BoxName.rideArguments)['passengerId'];
|
||||
driverId = box.read(BoxName.rideArguments)['driverId'];
|
||||
distance = box.read(BoxName.rideArguments)['Distance'];
|
||||
passengerName = box.read(BoxName.rideArguments)['name'];
|
||||
passengerEmail = box.read(BoxName.rideArguments)['email'];
|
||||
totalPassenger = box.read(BoxName.rideArguments)['totalPassenger'];
|
||||
passengerPhone = box.read(BoxName.rideArguments)['phone'];
|
||||
walletChecked = box.read(BoxName.rideArguments)['WalletChecked'];
|
||||
tokenPassenger = box.read(BoxName.rideArguments)['tokenPassenger'];
|
||||
direction = box.read(BoxName.rideArguments)['direction'];
|
||||
durationToPassenger =
|
||||
box.read(BoxName.rideArguments)['DurationToPassenger'].toString();
|
||||
print(durationToPassenger);
|
||||
rideId = box.read(BoxName.rideArguments)['rideId'];
|
||||
durationOfRideValue =
|
||||
box.read(BoxName.rideArguments)['durationOfRideValue'];
|
||||
paymentAmount = box.read(BoxName.rideArguments)['paymentAmount'];
|
||||
paymentMethod = box.read(BoxName.rideArguments)['paymentMethod'];
|
||||
isHaveSteps = box.read(BoxName.rideArguments)['isHaveSteps'];
|
||||
step0 = box.read(BoxName.rideArguments)['step0'];
|
||||
step1 = box.read(BoxName.rideArguments)['step1'];
|
||||
step2 = box.read(BoxName.rideArguments)['step2'];
|
||||
step3 = box.read(BoxName.rideArguments)['step3'];
|
||||
step4 = box.read(BoxName.rideArguments)['step4'];
|
||||
passengerWalletBurc =
|
||||
box.read(BoxName.rideArguments)['passengerWalletBurc'];
|
||||
timeOfOrder = box.read(BoxName.rideArguments)['timeOfOrder'];
|
||||
carType = box.read(BoxName.rideArguments)['carType'];
|
||||
kazan = box.read(BoxName.rideArguments)['kazan'];
|
||||
startNameLocation = box.read(BoxName.rideArguments)['startNameLocation'];
|
||||
endNameLocation = box.read(BoxName.rideArguments)['endNameLocation'];
|
||||
|
||||
// var coords = passengerLocation.toString().split(',');
|
||||
// var coordDestination = passengerDestination.toString().split(',');
|
||||
|
||||
// Parse to double
|
||||
latlng(passengerLocation, passengerDestination);
|
||||
String lat = Get.find<LocationController>().myLocation.latitude.toString();
|
||||
String lng = Get.find<LocationController>().myLocation.longitude.toString();
|
||||
String origin = '$lat,$lng';
|
||||
print('latLngpassengerLocation $latLngPassengerLocation');
|
||||
print('latLngPassengerDestination $latLngPassengerDestination');
|
||||
// Set the origin and destination coordinates for the Google Maps directions request.
|
||||
Future.delayed(const Duration(seconds: 1));
|
||||
getMap(origin, passengerLocation);
|
||||
isHaveSteps == 'haveSteps'
|
||||
? (
|
||||
await getMapDestination(step0, step1),
|
||||
await getMapDestination(step1, step2),
|
||||
step3 == '' ? await getMapDestination(step2, step3) : () {},
|
||||
step4 == '' ? await getMapDestination(step3, step4) : () {},
|
||||
)
|
||||
: await getMapDestination(passengerLocation, passengerDestination);
|
||||
update();
|
||||
}
|
||||
|
||||
latlng(String passengerLocation, passengerDestination) {
|
||||
double latPassengerLocation =
|
||||
double.parse(passengerLocation.toString().split(',')[0]);
|
||||
print('latPassengerLocation $latPassengerLocation');
|
||||
double lngPassengerLocation =
|
||||
double.parse(passengerLocation.toString().split(',')[1]);
|
||||
double latPassengerDestination =
|
||||
double.parse(passengerDestination.toString().split(',')[0]);
|
||||
double lngPassengerDestination =
|
||||
double.parse(passengerDestination.toString().split(',')[1]);
|
||||
latLngPassengerLocation =
|
||||
LatLng(latPassengerLocation, lngPassengerLocation);
|
||||
latLngPassengerDestination =
|
||||
LatLng(latPassengerDestination, lngPassengerDestination);
|
||||
}
|
||||
|
||||
double distanceBetweenDriverAndPassengerWhenConfirm = 0;
|
||||
getMap(String origin, destination) async {
|
||||
isLoading = false;
|
||||
|
||||
update();
|
||||
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
print(data);
|
||||
distanceBetweenDriverAndPassengerWhenConfirm =
|
||||
(data[0]['distance']['value']) / 1000;
|
||||
final points =
|
||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
double lat = points[i][0].toDouble();
|
||||
double lng = points[i][1].toDouble();
|
||||
polylineCoordinates.add(LatLng(lat, lng));
|
||||
}
|
||||
if (polyLines.isNotEmpty) {
|
||||
clearPolyline();
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
points: polylineCoordinates,
|
||||
width: 10,
|
||||
color: AppColor.blueColor,
|
||||
);
|
||||
polyLines.add(polyline);
|
||||
// rideConfirm = false;
|
||||
update();
|
||||
} else {
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
points: polylineCoordinates,
|
||||
width: 10,
|
||||
color: AppColor.blueColor,
|
||||
);
|
||||
// final dataBounds = response["routes"][0]["bounds"];
|
||||
|
||||
// updateCameraFromBoundsAfterGetMap(dataBounds);
|
||||
|
||||
// Fit the camera to the bounds
|
||||
|
||||
polyLines.add(polyline);
|
||||
// rideConfirm = false;
|
||||
// Define the northeast and southwest coordinates
|
||||
final bounds = response["routes"][0]["bounds"];
|
||||
LatLng northeast =
|
||||
LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
|
||||
LatLng southwest =
|
||||
LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']);
|
||||
|
||||
// Create the LatLngBounds object
|
||||
LatLngBounds boundsData =
|
||||
LatLngBounds(northeast: northeast, southwest: southwest);
|
||||
|
||||
// Fit the camera to the bounds
|
||||
var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData, 140);
|
||||
mapController!.animateCamera(cameraUpdate);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
getMapDestination(String origin, destination) async {
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
dataDestination = response['routes'][0]['legs'];
|
||||
// print(data);
|
||||
final points =
|
||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
double lat = points[i][0].toDouble();
|
||||
double lng = points[i][1].toDouble();
|
||||
polylineCoordinatesDestination.add(LatLng(lat, lng));
|
||||
}
|
||||
if (polyLinesDestination.isNotEmpty) {
|
||||
// clearPolyline();
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
points: polylineCoordinatesDestination,
|
||||
width: 10,
|
||||
color: AppColor.redColor,
|
||||
);
|
||||
polyLinesDestination.add(polyline);
|
||||
// rideConfirm = false;
|
||||
update();
|
||||
} else {
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
points: polylineCoordinatesDestination,
|
||||
width: 10,
|
||||
color: AppColor.redColor,
|
||||
);
|
||||
// final dataBounds = response["routes"][0]["bounds"];
|
||||
|
||||
// updateCameraFromBoundsAfterGetMap(dataBounds);
|
||||
// polyLinesDestination.add(polyline);
|
||||
// rideConfirm = false;
|
||||
// Define the northeast and southwest coordinates
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void startTimerToShowPassengerInfoWindowFromDriver() async {
|
||||
isPassengerInfoWindow = true;
|
||||
for (int i = 0; i <= int.parse(durationToPassenger); i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progressToPassenger = i / int.parse(durationToPassenger);
|
||||
remainingTimeToPassenger = int.parse(durationToPassenger) - i;
|
||||
if (remainingTimeToPassenger == 0) {
|
||||
isBtnRideBegin = true;
|
||||
print(isBtnRideBegin);
|
||||
update();
|
||||
}
|
||||
print(isBtnRideBegin);
|
||||
print(remainingTimeToPassenger);
|
||||
|
||||
int minutes = (remainingTimeToPassenger / 60).floor();
|
||||
int seconds = remainingTimeToPassenger % 60;
|
||||
stringRemainingTimeToPassenger =
|
||||
'$minutes:${seconds.toString().padLeft(2, '0')}';
|
||||
|
||||
update();
|
||||
}
|
||||
// update();
|
||||
// startTimerToShowDriverToPassengerDuration();
|
||||
}
|
||||
|
||||
void onMapCreated(GoogleMapController controller) async {
|
||||
myLocation = Get.find<LocationController>().location as LatLng;
|
||||
myLocation = myLocation;
|
||||
mapController = controller;
|
||||
controller.getVisibleRegion();
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(Get.find<LocationController>().myLocation),
|
||||
);
|
||||
update();
|
||||
// Set up a timer or interval to trigger the marker update every 3 seconds.
|
||||
timer = Timer.periodic(const Duration(seconds: 1), (_) {
|
||||
// updateMarker();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
// Get the passenger location from the arguments.
|
||||
await argumentLoading();
|
||||
// addCustomCarIcon();
|
||||
// addCustomPassengerIcon();
|
||||
// addCustomStartIcon();
|
||||
// addCustomEndIcon();
|
||||
// updateMarker();
|
||||
// updateLocation();
|
||||
startTimerToShowPassengerInfoWindowFromDriver();
|
||||
durationToAdd = Duration(seconds: int.parse(duration));
|
||||
hours = durationToAdd.inHours;
|
||||
minutes = (durationToAdd.inMinutes % 60).round();
|
||||
calculateConsumptionFuel();
|
||||
// cancelCheckRidefromPassenger();
|
||||
// checkIsDriverNearPassenger();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
calculateConsumptionFuel() {
|
||||
mpg = Get.find<HomeCaptainController>().fuelPrice /
|
||||
12; //todo in register car add mpg in box
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/controller/firebase/firbase_messge.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
@@ -9,6 +11,7 @@ import 'package:SEFER/main.dart';
|
||||
|
||||
class CaptainWalletController extends GetxController {
|
||||
bool isLoading = false;
|
||||
final formKeyTransfer = GlobalKey<FormState>();
|
||||
Map walletDate = {};
|
||||
Map walletDateVisa = {};
|
||||
Map walletDriverPointsDate = {};
|
||||
@@ -17,7 +20,8 @@ class CaptainWalletController extends GetxController {
|
||||
String totalAmountVisa = '0';
|
||||
String totalPoints = '0';
|
||||
final amountFromBudgetController = TextEditingController();
|
||||
final issurWallet = TextEditingController();
|
||||
final newDriverPhoneController = TextEditingController();
|
||||
final phoneWallet = TextEditingController();
|
||||
|
||||
payFromBudget() async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
@@ -37,6 +41,46 @@ class CaptainWalletController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
List amountToNewDriverMap = [];
|
||||
bool isNewTransfer = false;
|
||||
Future detectNewDriverFromMyBudget() async {
|
||||
if (formKeyTransfer.currentState!.validate()) {
|
||||
if (int.parse(amountFromBudgetController.text) <
|
||||
double.parse(totalAmountVisa) &&
|
||||
int.parse(amountFromBudgetController.text) > 10) {
|
||||
//get new driver details
|
||||
isNewTransfer = true;
|
||||
update();
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverDetails,
|
||||
payload: {'driver_phone': '+2${newDriverPhoneController.text}'});
|
||||
isNewTransfer = false;
|
||||
update();
|
||||
if (res != 'failure') {
|
||||
var d = jsonDecode(res);
|
||||
amountToNewDriverMap = d['data'];
|
||||
// update();
|
||||
} else {
|
||||
Get.snackbar(
|
||||
"This driver is not registered".tr,
|
||||
'',
|
||||
duration: const Duration(seconds: 3),
|
||||
backgroundColor: AppColor.redColor,
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Get.snackbar(
|
||||
'Your Budget less than needed'.tr,
|
||||
'',
|
||||
duration: const Duration(seconds: 3),
|
||||
backgroundColor: AppColor.redColor,
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future getCaptainWalletFromRide() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
@@ -79,8 +123,20 @@ class CaptainWalletController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
String paymentToken = '';
|
||||
Future<String> generateToken(String amount) async {
|
||||
var res = await CRUD().post(link: AppLink.addPaymentToken, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'amount': amount.toString(),
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
print('paymentToken ${d['message']}');
|
||||
return d['message'];
|
||||
}
|
||||
|
||||
late String paymentID;
|
||||
Future addDriverPayment(String paymentMethod, amount) async {
|
||||
Future<String> addDriverPayment(String paymentMethod, amount) async {
|
||||
// paymentToken = await generateToken(amount);
|
||||
var res = await CRUD().post(link: AppLink.addDriverPaymentPoints, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'amount': amount.toString(),
|
||||
@@ -89,17 +145,53 @@ class CaptainWalletController extends GetxController {
|
||||
var d = jsonDecode(res);
|
||||
paymentID = d['message'].toString();
|
||||
print('paymentID $paymentID');
|
||||
return paymentID;
|
||||
}
|
||||
|
||||
Future addDriverWallet(String paymentMethod, point) async {
|
||||
paymentToken = await generateToken(point);
|
||||
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'paymentID': paymentID.toString(),
|
||||
'amount': point,
|
||||
'token': paymentToken,
|
||||
'paymentMethod': paymentMethod.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
Future addtransferDriversWallet(String paymentMethod) async {
|
||||
paymentID =
|
||||
await addDriverPayment(paymentMethod, amountFromBudgetController.text);
|
||||
paymentToken = await generateToken(amountFromBudgetController.text);
|
||||
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'paymentID': paymentID.toString(),
|
||||
'amount': (int.parse(amountFromBudgetController.text) * -1).toString(),
|
||||
'token': paymentToken,
|
||||
'paymentMethod': paymentMethod.toString(),
|
||||
});
|
||||
paymentID =
|
||||
await addDriverPayment(paymentMethod, amountFromBudgetController.text);
|
||||
paymentToken = await generateToken(amountFromBudgetController.text);
|
||||
var res1 =
|
||||
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'driverID': amountToNewDriverMap[0]['id'].toString(),
|
||||
'paymentID': paymentID.toString(),
|
||||
'amount': (int.parse(amountFromBudgetController.text) - 5).toString(),
|
||||
'token': paymentToken,
|
||||
'paymentMethod': paymentMethod.toString(),
|
||||
});
|
||||
if (res1 != 'failure') {
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
'Transfer',
|
||||
'${'You have transfer to your wallet from'.tr}'
|
||||
'${box.read(BoxName.nameDriver)}',
|
||||
amountToNewDriverMap[0]['token'].toString(),
|
||||
[],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//check if account bank is created or not
|
||||
Future checkAccountCaptainBank() async {
|
||||
isLoading = false;
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'captain_wallet_controller.dart';
|
||||
|
||||
class PaymobPayout extends GetxController {
|
||||
bool isLoading = false;
|
||||
String dropdownValue = 'etisalat';
|
||||
|
||||
Future<String> getToken() async {
|
||||
var headers = {
|
||||
@@ -53,6 +54,7 @@ class PaymobPayout extends GetxController {
|
||||
"issuer": issuer, //"vodafone",
|
||||
"msisdn": msisdn, // "01023456789"
|
||||
});
|
||||
print(body);
|
||||
var res = await http.post(
|
||||
Uri.parse(
|
||||
'https://stagingpayouts.paymobsolutions.com/api/secure/disburse/'),
|
||||
@@ -65,7 +67,7 @@ class PaymobPayout extends GetxController {
|
||||
if (dec['disbursement_status'] == 'successful') {
|
||||
await CRUD().post(link: AppLink.addDriverpayment, payload: {
|
||||
'rideId': DateTime.now().toIso8601String(),
|
||||
'amount': ((-1) * double.parse(dec['amount'])).toStringAsFixed(0),
|
||||
'amount': ((-1) * (double.parse(dec['amount'])) + 5).toStringAsFixed(0),
|
||||
'payment_method': 'payout',
|
||||
'passengerID': 'myself',
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
@@ -75,7 +77,7 @@ class PaymobPayout extends GetxController {
|
||||
backgroundColor: AppColor.greenColor);
|
||||
Get.find<CaptainWalletController>().getCaptainWalletFromRide();
|
||||
} else if (dec['disbursement_status'] == 'failed') {
|
||||
Get.snackbar('Transaction successful'.tr, 'Transaction failed'.tr,
|
||||
Get.snackbar('Transaction failed'.tr, 'Transaction failed'.tr,
|
||||
backgroundColor: AppColor.redColor);
|
||||
}
|
||||
}
|
||||
@@ -89,7 +91,8 @@ class PaymobPayout extends GetxController {
|
||||
var body = {
|
||||
"issuer": "bank_card",
|
||||
"amount": amount, //9.0,
|
||||
"full_name": box.read(BoxName.nameDriver).toString(),
|
||||
"full_name":
|
||||
'${box.read(BoxName.nameDriver)} ${box.read(BoxName.lastNameDriver)}',
|
||||
"bank_card_number": bankCardNumber, //"1111-2222-3333-4444",
|
||||
"bank_code": bankCode, //"CIB",
|
||||
"bank_transaction_type": "cash_transfer"
|
||||
|
||||
@@ -4,6 +4,13 @@ class MyTranslation extends Translations {
|
||||
@override
|
||||
Map<String, Map<String, String>> get keys => {
|
||||
"ar": {
|
||||
"You have transferred to your wallet from": "لقد حولت إلى محفظتك من",
|
||||
'Transfer': "تحويل",
|
||||
"amount": "المبلغ",
|
||||
"This driver is not registered": "هذا السائق غير مسجل",
|
||||
'insert amount': "أدخل المبلغ",
|
||||
"phone number of driver": "رقم هاتف السائق",
|
||||
"Transfer budget": "نقل الميزانية",
|
||||
"Special Order": "طلب خاص",
|
||||
"Speed Order": "طلب سريع",
|
||||
"No data yet!": "لا توجد بيانات حتى الآن!",
|
||||
@@ -18,7 +25,7 @@ class MyTranslation extends Translations {
|
||||
"Enter your wallet number": "أدخل رقم محفظتك",
|
||||
"The Amount is less than": "المبلغ أقل من",
|
||||
"Cash Out": "صرف",
|
||||
"Transaction successful": "تمت العملية بنجاح",
|
||||
|
||||
"Do you want to collect your earnings?":
|
||||
"هل تريد استلام أموالك؟", // Corrected grammar
|
||||
"Total wallet is ": "إجمالي المحفظة هو ",
|
||||
|
||||
Reference in New Issue
Block a user