EnakPoint & EnakCoin wallet, PIN, outlet, order, community, reward
- Wallet EnakPoint & EnakCoin: beranda, riwayat, saldo kedaluwarsa, kode bayar, tukar EnakCoin, transfer - PIN (buat, ganti, lupa), outlet, riwayat order, game spin - Halaman community, webview, coming soon, dan ikon menu beranda baru - Redesign Reward Saya: kartu tiket, filter chip, detail kode + QR - Hapus customer point loader, menu, dan checkout lama - Base URL ke enaklo-pos-api.altru.id Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5954510b93
commit
f5e3075205
@@ -0,0 +1,132 @@
|
||||
part of '../wallet_dtos.dart';
|
||||
|
||||
/// Satu DTO untuk daftar dan detail order; field detail kosong di daftar.
|
||||
@freezed
|
||||
abstract class CustomerOrderDto with _$CustomerOrderDto {
|
||||
const factory CustomerOrderDto({
|
||||
@JsonKey(name: 'id') String? id,
|
||||
@JsonKey(name: 'order_number') String? orderNumber,
|
||||
@JsonKey(name: 'outlet_name') String? outletName,
|
||||
@JsonKey(name: 'order_type') String? orderType,
|
||||
@JsonKey(name: 'status') String? status,
|
||||
@JsonKey(name: 'payment_status') String? paymentStatus,
|
||||
@JsonKey(name: 'total_amount') int? totalAmount,
|
||||
@JsonKey(name: 'item_count') int? itemCount,
|
||||
@JsonKey(name: 'is_void') bool? isVoid,
|
||||
@JsonKey(name: 'is_refund') bool? isRefund,
|
||||
@JsonKey(name: 'points_earned') int? pointsEarned,
|
||||
@JsonKey(name: 'coins_earned') int? coinsEarned,
|
||||
@JsonKey(name: 'created_at') String? createdAt,
|
||||
// Detail
|
||||
@JsonKey(name: 'table_number') String? tableNumber,
|
||||
@JsonKey(name: 'subtotal') int? subtotal,
|
||||
@JsonKey(name: 'discount_amount') int? discountAmount,
|
||||
@JsonKey(name: 'tax_amount') int? taxAmount,
|
||||
@JsonKey(name: 'refund_amount') int? refundAmount,
|
||||
@JsonKey(name: 'items') List<CustomerOrderItemDto>? items,
|
||||
@JsonKey(name: 'payments') List<CustomerOrderPaymentDto>? payments,
|
||||
}) = _CustomerOrderDto;
|
||||
|
||||
factory CustomerOrderDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CustomerOrderDtoFromJson(json);
|
||||
|
||||
const CustomerOrderDto._();
|
||||
|
||||
CustomerOrder toDomain() => CustomerOrder(
|
||||
id: id ?? '',
|
||||
orderNumber: orderNumber ?? '',
|
||||
outletName: outletName ?? '',
|
||||
orderType: orderType ?? '',
|
||||
status: status ?? '',
|
||||
paymentStatus: paymentStatus ?? '',
|
||||
totalAmount: totalAmount ?? 0,
|
||||
itemCount: itemCount ?? 0,
|
||||
isVoid: isVoid ?? false,
|
||||
isRefund: isRefund ?? false,
|
||||
pointsEarned: pointsEarned ?? 0,
|
||||
coinsEarned: coinsEarned ?? 0,
|
||||
createdAt: _parseDateTime(createdAt),
|
||||
);
|
||||
|
||||
CustomerOrderDetail toDetailDomain() => CustomerOrderDetail(
|
||||
order: toDomain(),
|
||||
tableNumber: (tableNumber?.isEmpty ?? true) ? null : tableNumber,
|
||||
subtotal: subtotal ?? 0,
|
||||
discountAmount: discountAmount ?? 0,
|
||||
taxAmount: taxAmount ?? 0,
|
||||
refundAmount: refundAmount ?? 0,
|
||||
items: items?.map((e) => e.toDomain()).toList() ?? [],
|
||||
payments: payments?.map((e) => e.toDomain()).toList() ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class CustomerOrderItemDto with _$CustomerOrderItemDto {
|
||||
const factory CustomerOrderItemDto({
|
||||
@JsonKey(name: 'id') String? id,
|
||||
@JsonKey(name: 'product_name') String? productName,
|
||||
@JsonKey(name: 'variant_name') String? variantName,
|
||||
@JsonKey(name: 'quantity') int? quantity,
|
||||
@JsonKey(name: 'weight') double? weight,
|
||||
@JsonKey(name: 'unit_name') String? unitName,
|
||||
@JsonKey(name: 'unit_price') int? unitPrice,
|
||||
@JsonKey(name: 'total_price') int? totalPrice,
|
||||
@JsonKey(name: 'refund_quantity') int? refundQuantity,
|
||||
}) = _CustomerOrderItemDto;
|
||||
|
||||
factory CustomerOrderItemDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CustomerOrderItemDtoFromJson(json);
|
||||
|
||||
const CustomerOrderItemDto._();
|
||||
|
||||
CustomerOrderItem toDomain() => CustomerOrderItem(
|
||||
id: id ?? '',
|
||||
productName: productName ?? '',
|
||||
variantName: (variantName?.isEmpty ?? true) ? null : variantName,
|
||||
quantity: quantity ?? 0,
|
||||
weight: weight,
|
||||
unitName: unitName,
|
||||
unitPrice: unitPrice ?? 0,
|
||||
totalPrice: totalPrice ?? 0,
|
||||
refundQuantity: refundQuantity ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class CustomerOrderPaymentDto with _$CustomerOrderPaymentDto {
|
||||
const factory CustomerOrderPaymentDto({
|
||||
@JsonKey(name: 'id') String? id,
|
||||
@JsonKey(name: 'method_name') String? methodName,
|
||||
@JsonKey(name: 'method_type') String? methodType,
|
||||
@JsonKey(name: 'amount') int? amount,
|
||||
@JsonKey(name: 'refund_amount') int? refundAmount,
|
||||
@JsonKey(name: 'points_used') int? pointsUsed,
|
||||
}) = _CustomerOrderPaymentDto;
|
||||
|
||||
factory CustomerOrderPaymentDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CustomerOrderPaymentDtoFromJson(json);
|
||||
|
||||
const CustomerOrderPaymentDto._();
|
||||
|
||||
CustomerOrderPayment toDomain() => CustomerOrderPayment(
|
||||
id: id ?? '',
|
||||
methodName: methodName ?? '',
|
||||
methodType: methodType ?? '',
|
||||
amount: amount ?? 0,
|
||||
refundAmount: refundAmount ?? 0,
|
||||
pointsUsed: pointsUsed,
|
||||
);
|
||||
}
|
||||
|
||||
class CustomerOrderPageDto {
|
||||
final List<CustomerOrderDto> items;
|
||||
final WalletPaginationDto pagination;
|
||||
|
||||
const CustomerOrderPageDto({required this.items, required this.pagination});
|
||||
|
||||
CustomerOrderPage toDomain() => CustomerOrderPage(
|
||||
items: items.map((e) => e.toDomain()).toList(),
|
||||
page: pagination.page ?? 1,
|
||||
totalPages: pagination.totalPages ?? 1,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user