v1.0.12 customer properties and membership
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:collection';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:workouttest_util/model/customer_membership.dart';
|
||||
|
||||
import 'customer_property.dart';
|
||||
|
||||
@@ -31,6 +32,8 @@ class Customer {
|
||||
int? lifeLong;
|
||||
|
||||
LinkedHashMap<String, CustomerProperty> properties = LinkedHashMap();
|
||||
List<CustomerProperty> customerProperties = [];
|
||||
List<CustomerMembership> memberships = [];
|
||||
|
||||
Customer(
|
||||
{customerId,
|
||||
@@ -83,6 +86,14 @@ class Customer {
|
||||
|
||||
dateAdd = json['dateAdd'] == null ? DateTime.parse("0000-00-00") : DateTime.parse(json['dateAdd']);
|
||||
dateChange = json['dateChange'] == null ? DateTime.parse("0000-00-00") : DateTime.parse(json['dateChange']);
|
||||
|
||||
if (json['properties'] != null && json['properties'].length > 0) {
|
||||
customerProperties = json['properties'].map<CustomerProperty>((detail) => CustomerProperty.fromJson(detail)).toList();
|
||||
}
|
||||
|
||||
if (json['memberships'] != null && json['memberships'].length > 0) {
|
||||
memberships = json['memberships'].map<CustomerMembership>((detail) => CustomerMembership.fromJson(detail)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class CustomerMembership {
|
||||
late int membershipId;
|
||||
late int customerId;
|
||||
late DateTime startDate;
|
||||
|
||||
int? customerId;
|
||||
DateTime? startDate;
|
||||
|
||||
CustomerMembership.fromJson(Map json) {
|
||||
membershipId = json['membershipId'];
|
||||
customerId = json['customerId'];
|
||||
startDate = json['startDate'];
|
||||
customerId = json['customerId'] ?? 0;
|
||||
startDate = json['startDate'] == null ? null : DateTime.parse(json['startDate']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"membershipId": membershipId,
|
||||
"customerId": customerId,
|
||||
"startDate": startDate,
|
||||
};
|
||||
Map<String, dynamic> toJson() => {
|
||||
"membershipId": membershipId,
|
||||
"customerId": customerId ?? 0,
|
||||
"startDate": startDate == null ? "" : DateFormat('yyyy-MM-dd HH:mm:ss').format(startDate!),
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() => toJson().toString();
|
||||
}
|
||||
String toString() => toJson().toString();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import '../util/logging.dart';
|
||||
class CustomerProperty with Logging {
|
||||
int? customerPropertyId;
|
||||
late int propertyId;
|
||||
late int customerId;
|
||||
int? customerId;
|
||||
DateTime? dateAdd;
|
||||
String? dateYmd;
|
||||
String? dateYm;
|
||||
@@ -12,16 +12,12 @@ class CustomerProperty with Logging {
|
||||
late double propertyValue;
|
||||
bool newData = false;
|
||||
|
||||
CustomerProperty(
|
||||
{required propertyId,
|
||||
required customerId,
|
||||
required dateAdd,
|
||||
required propertyValue});
|
||||
CustomerProperty({required propertyId, required customerId, required dateAdd, required propertyValue});
|
||||
|
||||
CustomerProperty.fromJson(Map json) {
|
||||
customerPropertyId = json['customerPropertyId'];
|
||||
propertyId = json['propertyId'];
|
||||
customerId = json['customerId'];
|
||||
customerId = json['customerId'] ?? 0;
|
||||
dateAdd = DateTime.parse(json['dateAdd']);
|
||||
|
||||
if (dateAdd != null) {
|
||||
@@ -40,14 +36,14 @@ class CustomerProperty with Logging {
|
||||
return {
|
||||
"customerPropertyId": customerPropertyId,
|
||||
"propertyId": propertyId,
|
||||
"customerId": customerId,
|
||||
"customerId": customerId ?? 0,
|
||||
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(dateAdd!),
|
||||
"propertyValue": propertyValue
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
"propertyId": propertyId,
|
||||
"customerId": customerId,
|
||||
"customerId": customerId ?? 0,
|
||||
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(dateAdd!),
|
||||
"propertyValue": propertyValue
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user