| Line 18... |
Line 18... |
| 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.auth.AuthUser;
|
| 20 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
20 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 21 |
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;
|
22 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| - |
|
23 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 23 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
24 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 24 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
25 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 25 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
26 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
| 26 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
27 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 27 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
28 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
29 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
30 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
31 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
32 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| - |
|
33 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 32 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
34 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 33 |
import com.spice.profitmandi.service.user.RetailerService;
|
35 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 34 |
|
36 |
|
| 35 |
@Component
|
37 |
@Component
|
| 36 |
public class PartnerStatsServiceImpl implements PartnerStatsService {
|
38 |
public class PartnerStatsServiceImpl implements PartnerStatsService {
|
| Line 62... |
Line 64... |
| 62 |
UserWalletRepository userWalletRepository;
|
64 |
UserWalletRepository userWalletRepository;
|
| 63 |
|
65 |
|
| 64 |
@Autowired
|
66 |
@Autowired
|
| 65 |
PartnerTypeChangeService partnerTypeChangeService;
|
67 |
PartnerTypeChangeService partnerTypeChangeService;
|
| 66 |
|
68 |
|
| - |
|
69 |
@Autowired
|
| - |
|
70 |
OrderRepository orderRepository;
|
| - |
|
71 |
|
| 67 |
@Override
|
72 |
@Override
|
| 68 |
// @Cacheable(value = "partnerStats", cacheManager =
|
73 |
// @Cacheable(value = "partnerStats", cacheManager =
|
| 69 |
// "thirtyMinsTimeOutCacheManager")
|
74 |
// "thirtyMinsTimeOutCacheManager")
|
| 70 |
public Map<Integer, PartnerDetailModel> getAllPartnerStats() throws ProfitMandiBusinessException {
|
75 |
public Map<Integer, PartnerDetailModel> getAllPartnerStats() throws ProfitMandiBusinessException {
|
| 71 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
76 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| Line 83... |
Line 88... |
| 83 |
Map<Integer, Long> last3daystertiary = fofoOrderItemRepository.selectQtyGroupByRetailer(curDate.minusDays(4),
|
88 |
Map<Integer, Long> last3daystertiary = fofoOrderItemRepository.selectQtyGroupByRetailer(curDate.minusDays(4),
|
| 84 |
curDate.minusDays(1).with(LocalTime.MAX), 0, false);
|
89 |
curDate.minusDays(1).with(LocalTime.MAX), 0, false);
|
| 85 |
|
90 |
|
| 86 |
Map<Integer, Long> ticketMap = ticketRepository.selectAllOpenTicketsGroupByRetailer();
|
91 |
Map<Integer, Long> ticketMap = ticketRepository.selectAllOpenTicketsGroupByRetailer();
|
| 87 |
|
92 |
|
| - |
|
93 |
Map<Integer, Double> secondaryMtd = orderRepository
|
| - |
|
94 |
.selectBillingDatesBetweenSumGroupByRetailerId(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
|
| - |
|
95 |
Map<Integer, Double> secondarylmtd = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
|
| - |
|
96 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1));
|
| - |
|
97 |
Map<Integer, Double> secondarylms = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
|
| - |
|
98 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1));
|
| - |
|
99 |
|
| - |
|
100 |
LOGGER.info("secondarylmtd" + secondarylmtd);
|
| - |
|
101 |
LOGGER.info("secondarylms" + secondarylms);
|
| 88 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
102 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
| 89 |
Set<Integer> fofoIds = fofoStores.stream().map(x -> x.getId()).collect(Collectors.toSet());
|
103 |
Set<Integer> fofoIds = fofoStores.stream().map(x -> x.getId()).collect(Collectors.toSet());
|
| 90 |
Map<Integer, UserWallet> userWallet = userWalletRepository.selectByRetailerIds(fofoIds).stream()
|
104 |
Map<Integer, UserWallet> userWallet = userWalletRepository.selectByRetailerIds(fofoIds).stream()
|
| 91 |
.collect(Collectors.toMap(x -> x.getUserId(), x -> x));
|
105 |
.collect(Collectors.toMap(x -> x.getUserId(), x -> x));
|
| 92 |
|
106 |
|
| Line 114... |
Line 128... |
| 114 |
.getAuthUserAndEsclationByPartnerId(fofoId);
|
128 |
.getAuthUserAndEsclationByPartnerId(fofoId);
|
| 115 |
PartnerDetailModel pm = new PartnerDetailModel();
|
129 |
PartnerDetailModel pm = new PartnerDetailModel();
|
| 116 |
pm.setLmtd(lmtdSale.get(fofoId) == null ? 0 : lmtdSale.get(fofoId).intValue());
|
130 |
pm.setLmtd(lmtdSale.get(fofoId) == null ? 0 : lmtdSale.get(fofoId).intValue());
|
| 117 |
pm.setMtd(mtdSale.get(fofoId) == null ? 0 : mtdSale.get(fofoId).intValue());
|
131 |
pm.setMtd(mtdSale.get(fofoId) == null ? 0 : mtdSale.get(fofoId).intValue());
|
| 118 |
pm.setLms(lmsSale.get(fofoId) == null ? 0 : lmsSale.get(fofoId).intValue());
|
132 |
pm.setLms(lmsSale.get(fofoId) == null ? 0 : lmsSale.get(fofoId).intValue());
|
| - |
|
133 |
pm.setSecondarymtd(secondaryMtd.get(fofoId) == null ? 0 : secondaryMtd.get(fofoId).intValue());
|
| - |
|
134 |
pm.setSecondarylmtd(secondarylmtd.get(fofoId) == null ? 0 : secondarylmtd.get(fofoId).intValue());
|
| - |
|
135 |
pm.setSecondarylms(secondarylms.get(fofoId) == null ? 0 : secondarylms.get(fofoId).intValue());
|
| 119 |
pm.setTodayTertiary(todaytertiary.get(fofoId) == null ? 0 : todaytertiary.get(fofoId).intValue());
|
136 |
pm.setTodayTertiary(todaytertiary.get(fofoId) == null ? 0 : todaytertiary.get(fofoId).intValue());
|
| 120 |
pm.setLastThreeDaytertiary(last3daystertiary.get(fofoId) == null ? 0 : last3daystertiary.get(fofoId));
|
137 |
pm.setLastThreeDaytertiary(last3daystertiary.get(fofoId) == null ? 0 : last3daystertiary.get(fofoId));
|
| 121 |
pm.setWalletAmount(userWallet.get(fofoId) == null ? 0 : userWallet.get(fofoId).getAmount());
|
138 |
pm.setWalletAmount(userWallet.get(fofoId) == null ? 0 : userWallet.get(fofoId).getAmount());
|
| 122 |
pm.setInvestment(investmentMap.get(fofoId));
|
139 |
pm.setInvestment(investmentMap.get(fofoId));
|
| 123 |
pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
|
140 |
pm.setTicket(ticketMap.get(fofoId) == null ? 0 : ticketMap.get(fofoId).intValue());
|