Subversion Repositories SmartDukaan

Rev

Rev 35394 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31662 amit.gupta 1
package com.spice.profitmandi.dao.repository.cs;
2
 
3
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
4
import com.spice.profitmandi.common.model.ProfitMandiConstants;
5
import com.spice.profitmandi.dao.entity.auth.AuthUser;
6
import com.spice.profitmandi.dao.entity.cs.Position;
7
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
8
import com.spice.profitmandi.service.AuthService;
9
import org.springframework.beans.factory.annotation.Autowired;
10
import org.springframework.stereotype.Component;
11
 
12
import java.util.Arrays;
13
import java.util.List;
14
import java.util.Map;
15
import java.util.Set;
16
import java.util.stream.Collectors;
17
 
18
@Component
19
public class CsService1Impl implements CsService1 {
20
 
21
    @Autowired
22
    AuthService authService;
23
 
24
 
25
    @Autowired
26
    AuthRepository authRepository;
27
 
28
 
29
    @Autowired
30
    CsService csService;
31
 
32
    @Autowired
33
    PositionRepository positionRepository;
34
 
31831 amit.gupta 35
    private static List<Integer> categoryIds = Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_LOGISTICS,
36
            ProfitMandiConstants.TICKET_CATEGORY_FINANCIAL_SERVICES, ProfitMandiConstants.TICKET_CATEGORY_CATEGORY,
34901 ranu 37
            ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_ABM,
31831 amit.gupta 38
            ProfitMandiConstants.TICKET_CATEGORY_MARKETING, ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS,
39
            ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT, ProfitMandiConstants.TICKET_CATEGORY_STOCKS,
34272 tejus.loha 40
            ProfitMandiConstants.TICKET_CATEGORY_TECHNOLOGY, ProfitMandiConstants.TICKET_CATEGORY_TRAINING,ProfitMandiConstants.TICKET_CATEGORY_RECOVERY);
31662 amit.gupta 41
 
42
    @Override
43
    public Set<Integer> getAuthFofoIds(String email, boolean active) throws ProfitMandiBusinessException {
44
        Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, active);
45
        Set<Integer> authfofoIds = storeGuyMap.get(email);
46
 
47
        if (authfofoIds == null) {
35464 amit 48
            AuthUser authUser = authRepository.selectByEmailOrMobile(email);
49
            if (authUser != null) {
50
                List<Position> positions1 = positionRepository.selectAllByAuthUserId(authUser.getId());
51
                if (positions1.stream().anyMatch(x -> x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_MASTER)) {
52
                    authfofoIds = csService.getPositionCustomRetailerMap(positions1).values().stream().flatMap(x -> x.stream())
53
                            .map(x -> x.getPartnerId()).collect(Collectors.toSet());
54
                }
31662 amit.gupta 55
            }
56
        }
57
        return authfofoIds;
58
    }
59
}