fix(blackList+notifications): Issue-523, 191

This commit is contained in:
mso7nueh
2025-08-11 14:53:43 +03:00
parent 412ac0aeeb
commit dca4b4c471
9 changed files with 650 additions and 35 deletions

View File

@@ -538,6 +538,297 @@ class EntityCommented implements BaseNotificationModel {
}
}
class PlanSubscriptionExpiredNotification implements BaseNotificationModel {
@override
final NotificationType type;
@override
final bool isRead;
final String planName;
final String customerName;
@override
final DateTime createdAt;
PlanSubscriptionExpiredNotification({
required this.type,
required this.planName,
required this.customerName,
required this.isRead,
required this.createdAt,
});
factory PlanSubscriptionExpiredNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
return PlanSubscriptionExpiredNotification(
type: type,
planName: json['plan_name'],
customerName: json['user_name'],
isRead: isRead ?? false,
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
);
}
}
class PlanSubscriptionRenewedNotification implements BaseNotificationModel {
@override
final NotificationType type;
@override
final bool isRead;
final String planName;
final String customerName;
final String renewalDate;
@override
final DateTime createdAt;
PlanSubscriptionRenewedNotification({
required this.type,
required this.planName,
required this.customerName,
required this.renewalDate,
required this.isRead,
required this.createdAt,
});
factory PlanSubscriptionRenewedNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
return PlanSubscriptionRenewedNotification(
type: type,
planName: json['plan_name'],
customerName: json['user_name'],
renewalDate: json['renewal_date'],
isRead: isRead ?? false,
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
);
}
}
class ConsultantAssignedNotification implements BaseNotificationModel {
@override
final NotificationType type;
@override
final bool isRead;
final String consultantName;
final String planName;
final int planId;
@override
final DateTime createdAt;
ConsultantAssignedNotification({
required this.type,
required this.consultantName,
required this.planName,
required this.planId,
required this.isRead,
required this.createdAt,
});
factory ConsultantAssignedNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
return ConsultantAssignedNotification(
type: type,
consultantName: json['consultant_name'],
planName: json['plan_name'],
planId: json['plan_id'],
isRead: isRead ?? false,
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
);
}
}
class ConsultantUnassignedNotification implements BaseNotificationModel {
@override
final NotificationType type;
@override
final bool isRead;
final String consultantName;
final String planName;
final int planId;
@override
final DateTime createdAt;
ConsultantUnassignedNotification({
required this.type,
required this.consultantName,
required this.planName,
required this.planId,
required this.isRead,
required this.createdAt,
});
factory ConsultantUnassignedNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
return ConsultantUnassignedNotification(
type: type,
consultantName: json['consultant_name'],
planName: json['plan_name'],
planId: json['plan_id'],
isRead: isRead ?? false,
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
);
}
}
class PaymentFailedNotification implements BaseNotificationModel {
@override
final NotificationType type;
@override
final bool isRead;
final String planName;
final String errorMessage;
final String paymentMethod;
@override
final DateTime createdAt;
PaymentFailedNotification({
required this.type,
required this.planName,
required this.errorMessage,
required this.paymentMethod,
required this.isRead,
required this.createdAt,
});
factory PaymentFailedNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
return PaymentFailedNotification(
type: type,
planName: json['plan_name'],
errorMessage: json['error_message'],
paymentMethod: json['payment_method'],
isRead: isRead ?? false,
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
);
}
}
class PaymentSuccessfulNotification implements BaseNotificationModel {
@override
final NotificationType type;
@override
final bool isRead;
final String planName;
final double amount;
final String currency;
final String transactionId;
@override
final DateTime createdAt;
PaymentSuccessfulNotification({
required this.type,
required this.planName,
required this.amount,
required this.currency,
required this.transactionId,
required this.isRead,
required this.createdAt,
});
factory PaymentSuccessfulNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
return PaymentSuccessfulNotification(
type: type,
planName: json['plan_name'],
amount: (json['amount'] as num).toDouble(),
currency: json['currency'],
transactionId: json['transaction_id'],
isRead: isRead ?? false,
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
);
}
}
class GoalAchievedNotification implements BaseNotificationModel {
@override
final NotificationType type;
@override
final bool isRead;
final String goalName;
final String goalType;
final double achievedValue;
final double targetValue;
@override
final DateTime createdAt;
GoalAchievedNotification({
required this.type,
required this.goalName,
required this.goalType,
required this.achievedValue,
required this.targetValue,
required this.isRead,
required this.createdAt,
});
factory GoalAchievedNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
return GoalAchievedNotification(
type: type,
goalName: json['goal_name'],
goalType: json['goal_type'],
achievedValue: (json['achieved_value'] as num).toDouble(),
targetValue: (json['target_value'] as num).toDouble(),
isRead: isRead ?? false,
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
);
}
}
class WorkoutReminderNotification implements BaseNotificationModel {
@override
final NotificationType type;
@override
final bool isRead;
final String workoutName;
final String workoutType;
final int duration;
@override
final DateTime createdAt;
WorkoutReminderNotification({
required this.type,
required this.workoutName,
required this.workoutType,
required this.duration,
required this.isRead,
required this.createdAt,
});
factory WorkoutReminderNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
return WorkoutReminderNotification(
type: type,
workoutName: json['workout_name'],
workoutType: json['workout_type'],
duration: json['duration'],
isRead: isRead ?? false,
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
);
}
}
class MealReminderNotification implements BaseNotificationModel {
@override
final NotificationType type;
@override
final bool isRead;
final String mealName;
final String mealType;
final int calories;
@override
final DateTime createdAt;
MealReminderNotification({
required this.type,
required this.mealName,
required this.mealType,
required this.calories,
required this.isRead,
required this.createdAt,
});
factory MealReminderNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
return MealReminderNotification(
type: type,
mealName: json['meal_name'],
mealType: json['meal_type'],
calories: json['calories'],
isRead: isRead ?? false,
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
);
}
}
class UnknownNotification implements BaseNotificationModel {
@override
final NotificationType type;
@@ -570,6 +861,16 @@ enum NotificationType {
commentReplied,
scoreAdded,
entityCommented,
// Дополнительные типы уведомлений
planSubscriptionExpired,
planSubscriptionRenewed,
consultantAssigned,
consultantUnassigned,
paymentFailed,
paymentSuccessful,
goalAchieved,
workoutReminder,
mealReminder,
unknown;
static NotificationType getTypeFromString(String type) => switch (type) {
@@ -593,6 +894,16 @@ enum NotificationType {
'App\\Notifications\\Comment\\Replied' => NotificationType.commentReplied,
'App\\Notifications\\Score\\ScoreAdded' => NotificationType.scoreAdded,
'App\\Notifications\\Comment\\EntityCommented' => NotificationType.entityCommented,
// Дополнительные маппинги
'App\\Notifications\\Plan\\PlanSubscriptionExpired' => NotificationType.planSubscriptionExpired,
'App\\Notifications\\Plan\\PlanSubscriptionRenewed' => NotificationType.planSubscriptionRenewed,
'App\\Notifications\\Plan\\ConsultantAssigned' => NotificationType.consultantAssigned,
'App\\Notifications\\Plan\\ConsultantUnassigned' => NotificationType.consultantUnassigned,
'App\\Notifications\\Payment\\PaymentFailed' => NotificationType.paymentFailed,
'App\\Notifications\\Payment\\PaymentSuccessful' => NotificationType.paymentSuccessful,
'App\\Notifications\\Goal\\GoalAchieved' => NotificationType.goalAchieved,
'App\\Notifications\\Workout\\WorkoutReminder' => NotificationType.workoutReminder,
'App\\Notifications\\Meal\\MealReminder' => NotificationType.mealReminder,
_ => NotificationType.unknown,
};
}