| 21577 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 22486 |
ashik.ali |
3 |
import java.io.ByteArrayInputStream;
|
|
|
4 |
import java.io.ByteArrayOutputStream;
|
| 26482 |
tejbeer |
5 |
import java.io.IOException;
|
| 22486 |
ashik.ali |
6 |
import java.io.InputStream;
|
| 26279 |
amit.gupta |
7 |
import java.io.InputStreamReader;
|
| 26482 |
tejbeer |
8 |
import java.net.URISyntaxException;
|
| 23886 |
amit.gupta |
9 |
import java.time.LocalDateTime;
|
| 26279 |
amit.gupta |
10 |
import java.time.format.DateTimeFormatter;
|
| 24465 |
tejbeer |
11 |
import java.util.ArrayList;
|
| 25873 |
tejbeer |
12 |
import java.util.Arrays;
|
| 26979 |
amit.gupta |
13 |
import java.util.Collection;
|
| 24917 |
tejbeer |
14 |
import java.util.HashMap;
|
| 24465 |
tejbeer |
15 |
import java.util.HashSet;
|
| 24917 |
tejbeer |
16 |
import java.util.Iterator;
|
| 21577 |
ashik.ali |
17 |
import java.util.List;
|
| 21654 |
ashik.ali |
18 |
import java.util.Map;
|
| 24917 |
tejbeer |
19 |
import java.util.Optional;
|
| 24465 |
tejbeer |
20 |
import java.util.Set;
|
|
|
21 |
import java.util.stream.Collectors;
|
| 21577 |
ashik.ali |
22 |
|
|
|
23 |
import javax.servlet.http.HttpServletRequest;
|
| 21987 |
kshitij.so |
24 |
import javax.servlet.http.HttpServletResponse;
|
| 21577 |
ashik.ali |
25 |
|
| 26279 |
amit.gupta |
26 |
import org.apache.commons.csv.CSVFormat;
|
|
|
27 |
import org.apache.commons.csv.CSVParser;
|
|
|
28 |
import org.apache.commons.csv.CSVRecord;
|
| 27544 |
amit.gupta |
29 |
import org.apache.commons.io.FileUtils;
|
| 26299 |
amit.gupta |
30 |
import org.apache.commons.lang3.StringUtils;
|
| 23886 |
amit.gupta |
31 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
32 |
import org.apache.logging.log4j.Logger;
|
| 24739 |
tejbeer |
33 |
import org.apache.thrift.TException;
|
| 24465 |
tejbeer |
34 |
import org.json.JSONObject;
|
| 21577 |
ashik.ali |
35 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23784 |
ashik.ali |
36 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 21987 |
kshitij.so |
37 |
import org.springframework.beans.factory.annotation.Value;
|
| 27544 |
amit.gupta |
38 |
import org.springframework.core.io.ClassPathResource;
|
| 22486 |
ashik.ali |
39 |
import org.springframework.core.io.InputStreamResource;
|
|
|
40 |
import org.springframework.http.HttpHeaders;
|
|
|
41 |
import org.springframework.http.HttpStatus;
|
| 25140 |
amit.gupta |
42 |
import org.springframework.http.MediaType;
|
| 22472 |
ashik.ali |
43 |
import org.springframework.http.ResponseEntity;
|
| 24917 |
tejbeer |
44 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 21577 |
ashik.ali |
45 |
import org.springframework.stereotype.Controller;
|
| 21654 |
ashik.ali |
46 |
import org.springframework.transaction.annotation.Transactional;
|
| 21577 |
ashik.ali |
47 |
import org.springframework.ui.Model;
|
| 26279 |
amit.gupta |
48 |
import org.springframework.web.bind.annotation.PostMapping;
|
| 22472 |
ashik.ali |
49 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 21577 |
ashik.ali |
50 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 22472 |
ashik.ali |
51 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21577 |
ashik.ali |
52 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 26279 |
amit.gupta |
53 |
import org.springframework.web.bind.annotation.RequestPart;
|
|
|
54 |
import org.springframework.web.multipart.MultipartFile;
|
| 21577 |
ashik.ali |
55 |
|
| 21987 |
kshitij.so |
56 |
import com.google.gson.Gson;
|
| 25698 |
tejbeer |
57 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 21577 |
ashik.ali |
58 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 21612 |
ashik.ali |
59 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
| 24106 |
tejbeer |
60 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22472 |
ashik.ali |
61 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 24106 |
tejbeer |
62 |
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
|
| 24917 |
tejbeer |
63 |
import com.spice.profitmandi.common.model.NotifyItemIdModel;
|
|
|
64 |
import com.spice.profitmandi.common.model.NotifyOrderIdModel;
|
|
|
65 |
import com.spice.profitmandi.common.model.NotifyOrderModel;
|
| 25640 |
tejbeer |
66 |
import com.spice.profitmandi.common.model.OrderCancellationModel;
|
| 25140 |
amit.gupta |
67 |
import com.spice.profitmandi.common.model.PdfModel;
|
| 21577 |
ashik.ali |
68 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 25851 |
amit.gupta |
69 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 22472 |
ashik.ali |
70 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 25140 |
amit.gupta |
71 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 24123 |
tejbeer |
72 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 24950 |
tejbeer |
73 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 24106 |
tejbeer |
74 |
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
|
| 25140 |
amit.gupta |
75 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 24917 |
tejbeer |
76 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 24465 |
tejbeer |
77 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
|
|
78 |
import com.spice.profitmandi.dao.entity.fofo.LiveDemoSerialNumber;
|
| 26031 |
tejbeer |
79 |
import com.spice.profitmandi.dao.entity.transaction.NotifyCancel;
|
| 24917 |
tejbeer |
80 |
import com.spice.profitmandi.dao.entity.transaction.NotifyColorChange;
|
| 25066 |
tejbeer |
81 |
import com.spice.profitmandi.dao.entity.transaction.NotifyMessage;
|
| 24917 |
tejbeer |
82 |
import com.spice.profitmandi.dao.entity.transaction.NotifyOrder;
|
| 24739 |
tejbeer |
83 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 26482 |
tejbeer |
84 |
import com.spice.profitmandi.dao.model.ContentPojo;
|
| 26498 |
amit.gupta |
85 |
import com.spice.profitmandi.dao.model.Specification;
|
|
|
86 |
import com.spice.profitmandi.dao.model.SpecificationGroup;
|
| 24123 |
tejbeer |
87 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 24950 |
tejbeer |
88 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 24106 |
tejbeer |
89 |
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
|
| 24465 |
tejbeer |
90 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 26482 |
tejbeer |
91 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 24917 |
tejbeer |
92 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 24203 |
amit.gupta |
93 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24465 |
tejbeer |
94 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
|
|
95 |
import com.spice.profitmandi.dao.repository.fofo.LiveDemoBillingRespository;
|
| 24917 |
tejbeer |
96 |
import com.spice.profitmandi.dao.repository.inventory.NotifyStatus;
|
| 26031 |
tejbeer |
97 |
import com.spice.profitmandi.dao.repository.transaction.NotifyCancelOrderRepository;
|
| 24917 |
tejbeer |
98 |
import com.spice.profitmandi.dao.repository.transaction.NotifyColorChangeRepository;
|
|
|
99 |
import com.spice.profitmandi.dao.repository.transaction.NotifyItemRepository;
|
| 25066 |
tejbeer |
100 |
import com.spice.profitmandi.dao.repository.transaction.NotifyMessageRepository;
|
| 24917 |
tejbeer |
101 |
import com.spice.profitmandi.dao.repository.transaction.NotifyOrderRespository;
|
| 24658 |
tejbeer |
102 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 25851 |
amit.gupta |
103 |
import com.spice.profitmandi.service.NotificationService;
|
| 22927 |
ashik.ali |
104 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 27516 |
amit.gupta |
105 |
import com.spice.profitmandi.service.order.OrderService;
|
| 24465 |
tejbeer |
106 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 22139 |
amit.gupta |
107 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 22069 |
ashik.ali |
108 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24106 |
tejbeer |
109 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 21577 |
ashik.ali |
110 |
|
| 24658 |
tejbeer |
111 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 24739 |
tejbeer |
112 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 24658 |
tejbeer |
113 |
|
| 21577 |
ashik.ali |
114 |
@Controller
|
| 24123 |
tejbeer |
115 |
@Transactional(rollbackFor = Throwable.class)
|
| 21577 |
ashik.ali |
116 |
public class InventoryController {
|
| 21987 |
kshitij.so |
117 |
|
| 23568 |
govind |
118 |
private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
|
| 26482 |
tejbeer |
119 |
|
| 26292 |
amit.gupta |
120 |
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy H:m:s");
|
| 27544 |
amit.gupta |
121 |
|
|
|
122 |
private static final List<String> imeis = Arrays.asList(
|
|
|
123 |
"351030944216680",
|
|
|
124 |
"351030944217183",
|
|
|
125 |
"351030944217886",
|
|
|
126 |
"351030944507286",
|
|
|
127 |
"351081710231270",
|
|
|
128 |
"351081710238713",
|
|
|
129 |
"351081710238796",
|
|
|
130 |
"351081710241279",
|
|
|
131 |
"351081710244737",
|
|
|
132 |
"355777112655976"
|
|
|
133 |
);
|
| 21987 |
kshitij.so |
134 |
|
| 21577 |
ashik.ali |
135 |
@Autowired
|
| 22927 |
ashik.ali |
136 |
private CookiesProcessor cookiesProcessor;
|
| 24123 |
tejbeer |
137 |
|
| 22354 |
ashik.ali |
138 |
@Autowired
|
| 23784 |
ashik.ali |
139 |
@Qualifier("fofoInventoryService")
|
| 22927 |
ashik.ali |
140 |
private InventoryService inventoryService;
|
| 24465 |
tejbeer |
141 |
|
| 24203 |
amit.gupta |
142 |
@Autowired
|
| 24950 |
tejbeer |
143 |
TagListingRepository tagListingRepository;
|
|
|
144 |
|
|
|
145 |
@Autowired
|
| 24203 |
amit.gupta |
146 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 24123 |
tejbeer |
147 |
|
| 24106 |
tejbeer |
148 |
@Autowired
|
|
|
149 |
private TagRankingRepository tagRankingRepository;
|
| 24123 |
tejbeer |
150 |
|
| 24106 |
tejbeer |
151 |
@Autowired
|
| 24465 |
tejbeer |
152 |
private InventoryItemRepository inventoryItemRepository;
|
|
|
153 |
|
|
|
154 |
@Autowired
|
|
|
155 |
private LiveDemoBillingRespository liveDemoBillingRespository;
|
|
|
156 |
|
|
|
157 |
@Autowired
|
| 24123 |
tejbeer |
158 |
private ItemRepository itemRepository;
|
|
|
159 |
|
|
|
160 |
@Autowired
|
| 26512 |
amit.gupta |
161 |
private Gson gson;
|
|
|
162 |
|
|
|
163 |
@Autowired
|
| 24465 |
tejbeer |
164 |
private RetailerService retailerService;
|
|
|
165 |
|
|
|
166 |
@Autowired
|
| 24106 |
tejbeer |
167 |
private MVCResponseSender mvcResponseSender;
|
| 24123 |
tejbeer |
168 |
|
| 24465 |
tejbeer |
169 |
@Autowired
|
|
|
170 |
FofoStoreRepository fofoStoreRepository;
|
|
|
171 |
|
| 24658 |
tejbeer |
172 |
@Autowired
|
|
|
173 |
private OrderRepository orderRepository;
|
|
|
174 |
|
| 24739 |
tejbeer |
175 |
@Autowired
|
| 24917 |
tejbeer |
176 |
private NotifyItemRepository notifyItemRepository;
|
| 24739 |
tejbeer |
177 |
|
| 24917 |
tejbeer |
178 |
@Autowired
|
|
|
179 |
private NotifyColorChangeRepository notifyColorChangeRepository;
|
|
|
180 |
|
|
|
181 |
@Autowired
|
|
|
182 |
private NotifyOrderRespository notifyOrderRespository;
|
|
|
183 |
|
|
|
184 |
@Autowired
|
| 25851 |
amit.gupta |
185 |
private NotificationService notificationService;
|
|
|
186 |
|
|
|
187 |
@Autowired
|
| 25066 |
tejbeer |
188 |
private NotifyMessageRepository notifyMessageRepository;
|
|
|
189 |
|
|
|
190 |
@Autowired
|
| 24917 |
tejbeer |
191 |
private UserAccountRepository userAccountRepository;
|
|
|
192 |
|
| 27516 |
amit.gupta |
193 |
@Autowired
|
|
|
194 |
private OrderService orderService;
|
|
|
195 |
|
| 21987 |
kshitij.so |
196 |
@Value("${saholic.api.host}")
|
|
|
197 |
private String host;
|
| 23786 |
amit.gupta |
198 |
|
| 21987 |
kshitij.so |
199 |
@Value("${saholic.api.port}")
|
|
|
200 |
private int port;
|
| 23786 |
amit.gupta |
201 |
|
| 21987 |
kshitij.so |
202 |
@Value("${saholic.api.webapp}")
|
|
|
203 |
private String webapp;
|
|
|
204 |
|
| 24917 |
tejbeer |
205 |
@Autowired
|
|
|
206 |
JavaMailSender mailSender;
|
|
|
207 |
|
| 26031 |
tejbeer |
208 |
@Autowired
|
|
|
209 |
private NotifyCancelOrderRepository notifyCancelOrderRepository;
|
|
|
210 |
|
| 26482 |
tejbeer |
211 |
@Autowired
|
|
|
212 |
private Mongo mongoClient;
|
|
|
213 |
|
| 23786 |
amit.gupta |
214 |
@RequestMapping(value = "/getCurrentInventorySnapshot")
|
|
|
215 |
public String getCurrentAvailability(HttpServletRequest request,
|
|
|
216 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
217 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| 24123 |
tejbeer |
218 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| 23786 |
amit.gupta |
219 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
220 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
221 |
Map<String, Object> map = inventoryService.getCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
222 |
searchTerm);
|
| 22927 |
ashik.ali |
223 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
224 |
return "inventory-snapshot";
|
| 21612 |
ashik.ali |
225 |
}
|
| 21987 |
kshitij.so |
226 |
|
| 23786 |
amit.gupta |
227 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
|
|
228 |
public String getBadAvailability(HttpServletRequest request,
|
|
|
229 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
230 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
231 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
232 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
233 |
if (searchTerm == null) {
|
|
|
234 |
searchTerm = "";
|
| 24052 |
amit.gupta |
235 |
}
|
| 22927 |
ashik.ali |
236 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
237 |
Map<String, Object> map = inventoryService.getBadInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
238 |
searchTerm);
|
| 22927 |
ashik.ali |
239 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
240 |
return "bad-inventory-snapshot";
|
|
|
241 |
}
|
|
|
242 |
|
| 23786 |
amit.gupta |
243 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
|
|
244 |
public String getPaginatedCurrentInventorySnapshot(HttpServletRequest request,
|
|
|
245 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
246 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
247 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
248 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
249 |
if (searchTerm == null) {
|
|
|
250 |
searchTerm = "";
|
| 24052 |
amit.gupta |
251 |
}
|
| 22927 |
ashik.ali |
252 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
253 |
Map<String, Object> map = inventoryService.getPaginatedCurrentInventorySnapshot(loginDetails.getFofoId(),
|
|
|
254 |
offset, limit, searchTerm);
|
| 22927 |
ashik.ali |
255 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
256 |
return "inventory-snapshot-paginated";
|
|
|
257 |
}
|
| 23786 |
amit.gupta |
258 |
|
|
|
259 |
@RequestMapping(value = "/getCatalog")
|
|
|
260 |
public String getCatalog(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
261 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
262 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
263 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
264 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
265 |
if (searchTerm == null) {
|
|
|
266 |
searchTerm = "";
|
| 24052 |
amit.gupta |
267 |
}
|
| 24739 |
tejbeer |
268 |
|
| 22927 |
ashik.ali |
269 |
Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm);
|
|
|
270 |
model.addAllAttributes(map);
|
| 24203 |
amit.gupta |
271 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| 24658 |
tejbeer |
272 |
|
| 21987 |
kshitij.so |
273 |
return "catalog";
|
|
|
274 |
}
|
| 23786 |
amit.gupta |
275 |
|
| 24465 |
tejbeer |
276 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
277 |
private boolean hasGift(int fofoId) {
|
|
|
278 |
try {
|
| 24465 |
tejbeer |
279 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
280 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
281 |
} catch (ProfitMandiBusinessException e) {
|
|
|
282 |
return false;
|
|
|
283 |
}
|
|
|
284 |
}
|
|
|
285 |
|
| 23786 |
amit.gupta |
286 |
@RequestMapping(value = "/getPaginatedCatalog")
|
|
|
287 |
public String getCatalogPaginated(HttpServletRequest request,
|
|
|
288 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
289 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
290 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
291 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
292 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
293 |
if (searchTerm == null) {
|
|
|
294 |
searchTerm = "";
|
| 24052 |
amit.gupta |
295 |
}
|
| 23786 |
amit.gupta |
296 |
Map<String, Object> map = inventoryService.getPaginatedCatalog(loginDetails.getFofoId(), offset, limit,
|
|
|
297 |
searchTerm);
|
| 22927 |
ashik.ali |
298 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
299 |
return "catalog-paginated";
|
|
|
300 |
}
|
|
|
301 |
|
| 23786 |
amit.gupta |
302 |
@RequestMapping(value = "/checkItemAvailability")
|
|
|
303 |
public String getItemAvailability(HttpServletRequest request,
|
|
|
304 |
@RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, Model model)
|
|
|
305 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
306 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
307 |
CustomCurrentInventorySnapshot customCurrentInventorySnapshot = inventoryService.checkItemAvailability(itemId,
|
|
|
308 |
loginDetails.getFofoId());
|
| 25812 |
amit.gupta |
309 |
/*
|
|
|
310 |
* customCurrentInventorySnapshot
|
|
|
311 |
* .setIconUrl(Utils.getIconUrl(customCurrentInventorySnapshot.getCatalogItemId(
|
|
|
312 |
* ), host, port, webapp));
|
|
|
313 |
*/
|
| 22927 |
ashik.ali |
314 |
model.addAttribute("currentInventorySnapshot", new Gson().toJson(customCurrentInventorySnapshot));
|
|
|
315 |
return "current-item-availability";
|
| 23786 |
amit.gupta |
316 |
|
| 21577 |
ashik.ali |
317 |
}
|
| 23786 |
amit.gupta |
318 |
|
| 23192 |
ashik.ali |
319 |
@RequestMapping(value = "/cart", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
320 |
public String addToCart(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
|
|
|
321 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
322 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
323 |
|
| 22927 |
ashik.ali |
324 |
Map<String, Object> map = inventoryService.addToCart(cartData, loginDetails.getFofoId());
|
|
|
325 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
326 |
return "cart";
|
|
|
327 |
}
|
| 23786 |
amit.gupta |
328 |
|
| 23192 |
ashik.ali |
329 |
@RequestMapping(value = "/validate-cart", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
330 |
public String validateCart(HttpServletRequest request, HttpServletResponse response,
|
|
|
331 |
@RequestParam(name = "cartData") String cartData, Model model) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
332 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
333 |
|
| 22927 |
ashik.ali |
334 |
Map<String, Object> map = inventoryService.validateCart(cartData, loginDetails.getFofoId());
|
|
|
335 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
336 |
return "validate-cart";
|
|
|
337 |
}
|
|
|
338 |
|
| 23786 |
amit.gupta |
339 |
@RequestMapping(value = "/grnHistory")
|
| 24123 |
tejbeer |
340 |
public String getGrnHistory(HttpServletRequest request, @RequestParam(required = false) LocalDateTime startTime,
|
| 23886 |
amit.gupta |
341 |
@RequestParam(required = false) LocalDateTime endTime,
|
| 23786 |
amit.gupta |
342 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
343 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
344 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
345 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
346 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
347 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
348 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset,
|
|
|
349 |
limit, purchaseReference, searchType);
|
| 22927 |
ashik.ali |
350 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
351 |
return "grn-history";
|
| 21636 |
ashik.ali |
352 |
}
|
| 21987 |
kshitij.so |
353 |
|
| 25140 |
amit.gupta |
354 |
@RequestMapping(value = "/downloadPurchaseInvoices")
|
|
|
355 |
public ResponseEntity<?> downloadPurchaseInvoices(HttpServletRequest request,
|
|
|
356 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
357 |
@RequestParam(required = false) LocalDateTime endTime,
|
|
|
358 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
359 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
360 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
361 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
362 |
throws ProfitMandiBusinessException {
|
|
|
363 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
364 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset,
|
|
|
365 |
limit, purchaseReference, searchType);
|
|
|
366 |
|
|
|
367 |
List<FofoOrder> fofoOrders = (List<FofoOrder>) map.get("saleHistories");
|
|
|
368 |
|
|
|
369 |
if (fofoOrders.size() == 0) {
|
|
|
370 |
throw new ProfitMandiBusinessException("Search criteria", "", "No orders found for criteria");
|
|
|
371 |
}
|
|
|
372 |
|
|
|
373 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
374 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
|
375 |
headers.set("Content-disposition", "inline; filename=invoices.pdf");
|
|
|
376 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
377 |
List<PdfModel> pdfModels = new ArrayList<>();
|
| 25371 |
tejbeer |
378 |
/*
|
|
|
379 |
* for (FofoOrder fofoOrder : fofoOrders) { try {
|
|
|
380 |
* pdfModels.add(orderService.getInvoicePdfModel(fofoOrder.getId())); } catch
|
|
|
381 |
* (Exception e) {
|
|
|
382 |
* LOGGER.info("could not create invoice for {}, invoice number {}",
|
|
|
383 |
* fofoOrder.getId(), fofoOrder.getInvoiceNumber()); } }
|
|
|
384 |
*/
|
| 25140 |
amit.gupta |
385 |
PdfUtils.generateAndWrite(pdfModels, byteArrayOutputStream);
|
|
|
386 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
387 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
388 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
389 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
390 |
}
|
|
|
391 |
|
| 23786 |
amit.gupta |
392 |
@RequestMapping(value = "/getPaginatedGrnHistory")
|
|
|
393 |
public String getPaginatedGrnHistory(HttpServletRequest request,
|
| 23886 |
amit.gupta |
394 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
395 |
@RequestParam(required = false) LocalDateTime endTime,
|
| 23786 |
amit.gupta |
396 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
397 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
398 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
399 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
400 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
401 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
402 |
Map<String, Object> map = inventoryService.getPaginatedGrnHistory(loginDetails.getFofoId(), startTime, endTime,
|
|
|
403 |
offset, limit);
|
| 22927 |
ashik.ali |
404 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
405 |
return "grn-history-paginated";
|
|
|
406 |
}
|
|
|
407 |
|
| 23786 |
amit.gupta |
408 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
|
|
|
409 |
public String grnHistoryByPurchaseId(HttpServletRequest request,
|
|
|
410 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_ID) int purchaseId, Model model)
|
|
|
411 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
412 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
413 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseId, host, port,
|
|
|
414 |
webapp);
|
| 22927 |
ashik.ali |
415 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
416 |
return "grn-details";
|
| 21636 |
ashik.ali |
417 |
}
|
| 21987 |
kshitij.so |
418 |
|
| 23786 |
amit.gupta |
419 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseReference")
|
|
|
420 |
public String grnHistoryByPurchaseReference(HttpServletRequest request,
|
|
|
421 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE) String purchaseReference, Model model)
|
|
|
422 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
423 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
424 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseReference,
|
|
|
425 |
host, port, webapp);
|
| 22927 |
ashik.ali |
426 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
427 |
return "grn-details";
|
| 21654 |
ashik.ali |
428 |
}
|
| 23786 |
amit.gupta |
429 |
|
| 26248 |
amit.gupta |
430 |
@RequestMapping(value = "/activatedImeis")
|
|
|
431 |
public String activatedImeis(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
432 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
433 |
|
|
|
434 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByActivatedNotSold(loginDetails.getFofoId());
|
|
|
435 |
inventoryItems.stream().forEach(x -> {
|
|
|
436 |
try {
|
|
|
437 |
x.setItem(itemRepository.selectById(x.getItemId()));
|
|
|
438 |
} catch (Exception e) {
|
|
|
439 |
e.printStackTrace();
|
|
|
440 |
}
|
|
|
441 |
});
|
|
|
442 |
model.addAttribute("inventoryItems", inventoryItems);
|
|
|
443 |
return "activated-imeis";
|
|
|
444 |
}
|
| 27516 |
amit.gupta |
445 |
|
|
|
446 |
@RequestMapping(value = "/view-invoices")
|
|
|
447 |
public String viewInvoices(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
448 |
return "view-dummy-invoices";
|
|
|
449 |
}
|
|
|
450 |
|
|
|
451 |
@RequestMapping(value = "/dummy-invoices")
|
|
|
452 |
public ResponseEntity<?> downloadInvoices(HttpServletRequest request, @RequestParam String serialNumber, Model model) throws ProfitMandiBusinessException {
|
| 27544 |
amit.gupta |
453 |
byte[] bytes = null;
|
|
|
454 |
if(!imeis.contains(serialNumber)) {
|
|
|
455 |
PdfModel pdfModel = orderService.getDummyPdfModel(serialNumber);
|
|
|
456 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
457 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
|
|
458 |
bytes = byteArrayOutputStream.toByteArray();
|
|
|
459 |
} else {
|
|
|
460 |
ClassPathResource resource = new ClassPathResource("/META-INF/" + serialNumber + ".pdf");
|
|
|
461 |
try {
|
|
|
462 |
bytes = FileUtils.readFileToByteArray(resource.getFile());
|
|
|
463 |
} catch(Exception e) {
|
|
|
464 |
|
|
|
465 |
}
|
|
|
466 |
}
|
| 27516 |
amit.gupta |
467 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
468 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
| 27544 |
amit.gupta |
469 |
headers.set("Content-disposition", "inline; filename=invoice-" + serialNumber + ".pdf");
|
|
|
470 |
headers.setContentLength(bytes.length);
|
|
|
471 |
final InputStream inputStream = new ByteArrayInputStream(bytes);
|
| 27516 |
amit.gupta |
472 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
473 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
474 |
}
|
| 26248 |
amit.gupta |
475 |
|
| 22472 |
ashik.ali |
476 |
@RequestMapping(value = "/getInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
477 |
public String getInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals,
|
|
|
478 |
Model model, @RequestParam(name = "searchContent", defaultValue = "") String searchContent,
|
|
|
479 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
480 |
@RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
481 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
482 |
Map<String, Object> map = inventoryService.getPaginatedItemAgingByInterval(loginDetails.getFofoId(), intervals,
|
|
|
483 |
searchContent, offset, limit);
|
| 22927 |
ashik.ali |
484 |
model.addAllAttributes(map);
|
| 22523 |
ashik.ali |
485 |
return "item-aging";
|
|
|
486 |
}
|
| 23786 |
amit.gupta |
487 |
|
| 22523 |
ashik.ali |
488 |
@RequestMapping(value = "/downloadInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
489 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request,
|
|
|
490 |
@RequestBody List<Integer> intervals, Model model) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
491 |
LOGGER.info("Request received at url{} with body {}", request.getRequestURI(), intervals);
|
|
|
492 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
493 |
|
|
|
494 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService
|
|
|
495 |
.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
|
|
|
496 |
|
| 22486 |
ashik.ali |
497 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
498 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
| 23786 |
amit.gupta |
499 |
|
|
|
500 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
501 |
// private static final String CONTENT_TYPE_XLSX =
|
|
|
502 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
|
503 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
504 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
| 22486 |
ashik.ali |
505 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
| 23786 |
amit.gupta |
506 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
507 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
508 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
509 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| 22472 |
ashik.ali |
510 |
}
|
| 26961 |
amit.gupta |
511 |
|
| 26968 |
amit.gupta |
512 |
@RequestMapping(value = "/aging-report", method = RequestMethod.GET)
|
| 26961 |
amit.gupta |
513 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request) throws ProfitMandiBusinessException {
|
|
|
514 |
|
|
|
515 |
List<Integer> intervals = Arrays.asList(5,15,30,45);
|
|
|
516 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService.getItemAgingByInterval(intervals)
|
| 26979 |
amit.gupta |
517 |
.values().stream().flatMap(Collection::stream).collect(Collectors.toList());
|
|
|
518 |
LOGGER.info("Fofo Id {}", inventoryItemAgingModels.get(0).getFofoId());
|
| 26961 |
amit.gupta |
519 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
520 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
|
|
521 |
|
|
|
522 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
523 |
// private static final String CONTENT_TYPE_XLSX =
|
|
|
524 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
|
525 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
526 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
|
|
527 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
|
|
528 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
529 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
530 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
531 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
532 |
}
|
| 24123 |
tejbeer |
533 |
|
| 24106 |
tejbeer |
534 |
@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
|
| 25371 |
tejbeer |
535 |
public String FeaturePanel(HttpServletRequest request, Model model) throws Exception {
|
| 21987 |
kshitij.so |
536 |
|
| 24106 |
tejbeer |
537 |
List<TagRanking> tagRanking = null;
|
| 25362 |
tejbeer |
538 |
tagRanking = tagRankingRepository.getAllTagRanking();
|
| 24106 |
tejbeer |
539 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
540 |
if (!tagRanking.isEmpty()) {
|
| 25371 |
tejbeer |
541 |
Set<Integer> catalogIds = tagRanking.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
| 24798 |
tejbeer |
542 |
List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
|
|
|
543 |
Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
|
|
|
544 |
x -> x.getItemDescription(), (description1, description2) -> description1));
|
|
|
545 |
|
|
|
546 |
LOGGER.info("catalogDescription" + catalogDescription);
|
| 24465 |
tejbeer |
547 |
model.addAttribute("tagRanking", tagRanking);
|
| 24798 |
tejbeer |
548 |
model.addAttribute("catalogDescription", catalogDescription);
|
| 24106 |
tejbeer |
549 |
|
|
|
550 |
} else {
|
|
|
551 |
model.addAttribute("tagRanking", tagRanking);
|
| 25362 |
tejbeer |
552 |
|
| 24106 |
tejbeer |
553 |
}
|
|
|
554 |
|
|
|
555 |
return "feature";
|
|
|
556 |
|
|
|
557 |
}
|
| 24123 |
tejbeer |
558 |
|
| 26279 |
amit.gupta |
559 |
@PostMapping(value = "/imei/upload")
|
| 26294 |
amit.gupta |
560 |
public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
|
| 26279 |
amit.gupta |
561 |
throws Exception {
|
| 26482 |
tejbeer |
562 |
/*
|
|
|
563 |
* if(brand==null) { throw new
|
|
|
564 |
* ProfitMandiBusinessException("Please select brand", "Brand empty",
|
|
|
565 |
* "Brand required"); }
|
|
|
566 |
*/
|
| 26279 |
amit.gupta |
567 |
List<CSVRecord> masterDataList = readFile(file);
|
|
|
568 |
|
| 26482 |
tejbeer |
569 |
Map<String, LocalDateTime> imeisActivationMap = masterDataList.stream()
|
|
|
570 |
.collect(Collectors.toMap(x -> x.get(0).trim(), x -> {
|
|
|
571 |
if (!StringUtils.isEmpty(x.get(1).trim())) {
|
|
|
572 |
return LocalDateTime.parse((String) (x.get(1).trim()), formatter);
|
| 26299 |
amit.gupta |
573 |
} else {
|
|
|
574 |
return null;
|
|
|
575 |
}
|
|
|
576 |
}));
|
|
|
577 |
inventoryService.addActivatedImeis(imeisActivationMap);
|
|
|
578 |
model.addAttribute("response", true);
|
| 26294 |
amit.gupta |
579 |
return "response";
|
| 26279 |
amit.gupta |
580 |
}
|
|
|
581 |
|
|
|
582 |
private List<CSVRecord> readFile(MultipartFile file) throws Exception {
|
|
|
583 |
List<CSVRecord> records = null;
|
|
|
584 |
try (CSVParser parser = new CSVParser(new InputStreamReader(file.getInputStream()), CSVFormat.DEFAULT)) {
|
|
|
585 |
records = parser.getRecords();
|
|
|
586 |
if (records.size() < 2) {
|
|
|
587 |
throw new ProfitMandiBusinessException("Uploaded File", "", "No records Found");
|
|
|
588 |
}
|
|
|
589 |
records.remove(0);
|
| 26482 |
tejbeer |
590 |
} catch (Exception e) {
|
| 26279 |
amit.gupta |
591 |
throw new ProfitMandiBusinessException("Parsing Failed", "parse failed", "file parse failed");
|
|
|
592 |
}
|
|
|
593 |
return records;
|
|
|
594 |
}
|
|
|
595 |
|
| 24106 |
tejbeer |
596 |
@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
|
| 24123 |
tejbeer |
597 |
public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel,
|
|
|
598 |
Model model) throws Exception {
|
| 25371 |
tejbeer |
599 |
TagRanking tagRanking = tagRankingRepository.selectBycatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
|
|
600 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
601 |
if (tagRanking == null) {
|
|
|
602 |
tagRanking = new TagRanking();
|
|
|
603 |
tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
| 25363 |
tejbeer |
604 |
}
|
| 24106 |
tejbeer |
605 |
tagRanking.setFeature(itemFeatureDatatModel.getFeature());
|
| 25363 |
tejbeer |
606 |
tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
|
| 25371 |
tejbeer |
607 |
|
| 24123 |
tejbeer |
608 |
tagRankingRepository.persist(tagRanking);
|
| 24106 |
tejbeer |
609 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
610 |
return "response";
|
|
|
611 |
}
|
|
|
612 |
|
| 24798 |
tejbeer |
613 |
@RequestMapping(value = "/removeFeature", method = RequestMethod.DELETE)
|
|
|
614 |
public String removeTagRankingEnteries(HttpServletRequest request,
|
|
|
615 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
| 24917 |
tejbeer |
616 |
|
| 24798 |
tejbeer |
617 |
tagRankingRepository.deleteById(id);
|
|
|
618 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
619 |
return "response";
|
|
|
620 |
}
|
|
|
621 |
|
| 24465 |
tejbeer |
622 |
@RequestMapping(value = "/getDemolistbyfofoId", method = RequestMethod.GET)
|
|
|
623 |
public String DemoListbyFofoId(HttpServletRequest request,
|
|
|
624 |
@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
|
|
625 |
|
|
|
626 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
|
|
627 |
.collect(Collectors.toList());
|
|
|
628 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
|
|
|
629 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
|
|
630 |
List<String> serailNumberList = liveDemoBillingRespository.selectAllSerialNumber();
|
|
|
631 |
LOGGER.info("serailNumberList" + serailNumberList);
|
|
|
632 |
List<InventoryItem> inventoryItem = null;
|
|
|
633 |
List<InventoryItem> inventoryItem1 = new ArrayList<>();
|
|
|
634 |
if (fofoId > 0) {
|
|
|
635 |
List<Item> items = itemRepository.selectAllByBrand("Live Demo");
|
|
|
636 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
637 |
for (Item Item : items) {
|
|
|
638 |
itemIds.add(Item.getId());
|
|
|
639 |
}
|
|
|
640 |
inventoryItem = inventoryItemRepository.selectByFofoIdItemIds(fofoId, itemIds);
|
|
|
641 |
|
|
|
642 |
Set<String> serial = new HashSet<>();
|
|
|
643 |
for (InventoryItem invItem : inventoryItem) {
|
| 24658 |
tejbeer |
644 |
if (!serailNumberList.contains(invItem.getSerialNumber())) {
|
| 24465 |
tejbeer |
645 |
inventoryItem1.add(invItem);
|
| 25371 |
tejbeer |
646 |
|
| 24465 |
tejbeer |
647 |
}
|
|
|
648 |
|
|
|
649 |
}
|
|
|
650 |
|
|
|
651 |
LOGGER.info("inventoyItem" + inventoryItem1);
|
|
|
652 |
model.addAttribute("customRetailers", customRetailers);
|
| 25371 |
tejbeer |
653 |
|
| 24465 |
tejbeer |
654 |
model.addAttribute("liveDemo", inventoryItem1);
|
|
|
655 |
CustomRetailer fofoIdsAndRetailerName = retailerService.getFofoRetailer(fofoId);
|
|
|
656 |
|
|
|
657 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
|
|
658 |
|
|
|
659 |
}
|
|
|
660 |
|
|
|
661 |
else {
|
|
|
662 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
663 |
model.addAttribute("liveDemo", inventoryItem1);
|
|
|
664 |
}
|
|
|
665 |
|
|
|
666 |
return "live_demo_billing";
|
|
|
667 |
|
|
|
668 |
}
|
|
|
669 |
|
|
|
670 |
@RequestMapping(value = "/enableliveDemoSerailNumber", method = RequestMethod.POST)
|
|
|
671 |
public String EnableliveDemoSerailNumber(HttpServletRequest request, @RequestParam String serial_number,
|
|
|
672 |
Model model) throws Exception {
|
|
|
673 |
|
|
|
674 |
LiveDemoSerialNumber liveDemoSerialNumber = new LiveDemoSerialNumber();
|
|
|
675 |
liveDemoSerialNumber.setSerialNumber(serial_number);
|
|
|
676 |
|
|
|
677 |
liveDemoBillingRespository.persist(liveDemoSerialNumber);
|
|
|
678 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
679 |
return "response";
|
|
|
680 |
}
|
|
|
681 |
|
| 24739 |
tejbeer |
682 |
@RequestMapping(value = "/getInProcessOrder", method = RequestMethod.GET)
|
|
|
683 |
public String getInProcessOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
684 |
|
|
|
685 |
List<com.spice.profitmandi.dao.entity.transaction.Order> inProcessorder = orderRepository
|
| 25067 |
tejbeer |
686 |
.selectAllOrder(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 24917 |
tejbeer |
687 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
688 |
List<Integer> orderIds = new ArrayList<>();
|
|
|
689 |
if (!inProcessorder.isEmpty()) {
|
|
|
690 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessorder) {
|
|
|
691 |
retailerIds.add(order.getRetailerId());
|
|
|
692 |
orderIds.add(order.getId());
|
| 24739 |
tejbeer |
693 |
|
| 24917 |
tejbeer |
694 |
}
|
| 24739 |
tejbeer |
695 |
|
| 25640 |
tejbeer |
696 |
List<NotifyOrder> notify = notifyOrderRespository.selectByorderIds(orderIds);
|
|
|
697 |
for (NotifyOrder notifyOrder : notify) {
|
| 25449 |
tejbeer |
698 |
|
| 25640 |
tejbeer |
699 |
Order orderdetail = orderRepository.selectById(notifyOrder.getOrderId());
|
| 25449 |
tejbeer |
700 |
if (!orderdetail.getStatus().equals(OrderStatus.SUBMITTED_FOR_PROCESSING)) {
|
| 25640 |
tejbeer |
701 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
| 25449 |
tejbeer |
702 |
}
|
| 25640 |
tejbeer |
703 |
}
|
| 24950 |
tejbeer |
704 |
|
| 24917 |
tejbeer |
705 |
Map<Integer, Optional<NotifyOrder>> notifyOrders = notifyOrderRespository.selectByorderIds(orderIds)
|
|
|
706 |
.stream().collect(Collectors.groupingBy(NotifyOrder::getOrderId,
|
|
|
707 |
Collectors.maxBy((x1, x2) -> x1.getId() - x2.getId())));
|
| 24950 |
tejbeer |
708 |
|
| 26110 |
tejbeer |
709 |
Map<Integer, NotifyCancel> notifyCancelOrders = notifyCancelOrderRepository.selectByOrderIds(orderIds)
|
|
|
710 |
.stream().collect(Collectors.toMap(x -> x.getOrderId(), x -> x));
|
| 24917 |
tejbeer |
711 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
|
|
712 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
|
|
713 |
List<com.spice.profitmandi.dao.entity.transaction.Order> pendingPaymentorder = orderRepository
|
|
|
714 |
.selectAllOrderDatesBetweenByStatus(LocalDateTime.now().minusDays(30), LocalDateTime.now(),
|
|
|
715 |
OrderStatus.PAYMENT_PENDING);
|
|
|
716 |
List<com.spice.profitmandi.dao.entity.transaction.Order> failedPaymentorder = orderRepository
|
|
|
717 |
.selectAllOrderDatesBetweenByStatus(LocalDateTime.now().minusDays(30), LocalDateTime.now(),
|
|
|
718 |
OrderStatus.PAYMENT_FAILED);
|
|
|
719 |
pendingPaymentorder.addAll(failedPaymentorder);
|
|
|
720 |
|
|
|
721 |
model.addAttribute("inProcessorder", inProcessorder);
|
|
|
722 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
|
|
723 |
model.addAttribute("pendingPaymentorder", pendingPaymentorder);
|
|
|
724 |
model.addAttribute("latestNotifyOrders", notifyOrders);
|
| 26110 |
tejbeer |
725 |
model.addAttribute("notifyCancelOrders", notifyCancelOrders);
|
| 24917 |
tejbeer |
726 |
} else {
|
|
|
727 |
model.addAttribute("inProcessorder", inProcessorder);
|
|
|
728 |
}
|
| 24739 |
tejbeer |
729 |
return "review_order";
|
|
|
730 |
}
|
|
|
731 |
|
|
|
732 |
@RequestMapping(value = "/getKeepInTabOrder", method = RequestMethod.GET)
|
|
|
733 |
public String getKeepInTabOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
734 |
|
|
|
735 |
List<com.spice.profitmandi.dao.entity.transaction.Order> keepatab = orderRepository
|
|
|
736 |
.selectAllOrder(OrderStatus.KEEP_A_TAB);
|
|
|
737 |
|
|
|
738 |
model.addAttribute("keepatab", keepatab);
|
|
|
739 |
|
|
|
740 |
return "keep-a-tab";
|
|
|
741 |
}
|
|
|
742 |
|
|
|
743 |
@RequestMapping(value = "/closeOrder", method = RequestMethod.POST)
|
|
|
744 |
public String closeOrder(HttpServletRequest request, @RequestParam int orderId, Model model) throws Exception {
|
| 24798 |
tejbeer |
745 |
|
| 24739 |
tejbeer |
746 |
Order order = orderRepository.selectById(orderId);
|
| 24798 |
tejbeer |
747 |
if (order != null) {
|
| 24739 |
tejbeer |
748 |
order.setStatus(OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
| 24798 |
tejbeer |
749 |
|
| 24739 |
tejbeer |
750 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
751 |
|
| 24798 |
tejbeer |
752 |
} else {
|
| 24739 |
tejbeer |
753 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
754 |
|
|
|
755 |
}
|
|
|
756 |
return "response";
|
| 24658 |
tejbeer |
757 |
}
|
|
|
758 |
|
| 25640 |
tejbeer |
759 |
@RequestMapping(value = "/getcancelOrderItems", method = RequestMethod.GET)
|
|
|
760 |
public String getcancelOrderItems(HttpServletRequest request, @RequestParam int itemId, Model model)
|
|
|
761 |
throws Exception {
|
|
|
762 |
|
|
|
763 |
List<Order> inProcessselectedOrder = orderRepository.selectByItemIdOrderStatus(itemId,
|
|
|
764 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
765 |
|
|
|
766 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
767 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessselectedOrder) {
|
|
|
768 |
retailerIds.add(order.getRetailerId());
|
|
|
769 |
|
|
|
770 |
}
|
|
|
771 |
|
|
|
772 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
|
|
773 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
|
|
774 |
|
|
|
775 |
model.addAttribute("inProcessCancelOrder", inProcessselectedOrder);
|
|
|
776 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
|
|
777 |
|
|
|
778 |
return "cancel-order-modal";
|
|
|
779 |
}
|
|
|
780 |
|
| 24739 |
tejbeer |
781 |
@RequestMapping(value = "/cancelOrder", method = RequestMethod.POST)
|
| 25640 |
tejbeer |
782 |
public String cancelOrder(HttpServletRequest request, @RequestBody OrderCancellationModel orderCancellationModel,
|
|
|
783 |
Model model) throws Exception {
|
| 24739 |
tejbeer |
784 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 25640 |
tejbeer |
785 |
LOGGER.info("orderId" + orderCancellationModel.getOrderIds());
|
|
|
786 |
|
| 24739 |
tejbeer |
787 |
try {
|
| 25699 |
tejbeer |
788 |
// List<Order> orders =
|
|
|
789 |
// orderRepository.selectByOrderIds(orderCancellationModel.getOrderIds());
|
| 25640 |
tejbeer |
790 |
|
| 25699 |
tejbeer |
791 |
List<Order> orders = orderRepository.selectByOrderIdsOrdersStatus(orderCancellationModel.getOrderIds(),
|
|
|
792 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
793 |
if (!orders.isEmpty()) {
|
|
|
794 |
for (Order order : orders) {
|
| 25640 |
tejbeer |
795 |
|
| 25699 |
tejbeer |
796 |
orderRepository.refundOrder(order.getId(), loginDetails.getEmailId(),
|
|
|
797 |
orderCancellationModel.getReason(), OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
|
|
798 |
List<NotifyOrder> notifyOrders = notifyOrderRespository.selectByOrder(order.getId());
|
|
|
799 |
for (NotifyOrder notifyOrder : notifyOrders) {
|
|
|
800 |
if (notifyOrder.getStatus() == NotifyStatus.pending) {
|
|
|
801 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
|
|
802 |
}
|
| 25449 |
tejbeer |
803 |
}
|
| 25699 |
tejbeer |
804 |
sendCancellationNotificationToPartner(order, orderCancellationModel.getReason());
|
|
|
805 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
806 |
|
| 25640 |
tejbeer |
807 |
}
|
|
|
808 |
}
|
| 24739 |
tejbeer |
809 |
} catch (TransactionServiceException | TException e) {
|
|
|
810 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
811 |
|
|
|
812 |
}
|
| 25640 |
tejbeer |
813 |
|
| 24739 |
tejbeer |
814 |
return "response";
|
|
|
815 |
}
|
|
|
816 |
|
| 25039 |
amit.gupta |
817 |
private void sendCancellationNotificationToPartner(Order order, String reason) throws Exception {
|
|
|
818 |
Item item = itemRepository.selectById(order.getLineItem().getItemId());
|
| 25383 |
tejbeer |
819 |
|
| 25851 |
amit.gupta |
820 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
821 |
sendNotificationModel.setCampaignName("Order Cancellation");
|
|
|
822 |
sendNotificationModel.setTitle(String.format("Order %s %d(Pcs) cancelled", item.getItemDescription(),
|
| 25140 |
amit.gupta |
823 |
order.getLineItem().getQuantity()));
|
| 25851 |
amit.gupta |
824 |
sendNotificationModel.setType("url");
|
|
|
825 |
sendNotificationModel.setMessage(reason);
|
| 26482 |
tejbeer |
826 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/orderDetails");
|
| 25851 |
amit.gupta |
827 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
|
|
828 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 25857 |
tejbeer |
829 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
| 25873 |
tejbeer |
830 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 25851 |
amit.gupta |
831 |
notificationService.sendNotification(sendNotificationModel);
|
| 25140 |
amit.gupta |
832 |
|
| 25039 |
amit.gupta |
833 |
}
|
|
|
834 |
|
| 24917 |
tejbeer |
835 |
@RequestMapping(value = "/getNotifyItemColor", method = RequestMethod.GET)
|
|
|
836 |
public String getNotifyItemColor(HttpServletRequest request, @RequestParam int catalogItemId,
|
|
|
837 |
@RequestParam int itemId, Model model) throws ProfitMandiBusinessException {
|
|
|
838 |
|
| 24950 |
tejbeer |
839 |
List<Item> availableColorItems = itemRepository.selectAllByCatalogItemId(catalogItemId);
|
|
|
840 |
Iterator<Item> itemsIterator = availableColorItems.iterator();
|
| 24917 |
tejbeer |
841 |
|
| 24950 |
tejbeer |
842 |
while (itemsIterator.hasNext()) {
|
|
|
843 |
Item item = itemsIterator.next();
|
|
|
844 |
TagListing itemTagListing = tagListingRepository.selectByItemId(item.getId());
|
|
|
845 |
|
|
|
846 |
if (itemTagListing == null) {
|
|
|
847 |
itemsIterator.remove();
|
|
|
848 |
|
|
|
849 |
}
|
|
|
850 |
|
|
|
851 |
else if (!itemTagListing.isActive()) {
|
|
|
852 |
itemsIterator.remove();
|
|
|
853 |
|
|
|
854 |
}
|
|
|
855 |
}
|
|
|
856 |
|
| 24917 |
tejbeer |
857 |
List<Order> inProcessselectedOrder = orderRepository.selectByItemIdOrderStatus(itemId,
|
|
|
858 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
859 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
860 |
|
|
|
861 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessselectedOrder) {
|
|
|
862 |
retailerIds.add(order.getRetailerId());
|
|
|
863 |
|
|
|
864 |
}
|
|
|
865 |
|
|
|
866 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
|
|
867 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
| 24950 |
tejbeer |
868 |
LOGGER.info("item" + availableColorItems);
|
|
|
869 |
model.addAttribute("item", availableColorItems);
|
| 24917 |
tejbeer |
870 |
model.addAttribute("inProcessselectedOrder", inProcessselectedOrder);
|
|
|
871 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
|
|
872 |
|
|
|
873 |
return "notify-order-modal";
|
|
|
874 |
}
|
|
|
875 |
|
|
|
876 |
@RequestMapping(value = "/notifyOrder", method = RequestMethod.POST)
|
|
|
877 |
public String NotifyOrder(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel, Model model)
|
|
|
878 |
throws Exception {
|
|
|
879 |
|
|
|
880 |
com.spice.profitmandi.dao.entity.transaction.NotifyItem notifyItem = null;
|
|
|
881 |
List<Integer> orderIds = new ArrayList<>();
|
|
|
882 |
|
|
|
883 |
NotifyColorChange notifytimestamp = new NotifyColorChange();
|
|
|
884 |
notifytimestamp.setCreated(LocalDateTime.now());
|
|
|
885 |
notifyColorChangeRepository.persist(notifytimestamp);
|
| 25066 |
tejbeer |
886 |
NotifyMessage notifyMessage = new NotifyMessage();
|
|
|
887 |
notifyMessage.setNotifyId(notifytimestamp.getId());
|
|
|
888 |
notifyMessage.setNotifyMessages(notifyOrderModel.getMessage());
|
| 25140 |
amit.gupta |
889 |
notifyMessageRepository.persist(notifyMessage);
|
| 24917 |
tejbeer |
890 |
for (NotifyItemIdModel itemid : notifyOrderModel.getItemIds()) {
|
|
|
891 |
|
|
|
892 |
notifyItem = new com.spice.profitmandi.dao.entity.transaction.NotifyItem();
|
|
|
893 |
notifyItem.setItemId(itemid.getItemId());
|
|
|
894 |
notifyItem.setResponseTime(itemid.getResponseTime());
|
|
|
895 |
notifyItem.setProcuredDate(itemid.getProcuredTime());
|
|
|
896 |
notifyItem.setNotifyColorchangeId(notifytimestamp.getId());
|
|
|
897 |
notifyItemRepository.persist(notifyItem);
|
|
|
898 |
LOGGER.info("notifyItem" + notifyItem);
|
|
|
899 |
}
|
|
|
900 |
for (NotifyOrderIdModel st : notifyOrderModel.getOrderIds()) {
|
|
|
901 |
List<NotifyOrder> existingOrder = notifyOrderRespository.selectByOrder(st.getOrderId());
|
| 24950 |
tejbeer |
902 |
if (!existingOrder.isEmpty()) {
|
| 24917 |
tejbeer |
903 |
LOGGER.info("existingOrder" + existingOrder);
|
| 24950 |
tejbeer |
904 |
for (NotifyOrder notifyOrder : existingOrder) {
|
|
|
905 |
if (NotifyStatus.pending == notifyOrder.getStatus()) {
|
|
|
906 |
notifyOrder.setStatus(NotifyStatus.rejected);
|
| 26105 |
tejbeer |
907 |
notifyOrder.setUpdateTimestamp(LocalDateTime.now());
|
| 24950 |
tejbeer |
908 |
}
|
| 24917 |
tejbeer |
909 |
}
|
|
|
910 |
}
|
|
|
911 |
NotifyOrder orderStatus = new NotifyOrder();
|
|
|
912 |
orderStatus.setOrderId(st.getOrderId());
|
|
|
913 |
orderStatus.setNotifyId(notifytimestamp.getId());
|
|
|
914 |
orderStatus.setItemId(st.getOlditemId());
|
|
|
915 |
Order id = orderRepository.selectById(st.getOrderId());
|
|
|
916 |
orderStatus.setFofoId(id.getRetailerId());
|
|
|
917 |
orderStatus.setStatus(NotifyStatus.pending);
|
|
|
918 |
notifyOrderRespository.persist(orderStatus);
|
|
|
919 |
|
|
|
920 |
LOGGER.info("itemStatus" + orderStatus);
|
|
|
921 |
orderIds.add(st.getOrderId());
|
|
|
922 |
}
|
|
|
923 |
|
|
|
924 |
LOGGER.info("orderIds" + orderIds);
|
|
|
925 |
List<Order> orders = orderRepository.selectByOrderIds(orderIds);
|
|
|
926 |
for (Order order : orders) {
|
|
|
927 |
LOGGER.info("order" + order.getId());
|
|
|
928 |
|
| 25140 |
amit.gupta |
929 |
NotifyMessage message = notifyMessageRepository.selectByNotifyId(notifytimestamp.getId());
|
|
|
930 |
|
| 25851 |
amit.gupta |
931 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
932 |
sendNotificationModel.setCampaignName("Notify Partner");
|
|
|
933 |
sendNotificationModel.setMessage(message.getNotifyMessages());
|
|
|
934 |
sendNotificationModel.setType("url");
|
|
|
935 |
sendNotificationModel.setTitle("Alert");
|
| 26959 |
tejbeer |
936 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifyOrder");
|
| 25851 |
amit.gupta |
937 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
|
|
938 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 25857 |
tejbeer |
939 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
| 25873 |
tejbeer |
940 |
|
|
|
941 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 25851 |
amit.gupta |
942 |
notificationService.sendNotification(sendNotificationModel);
|
| 25140 |
amit.gupta |
943 |
|
| 24917 |
tejbeer |
944 |
}
|
|
|
945 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
946 |
return "response";
|
|
|
947 |
}
|
|
|
948 |
|
|
|
949 |
@RequestMapping(value = "/getAllNotifyOrder", method = RequestMethod.GET)
|
|
|
950 |
public String getAllNotifyOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 24950 |
tejbeer |
951 |
List<NotifyOrder> notifyOrders = null;
|
| 24917 |
tejbeer |
952 |
List<com.spice.profitmandi.dao.entity.transaction.Order> inProcessorder = orderRepository
|
| 25067 |
tejbeer |
953 |
.selectAllOrder(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 24950 |
tejbeer |
954 |
|
| 24917 |
tejbeer |
955 |
List<Integer> orderIds = new ArrayList<>();
|
| 24950 |
tejbeer |
956 |
if (!inProcessorder.isEmpty()) {
|
| 24917 |
tejbeer |
957 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : inProcessorder) {
|
| 24950 |
tejbeer |
958 |
|
| 24917 |
tejbeer |
959 |
orderIds.add(order.getId());
|
|
|
960 |
|
| 24950 |
tejbeer |
961 |
}
|
|
|
962 |
notifyOrders = notifyOrderRespository.selectByorderIds(orderIds);
|
|
|
963 |
Set<Integer> oldItemIds = new HashSet<>();
|
|
|
964 |
List<Integer> fofoIds = new ArrayList<>();
|
|
|
965 |
List<Integer> notifyIds = new ArrayList<>();
|
|
|
966 |
if (!notifyOrders.isEmpty()) {
|
|
|
967 |
for (NotifyOrder notifyOrder : notifyOrders) {
|
|
|
968 |
oldItemIds.add(notifyOrder.getItemId());
|
|
|
969 |
fofoIds.add(notifyOrder.getFofoId());
|
|
|
970 |
notifyIds.add(notifyOrder.getNotifyId());
|
| 24917 |
tejbeer |
971 |
}
|
|
|
972 |
|
| 24950 |
tejbeer |
973 |
List<NotifyColorChange> notifyColorChanges = notifyColorChangeRepository.selectByNotifyId(notifyIds);
|
|
|
974 |
Map<Integer, NotifyColorChange> notifyIdNotifyColorMap = this
|
|
|
975 |
.notifyOrdersToNotifyId(notifyColorChanges);
|
|
|
976 |
Map<Integer, CustomRetailer> fofoIdsAndRetailerName = retailerService.getFofoRetailers(fofoIds);
|
|
|
977 |
Map<Integer, String> itemdescription = inventoryService.getItemIdDescriptionMap(oldItemIds);
|
| 24917 |
tejbeer |
978 |
|
| 24950 |
tejbeer |
979 |
model.addAttribute("notifyOrders", notifyOrders);
|
|
|
980 |
model.addAttribute("notifyIdNotifyColorMap", notifyIdNotifyColorMap);
|
|
|
981 |
model.addAttribute("itemdescription", itemdescription);
|
|
|
982 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
| 24917 |
tejbeer |
983 |
|
| 24950 |
tejbeer |
984 |
} else {
|
|
|
985 |
model.addAttribute("notifyOrders", notifyOrders);
|
|
|
986 |
}
|
| 24917 |
tejbeer |
987 |
} else {
|
|
|
988 |
model.addAttribute("notifyOrders", notifyOrders);
|
| 24950 |
tejbeer |
989 |
}
|
| 24917 |
tejbeer |
990 |
return "notify_order";
|
|
|
991 |
}
|
|
|
992 |
|
|
|
993 |
private Map<Integer, NotifyColorChange> notifyOrdersToNotifyId(List<NotifyColorChange> notifyColorChanges) {
|
|
|
994 |
Map<Integer, NotifyColorChange> notifyIdNotifyColorMap = new HashMap<>();
|
|
|
995 |
for (NotifyColorChange notifyColorChange : notifyColorChanges) {
|
|
|
996 |
notifyIdNotifyColorMap.put(notifyColorChange.getId(), notifyColorChange);
|
|
|
997 |
}
|
|
|
998 |
return notifyIdNotifyColorMap;
|
|
|
999 |
}
|
|
|
1000 |
|
| 26031 |
tejbeer |
1001 |
@RequestMapping(value = "/getItems", method = RequestMethod.GET)
|
|
|
1002 |
public String getItems(HttpServletRequest request, @RequestParam int catalogItemId, Model model) throws Exception {
|
|
|
1003 |
|
|
|
1004 |
Set<Integer> itemIds = itemRepository.selectAllByCatalogItemId(catalogItemId).stream().map(x -> x.getId())
|
|
|
1005 |
.collect(Collectors.toSet());
|
|
|
1006 |
|
|
|
1007 |
List<Order> notAvailableProcessingOrder = orderRepository.selectByItemIdsOrderStatus(itemIds,
|
|
|
1008 |
OrderStatus.SUBMITTED_FOR_PROCESSING);
|
|
|
1009 |
LOGGER.info("notAvailableProcessingOrder" + notAvailableProcessingOrder);
|
|
|
1010 |
|
|
|
1011 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
1012 |
for (com.spice.profitmandi.dao.entity.transaction.Order order : notAvailableProcessingOrder) {
|
|
|
1013 |
retailerIds.add(order.getRetailerId());
|
|
|
1014 |
|
|
|
1015 |
}
|
|
|
1016 |
|
|
|
1017 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
|
|
1018 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
|
|
1019 |
|
|
|
1020 |
model.addAttribute("notAvailableProcessingOrder", notAvailableProcessingOrder);
|
|
|
1021 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
|
|
1022 |
|
|
|
1023 |
return "partner-cancel-order-modal";
|
|
|
1024 |
}
|
|
|
1025 |
|
|
|
1026 |
@RequestMapping(value = "/notifyCancelOrder", method = RequestMethod.POST)
|
|
|
1027 |
public String NotifyCancelOrder(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel,
|
|
|
1028 |
Model model) throws Exception {
|
|
|
1029 |
for (NotifyOrderIdModel st : notifyOrderModel.getOrderIds()) {
|
|
|
1030 |
LOGGER.info("orderId" + st.getOrderId());
|
|
|
1031 |
Order order = orderRepository.selectById(st.getOrderId());
|
| 26110 |
tejbeer |
1032 |
NotifyCancel nc = notifyCancelOrderRepository.selectByOrderId(st.getOrderId());
|
|
|
1033 |
if (nc == null) {
|
|
|
1034 |
nc = new NotifyCancel();
|
|
|
1035 |
nc.setOrderId(st.getOrderId());
|
|
|
1036 |
nc.setItemId(st.getOlditemId());
|
|
|
1037 |
nc.setFofoId(order.getRetailerId());
|
|
|
1038 |
nc.setCancellation(false);
|
|
|
1039 |
nc.setCreatedTimestamp(LocalDateTime.now());
|
|
|
1040 |
nc.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
1041 |
notifyCancelOrderRepository.persist(nc);
|
|
|
1042 |
} else {
|
|
|
1043 |
nc.setOrderId(st.getOrderId());
|
|
|
1044 |
nc.setItemId(st.getOlditemId());
|
|
|
1045 |
nc.setFofoId(order.getRetailerId());
|
|
|
1046 |
nc.setCancellation(false);
|
|
|
1047 |
nc.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
1048 |
notifyCancelOrderRepository.persist(nc);
|
|
|
1049 |
}
|
| 26031 |
tejbeer |
1050 |
|
|
|
1051 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
1052 |
sendNotificationModel.setCampaignName("Notify Partner");
|
|
|
1053 |
sendNotificationModel.setMessage(notifyOrderModel.getMessage());
|
|
|
1054 |
sendNotificationModel.setType("url");
|
|
|
1055 |
sendNotificationModel.setTitle("Alert");
|
| 26482 |
tejbeer |
1056 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifyCancelOrder");
|
| 26031 |
tejbeer |
1057 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
|
|
1058 |
sendNotificationModel.setMessageType(MessageType.notification);
|
|
|
1059 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
|
|
1060 |
|
|
|
1061 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
|
|
1062 |
notificationService.sendNotification(sendNotificationModel);
|
|
|
1063 |
|
|
|
1064 |
}
|
|
|
1065 |
|
|
|
1066 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
1067 |
return "response";
|
|
|
1068 |
}
|
| 26039 |
tejbeer |
1069 |
|
|
|
1070 |
@RequestMapping(value = "/getNotifiedCancelOrder", method = RequestMethod.GET)
|
|
|
1071 |
public String getNotifiedCancelOrder(HttpServletRequest request, Model model) throws Exception {
|
|
|
1072 |
|
|
|
1073 |
List<NotifyCancel> notifyCancels = notifyCancelOrderRepository.selectAllNonCancelOrder();
|
|
|
1074 |
if (!notifyCancels.isEmpty()) {
|
|
|
1075 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
1076 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
1077 |
for (NotifyCancel nc : notifyCancels) {
|
|
|
1078 |
retailerIds.add(nc.getFofoId());
|
|
|
1079 |
itemIds.add(nc.getItemId());
|
|
|
1080 |
}
|
|
|
1081 |
|
|
|
1082 |
Map<Integer, CustomRetailer> fofoIdsAndRetailerName = retailerService.getFofoRetailers(retailerIds);
|
|
|
1083 |
|
|
|
1084 |
Map<Integer, String> itemdescription = inventoryService.getItemIdDescriptionMap(itemIds);
|
|
|
1085 |
model.addAttribute("notifyCancels", notifyCancels);
|
|
|
1086 |
model.addAttribute("itemdescription", itemdescription);
|
|
|
1087 |
model.addAttribute("fofoIdsAndRetailerName", fofoIdsAndRetailerName);
|
|
|
1088 |
} else {
|
|
|
1089 |
|
|
|
1090 |
model.addAttribute("notifyCancels", notifyCancels);
|
|
|
1091 |
|
|
|
1092 |
}
|
|
|
1093 |
return "notify_cancel";
|
|
|
1094 |
}
|
|
|
1095 |
|
|
|
1096 |
@RequestMapping(value = "/getNotifyItems", method = RequestMethod.GET)
|
|
|
1097 |
public String getNotifyItems(HttpServletRequest request, @RequestParam int itemId, Model model) throws Exception {
|
|
|
1098 |
Item item = itemRepository.selectById(itemId);
|
|
|
1099 |
|
|
|
1100 |
List<Integer> itemIds = itemRepository.selectAllByCatalogItemId(item.getCatalogItemId()).stream()
|
|
|
1101 |
.map(x -> x.getId()).collect(Collectors.toList());
|
|
|
1102 |
|
|
|
1103 |
List<NotifyCancel> ncs = notifyCancelOrderRepository.selectByItemIdsAndStatus(itemIds);
|
|
|
1104 |
List<Integer> retailerIds = new ArrayList<>();
|
|
|
1105 |
Map<Integer, Object> orders = new HashMap<>();
|
|
|
1106 |
for (NotifyCancel nc : ncs) {
|
|
|
1107 |
retailerIds.add(nc.getFofoId());
|
|
|
1108 |
Order od = orderRepository.selectById(nc.getOrderId());
|
|
|
1109 |
orders.put(nc.getOrderId(), od);
|
|
|
1110 |
}
|
|
|
1111 |
|
|
|
1112 |
Map<Integer, String> storeIdAndFofoIdMap = fofoStoreRepository.selectByRetailerIds(retailerIds).stream()
|
|
|
1113 |
.collect(Collectors.toMap(FofoStore::getId, FofoStore::getCode));
|
|
|
1114 |
|
|
|
1115 |
model.addAttribute("notifyItems", ncs);
|
|
|
1116 |
model.addAttribute("orders", orders);
|
|
|
1117 |
model.addAttribute("storeIdAndFofoIdMap", storeIdAndFofoIdMap);
|
|
|
1118 |
|
|
|
1119 |
return "notify_cancel_order_modal";
|
|
|
1120 |
}
|
|
|
1121 |
|
|
|
1122 |
@RequestMapping(value = "/changeNotifyCancelRequest", method = RequestMethod.POST)
|
|
|
1123 |
public String changeNotifyCancelRequest(HttpServletRequest request, @RequestBody NotifyOrderModel notifyOrderModel,
|
|
|
1124 |
Model model) throws Exception {
|
|
|
1125 |
List<Integer> orderIds = notifyOrderModel.getOrderIds().stream().map(x -> x.getOrderId())
|
|
|
1126 |
.collect(Collectors.toList());
|
|
|
1127 |
|
|
|
1128 |
List<NotifyCancel> ncs = notifyCancelOrderRepository.selectByOrderIds(orderIds);
|
|
|
1129 |
for (NotifyCancel nc : ncs) {
|
|
|
1130 |
nc.setCancellation(true);
|
|
|
1131 |
}
|
|
|
1132 |
|
|
|
1133 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
1134 |
return "response";
|
|
|
1135 |
}
|
| 26482 |
tejbeer |
1136 |
|
|
|
1137 |
@RequestMapping(value = "/getProducts", method = RequestMethod.GET)
|
|
|
1138 |
public String getProducts(HttpServletRequest request, Model model)
|
|
|
1139 |
throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
|
|
1140 |
|
|
|
1141 |
return "product-detail";
|
|
|
1142 |
}
|
|
|
1143 |
|
|
|
1144 |
@RequestMapping(value = "/getProductInfo", method = RequestMethod.GET)
|
|
|
1145 |
public String getProductInfo(HttpServletRequest request, long catalogId, Model model) throws Exception {
|
|
|
1146 |
ContentPojo cp = mongoClient.getEntityById(catalogId);
|
| 26493 |
tejbeer |
1147 |
model.addAttribute("cp", cp);
|
|
|
1148 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 26482 |
tejbeer |
1149 |
return "product-info";
|
|
|
1150 |
}
|
| 26493 |
tejbeer |
1151 |
|
|
|
1152 |
@RequestMapping(value = "/getProductCompareInfo", method = RequestMethod.GET)
|
| 26512 |
amit.gupta |
1153 |
public String getProductCompareInfo(HttpServletRequest request, @RequestParam List<Long> catalogIds, Model model)
|
| 26493 |
tejbeer |
1154 |
throws Exception {
|
|
|
1155 |
List<ContentPojo> cps = new ArrayList<>();
|
| 26512 |
amit.gupta |
1156 |
for (Long cId : catalogIds) {
|
|
|
1157 |
ContentPojo cp = mongoClient.getEntityById(cId);
|
| 26959 |
tejbeer |
1158 |
if (cp.getName() == null) {
|
| 26512 |
amit.gupta |
1159 |
cp.setName(itemRepository.selectAllByCatalogItemId(cId.intValue()).get(0).getItemDescriptionNoColor());
|
|
|
1160 |
}
|
| 26493 |
tejbeer |
1161 |
cps.add(cp);
|
|
|
1162 |
}
|
| 26959 |
tejbeer |
1163 |
|
| 26498 |
amit.gupta |
1164 |
List<Map<String, String>> entityList = new ArrayList<>();
|
| 26959 |
tejbeer |
1165 |
for (ContentPojo cp : cps) {
|
| 26498 |
amit.gupta |
1166 |
Map<String, String> specsMap = new HashMap<>();
|
| 26959 |
tejbeer |
1167 |
for (SpecificationGroup sg : cp.getDetailedSpecs()) {
|
| 26498 |
amit.gupta |
1168 |
String title = sg.getTitle();
|
| 26959 |
tejbeer |
1169 |
for (Specification s : sg.getSpecs()) {
|
| 26498 |
amit.gupta |
1170 |
String key = title + s.getName();
|
|
|
1171 |
specsMap.put(key, String.join(", ", s.getValues()));
|
|
|
1172 |
}
|
|
|
1173 |
}
|
|
|
1174 |
entityList.add(specsMap);
|
|
|
1175 |
}
|
| 26959 |
tejbeer |
1176 |
|
| 26493 |
tejbeer |
1177 |
LOGGER.info("cps" + cps);
|
| 26959 |
tejbeer |
1178 |
model.addAttribute("cps", cps);
|
|
|
1179 |
model.addAttribute("catalogIds", gson.toJson(catalogIds, List.class));
|
|
|
1180 |
model.addAttribute("entityList", entityList);
|
| 26493 |
tejbeer |
1181 |
return "product-compare";
|
|
|
1182 |
}
|
| 24917 |
tejbeer |
1183 |
}
|