ebay

Use Case

Search product

add items to shopping carts

make an order

pay

delivery notification

refund

Class


class Controller{

    Order makeOrder(OrderRequest orderRequest);
    Account eBay;
    void pay(Order order){
        PaymentStatus paymentStatus = order.getPaymentMethod().pay(order.getBuyer(), eBayBank, order.getTotalPrice());
        order.changePayStatus(payStatus);
        if(payStatus == PayStatusEnum.SUCCESS){
            // async tranfer money to seller from eBay fund; 
            AsyncFundTranferService.notify(order);
            AsyncDeliver();
        }
    }
}

class Account{
    int id;
    int fund;
    List<PaymentMethod> paymentMethods;

    boolean withDrawFund(int price);
    boolean addFund(int price);
}

class Product{
    int id;
    List<Tag> tags;
    int unitPrice;
    int inventory;
    Seller seller;
}

class Cart{
    Buyer buyer;
    List<CartItem> items;
    void addItem(Product product, int quantity);
}

class CartItem{
    Product product;
    int quantity;
}

class OrderRequest{
    Cart cart;
    PaymentMethod paymentMethod;
    Address deliveryAddress;
}

class Order{
    Address deliveryAddress;
    Buyer buyer;
    PaymentMethod paymentMethod;
    List<OrderItem> orderItems;
    OrderStatus OrderStatus;
    int getTotalPrice();
}

class OrderItem{
    Order order;
    Product product;
    int quantity;
    int unitPrice;
    DelivaryStatus
}

interface PaymentMethod{
    PaymentStatus pay(Account from, Account to, int price);
}

enum PaymentStatus{
    SUCCESS;
    FAIL;
}