backup. before shop update
This commit is contained in:
66
lib/models/Subproduct.dart
Normal file
66
lib/models/Subproduct.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_wisetronic/models/product_attribute.dart';
|
||||
|
||||
class Subproduct {
|
||||
int id;
|
||||
SimpleProduct product;
|
||||
double quantity;
|
||||
|
||||
Subproduct.fromJson(Map<String, dynamic> json) :
|
||||
id = json['id'],
|
||||
product = SimpleProduct.fromJson(json['product']),
|
||||
quantity = double.parse(json['quantity'].toString());
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'product': product,
|
||||
'quantity': quantity,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SimpleProduct {
|
||||
int id;
|
||||
String name;
|
||||
String sku;
|
||||
double price;
|
||||
String description;
|
||||
String image;
|
||||
List<ProductAttribute> productAttributes;
|
||||
double customerLastPrice;
|
||||
String extraData;
|
||||
|
||||
SimpleProduct.fromJson(Map<String, dynamic> json) :
|
||||
id = json['id'],
|
||||
name = json['name'],
|
||||
sku = json['sku'],
|
||||
price = double.parse(json['price'].toString()),
|
||||
description = json['description'],
|
||||
image = json['image'],
|
||||
productAttributes = (json['productattributes'] as List).map((i) => ProductAttribute.fromJson(i)).toList(),
|
||||
customerLastPrice = double.parse(json['customer_last_price'].toString()),
|
||||
extraData = json['extra_data'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'sku': sku,
|
||||
'price': price,
|
||||
'description': description,
|
||||
'image': image,
|
||||
'productattributes': productAttributes,
|
||||
'customer_last_price': customerLastPrice,
|
||||
'extra_data': extraData,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
59
lib/models/address.dart
Normal file
59
lib/models/address.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Address {
|
||||
int id;
|
||||
String addressLine1;
|
||||
String addressLine2;
|
||||
String city;
|
||||
String state;
|
||||
String country;
|
||||
String zip;
|
||||
String phone;
|
||||
String fax;
|
||||
String email;
|
||||
String contactName;
|
||||
int gender;
|
||||
String lat;
|
||||
String lng;
|
||||
String fullAddress;
|
||||
|
||||
Address.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
addressLine1 = json['address_line1'],
|
||||
addressLine2 = json['address_line2'],
|
||||
city = json['city'],
|
||||
state = json['state'],
|
||||
country = json['country'],
|
||||
zip = json['zip'],
|
||||
phone = json['phone'],
|
||||
fax = json['fax'],
|
||||
email = json['email'],
|
||||
contactName = json['name'],
|
||||
gender = json['gender'],
|
||||
lat = json['lat'],
|
||||
lng = json['lng'],
|
||||
fullAddress = json['full_address'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'address_line1': addressLine1,
|
||||
'address_line2': addressLine2,
|
||||
'city': city,
|
||||
'state': state,
|
||||
'country': country,
|
||||
'zip': zip,
|
||||
'phone': phone,
|
||||
'fax': fax,
|
||||
'email': email,
|
||||
'name': contactName,
|
||||
'gender': gender,
|
||||
'lat': lat,
|
||||
'lng': lng,
|
||||
'full_address': fullAddress,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
58
lib/models/blog.dart
Normal file
58
lib/models/blog.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class Section {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
Section.fromJson(Map<String, dynamic> json) :
|
||||
id = json['id'],
|
||||
name = json['name'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class Blog {
|
||||
int id;
|
||||
String title;
|
||||
String body;
|
||||
String createdAt;
|
||||
String thumbUrl;
|
||||
String imageUrl;
|
||||
String videoUrl;
|
||||
Section section;
|
||||
|
||||
Blog.fromJson(Map<String, dynamic> json) :
|
||||
id = json['id'],
|
||||
title = json['title'],
|
||||
body = json['body'],
|
||||
createdAt = json['created_at'],
|
||||
thumbUrl = json['thumb_url'],
|
||||
imageUrl = json['image_url'],
|
||||
videoUrl = json['video_url'],
|
||||
section = Section.fromJson(json['section']);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'body': body,
|
||||
'created_at': createdAt,
|
||||
'thumb_url': thumbUrl,
|
||||
'image_url': imageUrl,
|
||||
'video_url': videoUrl,
|
||||
'section': section,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
32
lib/models/booking_date_time.dart
Normal file
32
lib/models/booking_date_time.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'booking_time.dart';
|
||||
|
||||
class BookingDateTime {
|
||||
String viewDate;
|
||||
int unixTime;
|
||||
String sendTimeTip;
|
||||
List<BookingTime> bookTimes;
|
||||
|
||||
BookingDateTime(this.viewDate, this.unixTime, this.sendTimeTip, this.bookTimes);
|
||||
|
||||
BookingDateTime.fromJson(Map<String, dynamic> json)
|
||||
: viewDate = json['view_date'],
|
||||
unixTime = int.parse(json['unix_time'].toString()),
|
||||
sendTimeTip = json['send_time_tip'],
|
||||
bookTimes = (json['book_times'] as List).map((e) => BookingTime.fromJson(e)).toList();
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'view_date': viewDate,
|
||||
'unix_time': unixTime,
|
||||
'send_time_tip': sendTimeTip,
|
||||
'book_times': bookTimes,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
|
||||
}
|
||||
27
lib/models/booking_time.dart
Normal file
27
lib/models/booking_time.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class BookingTime {
|
||||
String viewTime;
|
||||
int unixTime;
|
||||
String sendTimeTip;
|
||||
|
||||
BookingTime(this.viewTime, this.unixTime, this.sendTimeTip);
|
||||
|
||||
BookingTime.fromJson(Map<String, dynamic> json)
|
||||
: viewTime = json['view_time'],
|
||||
unixTime = int.parse(json['unix_time'].toString()),
|
||||
sendTimeTip = json['send_time_tip'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'view_time': viewTime,
|
||||
'unix_time': unixTime,
|
||||
'send_time_tip': sendTimeTip,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
|
||||
}
|
||||
164
lib/models/business.dart
Normal file
164
lib/models/business.dart
Normal file
@@ -0,0 +1,164 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'address.dart';
|
||||
import 'business_time.dart';
|
||||
import 'distance_info.dart';
|
||||
import 'image_url.dart';
|
||||
import 'product.dart';
|
||||
import 'waiting_line.dart';
|
||||
|
||||
class QuickInput {
|
||||
String value;
|
||||
QuickInput.fromJson(Map<String, dynamic> json)
|
||||
: value = json['value'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'value': value
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class Business {
|
||||
int id;
|
||||
String name;
|
||||
String phone;
|
||||
Address address;
|
||||
String fullAddress;
|
||||
String picUrl;
|
||||
int status;
|
||||
List<BusinessTime> openingTime;
|
||||
double shippingFee;
|
||||
double packageFee;
|
||||
double minPrice;
|
||||
int shippingTime;
|
||||
int monthSales;
|
||||
String bulletin;
|
||||
int category;
|
||||
bool isLike;
|
||||
String description;
|
||||
String policy;
|
||||
String bannerImageUrl;
|
||||
int todayOpen;
|
||||
int todayClose;
|
||||
bool showMonthlySold;
|
||||
List<ImageUrl> slideImages;
|
||||
List<Product> promoProducts;
|
||||
String paypalEmail;
|
||||
bool deliveryCanadaPost;
|
||||
bool deliveryStoreDelivery;
|
||||
bool deliveryPickup;
|
||||
String currency;
|
||||
List<WaitingLine> waitingLine;
|
||||
bool enableWaitingLine;
|
||||
double pointsToCreditsConversionRate;
|
||||
String chaseXLogin;
|
||||
String chaseTransactionKey;
|
||||
String chaseResponseKey;
|
||||
DistanceInfo distanceInfo;
|
||||
int commentsCount;
|
||||
bool forceClose;
|
||||
bool isPublic;
|
||||
double referrerCoupon;
|
||||
bool instanceDelivery;
|
||||
List<QuickInput> quickInputs;
|
||||
|
||||
Business.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
name = json['name'],
|
||||
phone = json['phone'],
|
||||
address = Address.fromJson(json['address']),
|
||||
fullAddress = json['full_address'],
|
||||
picUrl = json['pic_url'],
|
||||
status = json['status'],
|
||||
openingTime = (json['opening_time'] as List).map((i) => BusinessTime.fromJson(i)).toList(),
|
||||
shippingFee = double.parse(json['shipping_fee'].toString()),
|
||||
packageFee = double.parse(json['package_fee'].toString()),
|
||||
minPrice = double.parse(json['min_price'].toString()),
|
||||
shippingTime = json['shipping_time'],
|
||||
monthSales = json['month_sales'],
|
||||
bulletin = json['bulletin'],
|
||||
category = json['category'],
|
||||
isLike = json['is_like'],
|
||||
description = json['description'],
|
||||
policy = json['policy'],
|
||||
bannerImageUrl = json['banner_image_url'],
|
||||
todayOpen = json['today_open'],
|
||||
todayClose = json['today_close'],
|
||||
showMonthlySold = json['show_monthly_sold'],
|
||||
slideImages = (json['slide_images'] as List).map((i) => ImageUrl.fromJson(i)).toList(),
|
||||
promoProducts = (json['promo_products'] as List).map((i) => Product.fromJson(i)).toList(),
|
||||
paypalEmail = json['paypal_email'],
|
||||
deliveryCanadaPost = json['delivery_canada_post'],
|
||||
deliveryStoreDelivery = json['delivery_store_delivery'],
|
||||
deliveryPickup = json['delivery_pickup'],
|
||||
currency = json['currency'],
|
||||
|
||||
waitingLine = (json['waiting_line'] as List).map((i) => WaitingLine.fromJson(i)).toList(),
|
||||
|
||||
enableWaitingLine = json['enable_waiting_line'],
|
||||
pointsToCreditsConversionRate = double.parse(json['points_to_credits_conversion_rate'].toString()),
|
||||
chaseXLogin = json['chase_x_login'],
|
||||
chaseTransactionKey = json['chase_transaction_key'],
|
||||
chaseResponseKey = json['chase_response_key'],
|
||||
distanceInfo = json['distance_info'] != null ? DistanceInfo.fromJson(json['distance_info']) : null,
|
||||
commentsCount = json['comments_count'],
|
||||
forceClose = json['force_close'],
|
||||
isPublic = json['is_public'],
|
||||
referrerCoupon = double.parse(json['customer_referrer_coupon_amount'].toString()),
|
||||
instanceDelivery = json['instance_delivery'],
|
||||
quickInputs = (json['quick_inputs'] as List).map((i) => QuickInput.fromJson(i)).toList();
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'phone': phone,
|
||||
'address': address,
|
||||
'full_address': fullAddress,
|
||||
'pic_url': picUrl,
|
||||
'status': status,
|
||||
'opening_time': openingTime,
|
||||
'shipping_fee': shippingFee,
|
||||
'package_fee': packageFee,
|
||||
'min_price': minPrice,
|
||||
'shipping_time': shippingTime,
|
||||
'month_sales': monthSales,
|
||||
'bulletin': bulletin,
|
||||
'category': category,
|
||||
'is_like': isLike,
|
||||
'description': description,
|
||||
'policy': policy,
|
||||
'banner_image_url': bannerImageUrl,
|
||||
'today_open': todayOpen,
|
||||
'today_close': todayClose,
|
||||
'show_monthly_sold': showMonthlySold,
|
||||
'slide_images': slideImages,
|
||||
'promo_products': promoProducts,
|
||||
'paypal_email': paypalEmail,
|
||||
'delivery_canada_post': deliveryCanadaPost,
|
||||
'delivery_store_delivery': deliveryStoreDelivery,
|
||||
'delivery_pickup': deliveryPickup,
|
||||
'currency': currency,
|
||||
'waiting_line': waitingLine,
|
||||
'enable_waiting_line': enableWaitingLine,
|
||||
'points_to_credits_conversion_rate': pointsToCreditsConversionRate,
|
||||
'chase_x_login': chaseXLogin,
|
||||
'chase_transaction_key': chaseTransactionKey,
|
||||
'chase_response_key': chaseResponseKey,
|
||||
'distance_info': distanceInfo,
|
||||
'comments_count': commentsCount,
|
||||
'force_close': forceClose,
|
||||
'is_public': isPublic,
|
||||
'customer_referrer_coupon_amount': referrerCoupon,
|
||||
'instance_delivery': instanceDelivery,
|
||||
'quick_inputs': quickInputs
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
20
lib/models/business_time.dart
Normal file
20
lib/models/business_time.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class BusinessTime {
|
||||
String openTime;
|
||||
String closeTime;
|
||||
|
||||
BusinessTime.fromJson(Map<String, dynamic> json)
|
||||
: openTime = json['open_time'],
|
||||
closeTime = json['close_time'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'open_time': openTime,
|
||||
'close_time': closeTime
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
94
lib/models/cart_info.dart
Normal file
94
lib/models/cart_info.dart
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'business.dart';
|
||||
import 'cart_line_item.dart';
|
||||
import 'extra_fee.dart';
|
||||
|
||||
class CartInfo {
|
||||
int id;
|
||||
double originPrice;
|
||||
double discountPrice;
|
||||
double totalPrice;
|
||||
Business businessInfo;
|
||||
List<CartLineItem> productList;
|
||||
List<ExtraFee> extraFeeList;
|
||||
List<ExtraFee> discountList;
|
||||
int deliveryMethod;
|
||||
String shippingMethod;
|
||||
double amountPaid;
|
||||
String extraData;
|
||||
|
||||
CartInfo.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
originPrice = json['origin_price'] != null ? double.parse(json['origin_price'].toString()) : 0.0,
|
||||
discountPrice = json['discount_price'] != null ? double.parse(json['discount_price'].toString()) : 0.0,
|
||||
totalPrice = json['total_price'] != null ? double.parse(json['total_price'].toString()) : 0.0,
|
||||
businessInfo = json['business_info'] != null ? Business.fromJson(json['business_info']) : null,
|
||||
productList = (json['product_list'] as List).map((i) => CartLineItem.fromJson(i)).toList(),
|
||||
extraFeeList = (json['extra_fee_list'] as List).map((i) => ExtraFee.fromJson(i)).toList(),
|
||||
discountList = (json['discount_list'] as List).map((e) => ExtraFee.fromJson(e)).toList(),
|
||||
deliveryMethod = json['delivery_method'],
|
||||
shippingMethod = json['shipping_method'],
|
||||
amountPaid = double.parse(json['amount_paid'].toString()),
|
||||
extraData = json['extra_data'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'origin_price': originPrice,
|
||||
'discount_price': discountPrice,
|
||||
'total_price': totalPrice,
|
||||
'business_info': businessInfo,
|
||||
'product_list': productList,
|
||||
'extra_fee_list': extraFeeList,
|
||||
'discount_list': discountList,
|
||||
'delivery_method': deliveryMethod,
|
||||
'shipping_method': shippingMethod,
|
||||
'amount_paid': amountPaid,
|
||||
'extra_data': extraData,
|
||||
};
|
||||
|
||||
addToCart(CartLineItem item) {
|
||||
if (productList == null) {
|
||||
productList = [item];
|
||||
} else {
|
||||
productList.add(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
removeFromCart() {
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
|
||||
CartInfo();
|
||||
|
||||
double getTotalPrice() {
|
||||
double newTotal = 0.0;
|
||||
originPrice = 0.0;
|
||||
discountPrice = 0.0;
|
||||
totalPrice = 0.0;
|
||||
for (var i = 0; i < productList.length; i++) {
|
||||
newTotal += productList[i].getTotalPrice();
|
||||
}
|
||||
originPrice = newTotal;
|
||||
totalPrice = newTotal;
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
int getProductListTotalQuantity() {
|
||||
int qty = 0;
|
||||
if (productList != null && productList.length > 0) {
|
||||
for (var i = 0; i < productList.length; i++) {
|
||||
qty += productList[i].quantity.round();
|
||||
}
|
||||
}
|
||||
return qty;
|
||||
}
|
||||
}
|
||||
54
lib/models/cart_line_item.dart
Normal file
54
lib/models/cart_line_item.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import 'product.dart';
|
||||
|
||||
class CartLineItem {
|
||||
int id;
|
||||
double unitPrice;
|
||||
double totalPrice;
|
||||
Product product;
|
||||
String name;
|
||||
String description;
|
||||
double quantity;
|
||||
String uuid;
|
||||
String parentUuid;
|
||||
|
||||
CartLineItem() {
|
||||
uuid = Uuid().v4();
|
||||
}
|
||||
|
||||
CartLineItem.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
unitPrice = double.parse(json['unit_price'].toString()),
|
||||
totalPrice = json['total_price'] != null ? double.parse(json['total_price'].toString()) : double.parse(json['unit_price'].toString()) * double.parse(json['quantity'].toString()),
|
||||
product = json['product'] != null ? Product.fromJson(json['product']) : null,
|
||||
name = json['name'],
|
||||
description = json['description'],
|
||||
quantity = double.parse(json['quantity'].toString()),
|
||||
uuid = Uuid().v4();
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'unit_price': unitPrice,
|
||||
'total_price': totalPrice,
|
||||
'product': product,
|
||||
'name': name,
|
||||
'description': description,
|
||||
'quantity': quantity,
|
||||
'uuid': uuid,
|
||||
'parentUuid': parentUuid
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
|
||||
double getTotalPrice() {
|
||||
totalPrice = unitPrice * quantity;
|
||||
return totalPrice;
|
||||
}
|
||||
}
|
||||
21
lib/models/category.dart
Normal file
21
lib/models/category.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class Category {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
Category.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
name = json['name'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
38
lib/models/category_products.dart
Normal file
38
lib/models/category_products.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'product.dart';
|
||||
|
||||
class CategoryProducts {
|
||||
int id;
|
||||
int businessId;
|
||||
String name;
|
||||
String description;
|
||||
String iconUrl;
|
||||
List<Product> products;
|
||||
|
||||
CategoryProducts.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
businessId = json['business_id'],
|
||||
name = json['name'],
|
||||
description = json['description'],
|
||||
iconUrl = json['icon_url'],
|
||||
products = (json['products'] as List).map((i) => Product.fromJson(i)).toList();
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'business_id': businessId,
|
||||
'name': name,
|
||||
'description': description,
|
||||
'icon_url': iconUrl,
|
||||
'products': products
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
|
||||
CategoryProducts(this.id, this.businessId, this.name, this.description,
|
||||
this.iconUrl, this.products);
|
||||
}
|
||||
44
lib/models/comment.dart
Normal file
44
lib/models/comment.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'product_image.dart';
|
||||
|
||||
class Comment {
|
||||
int id;
|
||||
String contact;
|
||||
String content;
|
||||
int rating;
|
||||
List<ProductImage> images;
|
||||
String createdAt;
|
||||
int thumbUp;
|
||||
int thumbDown;
|
||||
String replyFromStore;
|
||||
|
||||
Comment.fromJson(Map<String, dynamic> json) :
|
||||
id = json['id'],
|
||||
contact = json['contact'],
|
||||
content = json['content'],
|
||||
rating = json['rating'],
|
||||
images = (json['images'] as List).map((e) => ProductImage.fromJson(e)).toList(),
|
||||
createdAt = json['created_at'],
|
||||
thumbUp = json['thumb_up'],
|
||||
thumbDown = json['thumb_down'],
|
||||
replyFromStore = json['reply_from_store'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'contact': contact,
|
||||
'content': content,
|
||||
'rating': rating,
|
||||
'images': images,
|
||||
'created_at': createdAt,
|
||||
'thumb_up': thumbUp,
|
||||
'thumb_down': thumbDown,
|
||||
'reply_from_store': replyFromStore,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
41
lib/models/coupon.dart
Normal file
41
lib/models/coupon.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'business.dart';
|
||||
|
||||
class Coupon {
|
||||
int id;
|
||||
String code;
|
||||
String description;
|
||||
String expirationDate;
|
||||
double minAmount;
|
||||
Business store;
|
||||
double valueAmount;
|
||||
bool isPercentage;
|
||||
|
||||
Coupon.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
code = json['code'].toString(),
|
||||
description = json['description'],
|
||||
expirationDate = json['expiration_date'],
|
||||
minAmount = double.parse(json['min_amount'].toString()),
|
||||
store = json['store'] != null ? Business.fromJson(json['store']) : null,
|
||||
valueAmount = double.parse(json['value_amount'].toString()),
|
||||
isPercentage = json['is_percentage'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'code': code,
|
||||
'description': description,
|
||||
'expiration_date': expirationDate,
|
||||
'min_amount': minAmount,
|
||||
'store': store,
|
||||
'value_amount': valueAmount,
|
||||
'is_percentage': isPercentage,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
26
lib/models/distance_info.dart
Normal file
26
lib/models/distance_info.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'text_value.dart';
|
||||
|
||||
class DistanceInfo {
|
||||
TextValue duration;
|
||||
TextValue distance;
|
||||
String status;
|
||||
|
||||
DistanceInfo.fromJson(Map<String, dynamic> json)
|
||||
: duration = json['duration'] != null ? TextValue.fromJson(json['duration']) : null,
|
||||
distance = json['distance'] != null ? TextValue.fromJson(json['distance']) : null,
|
||||
status = json['status'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'duration': duration,
|
||||
'distance': distance,
|
||||
'status': status
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
21
lib/models/error_message.dart
Normal file
21
lib/models/error_message.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class ErrorMessage {
|
||||
String code;
|
||||
String string;
|
||||
|
||||
ErrorMessage.fromJson(Map<String, dynamic> json)
|
||||
: code = json['code'],
|
||||
string = json['string'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'code': code,
|
||||
'string': string,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
31
lib/models/extra_fee.dart
Normal file
31
lib/models/extra_fee.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class ExtraFee {
|
||||
int id;
|
||||
String name;
|
||||
String description;
|
||||
double rate;
|
||||
double price;
|
||||
|
||||
ExtraFee.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
name = json['name'],
|
||||
description = json['description'],
|
||||
rate = double.parse(json['rate'].toString()),
|
||||
price = double.parse(json['price'].toString());
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'description': description,
|
||||
'rate': rate,
|
||||
'price': price,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
30
lib/models/fulfillment.dart
Normal file
30
lib/models/fulfillment.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class Fulfillment {
|
||||
int id;
|
||||
String shippingMethod;
|
||||
String trackingNumber;
|
||||
String note;
|
||||
String createdAt;
|
||||
|
||||
Fulfillment.fromJson(Map<String, dynamic> json) :
|
||||
id = json['id'],
|
||||
shippingMethod = json['shipping_method'],
|
||||
trackingNumber = json['tracking_number'],
|
||||
note = json['note'],
|
||||
createdAt = json['created_at'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'shipping_method': shippingMethod,
|
||||
'tracking_number': trackingNumber,
|
||||
'note': note,
|
||||
'created_at': createdAt,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
20
lib/models/image_url.dart
Normal file
20
lib/models/image_url.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class ImageUrl {
|
||||
int id;
|
||||
String imageUrl;
|
||||
|
||||
ImageUrl.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
imageUrl = json['image_url'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'image_url': imageUrl
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
12
lib/models/key_value.dart
Normal file
12
lib/models/key_value.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
class KeyValue {
|
||||
String name;
|
||||
dynamic value;
|
||||
|
||||
KeyValue(this.name, this.value);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '$name: $value';
|
||||
}
|
||||
}
|
||||
47
lib/models/located_address.dart
Normal file
47
lib/models/located_address.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class LocatedAddress {
|
||||
int storeId;
|
||||
double latitude;
|
||||
double longitude;
|
||||
String streetNumber;
|
||||
String streetName;
|
||||
String city;
|
||||
String locality;
|
||||
String province;
|
||||
String country;
|
||||
String postalCode;
|
||||
String formattedAddress;
|
||||
|
||||
LocatedAddress.fromJson(Map<String, dynamic> json)
|
||||
: storeId = json['store_id'],
|
||||
latitude = json['latitude'],
|
||||
longitude = json['longitude'],
|
||||
streetNumber = json['street_number'],
|
||||
streetName = json['street_name'],
|
||||
city = json['city'],
|
||||
locality = json['locality'],
|
||||
province = json['province'],
|
||||
country = json['country'],
|
||||
postalCode = json['postal_code'],
|
||||
formattedAddress = json['formatted_address'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'store_id': storeId,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'street_number': streetNumber,
|
||||
'street_name': streetName,
|
||||
'city': city,
|
||||
'locality': locality,
|
||||
'province': province,
|
||||
'country': country,
|
||||
'postal_code': postalCode,
|
||||
'formatted_address': formattedAddress
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
113
lib/models/order.dart
Normal file
113
lib/models/order.dart
Normal file
@@ -0,0 +1,113 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'address.dart';
|
||||
import 'business.dart';
|
||||
import 'cart_info.dart';
|
||||
import 'cart_line_item.dart';
|
||||
import 'distance_info.dart';
|
||||
import 'fulfillment.dart';
|
||||
import 'user_position.dart';
|
||||
|
||||
class Order {
|
||||
int id;
|
||||
int userId;
|
||||
int businessId;
|
||||
Business businessInfo;
|
||||
CartInfo cartInfo;
|
||||
int status;
|
||||
double originPrice;
|
||||
double discountPrice;
|
||||
double totalPrice;
|
||||
String consignee;
|
||||
String phone;
|
||||
String address;
|
||||
Address shippingAddress;
|
||||
int payMethod;
|
||||
String remark;
|
||||
String orderNum;
|
||||
int bookedAt;
|
||||
int createdAt;
|
||||
String shippingMethod;
|
||||
String paymentStatus; // UNPAID, PAID, PARTIALPAID
|
||||
double amountPaid;
|
||||
List<Fulfillment> fulfillments;
|
||||
String extraData;
|
||||
bool hasComment;
|
||||
double fee;
|
||||
UserPosition shipperPosition;
|
||||
DistanceInfo deliveryDistance;
|
||||
|
||||
Order.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
userId = json['user_id'],
|
||||
businessId = json['business_id'],
|
||||
businessInfo = json['business_info'] != null ? Business.fromJson(json['business_info']) : null,
|
||||
cartInfo = json['cart_info'] != null ? CartInfo.fromJson(json['cart_info']) : null,
|
||||
status = json['status'],
|
||||
originPrice = double.parse(json['origin_price'].toString()),
|
||||
discountPrice = double.parse(json['discount_price'].toString()),
|
||||
totalPrice = double.parse(json['total_price'].toString()),
|
||||
consignee = json['consignee'],
|
||||
phone = json['phone'],
|
||||
address = json['address'],
|
||||
shippingAddress = (json['shipping_address'] != null) ? Address.fromJson(json['shipping_address']) : null,
|
||||
payMethod = json['pay_method'],
|
||||
remark = json['remark'],
|
||||
orderNum = json['order_num'],
|
||||
bookedAt = int.parse(json['booked_at'].toString()),
|
||||
createdAt = int.parse(json['created_at'].toString()),
|
||||
shippingMethod = json['shipping_method'],
|
||||
paymentStatus = json['payment_status'],
|
||||
amountPaid = double.parse(json['amount_paid'].toString()),
|
||||
fulfillments = (json['fulfillments'] as List).map((e) => Fulfillment.fromJson(e)).toList(),
|
||||
extraData = json['extra_data'],
|
||||
hasComment = json['has_comment'],
|
||||
fee = double.parse(json['fee'].toString()),
|
||||
shipperPosition = UserPosition.fromJson(json['shipper_position']),
|
||||
deliveryDistance = DistanceInfo.fromJson(json['delivery_distance']);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'user_id': userId,
|
||||
'business_id': businessId,
|
||||
'business_info': businessInfo,
|
||||
'cart_info': cartInfo,
|
||||
'status': status,
|
||||
'origin_price': originPrice,
|
||||
'discount_price': discountPrice,
|
||||
'total_price': totalPrice,
|
||||
'consignee': consignee,
|
||||
'phone': phone,
|
||||
'address': address,
|
||||
'shipping_address': shippingAddress,
|
||||
'pay_method': payMethod,
|
||||
'remark': remark,
|
||||
'order_num': orderNum,
|
||||
'booked_at': bookedAt,
|
||||
'created_at': createdAt,
|
||||
'shipping_method': shippingMethod,
|
||||
'payment_status': paymentStatus,
|
||||
'amount_paid': amountPaid,
|
||||
'fulfillments': fulfillments,
|
||||
'extra_data': extraData,
|
||||
'has_comment': hasComment,
|
||||
'fee': fee,
|
||||
'shipper_position': shipperPosition,
|
||||
'delivery_distance': deliveryDistance,
|
||||
};
|
||||
|
||||
double getSubtotal() {
|
||||
double subtotal = 0.0;
|
||||
for (CartLineItem lineItem in cartInfo.productList) {
|
||||
subtotal += lineItem.getTotalPrice();
|
||||
}
|
||||
return subtotal;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
10
lib/models/order_status.dart
Normal file
10
lib/models/order_status.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
enum OrderStatus {
|
||||
WAIT_FOR_SUBMISSION, // -1
|
||||
WAIT_FOR_PAYMENT, // 0
|
||||
WAIT_FOR_APPROVAL, // 1
|
||||
WAIT_FOR_DELIVERY, // 2
|
||||
WAIT_FOR_ARRIVAL, // 3
|
||||
RECEIVED_CONFIRMATION, // 4
|
||||
DONE // 5
|
||||
}
|
||||
5
lib/models/payment_method.dart
Normal file
5
lib/models/payment_method.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
enum PaymentMethod {
|
||||
ONLINE, // 1
|
||||
OFFLINE // 0
|
||||
}
|
||||
85
lib/models/payment_platform.dart
Normal file
85
lib/models/payment_platform.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import '../generated/l10n.dart';
|
||||
|
||||
class PaymentPlatform {
|
||||
int id;
|
||||
String name;
|
||||
String code;
|
||||
String method;
|
||||
String icon;
|
||||
String xLogin;
|
||||
String transactionKey;
|
||||
String responseKey;
|
||||
String squareAppId;
|
||||
String squareAccessToken;
|
||||
String squareLocationId;
|
||||
String publishableKey;
|
||||
String merchantId;
|
||||
|
||||
PaymentPlatform(this.code);
|
||||
|
||||
PaymentPlatform.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
name = json['name'],
|
||||
code = json['code'],
|
||||
method = json['method'],
|
||||
icon = json['icon'],
|
||||
xLogin = json['x_login'],
|
||||
transactionKey = json['transaction_key'],
|
||||
responseKey = json['response_key'],
|
||||
squareAppId = json['square_app_id'],
|
||||
squareAccessToken = json['square_access_token'],
|
||||
squareLocationId = json['square_location_id'],
|
||||
publishableKey = json['publishable_key'],
|
||||
merchantId = json['merchant_id'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'code': code,
|
||||
'method': method,
|
||||
'icon': icon,
|
||||
'x_login': xLogin,
|
||||
'transaction_key': transactionKey,
|
||||
'response_key': responseKey,
|
||||
'square_app_id': squareAppId,
|
||||
'square_access_token': squareAccessToken,
|
||||
'square_location_id': squareLocationId,
|
||||
'publishable_key': publishableKey,
|
||||
'merchant_id': merchantId,
|
||||
};
|
||||
|
||||
static String getPaymentPlatformName(BuildContext context, String code) {
|
||||
switch(code) {
|
||||
case 'chase':
|
||||
return S.of(context).credit_debit_card;
|
||||
break;
|
||||
case 'web-credit-card':
|
||||
return S.of(context).credit_card;
|
||||
break;
|
||||
case 'ALIPAY':
|
||||
return S.of(context).alipay;
|
||||
break;
|
||||
case 'WECHATPAY':
|
||||
return S.of(context).wechatpay;
|
||||
break;
|
||||
case 'paypal':
|
||||
return S.of(context).paypal;
|
||||
case 'payondeliverypickup':
|
||||
return S.of(context).pay_on_deliery_pickup;
|
||||
case 'stripe':
|
||||
return S.of(context).credit_card;
|
||||
default:
|
||||
return S.of(context).pay_on_deliery;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
34
lib/models/position.dart
Normal file
34
lib/models/position.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
class Position {
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
|
||||
Position({this.latitude, this.longitude});
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
var areEqual = other is Position &&
|
||||
other.latitude == latitude &&
|
||||
other.longitude == longitude;
|
||||
|
||||
return areEqual;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => latitude.hashCode ^
|
||||
longitude.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Lat $latitude, Lng $longitude';
|
||||
}
|
||||
|
||||
Position.fromJson(Map<String, dynamic> json) :
|
||||
latitude = double.parse(json['latitude'].toString()),
|
||||
longitude = double.parse(json['longitude'].toString());
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'latitude': latitude,
|
||||
'longitude': longitude
|
||||
};
|
||||
}
|
||||
77
lib/models/product.dart
Normal file
77
lib/models/product.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'Subproduct.dart';
|
||||
import 'product_attribute.dart';
|
||||
|
||||
class Product {
|
||||
int id;
|
||||
int businessId;
|
||||
int categoryId;
|
||||
String name;
|
||||
double price;
|
||||
double regularPrice;
|
||||
String description;
|
||||
String detailDescription;
|
||||
String imagePath;
|
||||
double monthSales;
|
||||
int rate;
|
||||
double leftNum;
|
||||
List<ProductAttribute> productAttributes;
|
||||
bool nonInventory;
|
||||
String extraData;
|
||||
List<Subproduct> subproducts;
|
||||
|
||||
Product(int id, int businessId, String name, double price, String description,
|
||||
String imagePath, List<ProductAttribute> productAttributes) {
|
||||
this.id = id;
|
||||
this.businessId = businessId;
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
this.description = description;
|
||||
this.imagePath = imagePath;
|
||||
this.productAttributes = productAttributes;
|
||||
}
|
||||
|
||||
Product.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
businessId = json['business_id'],
|
||||
categoryId = json['category_id'],
|
||||
name = json['name'],
|
||||
price = double.parse(json['price'].toString()),
|
||||
regularPrice = double.parse(json['regular_price'].toString()),
|
||||
description = json['description'],
|
||||
detailDescription = json['detail_description'],
|
||||
imagePath = json['image_path'],
|
||||
monthSales = json['month_sales'] != null ? double.parse(json['month_sales'].toString()) : 0.0,
|
||||
rate = json['rate'],
|
||||
leftNum = json['left_num'] != null ? double.parse(json['left_num'].toString()) : 0.0,
|
||||
productAttributes = json['productattributes'] != null ? (json['productattributes'] as List).map((i) => ProductAttribute.fromJson(i)).toList() : [],
|
||||
nonInventory = json['non_inventory'],
|
||||
extraData = json['extra_data'],
|
||||
subproducts = json['subproducts'] != null ? (json['subproducts'] as List).map((e) => Subproduct.fromJson(e)).toList() : [];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'business_id': businessId,
|
||||
'category_id': categoryId,
|
||||
'name': name,
|
||||
'price': price,
|
||||
'regular_price': regularPrice,
|
||||
'description': description,
|
||||
'detail_description': detailDescription,
|
||||
'image_path': imagePath,
|
||||
'month_sales': monthSales,
|
||||
'rate': rate,
|
||||
'left_num': leftNum,
|
||||
'productattributes': productAttributes,
|
||||
'non_inventory': nonInventory,
|
||||
'extra_data': extraData,
|
||||
'subproducts': subproducts,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
41
lib/models/product_attribute.dart
Normal file
41
lib/models/product_attribute.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'product_option.dart';
|
||||
|
||||
class ProductAttribute {
|
||||
int id;
|
||||
String name;
|
||||
List<ProductOption> productOptions;
|
||||
bool singleSelection;
|
||||
bool byQuantity;
|
||||
bool required;
|
||||
String extra;
|
||||
bool disabled;
|
||||
|
||||
ProductAttribute.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
name = json['name'],
|
||||
productOptions = (json['productoptions'] as List).map((i) => ProductOption.fromJson(i)).toList(),
|
||||
singleSelection = json['single_selection'],
|
||||
byQuantity = json['by_quantity'],
|
||||
required = json['required'],
|
||||
extra = json['extra'],
|
||||
disabled = json['disabled'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'productoptions': productOptions,
|
||||
'single_selection': singleSelection,
|
||||
'by_quantity': byQuantity,
|
||||
'required': required,
|
||||
'extra': extra,
|
||||
'disabled': disabled
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
93
lib/models/product_detail.dart
Normal file
93
lib/models/product_detail.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_wisetronic/models/Subproduct.dart';
|
||||
|
||||
import 'category.dart';
|
||||
import 'product_attribute.dart';
|
||||
import 'product_image.dart';
|
||||
|
||||
class ProductDetail {
|
||||
int id;
|
||||
String image;
|
||||
List<ProductImage> images;
|
||||
String sku;
|
||||
String name;
|
||||
double price;
|
||||
double regularPrice;
|
||||
String description;
|
||||
String description2;
|
||||
String detailDescription;
|
||||
double monthSales;
|
||||
int rate;
|
||||
double leftNum;
|
||||
List<ProductAttribute> productAttributes;
|
||||
bool nonInventory;
|
||||
String extraData;
|
||||
String purchaseNote;
|
||||
double weight;
|
||||
double dimentionsLength;
|
||||
double dimentionsWidth;
|
||||
double dimentionsHeight;
|
||||
bool reviewsAllowed;
|
||||
List<Category> categories;
|
||||
List<Subproduct> subproducts;
|
||||
|
||||
ProductDetail.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
image = json['image'],
|
||||
images = (json['images'] as List).map((e) => ProductImage.fromJson(e)).toList(),
|
||||
sku = json['sku'],
|
||||
name = json['name'],
|
||||
price = double.parse(json['price'].toString()),
|
||||
regularPrice = double.parse(json['regular_price'].toString()),
|
||||
description = json['description'],
|
||||
description2 = json['description2'],
|
||||
detailDescription = json['detail_description'],
|
||||
reviewsAllowed = json['reviews_allowed'],
|
||||
monthSales = double.parse(json['month_sales'].toString()),
|
||||
rate = json['rate'],
|
||||
leftNum = double.parse(json['left_num'].toString()),
|
||||
productAttributes = (json['productattributes'] as List).map((i) => ProductAttribute.fromJson(i)).toList(),
|
||||
nonInventory = json['non_inventory'],
|
||||
extraData = json['extra_data'],
|
||||
purchaseNote = json['purchase_note'],
|
||||
weight = double.parse(json['weight'].toString()),
|
||||
dimentionsLength = double.parse(json['dimentions_length'].toString()),
|
||||
dimentionsWidth = double.parse(json['dimentions_width'].toString()),
|
||||
dimentionsHeight = double.parse(json['dimentions_height'].toString()),
|
||||
categories = (json['categories'] as List).map((e) => Category.fromJson(e)).toList(),
|
||||
subproducts = (json['subproducts'] as List).map((e) => Subproduct.fromJson(e)).toList();
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'image': image,
|
||||
'images': images,
|
||||
'sku': sku,
|
||||
'name': name,
|
||||
'price': price,
|
||||
'regular_price': regularPrice,
|
||||
'description': description,
|
||||
'description2': description2,
|
||||
'detail_description': detailDescription,
|
||||
'month_sales': monthSales,
|
||||
'rate': rate,
|
||||
'left_num': leftNum,
|
||||
'productattributes': productAttributes,
|
||||
'non_inventory': nonInventory,
|
||||
'extra_data': extraData,
|
||||
'purchase_note': purchaseNote,
|
||||
'weight': weight,
|
||||
'dimentions_length': dimentionsLength,
|
||||
'dimentions_width': dimentionsWidth,
|
||||
'dimentions_height': dimentionsHeight,
|
||||
'reviews_allowed': reviewsAllowed,
|
||||
'categories': categories,
|
||||
'subproducts': subproducts,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
20
lib/models/product_image.dart
Normal file
20
lib/models/product_image.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class ProductImage {
|
||||
int id;
|
||||
String image;
|
||||
|
||||
ProductImage.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
image = json['image'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'image': image
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
30
lib/models/product_option.dart
Normal file
30
lib/models/product_option.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class ProductOption {
|
||||
int id;
|
||||
String name;
|
||||
double adjustAmount;
|
||||
String extra;
|
||||
bool disabled;
|
||||
|
||||
ProductOption.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
name = json['name'],
|
||||
adjustAmount = double.parse(json['adjust_amount'].toString()),
|
||||
extra = json['extra'],
|
||||
disabled = json['disabled'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'adjust_amount': adjustAmount,
|
||||
'extra': extra,
|
||||
'disabled': disabled
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
73
lib/models/shipping_rate.dart
Normal file
73
lib/models/shipping_rate.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class ShippingRate {
|
||||
String name;
|
||||
double price;
|
||||
List<Rate> rates;
|
||||
|
||||
ShippingRate.fromJson(Map<String, dynamic> json)
|
||||
: name = json['name'],
|
||||
price = double.parse(json['price'].toString()),
|
||||
rates = (json['rates'] as List).map((e) => Rate.fromJson(e)).toList();
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'name': name,
|
||||
'price': price,
|
||||
'rates': rates,
|
||||
};
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ShippingRate &&
|
||||
runtimeType == other.runtimeType &&
|
||||
name == other.name &&
|
||||
price.toStringAsFixed(2) == other.price.toStringAsFixed(2) &&
|
||||
listEquals(rates, other.rates);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
name.hashCode ^
|
||||
price.hashCode ^
|
||||
rates.hashCode;
|
||||
}
|
||||
|
||||
class Rate {
|
||||
String name;
|
||||
double rate;
|
||||
|
||||
Rate.fromJson(Map<String, dynamic> json)
|
||||
: name = json['name'],
|
||||
rate = double.parse(json['rate'].toString());
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'name': name,
|
||||
'rate': rate,
|
||||
};
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is Rate &&
|
||||
runtimeType == other.runtimeType &&
|
||||
name == other.name &&
|
||||
rate.toStringAsFixed(2) == other.rate.toStringAsFixed(2);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
name.hashCode ^
|
||||
rate.hashCode;
|
||||
}
|
||||
26
lib/models/simple_business.dart
Normal file
26
lib/models/simple_business.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'address.dart';
|
||||
|
||||
class Store {
|
||||
int id;
|
||||
String name;
|
||||
Address address;
|
||||
|
||||
Store.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
name = json['name'],
|
||||
address = Address.fromJson(json['address']);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'address': address,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
32
lib/models/simple_product.dart
Normal file
32
lib/models/simple_product.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class SimpleProduct {
|
||||
int id;
|
||||
String name;
|
||||
double price;
|
||||
double regularPrice;
|
||||
String description;
|
||||
String imagePath;
|
||||
|
||||
SimpleProduct.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
name = json['name'],
|
||||
price = double.parse(json['price'].toString()),
|
||||
regularPrice = double.parse(json['regular_price'].toString()),
|
||||
description = json['description'],
|
||||
imagePath = json['image_path'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'price': price,
|
||||
'regular_price': regularPrice,
|
||||
'description': description,
|
||||
'image_path': imagePath
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
21
lib/models/text_value.dart
Normal file
21
lib/models/text_value.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class TextValue {
|
||||
String text;
|
||||
int value;
|
||||
|
||||
TextValue.fromJson(Map<String, dynamic> json)
|
||||
: text = json['text'],
|
||||
value = int.parse(json['value'].toString());
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'text': text,
|
||||
'value': value
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
110
lib/models/ticket.dart
Normal file
110
lib/models/ticket.dart
Normal file
@@ -0,0 +1,110 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'simple_business.dart';
|
||||
|
||||
class TicketFile {
|
||||
int id;
|
||||
String url;
|
||||
String fileName;
|
||||
String fileType;
|
||||
|
||||
TicketFile.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
url = json['url'],
|
||||
fileName = json['file_name'],
|
||||
fileType = json['file_type'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'url': url,
|
||||
'file_name': fileName,
|
||||
'file_type': fileType,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class Issue {
|
||||
int id;
|
||||
String msg;
|
||||
List<TicketFile> files;
|
||||
|
||||
Issue.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
msg = json['msg'],
|
||||
files = (json['files'] as List).map((e) => TicketFile.fromJson(e)).toList();
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'msg': msg,
|
||||
'files': files,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class FollowUp {
|
||||
int id;
|
||||
String msg;
|
||||
String poster;
|
||||
String createdAt;
|
||||
List<TicketFile> files;
|
||||
|
||||
FollowUp.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
msg = json['msg'],
|
||||
poster = json['poster'],
|
||||
createdAt = json['created_at'],
|
||||
files = (json['files'] as List).map((e) => TicketFile.fromJson(e)).toList();
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'msg': msg,
|
||||
'poster': poster,
|
||||
'created_at': createdAt,
|
||||
'files': files
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class Ticket {
|
||||
int id;
|
||||
Issue issue;
|
||||
Store store;
|
||||
List<FollowUp> followUps;
|
||||
bool isClosed;
|
||||
String createdAt;
|
||||
|
||||
Ticket.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
issue = Issue.fromJson(json['issue']),
|
||||
store = Store.fromJson(json['store']),
|
||||
followUps = (json['follow_ups'] as List).map((e) => FollowUp.fromJson(e)).toList(),
|
||||
isClosed = json['is_closed'],
|
||||
createdAt = json['created_at'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'issue': issue,
|
||||
'store': store,
|
||||
'follow_ups': followUps,
|
||||
'is_closed': isClosed,
|
||||
'created_at': createdAt,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
21
lib/models/user_position.dart
Normal file
21
lib/models/user_position.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class UserPosition {
|
||||
double lat;
|
||||
double lng;
|
||||
|
||||
UserPosition.fromJson(Map<String, dynamic> json) :
|
||||
lat = double.parse(json['lat'].toString()),
|
||||
lng = double.parse(json['lng'].toString());
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'lat': lat,
|
||||
'lng': lng
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
23
lib/models/waiting_line.dart
Normal file
23
lib/models/waiting_line.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'waiting_line_item.dart';
|
||||
|
||||
class WaitingLine {
|
||||
List<WaitingLineItem> waitingLines;
|
||||
String storeSn;
|
||||
|
||||
WaitingLine.fromJson(Map<String, dynamic> json)
|
||||
: waitingLines = (json['waiting_lines'] as List).map((i) => WaitingLineItem.fromJson(i)).toList(),
|
||||
storeSn = json['store_sn'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'waiting_lines': waitingLines,
|
||||
'store_sn': storeSn
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
29
lib/models/waiting_line_item.dart
Normal file
29
lib/models/waiting_line_item.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class WaitingLineItem {
|
||||
String deviceId;
|
||||
String phone;
|
||||
String createdAt;
|
||||
int peopleCount;
|
||||
int waitingNumber;
|
||||
|
||||
WaitingLineItem.fromJson(Map<String, dynamic> json)
|
||||
: deviceId = json['device_id'],
|
||||
phone = json['phone'],
|
||||
createdAt = json['created_at'],
|
||||
peopleCount = json['people_count'],
|
||||
waitingNumber = json['waiting_number'];
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'device_id': deviceId,
|
||||
'phone': phone,
|
||||
'created_at': createdAt,
|
||||
'people_count': peopleCount,
|
||||
'waiting_number': waitingNumber
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return json.encode(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user