feat: payment split

This commit is contained in:
efrilm
2025-08-07 14:48:59 +07:00
parent 9d78c9dcce
commit ffe076e120
7 changed files with 325 additions and 46 deletions
@@ -78,3 +78,57 @@ class PaymentOrderItemModel {
"amount": amount,
};
}
class PaymentSplitBillRequest {
final String orderId;
final String paymentMethodId;
final String customerId;
final String type; // e.g., "AMOUNT" or "ITEM"
final int amount;
final List<SplitItem> items;
PaymentSplitBillRequest({
required this.orderId,
required this.paymentMethodId,
required this.customerId,
required this.type,
required this.amount,
required this.items,
});
Map<String, dynamic> toMap() {
Map<String, dynamic> data = {
'order_id': orderId,
'payment_method_id': paymentMethodId,
'customer_id': customerId,
'type': type,
};
if (type == "AMOUNT") {
data['amount'] = amount;
}
if (type == "ITEM") {
data['items'] = items.map((e) => e.toJson()).toList();
}
return data;
}
}
class SplitItem {
final String orderItemId;
final int quantity;
SplitItem({
required this.orderItemId,
required this.quantity,
});
Map<String, dynamic> toJson() {
return {
'order_item_id': orderItemId,
'quantity': quantity,
};
}
}