feat : new segment logic

This commit is contained in:
2025-07-21 12:04:43 +03:30
parent 16833584f6
commit e2300293a7
5 changed files with 521 additions and 78 deletions

View File

@@ -9,11 +9,11 @@ abstract class SegmentationModel with _$SegmentationModel {
const factory SegmentationModel({ const factory SegmentationModel({
String? key, String? key,
String? productKey, String? productKey,
String? guildKey,
int? weight,
Buyer? buyer, Buyer? buyer,
DateTime? date, DateTime? date,
int? weight, ToGuild? toGuild,
String? result,
String? guildKey,
}) = _SegmentationModel; }) = _SegmentationModel;
factory SegmentationModel.fromJson(Map<String, dynamic> json) => factory SegmentationModel.fromJson(Map<String, dynamic> json) =>
@@ -22,7 +22,40 @@ abstract class SegmentationModel with _$SegmentationModel {
@freezed @freezed
abstract class Buyer with _$Buyer { abstract class Buyer with _$Buyer {
const factory Buyer({String? fullname, String? mobile, String? shop, String? type}) = _Buyer; const factory Buyer({
String? fullname,
String? mobile,
String? shop,
}) = _Buyer;
factory Buyer.fromJson(Map<String, dynamic> json) => _$BuyerFromJson(json); factory Buyer.fromJson(Map<String, dynamic> json) => _$BuyerFromJson(json);
} }
@freezed
abstract class ToGuild with _$ToGuild {
const factory ToGuild({
String? key,
String? guildsName,
String? typeActivity,
String? areaActivity,
String? guildsId,
bool? steward,
User? user,
}) = _ToGuild;
factory ToGuild.fromJson(Map<String, dynamic> json) => _$ToGuildFromJson(json);
}
@freezed
abstract class User with _$User {
const factory User({
String? fullname,
String? firstName,
String? lastName,
String? mobile,
String? nationalId,
String? city,
}) = _User;
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
}

View File

@@ -16,7 +16,7 @@ T _$identity<T>(T value) => value;
/// @nodoc /// @nodoc
mixin _$SegmentationModel { mixin _$SegmentationModel {
String? get key; String? get productKey; Buyer? get buyer; DateTime? get date; int? get weight; String? get result; String? get guildKey; String? get key; String? get productKey; String? get guildKey; int? get weight; Buyer? get buyer; DateTime? get date; ToGuild? get toGuild;
/// Create a copy of SegmentationModel /// Create a copy of SegmentationModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -29,16 +29,16 @@ $SegmentationModelCopyWith<SegmentationModel> get copyWith => _$SegmentationMode
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.result, result) || other.result == result)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)); return identical(this, other) || (other.runtimeType == runtimeType&&other is SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.toGuild, toGuild) || other.toGuild == toGuild));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType,key,productKey,buyer,date,weight,result,guildKey); int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,weight,buyer,date,toGuild);
@override @override
String toString() { String toString() {
return 'SegmentationModel(key: $key, productKey: $productKey, buyer: $buyer, date: $date, weight: $weight, result: $result, guildKey: $guildKey)'; return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)';
} }
@@ -49,11 +49,11 @@ abstract mixin class $SegmentationModelCopyWith<$Res> {
factory $SegmentationModelCopyWith(SegmentationModel value, $Res Function(SegmentationModel) _then) = _$SegmentationModelCopyWithImpl; factory $SegmentationModelCopyWith(SegmentationModel value, $Res Function(SegmentationModel) _then) = _$SegmentationModelCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
String? key, String? productKey, Buyer? buyer, DateTime? date, int? weight, String? result, String? guildKey String? key, String? productKey, String? guildKey, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild
}); });
$BuyerCopyWith<$Res>? get buyer; $BuyerCopyWith<$Res>? get buyer;$ToGuildCopyWith<$Res>? get toGuild;
} }
/// @nodoc /// @nodoc
@@ -66,16 +66,16 @@ class _$SegmentationModelCopyWithImpl<$Res>
/// Create a copy of SegmentationModel /// Create a copy of SegmentationModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? key = freezed,Object? productKey = freezed,Object? buyer = freezed,Object? date = freezed,Object? weight = freezed,Object? result = freezed,Object? guildKey = freezed,}) { @pragma('vm:prefer-inline') @override $Res call({Object? key = freezed,Object? productKey = freezed,Object? guildKey = freezed,Object? weight = freezed,Object? buyer = freezed,Object? date = freezed,Object? toGuild = freezed,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable
as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable
as String?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable
as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable
as DateTime?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable
as int?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable
as String?, as String?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable
as int?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable
as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable
as DateTime?,toGuild: freezed == toGuild ? _self.toGuild : toGuild // ignore: cast_nullable_to_non_nullable
as ToGuild?,
)); ));
} }
/// Create a copy of SegmentationModel /// Create a copy of SegmentationModel
@@ -90,6 +90,18 @@ $BuyerCopyWith<$Res>? get buyer {
return $BuyerCopyWith<$Res>(_self.buyer!, (value) { return $BuyerCopyWith<$Res>(_self.buyer!, (value) {
return _then(_self.copyWith(buyer: value)); return _then(_self.copyWith(buyer: value));
}); });
}/// Create a copy of SegmentationModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ToGuildCopyWith<$Res>? get toGuild {
if (_self.toGuild == null) {
return null;
}
return $ToGuildCopyWith<$Res>(_self.toGuild!, (value) {
return _then(_self.copyWith(toGuild: value));
});
} }
} }
@@ -98,16 +110,16 @@ $BuyerCopyWith<$Res>? get buyer {
@JsonSerializable() @JsonSerializable()
class _SegmentationModel implements SegmentationModel { class _SegmentationModel implements SegmentationModel {
const _SegmentationModel({this.key, this.productKey, this.buyer, this.date, this.weight, this.result, this.guildKey}); const _SegmentationModel({this.key, this.productKey, this.guildKey, this.weight, this.buyer, this.date, this.toGuild});
factory _SegmentationModel.fromJson(Map<String, dynamic> json) => _$SegmentationModelFromJson(json); factory _SegmentationModel.fromJson(Map<String, dynamic> json) => _$SegmentationModelFromJson(json);
@override final String? key; @override final String? key;
@override final String? productKey; @override final String? productKey;
@override final String? guildKey;
@override final int? weight;
@override final Buyer? buyer; @override final Buyer? buyer;
@override final DateTime? date; @override final DateTime? date;
@override final int? weight; @override final ToGuild? toGuild;
@override final String? result;
@override final String? guildKey;
/// Create a copy of SegmentationModel /// Create a copy of SegmentationModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -122,16 +134,16 @@ Map<String, dynamic> toJson() {
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.result, result) || other.result == result)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)); return identical(this, other) || (other.runtimeType == runtimeType&&other is _SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.toGuild, toGuild) || other.toGuild == toGuild));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType,key,productKey,buyer,date,weight,result,guildKey); int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,weight,buyer,date,toGuild);
@override @override
String toString() { String toString() {
return 'SegmentationModel(key: $key, productKey: $productKey, buyer: $buyer, date: $date, weight: $weight, result: $result, guildKey: $guildKey)'; return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)';
} }
@@ -142,11 +154,11 @@ abstract mixin class _$SegmentationModelCopyWith<$Res> implements $SegmentationM
factory _$SegmentationModelCopyWith(_SegmentationModel value, $Res Function(_SegmentationModel) _then) = __$SegmentationModelCopyWithImpl; factory _$SegmentationModelCopyWith(_SegmentationModel value, $Res Function(_SegmentationModel) _then) = __$SegmentationModelCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
String? key, String? productKey, Buyer? buyer, DateTime? date, int? weight, String? result, String? guildKey String? key, String? productKey, String? guildKey, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild
}); });
@override $BuyerCopyWith<$Res>? get buyer; @override $BuyerCopyWith<$Res>? get buyer;@override $ToGuildCopyWith<$Res>? get toGuild;
} }
/// @nodoc /// @nodoc
@@ -159,16 +171,16 @@ class __$SegmentationModelCopyWithImpl<$Res>
/// Create a copy of SegmentationModel /// Create a copy of SegmentationModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? key = freezed,Object? productKey = freezed,Object? buyer = freezed,Object? date = freezed,Object? weight = freezed,Object? result = freezed,Object? guildKey = freezed,}) { @override @pragma('vm:prefer-inline') $Res call({Object? key = freezed,Object? productKey = freezed,Object? guildKey = freezed,Object? weight = freezed,Object? buyer = freezed,Object? date = freezed,Object? toGuild = freezed,}) {
return _then(_SegmentationModel( return _then(_SegmentationModel(
key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable
as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable
as String?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable
as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable
as DateTime?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable
as int?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable
as String?, as String?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable
as int?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable
as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable
as DateTime?,toGuild: freezed == toGuild ? _self.toGuild : toGuild // ignore: cast_nullable_to_non_nullable
as ToGuild?,
)); ));
} }
@@ -184,6 +196,18 @@ $BuyerCopyWith<$Res>? get buyer {
return $BuyerCopyWith<$Res>(_self.buyer!, (value) { return $BuyerCopyWith<$Res>(_self.buyer!, (value) {
return _then(_self.copyWith(buyer: value)); return _then(_self.copyWith(buyer: value));
}); });
}/// Create a copy of SegmentationModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ToGuildCopyWith<$Res>? get toGuild {
if (_self.toGuild == null) {
return null;
}
return $ToGuildCopyWith<$Res>(_self.toGuild!, (value) {
return _then(_self.copyWith(toGuild: value));
});
} }
} }
@@ -191,7 +215,7 @@ $BuyerCopyWith<$Res>? get buyer {
/// @nodoc /// @nodoc
mixin _$Buyer { mixin _$Buyer {
String? get fullname; String? get mobile; String? get shop; String? get type; String? get fullname; String? get mobile; String? get shop;
/// Create a copy of Buyer /// Create a copy of Buyer
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -204,16 +228,16 @@ $BuyerCopyWith<Buyer> get copyWith => _$BuyerCopyWithImpl<Buyer>(this as Buyer,
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is Buyer&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.shop, shop) || other.shop == shop)&&(identical(other.type, type) || other.type == type)); return identical(this, other) || (other.runtimeType == runtimeType&&other is Buyer&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.shop, shop) || other.shop == shop));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType,fullname,mobile,shop,type); int get hashCode => Object.hash(runtimeType,fullname,mobile,shop);
@override @override
String toString() { String toString() {
return 'Buyer(fullname: $fullname, mobile: $mobile, shop: $shop, type: $type)'; return 'Buyer(fullname: $fullname, mobile: $mobile, shop: $shop)';
} }
@@ -224,7 +248,7 @@ abstract mixin class $BuyerCopyWith<$Res> {
factory $BuyerCopyWith(Buyer value, $Res Function(Buyer) _then) = _$BuyerCopyWithImpl; factory $BuyerCopyWith(Buyer value, $Res Function(Buyer) _then) = _$BuyerCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
String? fullname, String? mobile, String? shop, String? type String? fullname, String? mobile, String? shop
}); });
@@ -241,12 +265,11 @@ class _$BuyerCopyWithImpl<$Res>
/// Create a copy of Buyer /// Create a copy of Buyer
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? fullname = freezed,Object? mobile = freezed,Object? shop = freezed,Object? type = freezed,}) { @pragma('vm:prefer-inline') @override $Res call({Object? fullname = freezed,Object? mobile = freezed,Object? shop = freezed,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable
as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable
as String?,shop: freezed == shop ? _self.shop : shop // ignore: cast_nullable_to_non_nullable as String?,shop: freezed == shop ? _self.shop : shop // ignore: cast_nullable_to_non_nullable
as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String?, as String?,
)); ));
} }
@@ -258,13 +281,12 @@ as String?,
@JsonSerializable() @JsonSerializable()
class _Buyer implements Buyer { class _Buyer implements Buyer {
const _Buyer({this.fullname, this.mobile, this.shop, this.type}); const _Buyer({this.fullname, this.mobile, this.shop});
factory _Buyer.fromJson(Map<String, dynamic> json) => _$BuyerFromJson(json); factory _Buyer.fromJson(Map<String, dynamic> json) => _$BuyerFromJson(json);
@override final String? fullname; @override final String? fullname;
@override final String? mobile; @override final String? mobile;
@override final String? shop; @override final String? shop;
@override final String? type;
/// Create a copy of Buyer /// Create a copy of Buyer
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -279,16 +301,16 @@ Map<String, dynamic> toJson() {
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Buyer&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.shop, shop) || other.shop == shop)&&(identical(other.type, type) || other.type == type)); return identical(this, other) || (other.runtimeType == runtimeType&&other is _Buyer&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.shop, shop) || other.shop == shop));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@override @override
int get hashCode => Object.hash(runtimeType,fullname,mobile,shop,type); int get hashCode => Object.hash(runtimeType,fullname,mobile,shop);
@override @override
String toString() { String toString() {
return 'Buyer(fullname: $fullname, mobile: $mobile, shop: $shop, type: $type)'; return 'Buyer(fullname: $fullname, mobile: $mobile, shop: $shop)';
} }
@@ -299,7 +321,7 @@ abstract mixin class _$BuyerCopyWith<$Res> implements $BuyerCopyWith<$Res> {
factory _$BuyerCopyWith(_Buyer value, $Res Function(_Buyer) _then) = __$BuyerCopyWithImpl; factory _$BuyerCopyWith(_Buyer value, $Res Function(_Buyer) _then) = __$BuyerCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
String? fullname, String? mobile, String? shop, String? type String? fullname, String? mobile, String? shop
}); });
@@ -316,12 +338,334 @@ class __$BuyerCopyWithImpl<$Res>
/// Create a copy of Buyer /// Create a copy of Buyer
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? fullname = freezed,Object? mobile = freezed,Object? shop = freezed,Object? type = freezed,}) { @override @pragma('vm:prefer-inline') $Res call({Object? fullname = freezed,Object? mobile = freezed,Object? shop = freezed,}) {
return _then(_Buyer( return _then(_Buyer(
fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable
as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable
as String?,shop: freezed == shop ? _self.shop : shop // ignore: cast_nullable_to_non_nullable as String?,shop: freezed == shop ? _self.shop : shop // ignore: cast_nullable_to_non_nullable
as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable as String?,
));
}
}
/// @nodoc
mixin _$ToGuild {
String? get key; String? get guildsName; String? get typeActivity; String? get areaActivity; String? get guildsId; bool? get steward; User? get user;
/// Create a copy of ToGuild
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$ToGuildCopyWith<ToGuild> get copyWith => _$ToGuildCopyWithImpl<ToGuild>(this as ToGuild, _$identity);
/// Serializes this ToGuild to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ToGuild&&(identical(other.key, key) || other.key == key)&&(identical(other.guildsName, guildsName) || other.guildsName == guildsName)&&(identical(other.typeActivity, typeActivity) || other.typeActivity == typeActivity)&&(identical(other.areaActivity, areaActivity) || other.areaActivity == areaActivity)&&(identical(other.guildsId, guildsId) || other.guildsId == guildsId)&&(identical(other.steward, steward) || other.steward == steward)&&(identical(other.user, user) || other.user == user));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,key,guildsName,typeActivity,areaActivity,guildsId,steward,user);
@override
String toString() {
return 'ToGuild(key: $key, guildsName: $guildsName, typeActivity: $typeActivity, areaActivity: $areaActivity, guildsId: $guildsId, steward: $steward, user: $user)';
}
}
/// @nodoc
abstract mixin class $ToGuildCopyWith<$Res> {
factory $ToGuildCopyWith(ToGuild value, $Res Function(ToGuild) _then) = _$ToGuildCopyWithImpl;
@useResult
$Res call({
String? key, String? guildsName, String? typeActivity, String? areaActivity, String? guildsId, bool? steward, User? user
});
$UserCopyWith<$Res>? get user;
}
/// @nodoc
class _$ToGuildCopyWithImpl<$Res>
implements $ToGuildCopyWith<$Res> {
_$ToGuildCopyWithImpl(this._self, this._then);
final ToGuild _self;
final $Res Function(ToGuild) _then;
/// Create a copy of ToGuild
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? key = freezed,Object? guildsName = freezed,Object? typeActivity = freezed,Object? areaActivity = freezed,Object? guildsId = freezed,Object? steward = freezed,Object? user = freezed,}) {
return _then(_self.copyWith(
key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable
as String?,guildsName: freezed == guildsName ? _self.guildsName : guildsName // ignore: cast_nullable_to_non_nullable
as String?,typeActivity: freezed == typeActivity ? _self.typeActivity : typeActivity // ignore: cast_nullable_to_non_nullable
as String?,areaActivity: freezed == areaActivity ? _self.areaActivity : areaActivity // ignore: cast_nullable_to_non_nullable
as String?,guildsId: freezed == guildsId ? _self.guildsId : guildsId // ignore: cast_nullable_to_non_nullable
as String?,steward: freezed == steward ? _self.steward : steward // ignore: cast_nullable_to_non_nullable
as bool?,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
as User?,
));
}
/// Create a copy of ToGuild
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$UserCopyWith<$Res>? get user {
if (_self.user == null) {
return null;
}
return $UserCopyWith<$Res>(_self.user!, (value) {
return _then(_self.copyWith(user: value));
});
}
}
/// @nodoc
@JsonSerializable()
class _ToGuild implements ToGuild {
const _ToGuild({this.key, this.guildsName, this.typeActivity, this.areaActivity, this.guildsId, this.steward, this.user});
factory _ToGuild.fromJson(Map<String, dynamic> json) => _$ToGuildFromJson(json);
@override final String? key;
@override final String? guildsName;
@override final String? typeActivity;
@override final String? areaActivity;
@override final String? guildsId;
@override final bool? steward;
@override final User? user;
/// Create a copy of ToGuild
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ToGuildCopyWith<_ToGuild> get copyWith => __$ToGuildCopyWithImpl<_ToGuild>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$ToGuildToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ToGuild&&(identical(other.key, key) || other.key == key)&&(identical(other.guildsName, guildsName) || other.guildsName == guildsName)&&(identical(other.typeActivity, typeActivity) || other.typeActivity == typeActivity)&&(identical(other.areaActivity, areaActivity) || other.areaActivity == areaActivity)&&(identical(other.guildsId, guildsId) || other.guildsId == guildsId)&&(identical(other.steward, steward) || other.steward == steward)&&(identical(other.user, user) || other.user == user));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,key,guildsName,typeActivity,areaActivity,guildsId,steward,user);
@override
String toString() {
return 'ToGuild(key: $key, guildsName: $guildsName, typeActivity: $typeActivity, areaActivity: $areaActivity, guildsId: $guildsId, steward: $steward, user: $user)';
}
}
/// @nodoc
abstract mixin class _$ToGuildCopyWith<$Res> implements $ToGuildCopyWith<$Res> {
factory _$ToGuildCopyWith(_ToGuild value, $Res Function(_ToGuild) _then) = __$ToGuildCopyWithImpl;
@override @useResult
$Res call({
String? key, String? guildsName, String? typeActivity, String? areaActivity, String? guildsId, bool? steward, User? user
});
@override $UserCopyWith<$Res>? get user;
}
/// @nodoc
class __$ToGuildCopyWithImpl<$Res>
implements _$ToGuildCopyWith<$Res> {
__$ToGuildCopyWithImpl(this._self, this._then);
final _ToGuild _self;
final $Res Function(_ToGuild) _then;
/// Create a copy of ToGuild
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? key = freezed,Object? guildsName = freezed,Object? typeActivity = freezed,Object? areaActivity = freezed,Object? guildsId = freezed,Object? steward = freezed,Object? user = freezed,}) {
return _then(_ToGuild(
key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable
as String?,guildsName: freezed == guildsName ? _self.guildsName : guildsName // ignore: cast_nullable_to_non_nullable
as String?,typeActivity: freezed == typeActivity ? _self.typeActivity : typeActivity // ignore: cast_nullable_to_non_nullable
as String?,areaActivity: freezed == areaActivity ? _self.areaActivity : areaActivity // ignore: cast_nullable_to_non_nullable
as String?,guildsId: freezed == guildsId ? _self.guildsId : guildsId // ignore: cast_nullable_to_non_nullable
as String?,steward: freezed == steward ? _self.steward : steward // ignore: cast_nullable_to_non_nullable
as bool?,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
as User?,
));
}
/// Create a copy of ToGuild
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$UserCopyWith<$Res>? get user {
if (_self.user == null) {
return null;
}
return $UserCopyWith<$Res>(_self.user!, (value) {
return _then(_self.copyWith(user: value));
});
}
}
/// @nodoc
mixin _$User {
String? get fullname; String? get firstName; String? get lastName; String? get mobile; String? get nationalId; String? get city;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$UserCopyWith<User> get copyWith => _$UserCopyWithImpl<User>(this as User, _$identity);
/// Serializes this User to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is User&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.nationalId, nationalId) || other.nationalId == nationalId)&&(identical(other.city, city) || other.city == city));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,fullname,firstName,lastName,mobile,nationalId,city);
@override
String toString() {
return 'User(fullname: $fullname, firstName: $firstName, lastName: $lastName, mobile: $mobile, nationalId: $nationalId, city: $city)';
}
}
/// @nodoc
abstract mixin class $UserCopyWith<$Res> {
factory $UserCopyWith(User value, $Res Function(User) _then) = _$UserCopyWithImpl;
@useResult
$Res call({
String? fullname, String? firstName, String? lastName, String? mobile, String? nationalId, String? city
});
}
/// @nodoc
class _$UserCopyWithImpl<$Res>
implements $UserCopyWith<$Res> {
_$UserCopyWithImpl(this._self, this._then);
final User _self;
final $Res Function(User) _then;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? fullname = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? mobile = freezed,Object? nationalId = freezed,Object? city = freezed,}) {
return _then(_self.copyWith(
fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable
as String?,nationalId: freezed == nationalId ? _self.nationalId : nationalId // ignore: cast_nullable_to_non_nullable
as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
@JsonSerializable()
class _User implements User {
const _User({this.fullname, this.firstName, this.lastName, this.mobile, this.nationalId, this.city});
factory _User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
@override final String? fullname;
@override final String? firstName;
@override final String? lastName;
@override final String? mobile;
@override final String? nationalId;
@override final String? city;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$UserCopyWith<_User> get copyWith => __$UserCopyWithImpl<_User>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$UserToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _User&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.nationalId, nationalId) || other.nationalId == nationalId)&&(identical(other.city, city) || other.city == city));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,fullname,firstName,lastName,mobile,nationalId,city);
@override
String toString() {
return 'User(fullname: $fullname, firstName: $firstName, lastName: $lastName, mobile: $mobile, nationalId: $nationalId, city: $city)';
}
}
/// @nodoc
abstract mixin class _$UserCopyWith<$Res> implements $UserCopyWith<$Res> {
factory _$UserCopyWith(_User value, $Res Function(_User) _then) = __$UserCopyWithImpl;
@override @useResult
$Res call({
String? fullname, String? firstName, String? lastName, String? mobile, String? nationalId, String? city
});
}
/// @nodoc
class __$UserCopyWithImpl<$Res>
implements _$UserCopyWith<$Res> {
__$UserCopyWithImpl(this._self, this._then);
final _User _self;
final $Res Function(_User) _then;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? fullname = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? mobile = freezed,Object? nationalId = freezed,Object? city = freezed,}) {
return _then(_User(
fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable
as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable
as String?,nationalId: freezed == nationalId ? _self.nationalId : nationalId // ignore: cast_nullable_to_non_nullable
as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable
as String?, as String?,
)); ));
} }

View File

@@ -10,38 +10,78 @@ _SegmentationModel _$SegmentationModelFromJson(Map<String, dynamic> json) =>
_SegmentationModel( _SegmentationModel(
key: json['key'] as String?, key: json['key'] as String?,
productKey: json['product_key'] as String?, productKey: json['product_key'] as String?,
guildKey: json['guild_key'] as String?,
weight: (json['weight'] as num?)?.toInt(),
buyer: json['buyer'] == null buyer: json['buyer'] == null
? null ? null
: Buyer.fromJson(json['buyer'] as Map<String, dynamic>), : Buyer.fromJson(json['buyer'] as Map<String, dynamic>),
date: json['date'] == null date: json['date'] == null
? null ? null
: DateTime.parse(json['date'] as String), : DateTime.parse(json['date'] as String),
weight: (json['weight'] as num?)?.toInt(), toGuild: json['to_guild'] == null
result: json['result'] as String?, ? null
guildKey: json['guild_key'] as String?, : ToGuild.fromJson(json['to_guild'] as Map<String, dynamic>),
); );
Map<String, dynamic> _$SegmentationModelToJson(_SegmentationModel instance) => Map<String, dynamic> _$SegmentationModelToJson(_SegmentationModel instance) =>
<String, dynamic>{ <String, dynamic>{
'key': instance.key, 'key': instance.key,
'product_key': instance.productKey, 'product_key': instance.productKey,
'guild_key': instance.guildKey,
'weight': instance.weight,
'buyer': instance.buyer, 'buyer': instance.buyer,
'date': instance.date?.toIso8601String(), 'date': instance.date?.toIso8601String(),
'weight': instance.weight, 'to_guild': instance.toGuild,
'result': instance.result,
'guild_key': instance.guildKey,
}; };
_Buyer _$BuyerFromJson(Map<String, dynamic> json) => _Buyer( _Buyer _$BuyerFromJson(Map<String, dynamic> json) => _Buyer(
fullname: json['fullname'] as String?, fullname: json['fullname'] as String?,
mobile: json['mobile'] as String?, mobile: json['mobile'] as String?,
shop: json['shop'] as String?, shop: json['shop'] as String?,
type: json['type'] as String?,
); );
Map<String, dynamic> _$BuyerToJson(_Buyer instance) => <String, dynamic>{ Map<String, dynamic> _$BuyerToJson(_Buyer instance) => <String, dynamic>{
'fullname': instance.fullname, 'fullname': instance.fullname,
'mobile': instance.mobile, 'mobile': instance.mobile,
'shop': instance.shop, 'shop': instance.shop,
'type': instance.type, };
_ToGuild _$ToGuildFromJson(Map<String, dynamic> json) => _ToGuild(
key: json['key'] as String?,
guildsName: json['guilds_name'] as String?,
typeActivity: json['type_activity'] as String?,
areaActivity: json['area_activity'] as String?,
guildsId: json['guilds_id'] as String?,
steward: json['steward'] as bool?,
user: json['user'] == null
? null
: User.fromJson(json['user'] as Map<String, dynamic>),
);
Map<String, dynamic> _$ToGuildToJson(_ToGuild instance) => <String, dynamic>{
'key': instance.key,
'guilds_name': instance.guildsName,
'type_activity': instance.typeActivity,
'area_activity': instance.areaActivity,
'guilds_id': instance.guildsId,
'steward': instance.steward,
'user': instance.user,
};
_User _$UserFromJson(Map<String, dynamic> json) => _User(
fullname: json['fullname'] as String?,
firstName: json['first_name'] as String?,
lastName: json['last_name'] as String?,
mobile: json['mobile'] as String?,
nationalId: json['national_id'] as String?,
city: json['city'] as String?,
);
Map<String, dynamic> _$UserToJson(_User instance) => <String, dynamic>{
'fullname': instance.fullname,
'first_name': instance.firstName,
'last_name': instance.lastName,
'mobile': instance.mobile,
'national_id': instance.nationalId,
'city': instance.city,
}; };

View File

@@ -35,7 +35,6 @@ class SegmentationLogic extends GetxController {
RxList<GuildModel> guildsModel = <GuildModel>[].obs; RxList<GuildModel> guildsModel = <GuildModel>[].obs;
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
@@ -82,12 +81,16 @@ class SegmentationLogic extends GetxController {
void clearForm() { void clearForm() {
weightController.text = '0'; weightController.text = '0';
selectedSegment.value = null; selectedSegment.value = null;
selectedGuildModel.value = null;
} }
void validateForm() { void validateForm() {
var weight = int.tryParse(weightController.text.clearComma.trim()); var weight = int.tryParse(weightController.text.clearComma.trim());
isSubmitButtonEnabled.value = isSubmitButtonEnabled.value =
selectedProduct.value != null && weightController.text.isNotEmpty && weight! > 0; selectedProduct.value != null &&
weightController.text.isNotEmpty &&
weight! > 0 &&
(saleType.value == 1 || (saleType.value == 2 && selectedGuildModel.value != null));
} }
Future<void> getAllSegmentation([bool isLoadingMore = false]) async { Future<void> getAllSegmentation([bool isLoadingMore = false]) async {
@@ -177,9 +180,9 @@ class SegmentationLogic extends GetxController {
weight: int.tryParse(weightController.text.clearComma) ?? 0, weight: int.tryParse(weightController.text.clearComma) ?? 0,
); );
if (saleType.value == 2) { if (saleType.value == 2) {
segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key); segmentationModel = segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key);
} }
safeCall( await safeCall(
call: () async => await rootLogic.chickenRepository.createSegmentation( call: () async => await rootLogic.chickenRepository.createSegmentation(
token: rootLogic.tokenService.accessToken.value!, token: rootLogic.tokenService.accessToken.value!,
model: segmentationModel, model: segmentationModel,

View File

@@ -83,10 +83,21 @@ class SegmentationPage extends GetView<SegmentationLogic> {
SizedBox(width: 12), SizedBox(width: 12),
Expanded( Expanded(
flex: 3, flex: 3,
child: Text( child: Column(
item.date?.formattedJalaliDate ?? 'N/A', mainAxisAlignment: MainAxisAlignment.center,
textAlign: TextAlign.center, spacing: 4,
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark), children: [
Text(
item.toGuild != null ? 'مباشر' : 'قطعه‌بند',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
Text(
item.date?.formattedJalaliDate ?? 'N/A',
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
),
],
), ),
), ),
SizedBox(width: 4), SizedBox(width: 4),
@@ -96,14 +107,18 @@ class SegmentationPage extends GetView<SegmentationLogic> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
item.buyer?.fullname ?? 'N/A', item.toGuild != null
? item.toGuild?.user?.fullname ?? 'N/A'
: item.buyer?.fullname ?? 'N/A',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
), ),
SizedBox(height: 2), SizedBox(height: 2),
Text( Text(
item.buyer?.shop ?? 'N/A', item.toGuild != null
? item.toGuild?.guildsName ?? 'N/A'
: item.buyer?.shop ?? 'N/A',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark), style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
), ),
@@ -111,18 +126,10 @@ class SegmentationPage extends GetView<SegmentationLogic> {
), ),
), ),
SizedBox(width: 4), SizedBox(width: 4),
Expanded(
flex: 4,
child: Text(
item.date?.formattedJalaliDate,
textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
),
),
Expanded( Expanded(
flex: 2, flex: 2,
child: Text( child: Text(
'${item.weight} KG', '${item.weight.separatedByComma} KG',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: AppFonts.yekan12.copyWith(color: AppColor.bgDark), style: AppFonts.yekan12.copyWith(color: AppColor.bgDark),
), ),
@@ -178,9 +185,25 @@ class SegmentationPage extends GetView<SegmentationLogic> {
], ],
), ),
), ),
buildRow(title: 'مشخصات خریدار', value: item.buyer?.fullname ?? 'N/A'), buildRow(
buildRow(title: 'تلفن خریدار', value: item.buyer?.mobile ?? 'N/A'), title: 'مشخصات خریدار',
buildRow(title: 'نام واحد', value: item.buyer?.shop ?? 'N/A'), value: item.toGuild != null
? item.toGuild?.user?.fullname ?? 'N/A'
: item.buyer?.fullname ?? 'N/A',
),
buildRow(
title: 'تلفن خریدار',
value: item.toGuild != null
? item.toGuild?.user?.mobile ?? 'N/A'
: item.buyer?.mobile ?? 'N/A',
),
buildRow(
title: 'نام واحد',
value: item.toGuild != null
? item.toGuild?.guildsName ?? 'N/A'
: item.buyer?.shop ?? 'N/A',
),
buildRow(title: 'ماهیت', value: item.toGuild != null ? 'مباشر' : 'قطعه‌بند'),
buildRow(title: 'وزن قطعه‌بندی', value: '${item.weight?.separatedByComma}'), buildRow(title: 'وزن قطعه‌بندی', value: '${item.weight?.separatedByComma}'),
Row( Row(
@@ -268,7 +291,7 @@ class SegmentationPage extends GetView<SegmentationLogic> {
controller.selectedGuildModel.refresh(); controller.selectedGuildModel.refresh();
}, },
), ),
Text('خودم', style: AppFonts.yekan14), Text('قطعه‌بندی(مباشر)', style: AppFonts.yekan14),
SizedBox(width: 12), SizedBox(width: 12),
Radio( Radio(
value: 2, value: 2,
@@ -277,7 +300,7 @@ class SegmentationPage extends GetView<SegmentationLogic> {
controller.saleType.value = value!; controller.saleType.value = value!;
}, },
), ),
Text('صنف/مباشر', style: AppFonts.yekan14), Text('تخصیص به قطعه‌بند', style: AppFonts.yekan14),
], ],
); );
}, controller.saleType), }, controller.saleType),