| Line 14... |
Line 14... |
| 14 |
import org.springframework.beans.factory.annotation.Autowired;
|
14 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 15 |
import org.springframework.cache.annotation.Cacheable;
|
15 |
import org.springframework.cache.annotation.Cacheable;
|
| 16 |
import org.springframework.stereotype.Component;
|
16 |
import org.springframework.stereotype.Component;
|
| 17 |
|
17 |
|
| 18 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
18 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
19 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 19 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
20 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 20 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
21 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| - |
|
22 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 21 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
23 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| - |
|
24 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 22 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
25 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
| 23 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
26 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 24 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
27 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
28 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
29 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
30 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
| - |
|
31 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
| - |
|
32 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 28 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
33 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 29 |
import com.spice.profitmandi.service.user.RetailerService;
|
34 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 30 |
|
35 |
|
| 31 |
@Component
|
36 |
@Component
|
| 32 |
public class PartnerStatsServiceImpl implements PartnerStatsService {
|
37 |
public class PartnerStatsServiceImpl implements PartnerStatsService {
|
| Line 55... |
Line 60... |
| 55 |
HygieneDataRepository hygieneDataRepository;
|
60 |
HygieneDataRepository hygieneDataRepository;
|
| 56 |
|
61 |
|
| 57 |
@Autowired
|
62 |
@Autowired
|
| 58 |
UserWalletRepository userWalletRepository;
|
63 |
UserWalletRepository userWalletRepository;
|
| 59 |
|
64 |
|
| - |
|
65 |
@Autowired
|
| - |
|
66 |
PartnerTypeChangeService partnerTypeChangeService;
|
| - |
|
67 |
|
| 60 |
@Override
|
68 |
@Override
|
| 61 |
@Cacheable(value = "partnerStats", cacheManager = "thirtyMinsTimeOutCacheManager")
|
69 |
@Cacheable(value = "partnerStats", cacheManager = "thirtyMinsTimeOutCacheManager")
|
| 62 |
public Map<Integer, PartnerDetailModel> getAllPartnerStats() throws ProfitMandiBusinessException {
|
70 |
public Map<Integer, PartnerDetailModel> getAllPartnerStats() throws ProfitMandiBusinessException {
|
| 63 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
71 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 64 |
Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
72 |
Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
| Line 95... |
Line 103... |
| 95 |
int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
|
103 |
int hygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
|
| 96 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
104 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
| 97 |
int invalidHygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
|
105 |
int invalidHygieneCount = (int) hygieneDataRepository.selectHygieneCount(fofoId, true,
|
| 98 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
106 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.plusMonths(1).withDayOfMonth(1));
|
| 99 |
int totalHygieneCount = hygieneCount + invalidHygieneCount;
|
107 |
int totalHygieneCount = hygieneCount + invalidHygieneCount;
|
| - |
|
108 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
| - |
|
109 |
|
| - |
|
110 |
Map<EscalationType, AuthUser> authuserEsclationTypeMap = csService
|
| - |
|
111 |
.getAuthUserAndEsclationByPartnerId(fofoId);
|
| 100 |
PartnerDetailModel pm = new PartnerDetailModel();
|
112 |
PartnerDetailModel pm = new PartnerDetailModel();
|
| 101 |
pm.setLmtd(lmtdSale.get(fofoId) == null ? 0 : lmtdSale.get(fofoId));
|
113 |
pm.setLmtd(lmtdSale.get(fofoId) == null ? 0 : lmtdSale.get(fofoId));
|
| 102 |
pm.setMtd(mtdSale.get(fofoId) == null ? 0 : mtdSale.get(fofoId));
|
114 |
pm.setMtd(mtdSale.get(fofoId) == null ? 0 : mtdSale.get(fofoId));
|
| 103 |
pm.setLastOneDayTertiary(last1daystertiary.get(fofoId) == null ? 0 : last1daystertiary.get(fofoId));
|
115 |
pm.setLastOneDayTertiary(last1daystertiary.get(fofoId) == null ? 0 : last1daystertiary.get(fofoId));
|
| 104 |
pm.setLastThreeDaytertiary(last3daystertiary.get(fofoId) == null ? 0 : last3daystertiary.get(fofoId));
|
116 |
pm.setLastThreeDaytertiary(last3daystertiary.get(fofoId) == null ? 0 : last3daystertiary.get(fofoId));
|
| 105 |
pm.setWalletAmount(userWallet.get(fofoId).getAmount() == 0 ? 0 : userWallet.get(fofoId).getAmount());
|
117 |
pm.setWalletAmount(userWallet.get(fofoId).getAmount() == 0 ? 0 : userWallet.get(fofoId).getAmount());
|
| 106 |
pm.setInvestment(investmentMap.get(fofoId));
|
118 |
pm.setInvestment(investmentMap.get(fofoId));
|
| 107 |
pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
|
119 |
pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
|
| 108 |
pm.setHygiene(hygieneCount);
|
120 |
pm.setHygiene(hygieneCount);
|
| - |
|
121 |
pm.setPartnerType(partnerType);
|
| 109 |
|
122 |
|
| 110 |
pm.setAuthUser(csService.getAuthUserByPartnerId(fofoId).get(0) == null ? "not available"
|
123 |
pm.setAuthUser(authuserEsclationTypeMap.get(EscalationType.L1) == null ? "Not Available"
|
| 111 |
: csService.getAuthUserByPartnerId(fofoId).get(0));
|
124 |
: authuserEsclationTypeMap.get(EscalationType.L1).getName());
|
| 112 |
pm.setTotalHygiene(totalHygieneCount);
|
125 |
pm.setTotalHygiene(totalHygieneCount);
|
| 113 |
|
126 |
|
| 114 |
pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
|
127 |
pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
|
| 115 |
allPartnerStats.put(fofoId, pm);
|
128 |
allPartnerStats.put(fofoId, pm);
|
| 116 |
LOGGER.info("pm {}", pm);
|
129 |
LOGGER.info("pm {}", pm);
|