import { Order } from '../../entities/commerce/order'; import { Product, ProductCategory } from '../../entities/commerce/product'; import { BaseEntity, MoneyAmount } from '../../entities/types'; import { IRepository } from './repository'; export interface PriceList extends BaseEntity { name: string; code: string; currency: string; isDefault: boolean; status: 'active' | 'archived'; prices: Record; // productId -> MoneyAmount } export interface Payment extends BaseEntity { orderId: string; orderNumber: string; amount: MoneyAmount; method: 'card' | 'cash' | 'online' | 'bank_transfer'; status: 'completed' | 'pending' | 'failed' | 'refunded'; transactionId?: string; idempotencyKey?: string; paidAt: string; recipientAccount?: string; } export interface ShipmentItem { productId: string; sku: string; name: string; quantity: number; } export interface Shipment extends BaseEntity { orderId: string; orderNumber: string; warehouseId: string; status: 'draft' | 'ready' | 'shipped' | 'delivered'; trackingNumber?: string; carrier?: string; dispatchedAt?: string; deliveredAt?: string; items: ShipmentItem[]; } export interface ReturnItem { productId: string; sku: string; name: string; quantity: number; refundAmount: MoneyAmount; } export interface Return extends BaseEntity { orderId: string; orderNumber: string; status: 'requested' | 'approved' | 'received' | 'refunded' | 'rejected'; totalRefund: MoneyAmount; reason: string; items: ReturnItem[]; } export interface ICommerceService { products: IRepository; categories: IRepository; priceLists: IRepository; orders: IRepository; payments: IRepository; shipments: IRepository; returns: IRepository; updateOrderStatus(orderId: string, status: Order['status']): Promise; confirmOrder(orderId: string, warehouseId?: string): Promise; cancelOrder(orderId: string): Promise; createPayment( orderId: string, amount: MoneyAmount, method: Payment['method'], autoRecordFinance?: boolean, idempotencyKey?: string ): Promise; createShipment(orderId: string, warehouseId: string, items?: ShipmentItem[]): Promise; createReturn( orderId: string, reason: string, items: ReturnItem[], warehouseId?: string, autoRecordFinance?: boolean ): Promise; processReturn( orderId: string, reason: string, items: ReturnItem[], warehouseId?: string, autoRecordFinance?: boolean ): Promise; }