BASE: Update Icons & Name Of The App.
This commit is contained in:
@@ -4,7 +4,7 @@ import 'package:customer/models/coupon_model.dart';
|
||||
import 'package:customer/models/user_model.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get.dart' hide Trans;
|
||||
import '../constant/constant.dart';
|
||||
import '../models/onprovider_order_model.dart';
|
||||
import '../models/wallet_transaction_model.dart';
|
||||
@@ -19,7 +19,8 @@ class OnDemandOrderDetailsController extends GetxController {
|
||||
Rxn<WorkerModel> worker = Rxn<WorkerModel>();
|
||||
|
||||
Rx<TextEditingController> couponTextController = TextEditingController().obs;
|
||||
Rx<TextEditingController> cancelBookingController = TextEditingController().obs;
|
||||
Rx<TextEditingController> cancelBookingController =
|
||||
TextEditingController().obs;
|
||||
|
||||
RxDouble subTotal = 0.0.obs;
|
||||
RxDouble price = 0.0.obs;
|
||||
@@ -48,17 +49,22 @@ class OnDemandOrderDetailsController extends GetxController {
|
||||
|
||||
Future<void> getData() async {
|
||||
try {
|
||||
final order = await FireStoreUtils.getProviderOrderById(onProviderOrder.value!.id);
|
||||
final order = await FireStoreUtils.getProviderOrderById(
|
||||
onProviderOrder.value!.id,
|
||||
);
|
||||
if (order != null) {
|
||||
onProviderOrder.value = order;
|
||||
|
||||
discountType.value = order.discountType ?? "";
|
||||
discountLabel.value = order.discountLabel ?? "";
|
||||
discountAmount.value = double.tryParse(order.discount.toString()) ?? 0.0;
|
||||
discountAmount.value =
|
||||
double.tryParse(order.discount.toString()) ?? 0.0;
|
||||
offerCode.value = order.couponCode ?? "";
|
||||
|
||||
// Fetch provider
|
||||
providerUser.value = await FireStoreUtils.getUserProfile(order.provider.author.toString());
|
||||
providerUser.value = await FireStoreUtils.getUserProfile(
|
||||
order.provider.author.toString(),
|
||||
);
|
||||
|
||||
// Fetch worker (if exists)
|
||||
if (order.workerId != null && order.workerId!.isNotEmpty) {
|
||||
@@ -70,7 +76,9 @@ class OnDemandOrderDetailsController extends GetxController {
|
||||
calculatePrice();
|
||||
|
||||
// Load available coupons
|
||||
FireStoreUtils.getProviderCouponAfterExpire(order.provider.author.toString()).then((expiredCoupons) {
|
||||
FireStoreUtils.getProviderCouponAfterExpire(
|
||||
order.provider.author.toString(),
|
||||
).then((expiredCoupons) {
|
||||
couponList.assignAll(expiredCoupons);
|
||||
});
|
||||
} else {
|
||||
@@ -90,8 +98,12 @@ class OnDemandOrderDetailsController extends GetxController {
|
||||
|
||||
void applyCoupon(CouponModel coupon) {
|
||||
double discount = 0.0;
|
||||
if (coupon.discountType == "Percentage" || coupon.discountType == "Percent") {
|
||||
discount = price.value * (double.tryParse(coupon.discount.toString()) ?? 0) / 100;
|
||||
if (coupon.discountType == "Percentage" ||
|
||||
coupon.discountType == "Percent") {
|
||||
discount =
|
||||
price.value *
|
||||
(double.tryParse(coupon.discount.toString()) ?? 0) /
|
||||
100;
|
||||
} else {
|
||||
discount = double.tryParse(coupon.discount.toString()) ?? 0;
|
||||
}
|
||||
@@ -108,17 +120,29 @@ class OnDemandOrderDetailsController extends GetxController {
|
||||
|
||||
void calculatePrice() {
|
||||
double basePrice =
|
||||
(onProviderOrder.value?.provider.disPrice == "" || onProviderOrder.value?.provider.disPrice == "0")
|
||||
? double.tryParse(onProviderOrder.value?.provider.price.toString() ?? "0") ?? 0
|
||||
: double.tryParse(onProviderOrder.value?.provider.disPrice.toString() ?? "0") ?? 0;
|
||||
(onProviderOrder.value?.provider.disPrice == "" ||
|
||||
onProviderOrder.value?.provider.disPrice == "0")
|
||||
? double.tryParse(
|
||||
onProviderOrder.value?.provider.price.toString() ?? "0",
|
||||
) ??
|
||||
0
|
||||
: double.tryParse(
|
||||
onProviderOrder.value?.provider.disPrice.toString() ?? "0",
|
||||
) ??
|
||||
0;
|
||||
|
||||
price.value = basePrice * (onProviderOrder.value?.quantity ?? 0.0);
|
||||
|
||||
// discount
|
||||
if (discountType.value == "Percentage" || discountType.value == "Percent") {
|
||||
discountAmount.value = price.value * (double.tryParse(discountLabel.value) ?? 0) / 100;
|
||||
discountAmount.value =
|
||||
price.value * (double.tryParse(discountLabel.value) ?? 0) / 100;
|
||||
} else {
|
||||
discountAmount.value = double.tryParse(discountLabel.value.isEmpty ? '0' : discountLabel.value) ?? 0;
|
||||
discountAmount.value =
|
||||
double.tryParse(
|
||||
discountLabel.value.isEmpty ? '0' : discountLabel.value,
|
||||
) ??
|
||||
0;
|
||||
}
|
||||
|
||||
subTotal.value = price.value - discountAmount.value;
|
||||
@@ -126,7 +150,10 @@ class OnDemandOrderDetailsController extends GetxController {
|
||||
// tax calculation
|
||||
double total = subTotal.value;
|
||||
for (var element in Constant.taxList) {
|
||||
total += Constant.getTaxValue(amount: subTotal.value.toString(), taxModel: element);
|
||||
total += Constant.getTaxValue(
|
||||
amount: subTotal.value.toString(),
|
||||
taxModel: element,
|
||||
);
|
||||
}
|
||||
|
||||
totalAmount.value = total;
|
||||
@@ -152,22 +179,30 @@ class OnDemandOrderDetailsController extends GetxController {
|
||||
|
||||
// Calculate total
|
||||
final pricePerUnit =
|
||||
(order.provider.disPrice == "" || order.provider.disPrice == "0") ? double.tryParse(order.provider.price.toString()) ?? 0 : double.tryParse(order.provider.disPrice.toString()) ?? 0;
|
||||
(order.provider.disPrice == "" || order.provider.disPrice == "0")
|
||||
? double.tryParse(order.provider.price.toString()) ?? 0
|
||||
: double.tryParse(order.provider.disPrice.toString()) ?? 0;
|
||||
|
||||
total = pricePerUnit * (order.quantity);
|
||||
|
||||
// Add tax
|
||||
if (Constant.taxList.isNotEmpty) {
|
||||
for (var tax in Constant.taxList) {
|
||||
total += Constant.getTaxValue(amount: total.toString(), taxModel: tax);
|
||||
total += Constant.getTaxValue(
|
||||
amount: total.toString(),
|
||||
taxModel: tax,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Admin commission
|
||||
double adminComm = 0.0;
|
||||
if ((order.adminCommission ?? '0') != '0' && (order.adminCommissionType ?? '').isNotEmpty) {
|
||||
if (order.adminCommissionType!.toLowerCase() == 'percentage' || order.adminCommissionType!.toLowerCase() == 'percent') {
|
||||
adminComm = (total * (double.tryParse(order.adminCommission!) ?? 0)) / 100;
|
||||
if ((order.adminCommission ?? '0') != '0' &&
|
||||
(order.adminCommissionType ?? '').isNotEmpty) {
|
||||
if (order.adminCommissionType!.toLowerCase() == 'percentage' ||
|
||||
order.adminCommissionType!.toLowerCase() == 'percent') {
|
||||
adminComm =
|
||||
(total * (double.tryParse(order.adminCommission!) ?? 0)) / 100;
|
||||
} else {
|
||||
adminComm = double.tryParse(order.adminCommission!) ?? 0;
|
||||
}
|
||||
@@ -237,10 +272,19 @@ class OnDemandOrderDetailsController extends GetxController {
|
||||
await FireStoreUtils.updateOnDemandOrder(order); // Ensure this completes
|
||||
|
||||
// Notify provider
|
||||
final provider = await FireStoreUtils.getUserProfile(order.provider.author ?? '');
|
||||
final provider = await FireStoreUtils.getUserProfile(
|
||||
order.provider.author ?? '',
|
||||
);
|
||||
if (provider != null) {
|
||||
Map<String, dynamic> payload = {"type": 'provider_order', "orderId": order.id};
|
||||
await SendNotification.sendFcmMessage(Constant.bookingPlaced, provider.fcmToken ?? '', payload);
|
||||
Map<String, dynamic> payload = {
|
||||
"type": 'provider_order',
|
||||
"orderId": order.id,
|
||||
};
|
||||
await SendNotification.sendFcmMessage(
|
||||
Constant.bookingPlaced,
|
||||
provider.fcmToken ?? '',
|
||||
payload,
|
||||
);
|
||||
}
|
||||
|
||||
ShowToastDialog.closeLoader();
|
||||
|
||||
Reference in New Issue
Block a user