| Line 16... |
Line 16... |
| 16 |
import java.util.Comparator;
|
16 |
import java.util.Comparator;
|
| 17 |
import java.util.HashMap;
|
17 |
import java.util.HashMap;
|
| 18 |
import java.util.HashSet;
|
18 |
import java.util.HashSet;
|
| 19 |
import java.util.List;
|
19 |
import java.util.List;
|
| 20 |
import java.util.Map;
|
20 |
import java.util.Map;
|
| - |
|
21 |
import java.util.Map.Entry;
|
| 21 |
import java.util.Optional;
|
22 |
import java.util.Optional;
|
| 22 |
import java.util.Set;
|
23 |
import java.util.Set;
|
| 23 |
import java.util.stream.Collectors;
|
24 |
import java.util.stream.Collectors;
|
| 24 |
|
25 |
|
| 25 |
import javax.mail.MessagingException;
|
26 |
import javax.mail.MessagingException;
|
| Line 88... |
Line 89... |
| 88 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
89 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 89 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
90 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 90 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
91 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 91 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
92 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 92 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
93 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| - |
|
94 |
import com.spice.profitmandi.dao.entity.fofo.PartnerProblem;
|
| 93 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
95 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 94 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
96 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 95 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
97 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 96 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
98 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
| 97 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
99 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| - |
|
100 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 98 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
101 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| 99 |
import com.spice.profitmandi.dao.entity.transaction.PriceDropIMEI;
|
102 |
import com.spice.profitmandi.dao.entity.transaction.PriceDropIMEI;
|
| 100 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
103 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 101 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
104 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 102 |
import com.spice.profitmandi.dao.entity.user.Address;
|
105 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| Line 128... |
Line 131... |
| 128 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeVisitRepository;
|
131 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeVisitRepository;
|
| 129 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
132 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
| 130 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
133 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 131 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
134 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 132 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
135 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
| - |
|
136 |
import com.spice.profitmandi.dao.repository.dtr.PartnerProblemRepository;
|
| 133 |
import com.spice.profitmandi.dao.repository.dtr.PushNotificationRepository;
|
137 |
import com.spice.profitmandi.dao.repository.dtr.PushNotificationRepository;
|
| 134 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
|
138 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
|
| 135 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
139 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
| 136 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
140 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| 137 |
import com.spice.profitmandi.dao.repository.dtr.RefferalRepository;
|
141 |
import com.spice.profitmandi.dao.repository.dtr.RefferalRepository;
|
| Line 187... |
Line 191... |
| 187 |
@Value("${oxigen.recharge.enquiry.url}")
|
191 |
@Value("${oxigen.recharge.enquiry.url}")
|
| 188 |
private String oxigenRechargeEnquiryUrl;
|
192 |
private String oxigenRechargeEnquiryUrl;
|
| 189 |
|
193 |
|
| 190 |
@Autowired
|
194 |
@Autowired
|
| 191 |
private RegionRepository regionRepository;
|
195 |
private RegionRepository regionRepository;
|
| 192 |
|
196 |
|
| 193 |
private static final DateTimeFormatter leadTimeFormatter = DateTimeFormatter.ofPattern("d LLL, hh:mm a");
|
197 |
private static final DateTimeFormatter leadTimeFormatter = DateTimeFormatter.ofPattern("d LLL, hh:mm a");
|
| 194 |
|
198 |
|
| 195 |
@Autowired
|
199 |
@Autowired
|
| 196 |
private PartnerRegionRepository partnerRegionRepository;
|
200 |
private PartnerRegionRepository partnerRegionRepository;
|
| 197 |
|
201 |
|
| Line 276... |
Line 280... |
| 276 |
private SchemeService schemeService;
|
280 |
private SchemeService schemeService;
|
| 277 |
|
281 |
|
| 278 |
private static final String[] STOCK_AGEING_MAIL_LIST = new String[] { "uday.singh@smartudkaan.com",
|
282 |
private static final String[] STOCK_AGEING_MAIL_LIST = new String[] { "uday.singh@smartudkaan.com",
|
| 279 |
"adeel.yazdani@smartdukaan.com", "kamini.sharma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com",
|
283 |
"adeel.yazdani@smartdukaan.com", "kamini.sharma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com",
|
| 280 |
"ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com", "hemant.kaura@smartdukaan.com",
|
284 |
"ankit.bhatia@smartdukaan.com", "tarun.verma@smartdukaan.com", "hemant.kaura@smartdukaan.com",
|
| 281 |
"rajat.gupta@smartdukaan.com", "kuldeep.kumar@smartdukaan.com",
|
285 |
"rajat.gupta@smartdukaan.com", "kuldeep.kumar@smartdukaan.com", "manish.gupta@smartdukaan.com" };
|
| 282 |
"manish.gupta@smartdukaan.com" };
|
- |
|
| 283 |
|
286 |
|
| 284 |
private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[] { "kamini.sharma@smartdukaan.com",
|
287 |
private static final String[] ITEMWISE_PENDING_INDENT_MAIL_LIST = new String[] { "kamini.sharma@smartdukaan.com",
|
| 285 |
"tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com",
|
288 |
"tarun.verma@smartdukaan.com", "uday.singh@smartdukaan.com", "kuldeep.kumar@smartdukaan.com",
|
| 286 |
"kuldeep.kumar@smartdukaan.com", "niranjan.kala@smartdukaan.com" };
|
289 |
"niranjan.kala@smartdukaan.com" };
|
| 287 |
|
290 |
|
| 288 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
291 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 289 |
|
292 |
|
| 290 |
@Autowired
|
293 |
@Autowired
|
| 291 |
private ReporticoService reporticoService;
|
294 |
private ReporticoService reporticoService;
|
| Line 433... |
Line 436... |
| 433 |
private TicketRepository ticketRepository;
|
436 |
private TicketRepository ticketRepository;
|
| 434 |
|
437 |
|
| 435 |
@Autowired
|
438 |
@Autowired
|
| 436 |
private RefferalRepository refferalRepository;
|
439 |
private RefferalRepository refferalRepository;
|
| 437 |
|
440 |
|
| - |
|
441 |
@Autowired
|
| - |
|
442 |
private PartnerProblemRepository partnerProblemRepository;
|
| - |
|
443 |
|
| 438 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
444 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
| 439 |
|
445 |
|
| 440 |
private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
|
446 |
private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
|
| 441 |
private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
|
447 |
private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
|
| 442 |
|
448 |
|
| Line 544... |
Line 550... |
| 544 |
LOGGER.info("Could not check status for Request {}", rechargeTransaction.getRequestId());
|
550 |
LOGGER.info("Could not check status for Request {}", rechargeTransaction.getRequestId());
|
| 545 |
}
|
551 |
}
|
| 546 |
}
|
552 |
}
|
| 547 |
LOGGER.info("Reconcile recharge ran successfully");
|
553 |
LOGGER.info("Reconcile recharge ran successfully");
|
| 548 |
}
|
554 |
}
|
| 549 |
|
555 |
|
| 550 |
public void processActivation() throws Exception {
|
556 |
public void processActivation() throws Exception {
|
| 551 |
schemeService.processActivation();
|
557 |
schemeService.processActivation();
|
| 552 |
}
|
558 |
}
|
| 553 |
|
559 |
|
| 554 |
// TemporaryMethod
|
560 |
// TemporaryMethod
|
| Line 646... |
Line 652... |
| 646 |
public void processScheme(int offset, boolean dryRun) throws Exception {
|
652 |
public void processScheme(int offset, boolean dryRun) throws Exception {
|
| 647 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
|
653 |
LocalDateTime startDate = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT).minusDays(offset);
|
| 648 |
LocalDateTime endDate = startDate.plusDays(30);
|
654 |
LocalDateTime endDate = startDate.plusDays(30);
|
| 649 |
processScheme(startDate, endDate, dryRun);
|
655 |
processScheme(startDate, endDate, dryRun);
|
| 650 |
}
|
656 |
}
|
| 651 |
|
657 |
|
| 652 |
public void processSchemeOut(List<String> invoiceNumbers) throws Exception {
|
658 |
public void processSchemeOut(List<String> invoiceNumbers) throws Exception {
|
| 653 |
for(String invoiceNumber : invoiceNumbers) {
|
659 |
for (String invoiceNumber : invoiceNumbers) {
|
| 654 |
System.out.println("Invoice Number - " + invoiceNumber);
|
660 |
System.out.println("Invoice Number - " + invoiceNumber);
|
| 655 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
661 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
| 656 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
|
662 |
schemeService.processSchemeOut(fofoOrder.getId(), fofoOrder.getFofoId());
|
| 657 |
}
|
663 |
}
|
| 658 |
}
|
664 |
}
|
| 659 |
|
665 |
|
| 660 |
public void processSchemeIn(List<String> invoiceNumbers) throws Exception {
|
666 |
public void processSchemeIn(List<String> invoiceNumbers) throws Exception {
|
| 661 |
for(String invoiceNumber : invoiceNumbers) {
|
667 |
for (String invoiceNumber : invoiceNumbers) {
|
| 662 |
System.out.println("Invoice Number - " + invoiceNumber);
|
668 |
System.out.println("Invoice Number - " + invoiceNumber);
|
| 663 |
Purchase purchase = purchaseRepository.selectByPurchaseReference(invoiceNumber);
|
669 |
Purchase purchase = purchaseRepository.selectByPurchaseReference(invoiceNumber);
|
| 664 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
670 |
schemeService.processSchemeIn(purchase.getId(), purchase.getFofoId());
|
| 665 |
}
|
671 |
}
|
| 666 |
}
|
672 |
}
|
| 667 |
|
673 |
|
| Line 692... |
Line 698... |
| 692 |
}
|
698 |
}
|
| 693 |
} catch (Exception e) {
|
699 |
} catch (Exception e) {
|
| 694 |
e.printStackTrace();
|
700 |
e.printStackTrace();
|
| 695 |
throw e;
|
701 |
throw e;
|
| 696 |
}
|
702 |
}
|
| 697 |
List<UserWalletHistory> uwhs = userWalletHistoryRepository.selectAllByDateType(LocalDate.now().atStartOfDay(), endDate,
|
703 |
List<UserWalletHistory> uwhs = userWalletHistoryRepository.selectAllByDateType(LocalDate.now().atStartOfDay(),
|
| 698 |
Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
704 |
endDate, Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
| 699 |
System.out.println("Amount\tReference\tReferenceType\tTimestamp\tDescription");
|
705 |
System.out.println("Amount\tReference\tReferenceType\tTimestamp\tDescription");
|
| 700 |
for (UserWalletHistory uwh : uwhs) {
|
706 |
for (UserWalletHistory uwh : uwhs) {
|
| 701 |
System.out.println(String.format("%d\t%d\t%s\t%s\t%s", uwh.getAmount(), uwh.getReference(),
|
707 |
System.out.println(String.format("%d\t%d\t%s\t%s\t%s", uwh.getAmount(), uwh.getReference(),
|
| 702 |
uwh.getReferenceType(), uwh.getTimestamp().toString(), uwh.getDescription()));
|
708 |
uwh.getReferenceType(), uwh.getTimestamp().toString(), uwh.getDescription()));
|
| 703 |
}
|
709 |
}
|
| Line 1878... |
Line 1884... |
| 1878 |
}
|
1884 |
}
|
| 1879 |
}
|
1885 |
}
|
| 1880 |
}
|
1886 |
}
|
| 1881 |
|
1887 |
|
| 1882 |
public void attachToffeeInvoices() throws Exception {
|
1888 |
public void attachToffeeInvoices() throws Exception {
|
| - |
|
1889 |
/*
|
| 1883 |
/*LOGGER.info("Insurance Sum Summary --- {}",
|
1890 |
* LOGGER.info("Insurance Sum Summary --- {}",
|
| 1884 |
insurancePolicyRepository.selectAmountSumGroupByRetailerId(LocalDateTime.MIN, LocalDateTime.MAX));
|
1891 |
* insurancePolicyRepository.selectAmountSumGroupByRetailerId(LocalDateTime.MIN,
|
| 1885 |
LOGGER.info("Insurance Qty Summary --- {}",
|
1892 |
* LocalDateTime.MAX)); LOGGER.info("Insurance Qty Summary --- {}",
|
| 1886 |
insurancePolicyRepository.selectQtyGroupByRetailerId(LocalDateTime.MIN, LocalDateTime.MAX));
|
1893 |
* insurancePolicyRepository.selectQtyGroupByRetailerId(LocalDateTime.MIN,
|
| 1887 |
LOGGER.info("SmartPhone Amount Summary --- {}",
|
1894 |
* LocalDateTime.MAX)); LOGGER.info("SmartPhone Amount Summary --- {}",
|
| 1888 |
fofoOrderItemRepository.selectSumAmountGroupByRetailer(LocalDateTime.MIN, LocalDateTime.MAX, 0, true));
|
1895 |
* fofoOrderItemRepository.selectSumAmountGroupByRetailer(LocalDateTime.MIN,
|
| 1889 |
LOGGER.info("Smartphone Qty Summary --- {}",
|
1896 |
* LocalDateTime.MAX, 0, true)); LOGGER.info("Smartphone Qty Summary --- {}",
|
| 1890 |
fofoOrderItemRepository.selectQtyGroupByRetailer(LocalDateTime.MIN, LocalDateTime.MAX, 0, true));*/
|
1897 |
* fofoOrderItemRepository.selectQtyGroupByRetailer(LocalDateTime.MIN,
|
| - |
|
1898 |
* LocalDateTime.MAX, 0, true));
|
| - |
|
1899 |
*/
|
| 1891 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(3, Optional.of(false));
|
1900 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(3,
|
| - |
|
1901 |
Optional.of(false));
|
| 1892 |
for(InsurancePolicy insurancePolicy : insurancePolicies) {
|
1902 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
| 1893 |
String invoiceNumber = insurancePolicy.getInvoiceNumber();
|
1903 |
String invoiceNumber = insurancePolicy.getInvoiceNumber();
|
| 1894 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
1904 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
| 1895 |
PdfModel pdfModel = orderService.getInvoicePdfModel(fofoOrder.getId());
|
1905 |
PdfModel pdfModel = orderService.getInvoicePdfModel(fofoOrder.getId());
|
| 1896 |
java.io.ByteArrayOutputStream byteArrayOutputStream = new java.io.ByteArrayOutputStream();
|
1906 |
java.io.ByteArrayOutputStream byteArrayOutputStream = new java.io.ByteArrayOutputStream();
|
| 1897 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
1907 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
| - |
|
1908 |
String pdfInvoiceString = "data:application/pdf;base64,"
|
| 1898 |
String pdfInvoiceString = "data:application/pdf;base64," + Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());
|
1909 |
+ Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());
|
| 1899 |
boolean attached = toffeeService.attachInvoice(insurancePolicy.getPolicyNumber().split("#")[1], pdfInvoiceString);
|
1910 |
boolean attached = toffeeService.attachInvoice(insurancePolicy.getPolicyNumber().split("#")[1],
|
| - |
|
1911 |
pdfInvoiceString);
|
| 1900 |
if(attached) {
|
1912 |
if (attached) {
|
| 1901 |
insurancePolicy.setPosted(true);
|
1913 |
insurancePolicy.setPosted(true);
|
| 1902 |
}
|
1914 |
}
|
| 1903 |
}
|
1915 |
}
|
| 1904 |
}
|
1916 |
}
|
| 1905 |
|
1917 |
|
| Line 2345... |
Line 2357... |
| 2345 |
return sb.toString();
|
2357 |
return sb.toString();
|
| 2346 |
}
|
2358 |
}
|
| 2347 |
|
2359 |
|
| 2348 |
public void reverseWallet() throws Exception {
|
2360 |
public void reverseWallet() throws Exception {
|
| 2349 |
LocalDate localDate = LocalDate.of(2020, 10, 28);
|
2361 |
LocalDate localDate = LocalDate.of(2020, 10, 28);
|
| 2350 |
List<UserWalletHistory> uwhList = userWalletHistoryRepository.selectAllByDateType(localDate.atStartOfDay(), localDate.plusDays(1).atStartOfDay(),
|
2362 |
List<UserWalletHistory> uwhList = userWalletHistoryRepository.selectAllByDateType(localDate.atStartOfDay(),
|
| - |
|
2363 |
localDate.plusDays(1).atStartOfDay(),
|
| 2351 |
Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
2364 |
Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
|
| 2352 |
for (UserWalletHistory uwh : uwhList) {
|
2365 |
for (UserWalletHistory uwh : uwhList) {
|
| 2353 |
if(uwh.getBusinessTimestamp().getMonth().equals(Month.SEPTEMBER)) {
|
2366 |
if (uwh.getBusinessTimestamp().getMonth().equals(Month.SEPTEMBER)) {
|
| 2354 |
UserWallet uw = userWalletRepository.selectById(uwh.getWalletId());
|
2367 |
UserWallet uw = userWalletRepository.selectById(uwh.getWalletId());
|
| 2355 |
//LOGGER.info("UWH - {}", uwh);
|
2368 |
// LOGGER.info("UWH - {}", uwh);
|
| 2356 |
//amount += uwh.getAmount();
|
2369 |
// amount += uwh.getAmount();
|
| 2357 |
//System.out.println("Amount is - " + amount);
|
2370 |
// System.out.println("Amount is - " + amount);
|
| - |
|
2371 |
// walletService.rollbackAmountFromWallet(uw.getUserId(), uwh.getAmount(),
|
| 2358 |
//walletService.rollbackAmountFromWallet(uw.getUserId(), uwh.getAmount(), uwh.getReference(), uwh.getReferenceType(), "Margin reversal for error prone run", uwh.getBusinessTimestamp());
|
2372 |
// uwh.getReference(), uwh.getReferenceType(), "Margin reversal for error prone
|
| - |
|
2373 |
// run", uwh.getBusinessTimestamp());
|
| 2359 |
int orderId = uwh.getReference();
|
2374 |
int orderId = uwh.getReference();
|
| 2360 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(orderId);
|
2375 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(orderId);
|
| 2361 |
int inventoryItemId = 0;
|
2376 |
int inventoryItemId = 0;
|
| 2362 |
//fofoOrderRepository.delete(fofoOrder);
|
2377 |
// fofoOrderRepository.delete(fofoOrder);
|
| 2363 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
2378 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| - |
|
2379 |
/*
|
| - |
|
2380 |
* List<PaymentOptionTransaction> paymentOptionTransactions =
|
| 2364 |
/*List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
2381 |
* paymentOptionTransactionRepository.selectByReferenceIdAndType(fofoOrder.getId
|
| - |
|
2382 |
* (), PaymentOptionReferenceType.ORDER); for(PaymentOptionTransaction
|
| 2365 |
for(PaymentOptionTransaction paymentOptionTransaction : paymentOptionTransactions) {
|
2383 |
* paymentOptionTransaction : paymentOptionTransactions) {
|
| 2366 |
//paymentOptionTransactionRepository.delete(paymentOptionTransaction);
|
2384 |
* //paymentOptionTransactionRepository.delete(paymentOptionTransaction); }
|
| 2367 |
}*/
|
2385 |
*/
|
| 2368 |
for(FofoOrderItem foi : fofoOrderItems) {
|
2386 |
for (FofoOrderItem foi : fofoOrderItems) {
|
| 2369 |
//fofoOrderItemRepository.delete(foi);
|
2387 |
// fofoOrderItemRepository.delete(foi);
|
| 2370 |
List<FofoLineItem> flis = fofoLineItemRepository.selectByFofoOrderItemId(foi.getId());
|
2388 |
List<FofoLineItem> flis = fofoLineItemRepository.selectByFofoOrderItemId(foi.getId());
|
| 2371 |
for(FofoLineItem fli : flis) {
|
2389 |
for (FofoLineItem fli : flis) {
|
| 2372 |
//fofoLineItemRepository.delete(fli);
|
2390 |
// fofoLineItemRepository.delete(fli);
|
| 2373 |
inventoryItemId = fli.getInventoryItemId();
|
2391 |
inventoryItemId = fli.getInventoryItemId();
|
| 2374 |
}
|
2392 |
}
|
| 2375 |
}
|
2393 |
}
|
| 2376 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(java.util.stream.Stream.of(inventoryItemId).collect(Collectors.toSet()));
|
2394 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectByInventoryItemIds(
|
| - |
|
2395 |
java.util.stream.Stream.of(inventoryItemId).collect(Collectors.toSet()));
|
| 2377 |
for(SchemeInOut sio : schemeInOuts) {
|
2396 |
for (SchemeInOut sio : schemeInOuts) {
|
| 2378 |
if(sio.getCreateTimestamp().toLocalDate().equals(localDate)) {
|
2397 |
if (sio.getCreateTimestamp().toLocalDate().equals(localDate)) {
|
| 2379 |
LOGGER.info("SIO - {}", sio);
|
2398 |
LOGGER.info("SIO - {}", sio);
|
| 2380 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
2399 |
sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 2381 |
}
|
2400 |
}
|
| 2382 |
}
|
2401 |
}
|
| - |
|
2402 |
|
| - |
|
2403 |
}
|
| - |
|
2404 |
}
|
| - |
|
2405 |
|
| - |
|
2406 |
}
|
| - |
|
2407 |
|
| - |
|
2408 |
public void partnerProblemAlert() throws Exception {
|
| - |
|
2409 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
2410 |
Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
| - |
|
2411 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), 0, false);
|
| - |
|
2412 |
Map<Integer, Double> mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1),
|
| - |
|
2413 |
curDate.with(LocalTime.MAX), 0, false);
|
| - |
|
2414 |
Map<Integer, PartnerDailyInvestment> pdi = partnerDailyInvestmentRepository.selectAll(LocalDate.now()).stream()
|
| - |
|
2415 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| - |
|
2416 |
|
| - |
|
2417 |
for (Entry<Integer, Double> ls : lmtdSale.entrySet()) {
|
| - |
|
2418 |
|
| - |
|
2419 |
double lmtdTwentyPercentSale = ls.getValue() * 0.2;
|
| - |
|
2420 |
double mtdSale = mtdSales.get(ls.getKey());
|
| - |
|
2421 |
double totalSixtyPercentInvestment = pdi.get(ls.getKey()).getTotalInvestment() * 0.6;
|
| - |
|
2422 |
|
| - |
|
2423 |
double stockInvestment = pdi.get(ls.getKey()).getInStockAmount();
|
| - |
|
2424 |
boolean Investmentvalue = partnerInvestmentService.isInvestmentBelow(ls.getKey(), 25);
|
| - |
|
2425 |
|
| - |
|
2426 |
PartnerProblem partnerProblem = partnerProblemRepository.selectByFofoId(ls.getKey());
|
| - |
|
2427 |
|
| - |
|
2428 |
if (partnerProblem != null) {
|
| - |
|
2429 |
partnerProblem = new PartnerProblem();
|
| - |
|
2430 |
partnerProblem.setFofoId(ls.getKey());
|
| - |
|
2431 |
if (mtdSale < lmtdTwentyPercentSale) {
|
| - |
|
2432 |
partnerProblem.setMtd(1);
|
| - |
|
2433 |
}
|
| - |
|
2434 |
if (Investmentvalue) {
|
| - |
|
2435 |
partnerProblem.setInvestment(1);
|
| - |
|
2436 |
}
|
| - |
|
2437 |
|
| - |
|
2438 |
if (stockInvestment < totalSixtyPercentInvestment) {
|
| - |
|
2439 |
partnerProblem.setInvestment(1);
|
| - |
|
2440 |
}
|
| - |
|
2441 |
|
| - |
|
2442 |
partnerProblemRepository.persist(partnerProblem);
|
| - |
|
2443 |
} else {
|
| - |
|
2444 |
if (mtdSale < lmtdTwentyPercentSale) {
|
| - |
|
2445 |
partnerProblem.setMtd(partnerProblem.getMtd() + 1);
|
| - |
|
2446 |
|
| - |
|
2447 |
} else {
|
| - |
|
2448 |
partnerProblem.setMtd(0);
|
| - |
|
2449 |
|
| - |
|
2450 |
}
|
| - |
|
2451 |
if (Investmentvalue) {
|
| - |
|
2452 |
partnerProblem.setInvestment(partnerProblem.getInvestment() + 1);
|
| - |
|
2453 |
} else {
|
| - |
|
2454 |
partnerProblem.setInvestment(0);
|
| - |
|
2455 |
|
| - |
|
2456 |
}
|
| - |
|
2457 |
if (stockInvestment < totalSixtyPercentInvestment) {
|
| - |
|
2458 |
partnerProblem.setStockInvestment(partnerProblem.getStockInvestment() + 1);
|
| - |
|
2459 |
} else {
|
| - |
|
2460 |
partnerProblem.setStockInvestment(0);
|
| 2383 |
|
2461 |
}
|
| - |
|
2462 |
|
| 2384 |
}
|
2463 |
}
|
| - |
|
2464 |
|
| - |
|
2465 |
}
|
| - |
|
2466 |
|
| - |
|
2467 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
|
| - |
|
2468 |
List<String> sendTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
| - |
|
2469 |
"hemant.kaura@smartdukaan.com", "niranjan.kala@smartdukaan.com", "sm@smartdukaan.com ");
|
| - |
|
2470 |
List<PartnerProblem> partnerProblems = partnerProblemRepository.selectAll().stream()
|
| - |
|
2471 |
.filter(x -> x.getMtd() + x.getInvestment() + x.getStockInvestment() > 0).collect(Collectors.toList());
|
| - |
|
2472 |
StringBuilder sb = new StringBuilder();
|
| - |
|
2473 |
sb.append("<html><body>");
|
| - |
|
2474 |
sb.append("<p>Partner Problem Alert!:</p><br/><table style='border:1px solid black';cellspacing=0>");
|
| - |
|
2475 |
sb.append("<tbody>\n" + " <tr>"
|
| - |
|
2476 |
+ " <th style='border:1px solid black;padding: 5px'>Partner Name</th>"
|
| - |
|
2477 |
+ " <th style='border:1px solid black;padding: 5px'>Assign TO</th>"
|
| - |
|
2478 |
+ " <th style='border:1px solid black;padding: 5px'>Mtd</th>"
|
| - |
|
2479 |
+ " <th style='border:1px solid black;padding: 5px'>Investment</th>"
|
| - |
|
2480 |
+ " <th style='border:1px solid black;padding: 5px'>Stock</th>"
|
| - |
|
2481 |
+ " <th style='border:1px solid black;padding: 5px'>Manager</th>"
|
| - |
|
2482 |
|
| - |
|
2483 |
+ " </tr>");
|
| - |
|
2484 |
|
| - |
|
2485 |
for (PartnerProblem pp : partnerProblems) {
|
| - |
|
2486 |
int value = pp.getFofoId() % 5;
|
| - |
|
2487 |
|
| - |
|
2488 |
Map<EscalationType, AuthUser> authUserMap = csService.getAuthUserAndEsclationByPartnerId(pp.getFofoId());
|
| - |
|
2489 |
sb.append("<tr>");
|
| - |
|
2490 |
sb.append("<td style='border:1px solid black;padding: 5px'>"
|
| - |
|
2491 |
+ customRetailers.get(pp.getFofoId()).getBusinessName() + "</td>");
|
| - |
|
2492 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + sendTo.get(value) + "</td>");
|
| - |
|
2493 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getMtd() + "</td>");
|
| - |
|
2494 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getInvestment() + "</td>");
|
| - |
|
2495 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + pp.getStockInvestment() + "</td>");
|
| - |
|
2496 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + authUserMap.get(EscalationType.L1)
|
| - |
|
2497 |
+ authUserMap.get(EscalationType.L2) + "</td>");
|
| - |
|
2498 |
|
| - |
|
2499 |
sb.append("</tr>");
|
| 2385 |
}
|
2500 |
}
|
| - |
|
2501 |
sb.append("</tbody></table><br><br>");
|
| - |
|
2502 |
String subject = "Partner Problem Alert!";
|
| 2386 |
|
2503 |
|
| - |
|
2504 |
MimeMessage message = mailSender.createMimeMessage();
|
| - |
|
2505 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| - |
|
2506 |
String[] email = sendTo.toArray(new String[sendTo.size()]);
|
| - |
|
2507 |
helper.setSubject(subject);
|
| - |
|
2508 |
helper.setText(sb.toString(), true);
|
| - |
|
2509 |
helper.setTo("tejbeer.kaur@shop2020.in");
|
| - |
|
2510 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smartdukaan Alerts");
|
| - |
|
2511 |
helper.setFrom(senderAddress);
|
| - |
|
2512 |
mailSender.send(message);
|
| - |
|
2513 |
|
| 2387 |
}
|
2514 |
}
|
| - |
|
2515 |
|
| 2388 |
}
|
2516 |
}
|
| 2389 |
//2284
|
2517 |
//2284
|
| 2390 |
|
2518 |
|