Application/medcify/lib/models/order_item.dart
2022-09-26 12:03:52 +05:30

61 lines
1.4 KiB
Dart

import 'dart:convert';
class OrderItem{
int? id;
dynamic amount;
dynamic discount;
dynamic total;
dynamic deliveryFee;
String? date;
OrderUser? user;
String? paymentStatus;
PrescriptionData? prescription;
OrderItem.fromJson(Map<String, dynamic> json){
id = json["id"] ?? 0;
amount = json["amount"] ?? 0;
discount = json["discount"] ?? 0;
total = json["total"] ?? 0;
deliveryFee = json["deliveryfee"] ?? 0;
date = json["createdAt"] ?? "";
int status = json["paymentMethod"] ?? "POD";
paymentStatus = getPaymentStatus(status);
user = (json["user"] != null) ? OrderUser.fromJson(json["user"]) : null;
prescription = (json["prescription"] != null) ? PrescriptionData.fromJson(json["prescription"]) : null;
}
String getPaymentStatus(int val){
if(val == 1){
return "POD";
}else if(val == 2){
return "UPI";
}else{
return "Self Pickup";
}
}
}
class PrescriptionData{
String? value;
PrescriptionData.fromJson(Map<String, dynamic> json){
value = json["prescription"] ?? "";
}
}
class OrderUser{
String? name;
String? mobile;
String? address;
String? address1;
dynamic pincode;
OrderUser.fromJson(Map<String, dynamic> json){
name = json["userName"] ?? "";
mobile = json["contactNumber"] ?? "---";
address = json["address"] ?? "---";
address1 = json["address1"] ?? "---";
pincode = json["pincode"] ?? "---";
}
}