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 verifyEmailCaptin = "$authCaptin/verifyEmail.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") {
// print(res);
isLoading = false;
update();
Get.defaultDialog(
title: 'There is no help Question here'.tr,
titleStyle: AppStyle.title,

View File

@@ -14,6 +14,7 @@ class CaptainWalletController extends GetxController {
final formKey = GlobalKey<FormState>();
String totalAmount = '0';
String totalPoints = '0';
Future getCaptainWalletFromRide() async {
isLoading = true;
update();
@@ -37,8 +38,14 @@ class CaptainWalletController extends GetxController {
payload: {'driverID': box.read(BoxName.driverID)},
);
walletDriverPointsDate = jsonDecode(res);
if (walletDriverPointsDate['message'][0]['driverID'].toString() ==
box.read(BoxName.driverID)) {
totalPoints =
walletDriverPointsDate['message'][0]['total_amount'].toString();
} else {
totalPoints = '0';
}
isLoading = false;
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
void onInit() {
getCaptainWalletFromRide();
getCaptainWalletFromBuyPoints();
checkAccountCaptainBank();
super.onInit();
}
}

View File

@@ -403,13 +403,24 @@ class PaymentController extends GetxController {
payload: body,
);
final responseData = jsonDecode(response);
print(responseData);
// print(responseData);
final accountId = responseData['id'];
box.write(BoxName.accountIdStripeConnect, accountId);
await updateCaptainAccountBank();
print('accountId = $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(
String amount, String account) async {
String url = 'https://api.stripe.com//v1/transfers';
@@ -427,7 +438,7 @@ class PaymentController extends GetxController {
final responseData = jsonDecode(response);
print(responseData);
final transactionId = responseData['id'];
box.write(BoxName.accountIdStripeConnect, transactionId);
print('transactionId = $transactionId');
return transactionId;
}

View File

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

View File

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

View File

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

View File

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