Subversion Repositories SmartDukaan

Rev

Rev 37145 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.repository.cs;

import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
import com.spice.profitmandi.common.model.CustomRetailer;
import com.spice.profitmandi.dao.entity.auth.AuthUser;
import com.spice.profitmandi.dao.entity.cs.*;
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
import com.spice.profitmandi.dao.model.*;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Service
public interface CsService {
    int getAuthUserIdWithoutTicketAssignee(int categoryId, EscalationType escalationType, int fofoId) throws ProfitMandiBusinessException;

    // Sends happy code to customer
    void addActivity(Ticket ticket, Activity activity);

    void createTicket(int fofoId, int categoryId, int subcategoryId, String message) throws ProfitMandiBusinessException;

    void createTicket(int fofoId, int categoryId, int subcategoryId, String message, int createdByAuthId) throws ProfitMandiBusinessException;

    void createTicket(int fofoId, int categoryId, int subcategoryId, String message, int createdByAuthId, EscalationType targetEscalation) throws ProfitMandiBusinessException;

    void createTicketWithMedia(int fofoId, int categoryId, int subcategoryId, String message, int createdByAuthId, ActivityMediaModel selectedRecording) throws ProfitMandiBusinessException;

    void createTicketWithMedia(int fofoId, int categoryId, int subcategoryId, String message, int createdByAuthId, ActivityMediaModel selectedRecording, EscalationType targetEscalation) throws ProfitMandiBusinessException;

    TicketActivityMedia createMediaActivity(ActivityMediaModel selectedRecording);

    void addMediaActivity(Ticket ticket, TicketActivityMedia activity);

    void createTicketRemarkEscalation(int fofoId, int authId, int categoryId, int subcategoryId, String message, CollectionRemark remark) throws ProfitMandiBusinessException;

    void addPartnerToRegion(int regionId, List<Integer> fofoIds);

    Map<Integer, TicketSubCategory> getSubCategoryIdAndSubCategoryMap(List<Integer> subCategoryIds);

    Map<Integer, TicketCategory> getSubCategoryIdAndCategoryMap(List<Integer> subCategoryIds);


    Map<Integer, AuthUser> getAuthUserIdAndAuthUserMap(List<TicketAssigned> ticketAssigneds);

    Map<Integer, CustomRetailer> getPartnerByFofoIds(List<Ticket> tickets) throws ProfitMandiBusinessException;

    List<TicketCategory> getAllTicketCategotyFromSubCategory();

    Map<Integer, AuthUser> getAuthUserIdAndAuthUserMapUsingPositions(List<Position> positions);

    Map<Integer, TicketCategory> getCategoryIdAndCategoryUsingPositions(List<Position> positions);

    Map<Integer, Region> getRegionIdAndRegionMap(List<Position> positions);

    Map<Integer, List<CustomRetailer>> getRegionPartners(List<Position> position) throws ProfitMandiBusinessException;

    Map<Integer, List<CustomRetailer>> getPositionCustomRetailerMap(List<Position> position) throws ProfitMandiBusinessException;

    Map<Integer, AuthUser> getTicketIdAndAuthUserMapUsingTickets(List<Ticket> tickets);

    void updateTicket(int categoryId, int subCategoryId, Ticket ticket, int authUserId, EscalationType escalationType, ActivityMediaModel recording,int currentUserId) throws ProfitMandiBusinessException;
    void updateTicket(int categoryId, int subCategoryId, Ticket ticket, int authUserId, EscalationType escalationType) throws ProfitMandiBusinessException;

    Map<String, Set<String>> getAuthUserPartnerEmailMapping() throws ProfitMandiBusinessException;

    Map<String, Set<Integer>> getAuthUserPartnerIdMapping() throws ProfitMandiBusinessException;

    Map<Integer, List<Integer>> getAuthUserIdPartnerIdMapping() throws ProfitMandiBusinessException;

    Map<Integer, List<Integer>> getAuthUserIdAllPartnerIdMapping() throws ProfitMandiBusinessException;

    List<String> getAuthUserByPartnerId(int fofoId) throws ProfitMandiBusinessException;

    Map<Integer, List<Integer>> authUserpartnerIdMap(int authId, int categoryId);

    List<AuthUser> getAuthUserIdByPartnerId(int fofoId) throws ProfitMandiBusinessException;

    List<AuthUser> getAuthUserIdByPartnerId(int fofoId, EscalationType... escalationTypes) throws ProfitMandiBusinessException;

    /**
     * Active auth users holding a single position category against a partner, optionally narrowed to
     * given escalation levels (all levels when none is passed). Covers both the partner's own
     * cs.partner_position rows and the region-wide (partner_id = 0 / ALL_PARTNERS_REGION) ones.
     * Returns an empty list when the partner has no such position mapped.
     */
    List<AuthUser> getAuthUsersByPartnerIdAndCategory(int fofoId, int categoryId, EscalationType... escalationTypes) throws ProfitMandiBusinessException;

    Map<EscalationType, String> getAuthUserAndEsclationTypeByPartnerId(int fofoId) throws ProfitMandiBusinessException;

    Map<Integer, List<Integer>> getL2L1Mapping() throws ProfitMandiBusinessException;

    int getAuthUserId(int categoryId, EscalationType escalationType, int fofoId) throws ProfitMandiBusinessException;

    /**
     * Gets auth user ID with fallback to next escalation level if not found.
     * Returns both the user ID and the actual escalation level that was used.
     */
    EscalationAssignmentResult getAuthUserWithFallback(int categoryId, EscalationType targetEscalation, int fofoId) throws ProfitMandiBusinessException;

    List<AuthUser> getAuthUserIds(int categoryId, List<EscalationType> escalationType);

    List<AuthUser> getAuthUserByCategoryId(int categoryId);

    void assignTicket(Ticket ticket,int currentUserId) throws ProfitMandiBusinessException;

    void assignTicket(Ticket ticket) throws ProfitMandiBusinessException;

    /**
     * True if authId has ever been an assignee on the given ticket (any escalation level, including
     * the initial L1 assignment). Reads from ticket_assigned history.
     */
    boolean isInEscalationChain(int ticketId, int authId);

    /**
     * Batch variant of {@link #isInEscalationChain}. Returns the subset of ticketIds where authId
     * has been an assignee at some point. Use this for dashboards / list views to avoid N+1.
     */
    Set<Integer> ticketsInEscalationChain(int authId, List<Integer> ticketIds);

    Map<Integer, List<AuthUser>> getAssignedAuthList(List<Ticket> tickets);

    Map<EscalationType, AuthUser> getAuthUserAndEsclationByPartnerId(int fofoId) throws ProfitMandiBusinessException;

    // Batch method to fetch auth user escalations for all fofoIds at once
    Map<Integer, Map<EscalationType, AuthUser>> getAuthUserAndEsclationByPartnerIds(Set<Integer> fofoIds) throws ProfitMandiBusinessException;

    Activity createActivity(ActivityType activityType, String message, int createdBy);

    List<AuthUser> getAuthUserByCategoryId(int categoryId, EscalationType escalationType);

    Map<Integer, FofoReportingModel> getPartnerIdSalesHeaders() throws ProfitMandiBusinessException;

    Map<Integer, FofoAbmReportingModel> getPartnerIdABMHeaders() throws ProfitMandiBusinessException;

    Map<Integer, FofoRBMReportingModel> getPartnerIdRBMHeaders() throws ProfitMandiBusinessException;

    @Cacheable(value = "authUserEmailInactivePartnerIdMapping", cacheManager = "thirtyMinsTimeOutCacheManager")
    Map<String, Set<Integer>> getAuthUserInactivePartnerIdMapping() throws ProfitMandiBusinessException;

    Map<String, Set<Integer>> getAuthUserPartnerIdMappingByCategoryIds(List<Integer> categoryIds, boolean activeOnly) throws ProfitMandiBusinessException;

    /**
     * Batch method to get BM/ASM/RBM auth user IDs for all fofoIds at once.
     * Returns Map<fofoId, Map<role, authUserId>> where role is "BM", "ASM", or "RBM".
     */
    Map<Integer, Map<String, Integer>> getBmAsmRbmAuthUserIdsByFofoIds(Set<Integer> fofoIds) throws ProfitMandiBusinessException;

    /**
     * Batch equivalent of {@link #getAuthUserIdWithoutTicketAssignee}. Returns Map&lt;fofoId, authUserId&gt; for a
     * single (categoryId, escalationType). Missing fofoIds map to 0.
     */
    Map<Integer, Integer> getAuthUserIdsWithoutTicketAssigneeByFofoIds(int categoryId, EscalationType escalationType, Set<Integer> fofoIds) throws ProfitMandiBusinessException;

    Map<Integer, Boolean> getUnreadStatusForTickets(List<Ticket> tickets, int userId, TicketReadStatus.UserType userType);

    void markTicketAsRead(int ticketId, int userId, TicketReadStatus.UserType userType);

    Map<Integer, Activity> getLastActivitiesForTickets(List<Integer> ticketIds);

    Map<Integer, Activity> getLastMessageActivitiesForTickets(List<Integer> ticketIds);

    void notifyPartnerOfExternalCommunication(Ticket ticket, Activity activity);

}