update pickup

This commit is contained in:
tzw
2021-10-09 17:08:28 +06:30
parent 46da87dc0e
commit 50901992d7
21 changed files with 597 additions and 274 deletions

View File

@@ -1,24 +1,28 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/delivery_address.dart';
class Pickup {
String? id;
DateTime? pickupDate;
String? fromTime;
String? toTime;
//for consignee
String? userID;
String? userName;
String? userPhoneNumber;
String? pickupNumber;
DateTime? fromTime;
DateTime? toTime;
//for customer
String? customerID;
String? customerName;
String? customerRemark;
String? staffId;
String? staffName;
String? staffPhoneNumber;
//for shipper
String? fcsID;
String? shipperName;
String? shipperPhoneNumber;
String? status;
String? rescheduleRemark;
String? zoneID;
String? zoneName;
DeliveryAddress? pickupAddress;
// for complete
String? completeRemark;
@@ -28,9 +32,8 @@ class Pickup {
Pickup(
{this.id,
this.userID,
this.userName,
this.userPhoneNumber,
this.customerID,
this.customerName,
this.staffId,
this.staffName,
this.staffPhoneNumber,
@@ -38,11 +41,16 @@ class Pickup {
this.fromTime,
this.toTime,
this.fcsID,
this.shipperName,
this.shipperPhoneNumber,
this.status,
this.packages = const [],
this.photoUrls = const []});
this.photoUrls = const [],
this.completeRemark,
this.customerRemark,
this.pickupNumber,
this.rescheduleRemark,
this.zoneID,
this.zoneName,
this.pickupAddress});
@override
bool operator ==(Object other) => other is Pickup && other.id == id;
@@ -50,26 +58,63 @@ class Pickup {
@override
int get hashCode => id.hashCode;
bool isChangedForEdit(Pickup Pickup) {
return Pickup.userID != this.userID ||
Pickup.fcsID != this.fcsID ||
Pickup.packages != this.packages;
bool isChangedForEdit(Pickup pickup) {
return pickup.completeRemark != this.completeRemark;
}
factory Pickup.fromMap(Map<String, dynamic> map, String id) {
var _pickupDate = (map['pickup_date'] as Timestamp);
var _fromTime = map['pickup_time_from'] == null
? null
: (map['pickup_time_from'] as Timestamp);
var _toTime = map['pickup_time_to'] == null
? null
: (map['pickup_time_to'] as Timestamp);
var da = map['pickup_address'];
var _da = da != null ? DeliveryAddress.fromMap(da, da["id"]) : null;
List<String> _photoUrls =
map['photo_urls'] == null ? [] : List.from(map['photo_urls']);
return Pickup(
id: id,
pickupDate: _pickupDate.toDate(),
fromTime: map['from_time'],
toTime: map['to_time'],
staffId: map['staff_id'],
staffName: map['staff_name'],
staffPhoneNumber: map['staff_phone_number'],
userID: map['user_id'],
userName: map['user_name'],
userPhoneNumber: map['user_phone_number'],
status: map['status']);
pickupDate: _pickupDate.toDate().toLocal(),
pickupNumber: map['pickup_number'],
pickupAddress: _da,
fromTime: _fromTime?.toDate().toLocal() ?? null,
toTime: _toTime?.toDate().toLocal() ?? null,
staffId: map['pickup_staff_id'],
staffName: map['pickup_staff_name'],
customerID: map['customer_id'],
customerName: map['customer_name'],
customerRemark: map['customer_remark'] ?? "",
completeRemark: map['complete_remark'] ?? "",
rescheduleRemark: map['reschedule_remark'],
zoneID: map['zone_id'],
zoneName: map['zone_name'],
status: map['status'],
photoUrls: _photoUrls);
}
factory Pickup.fromJson(Map<String, dynamic> json) {
return Pickup(
id: json['id'],
pickupDate: DateTime.parse(json['pickup_date']),
pickupNumber: json['pickup_number'],
fromTime: DateTime.parse(json['pickup_date']),
toTime: DateTime.parse(json['pickup_date']),
staffId: json['pickup_staff_id'],
staffName: json['pickup_staff_name'],
customerID: json['customer_id'],
customerName: json['customer_name'],
customerRemark: json['customer_remark'] ?? "",
completeRemark: json['complete_remark'] ?? "",
rescheduleRemark: json['reschedule_remark'],
zoneID: json['zone_id'],
zoneName: json['zone_name'],
status: json['status'],
);
}
Map<String, dynamic> toMap() {
@@ -81,9 +126,8 @@ class Pickup {
'staff_id': staffId,
'staff_name': staffName,
"staff_phone_number": staffPhoneNumber,
'user_id': userID,
'user_name': userName,
'user_phone_number': userPhoneNumber,
'user_id': customerID,
'user_name': customerName,
'status': status,
};
}
@@ -92,7 +136,7 @@ class Pickup {
return {
"id": id,
"complete_remark": completeRemark,
'photo_urls': photoUrls ?? [],
'photo_urls': photoUrls,
};
}