| Line 80... |
Line 80... |
| 80 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
80 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 81 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
81 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 82 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
82 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 83 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
83 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 84 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
84 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 85 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
- |
|
| 86 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
85 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 87 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
86 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 88 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
87 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 89 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
88 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| 90 |
import com.spice.profitmandi.dao.entity.transaction.PriceDropIMEI;
|
89 |
import com.spice.profitmandi.dao.entity.transaction.PriceDropIMEI;
|
| Line 105... |
Line 104... |
| 105 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
104 |
import com.spice.profitmandi.dao.repository.catalog.SchemeRepository;
|
| 106 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
105 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 107 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
106 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 108 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
107 |
import com.spice.profitmandi.dao.repository.dtr.DailyRechargeRepository;
|
| 109 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
108 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
109 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
| 110 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
110 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 111 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
111 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
| 112 |
import com.spice.profitmandi.dao.repository.dtr.PushNotificationRepository;
|
112 |
import com.spice.profitmandi.dao.repository.dtr.PushNotificationRepository;
|
| 113 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
|
113 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderCreditWalletHistoryRepository;
|
| 114 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
114 |
import com.spice.profitmandi.dao.repository.dtr.RechargeProviderRepository;
|
| Line 171... |
Line 171... |
| 171 |
@Autowired
|
171 |
@Autowired
|
| 172 |
private PriceDropService priceDropService;
|
172 |
private PriceDropService priceDropService;
|
| 173 |
|
173 |
|
| 174 |
@Autowired
|
174 |
@Autowired
|
| 175 |
private CsService csService;
|
175 |
private CsService csService;
|
| - |
|
176 |
|
| - |
|
177 |
@Autowired
|
| - |
|
178 |
private InsurancePolicyRepository insurancePolicyRepository;
|
| 176 |
|
179 |
|
| 177 |
@Autowired
|
180 |
@Autowired
|
| 178 |
private ToffeeService toffeeService;
|
181 |
private ToffeeService toffeeService;
|
| 179 |
|
182 |
|
| 180 |
@Value("${oxigen.recharge.auth.key}")
|
183 |
@Value("${oxigen.recharge.auth.key}")
|
| Line 509... |
Line 512... |
| 509 |
// Temporary Method
|
512 |
// Temporary Method
|
| 510 |
public void evaluateExcessSchemeOut() throws Exception {
|
513 |
public void evaluateExcessSchemeOut() throws Exception {
|
| 511 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
514 |
Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
|
| 512 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
515 |
Map<Integer, Float> userAmountMap = new HashMap<>();
|
| 513 |
|
516 |
|
| 514 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
517 |
List<List<?>> rows = new ArrayList<>();
|
| 515 |
List<String> headers = Arrays.asList("Scheme", "Item", "Partner", "Amount", "Credited On", "Invoice Number",
|
518 |
List<String> headers = Arrays.asList("Scheme", "Item", "Partner", "Amount", "Credited On", "Invoice Number",
|
| 516 |
"Sale On", "Scheme Start", "Scheme End", "Active On", "Expired On");
|
519 |
"Sale On", "Scheme Start", "Scheme End", "Active On", "Expired On");
|
| 517 |
schemeRepository.selectAll().stream().forEach(x -> {
|
520 |
schemeRepository.selectAll().stream().forEach(x -> {
|
| 518 |
if (x.getType().equals(SchemeType.OUT)) {
|
521 |
if (x.getType().equals(SchemeType.OUT)) {
|
| 519 |
List<SchemeInOut> sioList = schemeInOutRepository
|
522 |
List<SchemeInOut> sioList = schemeInOutRepository
|
| Line 653... |
Line 656... |
| 653 |
|
656 |
|
| 654 |
public List<String> getL1() {
|
657 |
public List<String> getL1() {
|
| 655 |
return l1;
|
658 |
return l1;
|
| 656 |
}
|
659 |
}
|
| 657 |
|
660 |
|
| 658 |
public void setL1(List<String> l1) {
|
- |
|
| 659 |
this.l1 = l1;
|
- |
|
| 660 |
}
|
- |
|
| 661 |
|
- |
|
| 662 |
public List<String> getL2() {
|
661 |
public List<String> getL2() {
|
| 663 |
return l2;
|
662 |
return l2;
|
| 664 |
}
|
663 |
}
|
| 665 |
|
664 |
|
| 666 |
public void setL2(List<String> l2) {
|
- |
|
| 667 |
this.l2 = l2;
|
- |
|
| 668 |
}
|
- |
|
| 669 |
|
- |
|
| 670 |
}
|
665 |
}
|
| 671 |
|
666 |
|
| 672 |
public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
|
667 |
public void sendPartnerInvestmentDetails(List<String> sendTo) throws Exception {
|
| 673 |
if (sendTo == null) {
|
668 |
if (sendTo == null) {
|
| 674 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
669 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| Line 680... |
Line 675... |
| 680 |
.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
675 |
.getFofoRetailers(fofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| 681 |
|
676 |
|
| 682 |
List<String> headers = Arrays.asList("Code", "Firm Name", "Store Name", "State Manager", "Teritory/Team Lead",
|
677 |
List<String> headers = Arrays.asList("Code", "Firm Name", "Store Name", "State Manager", "Teritory/Team Lead",
|
| 683 |
"Wallet Amount", "In Stock Amount", "Return In Transit Stock", "Unbilled Amount", "Grn Pending Amount",
|
678 |
"Wallet Amount", "In Stock Amount", "Return In Transit Stock", "Unbilled Amount", "Grn Pending Amount",
|
| 684 |
"Min Investment", "Investment Amount", "Investment Short", "Unbilled Qty");
|
679 |
"Min Investment", "Investment Amount", "Investment Short", "Unbilled Qty");
|
| 685 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
680 |
List<List<?>> rows = new ArrayList<>();
|
| 686 |
Map<String, List<? extends Serializable>> partnerRow = new HashMap<>();
|
681 |
Map<Integer, List<? extends Serializable>> partnerRowsMap = new HashMap<>();
|
| 687 |
|
682 |
|
| 688 |
Map<String, SaleRoles> partnerEmailSalesMap = this.getPartnerEmailSalesMap();
|
683 |
Map<Integer, List<Serializable>> partnerIdSalesHeaderMap = this.getPartnerIdSalesHeaders();
|
| 689 |
|
684 |
|
| 690 |
for (FofoStore fofoStore : fofoStores) {
|
685 |
for (FofoStore fofoStore : fofoStores) {
|
| 691 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoStore.getId(),
|
686 |
PartnerDailyInvestment partnerDailyInvestment = partnerInvestmentService.getInvestment(fofoStore.getId(),
|
| 692 |
1);
|
687 |
1);
|
| 693 |
partnerDailyInvestment.setDate(yesterDay);
|
688 |
partnerDailyInvestment.setDate(yesterDay);
|
| Line 696... |
Line 691... |
| 696 |
} catch (Exception e) {
|
691 |
} catch (Exception e) {
|
| 697 |
// ignore the exceptions during persist
|
692 |
// ignore the exceptions during persist
|
| 698 |
}
|
693 |
}
|
| 699 |
|
694 |
|
| 700 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
695 |
CustomRetailer retailer = customRetailerMap.get(fofoStore.getId());
|
| 701 |
if (retailer == null || partnerEmailSalesMap.get(retailer.getEmail()) == null) {
|
696 |
if (retailer == null || partnerIdSalesHeaderMap.get(fofoStore.getId()) == null) {
|
| 702 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
697 |
LOGGER.info("Could not find retailer with retailer Id {}", fofoStore.getId());
|
| 703 |
continue;
|
698 |
continue;
|
| 704 |
}
|
699 |
}
|
| 705 |
|
- |
|
| 706 |
List<? extends Serializable> row = Arrays.asList(fofoStore.getCode(), retailer.getBusinessName(),
|
700 |
List<Serializable> row = partnerIdSalesHeaderMap.get(fofoStore.getId());
|
| 707 |
"SmartDukaan-" + fofoStore.getCode().replaceAll("[a-zA-Z]+", ""),
|
- |
|
| 708 |
StringUtils.join(partnerEmailSalesMap.get(retailer.getEmail()).getL2(), ", "),
|
- |
|
| 709 |
StringUtils.join(partnerEmailSalesMap.get(retailer.getEmail()).getL1(), ", "),
|
- |
|
| 710 |
partnerDailyInvestment.getWalletAmount(), partnerDailyInvestment.getInStockAmount(), 0,
|
- |
|
| 711 |
partnerDailyInvestment.getUnbilledAmount(), partnerDailyInvestment.getGrnPendingAmount(),
|
- |
|
| 712 |
partnerDailyInvestment.getMinInvestment(), partnerDailyInvestment.getTotalInvestment(),
|
- |
|
| 713 |
partnerDailyInvestment.getShortInvestment(), partnerDailyInvestment.getUnbilledQty());
|
- |
|
| 714 |
partnerRow.put(retailer.getEmail(), row);
|
701 |
partnerRowsMap.put(fofoStore.getId(), row);
|
| 715 |
rows.add(row);
|
702 |
rows.add(row);
|
| 716 |
|
703 |
|
| 717 |
}
|
704 |
}
|
| 718 |
|
705 |
|
| 719 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
706 |
String fileName = "InvestmentSummary-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 720 |
|
707 |
|
| 721 |
for (Map.Entry<String, Set<String>> storeGuyEntry : csService.getAuthUserPartnerEmailMapping().entrySet()) {
|
708 |
for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMapping().entrySet()) {
|
| 722 |
List<List<? extends Serializable>> filteredRows = storeGuyEntry.getValue().stream()
|
709 |
List<List<?>> filteredRows = storeGuyEntry.getValue().stream().map(x -> partnerRowsMap.get(x))
|
| 723 |
.map(x -> partnerRow.get(x)).filter(x -> x != null).collect(Collectors.toList());
|
710 |
.filter(x -> x != null).collect(Collectors.toList());
|
| 724 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
711 |
ByteArrayOutputStream baos = FileUtil.getCSVByteStream(headers, filteredRows);
|
| 725 |
String[] sendToArray = new String[] { storeGuyEntry.getKey() };
|
712 |
String[] sendToArray = new String[] { storeGuyEntry.getKey() };
|
| 726 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
713 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
| 727 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
714 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
| 728 |
}
|
715 |
}
|
| Line 732... |
Line 719... |
| 732 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
719 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Franchise Investment Summary", "PFA",
|
| 733 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
720 |
fileName, new ByteArrayResource(baos.toByteArray()));
|
| 734 |
|
721 |
|
| 735 |
}
|
722 |
}
|
| 736 |
|
723 |
|
| 737 |
private Map<String, SaleRoles> getPartnerEmailSalesMap() {
|
724 |
private Map<Integer, List<Serializable>> getPartnerIdSalesHeaders() {
|
| 738 |
Map<String, SaleRoles> partnerEmailSalesMap = new HashMap<>();
|
725 |
Map<String, SaleRoles> partnerEmailSalesMap = new HashMap<>();
|
| 739 |
|
726 |
|
| 740 |
List<Position> positions = positionRepository
|
727 |
List<Position> positions = positionRepository
|
| 741 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
728 |
.selectPositionByCategoryId(ProfitMandiConstants.TICKET_CATEGORY_SALES);
|
| 742 |
Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream()
|
729 |
Map<Integer, AuthUser> authUsersMap = authRepository.selectAllActiveUser().stream()
|
| Line 758... |
Line 745... |
| 758 |
} else if (position.getEscalationType().equals(EscalationType.L2)) {
|
745 |
} else if (position.getEscalationType().equals(EscalationType.L2)) {
|
| 759 |
saleRoles.getL2().add(name);
|
746 |
saleRoles.getL2().add(name);
|
| 760 |
}
|
747 |
}
|
| 761 |
}
|
748 |
}
|
| 762 |
}
|
749 |
}
|
| - |
|
750 |
|
| - |
|
751 |
Set<CustomRetailer> allCrList = new HashSet<>();
|
| - |
|
752 |
for (List<CustomRetailer> cr : positionIdRetailerMap.values()) {
|
| - |
|
753 |
allCrList.addAll(cr);
|
| - |
|
754 |
}
|
| - |
|
755 |
|
| - |
|
756 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream()
|
| - |
|
757 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
758 |
|
| - |
|
759 |
Map<Integer, List<Serializable>> partnerIdSalesHeadersMap = new HashMap<>();
|
| - |
|
760 |
|
| - |
|
761 |
for (CustomRetailer cr : allCrList) {
|
| - |
|
762 |
FofoStore fofoStore = fofoStoresMap.get(cr.getPartnerId());
|
| - |
|
763 |
String code = fofoStore.getCode();
|
| - |
|
764 |
String storeName = "SmartDukaan-" + fofoStore.getCode().replaceAll("[a-zA-Z]", "");
|
| - |
|
765 |
String businessName = cr.getBusinessName();
|
| - |
|
766 |
try {
|
| - |
|
767 |
String stateManager = StringUtils.join(partnerEmailSalesMap.get(cr.getEmail()).getL2(), ", ");
|
| - |
|
768 |
String territoryManager = StringUtils.join(partnerEmailSalesMap.get(cr.getEmail()).getL1(), ", ");
|
| - |
|
769 |
List<Serializable> row = new ArrayList<>(
|
| - |
|
770 |
Arrays.asList(code, businessName, storeName, stateManager, territoryManager));
|
| - |
|
771 |
partnerIdSalesHeadersMap.put(cr.getPartnerId(), row);
|
| - |
|
772 |
|
| - |
|
773 |
} catch (Exception e) {
|
| - |
|
774 |
LOGGER.warn("Could not find partner with email - {}", cr.getEmail());
|
| - |
|
775 |
}
|
| - |
|
776 |
}
|
| 763 |
return partnerEmailSalesMap;
|
777 |
return partnerIdSalesHeadersMap;
|
| - |
|
778 |
|
| 764 |
}
|
779 |
}
|
| 765 |
|
780 |
|
| 766 |
public void sendPartnerInvestmentDetails() throws Exception {
|
781 |
public void sendPartnerInvestmentDetails() throws Exception {
|
| 767 |
this.sendPartnerInvestmentDetails(null);
|
782 |
this.sendPartnerInvestmentDetails(null);
|
| 768 |
|
- |
|
| 769 |
}
|
783 |
}
|
| 770 |
|
784 |
|
| 771 |
public void sendTargetVsSalesReport(List<String> sendTo) throws Exception {
|
785 |
public void sendTargetVsSalesReport(List<String> sendTo) throws Exception {
|
| 772 |
|
786 |
|
| 773 |
if (sendTo == null) {
|
787 |
if (sendTo == null) {
|
| 774 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
788 |
sendTo = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
| 775 |
"amit.gupta@shop2020.in", "amod.sen@smartdukaan.com", "prakash.rai@smartdukaan.com");
|
789 |
"amit.gupta@shop2020.in", "amod.sen@smartdukaan.com", "prakash.rai@smartdukaan.com");
|
| 776 |
}
|
790 |
}
|
| 777 |
Map<String, List<? extends Serializable>> partnerSalesTargetRowsMap = targetService.getDailySaleReportVsTarget();
|
791 |
Map<Integer, List<Serializable>> partnerSalesTargetRowsMap = targetService.getDailySaleReportVsTarget();
|
| 778 |
Map<Integer, FofoStore> fofoStoresMap = fofoStoreRepository.selectActiveStores().stream()
|
- |
|
| 779 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
- |
|
| 780 |
|
- |
|
| 781 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService
|
- |
|
| 782 |
.getFofoRetailers(new ArrayList<>(fofoStoresMap.keySet()));
|
- |
|
| 783 |
|
- |
|
| 784 |
Map<String, CustomRetailer> customRetailerEmailMap = customRetailerMap.values().stream()
|
- |
|
| 785 |
.collect(Collectors.toMap(x -> x.getEmail(), x -> x));
|
- |
|
| 786 |
|
792 |
|
| 787 |
Map<String, SaleRoles> partnerEmailSalesMap = this.getPartnerEmailSalesMap();
|
793 |
Map<Integer, List<Serializable>> partnerIdSalesHeadersMap = this.getPartnerIdSalesHeaders();
|
| 788 |
|
794 |
|
| 789 |
List<String> headers = Arrays.asList("Code", "Firm Name", "Store Name","State Manager",
|
795 |
List<String> headers = Arrays.asList("Code", "Firm Name", "Store Name", "State Manager", "Teritory Manager",
|
| 790 |
"Teritory Manager", "Current Category", "Target Value", "Target Achieved",
|
796 |
"Current Category", "Target Value", "Target Achieved", "Achived Percentage", "Remaining Target",
|
| 791 |
"Achived Percentage", "Remaining Target", "Today's Target", "Today's achievement");
|
797 |
"Today's Target", "Today's achievement");
|
| 792 |
|
798 |
|
| 793 |
List<List<? extends Serializable>> rows = new ArrayList<>();
|
799 |
List<List<?>> rows = new ArrayList<>();
|
| 794 |
Map<String, List<? extends Serializable>> partnerRowMap = new HashMap<>();
|
800 |
Map<Integer, List<? extends Serializable>> partnerRowMap = new HashMap<>();
|
| 795 |
for (Map.Entry<String, List<? extends Serializable>> partnerSalesTargetRowEntry : partnerSalesTargetRowsMap
|
801 |
for (Map.Entry<Integer, List<Serializable>> partnerSalesTargetRowEntry : partnerSalesTargetRowsMap.entrySet()) {
|
| 796 |
.entrySet()) {
|
- |
|
| 797 |
CustomRetailer retailer = customRetailerEmailMap.get(partnerSalesTargetRowEntry.getKey());
|
802 |
List<Serializable> row = partnerIdSalesHeadersMap.get(partnerSalesTargetRowEntry.getKey());
|
| 798 |
FofoStore fofoStore = fofoStoresMap.get(retailer.getPartnerId());
|
- |
|
| 799 |
Serializable code = fofoStore.getCode();
|
- |
|
| 800 |
Serializable storeName = "SmartDukaan-" + fofoStore.getCode().replaceAll("[a-zA-Z]", "");
|
- |
|
| 801 |
Serializable businessName = retailer.getBusinessName();
|
- |
|
| 802 |
try {
|
- |
|
| 803 |
Serializable stateManager = StringUtils.join(partnerEmailSalesMap.get(retailer.getEmail()).getL2(),
|
- |
|
| 804 |
", ");
|
- |
|
| 805 |
Serializable territoryManager = StringUtils.join(partnerEmailSalesMap.get(retailer.getEmail()).getL1(),
|
- |
|
| 806 |
", ");
|
- |
|
| 807 |
List<Serializable> row = new ArrayList<>(
|
- |
|
| 808 |
Arrays.asList(code, businessName, storeName, stateManager, territoryManager));
|
- |
|
| 809 |
if (partnerSalesTargetRowsMap.get(retailer.getEmail()) != null) {
|
- |
|
| 810 |
row.addAll(partnerSalesTargetRowsMap.get(retailer.getEmail()));
|
- |
|
| 811 |
partnerRowMap.put(retailer.getEmail(), row);
|
- |
|
| 812 |
rows.add(row);
|
803 |
if (row == null) {
|
| 813 |
}
|
- |
|
| 814 |
} catch (Exception e) {
|
- |
|
| 815 |
LOGGER.warn("Could not find partner with email - {}", retailer.getEmail());
|
804 |
LOGGER.warn("Could not find headers for partner ID - {}", partnerSalesTargetRowEntry.getKey());
|
| 816 |
}
|
805 |
}
|
| 817 |
|
- |
|
| - |
|
806 |
row.addAll(partnerSalesTargetRowEntry.getValue());
|
| - |
|
807 |
partnerRowMap.put(partnerSalesTargetRowEntry.getKey(), row);
|
| - |
|
808 |
rows.add(row);
|
| 818 |
}
|
809 |
}
|
| 819 |
|
810 |
|
| 820 |
String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
811 |
String fileName = "TargetVsSales-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 821 |
Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
|
812 |
Map<String, Set<String>> storeGuysMap = csService.getAuthUserPartnerEmailMapping();
|
| 822 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
|
813 |
for (Map.Entry<String, Set<String>> storeGuyEntry : storeGuysMap.entrySet()) {
|
| 823 |
if (storeGuyEntry.getValue().size() == 0)
|
814 |
if (storeGuyEntry.getValue().size() == 0)
|
| 824 |
continue;
|
815 |
continue;
|
| 825 |
List<List<? extends Serializable>> storeGuyRows = storeGuyEntry.getValue().stream()
|
816 |
List<List<?>> storeGuyRows = storeGuyEntry.getValue().stream().map(x -> partnerRowMap.get(x))
|
| 826 |
.map(x -> partnerRowMap.get(x)).collect(Collectors.toList());
|
817 |
.collect(Collectors.toList());
|
| 827 |
ByteArrayOutputStream authUserStream = FileUtil.getCSVByteStream(headers, storeGuyRows);
|
818 |
ByteArrayOutputStream authUserStream = FileUtil.getCSVByteStream(headers, storeGuyRows);
|
| 828 |
Attachment attache = new Attachment(fileName, new ByteArrayResource(authUserStream.toByteArray()));
|
819 |
Attachment attache = new Attachment(fileName, new ByteArrayResource(authUserStream.toByteArray()));
|
| 829 |
System.out.println(storeGuyEntry.getValue());
|
820 |
System.out.println(storeGuyEntry.getValue());
|
| 830 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { storeGuyEntry.getKey() }, null,
|
821 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { storeGuyEntry.getKey() }, null,
|
| 831 |
"Franchise Stock Report", "PFA", attache);
|
822 |
"Franchise Stock Report", "PFA", attache);
|
| Line 1302... |
Line 1293... |
| 1302 |
|
1293 |
|
| 1303 |
throw new Exception();
|
1294 |
throw new Exception();
|
| 1304 |
|
1295 |
|
| 1305 |
}
|
1296 |
}
|
| 1306 |
|
1297 |
|
| 1307 |
public void sendDailySalesReportNotificationToPartner(Integer fofoIdInt)
|
1298 |
public void sendDailySalesNotificationToPartner(Integer fofoIdInt)
|
| 1308 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
1299 |
throws ProfitMandiBusinessException, MessagingException, IOException {
|
| 1309 |
LocalDateTime now = LocalDateTime.now();
|
1300 |
LocalDateTime now = LocalDateTime.now();
|
| 1310 |
LocalDateTime from = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 00, 00);
|
1301 |
LocalDateTime from = now.with(LocalTime.MIN);
|
| 1311 |
Map<Integer, Double> salesByFofoIdMap = new HashMap<>();
|
1302 |
Map<Integer, Double> salesByFofoIdMap = new HashMap<>();
|
| 1312 |
List<Integer> fofoIds = null;
|
1303 |
List<Integer> fofoIds = null;
|
| 1313 |
if (fofoIdInt == null) {
|
1304 |
if (fofoIdInt == null) {
|
| 1314 |
fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
|
1305 |
fofoIds = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive()).map(x -> x.getId())
|
| 1315 |
.collect(Collectors.toList());
|
1306 |
.collect(Collectors.toList());
|
| 1316 |
} else {
|
1307 |
} else {
|
| 1317 |
fofoIds = Arrays.asList(fofoIdInt);
|
1308 |
fofoIds = Arrays.asList(fofoIdInt);
|
| 1318 |
}
|
1309 |
}
|
| 1319 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
- |
|
| 1320 |
.selectAllGeEqAndLeEqStartDateAndEndDate(now);
|
- |
|
| 1321 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h a");
|
1310 |
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("h a");
|
| 1322 |
|
1311 |
|
| 1323 |
Map<Integer, Float> dailyTarget = new HashMap<>();
|
1312 |
Map<Integer, Float> dailyTarget = new HashMap<>();
|
| 1324 |
for (Integer fofoId : fofoIds) {
|
1313 |
for (Integer fofoId : fofoIds) {
|
| 1325 |
Map<Integer, Float> dailyAverageSale = null;
|
- |
|
| 1326 |
double sale = fofoOrderRepository.selectTotalSaleSumByFofoIdBrtweenDate(fofoId, from, now);
|
1314 |
double sale = fofoOrderRepository.selectTotalSaleSumByFofoIdBetweenDate(fofoId, from, now);
|
| 1327 |
for (PartnerTargetDetails partnerTargetDetail : partnerTargetDetails) {
|
- |
|
| 1328 |
Map<Integer, Float> targetValues = targetService.getTargetValueByFofoIdAndTargetId(fofoId,
|
- |
|
| 1329 |
partnerTargetDetail.getId());
|
- |
|
| 1330 |
if (targetValues.size() == 0) {
|
- |
|
| 1331 |
continue;
|
- |
|
| 1332 |
} else {
|
- |
|
| 1333 |
List<Integer> partnerIds = new ArrayList<>();
|
- |
|
| 1334 |
partnerIds.add(fofoId);
|
- |
|
| 1335 |
dailyAverageSale = targetService.getDailyAverageSaleForCurrentForSingleFofoIdAndBrand(partnerIds,
|
- |
|
| 1336 |
targetValues, partnerTargetDetail.getStartDate(), partnerTargetDetail.getEndDate(),
|
- |
|
| 1337 |
partnerTargetDetail.getBrandName());
|
- |
|
| 1338 |
dailyTarget.put(fofoId, dailyAverageSale.get(fofoId));
|
- |
|
| 1339 |
break;
|
- |
|
| 1340 |
}
|
- |
|
| 1341 |
}
|
1315 |
|
| 1342 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
1316 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 1343 |
sendNotificationModel.setCampaignName("Sales update alert");
|
1317 |
sendNotificationModel.setCampaignName("Sales update alert");
|
| 1344 |
if (dailyAverageSale != null && dailyAverageSale.get(fofoId) != null) {
|
- |
|
| 1345 |
sendNotificationModel.setMessage(String.format("Rs.%.0f till %s. Today's Target is Rs.%.0f", sale,
|
1318 |
sendNotificationModel.setMessage(String.format(
|
| 1346 |
now.format(timeFormatter), dailyAverageSale.get(fofoId)));
|
- |
|
| 1347 |
} else {
|
- |
|
| 1348 |
sendNotificationModel.setMessage(String.format("Rs.%.0f till %s", sale, now.format(timeFormatter)));
|
1319 |
"Smartphones Rs.%.0f, Insurance Rs.%.0f, Total Rs.%.0f till %s.", sale, now.format(timeFormatter)));
|
| 1349 |
}
|
- |
|
| 1350 |
sendNotificationModel.setType("url");
|
1320 |
sendNotificationModel.setType("url");
|
| 1351 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
1321 |
sendNotificationModel.setUrl("http://app.profitmandi.com/pages/home/notifications");
|
| 1352 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
1322 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 1353 |
sendNotificationModel.setMessageType(MessageType.notification);
|
1323 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 1354 |
salesByFofoIdMap.put(fofoId, sale);
|
1324 |
salesByFofoIdMap.put(fofoId, sale);
|
| 1355 |
LOGGER.info(sale);
|
1325 |
LOGGER.info(sale);
|
| 1356 |
}
|
1326 |
}
|
| - |
|
1327 |
Map<Integer, Float> parternPolicyAmountMap = insurancePolicyRepository.selectAmountSumGroupByRetailerId(now, null);
|
| - |
|
1328 |
Map<Integer, Float> parternPolicyQtyMap = insurancePolicyRepository.selectAmountSumGroupByRetailerId(now, null);
|
| 1357 |
String saleReport = this.getDailySalesReportByPartnerId(salesByFofoIdMap, dailyTarget);
|
1329 |
String saleReport = this.getDailySalesReportByPartnerId(salesByFofoIdMap, dailyTarget);
|
| 1358 |
LOGGER.info(saleReport);
|
1330 |
LOGGER.info(saleReport);
|
| 1359 |
String cc[] =
|
- |
|
| 1360 |
{ "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com",
|
1331 |
String cc[] = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
| 1361 |
"prakash.rai@smartdukaan.com", "chaitnaya.vats@smartdukaan.com",
|
1332 |
"chaitnaya.vats@smartdukaan.com"};
|
| 1362 |
"adeel.yazdani@smartdukaan.com", "mohinder.mutreja@smartdukaan.com" };
|
- |
|
| 1363 |
|
1333 |
|
| 1364 |
String subject = String.format("Sale till %s", now.format(timeFormatter));
|
1334 |
String subject = String.format("Sale till %s", now.format(timeFormatter));
|
| 1365 |
this.sendMailOfHtmlFomat("amit.gupta@shop2020.in", saleReport, cc, subject);
|
1335 |
this.sendMailOfHtmlFomat("amit.gupta@shop2020.in", saleReport, cc, subject);
|
| 1366 |
// this.sendMailOfHtmlFomat("amod.sen@smartdukaan.com", saleReport, cc,
|
- |
|
| 1367 |
// subject);
|
- |
|
| 1368 |
}
|
1336 |
}
|
| 1369 |
|
1337 |
|
| 1370 |
public String getDailySalesReportByPartnerId(Map<Integer, Double> salesByFofoIdMap, Map<Integer, Float> dailyTarget)
|
1338 |
private String getDailySalesReportByPartnerId(Map<Integer, Double> salesByFofoIdMap,
|
| 1371 |
throws ProfitMandiBusinessException {
|
1339 |
Map<Integer, Float> dailyTarget) throws ProfitMandiBusinessException {
|
| 1372 |
StringBuilder sb = new StringBuilder();
|
1340 |
StringBuilder sb = new StringBuilder();
|
| 1373 |
sb.append("<html><body><p>Sale Report:</p><br/><table style='border:1px solid black';cellspacing=0>");
|
1341 |
sb.append("<html><body><p>Sale Report:</p><br/><table style='border:1px solid black';cellspacing=0>");
|
| 1374 |
sb.append("<tbody>\n" + " <tr>\n"
|
1342 |
sb.append("<tbody>\n" + " <tr>\n"
|
| 1375 |
+ " <th style='border:1px solid black;padding: 5px'>Partner</th>\n"
|
1343 |
+ " <th style='border:1px solid black;padding: 5px'>Partner</th>\n"
|
| 1376 |
+ " <th style='border:1px solid black;padding: 5px'>Daily Target</th>\n"
|
1344 |
+ " <th style='border:1px solid black;padding: 5px'>Daily Target</th>\n"
|
| Line 1507... |
Line 1475... |
| 1507 |
inventoryItem.getUpdateTimestamp().format(dtf), priceDrop.getPartnerPayout() + "",
|
1475 |
inventoryItem.getUpdateTimestamp().format(dtf), priceDrop.getPartnerPayout() + "",
|
| 1508 |
inventoryItem.getLastScanType().equals(ScanType.DOA_OUT) + "")));
|
1476 |
inventoryItem.getLastScanType().equals(ScanType.DOA_OUT) + "")));
|
| 1509 |
}
|
1477 |
}
|
| 1510 |
}
|
1478 |
}
|
| 1511 |
}
|
1479 |
}
|
| 1512 |
/*
|
- |
|
| 1513 |
* for (FofoStore fofoStore : fofoStoreRepository.selectAll()) {
|
- |
|
| 1514 |
* LOGGER.info("{}, {}", fofoStore.getId(),
|
- |
|
| 1515 |
* partnerTypeChangeService.getTypeOnDate(fofoStore.getId(),
|
- |
|
| 1516 |
* LocalDate.now().plusDays(1))); UserWallet userWallet =
|
- |
|
| 1517 |
* userWalletRepository.selectByRetailerId(fofoStore.getId());
|
- |
|
| 1518 |
* if(userWallet==null) continue;
|
- |
|
| 1519 |
* System.out.printf("Store Code %s, Wallet amount %d, Sum amount %f%n",
|
- |
|
| 1520 |
* fofoStore.getCode(), userWallet.getAmount(),
|
- |
|
| 1521 |
* walletService.getWalletAmount(fofoStore.getId())); }
|
- |
|
| 1522 |
*/
|
- |
|
| 1523 |
|
- |
|
| 1524 |
/*
|
- |
|
| 1525 |
* for (Map.Entry<String, Set<String>> storeGuyEntry :
|
- |
|
| 1526 |
* csService.getAuthUserPartnerEmailMapping().entrySet()) {
|
- |
|
| 1527 |
* System.out.println(storeGuyEntry.getKey() + " = " +
|
- |
|
| 1528 |
* storeGuyEntry.getValue()); }
|
- |
|
| 1529 |
*/
|
- |
|
| 1530 |
}
|
1480 |
}
|
| 1531 |
|
1481 |
|
| 1532 |
public void testToffee() throws Exception {
|
1482 |
public void testToffee() throws Exception {
|
| 1533 |
// LOGGER.info("{}", toffeeService.getAuthToken());
|
1483 |
// LOGGER.info("{}", toffeeService.getAuthToken());
|
| 1534 |
LOGGER.info("{}", toffeeService.getProducts());
|
1484 |
LOGGER.info("{}", toffeeService.getProducts());
|
| Line 1733... |
Line 1683... |
| 1733 |
if (!focusedModelShortageReportMap.isEmpty())
|
1683 |
if (!focusedModelShortageReportMap.isEmpty())
|
| 1734 |
|
1684 |
|
| 1735 |
{
|
1685 |
{
|
| 1736 |
String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
1686 |
String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
|
| 1737 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
1687 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 1738 |
Map<String, List<List<? extends Serializable>>> emailRowsMap = new HashMap<>();
|
1688 |
Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
|
| 1739 |
|
1689 |
|
| 1740 |
focusedModelShortageReportMap.entrySet().forEach(x -> {
|
1690 |
focusedModelShortageReportMap.entrySet().forEach(x -> {
|
| 1741 |
storeGuyMap.entrySet().forEach(y -> {
|
1691 |
storeGuyMap.entrySet().forEach(y -> {
|
| 1742 |
|
1692 |
|
| 1743 |
if (y.getValue().contains(x.getKey())) {
|
1693 |
if (y.getValue().contains(x.getKey())) {
|
| Line 1754... |
Line 1704... |
| 1754 |
});
|
1704 |
});
|
| 1755 |
|
1705 |
|
| 1756 |
});
|
1706 |
});
|
| 1757 |
|
1707 |
|
| 1758 |
List<String> headers = Arrays.asList("Partner Id", "Partner Name", "Model Name", "Shortage Qty");
|
1708 |
List<String> headers = Arrays.asList("Partner Id", "Partner Name", "Model Name", "Shortage Qty");
|
| 1759 |
emailRowsMap.entrySet().forEach(e -> {
|
1709 |
emailRowsMap.entrySet().forEach(entry -> {
|
| 1760 |
|
1710 |
|
| 1761 |
ByteArrayOutputStream baos = null;
|
1711 |
ByteArrayOutputStream baos = null;
|
| 1762 |
try {
|
1712 |
try {
|
| 1763 |
baos = FileUtil.getCSVByteStream(headers, e.getValue());
|
1713 |
baos = FileUtil.getCSVByteStream(headers, entry.getValue());
|
| 1764 |
} catch (Exception e2) {
|
1714 |
} catch (Exception e2) {
|
| 1765 |
e2.printStackTrace();
|
1715 |
e2.printStackTrace();
|
| 1766 |
}
|
1716 |
}
|
| 1767 |
String[] sendToArray = new String[] { e.getKey() };
|
1717 |
String[] sendToArray = new String[] { entry.getKey() };
|
| 1768 |
try {
|
1718 |
try {
|
| 1769 |
|
- |
|
| 1770 |
LOGGER.info("email" + e.getKey());
|
- |
|
| 1771 |
LOGGER.info("list" + e.getValue());
|
- |
|
| 1772 |
|
- |
|
| 1773 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Stock Alert", "PFA", fileName,
|
1719 |
Utils.sendMailWithAttachment(googleMailSender, sendToArray, null, "Stock Alert", "PFA", fileName,
|
| 1774 |
new ByteArrayResource(baos.toByteArray()));
|
1720 |
new ByteArrayResource(baos.toByteArray()));
|
| 1775 |
} catch (Exception e1) { // TODO Auto-generated catch block
|
1721 |
} catch (Exception e1) { // TODO Auto-generated catch block
|
| 1776 |
e1.printStackTrace();
|
1722 |
e1.printStackTrace();
|
| 1777 |
}
|
1723 |
}
|