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