Package com.masai.Dao

Class SellerDaoImpl

java.lang.Object
com.masai.Dao.SellerDaoImpl
All Implemented Interfaces:
SellerDao

public class SellerDaoImpl extends Object implements SellerDao
  • Constructor Details

    • SellerDaoImpl

      public SellerDaoImpl()
  • Method Details

    • loginSeller

      public Seller loginSeller(String username, String password)
      Validates the seller's login credentials.
      Specified by:
      loginSeller in interface SellerDao
      Parameters:
      username - The username of the seller.
      password - The password of the seller.
      Returns:
      The authenticated seller object.
    • getSellerIncome

      public double getSellerIncome(String username)
      Retrieves the income earned by the seller username.
      Specified by:
      getSellerIncome in interface SellerDao
      Parameters:
      username - The username of the seller.
      Returns:
      The total income of the seller.
    • refundToBuyer

      public double refundToBuyer(int productId, int quantity)
      Initiates a refund to the buyer for a specific product and quantity.
      Specified by:
      refundToBuyer in interface SellerDao
      Parameters:
      productId - The ID of the product to be refunded.
      quantity - The quantity of the product to be refunded.
      Returns:
      The refund amount.
    • getSellerByUsername

      public Seller getSellerByUsername(String username)
      Retrieves the seller details based on the username.
      Specified by:
      getSellerByUsername in interface SellerDao
      Parameters:
      username - The username of the seller.
      Returns:
      The seller object.
    • updateSellerDetails

      public String updateSellerDetails(Seller u)
      Updates the details of a seller.
      Specified by:
      updateSellerDetails in interface SellerDao
      Parameters:
      seller - The updated seller object.
      Returns:
      The updated seller details as a string.
    • registerNewSeller

      public String registerNewSeller(Seller s)
      Registers a new seller.
      Specified by:
      registerNewSeller in interface SellerDao
      Parameters:
      seller - The seller object to register.
      Returns:
      A success message upon successful registration.
    • getAllSellerProducts

      public ResultSet getAllSellerProducts(String username)
      Retrieves all products of a seller.
      Specified by:
      getAllSellerProducts in interface SellerDao
      Parameters:
      username - The username of the seller.
      Returns:
      A ResultSet containing all the products of the seller.
    • getAllSellerProductsOrderByQuantity

      public ResultSet getAllSellerProductsOrderByQuantity(String username)
      Retrieves all seller products ordered by quantity.
      Specified by:
      getAllSellerProductsOrderByQuantity in interface SellerDao
      Parameters:
      username - The username of the seller.
      Returns:
      A ResultSet containing the products.
    • unhideSellerProducts

      public boolean unhideSellerProducts(String username)
      Unhides the products of a seller.
      Specified by:
      unhideSellerProducts in interface SellerDao
      Parameters:
      username - The username of the seller.
      Returns:
      true if the products were successfully unhidden, false otherwise.
    • hideSellerProducts

      public boolean hideSellerProducts(String username)
      Hides the products of a seller.
      Specified by:
      hideSellerProducts in interface SellerDao
      Parameters:
      username - The username of the seller.
      Returns:
      true if the products were successfully hidden, false otherwise.
    • getSellerAllProductsByCategory

      public ResultSet getSellerAllProductsByCategory(String item, String username)
      Retrieves all products of a seller belonging to a specific category.
      Specified by:
      getSellerAllProductsByCategory in interface SellerDao
      Parameters:
      item - The category of the products.
      username - The username of the seller.
      Returns:
      A ResultSet containing the products.
    • amountWithrowBySeller

      public boolean amountWithrowBySeller(double amount, String unsername)
      Withdraws a specified amount from the seller's account balance.
      Specified by:
      amountWithrowBySeller in interface SellerDao
      Parameters:
      amount - The amount to withdraw.
      username - The username of the seller.
      Returns:
      true if the withdrawal was successful, false otherwise.
    • deleteSeller

      public boolean deleteSeller(String username, String password)
      Deletes a seller based on their username and password.
      Specified by:
      deleteSeller in interface SellerDao
      Parameters:
      username - The username of the seller.
      password - The password of the seller.
      Returns:
      true if the seller was successfully deleted, false otherwise.
    • reopenSeller

      public boolean reopenSeller(String username, String password)
      Reopens the seller's account after it was closed.
      Specified by:
      reopenSeller in interface SellerDao
      Parameters:
      username - The username of the seller.
      password - The password of the seller.
      Returns:
      true if the seller's account was successfully reopened, false otherwise.
    • getSellerPendingAmount

      public double getSellerPendingAmount(String username)
      Adds a new pending amount to be paid to the seller.
      Specified by:
      getSellerPendingAmount in interface SellerDao
      Parameters:
      username - The username of the seller.
      newPaidAmount - The new pending amount to be paid.
      Returns:
      true if the pending amount was successfully added, false otherwise.
    • addSellerPendingAmount

      public boolean addSellerPendingAmount(String username, double newPaidAmount)
      Adds a new pending amount to be paid to the seller.
      Specified by:
      addSellerPendingAmount in interface SellerDao
      Parameters:
      username - The username of the seller.
      newPaidAmount - The new pending amount to be paid.
      Returns:
      true if the pending amount was successfully added, false otherwise.
    • getSellerProductsID

      public List<Integer> getSellerProductsID(String username)
      Retrieves the IDs of all products belonging to a seller.
      Specified by:
      getSellerProductsID in interface SellerDao
      Parameters:
      username - The username of the seller.
      Returns:
      A list of product IDs.
    • getAllSellerProductsOrderByPrice

      public ResultSet getAllSellerProductsOrderByPrice(String username)
      Retrieves all seller products ordered by price.
      Specified by:
      getAllSellerProductsOrderByPrice in interface SellerDao
      Parameters:
      username - The username of the seller.
      Returns:
      A ResultSet containing the products.
    • sellerPaidPendingAmount

      public boolean sellerPaidPendingAmount(double pendingAamount, String username, double income)
      Marks a pending amount as paid to the seller.
      Specified by:
      sellerPaidPendingAmount in interface SellerDao
      Parameters:
      pendingAmount - The pending amount to be paid.
      username - The username of the seller.
      income - The income earned by the
      Returns:
      true if the pending amount was successfully marked as paid, false otherwise.