Appointment Module's payment final changes!

models_removal
Faiz Hashmi 2 years ago
parent 63263801af
commit 057a202ed9

@ -50,13 +50,14 @@ class ApiConsts {
static String ServiceProviderService_Get = "${baseUrlServices}api/ServiceProviders/ServiceProviderService_Get"; static String ServiceProviderService_Get = "${baseUrlServices}api/ServiceProviders/ServiceProviderService_Get";
static String BranchesAndServices = "${baseUrlServices}api/ServiceProviders/ServiceProviderDetail_Get"; static String BranchesAndServices = "${baseUrlServices}api/ServiceProviders/ServiceProviderDetail_Get";
static String GetAllNearBranches = "${baseUrlServices}api/ServiceProviders/ServiceProviderBranchDetail_Get"; static String GetAllNearBranches = "${baseUrlServices}api/ServiceProviders/ServiceProviderBranchDetail_Get";
static String GetServiceItemAppointmentScheduleSlots = "${baseUrlServices}api/ServiceProviders/ServiceItemAppointmentScheduleSlots_Get";
static String ServiceProvidersAppointmentCreate = "${baseUrlServices}api/ServiceProviders/ServiceProvidersAppointment_Create";
//Appointment APIs //Appointment APIs
static String serviceProvidersAppointmentGet = "${baseUrlServices}api/ServiceProviders/ServiceProvidersAppointment_Get"; static String serviceProvidersAppointmentGet = "${baseUrlServices}api/ServiceProviders/ServiceProvidersAppointment_Get";
static String serviceCategoryGet = "${baseUrlServices}api/Master/ServiceCategory_Get"; static String serviceCategoryGet = "${baseUrlServices}api/Master/ServiceCategory_Get";
static String serviceItemsGet = "${baseUrlServices}api/ServiceProviders/ServiceItem_Get"; static String serviceItemsGet = "${baseUrlServices}api/ServiceProviders/ServiceItem_Get";
static String GetServiceItemAppointmentScheduleSlots = "${baseUrlServices}api/ServiceProviders/ServiceItemAppointmentScheduleSlots_GetByAppointmentType";
static String ServiceProvidersAppointmentCreate = "${baseUrlServices}api/ServiceProviders/ServiceProvidersAppointmentList_Create";
static String ServiceProviderAppointmentRescheduleCancelAppointment = "${baseUrlServices}api/ServiceProviders/ServiceProviderAppointment_RescheduleCancelAppointment";
//ServiceProvidersServiceID as params //ServiceProvidersServiceID as params
// static String servicesGet = "${baseUrlServices}api/ServiceProviders/Services_Get"; // static String servicesGet = "${baseUrlServices}api/ServiceProviders/Services_Get";

@ -46,6 +46,7 @@ class AppRoutes {
static const String bookProviderAppView = "/bookProviderAppView"; static const String bookProviderAppView = "/bookProviderAppView";
static const String appointmentDetailView = "/appointmentDetailView"; static const String appointmentDetailView = "/appointmentDetailView";
static const String bookAppointmenServicesView = "/bookAppointmenServicesView"; static const String bookAppointmenServicesView = "/bookAppointmenServicesView";
static const String bookAppointmenSchedulesView = "/bookAppointmenSchedulesView";
static const String bookAppointmentsItemView = "/bookAppointmentsItemView"; static const String bookAppointmentsItemView = "/bookAppointmentsItemView";
static const String reviewAppointmentView = "/reviewAppointmentView"; static const String reviewAppointmentView = "/reviewAppointmentView";
@ -83,12 +84,28 @@ class AppRoutes {
forgetPassword: (context) => const ForgetPasswordPage(), forgetPassword: (context) => const ForgetPasswordPage(),
loginVerification: (context) => const LoginVerificationPage(), loginVerification: (context) => const LoginVerificationPage(),
loginWithPassword: (context) => const LoginWithPassword(), loginWithPassword: (context) => const LoginWithPassword(),
loginMethodSelection: (context) => LoginMethodSelectionPage(ModalRoute.of(context)!.settings.arguments as String), loginMethodSelection: (context) =>
completeProfile: (context) => CompleteProfilePage(ModalRoute.of(context)!.settings.arguments as RegisterUserRespModel), LoginMethodSelectionPage(ModalRoute
.of(context)!
.settings
.arguments as String),
completeProfile: (context) =>
CompleteProfilePage(ModalRoute
.of(context)!
.settings
.arguments as RegisterUserRespModel),
verifyPassword: (context) => VerifyPasswordPage(), verifyPassword: (context) => VerifyPasswordPage(),
confirmNewPasswordPage: (context) => ConfirmNewPasswordPage(ModalRoute.of(context)!.settings.arguments as String), confirmNewPasswordPage: (context) =>
ConfirmNewPasswordPage(ModalRoute
.of(context)!
.settings
.arguments as String),
changePassword: (context) => const ChangePasswordPage(), changePassword: (context) => const ChangePasswordPage(),
forgetPasswordMethodPage: (context) => ForgetPasswordMethodPage(ModalRoute.of(context)!.settings.arguments as String), forgetPasswordMethodPage: (context) =>
ForgetPasswordMethodPage(ModalRoute
.of(context)!
.settings
.arguments as String),
changeMobilePage: (context) => ChangeMobilePage(), changeMobilePage: (context) => ChangeMobilePage(),
changeEmailPage: (context) => const ChangeEmailPage(), changeEmailPage: (context) => const ChangeEmailPage(),
editAccountPage: (context) => const EditAccountPage(), editAccountPage: (context) => const EditAccountPage(),

@ -206,6 +206,22 @@ extension AdPostEnum on int {
} }
} }
extension AppointmentEnum on int {
AppointmentStatusEnum toAppointmentStatusEnum() {
if (this == 1) {
return AppointmentStatusEnum.booked;
} else if (this == 2) {
return AppointmentStatusEnum.confirmed;
} else if (this == 3) {
return AppointmentStatusEnum.arrived;
} else if (this == 4) {
return AppointmentStatusEnum.cancelled;
} else {
return AppointmentStatusEnum.allAppointments;
}
}
}
extension AdPostStatusToInt on AdPostStatus { extension AdPostStatusToInt on AdPostStatus {
int getIdFromAdPostStatusEnum() { int getIdFromAdPostStatusEnum() {
switch (this) { switch (this) {
@ -246,6 +262,50 @@ extension AdPostStatusToInt on AdPostStatus {
} }
} }
extension PaymentTypesToInt on PaymentTypes {
int getIdFromPaymentTypesEnum() {
switch (this) {
case PaymentTypes.subscription:
return 1;
case PaymentTypes.appointment:
return 2;
case PaymentTypes.adReserve:
return 3;
case PaymentTypes.ads:
return 4;
case PaymentTypes.request:
return 5;
default:
return 0;
}
}
}
extension AppointmentStatusToInt on AppointmentStatusEnum {
int getIdFromAppointmentStatusEnum() {
switch (this) {
case AppointmentStatusEnum.booked:
return 1;
case AppointmentStatusEnum.confirmed:
return 2;
case AppointmentStatusEnum.arrived:
return 3;
case AppointmentStatusEnum.cancelled:
return 4;
default:
return -1;
}
}
}
extension CreatedByRoleEnumToInt on CreatedByRoleEnum { extension CreatedByRoleEnumToInt on CreatedByRoleEnum {
int getIdFromCreatedByRoleEnum() { int getIdFromCreatedByRoleEnum() {
switch (this) { switch (this) {
@ -390,3 +450,69 @@ extension VehicleAdTypeEnum on int {
} }
} }
} }
extension FormatMonthByName on int {
String getMonthNameByNumber() {
switch (this) {
case 1:
return "January";
case 2:
return "February";
case 3:
return "March";
case 4:
return "April";
case 5:
return "May";
case 6:
return "June";
case 7:
return "July";
case 8:
return "August";
case 9:
return "September";
case 10:
return "October";
case 11:
return "November";
case 12:
return "December";
default:
return "";
}
}
}
extension FormatMonthByNumber on String {
int getMonthNumberByName() {
switch (this) {
case "January":
return 1;
case "February":
return 2;
case "March":
return 3;
case "April":
return 4;
case "May":
return 5;
case "June":
return 6;
case "July":
return 7;
case "August":
return 8;
case "September":
return 9;
case "October":
return 10;
case "November":
return 11;
case "December":
return 12;
default:
return 1;
}
}
}

@ -1,3 +1,6 @@
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/utils/enums.dart';
class AppointmentListModel { class AppointmentListModel {
int? id; int? id;
int? serviceSlotID; int? serviceSlotID;
@ -9,28 +12,34 @@ class AppointmentListModel {
bool? isPaymentRequired; bool? isPaymentRequired;
int? paymentStatus; int? paymentStatus;
String? paymentStatusText; String? paymentStatusText;
String? customerName; String? customerName;
String? providerName; String? providerName;
String? duration; String? duration;
String? appointmentDate; String? appointmentDate;
AppointmentStatusEnum? appointmentStatusEnum;
List<ServiceAppointmentItems>? serviceAppointmentItems; List<ServiceAppointmentItems>? serviceAppointmentItems;
AppointmentListModel( AppointmentListModel(
{this.id, {this.id,
this.serviceSlotID, this.serviceSlotID,
this.appointmentStatusID, this.appointmentStatusID,
this.appointmentStatusText, this.appointmentStatusText,
this.serviceProviderID, this.serviceProviderID,
this.customerID, this.customerID,
this.isActive, this.isActive,
this.isPaymentRequired, this.isPaymentRequired,
this.paymentStatus, this.paymentStatus,
this.paymentStatusText, this.paymentStatusText,
this.customerName, this.customerName,
this.providerName, this.providerName,
this.duration, this.duration,
this.appointmentDate, this.appointmentDate,
this.serviceAppointmentItems}); this.serviceAppointmentItems});
@override
String toString() {
return 'AppointmentListModel{id: $id, serviceSlotID: $serviceSlotID, appointmentStatusID: $appointmentStatusID, appointmentStatusText: $appointmentStatusText, serviceProviderID: $serviceProviderID, customerID: $customerID, isActive: $isActive, isPaymentRequired: $isPaymentRequired, paymentStatus: $paymentStatus, paymentStatusText: $paymentStatusText, customerName: $customerName, providerName: $providerName, duration: $duration, appointmentDate: $appointmentDate, appointmentStatusEnum: $appointmentStatusEnum, serviceAppointmentItems: $serviceAppointmentItems}';
}
AppointmentListModel.fromJson(Map<String, dynamic> json) { AppointmentListModel.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
@ -47,6 +56,7 @@ class AppointmentListModel {
providerName = json['providerName']; providerName = json['providerName'];
duration = json['duration']; duration = json['duration'];
appointmentDate = json['appointmentDate']; appointmentDate = json['appointmentDate'];
appointmentStatusEnum = (json['appointmentStatusID'] as int).toAppointmentStatusEnum();
if (json['serviceAppointmentItems'] != null) { if (json['serviceAppointmentItems'] != null) {
serviceAppointmentItems = <ServiceAppointmentItems>[]; serviceAppointmentItems = <ServiceAppointmentItems>[];
json['serviceAppointmentItems'].forEach((v) { json['serviceAppointmentItems'].forEach((v) {
@ -54,29 +64,6 @@ class AppointmentListModel {
}); });
} }
} }
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['serviceSlotID'] = serviceSlotID;
data['appointmentStatusID'] = appointmentStatusID;
data['appointmentStatusText'] = appointmentStatusText;
data['serviceProviderID'] = serviceProviderID;
data['customerID'] = customerID;
data['isActive'] = isActive;
data['isPaymentRequired'] = isPaymentRequired;
data['paymentStatus'] = paymentStatus;
data['paymentStatusText'] = paymentStatusText;
data['customerName'] = customerName;
data['providerName'] = providerName;
data['duration'] = duration;
data['appointmentDate'] = appointmentDate;
if (serviceAppointmentItems != null) {
data['serviceAppointmentItems'] =
serviceAppointmentItems!.map((v) => v.toJson()).toList();
}
return data;
}
} }
class ServiceAppointmentItems { class ServiceAppointmentItems {
@ -85,11 +72,7 @@ class ServiceAppointmentItems {
String? serviceItemName; String? serviceItemName;
String? serviceItemDescription; String? serviceItemDescription;
ServiceAppointmentItems( ServiceAppointmentItems({this.id, this.serviceItemID, this.serviceItemName, this.serviceItemDescription});
{this.id,
this.serviceItemID,
this.serviceItemName,
this.serviceItemDescription});
ServiceAppointmentItems.fromJson(Map<String, dynamic> json) { ServiceAppointmentItems.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];

@ -1,5 +1,6 @@
import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/models/services/item_model.dart'; import 'package:mc_common_app/models/services/item_model.dart';
import 'package:mc_common_app/models/services/service_model.dart';
import 'package:mc_common_app/models/widgets_models.dart'; import 'package:mc_common_app/models/widgets_models.dart';
class CustomTimeDateSlotModel { class CustomTimeDateSlotModel {
@ -11,30 +12,25 @@ class CustomTimeDateSlotModel {
class ServiceAppointmentScheduleModel { class ServiceAppointmentScheduleModel {
List<ServiceSlotList>? serviceSlotList; List<ServiceSlotList>? serviceSlotList;
List<ItemData>? serviceItemList; List<ServiceModel>? servicesListInAppointment;
int? selectedDateIndex; int? selectedDateIndex;
// String? selectedTimeSlot;
// List<TimeSlotModel>? availableDates;
// List<TimeSlotModel>? availableTimeSlots;
List<CustomTimeDateSlotModel>? customTimeDateSlotList; List<CustomTimeDateSlotModel>? customTimeDateSlotList;
CustomTimeDateSlotModel? selectedCustomTimeDateSlotModel; CustomTimeDateSlotModel? selectedCustomTimeDateSlotModel;
double? amountToPay; double? amountToPay;
double? amountTotal; double? amountTotal;
double? amountRem; double? amountRem;
int? appointmentType;
ServiceAppointmentScheduleModel({ ServiceAppointmentScheduleModel({
this.serviceSlotList, this.serviceSlotList,
this.serviceItemList, this.servicesListInAppointment,
this.selectedDateIndex, this.selectedDateIndex,
// this.selectedTimeSlot,
// this.availableDates,
// this.availableTimeSlots,
this.customTimeDateSlotList, this.customTimeDateSlotList,
this.selectedCustomTimeDateSlotModel, this.selectedCustomTimeDateSlotModel,
this.amountToPay, this.amountToPay,
this.amountTotal, this.amountTotal,
this.amountRem, this.amountRem,
this.appointmentType,
}); });
List<CustomTimeDateSlotModel> getFormattedDateTimeSlotPackage() { List<CustomTimeDateSlotModel> getFormattedDateTimeSlotPackage() {
@ -55,7 +51,11 @@ class ServiceAppointmentScheduleModel {
List<TimeSlotModel> timeslots = []; List<TimeSlotModel> timeslots = [];
for (var element in serviceSlotList!) { for (var element in serviceSlotList!) {
if (element.slotDate == date) { if (element.slotDate == date) {
timeslots.add(TimeSlotModel(slotId: element.id!, slot: element.startTime!, date: element.slotDate!, isSelected: false, allowAppointment: element.bookAppointment! < element.allowAppointment!)); timeslots.add(TimeSlotModel(slotId: element.id!,
slot: element.startTime!,
date: element.slotDate!,
isSelected: false,
allowAppointment: element.bookAppointment! < element.allowAppointment!));
} }
} }
return timeslots; return timeslots;
@ -65,12 +65,13 @@ class ServiceAppointmentScheduleModel {
var seenSlots = <TimeSlotModel>{}; var seenSlots = <TimeSlotModel>{};
var slotTimeData = serviceSlotList! var slotTimeData = serviceSlotList!
.where((slot) => seenSlots.add(TimeSlotModel( .where((slot) =>
slot: slot.startTime!, seenSlots.add(TimeSlotModel(
slotId: slot.id!, slot: slot.startTime!,
isSelected: false, slotId: slot.id!,
date: slot.slotDate!.toFormattedDateWithoutTime(), isSelected: false,
))) date: slot.slotDate!.toFormattedDateWithoutTime(),
)))
.toList(); .toList();
List<TimeSlotModel> slotTime = []; List<TimeSlotModel> slotTime = [];
for (var element in slotTimeData) { for (var element in slotTimeData) {
@ -99,17 +100,19 @@ class ServiceAppointmentScheduleModel {
//TODO: I WILL START FROM HERE; I NEED TO ONLY PICK THE DISTINCT DATES FROM THE RESPONSE AND THEN BASED ON THE DATE SELECTION I WILL PICK THEIR SLOTS. //TODO: I WILL START FROM HERE; I NEED TO ONLY PICK THE DISTINCT DATES FROM THE RESPONSE AND THEN BASED ON THE DATE SELECTION I WILL PICK THEIR SLOTS.
//TODO: AFTER THAT, I WILL //TODO: AFTER THAT, I WILL
ServiceAppointmentScheduleModel.fromJson(Map<String, dynamic> json) { ServiceAppointmentScheduleModel.fromJson
(Map<String, dynamic> json, {bool isForAppointment = false}) {
if (json['serviceSlotList'] != null) { if (json['serviceSlotList'] != null) {
serviceSlotList = <ServiceSlotList>[]; serviceSlotList = <ServiceSlotList>[];
json['serviceSlotList'].forEach((v) { json['serviceSlotList'].forEach((v) {
serviceSlotList!.add(ServiceSlotList.fromJson(v)); serviceSlotList!.add(ServiceSlotList.fromJson(v));
}); });
} }
if (json['serviceItemList'] != null) { if (json['serviceList'] != null) {
serviceItemList = <ItemData>[]; servicesListInAppointment = <ServiceModel>[];
json['serviceItemList'].forEach((v) { json['serviceList'].forEach((v) {
serviceItemList!.add(ItemData.fromJson(v)); servicesListInAppointment!.add(ServiceModel.fromJson(v, isForAppointment: isForAppointment));
}); });
} }
customTimeDateSlotList = getFormattedDateTimeSlotPackage(); customTimeDateSlotList = getFormattedDateTimeSlotPackage();
@ -117,20 +120,7 @@ class ServiceAppointmentScheduleModel {
selectedDateIndex = null; selectedDateIndex = null;
amountTotal = json['amountTotal']; amountTotal = json['amountTotal'];
amountRem = json['amountRem']; amountRem = json['amountRem'];
} appointmentType = json['appointmentType'];
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (serviceSlotList != null) {
data['serviceSlotList'] = serviceSlotList!.map((v) => v.toJson()).toList();
}
if (serviceItemList != null) {
data['serviceItemList'] = serviceItemList!.map((v) => v.toJson()).toList();
}
data['amountToPay'] = amountToPay;
data['amountTotal'] = amountTotal;
data['amountRem'] = amountRem;
return data;
} }
} }
@ -152,23 +142,22 @@ class ServiceSlotList {
int? modifiedBy; int? modifiedBy;
String? modifiedOn; String? modifiedOn;
ServiceSlotList( ServiceSlotList({this.id,
{this.id, this.branchAppointmentScheduleID,
this.branchAppointmentScheduleID, this.branchAppointmentSchedule,
this.branchAppointmentSchedule, this.serviceProviderID,
this.serviceProviderID, this.slotDate,
this.slotDate, this.startTime,
this.startTime, this.endTime,
this.endTime, this.bookAppointment,
this.bookAppointment, this.allowAppointment,
this.allowAppointment, this.slotDurationMinute,
this.slotDurationMinute, this.appointmentType,
this.appointmentType, this.isActive,
this.isActive, this.createdBy,
this.createdBy, this.createdOn,
this.createdOn, this.modifiedBy,
this.modifiedBy, this.modifiedOn});
this.modifiedOn});
ServiceSlotList.fromJson(Map<String, dynamic> json) { ServiceSlotList.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];

@ -22,18 +22,18 @@ class ItemModel {
}); });
factory ItemModel.fromJson(Map<String, dynamic> json) => ItemModel( factory ItemModel.fromJson(Map<String, dynamic> json) => ItemModel(
messageStatus: json["messageStatus"], messageStatus: json["messageStatus"],
totalItemsCount: json["totalItemsCount"], totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? [] : List<ItemData>.from(json["data"]!.map((x) => ItemData.fromJson(x))), data: json["data"] == null ? [] : List<ItemData>.from(json["data"]!.map((x) => ItemData.fromJson(x))),
message: json["message"], message: json["message"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"messageStatus": messageStatus, "messageStatus": messageStatus,
"totalItemsCount": totalItemsCount, "totalItemsCount": totalItemsCount,
"data": data == null ? [] : List<dynamic>.from(data!.map((x) => x.toJson())), "data": data == null ? [] : List<dynamic>.from(data!.map((x) => x.toJson())),
"message": message, "message": message,
}; };
} }
class ItemData { class ItemData {
@ -52,6 +52,7 @@ class ItemData {
final bool? isAppointmentCustomerLoc; final bool? isAppointmentCustomerLoc;
final double? appointmentPricePercentage; final double? appointmentPricePercentage;
bool? isUpdateOrSelected; bool? isUpdateOrSelected;
bool? isHomeSelected;
ItemData({ ItemData({
this.id, this.id,
@ -69,37 +70,44 @@ class ItemData {
this.isAppointmentCustomerLoc, this.isAppointmentCustomerLoc,
this.appointmentPricePercentage, this.appointmentPricePercentage,
this.isUpdateOrSelected, this.isUpdateOrSelected,
this.isHomeSelected,
}); });
factory ItemData.fromJson(Map<String, dynamic> json) => ItemData( factory ItemData.fromJson(Map<String, dynamic> json) => ItemData(
id: json["id"], id: json["id"],
name: json["name"], name: json["name"],
price: json["price"].toString(), price: json["price"].toString(),
manufactureDate: json["manufactureDate"], manufactureDate: json["manufactureDate"],
description: json["description"], description: json["description"],
pictureUrl: json["pictureUrl"], pictureUrl: json["pictureUrl"],
companyId: json["companyID"], companyId: json["companyID"],
serviceProviderServiceId: json["serviceProviderServiceID"], serviceProviderServiceId: json["serviceProviderServiceID"],
serviceProviderServiceDescription: json["serviceProviderServiceDescription"], serviceProviderServiceDescription: json["serviceProviderServiceDescription"],
isActive: json["isActive"], isActive: json["isActive"],
isAllowAppointment: json["isAllowAppointment"], isAllowAppointment: json["isAllowAppointment"],
isAppointmentCompanyLoc: json["isAppointmentCompanyLoc"], isAppointmentCompanyLoc: json["isAppointmentCompanyLoc"],
isAppointmentCustomerLoc: json["isAppointmentCustomerLoc"], isAppointmentCustomerLoc: json["isAppointmentCustomerLoc"],
isUpdateOrSelected: false, isUpdateOrSelected: false,
); isHomeSelected: false,
);
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"id": id, "id": id,
"name": name, "name": name,
"price": price, "price": price,
"manufactureDate": manufactureDate, "manufactureDate": manufactureDate,
"description": description, "description": description,
"pictureUrl": pictureUrl, "pictureUrl": pictureUrl,
"companyID": companyId, "companyID": companyId,
"serviceProviderServiceID": serviceProviderServiceId, "serviceProviderServiceID": serviceProviderServiceId,
"isActive": isActive, "isActive": isActive,
"isAllowAppointment": isAllowAppointment, "isAllowAppointment": isAllowAppointment,
"isAppointmentCompanyLoc": isAppointmentCompanyLoc, "isAppointmentCompanyLoc": isAppointmentCompanyLoc,
"isAppointmentCustomerLoc": isAppointmentCustomerLoc, "isAppointmentCustomerLoc": isAppointmentCustomerLoc,
}; };
}
@override
String toString() {
return 'ItemData{id: $id, name: $name, price: $price, manufactureDate: $manufactureDate, description: $description, pictureUrl: $pictureUrl, companyId: $companyId, serviceProviderServiceId: $serviceProviderServiceId, serviceProviderServiceDescription: $serviceProviderServiceDescription, isActive: $isActive, isAllowAppointment: $isAllowAppointment, isAppointmentCompanyLoc: $isAppointmentCompanyLoc, isAppointmentCustomerLoc: $isAppointmentCustomerLoc, appointmentPricePercentage: $appointmentPricePercentage, isUpdateOrSelected: $isUpdateOrSelected}';
}
}

@ -19,6 +19,9 @@ class ServiceModel {
bool isExpandedOrSelected; bool isExpandedOrSelected;
int providerServiceId; int providerServiceId;
String providerServiceName; String providerServiceName;
bool isHomeSelected;
String homeLocation;
double currentTotalServicePrice;
ServiceModel({ ServiceModel({
this.serviceProviderServiceId, this.serviceProviderServiceId,
@ -36,13 +39,15 @@ class ServiceModel {
this.rangePricePerKm, this.rangePricePerKm,
this.itemsCount, this.itemsCount,
this.serviceItems, this.serviceItems,
this.isHomeSelected = false,
this.homeLocation = "",
this.currentTotalServicePrice = 0.0,
required this.isExpandedOrSelected, required this.isExpandedOrSelected,
required this.providerServiceId, required this.providerServiceId,
required this.providerServiceName, required this.providerServiceName,
}); });
factory ServiceModel.fromJson(Map<String, dynamic> json) => factory ServiceModel.fromJson(Map<String, dynamic> json, {bool isForAppointment = false}) => ServiceModel(
ServiceModel(
serviceProviderServiceId: json["serviceProviderServiceID"], serviceProviderServiceId: json["serviceProviderServiceID"],
providerServiceDescription: json["providerServiceDescription"], providerServiceDescription: json["providerServiceDescription"],
categoryId: json["categoryID"], categoryId: json["categoryID"],
@ -57,14 +62,21 @@ class ServiceModel {
customerLocationRange: json["customerLocationRange"], customerLocationRange: json["customerLocationRange"],
rangePricePerKm: json["rangePricePerKm"].toString(), rangePricePerKm: json["rangePricePerKm"].toString(),
itemsCount: json["itemsCount"], itemsCount: json["itemsCount"],
serviceItems: json["branchServiceItems"] == null ? [] : List<ItemData>.from(json["branchServiceItems"]!.map((x) => ItemData.fromJson(x))), serviceItems: isForAppointment
? json["serviceItemList"] == null
? []
: List<ItemData>.from(json["serviceItemList"]!.map((x) => ItemData.fromJson(x)))
: json["branchServiceItems"] == null
? []
: List<ItemData>.from(json["branchServiceItems"]!.map((x) => ItemData.fromJson(x))),
isExpandedOrSelected: false, isExpandedOrSelected: false,
providerServiceId: 0, providerServiceId: 0,
providerServiceName: "", providerServiceName: "",
isHomeSelected: false,
homeLocation: "",
); );
Map<String, dynamic> toJson() => Map<String, dynamic> toJson() => {
{
"serviceProviderServiceID": serviceProviderServiceId, "serviceProviderServiceID": serviceProviderServiceId,
"providerServiceDescription": providerServiceDescription, "providerServiceDescription": providerServiceDescription,
"categoryID": categoryId, "categoryID": categoryId,

@ -4,13 +4,16 @@ import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/services/my_in_app_browser.dart'; import 'package:mc_common_app/services/my_in_app_browser.dart';
import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/utils/utils.dart';
abstract class PaymentService { abstract class PaymentService {
Future<void> placeAdPayment({ Future<void> placePayment({
required int id, required int id,
required int paymentType, List<int>? appointmentIds,
required PaymentTypes paymentType,
required Function() onSuccess, required Function() onSuccess,
required Function() onFailure, required Function() onFailure,
}); });
@ -44,13 +47,39 @@ class PaymentServiceImp implements PaymentService {
} }
@override @override
Future<void> placeAdPayment({ Future<void> placePayment({
required int id, required int id,
required int paymentType, List<int>? appointmentIds,
required PaymentTypes paymentType,
required Function() onSuccess, required Function() onSuccess,
required Function() onFailure, required Function() onFailure,
}) async { }) async {
print("PaymentUrl: ${ApiConsts.paymentWebViewUrl}?PaymentType=$paymentType&AdsID=$id"); String urlRequest = "";
switch (paymentType) {
case PaymentTypes.subscription:
urlRequest = "";
break;
case PaymentTypes.appointment:
String appointIds = '';
for (var element in appointmentIds!) {
appointIds = "$appointIds$element:";
}
urlRequest = "${ApiConsts.paymentWebViewUrl}?PaymentType=${paymentType.getIdFromPaymentTypesEnum()}&AppointmentIDs=$appointIds";
break;
case PaymentTypes.adReserve:
urlRequest = "${ApiConsts.paymentWebViewUrl}?PaymentType=${paymentType.getIdFromPaymentTypesEnum()}&AdsID=$id";
break;
case PaymentTypes.ads:
urlRequest = "${ApiConsts.paymentWebViewUrl}?PaymentType=${paymentType.getIdFromPaymentTypesEnum()}&AdsID=$id";
break;
case PaymentTypes.request:
urlRequest = "";
break;
case PaymentTypes.extendAds:
urlRequest = "";
break;
}
print("PaymentUrl: $urlRequest");
myInAppBrowser = MyInAppBrowser(onExitCallback: () { myInAppBrowser = MyInAppBrowser(onExitCallback: () {
log("Browser Exited"); log("Browser Exited");
}, onLoadStartCallback: (String url) { }, onLoadStartCallback: (String url) {
@ -58,7 +87,7 @@ class PaymentServiceImp implements PaymentService {
onBrowserLoadStart(onFailure: onFailure, onSuccess: onSuccess, url: url); onBrowserLoadStart(onFailure: onFailure, onSuccess: onSuccess, url: url);
}); });
await myInAppBrowser!.openUrlRequest( await myInAppBrowser!.openUrlRequest(
urlRequest: URLRequest(url: Uri.parse("${ApiConsts.paymentWebViewUrl}?PaymentType=$paymentType&AdsID=$id")), urlRequest: URLRequest(url: Uri.parse(urlRequest)),
options: inAppBrowserOptions, options: inAppBrowserOptions,
); );
} }

@ -78,8 +78,8 @@ enum PaymentMethods {
enum PaymentTypes { enum PaymentTypes {
subscription, subscription,
appointment, appointment,
ads,
adReserve, adReserve,
ads,
request, request,
extendAds, extendAds,
} }
@ -141,3 +141,11 @@ enum BranchStatusEnum {
blocked, // 5 blocked, // 5
deactivated // 6 deactivated // 6
} }
enum AppointmentStatusEnum {
booked,
confirmed,
arrived,
cancelled,
allAppointments,
}

@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:mc_common_app/config/routes.dart'; import 'package:mc_common_app/config/routes.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/models/payment_models/pay_order_detail_resp_model.dart'; import 'package:mc_common_app/models/payment_models/pay_order_detail_resp_model.dart';
import 'package:mc_common_app/repositories/payments_repo.dart'; import 'package:mc_common_app/repositories/payments_repo.dart';
import 'package:mc_common_app/services/payments_service.dart'; import 'package:mc_common_app/services/payments_service.dart';
@ -49,29 +50,72 @@ class PaymentVM extends ChangeNotifier {
return; return;
} }
Future<void> placeThePayment({required int adId, required int paymentTypeId, required BuildContext context}) async { Future<void> onAdsPaymentSuccess({required BuildContext context, required int currentAdId, required int paymentTypeId}) async {
await paymentService.placeAdPayment( Utils.showLoading(context);
PayOrderDetailRespModel payOrderDetailRespModel = await paymentRepo.getPayOrderDetails(paymentId: paymentTypeId, adId: currentAdId);
await Future.delayed(const Duration(seconds: 2));
Utils.hideLoading(context);
print("payOrderDetailRespModel: ${payOrderDetailRespModel.toString()}");
if (payOrderDetailRespModel.isPaid == null || !payOrderDetailRespModel.isPaid!) {
Utils.showToast("Payment Failed!");
return;
}
if (payOrderDetailRespModel.isPaid != null && payOrderDetailRespModel.isPaid!) {
Utils.showToast("Payment Successful");
navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard);
}
}
Future<void> placeThePayment({required int adId, required PaymentTypes paymentTypeEnum, required BuildContext context}) async {
await paymentService.placePayment(
id: currentAdId, id: currentAdId,
paymentType: paymentTypeId, paymentType: paymentTypeEnum,
onFailure: () { onFailure: () {
Utils.showToast("Payment Failed!"); Utils.showToast("Payment Failed!");
switch (paymentTypeEnum) {
case PaymentTypes.subscription:
// TODO: Handle this case.
break;
case PaymentTypes.appointment:
// TODO: Handle this case.
break;
case PaymentTypes.adReserve:
// TODO: Handle this case.
break;
case PaymentTypes.ads:
// TODO: Handle this case.
break;
case PaymentTypes.request:
// TODO: Handle this case.
break;
case PaymentTypes.extendAds:
// TODO: Handle this case.
break;
}
}, },
onSuccess: () async { onSuccess: () async {
Utils.showLoading(context); switch (paymentTypeEnum) {
PayOrderDetailRespModel payOrderDetailRespModel = await paymentRepo.getPayOrderDetails(paymentId: paymentTypeId, adId: currentAdId); case PaymentTypes.subscription:
await Future.delayed(const Duration(seconds: 2)); // TODO: Handle this case.
Utils.hideLoading(context); break;
case PaymentTypes.appointment:
print("payOrderDetailRespModel: ${payOrderDetailRespModel.toString()}"); // TODO: Handle this case.
break;
if (payOrderDetailRespModel.isPaid == null || !payOrderDetailRespModel.isPaid!) { case PaymentTypes.adReserve:
Utils.showToast("Payment Failed!"); // TODO: Handle this case.
return; break;
} case PaymentTypes.ads:
await onAdsPaymentSuccess(context: context, paymentTypeId: paymentTypeEnum.getIdFromPaymentTypesEnum(), currentAdId: currentAdId);
if (payOrderDetailRespModel.isPaid != null && payOrderDetailRespModel.isPaid!) { break;
Utils.showToast("Payment Successful"); case PaymentTypes.request:
navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard); // TODO: Handle this case.
break;
case PaymentTypes.extendAds:
// TODO: Handle this case.
break;
} }
}, },
); );
@ -80,25 +124,26 @@ class PaymentVM extends ChangeNotifier {
Future<void> onVisaCardSelected(BuildContext context, PaymentTypes paymentType) async { Future<void> onVisaCardSelected(BuildContext context, PaymentTypes paymentType) async {
currentPaymentType = paymentType; currentPaymentType = paymentType;
switch (currentPaymentType) { switch (currentPaymentType) {
case PaymentTypes.appointment:
break;
case PaymentTypes.ads: case PaymentTypes.ads:
if (currentAdId == -1) return; if (currentAdId == -1) return;
int paymentType = 3;
await placeThePayment(adId: currentAdId, context: context, paymentTypeId: paymentType); await placeThePayment(adId: currentAdId, context: context, paymentTypeEnum: paymentType);
break; break;
case PaymentTypes.adReserve: case PaymentTypes.adReserve:
if (currentAdId == -1) return; if (currentAdId == -1) return;
int paymentType = 4;
await placeThePayment(adId: currentAdId, context: context, paymentTypeId: paymentType); await placeThePayment(adId: currentAdId, context: context, paymentTypeEnum: paymentType);
break; break;
case PaymentTypes.extendAds: case PaymentTypes.extendAds:
if (currentAdId == -1) return; if (currentAdId == -1) return;
int paymentType = 6;
await placeThePayment(adId: currentAdId, context: context, paymentTypeId: paymentType);
break;
await placeThePayment(adId: currentAdId, context: context, paymentTypeEnum: paymentType);
break;
case PaymentTypes.request: case PaymentTypes.request:
// TODO: Handle this case. // TODO: Handle this case.
@ -106,9 +151,6 @@ class PaymentVM extends ChangeNotifier {
case PaymentTypes.subscription: case PaymentTypes.subscription:
// TODO: Handle this case. // TODO: Handle this case.
break; break;
case PaymentTypes.appointment:
// TODO: Handle this case.
break;
} }
} }
} }

@ -649,7 +649,7 @@ class BuildAdDetailsActionButtonForMyAds extends StatelessWidget {
}); });
} }
Widget pendingForReviewAction(BuildContext context, {required bool isPendingPost}) { Widget pendingForReviewAction({required bool isPendingPost}) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
@ -881,10 +881,10 @@ class BuildAdDetailsActionButtonForMyAds extends StatelessWidget {
case AdPostStatus.rejected: case AdPostStatus.rejected:
case AdPostStatus.cancelled: case AdPostStatus.cancelled:
case AdPostStatus.pendingForPost: case AdPostStatus.pendingForPost:
return pendingForReviewAction(context, isPendingPost: true); return pendingForReviewAction(isPendingPost: true);
case AdPostStatus.pendingForReview: case AdPostStatus.pendingForReview:
return pendingForReviewAction(context, isPendingPost: false); return pendingForReviewAction(isPendingPost: false);
case AdPostStatus.sold: case AdPostStatus.sold:
case AdPostStatus.expired: case AdPostStatus.expired:

@ -26,8 +26,10 @@ class DropdownField extends StatefulWidget {
final List<DropValue>? list; final List<DropValue>? list;
final DropValue? dropdownValue; final DropValue? dropdownValue;
final Function(DropValue) onSelect; final Function(DropValue) onSelect;
final bool showAppointmentPickerVariant;
final TextStyle? textStyle;
const DropdownField(this.onSelect, {Key? key, this.hint, this.list, this.dropdownValue, this.errorValue = ""}) : super(key: key); const DropdownField(this.onSelect, {Key? key, this.hint, this.list, this.dropdownValue, this.errorValue = "", this.showAppointmentPickerVariant = false, this.textStyle}) : super(key: key);
@override @override
State<DropdownField> createState() => _DropdownFieldState(); State<DropdownField> createState() => _DropdownFieldState();
@ -43,7 +45,6 @@ class _DropdownFieldState extends State<DropdownField> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
} }
@override @override
@ -52,19 +53,20 @@ class _DropdownFieldState extends State<DropdownField> {
return Column( return Column(
children: [ children: [
Container( Container(
decoration: Utils.containerColorRadiusBorderWidth(MyColors.white, 0, MyColors.darkPrimaryColor, 2), decoration: widget.showAppointmentPickerVariant ? null : Utils.containerColorRadiusBorderWidth(MyColors.white, 0, MyColors.darkPrimaryColor, 2),
margin: const EdgeInsets.all(0), margin: const EdgeInsets.all(0),
padding: const EdgeInsets.only(left: 8, right: 8), // padding: const EdgeInsets.only(left: 0, right: ),
width: widget.showAppointmentPickerVariant ? 170 : null,
child: DropdownButton<DropValue>( child: DropdownButton<DropValue>(
value: dropdownValue, value: dropdownValue,
icon: const Icon(Icons.keyboard_arrow_down_sharp), icon: const Icon(Icons.keyboard_arrow_down_sharp),
elevation: 16, elevation: 16,
iconSize: 16, iconSize: widget.showAppointmentPickerVariant ? 26 : 16,
iconEnabledColor: borderColor, iconEnabledColor: borderColor,
iconDisabledColor: borderColor, iconDisabledColor: borderColor,
isExpanded: true, isExpanded: true,
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w600, fontSize: 15), style: widget.showAppointmentPickerVariant ? widget.textStyle : const TextStyle(color: Colors.black, fontWeight: FontWeight.w600, fontSize: 15),
hint: (widget.hint ?? "").toText(color: borderColor, fontSize: 15), hint: (widget.hint ?? "").toText(color: widget.showAppointmentPickerVariant ? Colors.black : borderColor, fontSize: widget.showAppointmentPickerVariant ? 18 : 15),
underline: Container(height: 0), underline: Container(height: 0),
onChanged: (DropValue? newValue) { onChanged: (DropValue? newValue) {
setState(() { setState(() {

Loading…
Cancel
Save