add shipments
This commit is contained in:
@@ -25,6 +25,7 @@ const user_disabled_status = "disabled";
|
||||
const user_joined_status = "joined";
|
||||
|
||||
const pkg_files_path = "/packages";
|
||||
const shipment_labels_files_path = "/shipment_labels";
|
||||
|
||||
// Link page
|
||||
const page_payment_methods = "payment_methods";
|
||||
@@ -75,7 +76,9 @@ const carton_mix_box = "Mix carton";
|
||||
|
||||
// shipment status
|
||||
const shipment_pending_status = "pending";
|
||||
const shipment_assigned_status = "assigned";
|
||||
const shipment_confirmed_status = "confirmed";
|
||||
const shipment_received_status = "received";
|
||||
const shipment_pickuped_status = "pickuped";
|
||||
const shipment_packed_status = "packed";
|
||||
const shipment_shipped_status = "shipped";
|
||||
|
||||
@@ -28,6 +28,9 @@ class Carton {
|
||||
String cartonType;
|
||||
String fcsID;
|
||||
String userName;
|
||||
String userID;
|
||||
String fcsShipmentID;
|
||||
String fcsShipmentNumber;
|
||||
|
||||
int rate;
|
||||
int weight;
|
||||
@@ -36,6 +39,7 @@ class Carton {
|
||||
List<String> photos;
|
||||
String remark;
|
||||
DateTime arrivedDate;
|
||||
String cartonNumber;
|
||||
|
||||
List<Package> packages;
|
||||
|
||||
@@ -109,6 +113,7 @@ class Carton {
|
||||
this.isChecked = false,
|
||||
this.cartonType,
|
||||
this.fcsID,
|
||||
this.userID,
|
||||
this.userName,
|
||||
this.rate = 0,
|
||||
this.weight = 0,
|
||||
@@ -121,13 +126,18 @@ class Carton {
|
||||
this.shipmentHistory,
|
||||
this.packages,
|
||||
this.cargoTypes,
|
||||
this.cartonNumber,
|
||||
this.fcsShipmentID,
|
||||
this.fcsShipmentNumber,
|
||||
this.deliveryAddress});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
List _cargoTypes = cargoTypes.map((c) => c.toMap()).toList();
|
||||
List _packages = packages.map((c) => c.toJson()).toList();
|
||||
return {
|
||||
"id": id,
|
||||
'cargo_types': _cargoTypes,
|
||||
'packages': _packages,
|
||||
'length': length,
|
||||
'width': width,
|
||||
'height': height,
|
||||
@@ -155,6 +165,10 @@ class Carton {
|
||||
userName: map['user_name'],
|
||||
fcsID: map['fcs_id'],
|
||||
cartonType: map['carton_type'],
|
||||
cartonNumber: map['carton_number'],
|
||||
status: map['status'],
|
||||
fcsShipmentID: map['fcs_shipment_id'],
|
||||
fcsShipmentNumber: map['fcs_shipment_number'],
|
||||
deliveryAddress: _da,
|
||||
cargoTypes: cargoTypes);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
import 'package:fcs/domain/vo/shipment_status.dart';
|
||||
|
||||
class Package {
|
||||
@@ -13,7 +14,6 @@ class Package {
|
||||
List<String> photoUrls;
|
||||
List<ShipmentStatus> shipmentHistory;
|
||||
String desc;
|
||||
String deliveryAddressID;
|
||||
|
||||
String status;
|
||||
String shipmentNumber;
|
||||
@@ -35,6 +35,7 @@ class Package {
|
||||
List<String> photos;
|
||||
String remark;
|
||||
DateTime arrivedDate;
|
||||
DeliveryAddress deliveryAddress;
|
||||
|
||||
int get amount => rate != null && weight != null ? rate * weight : 0;
|
||||
|
||||
@@ -71,17 +72,19 @@ class Package {
|
||||
this.currentStatusDate,
|
||||
this.photoUrls,
|
||||
this.desc,
|
||||
this.deliveryAddressID,
|
||||
this.deliveryAddress,
|
||||
this.isChecked = false});
|
||||
|
||||
factory Package.fromMap(Map<String, dynamic> map, String docID) {
|
||||
var _currentStatusDate = (map['current_status_date'] as Timestamp);
|
||||
var _currentStatusDate = (map['status_date'] as Timestamp);
|
||||
|
||||
List<ShipmentStatus> _shipmentStatus = List.from(map['all_status'])
|
||||
.map((e) => ShipmentStatus.fromMap(Map<String, dynamic>.from(e)))
|
||||
.toList();
|
||||
List<String> _photoUrls =
|
||||
map['photo_urls'] == null ? [] : List.from(map['photo_urls']);
|
||||
var da = map['delivery_address'];
|
||||
var _da = da != null ? DeliveryAddress.fromMap(da, da["id"]) : null;
|
||||
|
||||
return Package(
|
||||
id: docID,
|
||||
@@ -93,8 +96,8 @@ class Package {
|
||||
phoneNumber: map['phone_number'],
|
||||
remark: map['remark'],
|
||||
desc: map['desc'],
|
||||
currentStatus: map['current_status'],
|
||||
deliveryAddressID: map['delivery_address_id'],
|
||||
currentStatus: map['status'],
|
||||
deliveryAddress: _da,
|
||||
currentStatusDate:
|
||||
_currentStatusDate != null ? _currentStatusDate.toDate() : null,
|
||||
photoUrls: _photoUrls,
|
||||
@@ -118,8 +121,8 @@ class Package {
|
||||
market: json['market'],
|
||||
userName: json['user_name'],
|
||||
phoneNumber: json['phone_number'],
|
||||
currentStatus: json['current_status'],
|
||||
currentStatusDate: DateTime.parse(json['current_status_date']));
|
||||
currentStatus: json['status'],
|
||||
currentStatusDate: DateTime.parse(json['status_date']));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
|
||||
@@ -15,13 +16,21 @@ class Shipment {
|
||||
String phoneNumber;
|
||||
int numberOfPackage;
|
||||
int weight;
|
||||
int handlingFee;
|
||||
double handlingFee;
|
||||
String address;
|
||||
String currentStatus;
|
||||
String status;
|
||||
bool isCourier;
|
||||
int radioIndex;
|
||||
List<Carton> boxes;
|
||||
|
||||
String pickupUserID;
|
||||
String pickupUserName;
|
||||
String pickupUserPhoneNumber;
|
||||
|
||||
String fcsShipmentID;
|
||||
String fcsShipmentNumber;
|
||||
String shipmentLabelUrl;
|
||||
|
||||
Shipment(
|
||||
{this.id,
|
||||
this.shipmentNumber,
|
||||
@@ -34,15 +43,31 @@ class Shipment {
|
||||
this.weight,
|
||||
this.handlingFee,
|
||||
this.address,
|
||||
this.currentStatus,
|
||||
this.status,
|
||||
this.pickupDate,
|
||||
this.isCourier = false,
|
||||
this.radioIndex = 1,
|
||||
this.pickupAddress,
|
||||
this.pickupUserID,
|
||||
this.pickupUserName,
|
||||
this.pickupUserPhoneNumber,
|
||||
this.fcsShipmentID,
|
||||
this.fcsShipmentNumber,
|
||||
this.shipmentLabelUrl,
|
||||
this.boxes});
|
||||
|
||||
int get last => DateTime.now().difference(pickupDate).inDays;
|
||||
|
||||
double get totalWeight => boxes?.fold(0, (p, e) => p + e.actualWeight);
|
||||
int get totalCount => boxes?.length;
|
||||
|
||||
bool get isPending => status == shipment_pending_status;
|
||||
bool get isAssigned => status == shipment_assigned_status;
|
||||
bool get isPickuped => status == shipment_pickuped_status;
|
||||
bool get isPacked => status == shipment_packed_status;
|
||||
bool get isConfirmed => status == shipment_confirmed_status;
|
||||
bool get isReceived => status == shipment_received_status;
|
||||
|
||||
factory Shipment.fromMap(Map<String, dynamic> map, String id) {
|
||||
var pd = (map['pickup_date'] as Timestamp);
|
||||
var pa = map['pickup_address'];
|
||||
@@ -55,8 +80,15 @@ class Shipment {
|
||||
pickupDate: pd == null ? null : pd.toDate(),
|
||||
pickupTimeStart: map['pickup_time_start'],
|
||||
pickupTimeEnd: map['pickup_time_end'],
|
||||
currentStatus: map['current_status'],
|
||||
status: map['status'],
|
||||
shipmentType: map['shipment_type'],
|
||||
pickupUserID: map['pickup_user_id'],
|
||||
pickupUserName: map['pickup_user_name'],
|
||||
pickupUserPhoneNumber: map['pickup_user_phone_number'],
|
||||
handlingFee: map['handling_fee'],
|
||||
fcsShipmentID: map['fcs_shipment_id'],
|
||||
fcsShipmentNumber: map['fcs_shipment_number'],
|
||||
shipmentLabelUrl: map['shipment_label_url'],
|
||||
pickupAddress: _pa);
|
||||
}
|
||||
|
||||
@@ -71,11 +103,17 @@ class Shipment {
|
||||
"pickup_date": pickupDate?.toUtc()?.toIso8601String(),
|
||||
'pickup_time_start': pickupTimeStart,
|
||||
'pickup_time_end': pickupTimeEnd,
|
||||
'pickup_user_id': pickupUserID,
|
||||
'pickup_user_name': pickupUserName,
|
||||
'pickup_user_phone_number': pickupUserPhoneNumber,
|
||||
'handling_fee': handlingFee,
|
||||
'fcs_shipment_id': fcsShipmentID,
|
||||
'shipment_label_url': shipmentLabelUrl
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PickUp{id:$id, userName:$userName,phoneNumber:$phoneNumber,numberOfPackage:$numberOfPackage,weight:$weight,currentStatus:$currentStatus}';
|
||||
return 'PickUp{id:$id, userName:$userName,phoneNumber:$phoneNumber,numberOfPackage:$numberOfPackage,weight:$weight,status:$status}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user