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