This commit is contained in:
Hamza-Ayed
2023-12-12 21:31:36 +03:00
parent ba90f96e77
commit 44505dd9ea
8 changed files with 216 additions and 170 deletions

View File

@@ -141,4 +141,6 @@ class AppLink {
static String sendVerifyEmailCaptin = "$authCaptin/sendVerifyEmail.php"; static String sendVerifyEmailCaptin = "$authCaptin/sendVerifyEmail.php";
static String verifyEmailCaptin = "$authCaptin/verifyEmail.php"; static String verifyEmailCaptin = "$authCaptin/verifyEmail.php";
static String removeUser = "$authCaptin/removeAccount.php"; static String removeUser = "$authCaptin/removeAccount.php";
static String updateAccountBank = "$authCaptin/updateAccountBank.php";
static String getAccount = "$authCaptin/getAccount.php";
} }

View File

@@ -52,6 +52,8 @@ class HelpController extends GetxController {
}); });
if (res == "failure") { if (res == "failure") {
// print(res); // print(res);
isLoading = false;
update();
Get.defaultDialog( Get.defaultDialog(
title: 'There is no help Question here'.tr, title: 'There is no help Question here'.tr,
titleStyle: AppStyle.title, titleStyle: AppStyle.title,

View File

@@ -14,6 +14,7 @@ class CaptainWalletController extends GetxController {
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
String totalAmount = '0'; String totalAmount = '0';
String totalPoints = '0'; String totalPoints = '0';
Future getCaptainWalletFromRide() async { Future getCaptainWalletFromRide() async {
isLoading = true; isLoading = true;
update(); update();
@@ -37,8 +38,14 @@ class CaptainWalletController extends GetxController {
payload: {'driverID': box.read(BoxName.driverID)}, payload: {'driverID': box.read(BoxName.driverID)},
); );
walletDriverPointsDate = jsonDecode(res); walletDriverPointsDate = jsonDecode(res);
if (walletDriverPointsDate['message'][0]['driverID'].toString() ==
box.read(BoxName.driverID)) {
totalPoints = totalPoints =
walletDriverPointsDate['message'][0]['total_amount'].toString(); walletDriverPointsDate['message'][0]['total_amount'].toString();
} else {
totalPoints = '0';
}
isLoading = false; isLoading = false;
update(); update();
} }
@@ -64,10 +71,25 @@ class CaptainWalletController extends GetxController {
}); });
} }
//check if account bank is created or not
Future checkAccountCaptainBank() async {
if (box.read(BoxName.accountIdStripeConnect).toString().isEmpty) {
var res = await CRUD().get(link: AppLink.getAccount, payload: {
'id': box.read(BoxName.driverID).toString(),
});
var d = jsonDecode(res);
if (d['status'] != 'failure') {
box.write(BoxName.accountIdStripeConnect,
d['message'][0]['accountBank'].toString());
}
}
}
@override @override
void onInit() { void onInit() {
getCaptainWalletFromRide(); getCaptainWalletFromRide();
getCaptainWalletFromBuyPoints(); getCaptainWalletFromBuyPoints();
checkAccountCaptainBank();
super.onInit(); super.onInit();
} }
} }

View File

@@ -403,13 +403,24 @@ class PaymentController extends GetxController {
payload: body, payload: body,
); );
final responseData = jsonDecode(response); final responseData = jsonDecode(response);
print(responseData); // print(responseData);
final accountId = responseData['id']; final accountId = responseData['id'];
box.write(BoxName.accountIdStripeConnect, accountId); box.write(BoxName.accountIdStripeConnect, accountId);
await updateCaptainAccountBank();
print('accountId = $accountId'); print('accountId = $accountId');
return accountId; return accountId;
} }
Future updateCaptainAccountBank() async {
var res = await CRUD().post(link: AppLink.updateAccountBank, payload: {
'id': box.read(BoxName.driverID),
'accountBank': box.read(BoxName.accountIdStripeConnect),
});
if (jsonDecode(res)['status'] == 'success') {
Get.snackbar('Account Updated', '');
}
}
Future<String> createTransactionToCaptain( Future<String> createTransactionToCaptain(
String amount, String account) async { String amount, String account) async {
String url = 'https://api.stripe.com//v1/transfers'; String url = 'https://api.stripe.com//v1/transfers';
@@ -427,7 +438,7 @@ class PaymentController extends GetxController {
final responseData = jsonDecode(response); final responseData = jsonDecode(response);
print(responseData); print(responseData);
final transactionId = responseData['id']; final transactionId = responseData['id'];
box.write(BoxName.accountIdStripeConnect, transactionId);
print('transactionId = $transactionId'); print('transactionId = $transactionId');
return transactionId; return transactionId;
} }

View File

@@ -18,11 +18,9 @@ class HelpCaptain extends StatelessWidget {
return MyScafolld( return MyScafolld(
title: 'Helping Page'.tr, title: 'Helping Page'.tr,
body: [ body: [
Positioned( Column(
top: Get.height * .025, children: [
right: 20, Card(
left: 20,
child: Card(
color: AppColor.yellowColor, color: AppColor.yellowColor,
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@@ -33,12 +31,7 @@ class HelpCaptain extends StatelessWidget {
), ),
), ),
), ),
), Card(
Positioned(
top: Get.height * .15,
right: 20,
left: 20,
child: Card(
elevation: 3, elevation: 3,
color: AppColor.secondaryColor, color: AppColor.secondaryColor,
child: Padding( child: Padding(
@@ -48,8 +41,11 @@ class HelpCaptain extends StatelessWidget {
key: helpController.formKey, key: helpController.formKey,
child: Column( child: Column(
children: [ children: [
TextFormField( SizedBox(
controller: helpController.helpQuestionController, width: Get.width * .8,
child: TextFormField(
controller:
helpController.helpQuestionController,
decoration: const InputDecoration( decoration: const InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
hintText: 'Enter your Question here', hintText: 'Enter your Question here',
@@ -62,6 +58,7 @@ class HelpCaptain extends StatelessWidget {
return null; return null;
}, },
), ),
),
const SizedBox(height: 20), const SizedBox(height: 20),
helpController.isLoading helpController.isLoading
? const MyCircularProgressIndicator() ? const MyCircularProgressIndicator()
@@ -82,19 +79,20 @@ class HelpCaptain extends StatelessWidget {
)), )),
), ),
)), )),
), GetBuilder<HelpController>(
Positioned(
bottom: 3,
right: 8,
left: 8,
child: GetBuilder<HelpController>(
builder: (helpController) => Container( builder: (helpController) => Container(
height: Get.height * .63, height: 400,
decoration: AppStyle.boxDecoration, decoration: AppStyle.boxDecoration,
child: ListView.builder( child: ListView.builder(
itemCount: itemCount: helpController.helpQuestionDate['message'] !=
helpController.helpQuestionDate['message'].length, null
? helpController.helpQuestionDate['message'].length
: 0,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
// if (helpController.helpQuestionDate['message'] ==
// null) {
// return const CircularProgressIndicator();
// }
var list = var list =
helpController.helpQuestionDate['message'][index]; helpController.helpQuestionDate['message'][index];
return Padding( return Padding(
@@ -148,7 +146,8 @@ class HelpCaptain extends StatelessWidget {
}, },
), ),
)), )),
) ],
),
], ],
isleading: true, isleading: true,
); );

View File

@@ -197,23 +197,7 @@ class PassengerWallet extends StatelessWidget {
}, },
), ),
)), )),
PassengerWalletDialoge(), const PassengerWalletDialoge(),
GetBuilder<PaymentController>(
builder: (controller) => Positioned(
top: 440,
right: 100,
left: 100,
child: Column(
children: [
MyElevatedButton(
title: 'createConnectAccount',
onPressed: () {
controller.createConnectAccount();
},
),
],
),
))
], ],
); );
} }

View File

@@ -27,6 +27,7 @@ class PointsCaptain extends StatelessWidget {
await paymentController.makePaymentStripe(pricePoint, 'USD', () async { await paymentController.makePaymentStripe(pricePoint, 'USD', () async {
await captainWalletController.addDriverPayment('visa', pricePoint); await captainWalletController.addDriverPayment('visa', pricePoint);
await captainWalletController.addDriverWallet('visa', countPoint); await captainWalletController.addDriverWallet('visa', countPoint);
await captainWalletController.getCaptainWalletFromBuyPoints();
}); });
}, },
child: Container( child: Container(

View File

@@ -32,16 +32,32 @@ class WaletCaptain extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Card( const SizedBox(),
elevation: 4, Container(
decoration: AppStyle.boxDecoration.copyWith(
color: double.parse(
captainWalletController.totalPoints) <
100
? AppColor.redColor
: AppColor.greenColor,
),
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4), padding: const EdgeInsets.symmetric(horizontal: 4),
child: Text( child: Text(
'Total Points is ${captainWalletController.totalPoints} 💎', 'Total Points is ${captainWalletController.totalPoints.toString()} 💎',
style: AppStyle.headtitle2, style: AppStyle.headtitle2,
), ),
), ),
), ),
const SizedBox(
height: 10,
),
double.parse(captainWalletController.totalPoints
.toString()) <
100
? MyElevatedButton(
title: 'Charge your Account', onPressed: () {})
: const SizedBox(),
Card( Card(
elevation: 4, elevation: 4,
child: Padding( child: Padding(
@@ -93,30 +109,39 @@ class WaletCaptain extends StatelessWidget {
const SizedBox( const SizedBox(
height: 30, height: 30,
), ),
Row( box
.read(BoxName.accountIdStripeConnect)
.toString()
.isEmpty
? Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
MyElevatedButton( MyElevatedButton(
title: 'Create Wallet to recive your money', title:
'Create Wallet to recive your money',
onPressed: () async { onPressed: () async {
PaymentController paymentController = PaymentController paymentController =
Get.find<PaymentController>(); Get.find<PaymentController>();
paymentController.createConnectAccount(); paymentController
.createConnectAccount();
}), }),
], ],
),
TextButton(
onPressed: () async {
PaymentController paymentController =
Get.put(PaymentController());
await paymentController.createTransactionToCaptain(
'1000',
box.read(BoxName.accountIdStripeConnect));
},
child: const Text(
"Pay to Captain",
),
) )
: const SizedBox(
height: 30,
),
// TextButton(
// onPressed: () async {
// PaymentController paymentController =
// Get.put(PaymentController());
// await paymentController.createTransactionToCaptain(
// '1000',
// box.read(BoxName.accountIdStripeConnect));
// },
// child: const Text(
// "Pay to Captain",
// ),
// )
], ],
), ),
)) ))