add fcs shipment apis
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
import 'bank_account.dart';
|
||||
|
||||
List<Day> dayLists = [
|
||||
Day(id: 1, name: 'Sun'),
|
||||
Day(id: 2, name: 'Mon'),
|
||||
@@ -26,140 +22,42 @@ class Setting {
|
||||
String appUrl;
|
||||
final String termsEng;
|
||||
final String termsMm;
|
||||
String about;
|
||||
|
||||
final String okEnergyId;
|
||||
final String about;
|
||||
int poExpireInHours;
|
||||
int doExpireInHours;
|
||||
int poOpenAt;
|
||||
int poCloseAt;
|
||||
List<int> poCloseOn;
|
||||
int latestDeliveryDay;
|
||||
int firstStorageChargeIn;
|
||||
int firstStorageCharge;
|
||||
int secondStorageChargeIn;
|
||||
int secondStorageCharge;
|
||||
int deliveryStartWaitMin;
|
||||
String reportURL;
|
||||
String helpVersion;
|
||||
String helpURL;
|
||||
List<String> shipmentTypes;
|
||||
|
||||
List<String> phones;
|
||||
String deliveryPhone;
|
||||
String address;
|
||||
String website;
|
||||
DateTime priceLastUpdate;
|
||||
String bankAccountInfo;
|
||||
List<BankAccount> bankAccounts;
|
||||
|
||||
String get getPoOpenAt => poOpenAt > 12
|
||||
? (poOpenAt - 12).toString() + "PM"
|
||||
: poOpenAt.toString() + "AM";
|
||||
|
||||
String get getPoCloseAt => poCloseAt > 12
|
||||
? (poCloseAt - 12).toString() + "PM"
|
||||
: poCloseAt.toString() + "AM";
|
||||
|
||||
String get getPoCloseOn => poCloseOn.fold(
|
||||
"", (p, e) => p + (p == "" ? "" : ", ") + dayLists[e - 1].name);
|
||||
|
||||
String get getPoOpenOn => dayLists.fold(
|
||||
"",
|
||||
(p, e) =>
|
||||
p +
|
||||
(p == "" ? "" : poCloseOn.contains(e.id) ? "" : ", ") +
|
||||
(poCloseOn.contains(e.id) ? "" : e.name));
|
||||
|
||||
bool get isPOClose {
|
||||
DateTime now = DateTime.now();
|
||||
// dart starts from monday width starting index one
|
||||
// server starts from sunday with starting index one
|
||||
var day = (now.weekday + 1) == 8 ? 1 : now.weekday + 1;
|
||||
return poCloseOn.contains(day) ||
|
||||
(now.hour < poOpenAt || now.hour >= poCloseAt);
|
||||
}
|
||||
|
||||
Setting(
|
||||
{this.supportBuildNum,
|
||||
this.usaAddress,
|
||||
this.mmAddress,
|
||||
this.usaContactNumber,
|
||||
this.mmContactNumber,
|
||||
this.emailAddress,
|
||||
this.facebookLink,
|
||||
this.inviteRequired,
|
||||
this.appUrl,
|
||||
this.termsEng,
|
||||
this.termsMm,
|
||||
this.about,
|
||||
this.okEnergyId,
|
||||
this.poExpireInHours,
|
||||
this.doExpireInHours,
|
||||
this.poOpenAt,
|
||||
this.poCloseAt,
|
||||
this.poCloseOn,
|
||||
this.latestDeliveryDay,
|
||||
this.firstStorageCharge,
|
||||
this.firstStorageChargeIn,
|
||||
this.secondStorageCharge,
|
||||
this.secondStorageChargeIn,
|
||||
this.deliveryStartWaitMin,
|
||||
this.reportURL,
|
||||
this.helpVersion,
|
||||
this.helpURL,
|
||||
this.phones,
|
||||
this.website,
|
||||
this.priceLastUpdate,
|
||||
this.bankAccountInfo,
|
||||
this.bankAccounts,
|
||||
this.deliveryPhone,
|
||||
this.address});
|
||||
Setting({
|
||||
this.supportBuildNum,
|
||||
this.usaAddress,
|
||||
this.mmAddress,
|
||||
this.usaContactNumber,
|
||||
this.mmContactNumber,
|
||||
this.emailAddress,
|
||||
this.facebookLink,
|
||||
this.inviteRequired,
|
||||
this.appUrl,
|
||||
this.termsEng,
|
||||
this.termsMm,
|
||||
this.about,
|
||||
this.shipmentTypes,
|
||||
});
|
||||
|
||||
factory Setting.fromMap(Map<String, dynamic> map) {
|
||||
var ts = (map['price_last_update'] as Timestamp);
|
||||
var list = (map['bank_accounts'] as List);
|
||||
|
||||
List<BankAccount> bankAccounts = [];
|
||||
if (list != null) {
|
||||
list.asMap().forEach((index, item) {
|
||||
bankAccounts
|
||||
.add(BankAccount.fromMap(index, item.cast<String, dynamic>()));
|
||||
});
|
||||
}
|
||||
|
||||
return Setting(
|
||||
supportBuildNum: map['support_build_number'],
|
||||
inviteRequired: map['invite_required'],
|
||||
appUrl: map['app_url'],
|
||||
usaAddress: map['usa_address'],
|
||||
mmAddress: map['mm_address'],
|
||||
usaContactNumber: map['usa_contact_number'],
|
||||
mmContactNumber: map['mm_contact_number'],
|
||||
emailAddress: map['email_address'],
|
||||
facebookLink: map['facebook_link'],
|
||||
about: map['about'],
|
||||
termsEng: map['terms_eng'],
|
||||
termsMm: map['terms_mm'],
|
||||
priceLastUpdate: ts?.toDate(),
|
||||
okEnergyId: map['ok_energy_id'],
|
||||
poExpireInHours: map['po_expire_hours'],
|
||||
doExpireInHours: map['do_expire_hours'],
|
||||
poOpenAt: map['po_open_at'],
|
||||
poCloseAt: map['po_close_at'],
|
||||
latestDeliveryDay: map['latest_delivery_days'],
|
||||
firstStorageChargeIn: map['first_storage_charge_in'],
|
||||
firstStorageCharge: map['first_storage_charge'],
|
||||
secondStorageChargeIn: map['second_storage_charge_in'],
|
||||
secondStorageCharge: map['second_storage_charge'],
|
||||
deliveryStartWaitMin: map['delivery_start_wait_min'],
|
||||
reportURL: map['report_url'],
|
||||
helpVersion: map['help_version'],
|
||||
helpURL: map['help_url'],
|
||||
deliveryPhone: map['delivery_phone'],
|
||||
address: map['address'],
|
||||
website: map['website'],
|
||||
bankAccountInfo: map['bank_account_info'],
|
||||
bankAccounts: bankAccounts);
|
||||
supportBuildNum: map['support_build_number'],
|
||||
inviteRequired: map['invite_required'],
|
||||
appUrl: map['app_url'],
|
||||
usaAddress: map['usa_address'],
|
||||
mmAddress: map['mm_address'],
|
||||
usaContactNumber: map['usa_contact_number'],
|
||||
mmContactNumber: map['mm_contact_number'],
|
||||
emailAddress: map['email_address'],
|
||||
facebookLink: map['facebook_link'],
|
||||
about: map['about'],
|
||||
termsEng: map['terms_eng'],
|
||||
termsMm: map['terms_mm'],
|
||||
shipmentTypes: List.from(map['shipment_types']),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
@@ -169,13 +67,9 @@ class Setting {
|
||||
};
|
||||
}
|
||||
|
||||
String helpFileName() {
|
||||
return "help-v$helpVersion.zip";
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Setting{supportBuildNum:$supportBuildNum,about:$about,okEnergyId:$okEnergyId}';
|
||||
return 'Setting{supportBuildNum:$supportBuildNum,about:$about}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user