| Line 42... |
Line 42... |
| 42 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
42 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 43 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
43 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| 44 |
import com.spice.profitmandi.common.util.FileUtil;
|
44 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 45 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
45 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 46 |
import com.spice.profitmandi.common.util.Utils;
|
46 |
import com.spice.profitmandi.common.util.Utils;
|
| - |
|
47 |
import com.spice.profitmandi.dao.entity.cs.Ticket;
|
| - |
|
48 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
| 47 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
49 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
| 48 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
50 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
| 49 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
51 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
| 50 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
52 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
| 51 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
53 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| Line 58... |
Line 60... |
| 58 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
60 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 59 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
61 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 60 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
62 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| 61 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
63 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
| 62 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
64 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| - |
|
65 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
66 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 64 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
67 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| - |
|
68 |
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
|
| - |
|
69 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| 65 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
70 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
| 66 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
71 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 67 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
|
72 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
|
| 68 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
73 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
| 69 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
74 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| Line 92... |
Line 97... |
| 92 |
|
97 |
|
| 93 |
@Component
|
98 |
@Component
|
| 94 |
@Transactional(rollbackFor = Throwable.class)
|
99 |
@Transactional(rollbackFor = Throwable.class)
|
| 95 |
public class ScheduledTasks {
|
100 |
public class ScheduledTasks {
|
| 96 |
|
101 |
|
| - |
|
102 |
private static final String Escalate_TICKET = "Dear {0},Your Ticket created by {1} is escalated and assigned to {2}. Regards \nSmartdukaan";
|
| - |
|
103 |
|
| 97 |
@Value("${oxigen.recharge.transaction.url}")
|
104 |
@Value("${oxigen.recharge.transaction.url}")
|
| 98 |
private String oxigenRechargeTransactionUrl;
|
105 |
private String oxigenRechargeTransactionUrl;
|
| 99 |
|
106 |
|
| 100 |
@Value("${oxigen.recharge.enquiry.url}")
|
107 |
@Value("${oxigen.recharge.enquiry.url}")
|
| 101 |
private String oxigenRechargeEnquiryUrl;
|
108 |
private String oxigenRechargeEnquiryUrl;
|
| 102 |
|
109 |
|
| 103 |
@Autowired
|
110 |
@Autowired
|
| 104 |
private PriceDropService priceDropService;
|
111 |
private PriceDropService priceDropService;
|
| 105 |
|
112 |
|
| 106 |
@Value("${oxigen.recharge.auth.key}")
|
113 |
@Value("${oxigen.recharge.auth.key}")
|
| 107 |
private String oxigenRechargeAuthKey;
|
114 |
private String oxigenRechargeAuthKey;
|
| Line 219... |
Line 226... |
| 219 |
private JavaMailSender googleMailSender;
|
226 |
private JavaMailSender googleMailSender;
|
| 220 |
|
227 |
|
| 221 |
@Autowired
|
228 |
@Autowired
|
| 222 |
private InventoryService inventoryService;
|
229 |
private InventoryService inventoryService;
|
| 223 |
|
230 |
|
| - |
|
231 |
@Autowired
|
| - |
|
232 |
private TicketRepository ticketRepository;
|
| - |
|
233 |
|
| - |
|
234 |
@Autowired
|
| - |
|
235 |
private TicketAssignedRepository ticketAssignedRepository;
|
| - |
|
236 |
|
| - |
|
237 |
@Autowired
|
| - |
|
238 |
private AuthRepository authRepository;
|
| - |
|
239 |
|
| 224 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
240 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
| 225 |
|
241 |
|
| 226 |
public void generateDailyRecharge() {
|
242 |
public void generateDailyRecharge() {
|
| 227 |
List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
|
243 |
List<RechargeProviderCreditWalletHistory> allCreditHistory = rechargeProviderCreditWalletHistoryRepository
|
| 228 |
.selectAll(0, 2000);
|
244 |
.selectAll(0, 2000);
|
| Line 425... |
Line 441... |
| 425 |
public void processScheme(int offset) throws Exception {
|
441 |
public void processScheme(int offset) throws Exception {
|
| 426 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
|
442 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
|
| 427 |
LocalDateTime endDate = startDate.plusDays(30);
|
443 |
LocalDateTime endDate = startDate.plusDays(30);
|
| 428 |
processScheme(startDate, endDate);
|
444 |
processScheme(startDate, endDate);
|
| 429 |
}
|
445 |
}
|
| 430 |
|
446 |
|
| 431 |
public void processScheme(int offset, int durationDays) throws Exception {
|
447 |
public void processScheme(int offset, int durationDays) throws Exception {
|
| 432 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
|
448 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
|
| 433 |
LocalDateTime endDate = startDate.plusDays(durationDays);
|
449 |
LocalDateTime endDate = startDate.plusDays(durationDays);
|
| 434 |
processScheme(startDate, endDate);
|
450 |
processScheme(startDate, endDate);
|
| 435 |
}
|
451 |
}
|
| Line 499... |
Line 515... |
| 499 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
515 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
| 500 |
if (retailer == null) {
|
516 |
if (retailer == null) {
|
| 501 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
517 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
| 502 |
continue;
|
518 |
continue;
|
| 503 |
}
|
519 |
}
|
| 504 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService
|
520 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoStore.getId(),
|
| 505 |
.getInvestment(fofoStore.getId(), 1);
|
521 |
1);
|
| 506 |
partnerDailyInvestment.setDate(yesterDay);
|
522 |
partnerDailyInvestment.setDate(yesterDay);
|
| 507 |
partnerDailyInvestmentRepository.persist(partnerDailyInvestment);
|
523 |
partnerDailyInvestmentRepository.persist(partnerDailyInvestment);
|
| 508 |
|
524 |
|
| 509 |
List<Object> row = Arrays.asList(fofoStore.getCode(), retailer.getBusinessName(), retailer.getEmail(),
|
525 |
List<Object> row = Arrays.asList(fofoStore.getCode(), retailer.getBusinessName(), retailer.getEmail(),
|
| 510 |
retailer.getMobileNumber(), partnerDailyInvestment.getWalletAmount(),
|
526 |
retailer.getMobileNumber(), partnerDailyInvestment.getWalletAmount(),
|
| 511 |
partnerDailyInvestment.getSalesAmount(), partnerDailyInvestment.getInStockAmount(), 0,
|
527 |
partnerDailyInvestment.getSalesAmount(), partnerDailyInvestment.getInStockAmount(), 0,
|
| 512 |
partnerDailyInvestment.getUnbilledAmount(), partnerDailyInvestment.getGrnPendingAmount(),
|
528 |
partnerDailyInvestment.getUnbilledAmount(), partnerDailyInvestment.getGrnPendingAmount(),
|
| 513 |
partnerDailyInvestment.getMinInvestment(), partnerDailyInvestment.getTotalInvestment(), partnerDailyInvestment.getShortInvestment());
|
529 |
partnerDailyInvestment.getMinInvestment(), partnerDailyInvestment.getTotalInvestment(),
|
| - |
|
530 |
partnerDailyInvestment.getShortInvestment());
|
| 514 |
rows.add(row);
|
531 |
rows.add(row);
|
| 515 |
|
532 |
|
| 516 |
}
|
533 |
}
|
| 517 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
534 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 518 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
535 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, rows);
|
| Line 621... |
Line 638... |
| 621 |
this.sendMailWithAttachmentsForPartners(fofoIdsAndCustomRetailer.get(fofoId).getEmail(), message, subject,
|
638 |
this.sendMailWithAttachmentsForPartners(fofoIdsAndCustomRetailer.get(fofoId).getEmail(), message, subject,
|
| 622 |
is);
|
639 |
is);
|
| 623 |
|
640 |
|
| 624 |
}
|
641 |
}
|
| 625 |
}
|
642 |
}
|
| 626 |
|
643 |
|
| 627 |
public void moveImeisToPriceDropImeis() throws Exception{
|
644 |
public void moveImeisToPriceDropImeis() throws Exception {
|
| 628 |
List<PriceDrop> priceDrops = priceDropRepository.selectAll();
|
645 |
List<PriceDrop> priceDrops = priceDropRepository.selectAll();
|
| 629 |
for(PriceDrop priceDrop : priceDrops) {
|
646 |
for (PriceDrop priceDrop : priceDrops) {
|
| 630 |
priceDropService.priceDropStatus(priceDrop.getId());
|
647 |
priceDropService.priceDropStatus(priceDrop.getId());
|
| 631 |
}
|
648 |
}
|
| 632 |
}
|
649 |
}
|
| 633 |
|
650 |
|
| - |
|
651 |
public void escalateTicket() throws ProfitMandiBusinessException {
|
| - |
|
652 |
List<Ticket> tickets = ticketRepository.selectAllNotClosedTickets();
|
| - |
|
653 |
for (Ticket ticket : tickets) {
|
| - |
|
654 |
if ((ticket.getL2EscalationTimestamp().isBefore(LocalDateTime.now())
|
| - |
|
655 |
|| ticket.getL2EscalationTimestamp().isEqual(LocalDateTime.now()))
|
| - |
|
656 |
&& ticket.getL3EscalationTimestamp().isAfter(LocalDateTime.now())) {
|
| - |
|
657 |
TicketAssigned ticketAssigned = ticketAssignedRepository
|
| - |
|
658 |
.selectByAssigneeIdAndTicketId(ticket.getL2AuthUser(), ticket.getId());
|
| - |
|
659 |
if (ticketAssigned == null) {
|
| - |
|
660 |
ticketAssigned = new TicketAssigned();
|
| - |
|
661 |
ticketAssigned.setAssineeId(ticket.getL2AuthUser());
|
| - |
|
662 |
ticketAssigned.setTicketId(ticket.getId());
|
| - |
|
663 |
ticketAssignedRepository.persist(ticketAssigned);
|
| - |
|
664 |
String subject = "Escalated Ticket";
|
| - |
|
665 |
LOGGER.info(subject);
|
| - |
|
666 |
|
| - |
|
667 |
String message = MessageFormat.format(Escalate_TICKET,
|
| - |
|
668 |
authRepository.selectById(ticket.getL1AuthUser()).getFirstName(),
|
| - |
|
669 |
retailerService.getFofoRetailer(ticket.getFofoId()).getBusinessName(),
|
| - |
|
670 |
authRepository.selectById(ticket.getL2AuthUser()).getFirstName());
|
| - |
|
671 |
LOGGER.info(message);
|
| - |
|
672 |
|
| - |
|
673 |
String[] cc = { authRepository.selectById(ticket.getL2AuthUser()).getEmailId() };
|
| - |
|
674 |
LOGGER.info(cc[0]);
|
| - |
|
675 |
|
| - |
|
676 |
String to = authRepository.selectById(ticket.getL1AuthUser()).getEmailId();
|
| - |
|
677 |
LOGGER.info(to);
|
| - |
|
678 |
|
| - |
|
679 |
this.sendEscaltedTicketMail(to, subject, message, cc);
|
| - |
|
680 |
LOGGER.info(subject + " " + message + " " + to + " " + cc[0]);
|
| - |
|
681 |
}
|
| - |
|
682 |
} else if ((ticket.getL3EscalationTimestamp().isBefore(LocalDateTime.now())
|
| - |
|
683 |
|| ticket.getL3EscalationTimestamp().isEqual(LocalDateTime.now()))
|
| - |
|
684 |
&& ticket.getLastEscalationTimestamp().isAfter(LocalDateTime.now())) {
|
| - |
|
685 |
|
| - |
|
686 |
TicketAssigned ticketAssigned = ticketAssignedRepository
|
| - |
|
687 |
.selectByAssigneeIdAndTicketId(ticket.getL3AuthUser(), ticket.getId());
|
| - |
|
688 |
if (ticketAssigned == null) {
|
| - |
|
689 |
ticketAssigned = new TicketAssigned();
|
| - |
|
690 |
ticketAssigned.setAssineeId(ticket.getL3AuthUser());
|
| - |
|
691 |
ticketAssigned.setTicketId(ticket.getId());
|
| - |
|
692 |
ticketAssignedRepository.persist(ticketAssigned);
|
| - |
|
693 |
String subject = "Escalated Ticket";
|
| - |
|
694 |
String message = MessageFormat.format(Escalate_TICKET,
|
| - |
|
695 |
authRepository.selectById(ticket.getL2AuthUser()).getFirstName(),
|
| - |
|
696 |
retailerService.getFofoRetailer(ticket.getFofoId()).getBusinessName(),
|
| - |
|
697 |
authRepository.selectById(ticket.getL3AuthUser()).getFirstName());
|
| - |
|
698 |
LOGGER.info(subject);
|
| - |
|
699 |
LOGGER.info(message);
|
| - |
|
700 |
String[] cc = { authRepository.selectById(ticket.getL3AuthUser()).getEmailId() };
|
| - |
|
701 |
LOGGER.info(cc[0]);
|
| - |
|
702 |
|
| - |
|
703 |
String to = authRepository.selectById(ticket.getL2AuthUser()).getEmailId();
|
| - |
|
704 |
LOGGER.info(to);
|
| - |
|
705 |
this.sendEscaltedTicketMail(to, subject, message, cc);
|
| - |
|
706 |
LOGGER.info(subject);
|
| - |
|
707 |
}
|
| - |
|
708 |
}
|
| - |
|
709 |
}
|
| - |
|
710 |
}
|
| - |
|
711 |
|
| - |
|
712 |
private void sendEscaltedTicketMail(String to, String subject, String message, String[] cc)
|
| - |
|
713 |
throws ProfitMandiBusinessException {
|
| - |
|
714 |
try {
|
| - |
|
715 |
Utils.sendMailWithAttachments(mailSender, to, cc, subject, message, null);
|
| - |
|
716 |
LOGGER.info("mail send successfully");
|
| - |
|
717 |
} catch (Exception e) {
|
| - |
|
718 |
throw new ProfitMandiBusinessException("Escalated Ticket", to, "Could not send Escalated ticket mail");
|
| - |
|
719 |
}
|
| - |
|
720 |
}
|
| - |
|
721 |
|
| 634 |
}
|
722 |
}
|