Subversion Repositories SmartDukaan

Rev

Rev 32339 | Rev 32404 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 32339 Rev 32402
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
-
 
3
import java.io.ByteArrayInputStream;
-
 
4
import java.io.ByteArrayOutputStream;
-
 
5
import java.io.IOException;
-
 
6
import java.io.InputStream;
-
 
7
import java.io.InputStreamReader;
-
 
8
import java.net.URISyntaxException;
-
 
9
import java.nio.charset.StandardCharsets;
-
 
10
import java.security.Key;
-
 
11
import java.time.LocalDate;
-
 
12
import java.time.LocalDateTime;
-
 
13
import java.time.YearMonth;
-
 
14
import java.time.ZoneId;
-
 
15
import java.time.format.DateTimeFormatter;
-
 
16
import java.time.temporal.ChronoUnit;
-
 
17
import java.util.ArrayList;
-
 
18
import java.util.Arrays;
-
 
19
import java.util.Base64;
-
 
20
import java.util.Collection;
-
 
21
import java.util.Comparator;
-
 
22
import java.util.HashMap;
-
 
23
import java.util.HashSet;
-
 
24
import java.util.Iterator;
-
 
25
import java.util.List;
-
 
26
import java.util.Map;
-
 
27
import java.util.Optional;
-
 
28
import java.util.Set;
-
 
29
import java.util.stream.Collectors;
-
 
30
import java.util.stream.Stream;
-
 
31
 
-
 
32
import javax.servlet.http.HttpServletRequest;
-
 
33
import javax.servlet.http.HttpServletResponse;
-
 
34
 
-
 
35
import org.apache.commons.csv.CSVFormat;
-
 
36
import org.apache.commons.csv.CSVParser;
-
 
37
import org.apache.commons.csv.CSVRecord;
-
 
38
import org.apache.commons.io.FileUtils;
-
 
39
import org.apache.commons.lang3.StringUtils;
-
 
40
import org.apache.logging.log4j.LogManager;
-
 
41
import org.apache.logging.log4j.Logger;
-
 
42
import org.apache.thrift.TException;
-
 
43
import org.json.JSONObject;
-
 
44
import org.springframework.beans.factory.annotation.Autowired;
-
 
45
import org.springframework.beans.factory.annotation.Qualifier;
-
 
46
import org.springframework.beans.factory.annotation.Value;
-
 
47
import org.springframework.core.io.ByteArrayResource;
-
 
48
import org.springframework.core.io.ClassPathResource;
-
 
49
import org.springframework.core.io.InputStreamResource;
-
 
50
import org.springframework.http.HttpHeaders;
-
 
51
import org.springframework.http.HttpStatus;
-
 
52
import org.springframework.http.MediaType;
-
 
53
import org.springframework.http.ResponseEntity;
-
 
54
import org.springframework.mail.javamail.JavaMailSender;
-
 
55
import org.springframework.stereotype.Controller;
-
 
56
import org.springframework.transaction.annotation.Transactional;
-
 
57
import org.springframework.ui.Model;
-
 
58
import org.springframework.web.bind.annotation.GetMapping;
-
 
59
import org.springframework.web.bind.annotation.PostMapping;
-
 
60
import org.springframework.web.bind.annotation.RequestBody;
-
 
61
import org.springframework.web.bind.annotation.RequestMapping;
-
 
62
import org.springframework.web.bind.annotation.RequestMethod;
-
 
63
import org.springframework.web.bind.annotation.RequestParam;
-
 
64
import org.springframework.web.bind.annotation.RequestPart;
-
 
65
import org.springframework.web.multipart.MultipartFile;
-
 
66
 
3
import com.fasterxml.jackson.databind.ObjectMapper;
67
import com.fasterxml.jackson.databind.ObjectMapper;
4
import com.google.gson.Gson;
68
import com.google.gson.Gson;
-
 
69
import com.google.gson.JsonObject;
5
import com.spice.profitmandi.common.enumuration.MessageType;
70
import com.spice.profitmandi.common.enumuration.MessageType;
6
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
71
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
-
 
72
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
7
import com.spice.profitmandi.common.model.*;
73
import com.spice.profitmandi.common.model.CustomRetailer;
-
 
74
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
-
 
75
import com.spice.profitmandi.common.model.InvoicePdfModel;
-
 
76
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
-
 
77
import com.spice.profitmandi.common.model.NotifyItemIdModel;
-
 
78
import com.spice.profitmandi.common.model.NotifyOrderIdModel;
-
 
79
import com.spice.profitmandi.common.model.NotifyOrderModel;
-
 
80
import com.spice.profitmandi.common.model.OrderCancellationModel;
-
 
81
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
82
import com.spice.profitmandi.common.model.SendNotificationModel;
8
import com.spice.profitmandi.common.util.ExcelUtils;
83
import com.spice.profitmandi.common.util.ExcelUtils;
9
import com.spice.profitmandi.common.util.PdfUtils;
84
import com.spice.profitmandi.common.util.PdfUtils;
10
import com.spice.profitmandi.common.util.Utils;
85
import com.spice.profitmandi.common.util.Utils;
11
import com.spice.profitmandi.common.util.Utils.Attachment;
86
import com.spice.profitmandi.common.util.Utils.Attachment;
-
 
87
import com.spice.profitmandi.common.web.client.RestClient;
12
import com.spice.profitmandi.dao.entity.auth.AuthUser;
88
import com.spice.profitmandi.dao.entity.auth.AuthUser;
-
 
89
import com.spice.profitmandi.dao.entity.catalog.ComboMappedModel;
-
 
90
import com.spice.profitmandi.dao.entity.catalog.ComboModel;
-
 
91
import com.spice.profitmandi.dao.entity.catalog.ComboOption;
-
 
92
import com.spice.profitmandi.dao.entity.catalog.FocusedModelByPassRequest;
-
 
93
import com.spice.profitmandi.dao.entity.catalog.HighDemandItem;
13
import com.spice.profitmandi.dao.entity.catalog.*;
94
import com.spice.profitmandi.dao.entity.catalog.Item;
-
 
95
import com.spice.profitmandi.dao.entity.catalog.TagListing;
-
 
96
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
14
import com.spice.profitmandi.dao.entity.cs.Position;
97
import com.spice.profitmandi.dao.entity.cs.Position;
15
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
98
import com.spice.profitmandi.dao.entity.dtr.WebOffer;
-
 
99
import com.spice.profitmandi.dao.entity.fofo.Customer;
16
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
100
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
17
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
101
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
18
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
102
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
19
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
103
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
-
 
104
import com.spice.profitmandi.dao.entity.transaction.NotifyCancel;
-
 
105
import com.spice.profitmandi.dao.entity.transaction.NotifyColorChange;
-
 
106
import com.spice.profitmandi.dao.entity.transaction.NotifyMessage;
-
 
107
import com.spice.profitmandi.dao.entity.transaction.NotifyOrder;
20
import com.spice.profitmandi.dao.entity.transaction.*;
108
import com.spice.profitmandi.dao.entity.transaction.Order;
21
import com.spice.profitmandi.dao.entity.user.Address;
109
import com.spice.profitmandi.dao.entity.user.Address;
22
import com.spice.profitmandi.dao.enumuration.catalog.ByPassRequestStatus;
110
import com.spice.profitmandi.dao.enumuration.catalog.ByPassRequestStatus;
23
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
111
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
-
 
112
import com.spice.profitmandi.dao.model.BrandItemWiseTertiaryModel;
-
 
113
import com.spice.profitmandi.dao.model.BrandRegionModel;
-
 
114
import com.spice.profitmandi.dao.model.BrandWiseTertiaryModel;
24
import com.spice.profitmandi.dao.model.*;
115
import com.spice.profitmandi.dao.model.ContentPojo;
-
 
116
import com.spice.profitmandi.dao.model.ImeiActivationTimestampModel;
-
 
117
import com.spice.profitmandi.dao.model.OpenPoItemModel;
-
 
118
import com.spice.profitmandi.dao.model.OpenPoModel;
-
 
119
import com.spice.profitmandi.dao.model.OurPurchaseItemModel;
-
 
120
import com.spice.profitmandi.dao.model.OurPurchaseModel;
-
 
121
import com.spice.profitmandi.dao.model.SecondaeryOrderDateRange;
-
 
122
import com.spice.profitmandi.dao.model.SecondaryOrderBillingModel;
-
 
123
import com.spice.profitmandi.dao.model.SecondaryOrderItemBillingModel;
-
 
124
import com.spice.profitmandi.dao.model.SecondaryWarehouseWiseOrderBilllingModel;
-
 
125
import com.spice.profitmandi.dao.model.Specification;
-
 
126
import com.spice.profitmandi.dao.model.SpecificationGroup;
25
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
127
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
-
 
128
import com.spice.profitmandi.dao.repository.catalog.ComboMappedModelRepository;
-
 
129
import com.spice.profitmandi.dao.repository.catalog.ComboModelRepository;
-
 
130
import com.spice.profitmandi.dao.repository.catalog.ComboOptionRepository;
-
 
131
import com.spice.profitmandi.dao.repository.catalog.FocusedModelByPassRepository;
-
 
132
import com.spice.profitmandi.dao.repository.catalog.HighDemandItemsRepository;
26
import com.spice.profitmandi.dao.repository.catalog.*;
133
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
-
 
134
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
-
 
135
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
27
import com.spice.profitmandi.dao.repository.cs.CsService;
136
import com.spice.profitmandi.dao.repository.cs.CsService;
28
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
137
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
29
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
138
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
30
import com.spice.profitmandi.dao.repository.dtr.Mongo;
139
import com.spice.profitmandi.dao.repository.dtr.Mongo;
31
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
140
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
32
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
141
import com.spice.profitmandi.dao.repository.dtr.WebOfferRepository;
-
 
142
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
-
 
143
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
33
import com.spice.profitmandi.dao.repository.fofo.*;
144
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
-
 
145
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
-
 
146
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
-
 
147
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
34
import com.spice.profitmandi.dao.repository.inventory.NotifyStatus;
148
import com.spice.profitmandi.dao.repository.inventory.NotifyStatus;
-
 
149
import com.spice.profitmandi.dao.repository.transaction.NotifyCancelOrderRepository;
-
 
150
import com.spice.profitmandi.dao.repository.transaction.NotifyColorChangeRepository;
-
 
151
import com.spice.profitmandi.dao.repository.transaction.NotifyItemRepository;
-
 
152
import com.spice.profitmandi.dao.repository.transaction.NotifyMessageRepository;
-
 
153
import com.spice.profitmandi.dao.repository.transaction.NotifyOrderRespository;
35
import com.spice.profitmandi.dao.repository.transaction.*;
154
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
36
import com.spice.profitmandi.dao.repository.user.AddressRepository;
155
import com.spice.profitmandi.dao.repository.user.AddressRepository;
37
import com.spice.profitmandi.dao.repository.user.UserRepository;
156
import com.spice.profitmandi.dao.repository.user.UserRepository;
38
import com.spice.profitmandi.dao.repository.warehouse.WarehousePurchaseOrderRepository;
157
import com.spice.profitmandi.dao.repository.warehouse.WarehousePurchaseOrderRepository;
39
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
158
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
40
import com.spice.profitmandi.service.NotificationService;
159
import com.spice.profitmandi.service.NotificationService;
Line 45... Line 164...
45
import com.spice.profitmandi.service.order.OrderService;
164
import com.spice.profitmandi.service.order.OrderService;
46
import com.spice.profitmandi.service.user.RetailerService;
165
import com.spice.profitmandi.service.user.RetailerService;
47
import com.spice.profitmandi.web.model.LoginDetails;
166
import com.spice.profitmandi.web.model.LoginDetails;
48
import com.spice.profitmandi.web.util.CookiesProcessor;
167
import com.spice.profitmandi.web.util.CookiesProcessor;
49
import com.spice.profitmandi.web.util.MVCResponseSender;
168
import com.spice.profitmandi.web.util.MVCResponseSender;
-
 
169
 
50
import in.shop2020.model.v1.order.OrderStatus;
170
import in.shop2020.model.v1.order.OrderStatus;
51
import in.shop2020.model.v1.order.TransactionServiceException;
171
import in.shop2020.model.v1.order.TransactionServiceException;
52
import org.apache.commons.csv.CSVFormat;
-
 
53
import org.apache.commons.csv.CSVParser;
-
 
54
import org.apache.commons.csv.CSVRecord;
-
 
55
import org.apache.commons.io.FileUtils;
-
 
56
import org.apache.commons.lang3.StringUtils;
-
 
57
import org.apache.logging.log4j.LogManager;
-
 
58
import org.apache.logging.log4j.Logger;
-
 
59
import org.apache.thrift.TException;
-
 
60
import org.json.JSONObject;
-
 
61
import org.springframework.beans.factory.annotation.Autowired;
-
 
62
import org.springframework.beans.factory.annotation.Qualifier;
-
 
63
import org.springframework.beans.factory.annotation.Value;
-
 
64
import org.springframework.core.io.ByteArrayResource;
-
 
65
import org.springframework.core.io.ClassPathResource;
-
 
66
import org.springframework.core.io.InputStreamResource;
-
 
67
import org.springframework.http.HttpHeaders;
-
 
68
import org.springframework.http.HttpStatus;
-
 
69
import org.springframework.http.MediaType;
-
 
70
import org.springframework.http.ResponseEntity;
-
 
71
import org.springframework.mail.javamail.JavaMailSender;
-
 
72
import org.springframework.stereotype.Controller;
-
 
73
import org.springframework.transaction.annotation.Transactional;
-
 
74
import org.springframework.ui.Model;
-
 
75
import org.springframework.web.bind.annotation.*;
-
 
76
import org.springframework.web.multipart.MultipartFile;
-
 
77
 
172
 
78
import javax.servlet.http.HttpServletRequest;
-
 
79
import javax.servlet.http.HttpServletResponse;
-
 
80
import java.io.*;
-
 
81
import java.net.URISyntaxException;
-
 
82
import java.time.LocalDate;
-
 
83
import java.time.LocalDateTime;
-
 
84
import java.time.YearMonth;
-
 
85
import java.time.format.DateTimeFormatter;
-
 
86
import java.time.temporal.ChronoUnit;
-
 
87
import java.util.*;
-
 
88
import java.util.stream.Collectors;
-
 
89
import java.util.stream.Stream;
-
 
90
 
173
 
91
@Controller
174
@Controller
92
@Transactional(rollbackFor = Throwable.class)
175
@Transactional(rollbackFor = Throwable.class)
93
public class InventoryController {
176
public class InventoryController {
94
 
177
 
Line 1729... Line 1812...
1729
 
1812
 
1730
        model.addAttribute("response1", objectMapper.writeValueAsString(isImei));
1813
        model.addAttribute("response1", objectMapper.writeValueAsString(isImei));
1731
        return "response";
1814
        return "response";
1732
    }
1815
    }
1733
 
1816
 
-
 
1817
    @Autowired
-
 
1818
    RestClient restClient;
-
 
1819
 
-
 
1820
 
-
 
1821
    @Autowired
-
 
1822
    private CustomerRepository customerRepository;
-
 
1823
 
-
 
1824
 
1734
    @RequestMapping(value = "/createCombo", method = RequestMethod.GET)
1825
    @RequestMapping(value = "/createCombo", method = RequestMethod.GET)
1735
    public String createCombo(HttpServletRequest request, Model model) throws Exception {
1826
    public String createCombo(HttpServletRequest request, Model model) throws Exception {
1736
 
1827
 
1737
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1828
        Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
1738
 
1829
 
-
 
1830
        FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(315604);
-
 
1831
        Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
-
 
1832
        CustomRetailer retailer = retailerService.getFofoRetailer(fofoOrder.getFofoId());
-
 
1833
        String message = String.format("Dear %s,\n" + "Thank you for your purchase from SmartDukaan store - %s, %s.\n" + "Your purchase invoice is attached for your reference.\n" + "\n" + "Download our app for offers and updates on new products.\n" + "https://www.smartdukaan.com/b2c\n" + "\n" + "Best Regards\n" + "SmartDukaan", customer.getFirstName(), retailer.getBusinessName(), retailer.getAddress().getCity());
-
 
1834
        notificationService.sendWhatsappMediaMessage(message, "9816068341", this.getPublicInvoiceUrl(fofoOrder.getInvoiceNumber()), this.getFileName(fofoOrder.getInvoiceNumber()));
-
 
1835
 
-
 
1836
 
1739
        List<ComboModel> comboModels = comboModelRepository.selectAll();
1837
        List<ComboModel> comboModels = comboModelRepository.selectAll();
1740
 
1838
 
1741
        model.addAttribute("warehouseMap", warehouseMap);
1839
        model.addAttribute("warehouseMap", warehouseMap);
1742
        model.addAttribute("comboModels", comboModels);
1840
        model.addAttribute("comboModels", comboModels);
1743
        return "create-combo";
1841
        return "create-combo";
1744
    }
1842
    }
1745
 
1843
 
-
 
1844
 
-
 
1845
    private String getFileName(String invoiceNumber) {
-
 
1846
        return "INV-" + invoiceNumber.replace("/", "-") + ".pdf";
-
 
1847
    }
-
 
1848
 
-
 
1849
    private String getPublicInvoiceUrl(String invoiceNumber) {
-
 
1850
        String base64Encoded = Base64.getMimeEncoder().encodeToString(invoiceNumber.getBytes(StandardCharsets.UTF_8));
-
 
1851
        String publicUrl = "https://partners.smartdukaan.com/wa-invoice-send/" + base64Encoded + ".pdf";
-
 
1852
        return publicUrl;
-
 
1853
    }
-
 
1854
 
1746
    @RequestMapping(value = "/addCombo", method = RequestMethod.POST)
1855
    @RequestMapping(value = "/addCombo", method = RequestMethod.POST)
1747
    public String addCombo(HttpServletRequest request, @RequestBody Combo combo, Model model) throws Exception {
1856
    public String addCombo(HttpServletRequest request, @RequestBody Combo combo, Model model) throws Exception {
1748
        List<Integer> warehouseIds = new ArrayList<Integer>();
1857
        List<Integer> warehouseIds = new ArrayList<Integer>();
1749
 
1858
 
1750
 
1859