25-11-18/1
This commit is contained in:
@@ -29,7 +29,6 @@ import '../../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../firebase/firbase_messge.dart';
|
||||
import '../../firebase/notification_service.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/encrypt_decrypt.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
import '../../functions/tts.dart';
|
||||
|
||||
@@ -210,12 +209,16 @@ class MapDriverController extends GetxController {
|
||||
tone: 'cancel',
|
||||
driverList: [], category: "Cancel Trip from driver",
|
||||
);
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferCairoServer}/ride/rides/update.php",
|
||||
payload: {
|
||||
"id": (rideId).toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
await CRUD()
|
||||
.post(link: "${AppLink.server}/ride/rides/update.php", payload: {
|
||||
"id": (rideId).toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
await CRUD()
|
||||
.post(link: "${AppLink.rideServer}/rides/update.php", payload: {
|
||||
"id": (rideId).toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
CRUD().postFromDialogue(
|
||||
link: '${AppLink.seferCairoServer}/driver_order/add.php',
|
||||
payload: {
|
||||
@@ -226,37 +229,13 @@ class MapDriverController extends GetxController {
|
||||
});
|
||||
await CRUD().post(
|
||||
link:
|
||||
"${AppLink.seferCairoServer}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
|
||||
"${AppLink.server}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
|
||||
payload: {
|
||||
"order_id": (rideId).toString(),
|
||||
"driver_id": box.read(BoxName.driverID).toString(),
|
||||
"status": 'reject After Applied',
|
||||
"notes": (cancelTripCotroller.text).toString()
|
||||
});
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD()
|
||||
.post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
|
||||
"id": (rideId).toString(), // Convert to String
|
||||
"status": 'CancelFromDriverAfterApply'
|
||||
});
|
||||
CRUD().postFromDialogue(
|
||||
link: '${AppLink.endPoint}/driver_order/add.php',
|
||||
payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id': (rideId).toString(),
|
||||
'status': 'CancelFromDriverAfterApply'
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
"${AppLink.endPoint}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
|
||||
payload: {
|
||||
"order_id": (rideId).toString(),
|
||||
"driver_id": box.read(BoxName.driverID).toString(),
|
||||
"status": 'reject After Applied',
|
||||
"notes": (cancelTripCotroller.text).toString()
|
||||
});
|
||||
}
|
||||
|
||||
sql.insertData({
|
||||
'order_id': (rideId),
|
||||
@@ -331,13 +310,17 @@ class MapDriverController extends GetxController {
|
||||
box.write(BoxName.rideStatus, 'Applied');
|
||||
Log.print('rideStatus from map 304 : ${box.read(BoxName.rideStatus)}');
|
||||
update();
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferCairoServer}/ride/rides/update.php",
|
||||
payload: {
|
||||
'id': (rideId),
|
||||
'driverGoToPassengerTime': DateTime.now().toString(),
|
||||
'status': 'Applied'
|
||||
});
|
||||
await CRUD()
|
||||
.post(link: "${AppLink.server}/ride/rides/update.php", payload: {
|
||||
'id': (rideId),
|
||||
'driverGoToPassengerTime': DateTime.now().toString(),
|
||||
'status': 'Applied'
|
||||
});
|
||||
CRUD().post(link: "${AppLink.rideServer}/ride/rides/update.php", payload: {
|
||||
'id': (rideId),
|
||||
'driverGoToPassengerTime': DateTime.now().toString(),
|
||||
'status': 'Applied'
|
||||
});
|
||||
|
||||
NotificationService.sendNotification(
|
||||
target: tokenPassenger.toString(),
|
||||
@@ -378,12 +361,37 @@ class MapDriverController extends GetxController {
|
||||
var res = await CRUD().post(link: AppLink.getDriverScam, payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
});
|
||||
|
||||
if (res == 'failure') {
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
return '0';
|
||||
}
|
||||
var d = jsonDecode(res);
|
||||
return d['message'][0]['count'];
|
||||
var d = (res);
|
||||
Log.print('d: ${d}');
|
||||
|
||||
// 1. Check if the response status is 'failure' (API level check)
|
||||
if (d['status'] == 'failure') {
|
||||
// If the API status is failure, the message is a String (e.g., 'No ride scam record found')
|
||||
// and there's no 'count' array to read.
|
||||
return '0';
|
||||
}
|
||||
|
||||
// 2. Safely access the List/Map structure for 'count'
|
||||
// This assumes a successful response looks like:
|
||||
// {'status': 'success', 'message': [{'count': '12'}]}
|
||||
var messageData = d['message'];
|
||||
|
||||
// Check if messageData is actually a List before accessing index [0]
|
||||
if (messageData is List &&
|
||||
messageData.isNotEmpty &&
|
||||
messageData[0] is Map) {
|
||||
return messageData[0]['count'];
|
||||
}
|
||||
|
||||
// Fallback if the successful data structure is unexpected
|
||||
return '0';
|
||||
|
||||
// --- FIX END ---
|
||||
}
|
||||
|
||||
void startRideFromStartApp() {
|
||||
@@ -429,6 +437,11 @@ class MapDriverController extends GetxController {
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Begin',
|
||||
});
|
||||
CRUD().post(link: "${AppLink.server}/ride/rides/update.php", payload: {
|
||||
'id': (rideId),
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Begin',
|
||||
});
|
||||
CRUD().post(link: AppLink.addDriverOrder, payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'order_id': (rideId).toString(),
|
||||
@@ -547,18 +560,6 @@ class MapDriverController extends GetxController {
|
||||
'status': 'CancelAfterWait'
|
||||
});
|
||||
|
||||
if (AppLink.endPoint != AppLink.seferCairoServer) {
|
||||
CRUD().post(link: "${AppLink.endPoint}/rides/update.php", payload: {
|
||||
'id': (rideId),
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'CancelAfterWait',
|
||||
});
|
||||
CRUD().post(link: "${AppLink.endPoint}/rides/update.php", payload: {
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
'order_id': (rideId).toString(),
|
||||
'status': 'CancelAfterWait'
|
||||
});
|
||||
}
|
||||
var paymentTokenWait =
|
||||
await generateTokenDriver(costOfWaiting5Minute.toString());
|
||||
var res = await CRUD().post(link: AppLink.addDrivePayment, payload: {
|
||||
@@ -734,7 +735,11 @@ class MapDriverController extends GetxController {
|
||||
List<Future<dynamic>> apiCalls = [];
|
||||
|
||||
apiCalls.add(CRUD().post(
|
||||
link: "${AppLink.seferCairoServer}/ride/rides//finish_ride_updates.php",
|
||||
link: "${AppLink.rideServer}/ride/rides/finish_ride_updates.php",
|
||||
payload: rideUpdatePayload,
|
||||
));
|
||||
apiCalls.add(CRUD().post(
|
||||
link: "${AppLink.ride}/rides/finish_ride_updates.php",
|
||||
payload: rideUpdatePayload,
|
||||
));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user