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