| 21612 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 26817 |
amit.gupta |
3 |
import com.google.gson.Gson;
|
| 23203 |
ashik.ali |
4 |
import com.spice.profitmandi.common.enumuration.SearchType;
|
| 21612 |
ashik.ali |
5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 30322 |
amit.gupta |
6 |
import com.spice.profitmandi.common.model.*;
|
| 28339 |
tejbeer |
7 |
import com.spice.profitmandi.common.solr.SolrService;
|
| 30162 |
manish |
8 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 31459 |
amit.gupta |
9 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 21689 |
ashik.ali |
10 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 23638 |
amit.gupta |
11 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 22244 |
ashik.ali |
12 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 23638 |
amit.gupta |
13 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 27861 |
tejbeer |
14 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 22217 |
ashik.ali |
15 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| 23343 |
ashik.ali |
16 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
| 23548 |
ashik.ali |
17 |
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
|
| 30322 |
amit.gupta |
18 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 23298 |
ashik.ali |
19 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 23548 |
ashik.ali |
20 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
| 27046 |
tejbeer |
21 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 30322 |
amit.gupta |
22 |
import com.spice.profitmandi.dao.model.*;
|
| 23638 |
amit.gupta |
23 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 27861 |
tejbeer |
24 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 30322 |
amit.gupta |
25 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
|
|
26 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 24440 |
amit.gupta |
27 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 30162 |
manish |
28 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 23298 |
ashik.ali |
29 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 28377 |
tejbeer |
30 |
import com.spice.profitmandi.service.EmailService;
|
| 32251 |
amit.gupta |
31 |
import com.spice.profitmandi.service.NotificationService;
|
| 23798 |
amit.gupta |
32 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 25726 |
amit.gupta |
33 |
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
|
| 24440 |
amit.gupta |
34 |
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
|
| 23366 |
ashik.ali |
35 |
import com.spice.profitmandi.service.order.OrderService;
|
| 22069 |
ashik.ali |
36 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 26647 |
tejbeer |
37 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 32405 |
jai.hind |
38 |
import com.spice.profitmandi.service.whatsapp.WhatsappMessageService;
|
| 22139 |
amit.gupta |
39 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 22069 |
ashik.ali |
40 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24105 |
govind |
41 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 30148 |
amit.gupta |
42 |
import org.apache.logging.log4j.LogManager;
|
|
|
43 |
import org.apache.logging.log4j.Logger;
|
| 32405 |
jai.hind |
44 |
import org.json.JSONArray;
|
| 30148 |
amit.gupta |
45 |
import org.json.JSONObject;
|
|
|
46 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
47 |
import org.springframework.core.io.InputStreamResource;
|
|
|
48 |
import org.springframework.http.HttpHeaders;
|
|
|
49 |
import org.springframework.http.HttpStatus;
|
|
|
50 |
import org.springframework.http.MediaType;
|
|
|
51 |
import org.springframework.http.ResponseEntity;
|
|
|
52 |
import org.springframework.stereotype.Controller;
|
|
|
53 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
54 |
import org.springframework.ui.Model;
|
|
|
55 |
import org.springframework.web.bind.annotation.*;
|
| 21612 |
ashik.ali |
56 |
|
| 30148 |
amit.gupta |
57 |
import javax.servlet.http.HttpServletRequest;
|
|
|
58 |
import javax.servlet.http.HttpServletResponse;
|
| 32409 |
amit.gupta |
59 |
import java.io.ByteArrayInputStream;
|
|
|
60 |
import java.io.ByteArrayOutputStream;
|
|
|
61 |
import java.io.InputStream;
|
| 32271 |
amit.gupta |
62 |
import java.nio.charset.StandardCharsets;
|
| 30148 |
amit.gupta |
63 |
import java.time.LocalDate;
|
|
|
64 |
import java.time.LocalDateTime;
|
| 31416 |
tejbeer |
65 |
import java.time.LocalTime;
|
| 30148 |
amit.gupta |
66 |
import java.time.format.DateTimeFormatter;
|
|
|
67 |
import java.time.temporal.ChronoUnit;
|
|
|
68 |
import java.util.*;
|
|
|
69 |
import java.util.stream.Collectors;
|
|
|
70 |
|
| 21612 |
ashik.ali |
71 |
@Controller
|
| 23973 |
govind |
72 |
@Transactional(rollbackFor = Throwable.class)
|
| 21612 |
ashik.ali |
73 |
public class OrderController {
|
|
|
74 |
|
| 32251 |
amit.gupta |
75 |
private static final Logger LOGGER = LogManager.getLogger(OrderController.class);
|
| 21985 |
kshitij.so |
76 |
|
| 32251 |
amit.gupta |
77 |
private static final List<String> offlineOrders = Arrays.asList("EMIOD", "POD");
|
|
|
78 |
private static final List<String> allowedDoaImeis = Arrays.asList("863903054378477");
|
|
|
79 |
@Autowired
|
|
|
80 |
NotificationService notificationService;
|
|
|
81 |
@Autowired
|
|
|
82 |
private CustomerRepository customerRepository;
|
|
|
83 |
private boolean accessoriesDeals = true;
|
|
|
84 |
@Autowired
|
|
|
85 |
private RoleManager roleManager;
|
|
|
86 |
@Autowired
|
|
|
87 |
private Gson gson;
|
|
|
88 |
@Autowired
|
|
|
89 |
private CustomerReturnItemRepository customerReturnItemRepository;
|
|
|
90 |
@Autowired
|
|
|
91 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
|
|
92 |
@Autowired
|
|
|
93 |
private PaymentOptionRepository paymentOptionRepository;
|
|
|
94 |
@Autowired
|
|
|
95 |
private StateRepository stateRepository;
|
|
|
96 |
@Autowired
|
|
|
97 |
private ItemRepository itemRepository;
|
|
|
98 |
@Autowired
|
|
|
99 |
private MVCResponseSender mvcResponseSender;
|
|
|
100 |
@Autowired
|
|
|
101 |
private InsuranceService insuranceService;
|
|
|
102 |
@Autowired
|
|
|
103 |
private FofoOrderRepository fofoOrderRepository;
|
|
|
104 |
@Autowired
|
|
|
105 |
private CustomerAddressRepository customerAddressRepository;
|
|
|
106 |
@Autowired
|
|
|
107 |
private InsurancePolicyRepository insurancePolicyRepository;
|
|
|
108 |
@Autowired
|
|
|
109 |
private InsuranceProviderRepository insuranceProviderRepository;
|
|
|
110 |
@Autowired
|
|
|
111 |
private CookiesProcessor cookiesProcessor;
|
|
|
112 |
@Autowired
|
|
|
113 |
private PricingService pricingService;
|
|
|
114 |
@Autowired
|
|
|
115 |
private OrderService orderService;
|
|
|
116 |
@Autowired
|
|
|
117 |
private RetailerRegisteredAddressRepository retailerRegisteredAddressRepository;
|
|
|
118 |
@Autowired
|
|
|
119 |
private AddressRepository addressRepository;
|
|
|
120 |
@Autowired
|
|
|
121 |
private PaymentOptionTransactionRepository paymentOptionTransactionRepository;
|
|
|
122 |
@Autowired
|
|
|
123 |
private FofoPartnerPaymentOptionRepository fofoPartnerPaymentOptionRepository;
|
|
|
124 |
@Autowired
|
|
|
125 |
private ResponseSender<?> responseSender;
|
|
|
126 |
@Autowired
|
|
|
127 |
private PendingOrderRepository pendingOrderRepository;
|
|
|
128 |
@Autowired
|
|
|
129 |
private OrderRepository orderRepository;
|
|
|
130 |
@Autowired
|
|
|
131 |
private PendingOrderItemRepository pendingOrderItemRepository;
|
|
|
132 |
@Autowired
|
|
|
133 |
private FofoStoreRepository fofoStoreRepository;
|
|
|
134 |
@Autowired
|
|
|
135 |
private RetailerService retailerService;
|
|
|
136 |
@Autowired
|
|
|
137 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
138 |
@Autowired
|
|
|
139 |
private TagListingRepository tagListingRepository;
|
|
|
140 |
@Autowired
|
|
|
141 |
private PendingOrderService pendingOrderService;
|
|
|
142 |
@Autowired
|
|
|
143 |
private EmailService emailService;
|
|
|
144 |
@Autowired
|
|
|
145 |
private SolrService commonSolrService;
|
|
|
146 |
@Autowired
|
|
|
147 |
private MouRepository mouRepository;
|
| 28339 |
tejbeer |
148 |
|
| 32405 |
jai.hind |
149 |
@Autowired
|
|
|
150 |
private WhatsappMessageService whatsappMessageService;
|
|
|
151 |
|
| 32251 |
amit.gupta |
152 |
@RequestMapping(value = "/order")
|
|
|
153 |
public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
|
|
|
154 |
throws ProfitMandiBusinessException {
|
|
|
155 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23973 |
govind |
156 |
|
| 32251 |
amit.gupta |
157 |
int addressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(loginDetails.getFofoId());
|
|
|
158 |
Address address = addressRepository.selectById(addressId);
|
| 21985 |
kshitij.so |
159 |
|
| 32251 |
amit.gupta |
160 |
List<CartFofo> cartItems = orderService.cartCheckout(cartData);
|
|
|
161 |
Set<Integer> itemIds = new HashSet<>();
|
|
|
162 |
List<Integer> poIds = new ArrayList<>();
|
|
|
163 |
List<Integer> poItemIds = new ArrayList<>();
|
|
|
164 |
for (CartFofo cartFofo : cartItems) {
|
|
|
165 |
itemIds.add(cartFofo.getItemId());
|
|
|
166 |
if (cartFofo.getPoId() != 0) {
|
|
|
167 |
poIds.add(cartFofo.getPoId());
|
|
|
168 |
poItemIds.add(cartFofo.getPoItemId());
|
|
|
169 |
}
|
|
|
170 |
}
|
| 23973 |
govind |
171 |
|
| 32251 |
amit.gupta |
172 |
PendingOrder po = null;
|
|
|
173 |
Customer customer = null;
|
|
|
174 |
PendingOrderItem poi = null;
|
|
|
175 |
Map<Integer, PriceModel> mopPriceMap = pricingService.getPurchasePriceMopPriceNotFound(itemIds,
|
|
|
176 |
loginDetails.getFofoId());
|
|
|
177 |
List<Integer> paymentOptionIds = fofoPartnerPaymentOptionRepository
|
|
|
178 |
.selectPaymentOptionIdsByFofoId(loginDetails.getFofoId());
|
| 27046 |
tejbeer |
179 |
|
| 32251 |
amit.gupta |
180 |
if (!poIds.isEmpty()) {
|
|
|
181 |
po = pendingOrderRepository.selectById(poIds.get(0));
|
|
|
182 |
customer = customerRepository.selectById(po.getCustomerId());
|
|
|
183 |
if (!offlineOrders.contains(po.getPayMethod())) {
|
|
|
184 |
paymentOptionIds.add(23);
|
|
|
185 |
}
|
|
|
186 |
}
|
| 23973 |
govind |
187 |
|
| 32251 |
amit.gupta |
188 |
if (!poItemIds.isEmpty()) {
|
|
|
189 |
poi = pendingOrderItemRepository.selectById(poItemIds.get(0));
|
|
|
190 |
}
|
| 21985 |
kshitij.so |
191 |
|
| 32251 |
amit.gupta |
192 |
// List<PaymentOption> paymentOptions = paymentOptionRepository.selectByIds(new
|
|
|
193 |
// HashSet<>(paymentOptionIds));
|
| 29642 |
amit.gupta |
194 |
|
| 32251 |
amit.gupta |
195 |
List<PaymentOption> paymentOptions = paymentOptionRepository.selectActiveOption();
|
| 24844 |
amit.gupta |
196 |
|
| 32251 |
amit.gupta |
197 |
LOGGER.info("pendingOrder" + po);
|
|
|
198 |
LOGGER.info("pendingOrderItem" + poi);
|
| 23973 |
govind |
199 |
|
| 32251 |
amit.gupta |
200 |
LOGGER.info("mopPriceMap {}", mopPriceMap);
|
|
|
201 |
model.addAttribute("stateNames",
|
|
|
202 |
stateRepository.selectAll().stream().map(x -> x.getName()).collect(Collectors.toList()));
|
|
|
203 |
model.addAttribute("retailerStateName", address.getState());
|
|
|
204 |
model.addAttribute("pendingPOCustomer", gson.toJson(customer));
|
|
|
205 |
model.addAttribute("pendingPO", gson.toJson(po));
|
| 21985 |
kshitij.so |
206 |
|
| 32251 |
amit.gupta |
207 |
model.addAttribute("cartItems", cartItems);
|
|
|
208 |
model.addAttribute("pendingOrder", po);
|
|
|
209 |
model.addAttribute("pendingOrderItem", poi);
|
| 24844 |
amit.gupta |
210 |
|
| 32251 |
amit.gupta |
211 |
model.addAttribute("mopPriceMap", mopPriceMap);
|
|
|
212 |
model.addAttribute("paymentOptions", paymentOptions);
|
|
|
213 |
model.addAttribute("accessoriesDeals", accessoriesDeals);
|
|
|
214 |
return "order-index";
|
|
|
215 |
}
|
| 24105 |
govind |
216 |
|
| 32251 |
amit.gupta |
217 |
@RequestMapping(value = "/checkplans", method = RequestMethod.GET)
|
|
|
218 |
public String getInsurancePrices(HttpServletRequest request, @RequestParam float price, Model model,
|
|
|
219 |
@RequestParam int itemId) throws ProfitMandiBusinessException {
|
|
|
220 |
LOGGER.info("Request received at url : {}", request.getRequestURI());
|
| 21985 |
kshitij.so |
221 |
|
| 32251 |
amit.gupta |
222 |
try {
|
|
|
223 |
String response = mvcResponseSender.createResponseString(this.getPlans(price, itemId));
|
|
|
224 |
model.addAttribute("response1", response);
|
|
|
225 |
} catch (Exception e) {
|
|
|
226 |
// TODO Auto-generated catch block
|
|
|
227 |
LOGGER.info(e.getMessage(), e);
|
|
|
228 |
throw new ProfitMandiBusinessException("Plans", "Plans API", "Error formatting insurance plans");
|
|
|
229 |
}
|
| 23973 |
govind |
230 |
|
| 32251 |
amit.gupta |
231 |
return "response";
|
|
|
232 |
}
|
| 23973 |
govind |
233 |
|
| 32251 |
amit.gupta |
234 |
@RequestMapping(value = "/get-order", method = RequestMethod.GET)
|
|
|
235 |
public String getOrder(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId,
|
|
|
236 |
Model model) throws ProfitMandiBusinessException {
|
|
|
237 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
238 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
|
|
239 |
List<FofoOrderItem> fofoLineItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 32627 |
ranu |
240 |
CustomerAddress customerAddress = null;
|
|
|
241 |
if (fofoOrder.getCustomerAddressId() != 0) {
|
|
|
242 |
customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
|
|
243 |
}
|
|
|
244 |
|
| 32251 |
amit.gupta |
245 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
| 32627 |
ranu |
246 |
if (customerAddress != null) {
|
|
|
247 |
customerAddress.setPhoneNumber(customer.getMobileNumber());
|
|
|
248 |
}
|
|
|
249 |
LOGGER.info("Added to get invoice - {}, {}", customer, 123);
|
| 32251 |
amit.gupta |
250 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository
|
|
|
251 |
.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
|
|
252 |
Map<Integer, PaymentOption> paymentOptionIdPaymentOptionMap = this
|
|
|
253 |
.paymentOptionIdPaymentOptionMap(paymentOptionTransactions);
|
|
|
254 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository
|
|
|
255 |
.selectByRetailerIdInvoiceNumber(fofoOrder.getInvoiceNumber());
|
|
|
256 |
this.addInsuranceProvider(insurancePolicies);
|
| 21985 |
kshitij.so |
257 |
|
| 32251 |
amit.gupta |
258 |
model.addAttribute("fofoOrder", fofoOrder);
|
|
|
259 |
model.addAttribute("fofoLineItems", fofoLineItems);
|
| 32627 |
ranu |
260 |
if (customerAddress != null) {
|
|
|
261 |
model.addAttribute("customerBillingAddress", orderService.getBillingAddress(customerAddress));
|
| 32637 |
amit.gupta |
262 |
} else {
|
|
|
263 |
model.addAttribute("customerBillingAddress", "");
|
|
|
264 |
|
| 32627 |
ranu |
265 |
}
|
| 32251 |
amit.gupta |
266 |
model.addAttribute("customerBillingAddressObj", customerAddress);
|
| 32627 |
ranu |
267 |
model.addAttribute("customerDetailsObj", customer);
|
| 32251 |
amit.gupta |
268 |
model.addAttribute("paymentOptionTransactions", paymentOptionTransactions);
|
|
|
269 |
model.addAttribute("paymentOptionIdPaymentOptionMap", paymentOptionIdPaymentOptionMap);
|
|
|
270 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
|
|
271 |
return "order-details";
|
|
|
272 |
}
|
| 23973 |
govind |
273 |
|
| 32251 |
amit.gupta |
274 |
private Map<Integer, InsuranceProvider> toInsuranceProviderIdInsuranceProvider(
|
|
|
275 |
List<InsuranceProvider> insuranceProviders) {
|
|
|
276 |
Map<Integer, InsuranceProvider> insuranceProviderIdInsuranceProviderMap = new HashMap<>();
|
|
|
277 |
for (InsuranceProvider insuranceProvider : insuranceProviders) {
|
|
|
278 |
insuranceProviderIdInsuranceProviderMap.put(insuranceProvider.getId(), insuranceProvider);
|
|
|
279 |
}
|
|
|
280 |
return insuranceProviderIdInsuranceProviderMap;
|
|
|
281 |
}
|
| 23973 |
govind |
282 |
|
| 32251 |
amit.gupta |
283 |
private void addInsuranceProvider(List<InsurancePolicy> insurancePolicies) {
|
|
|
284 |
if (insurancePolicies.isEmpty()) {
|
|
|
285 |
return;
|
|
|
286 |
}
|
|
|
287 |
Set<Integer> insuranceProviderIds = new HashSet<>();
|
|
|
288 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
|
|
289 |
insuranceProviderIds.add(insurancePolicy.getProviderId());
|
|
|
290 |
}
|
|
|
291 |
LOGGER.info("insuranceProviderIds {}", insuranceProviderIds);
|
|
|
292 |
List<InsuranceProvider> insuranceProviders = insuranceProviderRepository.selectByIds(insuranceProviderIds);
|
|
|
293 |
Map<Integer, InsuranceProvider> insuranceProviderIdInsuranceProviderMap = this
|
|
|
294 |
.toInsuranceProviderIdInsuranceProvider(insuranceProviders);
|
|
|
295 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
|
|
296 |
insurancePolicy
|
|
|
297 |
.setInsuranceProvider(insuranceProviderIdInsuranceProviderMap.get(insurancePolicy.getProviderId()));
|
|
|
298 |
}
|
|
|
299 |
}
|
| 23973 |
govind |
300 |
|
| 32251 |
amit.gupta |
301 |
@RequestMapping(value = "/saleDetails", method = RequestMethod.GET)
|
|
|
302 |
public String getSaleDetails(HttpServletRequest request,
|
|
|
303 |
@RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId, Model model) throws Exception {
|
|
|
304 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
305 |
boolean isAdmin = roleManager.isAdmin(fofoDetails.getRoleIds());
|
|
|
306 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
|
|
307 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
|
|
308 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
|
|
309 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository
|
|
|
310 |
.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
| 23973 |
govind |
311 |
|
| 32251 |
amit.gupta |
312 |
// Added Migration info as we lost it.
|
|
|
313 |
if (paymentOptionTransactions == null || paymentOptionTransactions.size() == 0) {
|
|
|
314 |
PaymentOptionTransaction pot = new PaymentOptionTransaction();
|
|
|
315 |
pot.setAmount(fofoOrder.getTotalAmount());
|
|
|
316 |
pot.setCreateTimestamp(fofoOrder.getCreateTimestamp());
|
|
|
317 |
// Mark it paid through cash
|
|
|
318 |
pot.setPaymentOptionId(1);
|
|
|
319 |
pot.setReferenceType(PaymentOptionReferenceType.ORDER);
|
|
|
320 |
paymentOptionTransactionRepository.persist(pot);
|
|
|
321 |
paymentOptionTransactions.add(pot);
|
|
|
322 |
LOGGER.info("Added to get invoice");
|
|
|
323 |
}
|
|
|
324 |
Map<Integer, PaymentOption> paymentOptionIdPaymentOptionMap = this
|
|
|
325 |
.paymentOptionIdPaymentOptionMap(paymentOptionTransactions);
|
|
|
326 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository
|
|
|
327 |
.selectByRetailerIdInvoiceNumber(fofoOrder.getInvoiceNumber());
|
|
|
328 |
this.addInsuranceProvider(insurancePolicies);
|
|
|
329 |
Map<Integer, Item> itemsMap = fofoOrderItems.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> {
|
|
|
330 |
try {
|
|
|
331 |
return itemRepository.selectById(x.getItemId());
|
|
|
332 |
} catch (ProfitMandiBusinessException e) {
|
|
|
333 |
// TODO Auto-generated catch block
|
|
|
334 |
return null;
|
|
|
335 |
}
|
|
|
336 |
}));
|
|
|
337 |
Map<Integer, Set<FofoLineItem>> fofoOrderItemIdLineItemMap = fofoOrderItems.stream()
|
|
|
338 |
.collect(Collectors.toMap(FofoOrderItem::getId, FofoOrderItem::getFofoLineItems));
|
| 23973 |
govind |
339 |
|
| 32251 |
amit.gupta |
340 |
Map<Integer, List<CustomerReturnItem>> foiIdCustomerReturnInventoryItemsMap = fofoOrderItems.stream()
|
|
|
341 |
.collect(Collectors.toMap(foi -> foi.getId(),
|
|
|
342 |
foi -> customerReturnItemRepository.selectAllByOrderItemId(foi.getId())));
|
| 23973 |
govind |
343 |
|
| 32251 |
amit.gupta |
344 |
Map<Integer, Integer> inventoryItemBilledQtyMap = new HashMap<>();
|
| 23973 |
govind |
345 |
|
| 32251 |
amit.gupta |
346 |
for (FofoOrderItem foi : fofoOrderItems) {
|
|
|
347 |
for (FofoLineItem fli : foi.getFofoLineItems()) {
|
|
|
348 |
inventoryItemBilledQtyMap.put(fli.getInventoryItemId(), fli.getQuantity());
|
|
|
349 |
}
|
|
|
350 |
List<CustomerReturnItem> customerReturnItems = customerReturnItemRepository
|
|
|
351 |
.selectAllByOrderItemId(foi.getId());
|
|
|
352 |
this.markDoa(fofoOrder, foi, isAdmin);
|
|
|
353 |
for (CustomerReturnItem customerReturnItem : customerReturnItems) {
|
|
|
354 |
inventoryItemBilledQtyMap.put(customerReturnItem.getInventoryItemId(),
|
|
|
355 |
inventoryItemBilledQtyMap.get(customerReturnItem.getInventoryItemId()) - 1);
|
|
|
356 |
}
|
|
|
357 |
}
|
| 23973 |
govind |
358 |
|
| 32251 |
amit.gupta |
359 |
LOGGER.info("fofoOrderItemIdLineItemMap {}", fofoOrderItemIdLineItemMap);
|
|
|
360 |
model.addAttribute("fofoOrder", fofoOrder);
|
|
|
361 |
model.addAttribute("itemsMap", itemsMap);
|
|
|
362 |
model.addAttribute("fofoOrderItemIdLineItemsMap", StringUtils.toString(fofoOrderItemIdLineItemMap));
|
|
|
363 |
model.addAttribute("foiIdCustomerReturnInventoryItemsMap",
|
|
|
364 |
StringUtils.toString(foiIdCustomerReturnInventoryItemsMap));
|
|
|
365 |
model.addAttribute("fofoOrderItemIdLineItemMap", fofoOrderItemIdLineItemMap);
|
| 30426 |
tejbeer |
366 |
|
| 32251 |
amit.gupta |
367 |
model.addAttribute("fofoOrderItems", fofoOrderItems);
|
|
|
368 |
model.addAttribute("inventoryItemBilledQtyMap", StringUtils.toString(inventoryItemBilledQtyMap));
|
| 32637 |
amit.gupta |
369 |
if (customerAddress != null) {
|
|
|
370 |
|
|
|
371 |
model.addAttribute("customerBillingAddress", orderService.getBillingAddress(customerAddress));
|
|
|
372 |
} else {
|
|
|
373 |
model.addAttribute("customerBillingAddress", "");
|
|
|
374 |
|
|
|
375 |
}
|
| 32251 |
amit.gupta |
376 |
model.addAttribute("customerBillingAddressObj", customerAddress);
|
|
|
377 |
model.addAttribute("paymentOptionTransactions", paymentOptionTransactions);
|
|
|
378 |
model.addAttribute("paymentOptionIdPaymentOptionMap", paymentOptionIdPaymentOptionMap);
|
|
|
379 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
|
|
380 |
model.addAttribute("markDefective", this.markDefective(fofoOrder));
|
|
|
381 |
return "sale-details";
|
|
|
382 |
}
|
| 30426 |
tejbeer |
383 |
|
| 32251 |
amit.gupta |
384 |
private void markDoa(FofoOrder fofoOrder, FofoOrderItem foi, boolean isAdmin) {
|
|
|
385 |
if (isAdmin) {
|
|
|
386 |
foi.setDoa(true);
|
|
|
387 |
return;
|
|
|
388 |
}
|
|
|
389 |
boolean isImei = foi.getFofoLineItems().stream()
|
|
|
390 |
.anyMatch(x -> org.apache.commons.lang3.StringUtils.isNotEmpty(x.getSerialNumber())
|
|
|
391 |
&& allowedDoaImeis.contains(x.getSerialNumber()));
|
|
|
392 |
LocalDateTime buyDate = fofoOrder.getCreateTimestamp().truncatedTo(ChronoUnit.DAYS);
|
|
|
393 |
LocalDateTime curDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
|
|
|
394 |
if (buyDate.isAfter(curDate.minusDays(45)) || isImei) {
|
|
|
395 |
foi.setDoa(true);
|
|
|
396 |
} else
|
|
|
397 |
foi.setDoa(
|
|
|
398 |
foi.getBrand().equals("Nokia") && foi.getCost() < 4990 && buyDate.isAfter(curDate.minusYears(1)));
|
|
|
399 |
}
|
| 26647 |
tejbeer |
400 |
|
| 32251 |
amit.gupta |
401 |
private boolean markDefective(FofoOrder fofoOrder) {
|
|
|
402 |
return fofoOrder.getCreateTimestamp().truncatedTo(ChronoUnit.DAYS).plusDays(180)
|
|
|
403 |
.isAfter(LocalDateTime.now().truncatedTo(ChronoUnit.DAYS));
|
| 26647 |
tejbeer |
404 |
|
| 32251 |
amit.gupta |
405 |
}
|
| 26647 |
tejbeer |
406 |
|
| 32251 |
amit.gupta |
407 |
@RequestMapping(value = "/getSearchOrder")
|
|
|
408 |
public String getSearchOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
409 |
return "search-order";
|
|
|
410 |
}
|
| 26647 |
tejbeer |
411 |
|
| 32251 |
amit.gupta |
412 |
@RequestMapping(value = "/getInvoiceSearchOrder")
|
|
|
413 |
public String getInvoiceSearchOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
414 |
return "invoices-cancel";
|
|
|
415 |
}
|
| 27861 |
tejbeer |
416 |
|
| 32251 |
amit.gupta |
417 |
@RequestMapping(value = "/customerDetails", method = RequestMethod.PUT)
|
|
|
418 |
public String updateCustomerDetails(HttpServletRequest request, @RequestBody CustomCustomer customCustomer,
|
|
|
419 |
@RequestParam(name = ProfitMandiConstants.INVOICE_NUMBER) String invoiceNumber, Model model)
|
|
|
420 |
throws Exception {
|
| 28339 |
tejbeer |
421 |
|
| 32251 |
amit.gupta |
422 |
orderService.updateCustomerDetails(customCustomer, invoiceNumber);
|
|
|
423 |
return this.getSearchOrderDetails(request, invoiceNumber, model);
|
|
|
424 |
}
|
| 28339 |
tejbeer |
425 |
|
| 32251 |
amit.gupta |
426 |
@RequestMapping(value = "/searchOrderDetails", method = RequestMethod.GET)
|
|
|
427 |
public String getSearchOrderDetails(HttpServletRequest request,
|
|
|
428 |
@RequestParam(name = ProfitMandiConstants.INVOICE_NUMBER) String invoiceNumber, Model model)
|
|
|
429 |
throws Exception {
|
| 28339 |
tejbeer |
430 |
|
| 32251 |
amit.gupta |
431 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
|
|
|
432 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
|
|
433 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
|
|
434 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
|
|
435 |
Map<Integer, PaymentOption> paymentOptionIdPaymentOptionMap = paymentOptionRepository.selectActiveOption().stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
|
|
436 |
List<Integer> fofoPartnerPaymentOptions = new ArrayList<>(paymentOptionIdPaymentOptionMap.keySet());
|
|
|
437 |
Map<Integer, Item> itemsMap = fofoOrderItems.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> {
|
|
|
438 |
try {
|
|
|
439 |
return itemRepository.selectById(x.getItemId());
|
|
|
440 |
} catch (ProfitMandiBusinessException e) {
|
|
|
441 |
// TODO Auto-generated catch block
|
|
|
442 |
return null;
|
|
|
443 |
}
|
|
|
444 |
}));
|
|
|
445 |
LOGGER.info("fofoPartnerPaymentOptions" + fofoPartnerPaymentOptions);
|
|
|
446 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository
|
|
|
447 |
.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
|
|
448 |
LOGGER.info("paymentOptionTransactions" + paymentOptionTransactions);
|
| 28420 |
tejbeer |
449 |
|
| 32251 |
amit.gupta |
450 |
Map<Integer, PaymentOptionTransaction> paymentOptionIdPaymentOptionTransactionMap = this
|
|
|
451 |
.paymentOptionIdPaymentOptionTransactionMap(paymentOptionTransactions);
|
|
|
452 |
LOGGER.info("paymentOptionIdPaymentOptionTransactionMap" + paymentOptionIdPaymentOptionTransactionMap.keySet());
|
|
|
453 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository
|
|
|
454 |
.selectByRetailerIdInvoiceNumber(fofoOrder.getInvoiceNumber());
|
|
|
455 |
this.addInsuranceProvider(insurancePolicies);
|
|
|
456 |
model.addAttribute("fofoOrder", fofoOrder);
|
|
|
457 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
|
|
458 |
fofoOrderItem.setDoa(true);
|
|
|
459 |
}
|
| 23973 |
govind |
460 |
|
| 32251 |
amit.gupta |
461 |
Map<Integer, Set<FofoLineItem>> fofoOrderItemIdLineItemMap = fofoOrderItems.stream()
|
|
|
462 |
.collect(Collectors.toMap(FofoOrderItem::getId, FofoOrderItem::getFofoLineItems));
|
| 23973 |
govind |
463 |
|
| 32251 |
amit.gupta |
464 |
Map<Integer, List<CustomerReturnItem>> foiIdCustomerReturnInventoryItemsMap = fofoOrderItems.stream()
|
|
|
465 |
.collect(Collectors.toMap(foi -> foi.getId(),
|
|
|
466 |
foi -> customerReturnItemRepository.selectAllByOrderItemId(foi.getId())));
|
| 28339 |
tejbeer |
467 |
|
| 32251 |
amit.gupta |
468 |
Map<Integer, Integer> inventoryItemBilledQtyMap = new HashMap<>();
|
| 28339 |
tejbeer |
469 |
|
| 32251 |
amit.gupta |
470 |
for (FofoOrderItem foi : fofoOrderItems) {
|
|
|
471 |
for (FofoLineItem fli : foi.getFofoLineItems()) {
|
|
|
472 |
inventoryItemBilledQtyMap.put(fli.getInventoryItemId(), fli.getQuantity());
|
|
|
473 |
}
|
|
|
474 |
List<CustomerReturnItem> customerReturnItems = customerReturnItemRepository
|
|
|
475 |
.selectAllByOrderItemId(foi.getId());
|
|
|
476 |
for (CustomerReturnItem customerReturnItem : customerReturnItems) {
|
|
|
477 |
inventoryItemBilledQtyMap.put(customerReturnItem.getInventoryItemId(),
|
|
|
478 |
inventoryItemBilledQtyMap.get(customerReturnItem.getInventoryItemId()) - 1);
|
|
|
479 |
}
|
|
|
480 |
}
|
|
|
481 |
model.addAttribute("foiIdCustomerReturnInventoryItemsMap",
|
|
|
482 |
StringUtils.toString(foiIdCustomerReturnInventoryItemsMap));
|
|
|
483 |
model.addAttribute("fofoOrderItems", fofoOrderItems);
|
|
|
484 |
model.addAttribute("inventoryItemBilledQtyMap", StringUtils.toString(inventoryItemBilledQtyMap));
|
|
|
485 |
model.addAttribute("fofoOrderItemIdLineItemsMap", StringUtils.toString(fofoOrderItemIdLineItemMap));
|
|
|
486 |
model.addAttribute("itemsMap", itemsMap);
|
|
|
487 |
model.addAttribute("markDefective", true);
|
|
|
488 |
model.addAttribute("customer", customer);
|
|
|
489 |
model.addAttribute("customerAddress", customerAddress);
|
|
|
490 |
model.addAttribute("paymentOptionTransactions", paymentOptionTransactions);
|
|
|
491 |
model.addAttribute("paymentOptionIdPaymentOptionMap", paymentOptionIdPaymentOptionMap);
|
|
|
492 |
model.addAttribute("paymentOptionIdPaymentOptionTransactionMap", paymentOptionIdPaymentOptionTransactionMap);
|
|
|
493 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
|
|
494 |
model.addAttribute("fofoPartnerPaymentOptions", fofoPartnerPaymentOptions);
|
|
|
495 |
model.addAttribute("totalNumberOfPaymentOptionId", fofoPartnerPaymentOptions.size());
|
|
|
496 |
model.addAttribute("stateNames",
|
|
|
497 |
stateRepository.selectAll().stream().map(x -> x.getName()).collect(Collectors.toList()));
|
|
|
498 |
return "search-order-details";
|
|
|
499 |
}
|
| 28339 |
tejbeer |
500 |
|
| 32251 |
amit.gupta |
501 |
private Map<Integer, PaymentOption> paymentOptionIdPaymentOptionMap(
|
|
|
502 |
List<PaymentOptionTransaction> paymentOptionTransactions) {
|
|
|
503 |
Set<Integer> paymentOptionIds = new HashSet<>();
|
|
|
504 |
for (PaymentOptionTransaction paymentOptionTransaction : paymentOptionTransactions) {
|
|
|
505 |
paymentOptionIds.add(paymentOptionTransaction.getPaymentOptionId());
|
|
|
506 |
}
|
|
|
507 |
List<PaymentOption> paymentOptions = paymentOptionRepository.selectByIds(paymentOptionIds);
|
|
|
508 |
Map<Integer, PaymentOption> paymentOptionIdPaymentOptionMap = new HashMap<>();
|
|
|
509 |
for (PaymentOption paymentOption : paymentOptions) {
|
|
|
510 |
paymentOptionIdPaymentOptionMap.put(paymentOption.getId(), paymentOption);
|
|
|
511 |
}
|
|
|
512 |
return paymentOptionIdPaymentOptionMap;
|
|
|
513 |
}
|
| 28339 |
tejbeer |
514 |
|
| 32251 |
amit.gupta |
515 |
private Map<Integer, PaymentOption> paymentOptionIdPaymentOptionMapUsingPaymentOptions(
|
|
|
516 |
List<Integer> fofoPartnerPaymentOptions) {
|
|
|
517 |
List<PaymentOption> paymentOptions = paymentOptionRepository
|
|
|
518 |
.selectByIds(new HashSet<>(fofoPartnerPaymentOptions));
|
|
|
519 |
Map<Integer, PaymentOption> paymentOptionIdPaymentOptionMap = new HashMap<>();
|
|
|
520 |
for (PaymentOption paymentOption : paymentOptions) {
|
|
|
521 |
paymentOptionIdPaymentOptionMap.put(paymentOption.getId(), paymentOption);
|
|
|
522 |
}
|
|
|
523 |
return paymentOptionIdPaymentOptionMap;
|
|
|
524 |
}
|
| 28339 |
tejbeer |
525 |
|
| 32251 |
amit.gupta |
526 |
private Map<Integer, PaymentOptionTransaction> paymentOptionIdPaymentOptionTransactionMap(
|
|
|
527 |
List<PaymentOptionTransaction> paymentOptionTransactions) {
|
|
|
528 |
Map<Integer, PaymentOptionTransaction> paymentOptionIdPaymentOptionTransactionMap = new HashMap<>();
|
|
|
529 |
for (PaymentOptionTransaction paymentOptionTransaction : paymentOptionTransactions) {
|
|
|
530 |
paymentOptionIdPaymentOptionTransactionMap.put(paymentOptionTransaction.getPaymentOptionId(),
|
|
|
531 |
paymentOptionTransaction);
|
|
|
532 |
}
|
|
|
533 |
return paymentOptionIdPaymentOptionTransactionMap;
|
|
|
534 |
}
|
| 31375 |
tejbeer |
535 |
|
| 32251 |
amit.gupta |
536 |
@RequestMapping(value = "/create-order", method = RequestMethod.POST)
|
|
|
537 |
public String createOrder(HttpServletRequest request, @RequestBody CreateOrderRequest createOrderRequest,
|
|
|
538 |
Model model) throws ProfitMandiBusinessException {
|
|
|
539 |
// throw new ProfitMandiBusinessException("Billing is on hold temporarily",
|
|
|
540 |
// "Billing is on hold temporarily", "Billing is on hold temporarily");
|
|
|
541 |
LOGGER.info("request at uri {} body {}", request.getRequestURI(), createOrderRequest);
|
|
|
542 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 28339 |
tejbeer |
543 |
|
| 32251 |
amit.gupta |
544 |
int fofoOrderId = orderService.createOrder(createOrderRequest, fofoDetails.getFofoId(), accessoriesDeals);
|
| 28339 |
tejbeer |
545 |
|
| 32251 |
amit.gupta |
546 |
LOGGER.info("Order has been created successfully...");
|
|
|
547 |
try {
|
|
|
548 |
this.sendWhatsappInvoice(fofoOrderRepository.selectByOrderId(fofoOrderId));
|
|
|
549 |
} catch (Exception e) {
|
|
|
550 |
LOGGER.info("Could not send whatsapp message");
|
|
|
551 |
e.printStackTrace();
|
|
|
552 |
}
|
|
|
553 |
return "redirect:/get-order/?orderId=" + fofoOrderId;
|
|
|
554 |
}
|
| 28339 |
tejbeer |
555 |
|
| 32251 |
amit.gupta |
556 |
private void sendWhatsappInvoice(FofoOrder fofoOrder) throws Exception {
|
|
|
557 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
|
|
558 |
CustomRetailer retailer = retailerService.getFofoRetailer(fofoOrder.getFofoId());
|
|
|
559 |
String message = String.format("Dear %s,\n" +
|
| 32326 |
amit.gupta |
560 |
"Thank you for your purchase from SmartDukaan store - %s, %s.\n" +
|
| 32251 |
amit.gupta |
561 |
"Your purchase invoice is attached for your reference.\n" +
|
|
|
562 |
"\n" +
|
|
|
563 |
"Download our app for offers and updates on new products.\n" +
|
| 32269 |
amit.gupta |
564 |
"https://www.smartdukaan.com/b2c\n" +
|
| 32251 |
amit.gupta |
565 |
"\n" +
|
|
|
566 |
"Best Regards\n" +
|
|
|
567 |
"SmartDukaan", customer.getFirstName(), retailer.getBusinessName(), retailer.getAddress().getCity());
|
| 32508 |
amit.gupta |
568 |
boolean sentMessage = notificationService.isWhatMessageSend(customer.getMobileNumber());
|
|
|
569 |
if (sentMessage) {
|
|
|
570 |
notificationService.sendWhatsappMediaMessage(message, customer.getMobileNumber(), this.getPublicInvoiceUrl(fofoOrder.getInvoiceNumber()), this.getFileName(fofoOrder.getInvoiceNumber()));
|
|
|
571 |
}
|
| 32251 |
amit.gupta |
572 |
}
|
| 23973 |
govind |
573 |
|
| 32251 |
amit.gupta |
574 |
private String getFileName(String invoiceNumber) {
|
| 32270 |
amit.gupta |
575 |
return "INV-" + invoiceNumber.replace("/", "-") + ".pdf";
|
| 32251 |
amit.gupta |
576 |
}
|
| 24844 |
amit.gupta |
577 |
|
| 32251 |
amit.gupta |
578 |
private String getPublicInvoiceUrl(String invoiceNumber) {
|
| 32271 |
amit.gupta |
579 |
String base64Encoded = Base64.getMimeEncoder().encodeToString(invoiceNumber.getBytes(StandardCharsets.UTF_8));
|
|
|
580 |
String publicUrl = "https://partners.smartdukaan.com/wa-invoice-send/" + base64Encoded + ".pdf";
|
| 32710 |
amit.gupta |
581 |
LOGGER.info("Public Whatsapp Url for Invoice Message - {}", publicUrl);
|
| 32251 |
amit.gupta |
582 |
return publicUrl;
|
|
|
583 |
}
|
| 24844 |
amit.gupta |
584 |
|
| 32251 |
amit.gupta |
585 |
@RequestMapping(value = "/order/bad_return", method = RequestMethod.POST)
|
|
|
586 |
public ResponseEntity<?> badReturn(HttpServletRequest request, @RequestBody FoiBadReturnRequest foiBadReturnRequest,
|
|
|
587 |
Model model) throws ProfitMandiBusinessException {
|
|
|
588 |
LOGGER.info("request at uri {} body {}", request.getRequestURI(), foiBadReturnRequest);
|
|
|
589 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
590 |
CustomerCreditNote custmoerCreditNote;
|
|
|
591 |
if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
|
|
|
592 |
FofoOrderItem foi = fofoOrderItemRepository.selectById(foiBadReturnRequest.getFofoOrderItemId());
|
|
|
593 |
FofoOrder fo = fofoOrderRepository.selectByOrderId(foi.getOrderId());
|
|
|
594 |
custmoerCreditNote = orderService.badReturn(fo.getFofoId(), foiBadReturnRequest);
|
|
|
595 |
} else {
|
|
|
596 |
custmoerCreditNote = orderService.badReturn(fofoDetails.getFofoId(), foiBadReturnRequest);
|
|
|
597 |
}
|
|
|
598 |
return responseSender.ok(custmoerCreditNote.getId());
|
|
|
599 |
}
|
| 23973 |
govind |
600 |
|
| 32271 |
amit.gupta |
601 |
@GetMapping(value = "/wa-invoice-send/{invoiceHash}")
|
|
|
602 |
public ResponseEntity<?> generateInvoice(@PathVariable String invoiceHash) throws ProfitMandiBusinessException {
|
|
|
603 |
String decodedInvoiceNumber = new String(Base64.getMimeDecoder().decode(invoiceHash));
|
| 32711 |
amit.gupta |
604 |
LOGGER.info("Invoice Hash {}", invoiceHash);
|
|
|
605 |
|
|
|
606 |
|
| 32271 |
amit.gupta |
607 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(decodedInvoiceNumber);
|
|
|
608 |
|
| 32251 |
amit.gupta |
609 |
InvoicePdfModel pdfModel = orderService.getInvoicePdfModel(fofoOrder.getId());
|
| 24087 |
amit.gupta |
610 |
|
| 32251 |
amit.gupta |
611 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
612 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
|
|
613 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
614 |
//headers.setContentDispositionFormData("inline", number + ".pdf");
|
|
|
615 |
headers.add(HttpHeaders.CONTENT_DISPOSITION, "inline;filename=" + pdfModel.getInvoiceNumber() + ".pdf");
|
|
|
616 |
int contentLength = byteArrayOutputStream.toByteArray().length;
|
|
|
617 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
618 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
619 |
return ResponseEntity.ok()
|
|
|
620 |
.headers(headers)
|
|
|
621 |
.contentLength(contentLength)
|
|
|
622 |
.contentType(MediaType.parseMediaType("application/pdf"))
|
|
|
623 |
.body(inputStreamResource);
|
|
|
624 |
}
|
| 23973 |
govind |
625 |
|
| 32254 |
amit.gupta |
626 |
@RequestMapping(value = "/wa-listen", method = RequestMethod.POST)
|
| 32251 |
amit.gupta |
627 |
public ResponseEntity<?> listenWhatsappStatus(@RequestBody String whatsappJsonResponse) {
|
|
|
628 |
LOGGER.info("whatsappJsonResponse {}", whatsappJsonResponse);
|
| 32405 |
jai.hind |
629 |
//jaihind
|
| 32409 |
amit.gupta |
630 |
// String jsonString = "[{\"srcAddr\":\"TESTSM\",\"channel\":\"WHATSAPP\",\"externalId\":\"4977024756456780043-180044363908187691\",\"cause\":\"SUCCESS\",\"errorCode\":\"000\",\"destAddr\":\"919813272029\",\"eventType\":\"DELIVERED\",\"eventTs\":1692848106000}]";
|
| 32405 |
jai.hind |
631 |
JSONArray jsonArray = new JSONArray(whatsappJsonResponse);
|
| 32409 |
amit.gupta |
632 |
for (int i = 0; i < jsonArray.length(); i++) {
|
| 32405 |
jai.hind |
633 |
|
|
|
634 |
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
635 |
String externalId = jsonObject.getString("externalId");
|
|
|
636 |
String destAddr = jsonObject.getString("destAddr");
|
|
|
637 |
String eventType = jsonObject.getString("eventType");
|
| 32409 |
amit.gupta |
638 |
whatsappMessageService.setWhatsappResponse(externalId, destAddr, eventType);
|
| 32405 |
jai.hind |
639 |
}
|
|
|
640 |
//jaihind
|
| 32251 |
amit.gupta |
641 |
return responseSender.ok("Success");
|
| 32405 |
jai.hind |
642 |
|
| 32251 |
amit.gupta |
643 |
}
|
| 32409 |
amit.gupta |
644 |
|
| 32251 |
amit.gupta |
645 |
@RequestMapping(value = "/generateInvoice")
|
|
|
646 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response,
|
|
|
647 |
@RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws ProfitMandiBusinessException {
|
|
|
648 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(),
|
|
|
649 |
ProfitMandiConstants.ORDER_ID, orderId);
|
|
|
650 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
651 |
InvoicePdfModel pdfModel = null;
|
|
|
652 |
if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
|
|
|
653 |
pdfModel = orderService.getInvoicePdfModel(orderId);
|
|
|
654 |
} else {
|
|
|
655 |
pdfModel = orderService.getInvoicePdfModel(fofoDetails.getFofoId(), orderId);
|
|
|
656 |
}
|
|
|
657 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
658 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
|
|
659 |
LOGGER.info("Pdf Stream length {}", byteArrayOutputStream.toByteArray().length);
|
|
|
660 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
661 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
|
662 |
headers.setContentDispositionFormData("inline", "invoice-" + pdfModel.getInvoiceNumber() + ".pdf");
|
|
|
663 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
664 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
665 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
666 |
return new ResponseEntity<>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
667 |
}
|
| 23973 |
govind |
668 |
|
| 32251 |
amit.gupta |
669 |
@RequestMapping(value = "/generateInvoices")
|
|
|
670 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response,
|
|
|
671 |
@RequestParam LocalDateTime startDate, @RequestParam LocalDateTime endDate, @RequestParam int partnerId)
|
|
|
672 |
throws ProfitMandiBusinessException {
|
|
|
673 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
674 |
List<InvoicePdfModel> pdfModels = new ArrayList<>();
|
|
|
675 |
if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
|
|
|
676 |
List<Integer> orderIds = fofoOrderRepository.selectByFofoId(partnerId, startDate, endDate, 0, 0).stream()
|
|
|
677 |
.map(x -> x.getId()).collect(Collectors.toList());
|
|
|
678 |
for (int orderId : orderIds) {
|
|
|
679 |
pdfModels.add(orderService.getInvoicePdfModel(orderId));
|
|
|
680 |
}
|
|
|
681 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
682 |
PdfUtils.generateAndWrite(pdfModels, byteArrayOutputStream);
|
|
|
683 |
LOGGER.info("Pdf Stream length {}", byteArrayOutputStream.toByteArray().length);
|
|
|
684 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
685 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
|
686 |
headers.set("Content-disposition", "inline; filename=invoice-" + partnerId + ".pdf");
|
|
|
687 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
688 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
689 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
690 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
691 |
} else {
|
|
|
692 |
throw new ProfitMandiBusinessException("Auth", fofoDetails.getEmailId(), "Unauthorised access");
|
|
|
693 |
}
|
|
|
694 |
}
|
| 23654 |
amit.gupta |
695 |
|
| 32251 |
amit.gupta |
696 |
@RequestMapping(value = "/saleHistory")
|
|
|
697 |
public String saleHistory(HttpServletRequest request,
|
|
|
698 |
@RequestParam(name = "searchValue", defaultValue = "") String searchValue,
|
|
|
699 |
@RequestParam(name = "searchType", defaultValue = "") SearchType searchType,
|
|
|
700 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
701 |
@RequestParam(required = false) LocalDateTime endTime,
|
|
|
702 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
703 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
704 |
throws ProfitMandiBusinessException {
|
|
|
705 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23654 |
amit.gupta |
706 |
|
| 32251 |
amit.gupta |
707 |
Map<String, Object> map = orderService.getSaleHistory(loginDetails.getFofoId(), searchType, searchValue,
|
|
|
708 |
startTime, endTime, offset, limit);
|
|
|
709 |
model.addAllAttributes(map);
|
|
|
710 |
return "sale-history";
|
|
|
711 |
}
|
| 23973 |
govind |
712 |
|
| 32251 |
amit.gupta |
713 |
@RequestMapping(value = "/downloadInvoices")
|
|
|
714 |
public ResponseEntity<?> downloadInvoices(HttpServletRequest request,
|
|
|
715 |
@RequestParam(name = "searchValue", defaultValue = "") String searchValue,
|
|
|
716 |
@RequestParam(name = "searchType", defaultValue = "") SearchType searchType,
|
|
|
717 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
718 |
@RequestParam(required = false) LocalDateTime endTime,
|
|
|
719 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
720 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
721 |
throws ProfitMandiBusinessException {
|
|
|
722 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23973 |
govind |
723 |
|
| 32251 |
amit.gupta |
724 |
Map<String, Object> map = orderService.getSaleHistory(loginDetails.getFofoId(), searchType, searchValue,
|
|
|
725 |
startTime, endTime, offset, 100);
|
|
|
726 |
List<FofoOrder> fofoOrders = (List<FofoOrder>) map.get("saleHistories");
|
| 29707 |
tejbeer |
727 |
|
| 32251 |
amit.gupta |
728 |
if (fofoOrders.size() == 0) {
|
|
|
729 |
throw new ProfitMandiBusinessException("Search criteria", "", "No orders found for criteria");
|
|
|
730 |
}
|
| 23973 |
govind |
731 |
|
| 32251 |
amit.gupta |
732 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
733 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
|
734 |
headers.set("Content-disposition", "inline; filename=invoices.pdf");
|
|
|
735 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
736 |
List<InvoicePdfModel> pdfModels = new ArrayList<>();
|
|
|
737 |
for (FofoOrder fofoOrder : fofoOrders) {
|
|
|
738 |
try {
|
|
|
739 |
pdfModels.add(orderService.getInvoicePdfModel(fofoOrder.getId()));
|
|
|
740 |
} catch (Exception e) {
|
|
|
741 |
LOGGER.info("could not create invoice for {}, invoice number {}", fofoOrder.getId(),
|
|
|
742 |
fofoOrder.getInvoiceNumber());
|
|
|
743 |
}
|
|
|
744 |
}
|
|
|
745 |
PdfUtils.generateAndWrite(pdfModels, byteArrayOutputStream);
|
|
|
746 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
747 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
748 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
749 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
750 |
}
|
| 23973 |
govind |
751 |
|
| 32251 |
amit.gupta |
752 |
@RequestMapping(value = "/credit-note/{creditNoteId}")
|
|
|
753 |
public ResponseEntity<?> downloadCreditNote(HttpServletRequest request, @PathVariable int creditNoteId)
|
|
|
754 |
throws ProfitMandiBusinessException {
|
|
|
755 |
CreditNotePdfModel creditNotePdfModel = orderService.getCreditNotePdfModel(creditNoteId);
|
|
|
756 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
757 |
PdfUtils.generateAndWriteCustomerCreditNotes(Arrays.asList(creditNotePdfModel), byteArrayOutputStream);
|
|
|
758 |
LOGGER.info("Pdf Stream length {}", byteArrayOutputStream.toByteArray().length);
|
|
|
759 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
760 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
|
761 |
headers.set("Content-disposition",
|
|
|
762 |
"inline; filename=invoice-" + creditNotePdfModel.getCreditNoteNumber() + ".pdf");
|
|
|
763 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
764 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
765 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
766 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
767 |
}
|
| 23973 |
govind |
768 |
|
| 32251 |
amit.gupta |
769 |
@RequestMapping(value = "/getPaginatedSaleHistory")
|
|
|
770 |
public String getSaleHistoryPaginated(HttpServletRequest request,
|
|
|
771 |
@RequestParam(name = "searchValue", defaultValue = "") String searchValue,
|
|
|
772 |
@RequestParam(name = "searchType", defaultValue = "") SearchType searchType,
|
|
|
773 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
774 |
@RequestParam(required = false) LocalDateTime endTime,
|
|
|
775 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
776 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
777 |
throws ProfitMandiBusinessException {
|
|
|
778 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
779 |
Map<String, Object> map = orderService.getSaleHistoryPaginated(loginDetails.getFofoId(), searchType,
|
|
|
780 |
searchValue, startTime, endTime, offset, limit);
|
|
|
781 |
model.addAllAttributes(map);
|
|
|
782 |
return "sale-history-paginated";
|
|
|
783 |
}
|
| 23973 |
govind |
784 |
|
| 32251 |
amit.gupta |
785 |
@PutMapping(value = "/updatePaymentTransaction")
|
|
|
786 |
public String updateTransactionDetails(HttpServletRequest request, @RequestParam String referenceType,
|
|
|
787 |
@RequestParam int fofoId, @RequestParam int referenceId,
|
|
|
788 |
@RequestBody PartnerOptionsAndItemAmountModel partnerOptionsAndItemAmountModel,
|
|
|
789 |
@RequestParam float totalAmount, Model model) throws Exception {
|
| 23973 |
govind |
790 |
|
| 32251 |
amit.gupta |
791 |
List<PaymentOptionTransactionModel> paymentOptionTransactionModels = partnerOptionsAndItemAmountModel
|
|
|
792 |
.getPaymentOptionTransactionModel();
|
|
|
793 |
LOGGER.info(paymentOptionTransactionModels);
|
|
|
794 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoId, referenceId);
|
|
|
795 |
LOGGER.info("sdssd" + fofoOrder);
|
|
|
796 |
fofoOrder.setTotalAmount(totalAmount);
|
|
|
797 |
List<FofoItemIdAmountModel> fofoItemIdAmountModel = partnerOptionsAndItemAmountModel.getItemAmountModel();
|
|
|
798 |
for (FofoItemIdAmountModel fim : fofoItemIdAmountModel) {
|
|
|
799 |
LOGGER.info("fim" + fim.getFofoItemId());
|
| 27819 |
tejbeer |
800 |
|
| 32251 |
amit.gupta |
801 |
LOGGER.info("fimAmount" + fim.getAmount());
|
|
|
802 |
Item item = itemRepository.selectById(fim.getItemId());
|
|
|
803 |
TagListing tagListing = tagListingRepository.selectByItemId(item.getId());
|
|
|
804 |
FofoOrderItem fofoOrderItem = fofoOrderItemRepository.selectById(fim.getFofoItemId());
|
|
|
805 |
LOGGER.info("category" + item.getCategoryId());
|
|
|
806 |
if (item.getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID) {
|
|
|
807 |
if (fofoOrderItem.getMop() <= fim.getAmount()) {
|
| 23973 |
govind |
808 |
|
| 32251 |
amit.gupta |
809 |
if (fim.getAmount() <= tagListing.getMrp()) {
|
|
|
810 |
fofoOrderItem.setSellingPrice(fim.getAmount());
|
|
|
811 |
} else {
|
|
|
812 |
throw new ProfitMandiBusinessException("Amount", fim.getAmount(),
|
|
|
813 |
"Sum of amount is not less than to MRP");
|
|
|
814 |
}
|
| 23973 |
govind |
815 |
|
| 32251 |
amit.gupta |
816 |
LOGGER.info("fofoOrderItem2" + fofoOrderItem);
|
| 23973 |
govind |
817 |
|
| 32251 |
amit.gupta |
818 |
} else {
|
|
|
819 |
// TODO below mop condition need to added added
|
|
|
820 |
fofoOrderItem.setSellingPrice(fim.getAmount());
|
|
|
821 |
}
|
| 31739 |
amit.gupta |
822 |
|
| 32251 |
amit.gupta |
823 |
} else {
|
|
|
824 |
fofoOrderItem.setSellingPrice(fim.getAmount());
|
|
|
825 |
LOGGER.info("fofoOrderItem1" + fofoOrderItem);
|
| 24844 |
amit.gupta |
826 |
|
| 32251 |
amit.gupta |
827 |
}
|
|
|
828 |
LOGGER.info("fofoOrderItem" + fofoOrderItem);
|
| 24281 |
amit.gupta |
829 |
|
| 32251 |
amit.gupta |
830 |
}
|
| 24281 |
amit.gupta |
831 |
|
| 32251 |
amit.gupta |
832 |
/*
|
|
|
833 |
* for (PaymentOptionTransactionModel paymentOptionTransactionModel :
|
|
|
834 |
* paymentOptionTransactionModels) { amount = amount +
|
|
|
835 |
* paymentOptionTransactionModel.getAmount(); } LOGGER.info("FofoOrder amount" +
|
|
|
836 |
* fofoOrder.getUnitPrice() + "amount" + amount); if (amount ==
|
|
|
837 |
* fofoOrder.getUnitPrice()) {
|
|
|
838 |
*/
|
|
|
839 |
if (paymentOptionTransactionModels.size() > 0) {
|
|
|
840 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository
|
|
|
841 |
.selectByReferenceIdAndType(referenceId, PaymentOptionReferenceType.ORDER);
|
|
|
842 |
Map<Integer, PaymentOptionTransaction> paymentOptionIdPaymentOptionTransactionMap = this
|
|
|
843 |
.paymentOptionIdPaymentOptionTransactionMap(paymentOptionTransactions);
|
|
|
844 |
LOGGER.info(
|
|
|
845 |
"paymentOptionIdPaymentOptionTransactionMap" + paymentOptionIdPaymentOptionTransactionMap.keySet());
|
|
|
846 |
for (PaymentOptionTransactionModel paymentOptionTransactionModel : paymentOptionTransactionModels) {
|
|
|
847 |
if (paymentOptionIdPaymentOptionTransactionMap
|
|
|
848 |
.containsKey(paymentOptionTransactionModel.getPaymentOptionId())) {
|
| 24281 |
amit.gupta |
849 |
|
| 32251 |
amit.gupta |
850 |
PaymentOptionTransaction paymentOptionTransaction = paymentOptionIdPaymentOptionTransactionMap
|
|
|
851 |
.get(paymentOptionTransactionModel.getPaymentOptionId());
|
| 23973 |
govind |
852 |
|
| 32251 |
amit.gupta |
853 |
if (paymentOptionTransactionModel.getAmount() == 0) {
|
|
|
854 |
paymentOptionTransactionRepository.delete(paymentOptionTransaction);
|
|
|
855 |
LOGGER.info("deleted successfully");
|
|
|
856 |
} else {
|
| 23973 |
govind |
857 |
|
| 32251 |
amit.gupta |
858 |
paymentOptionTransaction.setAmount(paymentOptionTransactionModel.getAmount());
|
|
|
859 |
paymentOptionTransactionRepository.persist(paymentOptionTransaction);
|
|
|
860 |
LOGGER.info("updated successfully");
|
| 24105 |
govind |
861 |
|
| 32251 |
amit.gupta |
862 |
}
|
|
|
863 |
} else {
|
|
|
864 |
if (paymentOptionTransactionModel.getAmount() > 0) {
|
|
|
865 |
PaymentOptionTransaction paymentOptionTransaction = new PaymentOptionTransaction();
|
|
|
866 |
paymentOptionTransaction.setReferenceId(referenceId);
|
|
|
867 |
paymentOptionTransaction.setReferenceType(PaymentOptionReferenceType.ORDER);
|
|
|
868 |
paymentOptionTransaction.setPaymentOptionId(paymentOptionTransactionModel.getPaymentOptionId());
|
|
|
869 |
paymentOptionTransaction.setAmount(paymentOptionTransactionModel.getAmount());
|
|
|
870 |
paymentOptionTransaction.setFofoId(fofoId);
|
|
|
871 |
paymentOptionTransaction.setCreateTimestamp(fofoOrder.getCreateTimestamp());
|
|
|
872 |
paymentOptionTransactionRepository.persist(paymentOptionTransaction);
|
|
|
873 |
LOGGER.info("inserted successfully");
|
|
|
874 |
}
|
|
|
875 |
}
|
| 24105 |
govind |
876 |
|
| 32251 |
amit.gupta |
877 |
}
|
| 23973 |
govind |
878 |
|
| 32251 |
amit.gupta |
879 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
880 |
}
|
|
|
881 |
/*
|
|
|
882 |
* else
|
|
|
883 |
*
|
|
|
884 |
* { throw new ProfitMandiBusinessException("Amount", amount,
|
|
|
885 |
* "Sum of amount is not equal to total amount"); }
|
|
|
886 |
*/
|
| 28339 |
tejbeer |
887 |
|
| 32251 |
amit.gupta |
888 |
return "response";
|
| 23973 |
govind |
889 |
|
| 32251 |
amit.gupta |
890 |
}
|
| 21985 |
kshitij.so |
891 |
|
| 32251 |
amit.gupta |
892 |
private Map<String, List<MobileInsurancePlan>> getPlans(float sellingPrice, int itemId)
|
|
|
893 |
throws ProfitMandiBusinessException {
|
|
|
894 |
try {
|
|
|
895 |
Map<String, List<MobileInsurancePlan>> productDurationPlans = insuranceService.getAllPlans(itemId,
|
|
|
896 |
sellingPrice);
|
|
|
897 |
return productDurationPlans;
|
|
|
898 |
} catch (Exception e) {
|
|
|
899 |
LOGGER.info(e, e);
|
|
|
900 |
throw new ProfitMandiBusinessException("Fetch Insurance Plans", "Insurance",
|
|
|
901 |
"Could not fetch insurance Plans");
|
|
|
902 |
}
|
| 32238 |
amit.gupta |
903 |
|
| 32251 |
amit.gupta |
904 |
}
|
| 32238 |
amit.gupta |
905 |
|
| 32251 |
amit.gupta |
906 |
@GetMapping("/insuranceDetails")
|
|
|
907 |
public String getInsuranceDetails(HttpServletRequest request,
|
|
|
908 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
909 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
910 |
throws ProfitMandiBusinessException {
|
|
|
911 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
912 |
long size = 0;
|
|
|
913 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectByRetailerId(loginDetails.getFofoId(),
|
|
|
914 |
offset, limit);
|
|
|
915 |
size = insurancePolicyRepository.selectCountByRetailerId(loginDetails.getFofoId());
|
|
|
916 |
Map<Integer, String> providerPolicyNameAndIdMap = insuranceProviderRepository
|
|
|
917 |
.selectByIds(insurancePolicies.stream().map(x -> x.getProviderId()).collect(Collectors.toSet()))
|
|
|
918 |
.stream().collect(Collectors.toMap(InsuranceProvider::getId, InsuranceProvider::getName));
|
|
|
919 |
if (size < limit) {
|
|
|
920 |
model.addAttribute("end", offset + size);
|
|
|
921 |
} else {
|
|
|
922 |
model.addAttribute("end", offset + limit);
|
|
|
923 |
}
|
|
|
924 |
model.addAttribute("start", offset + 1);
|
|
|
925 |
model.addAttribute("size", size);
|
|
|
926 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
|
|
927 |
model.addAttribute("providerPolicyNameAndIdMap", providerPolicyNameAndIdMap);
|
|
|
928 |
return "insurance-details";
|
|
|
929 |
}
|
| 32238 |
amit.gupta |
930 |
|
| 32251 |
amit.gupta |
931 |
@GetMapping("/insuranceDetailsPaginated")
|
|
|
932 |
public String getInsuranceDetailsPaginated(HttpServletRequest request,
|
|
|
933 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
934 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
935 |
throws ProfitMandiBusinessException {
|
|
|
936 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
937 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectByRetailerId(loginDetails.getFofoId(),
|
|
|
938 |
offset, limit);
|
|
|
939 |
Map<Integer, String> providerPolicyNameAndIdMap = insuranceProviderRepository
|
|
|
940 |
.selectByIds(insurancePolicies.stream().map(x -> x.getProviderId()).collect(Collectors.toSet()))
|
|
|
941 |
.stream().collect(Collectors.toMap(InsuranceProvider::getId, InsuranceProvider::getName));
|
|
|
942 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
|
|
943 |
model.addAttribute("providerPolicyNameAndIdMap", providerPolicyNameAndIdMap);
|
|
|
944 |
return "insurance-details-paginated";
|
|
|
945 |
}
|
| 23973 |
govind |
946 |
|
| 32251 |
amit.gupta |
947 |
@GetMapping("/getMouForm")
|
|
|
948 |
public String getMouForm(HttpServletRequest request, Model model) throws Exception {
|
|
|
949 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24844 |
amit.gupta |
950 |
|
| 32251 |
amit.gupta |
951 |
Mou mou = mouRepository.selectByFofoId(loginDetails.getFofoId());
|
|
|
952 |
if (mou != null) {
|
|
|
953 |
if (mou.getUpdateTimestamp().getMonth().equals(LocalDateTime.now().getMonth())) {
|
|
|
954 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
955 |
} else {
|
|
|
956 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
|
|
957 |
}
|
| 23973 |
govind |
958 |
|
| 32251 |
amit.gupta |
959 |
} else {
|
|
|
960 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
| 23973 |
govind |
961 |
|
| 32251 |
amit.gupta |
962 |
}
|
|
|
963 |
return "response";
|
| 25092 |
amit.gupta |
964 |
|
| 32251 |
amit.gupta |
965 |
}
|
| 25092 |
amit.gupta |
966 |
|
| 32251 |
amit.gupta |
967 |
@GetMapping("/pendingOrders")
|
|
|
968 |
public String getPendingOrders(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
969 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
970 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
971 |
Mou mou = mouRepository.selectByFofoId(loginDetails.getFofoId());
|
|
|
972 |
if (mou == null) {
|
|
|
973 |
mou = new Mou();
|
|
|
974 |
mou.setFofoId(loginDetails.getFofoId());
|
|
|
975 |
mou.setCreateTimestamp(LocalDateTime.now());
|
|
|
976 |
mou.setUpdateTimestamp(LocalDateTime.now());
|
|
|
977 |
mouRepository.persist(mou);
|
|
|
978 |
} else if (!mou.getUpdateTimestamp().getMonth().equals(LocalDateTime.now().getMonth())) {
|
|
|
979 |
mou.setUpdateTimestamp(LocalDateTime.now());
|
|
|
980 |
}
|
| 25092 |
amit.gupta |
981 |
|
| 32761 |
amit.gupta |
982 |
List<PendingOrderItem> pendingOrderItems = pendingOrderItemRepository.selectOrderItemByStatusAndFofoId(OrderStatus.PROCESSING,
|
| 32251 |
amit.gupta |
983 |
loginDetails.getFofoId());
|
| 23973 |
govind |
984 |
|
| 32761 |
amit.gupta |
985 |
Map<String, Object> map = pendingOrderService.getItemOrders(pendingOrderItems, loginDetails.getFofoId());
|
| 32251 |
amit.gupta |
986 |
model.addAttribute("inventoryMap", map.get("inventoryMap"));
|
| 32761 |
amit.gupta |
987 |
model.addAttribute("pendingOrderItems", (List<PendingOrderItem>)map.get("pendingOrderItems"));
|
| 27861 |
tejbeer |
988 |
|
| 32251 |
amit.gupta |
989 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
990 |
return "pending_fofo_order";
|
| 27861 |
tejbeer |
991 |
|
| 32251 |
amit.gupta |
992 |
}
|
| 27861 |
tejbeer |
993 |
|
| 32251 |
amit.gupta |
994 |
@GetMapping("/billedOrders")
|
|
|
995 |
public String getBilledOrders(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
996 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
997 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| 27861 |
tejbeer |
998 |
|
| 32756 |
amit.gupta |
999 |
List<PendingOrderItem> pendingOrderItem;
|
| 27861 |
tejbeer |
1000 |
|
| 32251 |
amit.gupta |
1001 |
if (isAdmin) {
|
| 27861 |
tejbeer |
1002 |
|
| 32251 |
amit.gupta |
1003 |
pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatus(OrderStatus.BILLED);
|
| 27861 |
tejbeer |
1004 |
|
| 32251 |
amit.gupta |
1005 |
} else {
|
|
|
1006 |
pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatusAndFofoId(OrderStatus.BILLED,
|
|
|
1007 |
loginDetails.getFofoId());
|
|
|
1008 |
}
|
| 24105 |
govind |
1009 |
|
| 32251 |
amit.gupta |
1010 |
Map<String, Object> map = pendingOrderService.getItemOrders(pendingOrderItem, loginDetails.getFofoId());
|
| 24105 |
govind |
1011 |
|
| 32251 |
amit.gupta |
1012 |
model.addAttribute("pendingOrderItem", map.get("pendingOrderItem"));
|
|
|
1013 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
1014 |
return "billed_order_item";
|
|
|
1015 |
}
|
| 24105 |
govind |
1016 |
|
| 32251 |
amit.gupta |
1017 |
@GetMapping("/settledOrders")
|
|
|
1018 |
public String getSettledOrders(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
1019 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1020 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| 24105 |
govind |
1021 |
|
| 32251 |
amit.gupta |
1022 |
List<PendingOrderItem> pendingOrderItem = null;
|
| 27861 |
tejbeer |
1023 |
|
| 32251 |
amit.gupta |
1024 |
if (isAdmin) {
|
| 24105 |
govind |
1025 |
|
| 32251 |
amit.gupta |
1026 |
pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatus(OrderStatus.SETTLED);
|
| 27861 |
tejbeer |
1027 |
|
| 32251 |
amit.gupta |
1028 |
} else {
|
|
|
1029 |
pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatusAndFofoId(OrderStatus.SETTLED,
|
|
|
1030 |
loginDetails.getFofoId());
|
|
|
1031 |
}
|
| 24105 |
govind |
1032 |
|
| 32251 |
amit.gupta |
1033 |
Map<String, Object> map = pendingOrderService.getItemOrders(pendingOrderItem, loginDetails.getFofoId());
|
| 27861 |
tejbeer |
1034 |
|
| 32251 |
amit.gupta |
1035 |
model.addAttribute("pendingOrderItem", map.get("pendingOrderItem"));
|
|
|
1036 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
1037 |
return "settled_order_item";
|
|
|
1038 |
}
|
| 24440 |
amit.gupta |
1039 |
|
| 32251 |
amit.gupta |
1040 |
@GetMapping("/unsettledOrders")
|
|
|
1041 |
public String getunsettledOrders(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
1042 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1043 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| 25726 |
amit.gupta |
1044 |
|
| 32251 |
amit.gupta |
1045 |
List<PendingOrderItem> pendingOrderItem = null;
|
| 24880 |
govind |
1046 |
|
| 32251 |
amit.gupta |
1047 |
if (isAdmin) {
|
| 25092 |
amit.gupta |
1048 |
|
| 32251 |
amit.gupta |
1049 |
pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatus(OrderStatus.UNSETTLED);
|
| 26647 |
tejbeer |
1050 |
|
| 32251 |
amit.gupta |
1051 |
} else {
|
|
|
1052 |
pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatusAndFofoId(OrderStatus.UNSETTLED,
|
|
|
1053 |
loginDetails.getFofoId());
|
|
|
1054 |
}
|
| 28420 |
tejbeer |
1055 |
|
| 32251 |
amit.gupta |
1056 |
Map<String, Object> map = pendingOrderService.getItemOrders(pendingOrderItem, loginDetails.getFofoId());
|
| 28425 |
tejbeer |
1057 |
|
| 32251 |
amit.gupta |
1058 |
model.addAttribute("pendingOrderItem", map.get("pendingOrderItem"));
|
|
|
1059 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
1060 |
return "unsettled_order_item";
|
|
|
1061 |
}
|
| 28420 |
tejbeer |
1062 |
|
| 32251 |
amit.gupta |
1063 |
@GetMapping("/claimedOrders")
|
|
|
1064 |
public String getclaimedOrders(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
|
|
1065 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1066 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
1067 |
List<Integer> fofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId())
|
|
|
1068 |
.collect(Collectors.toList());
|
| 28420 |
tejbeer |
1069 |
|
| 32251 |
amit.gupta |
1070 |
List<PendingOrderItem> pendingOrderItem = null;
|
| 28420 |
tejbeer |
1071 |
|
| 32251 |
amit.gupta |
1072 |
if (isAdmin) {
|
| 26647 |
tejbeer |
1073 |
|
| 32251 |
amit.gupta |
1074 |
pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatus(OrderStatus.CLAIMED);
|
|
|
1075 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 28339 |
tejbeer |
1076 |
|
| 32251 |
amit.gupta |
1077 |
Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x))
|
|
|
1078 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
|
|
1079 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
1080 |
model.addAttribute("customRetailersMap", customRetailersMap);
|
| 28339 |
tejbeer |
1081 |
|
| 32251 |
amit.gupta |
1082 |
} else {
|
|
|
1083 |
pendingOrderItem = pendingOrderItemRepository.selectOrderItemByStatusAndFofoId(OrderStatus.CLAIMED,
|
|
|
1084 |
loginDetails.getFofoId());
|
|
|
1085 |
}
|
| 27046 |
tejbeer |
1086 |
|
| 32251 |
amit.gupta |
1087 |
Map<String, Object> map = pendingOrderService.getItemOrders(pendingOrderItem, loginDetails.getFofoId());
|
| 27046 |
tejbeer |
1088 |
|
| 32251 |
amit.gupta |
1089 |
model.addAttribute("pendingOrderItem", map.get("pendingOrderItem"));
|
|
|
1090 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
1091 |
return "claim_raised_order_item";
|
|
|
1092 |
}
|
| 28350 |
tejbeer |
1093 |
|
| 32251 |
amit.gupta |
1094 |
@GetMapping("/getPendingOrderItem")
|
|
|
1095 |
public String getPendingOrderItem(HttpServletRequest request, @RequestParam int orderId, Model model)
|
|
|
1096 |
throws ProfitMandiBusinessException {
|
|
|
1097 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1098 |
Map<Integer, Item> itemMap = new HashMap<>();
|
|
|
1099 |
Map<Integer, CurrentInventorySnapshot> inventoryMap = new HashMap<>();
|
|
|
1100 |
PendingOrder pendingPO = pendingOrderRepository.selectById(orderId);
|
|
|
1101 |
Customer customer = customerRepository.selectById(pendingPO.getCustomerId());
|
|
|
1102 |
List<PendingOrderItem> pendingOrderItems = pendingOrderItemRepository.selectByOrderId(orderId);
|
|
|
1103 |
for (PendingOrderItem pendingOrderItem : pendingOrderItems) {
|
|
|
1104 |
Item item = itemRepository.selectById(pendingOrderItem.getItemId());
|
|
|
1105 |
CurrentInventorySnapshot cis = currentInventorySnapshotRepository
|
|
|
1106 |
.selectByItemAndFofoId(pendingOrderItem.getItemId(), pendingPO.getFofoId());
|
|
|
1107 |
itemMap.put(pendingOrderItem.getItemId(), item);
|
|
|
1108 |
LOGGER.info("cis" + cis);
|
|
|
1109 |
inventoryMap.put(pendingOrderItem.getItemId(), cis);
|
|
|
1110 |
}
|
| 28358 |
tejbeer |
1111 |
|
| 32251 |
amit.gupta |
1112 |
LOGGER.info("inventoryMap" + inventoryMap);
|
|
|
1113 |
model.addAttribute("pendingOrderItems", pendingOrderItems);
|
|
|
1114 |
model.addAttribute("itemMap", itemMap);
|
|
|
1115 |
model.addAttribute("inventoryMap", inventoryMap);
|
|
|
1116 |
model.addAttribute("pendingPO", gson.toJson(pendingPO));
|
|
|
1117 |
model.addAttribute("pendingPOCustomer", gson.toJson(customer));
|
|
|
1118 |
model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
|
|
1119 |
return "pending-order-item";
|
|
|
1120 |
}
|
| 28350 |
tejbeer |
1121 |
|
| 32251 |
amit.gupta |
1122 |
@RequestMapping(value = "/getPendingOrderItemById", method = RequestMethod.GET)
|
|
|
1123 |
public String getPendingOrderItemById(HttpServletRequest request, @RequestParam int id, Model model)
|
|
|
1124 |
throws Exception {
|
| 28339 |
tejbeer |
1125 |
|
| 32251 |
amit.gupta |
1126 |
PendingOrderItem pendingOrderItem = pendingOrderItemRepository.selectById(id);
|
|
|
1127 |
model.addAttribute("pendingOrderItem", pendingOrderItem);
|
|
|
1128 |
return "cancel-pending-order";
|
|
|
1129 |
}
|
| 28339 |
tejbeer |
1130 |
|
| 32251 |
amit.gupta |
1131 |
@RequestMapping(value = "/getPendingOrderChangePartnerById", method = RequestMethod.GET)
|
|
|
1132 |
public String getPendingOrderChangePartnerById(HttpServletRequest request, @RequestParam int id, Model model)
|
|
|
1133 |
throws Exception {
|
| 28339 |
tejbeer |
1134 |
|
| 32251 |
amit.gupta |
1135 |
PendingOrder pendingOrder = pendingOrderRepository.selectById(id);
|
|
|
1136 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(true);
|
|
|
1137 |
model.addAttribute("customRetailersMap", customRetailersMap);
|
|
|
1138 |
model.addAttribute("pendingOrder", pendingOrder);
|
|
|
1139 |
return "change-partner-po";
|
|
|
1140 |
}
|
| 28339 |
tejbeer |
1141 |
|
| 32251 |
amit.gupta |
1142 |
@RequestMapping(value = "/changePendingOrderPartner", method = RequestMethod.POST)
|
|
|
1143 |
public String changePendingOrderPartner(HttpServletRequest request, @RequestParam int id, @RequestParam int fofoId,
|
|
|
1144 |
Model model) throws Exception {
|
| 27046 |
tejbeer |
1145 |
|
| 32251 |
amit.gupta |
1146 |
PendingOrder pendingOrder = pendingOrderRepository.selectById(id);
|
|
|
1147 |
pendingOrder.setFofoId(fofoId);
|
|
|
1148 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 28339 |
tejbeer |
1149 |
|
| 32251 |
amit.gupta |
1150 |
return "response";
|
|
|
1151 |
}
|
| 26647 |
tejbeer |
1152 |
|
| 32251 |
amit.gupta |
1153 |
@RequestMapping(value = "/cancelPendingOrderItem", method = RequestMethod.POST)
|
|
|
1154 |
public String cancelPendingOrderItem(HttpServletRequest request, @RequestParam int id, @RequestParam String reason,
|
|
|
1155 |
Model model) throws Exception {
|
| 28339 |
tejbeer |
1156 |
|
| 32251 |
amit.gupta |
1157 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1158 |
PendingOrderItem pendingOrderItem = pendingOrderItemRepository.selectById(id);
|
| 28339 |
tejbeer |
1159 |
|
| 32251 |
amit.gupta |
1160 |
pendingOrderItem.setStatus(OrderStatus.CANCELLED);
|
|
|
1161 |
pendingOrderItem.setStatusDescription(loginDetails.getEmailId());
|
|
|
1162 |
pendingOrderItem.setRemark(reason);
|
|
|
1163 |
pendingOrderItem.setCancelledTimestamp(LocalDateTime.now());
|
|
|
1164 |
PendingOrder pendingOrder = pendingOrderRepository.selectById(pendingOrderItem.getOrderId());
|
| 28339 |
tejbeer |
1165 |
|
| 32251 |
amit.gupta |
1166 |
List<OrderStatus> status = pendingOrderItemRepository.selectByOrderId(pendingOrderItem.getOrderId()).stream()
|
|
|
1167 |
.map(x -> x.getStatus()).collect(Collectors.toList());
|
| 28339 |
tejbeer |
1168 |
|
| 32251 |
amit.gupta |
1169 |
Customer customer = customerRepository.selectById(pendingOrder.getCustomerId());
|
| 28339 |
tejbeer |
1170 |
|
| 32251 |
amit.gupta |
1171 |
List<Integer> catalogIds = new ArrayList<>();
|
| 28339 |
tejbeer |
1172 |
|
| 32251 |
amit.gupta |
1173 |
Item item = itemRepository.selectById(pendingOrderItem.getItemId());
|
|
|
1174 |
pendingOrderItem.setItemName(item.getItemDescription());
|
|
|
1175 |
catalogIds.add(item.getCatalogItemId());
|
| 28339 |
tejbeer |
1176 |
|
| 32251 |
amit.gupta |
1177 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
|
|
1178 |
JSONObject jsonObj = contentMap.get(item.getCatalogItemId());
|
|
|
1179 |
pendingOrderItem.setImgUrl(jsonObj.getString("imageUrl_s"));
|
|
|
1180 |
pendingOrder.setPendingOrderItems(Arrays.asList(pendingOrderItem));
|
|
|
1181 |
CustomerAddress customerAddress = customerAddressRepository.selectById(pendingOrder.getCustomerAddressId());
|
| 28339 |
tejbeer |
1182 |
|
| 32251 |
amit.gupta |
1183 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy h:mm a");
|
| 28339 |
tejbeer |
1184 |
|
| 32251 |
amit.gupta |
1185 |
Map<String, Object> emailModel = new HashMap<>();
|
|
|
1186 |
emailModel.put("customer", customerAddress);
|
|
|
1187 |
emailModel.put("pendingOrder", pendingOrder);
|
|
|
1188 |
emailModel.put("date", dateTimeFormatter);
|
|
|
1189 |
LOGGER.info("emal" + customer.getEmailId());
|
|
|
1190 |
String[] customerEmail = null;
|
|
|
1191 |
if (customer.getEmailId() != null && !customer.getEmailId().isEmpty()) {
|
|
|
1192 |
customerEmail = new String[]{customer.getEmailId()};
|
| 28339 |
tejbeer |
1193 |
|
| 32251 |
amit.gupta |
1194 |
List<String> bccTo = Arrays.asList("tejbeer.kaur@smartdukaan.com");
|
| 28339 |
tejbeer |
1195 |
|
| 32251 |
amit.gupta |
1196 |
emailService.sendMailWithAttachments("Order Cancellation", "order-cancellation.vm", emailModel,
|
|
|
1197 |
customerEmail, null, bccTo.toArray(new String[0]));
|
| 28339 |
tejbeer |
1198 |
|
| 32251 |
amit.gupta |
1199 |
}
|
| 28339 |
tejbeer |
1200 |
|
| 32251 |
amit.gupta |
1201 |
if (!status.contains(OrderStatus.PENDING) && !status.contains(OrderStatus.PROCESSING)
|
|
|
1202 |
&& !status.contains(OrderStatus.BILLED) && !status.contains(OrderStatus.UNSETTLED)
|
|
|
1203 |
&& !status.contains(OrderStatus.CLAIMED)) {
|
|
|
1204 |
pendingOrder.setStatus(OrderStatus.CLOSED);
|
|
|
1205 |
}
|
|
|
1206 |
pendingOrderItemRepository.persist(pendingOrderItem);
|
| 28339 |
tejbeer |
1207 |
|
| 32251 |
amit.gupta |
1208 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 28339 |
tejbeer |
1209 |
|
| 32251 |
amit.gupta |
1210 |
return "response";
|
|
|
1211 |
}
|
| 28339 |
tejbeer |
1212 |
|
| 32251 |
amit.gupta |
1213 |
@RequestMapping(value = "/deliveredPendingOrderItem", method = RequestMethod.POST)
|
|
|
1214 |
public String deliveredPendingOrderItem(HttpServletRequest request, @RequestParam int id, Model model)
|
|
|
1215 |
throws Exception {
|
| 28339 |
tejbeer |
1216 |
|
| 32251 |
amit.gupta |
1217 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1218 |
PendingOrderItem pendingOrderItem = pendingOrderItemRepository.selectById(id);
|
|
|
1219 |
PendingOrder pendingOrder = pendingOrderRepository.selectById(pendingOrderItem.getOrderId());
|
| 30426 |
tejbeer |
1220 |
|
| 32251 |
amit.gupta |
1221 |
if (pendingOrder.getTotalAmount() == pendingOrder.getPaidAmount()) {
|
|
|
1222 |
pendingOrderItem.setStatus(OrderStatus.UNSETTLED);
|
|
|
1223 |
pendingOrderItem.setDeliveredTimestamp(LocalDateTime.now());
|
| 28339 |
tejbeer |
1224 |
|
| 32251 |
amit.gupta |
1225 |
} else {
|
|
|
1226 |
pendingOrderItem.setStatus(OrderStatus.SETTLED);
|
|
|
1227 |
pendingOrderItem.setDeliveredTimestamp(LocalDateTime.now());
|
| 28339 |
tejbeer |
1228 |
|
| 32251 |
amit.gupta |
1229 |
}
|
| 28339 |
tejbeer |
1230 |
|
| 32251 |
amit.gupta |
1231 |
List<OrderStatus> status = pendingOrderItemRepository.selectByOrderId(pendingOrderItem.getOrderId()).stream()
|
|
|
1232 |
.map(x -> x.getStatus()).collect(Collectors.toList());
|
| 28339 |
tejbeer |
1233 |
|
| 32251 |
amit.gupta |
1234 |
List<Integer> catalogIds = new ArrayList<>();
|
| 26647 |
tejbeer |
1235 |
|
| 32251 |
amit.gupta |
1236 |
Item item = itemRepository.selectById(pendingOrderItem.getItemId());
|
|
|
1237 |
pendingOrderItem.setItemName(item.getItemDescription());
|
|
|
1238 |
catalogIds.add(item.getCatalogItemId());
|
| 26721 |
tejbeer |
1239 |
|
| 32251 |
amit.gupta |
1240 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
|
|
1241 |
JSONObject jsonObj = contentMap.get(item.getCatalogItemId());
|
|
|
1242 |
pendingOrderItem.setImgUrl(jsonObj.getString("imageUrl_s"));
|
|
|
1243 |
pendingOrder.setPendingOrderItems(Arrays.asList(pendingOrderItem));
|
|
|
1244 |
CustomerAddress customerAddress = customerAddressRepository.selectById(pendingOrder.getCustomerAddressId());
|
| 27046 |
tejbeer |
1245 |
|
| 32251 |
amit.gupta |
1246 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy h:mm a");
|
| 28352 |
tejbeer |
1247 |
|
| 32251 |
amit.gupta |
1248 |
Map<String, Object> emailModel = new HashMap<>();
|
|
|
1249 |
emailModel.put("customer", customerAddress);
|
|
|
1250 |
emailModel.put("pendingOrder", pendingOrder);
|
|
|
1251 |
emailModel.put("date", dateTimeFormatter);
|
|
|
1252 |
Customer customer = customerRepository.selectById(pendingOrder.getCustomerId());
|
|
|
1253 |
String[] customerEmail = null;
|
|
|
1254 |
if (customer.getEmailId() != null && !customer.getEmailId().isEmpty()) {
|
|
|
1255 |
customerEmail = new String[]{customer.getEmailId()};
|
|
|
1256 |
List<String> bccTo = Arrays.asList("tejbeer.kaur@smartdukaan.com");
|
| 28437 |
tejbeer |
1257 |
|
| 32251 |
amit.gupta |
1258 |
emailService.sendMailWithAttachments("Order Delivered with SmartDukaan", "order-delivered.vm", emailModel,
|
|
|
1259 |
customerEmail, null, bccTo.toArray(new String[0]));
|
| 28437 |
tejbeer |
1260 |
|
| 32251 |
amit.gupta |
1261 |
}
|
|
|
1262 |
if (!status.contains(OrderStatus.PENDING) && !status.contains(OrderStatus.PROCESSING)
|
|
|
1263 |
&& !status.contains(OrderStatus.BILLED) && !status.contains(OrderStatus.UNSETTLED)
|
|
|
1264 |
&& !status.contains(OrderStatus.CLAIMED)) {
|
|
|
1265 |
pendingOrder.setStatus(OrderStatus.CLOSED);
|
|
|
1266 |
}
|
|
|
1267 |
pendingOrderItemRepository.persist(pendingOrderItem);
|
|
|
1268 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 28437 |
tejbeer |
1269 |
|
| 32251 |
amit.gupta |
1270 |
return "response";
|
|
|
1271 |
}
|
| 28437 |
tejbeer |
1272 |
|
| 32251 |
amit.gupta |
1273 |
@RequestMapping(value = "/raiseClaimOrderItem", method = RequestMethod.POST)
|
|
|
1274 |
public String raiseClaimOrderItem(HttpServletRequest request, @RequestParam int id, Model model) throws Exception {
|
| 28437 |
tejbeer |
1275 |
|
| 32251 |
amit.gupta |
1276 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1277 |
PendingOrderItem pendingOrderItem = pendingOrderItemRepository.selectById(id);
|
|
|
1278 |
PendingOrder pendingOrder = pendingOrderRepository.selectById(pendingOrderItem.getOrderId());
|
| 28352 |
tejbeer |
1279 |
|
| 32251 |
amit.gupta |
1280 |
if (pendingOrder.getTotalAmount() == pendingOrder.getPaidAmount()) {
|
|
|
1281 |
pendingOrderItem.setStatus(OrderStatus.CLAIMED);
|
|
|
1282 |
pendingOrderItem.setClaimedTimestamp(LocalDateTime.now());
|
| 26721 |
tejbeer |
1283 |
|
| 32251 |
amit.gupta |
1284 |
}
|
|
|
1285 |
pendingOrderItemRepository.persist(pendingOrderItem);
|
|
|
1286 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 26721 |
tejbeer |
1287 |
|
| 32251 |
amit.gupta |
1288 |
return "response";
|
|
|
1289 |
}
|
| 26721 |
tejbeer |
1290 |
|
| 32251 |
amit.gupta |
1291 |
@RequestMapping(value = "/verifyOrderItem", method = RequestMethod.POST)
|
|
|
1292 |
public String verifyOrderItem(HttpServletRequest request, @RequestParam int id, Model model) throws Exception {
|
| 28352 |
tejbeer |
1293 |
|
| 32251 |
amit.gupta |
1294 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1295 |
PendingOrderItem pendingOrderItem = pendingOrderItemRepository.selectById(id);
|
|
|
1296 |
pendingOrderItem.setVerifiedTimestamp(LocalDateTime.now());
|
| 28352 |
tejbeer |
1297 |
|
| 32251 |
amit.gupta |
1298 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 28352 |
tejbeer |
1299 |
|
| 32251 |
amit.gupta |
1300 |
return "response";
|
|
|
1301 |
}
|
| 28352 |
tejbeer |
1302 |
|
| 32251 |
amit.gupta |
1303 |
@RequestMapping(value = "/cancelOrderByInvoice", method = RequestMethod.POST)
|
|
|
1304 |
public String cancelOrder(HttpServletRequest request, @RequestParam List<String> invoiceNumbers, Model model)
|
|
|
1305 |
throws Exception {
|
|
|
1306 |
orderService.cancelOrder(invoiceNumbers);
|
|
|
1307 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 28352 |
tejbeer |
1308 |
|
| 32251 |
amit.gupta |
1309 |
return "response";
|
|
|
1310 |
}
|
| 28352 |
tejbeer |
1311 |
|
| 32251 |
amit.gupta |
1312 |
@RequestMapping(value = "/getOnlineOrder", method = RequestMethod.GET)
|
|
|
1313 |
public String cancelOrder(HttpServletRequest request, Model model) throws Exception {
|
|
|
1314 |
return "online-order";
|
|
|
1315 |
}
|
| 28356 |
tejbeer |
1316 |
|
| 32251 |
amit.gupta |
1317 |
@GetMapping("/getAllOrdersByStatus")
|
|
|
1318 |
public String getAllOrdersByStatus(HttpServletRequest request, @RequestParam OrderStatus status,
|
|
|
1319 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
1320 |
@RequestParam(required = false) LocalDateTime endTime, Model model) throws ProfitMandiBusinessException {
|
|
|
1321 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1322 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| 28352 |
tejbeer |
1323 |
|
| 32731 |
ranu |
1324 |
LOGGER.info("startTime {}", startTime);
|
|
|
1325 |
LOGGER.info("endTime {}", endTime);
|
| 28352 |
tejbeer |
1326 |
|
| 32697 |
ranu |
1327 |
List<PendingOrderItem> pendingOrderItems;
|
| 32251 |
amit.gupta |
1328 |
if (startTime == null) {
|
| 32697 |
ranu |
1329 |
pendingOrderItems = pendingOrderItemRepository.selectOrderItemByStatus(status);
|
| 32251 |
amit.gupta |
1330 |
} else {
|
|
|
1331 |
List<OrderStatus> statusList = new ArrayList<>();
|
|
|
1332 |
if (status.equals(OrderStatus.DELIVERED)) {
|
|
|
1333 |
statusList.add(OrderStatus.SETTLED);
|
|
|
1334 |
statusList.add(OrderStatus.UNSETTLED);
|
|
|
1335 |
} else {
|
|
|
1336 |
statusList.add(status);
|
|
|
1337 |
}
|
| 32697 |
ranu |
1338 |
pendingOrderItems = pendingOrderItemRepository.selectByStatusAndCreateTimestamp(statusList,
|
| 32251 |
amit.gupta |
1339 |
startTime.toLocalDate().atStartOfDay(), endTime);
|
|
|
1340 |
}
|
| 28339 |
tejbeer |
1341 |
|
| 32697 |
ranu |
1342 |
List<Integer> pendingOrderIds = pendingOrderItems.stream().map(x -> x.getOrderId()).collect(Collectors.toList());
|
|
|
1343 |
|
|
|
1344 |
List<Integer> fofoIds = pendingOrderRepository.selectByIds(pendingOrderIds)
|
|
|
1345 |
.stream().map(x -> x.getFofoId()).distinct().collect(Collectors.toList());
|
|
|
1346 |
|
|
|
1347 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
1348 |
|
|
|
1349 |
Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x))
|
|
|
1350 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
|
|
1351 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
1352 |
model.addAttribute("customRetailersMap", customRetailersMap);
|
|
|
1353 |
|
|
|
1354 |
LOGGER.info("customRetailersMap {}", customRetailersMap);
|
|
|
1355 |
|
|
|
1356 |
Map<String, Object> map = pendingOrderService.getItemOrders(pendingOrderItems, 0);
|
|
|
1357 |
|
| 32750 |
ranu |
1358 |
model.addAttribute("pendingOrderItems", (List<PendingOrderItem>) map.get("pendingOrderItems"));
|
| 32251 |
amit.gupta |
1359 |
model.addAttribute("partnerInventoryMap", map.get("partnerInventoryMap"));
|
| 28339 |
tejbeer |
1360 |
|
| 32251 |
amit.gupta |
1361 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
1362 |
return "online-order-item";
|
|
|
1363 |
}
|
| 28339 |
tejbeer |
1364 |
|
| 32251 |
amit.gupta |
1365 |
@RequestMapping(value = "/franchiseeSalesReport", method = RequestMethod.GET)
|
|
|
1366 |
public String getFranchiseeSalesReport(HttpServletRequest request, Model model)
|
|
|
1367 |
throws ProfitMandiBusinessException {
|
|
|
1368 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 28339 |
tejbeer |
1369 |
|
| 32251 |
amit.gupta |
1370 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1371 |
LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
|
|
|
1372 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoDetails.getFofoId());
|
| 28339 |
tejbeer |
1373 |
|
| 32251 |
amit.gupta |
1374 |
List<FocoSaleReportModel> focoSaleReportList = fofoOrderRepository.selectFocoSaleReport(fofoDetails.getFofoId(),
|
|
|
1375 |
fs.getCode(), currentStartMonth, currentDate);
|
| 28339 |
tejbeer |
1376 |
|
| 32251 |
amit.gupta |
1377 |
LOGGER.info("focoSaleReportList {}", focoSaleReportList);
|
| 28339 |
tejbeer |
1378 |
|
| 32251 |
amit.gupta |
1379 |
model.addAttribute("startDate", currentDate.minusDays(30).toLocalDate());
|
|
|
1380 |
model.addAttribute("endDate", LocalDate.now());
|
|
|
1381 |
model.addAttribute("focoSaleReportList", focoSaleReportList);
|
|
|
1382 |
return "foco-sale-report";
|
|
|
1383 |
}
|
| 28339 |
tejbeer |
1384 |
|
| 32251 |
amit.gupta |
1385 |
@RequestMapping(value = "/downloadFranchiseeSales", method = RequestMethod.GET)
|
|
|
1386 |
public ResponseEntity<?> getdownloadFranchiseeSales(HttpServletRequest request,
|
|
|
1387 |
@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
|
|
|
1388 |
@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
|
|
|
1389 |
throws Exception {
|
|
|
1390 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1391 |
List<List<?>> rows = new ArrayList<>();
|
| 28339 |
tejbeer |
1392 |
|
| 32251 |
amit.gupta |
1393 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoDetails.getFofoId());
|
|
|
1394 |
List<FocoSaleReportModel> focoSaleReportList = fofoOrderRepository.selectFocoSaleReport(fofoDetails.getFofoId(),
|
|
|
1395 |
fs.getCode(), startDate.atStartOfDay(), endDate.atStartOfDay());
|
|
|
1396 |
LOGGER.info("FocoSaleReportList {}", focoSaleReportList);
|
| 28339 |
tejbeer |
1397 |
|
| 32251 |
amit.gupta |
1398 |
for (FocoSaleReportModel fsr : focoSaleReportList) {
|
| 28339 |
tejbeer |
1399 |
|
| 32251 |
amit.gupta |
1400 |
rows.add(Arrays.asList(fsr.getCode(), fsr.getName(), fsr.getCity(), fsr.getState(), fsr.getRegion(),
|
|
|
1401 |
fsr.getItemId(), fsr.getBrand(), fsr.getModelName(), fsr.getModelNumber(), fsr.getColor(),
|
|
|
1402 |
fsr.getQuantity(), fsr.getDp(), fsr.getSellingPrice(), fsr.getMop(), fsr.getSerialNumber(),
|
|
|
1403 |
FormattingUtils.format(fsr.getCreateDate()), fsr.getCustomerName(), fsr.getCustomerPhone(),
|
|
|
1404 |
fsr.getCustomerCity(), fsr.getCustomerPincode(), fsr.getInvoiceNumber(), fsr.getPurchaseReference(),
|
|
|
1405 |
fsr.getCustomerGstNumber(), FormattingUtils.format(fsr.getCancelledTimestamp()),
|
|
|
1406 |
FormattingUtils.format(fsr.getGrnCompleteDate()), fsr.getHygieneRating(), fsr.getRating(),
|
|
|
1407 |
fsr.getStatus(), fsr.getRemark(), FormattingUtils.format(fsr.getCreatedTimestamp()),
|
|
|
1408 |
FormattingUtils.format(fsr.getDisposedTimestamp()),
|
|
|
1409 |
FormattingUtils.format(fsr.getNextTimestamp()),
|
|
|
1410 |
FormattingUtils.format(fsr.getActivationTimestamp()),
|
|
|
1411 |
FormattingUtils.format(fsr.getActivationTimestamp()), fsr.getLabel()));
|
| 28339 |
tejbeer |
1412 |
|
| 32251 |
amit.gupta |
1413 |
}
|
| 28339 |
tejbeer |
1414 |
|
| 32251 |
amit.gupta |
1415 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
|
|
1416 |
Arrays.asList("Code", "Name", "City", "State", "Region", "Item Id", "Brand", "Model Name",
|
|
|
1417 |
"Model Number", "Color", "Quantity", "Dp", "Selling_Price", "mop", "Serial Number",
|
|
|
1418 |
"Create Date", "Customer Name", "Customer Phone", "Customer City", " Customer Pincode",
|
|
|
1419 |
"Invoice Number", "Purchase Reference", "Customer Gst Number", " Cancelled Timestamp",
|
|
|
1420 |
"GRN Complete Date", "Hygiene Rating", "Rating", "Status", "Remark", "Created Timestamp",
|
|
|
1421 |
"Disposed Timestamp", " Next Timestamp", "Activation Timestamp", "Create Timestamp", "Label"),
|
|
|
1422 |
rows);
|
| 28339 |
tejbeer |
1423 |
|
| 32251 |
amit.gupta |
1424 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Franchisee Sales Report");
|
| 28339 |
tejbeer |
1425 |
|
| 32251 |
amit.gupta |
1426 |
return responseEntity;
|
| 28339 |
tejbeer |
1427 |
|
| 32251 |
amit.gupta |
1428 |
}
|
| 28339 |
tejbeer |
1429 |
|
| 32251 |
amit.gupta |
1430 |
@RequestMapping(value = "/downloadWalletSummaryReport", method = RequestMethod.GET)
|
|
|
1431 |
public ResponseEntity<?> getDownloadWalletSummaryReport(HttpServletRequest request,
|
|
|
1432 |
@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
|
|
|
1433 |
@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
|
|
|
1434 |
throws Exception {
|
| 28339 |
tejbeer |
1435 |
|
| 32251 |
amit.gupta |
1436 |
List<List<?>> rows = new ArrayList<>();
|
|
|
1437 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1438 |
List<WalletSummaryReportModel> walletSummartList = fofoOrderRepository.selectWalletSummaryReport(
|
|
|
1439 |
fofoDetails.getFofoId(), startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
|
|
|
1440 |
LOGGER.info("walletSummartList {}", walletSummartList);
|
|
|
1441 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
|
| 28339 |
tejbeer |
1442 |
|
| 32251 |
amit.gupta |
1443 |
for (WalletSummaryReportModel walletSummary : walletSummartList) {
|
| 28344 |
tejbeer |
1444 |
|
| 32251 |
amit.gupta |
1445 |
rows.add(Arrays.asList(walletSummary.getId(), walletSummary.getCode(), walletSummary.getName(),
|
|
|
1446 |
walletSummary.getEmail(), walletSummary.getPhone(), walletSummary.getAmount(),
|
|
|
1447 |
walletSummary.getRefundableAmount(), walletSummary.getReference(), walletSummary.getReferenceType(),
|
|
|
1448 |
FormattingUtils.format(walletSummary.getBusinessTimestamp())));
|
| 28350 |
tejbeer |
1449 |
|
| 32251 |
amit.gupta |
1450 |
}
|
| 28350 |
tejbeer |
1451 |
|
| 32251 |
amit.gupta |
1452 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
|
|
|
1453 |
.getCSVByteStream(Arrays.asList("Id", "Code", "Name", "Email", "Phone", "Amount", "Refundable_amount",
|
|
|
1454 |
"Reference", "Reference_type", "Business_timestamp", "Description"), rows);
|
| 28344 |
tejbeer |
1455 |
|
| 32251 |
amit.gupta |
1456 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Wallet Statement Report");
|
| 27819 |
tejbeer |
1457 |
|
| 32251 |
amit.gupta |
1458 |
return responseEntity;
|
| 27819 |
tejbeer |
1459 |
|
| 32251 |
amit.gupta |
1460 |
}
|
| 28358 |
tejbeer |
1461 |
|
| 32251 |
amit.gupta |
1462 |
@RequestMapping(value = "/walletSummaryReport", method = RequestMethod.GET)
|
|
|
1463 |
public String getWalletSummaryReport(HttpServletRequest request, Model model) throws Exception {
|
|
|
1464 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 28358 |
tejbeer |
1465 |
|
| 32251 |
amit.gupta |
1466 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1467 |
LocalDateTime currentStartMonth = currentDate.minusDays(30).toLocalDate().atStartOfDay();
|
| 28420 |
tejbeer |
1468 |
|
| 32251 |
amit.gupta |
1469 |
List<WalletSummaryReportModel> walletSummartList = fofoOrderRepository
|
|
|
1470 |
.selectWalletSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
|
|
|
1471 |
LOGGER.info("walletSummartList {}", walletSummartList);
|
| 28420 |
tejbeer |
1472 |
|
| 32251 |
amit.gupta |
1473 |
model.addAttribute("startDate", currentDate.minusDays(30).toLocalDate());
|
|
|
1474 |
model.addAttribute("endDate", LocalDate.now());
|
|
|
1475 |
model.addAttribute("walletSummartList", walletSummartList);
|
| 28358 |
tejbeer |
1476 |
|
| 32251 |
amit.gupta |
1477 |
return "wallet-summary-report";
|
|
|
1478 |
}
|
| 30426 |
tejbeer |
1479 |
|
| 32251 |
amit.gupta |
1480 |
@RequestMapping(value = "/pendingIndentReport", method = RequestMethod.GET)
|
|
|
1481 |
public String getPendingIndentReport(HttpServletRequest request, Model model) throws Exception {
|
|
|
1482 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 28358 |
tejbeer |
1483 |
|
| 32251 |
amit.gupta |
1484 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1485 |
LocalDateTime currentStartMonth = currentDate.minusMonths(2).toLocalDate().atStartOfDay();
|
| 28358 |
tejbeer |
1486 |
|
| 32251 |
amit.gupta |
1487 |
List<PendingIndentReportModel> pendingIndentReports = fofoOrderRepository
|
|
|
1488 |
.selectPendingIndentReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
|
|
|
1489 |
LOGGER.info("pendingIndentReports {}", pendingIndentReports);
|
| 28358 |
tejbeer |
1490 |
|
| 32251 |
amit.gupta |
1491 |
model.addAttribute("startDate", currentDate.minusMonths(2).toLocalDate());
|
|
|
1492 |
model.addAttribute("endDate", LocalDate.now());
|
|
|
1493 |
model.addAttribute("pendingIndentReports", pendingIndentReports);
|
| 30426 |
tejbeer |
1494 |
|
| 32251 |
amit.gupta |
1495 |
return "pending-indent-report";
|
|
|
1496 |
}
|
| 30426 |
tejbeer |
1497 |
|
| 32251 |
amit.gupta |
1498 |
@RequestMapping(value = "/pendingIndentReportDownload", method = RequestMethod.GET)
|
|
|
1499 |
public ResponseEntity<?> getPendingIndentReportDownload(HttpServletRequest request, Model model) throws Exception {
|
|
|
1500 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1501 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1502 |
LocalDateTime currentStartMonth = currentDate.minusMonths(2).toLocalDate().atStartOfDay();
|
|
|
1503 |
List<List<?>> rows = new ArrayList<>();
|
|
|
1504 |
List<PendingIndentReportModel> pendingIndentReports = fofoOrderRepository
|
|
|
1505 |
.selectPendingIndentReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
|
|
|
1506 |
LOGGER.info("pendingIndentReports {}", pendingIndentReports);
|
|
|
1507 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
|
| 28377 |
tejbeer |
1508 |
|
| 32251 |
amit.gupta |
1509 |
for (PendingIndentReportModel pir : pendingIndentReports) {
|
| 30426 |
tejbeer |
1510 |
|
| 32251 |
amit.gupta |
1511 |
rows.add(Arrays.asList(pir.getTransactionId(), pir.getOrderId(),
|
|
|
1512 |
pir.getCreatTimestamp().format(dateTimeFormatter), pir.getItemId(), pir.getBrand(),
|
|
|
1513 |
pir.getModelName(), pir.getModelNumber(), pir.getColor(), pir.getQuantity(), pir.getUnitPrice(),
|
|
|
1514 |
pir.getWalletAmount(), pir.getStatus(), pir.getInvoiceNumber(),
|
|
|
1515 |
pir.getBillingTimestamp().format(dateTimeFormatter)));
|
| 30426 |
tejbeer |
1516 |
|
| 32251 |
amit.gupta |
1517 |
}
|
| 30426 |
tejbeer |
1518 |
|
| 32251 |
amit.gupta |
1519 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(Arrays.asList(
|
|
|
1520 |
"Transaction Id", "Order Id", "Created_At", "Item_Id", "Brand", "Model Name", "Model Number", "Color",
|
|
|
1521 |
"Quantity", "Unit Price", "Wallet Deduction", "Status", "Invoice Number", "Billing Timestamp"), rows);
|
| 30162 |
manish |
1522 |
|
| 32251 |
amit.gupta |
1523 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Order Status Summary Report");
|
| 31384 |
tejbeer |
1524 |
|
| 32251 |
amit.gupta |
1525 |
return responseEntity;
|
|
|
1526 |
}
|
| 30162 |
manish |
1527 |
|
| 32251 |
amit.gupta |
1528 |
@RequestMapping(value = "/schemePayoutReport", method = RequestMethod.GET)
|
|
|
1529 |
public String getSchemePayoutReport(HttpServletRequest request, Model model) throws Exception {
|
|
|
1530 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 30162 |
manish |
1531 |
|
| 32251 |
amit.gupta |
1532 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1533 |
LocalDateTime startDate = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
|
| 30162 |
manish |
1534 |
|
| 32251 |
amit.gupta |
1535 |
List<SchemePayoutReportModel> schemePayoutReports = fofoOrderRepository
|
|
|
1536 |
.selectSchemePayoutReport(fofoDetails.getFofoId(), startDate, currentDate);
|
|
|
1537 |
LOGGER.info("schemePayoutReports {}", schemePayoutReports);
|
| 30162 |
manish |
1538 |
|
| 32251 |
amit.gupta |
1539 |
model.addAttribute("startDate", currentDate.minusMonths(3).toLocalDate());
|
|
|
1540 |
model.addAttribute("endDate", LocalDate.now());
|
|
|
1541 |
model.addAttribute("schemePayoutReports", schemePayoutReports);
|
| 30162 |
manish |
1542 |
|
| 32251 |
amit.gupta |
1543 |
return "scheme-payout-report";
|
|
|
1544 |
}
|
| 30162 |
manish |
1545 |
|
| 32251 |
amit.gupta |
1546 |
@RequestMapping(value = "/selectPartnerBillingSummaryReport", method = RequestMethod.GET)
|
|
|
1547 |
public String getselectPartnerBillingSummaryReport(HttpServletRequest request, Model model) throws Exception {
|
|
|
1548 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 30426 |
tejbeer |
1549 |
|
| 32251 |
amit.gupta |
1550 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1551 |
LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
|
| 30162 |
manish |
1552 |
|
| 32251 |
amit.gupta |
1553 |
List<PartnerBillingSummaryModel> partnerBillingSummaryReports = fofoOrderRepository
|
|
|
1554 |
.selectPartnerBillingSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
|
| 30162 |
manish |
1555 |
|
| 32251 |
amit.gupta |
1556 |
model.addAttribute("startDate", currentDate.minusMonths(3).toLocalDate());
|
|
|
1557 |
model.addAttribute("endDate", LocalDate.now());
|
|
|
1558 |
model.addAttribute("partnerBillingSummaryReports", partnerBillingSummaryReports);
|
| 30162 |
manish |
1559 |
|
| 32251 |
amit.gupta |
1560 |
return "partner-billing-summary-report";
|
|
|
1561 |
}
|
| 30162 |
manish |
1562 |
|
| 32251 |
amit.gupta |
1563 |
@RequestMapping(value = "/priceDropReport", method = RequestMethod.GET)
|
|
|
1564 |
public String getSelectPriceDropReport(HttpServletRequest request, Model model) throws Exception {
|
|
|
1565 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 30162 |
manish |
1566 |
|
| 32251 |
amit.gupta |
1567 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1568 |
LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
|
| 30162 |
manish |
1569 |
|
| 32251 |
amit.gupta |
1570 |
List<PriceDropReportModel> priceDropReports = orderRepository.selectPriceDropReport(fofoDetails.getFofoId(),
|
|
|
1571 |
currentStartMonth, currentDate);
|
| 30162 |
manish |
1572 |
|
| 32251 |
amit.gupta |
1573 |
model.addAttribute("startDate", currentDate.minusMonths(3).toLocalDate());
|
|
|
1574 |
model.addAttribute("endDate", LocalDate.now());
|
|
|
1575 |
model.addAttribute("priceDropReports", priceDropReports);
|
| 30162 |
manish |
1576 |
|
| 32251 |
amit.gupta |
1577 |
return "price-drop-report";
|
|
|
1578 |
}
|
| 30426 |
tejbeer |
1579 |
|
| 32251 |
amit.gupta |
1580 |
@RequestMapping(value = "/downloadPriceDropReport", method = RequestMethod.GET)
|
|
|
1581 |
public ResponseEntity<?> getSelectDownloadPriceDropReport(HttpServletRequest request,
|
|
|
1582 |
@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
|
|
|
1583 |
@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
|
|
|
1584 |
throws Exception {
|
|
|
1585 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 30162 |
manish |
1586 |
|
| 32251 |
amit.gupta |
1587 |
List<List<?>> rows = new ArrayList<>();
|
|
|
1588 |
List<PriceDropReportModel> priceDropReports = orderRepository.selectPriceDropReport(fofoDetails.getFofoId(),
|
|
|
1589 |
startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
|
| 30426 |
tejbeer |
1590 |
|
| 32251 |
amit.gupta |
1591 |
for (PriceDropReportModel pdr : priceDropReports) {
|
| 30426 |
tejbeer |
1592 |
|
| 32251 |
amit.gupta |
1593 |
rows.add(Arrays.asList(pdr.getCode(), pdr.getId(), pdr.getBrand(), pdr.getModelName(), pdr.getModelNumber(),
|
|
|
1594 |
pdr.getAffectedOn(), pdr.getAmount(), pdr.getPartnerPayout(), pdr.getImei(), pdr.getStatus(),
|
|
|
1595 |
pdr.getUpdateTimestamp(), pdr.getRejectionReason()));
|
| 30426 |
tejbeer |
1596 |
|
| 32251 |
amit.gupta |
1597 |
}
|
|
|
1598 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
|
|
|
1599 |
.getCSVByteStream(Arrays.asList("code", "Price_Drop_Id", "brand", "model_name", "model_number",
|
|
|
1600 |
"affected_on", "amount", "partner_payout", "Imei", "status", "processed_on", "Reason"), rows);
|
| 30426 |
tejbeer |
1601 |
|
| 32251 |
amit.gupta |
1602 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "price drop report");
|
| 30162 |
manish |
1603 |
|
| 32251 |
amit.gupta |
1604 |
return responseEntity;
|
| 30426 |
tejbeer |
1605 |
|
| 32251 |
amit.gupta |
1606 |
}
|
| 30426 |
tejbeer |
1607 |
|
| 32251 |
amit.gupta |
1608 |
@RequestMapping(value = "/downloadPartnerBillingSummaryReport", method = RequestMethod.GET)
|
|
|
1609 |
public ResponseEntity<?> getdownloadPartnerBillingSummaryReport(HttpServletRequest request,
|
|
|
1610 |
@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
|
|
|
1611 |
@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
|
|
|
1612 |
throws Exception {
|
| 30426 |
tejbeer |
1613 |
|
| 32251 |
amit.gupta |
1614 |
List<List<?>> rows = new ArrayList<>();
|
|
|
1615 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 30426 |
tejbeer |
1616 |
|
| 32251 |
amit.gupta |
1617 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1618 |
LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
|
| 30162 |
manish |
1619 |
|
| 32251 |
amit.gupta |
1620 |
List<PartnerBillingSummaryModel> partnerBillingSummaryReports = fofoOrderRepository
|
|
|
1621 |
.selectPartnerBillingSummaryReport(fofoDetails.getFofoId(), startDate.atStartOfDay(),
|
|
|
1622 |
endDate.atTime(LocalTime.MAX));
|
| 30426 |
tejbeer |
1623 |
|
| 32251 |
amit.gupta |
1624 |
for (PartnerBillingSummaryModel pbsr : partnerBillingSummaryReports) {
|
| 30426 |
tejbeer |
1625 |
|
| 32251 |
amit.gupta |
1626 |
rows.add(Arrays.asList(pbsr.getId(),
|
|
|
1627 |
FormattingUtils.format(pbsr.getCreateTimestamp()),
|
|
|
1628 |
FormattingUtils.format(pbsr.getBillingTimestamp()),
|
|
|
1629 |
FormattingUtils.format(pbsr.getDeliveryTimestamp()),
|
|
|
1630 |
FormattingUtils.format(pbsr.getPartnerGrnTimestamp()),
|
|
|
1631 |
pbsr.getTransactionId(),
|
|
|
1632 |
pbsr.getLogisticsTransactionId(), pbsr.getAirwayBillNumber(), pbsr.getStatusSubGroup(),
|
|
|
1633 |
pbsr.getStatusName(), pbsr.getRetailerId(), pbsr.getRetailerName(), pbsr.getItemId(),
|
|
|
1634 |
pbsr.getBrand(), pbsr.getModelName(), pbsr.getModelNumber(), pbsr.getColor(), pbsr.getUnitPrice(),
|
|
|
1635 |
pbsr.getQuantity(), pbsr.getTotalPrice(), pbsr.getInvoiceNumber(), pbsr.getIgstRate(),
|
|
|
1636 |
pbsr.getCgstRate(), pbsr.getSgstRate()));
|
| 30162 |
manish |
1637 |
|
| 32251 |
amit.gupta |
1638 |
}
|
| 30426 |
tejbeer |
1639 |
|
| 32251 |
amit.gupta |
1640 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(Arrays.asList("OrderId",
|
|
|
1641 |
"Created On", "Billed On", "Delivered On", "Grned On", "Transaction_id", "master_order_id",
|
|
|
1642 |
"airwaybill_no", "statusSubGroupp", "statusName", "customer_id", "customer_name", "Item_Id", "brand",
|
|
|
1643 |
"model_name", "model_number", "color", "selling_price", "Quantity", "total_price", "invoice_number",
|
|
|
1644 |
"igstrate", "cgstrate", "sgstrate"), rows);
|
| 30426 |
tejbeer |
1645 |
|
| 32251 |
amit.gupta |
1646 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Billing Statement Report");
|
| 30426 |
tejbeer |
1647 |
|
| 32251 |
amit.gupta |
1648 |
return responseEntity;
|
| 30162 |
manish |
1649 |
|
| 32251 |
amit.gupta |
1650 |
}
|
| 30426 |
tejbeer |
1651 |
|
| 32251 |
amit.gupta |
1652 |
@RequestMapping(value = "/invoiceSchemeOutSummaryReport", method = RequestMethod.GET)
|
|
|
1653 |
public String getInvoiceSchemeOutSummaryReport(HttpServletRequest request, Model model) throws Exception {
|
|
|
1654 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 30426 |
tejbeer |
1655 |
|
| 32251 |
amit.gupta |
1656 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1657 |
LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
|
| 30426 |
tejbeer |
1658 |
|
| 32251 |
amit.gupta |
1659 |
List<FocoSchemeOutReportModel> focoSchemeOutReports = fofoOrderRepository
|
|
|
1660 |
.selectInvoiceSchemeOutSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
|
|
|
1661 |
LOGGER.info("focoSchemeOutReportModel {}", focoSchemeOutReports);
|
| 30426 |
tejbeer |
1662 |
|
| 32251 |
amit.gupta |
1663 |
model.addAttribute("startDate", currentDate.minusMonths(3).toLocalDate());
|
|
|
1664 |
model.addAttribute("endDate", LocalDate.now());
|
|
|
1665 |
model.addAttribute("focoSchemeOutReports", focoSchemeOutReports);
|
| 30426 |
tejbeer |
1666 |
|
| 32251 |
amit.gupta |
1667 |
return "invoicewise-scheme-out-report";
|
|
|
1668 |
}
|
| 30426 |
tejbeer |
1669 |
|
| 32251 |
amit.gupta |
1670 |
@RequestMapping(value = "/downloadInvoiceSchemeOutSummaryReport", method = RequestMethod.GET)
|
|
|
1671 |
public ResponseEntity<?> getDownloadInvoiceSchemeOutSummaryReport(HttpServletRequest request, Model model)
|
|
|
1672 |
throws Exception {
|
|
|
1673 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 30426 |
tejbeer |
1674 |
|
| 32251 |
amit.gupta |
1675 |
List<List<?>> rows = new ArrayList<>();
|
|
|
1676 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1677 |
LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
|
| 30426 |
tejbeer |
1678 |
|
| 32251 |
amit.gupta |
1679 |
List<FocoSchemeOutReportModel> focoSchemeOutReports = fofoOrderRepository
|
|
|
1680 |
.selectInvoiceSchemeOutSummaryReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
|
|
|
1681 |
LOGGER.info("focoSchemeOutReportModel {}", focoSchemeOutReports);
|
| 30426 |
tejbeer |
1682 |
|
| 32251 |
amit.gupta |
1683 |
for (FocoSchemeOutReportModel fsor : focoSchemeOutReports) {
|
|
|
1684 |
rows.add(Arrays.asList(fsor.getInvoiceNumber(), fsor.getQuantity(), fsor.getBrand(), fsor.getModelName(),
|
|
|
1685 |
fsor.getModelNumber(), fsor.getColor(), fsor.getAmount()));
|
| 30426 |
tejbeer |
1686 |
|
| 32251 |
amit.gupta |
1687 |
}
|
| 30426 |
tejbeer |
1688 |
|
| 32251 |
amit.gupta |
1689 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
|
|
1690 |
Arrays.asList("InvoiceNumber", "Quantity", "Brand", "Model Name", "Model Number", "Color", "Amount"),
|
|
|
1691 |
rows);
|
| 30426 |
tejbeer |
1692 |
|
| 32251 |
amit.gupta |
1693 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows,
|
|
|
1694 |
"invoice wise scheme out Summary Report");
|
| 30426 |
tejbeer |
1695 |
|
| 32251 |
amit.gupta |
1696 |
return responseEntity;
|
|
|
1697 |
}
|
| 30426 |
tejbeer |
1698 |
|
| 32251 |
amit.gupta |
1699 |
@RequestMapping(value = "/schemePayoutReportDownload", method = RequestMethod.GET)
|
|
|
1700 |
public ResponseEntity<?> getSchemePayoutReportDownload(HttpServletRequest request,
|
|
|
1701 |
@RequestParam(name = "startDate", required = true, defaultValue = "") LocalDate startDate,
|
|
|
1702 |
@RequestParam(name = "endDate", required = true, defaultValue = "") LocalDate endDate, Model model)
|
|
|
1703 |
throws Exception {
|
|
|
1704 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 30426 |
tejbeer |
1705 |
|
| 32251 |
amit.gupta |
1706 |
List<List<?>> rows = new ArrayList<>();
|
|
|
1707 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
1708 |
LocalDateTime currentStartMonth = currentDate.minusMonths(3).toLocalDate().atStartOfDay();
|
| 30162 |
manish |
1709 |
|
| 32251 |
amit.gupta |
1710 |
List<SchemePayoutReportModel> schemePayoutReports = fofoOrderRepository
|
|
|
1711 |
.selectSchemePayoutReport(fofoDetails.getFofoId(), currentStartMonth, currentDate);
|
|
|
1712 |
LOGGER.info("schemePayoutReports {}", schemePayoutReports);
|
| 30426 |
tejbeer |
1713 |
|
| 32251 |
amit.gupta |
1714 |
for (SchemePayoutReportModel spr : schemePayoutReports) {
|
| 30426 |
tejbeer |
1715 |
|
| 32251 |
amit.gupta |
1716 |
rows.add(Arrays.asList(spr.getId(), spr.getSerialNumber(), spr.getBrand(), spr.getModelName(),
|
|
|
1717 |
spr.getModelNumber(), spr.getColor(), spr.getSchemeInDp(), spr.getSchemeOutDp(), spr.getSchemeId(),
|
|
|
1718 |
spr.getName(), spr.getType(), spr.getAmountType(), spr.getPurchaseReference(),
|
|
|
1719 |
spr.getInvoiceNumber(), spr.getSioAmount(), spr.getStatus(), spr.getStatusDescription(),
|
|
|
1720 |
spr.getCreateTimestamp(), spr.getRolledBackTimestamp()));
|
| 30162 |
manish |
1721 |
|
| 32251 |
amit.gupta |
1722 |
}
|
|
|
1723 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(Arrays.asList("Item_Id",
|
|
|
1724 |
"serial_number", "Brand", "Model Name", "Model Number", "Color", "Scheme_IN_DP", "Scheme_out_dp",
|
|
|
1725 |
"Scheme_Id", "Name", "Type", "amount", "Purchase_Invoice", "SALE_INOVOICE", "Amount", "status",
|
|
|
1726 |
"description", "create_timestamp", "rolled_back_timestamp"), rows);
|
| 30162 |
manish |
1727 |
|
| 32251 |
amit.gupta |
1728 |
ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Scheme Payout Summary Report");
|
| 30426 |
tejbeer |
1729 |
|
| 32251 |
amit.gupta |
1730 |
return responseEntity;
|
|
|
1731 |
}
|
| 30426 |
tejbeer |
1732 |
|
| 32251 |
amit.gupta |
1733 |
@GetMapping("/getAllOnlineOrder")
|
|
|
1734 |
public String getAllOrders(HttpServletRequest request, @RequestParam(required = false) LocalDate date, Model model)
|
|
|
1735 |
throws ProfitMandiBusinessException {
|
|
|
1736 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1737 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
1738 |
if (date == null) {
|
|
|
1739 |
date = LocalDate.now().minusDays(3);
|
|
|
1740 |
}
|
| 30177 |
manish |
1741 |
|
| 32251 |
amit.gupta |
1742 |
LOGGER.info("date" + date);
|
|
|
1743 |
List<Integer> fofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId())
|
|
|
1744 |
.collect(Collectors.toList());
|
| 30426 |
tejbeer |
1745 |
|
| 32251 |
amit.gupta |
1746 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 30426 |
tejbeer |
1747 |
|
| 32251 |
amit.gupta |
1748 |
Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x))
|
|
|
1749 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
|
|
1750 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 30426 |
tejbeer |
1751 |
|
| 32251 |
amit.gupta |
1752 |
model.addAttribute("customRetailersMap", customRetailersMap);
|
| 30177 |
manish |
1753 |
|
| 32251 |
amit.gupta |
1754 |
List<PendingOrderItem> pendingOrderItem = null;
|
| 30426 |
tejbeer |
1755 |
|
| 32251 |
amit.gupta |
1756 |
pendingOrderItem = pendingOrderItemRepository.selectAll(date.atStartOfDay(), LocalDateTime.now());
|
| 30177 |
manish |
1757 |
|
| 32251 |
amit.gupta |
1758 |
Map<String, Object> map = pendingOrderService.getItemOrders(pendingOrderItem, 0);
|
| 30177 |
manish |
1759 |
|
| 32251 |
amit.gupta |
1760 |
model.addAttribute("pendingOrderItem", map.get("pendingOrderItem"));
|
|
|
1761 |
model.addAttribute("partnerInventoryMap", map.get("partnerInventoryMap"));
|
|
|
1762 |
model.addAttribute("date", date);
|
|
|
1763 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
1764 |
return "online-all-order-item";
|
|
|
1765 |
}
|
| 32409 |
amit.gupta |
1766 |
}
|
| 32405 |
jai.hind |
1767 |
|
|
|
1768 |
|
|
|
1769 |
|
|
|
1770 |
|
|
|
1771 |
|