fix mainmodel
This commit is contained in:
37
lib/fcs/common/domain/constants.dart
Normal file
37
lib/fcs/common/domain/constants.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
const ok_doc_id = "ok";
|
||||
const setting_doc_id = "setting";
|
||||
|
||||
const config_collection = "configs";
|
||||
const biz_collection = "bizs";
|
||||
const product_collection = "products";
|
||||
const user_collection = "users";
|
||||
const privilege_collection = "privileges";
|
||||
const user_level_collection = "user_levels";
|
||||
const storage_collection = "storages";
|
||||
const buyer_collection = "buyers";
|
||||
const buying_pos = "buying_pos";
|
||||
const selling_pos = "selling_pos";
|
||||
const inventory_takings = "inventory_takings";
|
||||
const inventory_lines = "inventory_lines";
|
||||
const pds_collection = "pds";
|
||||
const pos_collection = "pos";
|
||||
const dos_collection = "dos";
|
||||
const notification_collection = "notifications";
|
||||
const log_collection = "logs";
|
||||
const report_collection = "reports";
|
||||
const po_product_collection = "po_products";
|
||||
const device_collection = "devices";
|
||||
const do_po_lines_collection = "do_po_lines";
|
||||
const reports_collection = "reports";
|
||||
const announcement_collection = "announcements";
|
||||
const report_user_collection = "report_users";
|
||||
|
||||
const po_files_path = "/ok/po";
|
||||
const reg_files_path = "/ok/reg";
|
||||
const do_files_path = "/ok/do";
|
||||
const sign_files_path = "/ok/sign";
|
||||
const bank_images_path = "/ok/banks";
|
||||
|
||||
const po_approved_status = "approved";
|
||||
const po_closed_status = "closed";
|
||||
const do_approved_status = "approved";
|
||||
@@ -1,13 +0,0 @@
|
||||
import 'auth_status.dart';
|
||||
|
||||
class Auth {
|
||||
AuthStatus authStatus;
|
||||
String authErrorCode;
|
||||
String authErrorMsg;
|
||||
|
||||
String uid;
|
||||
String name;
|
||||
String phoneNumber;
|
||||
|
||||
Auth({this.authStatus, this.authErrorCode, this.authErrorMsg});
|
||||
}
|
||||
9
lib/fcs/common/domain/entities/auth_result.dart
Normal file
9
lib/fcs/common/domain/entities/auth_result.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
import 'auth_status.dart';
|
||||
|
||||
class AuthResult {
|
||||
AuthStatus authStatus;
|
||||
String authErrorCode;
|
||||
String authErrorMsg;
|
||||
|
||||
AuthResult({this.authStatus, this.authErrorCode, this.authErrorMsg});
|
||||
}
|
||||
31
lib/fcs/common/domain/entities/bank_account.dart
Normal file
31
lib/fcs/common/domain/entities/bank_account.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
class BankAccount {
|
||||
int index;
|
||||
String bankName;
|
||||
String bankLogo;
|
||||
String accountName;
|
||||
String accountNumber;
|
||||
BankAccount(
|
||||
{this.index,
|
||||
this.bankName,
|
||||
this.bankLogo,
|
||||
this.accountName,
|
||||
this.accountNumber});
|
||||
|
||||
BankAccount.fromMap(int index, Map<String, dynamic> json) {
|
||||
this.index = index;
|
||||
bankName = json['bank_name'];
|
||||
bankLogo = json['bank_logo'];
|
||||
accountName = json['account_name'];
|
||||
accountNumber = json['account_number'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
"index": index,
|
||||
'bank_name': bankName,
|
||||
'bank_logo': bankLogo,
|
||||
'account_name': accountName,
|
||||
'account_number': accountNumber,
|
||||
};
|
||||
}
|
||||
}
|
||||
166
lib/fcs/common/domain/entities/setting.dart
Normal file
166
lib/fcs/common/domain/entities/setting.dart
Normal file
@@ -0,0 +1,166 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
import 'bank_account.dart';
|
||||
|
||||
List<Day> dayLists = [
|
||||
Day(id: 1, name: 'Sun'),
|
||||
Day(id: 2, name: 'Mon'),
|
||||
Day(id: 3, name: 'Tue'),
|
||||
Day(id: 4, name: 'Wed'),
|
||||
Day(id: 5, name: 'Thu'),
|
||||
Day(id: 6, name: 'Fri'),
|
||||
Day(id: 7, name: 'Sat'),
|
||||
];
|
||||
|
||||
class Setting {
|
||||
final int supportBuildNum;
|
||||
final String okEnergyId;
|
||||
final String about;
|
||||
final String terms;
|
||||
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> phones;
|
||||
String deliveryPhone;
|
||||
String address;
|
||||
String email;
|
||||
String website;
|
||||
String facebook;
|
||||
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.about,
|
||||
this.okEnergyId,
|
||||
this.terms,
|
||||
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.email,
|
||||
this.website,
|
||||
this.facebook,
|
||||
this.priceLastUpdate,
|
||||
this.bankAccountInfo,
|
||||
this.bankAccounts,
|
||||
this.deliveryPhone,
|
||||
this.address});
|
||||
|
||||
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(
|
||||
priceLastUpdate: ts?.toDate(),
|
||||
supportBuildNum: map['support_build_number'],
|
||||
about: map['about'],
|
||||
terms: map['terms'],
|
||||
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'],
|
||||
email: map['email'],
|
||||
deliveryPhone: map['delivery_phone'],
|
||||
address: map['address'],
|
||||
website: map['website'],
|
||||
facebook: map['facebook'],
|
||||
bankAccountInfo: map['bank_account_info'],
|
||||
bankAccounts: bankAccounts);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'terms': terms,
|
||||
};
|
||||
}
|
||||
|
||||
String helpFileName() {
|
||||
return "help-v$helpVersion.zip";
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Setting{supportBuildNum:$supportBuildNum,about:$about,okEnergyId:$okEnergyId}';
|
||||
}
|
||||
}
|
||||
|
||||
class Day {
|
||||
int id;
|
||||
String name;
|
||||
bool isChecked = false;
|
||||
Day({this.id, this.name, this.isChecked});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Day{id:$id,name:$name,isChecked:$isChecked}';
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ class User {
|
||||
String id;
|
||||
String name;
|
||||
String phoneNumber;
|
||||
bool hasSignup;
|
||||
|
||||
String fcsID;
|
||||
String shippingAddress;
|
||||
String deliveryAddress;
|
||||
@@ -280,6 +282,6 @@ class User {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'User{name: $name, phoneNumber: $phoneNumber,dateofBirth:$dateofBirth,disable:$disable,gender:$gender,roleName:$roleName,roleID:$roleID,privilegeIds:$privilegeIds,status:$status,frontUrl:$frontUrl,backUrl:$backUrl,selfieUrl:$selfieUrl}';
|
||||
return 'User{name: $name, phoneNumber: $phoneNumber,hasSignup:$hasSignup}';
|
||||
}
|
||||
}
|
||||
|
||||
8
lib/fcs/common/domain/exceiptions/signin_exception.dart
Normal file
8
lib/fcs/common/domain/exceiptions/signin_exception.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
class SigninException {
|
||||
final String msg;
|
||||
|
||||
SigninException(this.msg);
|
||||
|
||||
@override
|
||||
String toString() => msg;
|
||||
}
|
||||
Reference in New Issue
Block a user