| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDate;
|
- |
|
| 4 |
import java.time.LocalDateTime;
|
- |
|
| 5 |
import java.time.LocalTime;
|
- |
|
| 6 |
import java.util.ArrayList;
|
- |
|
| 7 |
import java.util.Arrays;
|
- |
|
| 8 |
import java.util.Collections;
|
- |
|
| 9 |
import java.util.Comparator;
|
- |
|
| 10 |
import java.util.HashMap;
|
- |
|
| 11 |
import java.util.HashSet;
|
- |
|
| 12 |
import java.util.Iterator;
|
- |
|
| 13 |
import java.util.List;
|
- |
|
| 14 |
import java.util.Map;
|
- |
|
| 15 |
import java.util.Map.Entry;
|
- |
|
| 16 |
import java.util.Optional;
|
- |
|
| 17 |
import java.util.Set;
|
- |
|
| 18 |
import java.util.function.Function;
|
- |
|
| 19 |
import java.util.stream.Collectors;
|
- |
|
| 20 |
|
- |
|
| 21 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 22 |
|
- |
|
| 23 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
- |
|
| 24 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 25 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 26 |
import org.apache.thrift.TException;
|
- |
|
| 27 |
import org.json.JSONArray;
|
- |
|
| 28 |
import org.json.JSONObject;
|
- |
|
| 29 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 30 |
import org.springframework.core.io.ByteArrayResource;
|
- |
|
| 31 |
import org.springframework.http.HttpHeaders;
|
- |
|
| 32 |
import org.springframework.http.HttpStatus;
|
- |
|
| 33 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 34 |
import org.springframework.mail.javamail.JavaMailSender;
|
- |
|
| 35 |
import org.springframework.stereotype.Controller;
|
- |
|
| 36 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 37 |
import org.springframework.ui.Model;
|
- |
|
| 38 |
import org.springframework.web.bind.annotation.RequestBody;
|
- |
|
| 39 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 40 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 41 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 42 |
|
- |
|
| 43 |
import com.mongodb.DBObject;
|
3 |
import com.mongodb.DBObject;
|
| 44 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
4 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
| 45 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
5 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 46 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 47 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
- |
|
| 48 |
import com.spice.profitmandi.common.model.CatalogListingModel;
|
- |
|
| 49 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
- |
|
| 50 |
import com.spice.profitmandi.common.model.FocusedModelShortageModel;
|
- |
|
| 51 |
import com.spice.profitmandi.common.model.IntegerIdAggregateValue;
|
- |
|
| 52 |
import com.spice.profitmandi.common.model.PlannedModel;
|
7 |
import com.spice.profitmandi.common.model.*;
|
| 53 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
- |
|
| 54 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
- |
|
| 55 |
import com.spice.profitmandi.common.model.StockAllocationModel;
|
- |
|
| 56 |
import com.spice.profitmandi.common.model.SuggestedPoIdModel;
|
- |
|
| 57 |
import com.spice.profitmandi.common.model.SuggestedPoModel;
|
- |
|
| 58 |
import com.spice.profitmandi.common.util.FileUtil;
|
8 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 59 |
import com.spice.profitmandi.common.util.Utils;
|
9 |
import com.spice.profitmandi.common.util.Utils;
|
| 60 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
10 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
| 61 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
11 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 62 |
import com.spice.profitmandi.dao.entity.catalog.Category;
|
12 |
import com.spice.profitmandi.dao.entity.catalog.Category;
|
| 63 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
|
13 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
|
| 64 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
14 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 65 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
15 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 66 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
16 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 67 |
import com.spice.profitmandi.dao.entity.cs.Region;
|
17 |
import com.spice.profitmandi.dao.entity.cs.Region;
|
| 68 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
- |
|
| 69 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
- |
|
| 70 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
18 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 71 |
import com.spice.profitmandi.dao.entity.fofo.MonthlyPlanned;
|
- |
|
| 72 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
- |
|
| 73 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
- |
|
| 74 |
import com.spice.profitmandi.dao.entity.fofo.PlannedDetail;
|
- |
|
| 75 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPo;
|
- |
|
| 76 |
import com.spice.profitmandi.dao.entity.fofo.SuggestedPoDetail;
|
- |
|
| 77 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
19 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
| 78 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
20 |
import com.spice.profitmandi.dao.entity.inventory.SaholicPOItem;
|
| 79 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
21 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 80 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
22 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 81 |
import com.spice.profitmandi.dao.entity.user.User;
|
23 |
import com.spice.profitmandi.dao.entity.user.User;
|
| - |
|
24 |
import com.spice.profitmandi.dao.entity.warehouse.BrandRegionMapping;
|
| 82 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
25 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 83 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
26 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
| 84 |
import com.spice.profitmandi.dao.model.InStockAccessoriesTvFofoIdModel;
|
27 |
import com.spice.profitmandi.dao.model.InStockAccessoriesTvFofoIdModel;
|
| 85 |
import com.spice.profitmandi.dao.model.InStockBrandFofoIdModel;
|
28 |
import com.spice.profitmandi.dao.model.InStockBrandFofoIdModel;
|
| 86 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
29 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| Line 93... |
Line 36... |
| 93 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
36 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 94 |
import com.spice.profitmandi.dao.repository.cs.RegionRepository;
|
37 |
import com.spice.profitmandi.dao.repository.cs.RegionRepository;
|
| 95 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
38 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 96 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
39 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 97 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
40 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 98 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
- |
|
| 99 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
- |
|
| 100 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
- |
|
| 101 |
import com.spice.profitmandi.dao.repository.fofo.MonthlyPlannedRepository;
|
- |
|
| 102 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
- |
|
| 103 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
- |
|
| 104 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
- |
|
| 105 |
import com.spice.profitmandi.dao.repository.fofo.PlannedDetailRepository;
|
- |
|
| 106 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
41 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 107 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoDetailRepository;
|
- |
|
| 108 |
import com.spice.profitmandi.dao.repository.fofo.SuggestedPoRepository;
|
- |
|
| 109 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
42 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
| - |
|
43 |
import com.spice.profitmandi.dao.repository.inventory.WarehouseRepository;
|
| 110 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
44 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 111 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
45 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 112 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
46 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| - |
|
47 |
import com.spice.profitmandi.dao.repository.warehouse.BrandRegionMappingRepository;
|
| 113 |
import com.spice.profitmandi.service.NotificationService;
|
48 |
import com.spice.profitmandi.service.NotificationService;
|
| 114 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
49 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 115 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
50 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 116 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
51 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
| 117 |
import com.spice.profitmandi.service.inventory.StockAllocationService;
|
52 |
import com.spice.profitmandi.service.inventory.StockAllocationService;
|
| Line 121... |
Line 56... |
| 121 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
56 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
| 122 |
import com.spice.profitmandi.thrift.clients.UserClient;
|
57 |
import com.spice.profitmandi.thrift.clients.UserClient;
|
| 123 |
import com.spice.profitmandi.web.model.LoginDetails;
|
58 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 124 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
59 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 125 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
60 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 126 |
|
- |
|
| 127 |
import in.shop2020.logistics.PickUpType;
|
61 |
import in.shop2020.logistics.PickUpType;
|
| 128 |
|
- |
|
| 129 |
import in.shop2020.model.v1.order.LineItem;
|
62 |
import in.shop2020.model.v1.order.*;
|
| 130 |
import in.shop2020.model.v1.order.OrderSource;
|
- |
|
| 131 |
import in.shop2020.model.v1.order.OrderStatus;
|
- |
|
| 132 |
import in.shop2020.model.v1.order.OrderType;
|
- |
|
| 133 |
import in.shop2020.model.v1.order.Transaction;
|
- |
|
| 134 |
import in.shop2020.model.v1.order.TransactionService;
|
- |
|
| 135 |
import in.shop2020.model.v1.order.TransactionStatus;
|
- |
|
| 136 |
import in.shop2020.model.v1.user.ItemPriceQuantity;
|
63 |
import in.shop2020.model.v1.user.ItemPriceQuantity;
|
| 137 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
64 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
| 138 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
65 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
| 139 |
import in.shop2020.payments.Attribute;
|
66 |
import in.shop2020.payments.Attribute;
|
| 140 |
import in.shop2020.payments.PaymentException;
|
67 |
import in.shop2020.payments.PaymentException;
|
| 141 |
import in.shop2020.payments.PaymentStatus;
|
68 |
import in.shop2020.payments.PaymentStatus;
|
| - |
|
69 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| - |
|
70 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
71 |
import org.apache.logging.log4j.Logger;
|
| - |
|
72 |
import org.apache.thrift.TException;
|
| - |
|
73 |
import org.json.JSONArray;
|
| - |
|
74 |
import org.json.JSONObject;
|
| - |
|
75 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
76 |
import org.springframework.core.io.ByteArrayResource;
|
| - |
|
77 |
import org.springframework.http.HttpHeaders;
|
| - |
|
78 |
import org.springframework.http.HttpStatus;
|
| - |
|
79 |
import org.springframework.http.ResponseEntity;
|
| - |
|
80 |
import org.springframework.mail.javamail.JavaMailSender;
|
| - |
|
81 |
import org.springframework.stereotype.Controller;
|
| - |
|
82 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
83 |
import org.springframework.ui.Model;
|
| - |
|
84 |
import org.springframework.web.bind.annotation.RequestBody;
|
| - |
|
85 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| - |
|
86 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
87 |
import org.springframework.web.bind.annotation.RequestParam;
|
| - |
|
88 |
|
| - |
|
89 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
90 |
import java.time.LocalDate;
|
| - |
|
91 |
import java.time.LocalDateTime;
|
| - |
|
92 |
import java.time.LocalTime;
|
| - |
|
93 |
import java.util.*;
|
| - |
|
94 |
import java.util.Map.Entry;
|
| - |
|
95 |
import java.util.function.Function;
|
| - |
|
96 |
import java.util.stream.Collectors;
|
| 142 |
|
97 |
|
| 143 |
@Controller
|
98 |
@Controller
|
| 144 |
@Transactional(rollbackFor = Throwable.class)
|
99 |
@Transactional(rollbackFor = Throwable.class)
|
| 145 |
public class IndentController {
|
100 |
public class IndentController {
|
| 146 |
|
101 |
|
| Line 154... |
Line 109... |
| 154 |
OrderStatus.REACHED_DESTINATION_CITY);
|
109 |
OrderStatus.REACHED_DESTINATION_CITY);
|
| 155 |
|
110 |
|
| 156 |
private static final int PLANNING_OPEN_DAY = 20;
|
111 |
private static final int PLANNING_OPEN_DAY = 20;
|
| 157 |
private static final int PLANNING_CLOSE_DAY = 1;
|
112 |
private static final int PLANNING_CLOSE_DAY = 1;
|
| 158 |
|
113 |
|
| - |
|
114 |
private static final String PO_TITLE_STRING = "Alert - Stock Arriving at SD Warehouse";
|
| - |
|
115 |
|
| 159 |
@Autowired
|
116 |
@Autowired
|
| 160 |
WalletService walletService;
|
117 |
WalletService walletService;
|
| 161 |
|
118 |
|
| 162 |
@Autowired
|
119 |
@Autowired
|
| - |
|
120 |
BrandRegionMappingRepository brandRegionMappingRepository;
|
| - |
|
121 |
|
| - |
|
122 |
@Autowired
|
| 163 |
private JavaMailSender googleMailSender;
|
123 |
private JavaMailSender googleMailSender;
|
| 164 |
|
124 |
|
| 165 |
@Autowired
|
125 |
@Autowired
|
| 166 |
private CookiesProcessor cookiesProcessor;
|
126 |
private CookiesProcessor cookiesProcessor;
|
| 167 |
|
127 |
|
| Line 231... |
Line 191... |
| 231 |
@Autowired
|
191 |
@Autowired
|
| 232 |
private CsService csService;
|
192 |
private CsService csService;
|
| 233 |
|
193 |
|
| 234 |
@Autowired
|
194 |
@Autowired
|
| 235 |
private AuthRepository authRepository;
|
195 |
private AuthRepository authRepository;
|
| 236 |
|
- |
|
| 237 |
@Autowired
|
196 |
@Autowired
|
| 238 |
private SuggestedPoRepository monthlyPoRepository;
|
197 |
WarehouseRepository warehouseRepository;
|
| 239 |
|
- |
|
| 240 |
@Autowired
|
198 |
@Autowired
|
| 241 |
private SuggestedPoDetailRepository monthlyPoDetailRepository;
|
199 |
private SuggestedPoRepository suggestedPoRepository;
|
| 242 |
|
200 |
|
| 243 |
@Autowired
|
201 |
@Autowired
|
| 244 |
private NotificationService notificationService;
|
202 |
private NotificationService notificationService;
|
| 245 |
|
203 |
|
| 246 |
@Autowired
|
204 |
@Autowired
|
| Line 255... |
Line 213... |
| 255 |
@Autowired
|
213 |
@Autowired
|
| 256 |
private SaholicInventoryService saholicInventoryService;
|
214 |
private SaholicInventoryService saholicInventoryService;
|
| 257 |
|
215 |
|
| 258 |
@Autowired
|
216 |
@Autowired
|
| 259 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
217 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| - |
|
218 |
@Autowired
|
| - |
|
219 |
private SuggestedPoDetailRepository suggestedPoDetailRepository;
|
| 260 |
|
220 |
|
| 261 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
221 |
@RequestMapping(value = "/open-indent/save", method = RequestMethod.POST)
|
| 262 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
222 |
public String saveOpenIndent(HttpServletRequest request, Model model, @RequestParam int catalogId,
|
| 263 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
223 |
@RequestParam int itemQty, @RequestParam int fofoId) throws Exception {
|
| 264 |
if (fofoId == 0) {
|
224 |
if (fofoId == 0) {
|
| 265 |
|
225 |
|
| 266 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
226 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 267 |
fofoId = loginDetails.getFofoId();
|
227 |
fofoId = loginDetails.getFofoId();
|
| 268 |
|
228 |
|
| Line 280... |
Line 240... |
| 280 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
240 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
| 281 |
return "response";
|
241 |
return "response";
|
| 282 |
}
|
242 |
}
|
| 283 |
|
243 |
|
| 284 |
private void saveMonthlyPlanned(MonthlyPlanned monthlyPlanned, int fofoId, LocalDate currentMonthDate,
|
244 |
private void saveMonthlyPlanned(MonthlyPlanned monthlyPlanned, int fofoId, LocalDate currentMonthDate,
|
| 285 |
int catalogId, int itemQty) {
|
245 |
int catalogId, int itemQty) {
|
| 286 |
if (monthlyPlanned == null) {
|
246 |
if (monthlyPlanned == null) {
|
| 287 |
monthlyPlanned = new MonthlyPlanned();
|
247 |
monthlyPlanned = new MonthlyPlanned();
|
| 288 |
monthlyPlanned.setFofoId(fofoId);
|
248 |
monthlyPlanned.setFofoId(fofoId);
|
| 289 |
monthlyPlanned.setYearMonth(currentMonthDate);
|
249 |
monthlyPlanned.setYearMonth(currentMonthDate);
|
| 290 |
monthlyPlannedRepository.persist(monthlyPlanned);
|
250 |
monthlyPlannedRepository.persist(monthlyPlanned);
|
| Line 318... |
Line 278... |
| 318 |
|
278 |
|
| 319 |
}
|
279 |
}
|
| 320 |
|
280 |
|
| 321 |
@RequestMapping(value = "/open-indent/confirm", method = RequestMethod.POST)
|
281 |
@RequestMapping(value = "/open-indent/confirm", method = RequestMethod.POST)
|
| 322 |
public String confirmOpenIndent(HttpServletRequest request,
|
282 |
public String confirmOpenIndent(HttpServletRequest request,
|
| 323 |
@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
283 |
@RequestParam(required = false, defaultValue = "0") int fofoId, Model model) throws Exception {
|
| 324 |
|
284 |
|
| 325 |
if (fofoId == 0) {
|
285 |
if (fofoId == 0) {
|
| 326 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
286 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 327 |
fofoId = loginDetails.getFofoId();
|
287 |
fofoId = loginDetails.getFofoId();
|
| 328 |
}
|
288 |
}
|
| Line 374... |
Line 334... |
| 374 |
Arrays.asList("Partner Id", "Partner Name", "Model Name", "Qty"),
|
334 |
Arrays.asList("Partner Id", "Partner Name", "Model Name", "Qty"),
|
| 375 |
plannedModel.stream()
|
335 |
plannedModel.stream()
|
| 376 |
.map(x -> Arrays.asList(x.getFofoId(), x.getStoreName(), x.getItemDescription(), x.getQty()))
|
336 |
.map(x -> Arrays.asList(x.getFofoId(), x.getStoreName(), x.getItemDescription(), x.getQty()))
|
| 377 |
.collect(Collectors.toList()));
|
337 |
.collect(Collectors.toList()));
|
| 378 |
LOGGER.info("baos" + baos);
|
338 |
LOGGER.info("baos" + baos);
|
| 379 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { customRetailer.getEmail() },
|
339 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{customRetailer.getEmail()},
|
| 380 |
ccemails.toArray(new String[ccemails.size()]), bccemails.toArray(new String[bccemails.size()]),
|
340 |
ccemails.toArray(new String[ccemails.size()]), bccemails.toArray(new String[bccemails.size()]),
|
| 381 |
"Planned Indent", "PFA",
|
341 |
"Planned Indent", "PFA",
|
| 382 |
new Attachment[] { new Attachment("PlannedIndent.csv", new ByteArrayResource(baos.toByteArray())), });
|
342 |
new Attachment[]{new Attachment("PlannedIndent.csv", new ByteArrayResource(baos.toByteArray())),});
|
| 383 |
|
343 |
|
| 384 |
}
|
344 |
}
|
| 385 |
|
345 |
|
| 386 |
@RequestMapping(value = "/indent/download", method = RequestMethod.GET)
|
346 |
@RequestMapping(value = "/indent/download", method = RequestMethod.GET)
|
| 387 |
public ResponseEntity<ByteArrayResource> downloadIndent(HttpServletRequest request, Model model,
|
347 |
public ResponseEntity<ByteArrayResource> downloadIndent(HttpServletRequest request, Model model,
|
| 388 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
348 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 389 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
349 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 390 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
350 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 391 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
351 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
| 392 |
LOGGER.info("Counter size is {}", counterSize);
|
352 |
LOGGER.info("Counter size is {}", counterSize);
|
| 393 |
LOGGER.info("Fofo Id is {}", fofoId);
|
353 |
LOGGER.info("Fofo Id is {}", fofoId);
|
| 394 |
if (roleManager.isAdmin(roleIds) || loginDetails.getFofoId() == fofoId) {
|
354 |
if (roleManager.isAdmin(roleIds) || loginDetails.getFofoId() == fofoId) {
|
| Line 497... |
Line 457... |
| 497 |
|
457 |
|
| 498 |
}
|
458 |
}
|
| 499 |
|
459 |
|
| 500 |
@RequestMapping(value = "/itemsByCatalogId")
|
460 |
@RequestMapping(value = "/itemsByCatalogId")
|
| 501 |
public String getItemsByCatalogId(HttpServletRequest request, Model model,
|
461 |
public String getItemsByCatalogId(HttpServletRequest request, Model model,
|
| 502 |
@RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
|
462 |
@RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
|
| 503 |
throws ProfitMandiBusinessException {
|
463 |
throws ProfitMandiBusinessException {
|
| 504 |
if (catalogId == 0) {
|
464 |
if (catalogId == 0) {
|
| 505 |
catalogId = itemRepository.selectById(itemId).getCatalogItemId();
|
465 |
catalogId = itemRepository.selectById(itemId).getCatalogItemId();
|
| 506 |
}
|
466 |
}
|
| 507 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
|
467 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
|
| Line 522... |
Line 482... |
| 522 |
|
482 |
|
| 523 |
}
|
483 |
}
|
| 524 |
|
484 |
|
| 525 |
@RequestMapping(value = "/hotdealsitemsByCatalogId")
|
485 |
@RequestMapping(value = "/hotdealsitemsByCatalogId")
|
| 526 |
public String getHotdealsitemsByCatalogId(HttpServletRequest request, Model model,
|
486 |
public String getHotdealsitemsByCatalogId(HttpServletRequest request, Model model,
|
| 527 |
@RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
|
487 |
@RequestParam(required = false) int catalogId, @RequestParam(required = false) int itemId)
|
| 528 |
throws ProfitMandiBusinessException {
|
488 |
throws ProfitMandiBusinessException {
|
| 529 |
if (catalogId == 0) {
|
489 |
if (catalogId == 0) {
|
| 530 |
catalogId = itemRepository.selectById(itemId).getCatalogItemId();
|
490 |
catalogId = itemRepository.selectById(itemId).getCatalogItemId();
|
| 531 |
}
|
491 |
}
|
| 532 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
|
492 |
List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
|
| Line 547... |
Line 507... |
| 547 |
|
507 |
|
| 548 |
}
|
508 |
}
|
| 549 |
|
509 |
|
| 550 |
@RequestMapping(value = "/indent/loadIndent")
|
510 |
@RequestMapping(value = "/indent/loadIndent")
|
| 551 |
public String loadOpenIndent(HttpServletRequest request, Model model,
|
511 |
public String loadOpenIndent(HttpServletRequest request, Model model,
|
| 552 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
512 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 553 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
513 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 554 |
|
514 |
|
| 555 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
515 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 556 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
516 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
| 557 |
LOGGER.info("Counter size is {}", counterSize);
|
517 |
LOGGER.info("Counter size is {}", counterSize);
|
| 558 |
LOGGER.info("Fofo Id is {}", fofoId);
|
518 |
LOGGER.info("Fofo Id is {}", fofoId);
|
| Line 635... |
Line 595... |
| 635 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
595 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
| 636 |
planningMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
596 |
planningMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| 637 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
|
597 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
|
| 638 |
LOGGER.info("monthlyPlanned2" + monthlyPlanned);
|
598 |
LOGGER.info("monthlyPlanned2" + monthlyPlanned);
|
| 639 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
599 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
| 640 |
LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
|
600 |
LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
|
| 641 |
.collect(Collectors.toList());
|
601 |
.collect(Collectors.toList());
|
| 642 |
|
602 |
|
| 643 |
model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
|
603 |
model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
|
| 644 |
} else {
|
604 |
} else {
|
| 645 |
planningMonthDate = LocalDate.now().withDayOfMonth(1);
|
605 |
planningMonthDate = LocalDate.now().withDayOfMonth(1);
|
| Line 647... |
Line 607... |
| 647 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
|
607 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, planningMonthDate);
|
| 648 |
model.addAttribute("planningMonth", planningMonthDate.getMonth());
|
608 |
model.addAttribute("planningMonth", planningMonthDate.getMonth());
|
| 649 |
model.addAttribute("mtd", true);
|
609 |
model.addAttribute("mtd", true);
|
| 650 |
model.addAttribute("freezed", true);
|
610 |
model.addAttribute("freezed", true);
|
| 651 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
611 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
| 652 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
|
612 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
|
| 653 |
.collect(Collectors.toList());
|
613 |
.collect(Collectors.toList());
|
| 654 |
LOGGER.info("monthlyPlanned1" + monthlyPlanned);
|
614 |
LOGGER.info("monthlyPlanned1" + monthlyPlanned);
|
| 655 |
}
|
615 |
}
|
| 656 |
|
616 |
|
| 657 |
Map<Integer, Integer> plannedDetailMap = null;
|
617 |
Map<Integer, Integer> plannedDetailMap = null;
|
| Line 795... |
Line 755... |
| 795 |
model.addAttribute("totalPcs", totalPcs);
|
755 |
model.addAttribute("totalPcs", totalPcs);
|
| 796 |
return "open-indent";
|
756 |
return "open-indent";
|
| 797 |
|
757 |
|
| 798 |
}
|
758 |
}
|
| 799 |
|
759 |
|
| - |
|
760 |
private List<Order> filterValidOrders(List<Order> lastOrdersList) {
|
| - |
|
761 |
int orderRemovedCount = 0;
|
| - |
|
762 |
Iterator<Order> orderIterator = lastOrdersList.iterator();
|
| - |
|
763 |
while (orderIterator.hasNext()) {
|
| - |
|
764 |
Order o = orderIterator.next();
|
| - |
|
765 |
if (o.getInvoiceNumber() != null) {
|
| - |
|
766 |
try {
|
| - |
|
767 |
purchaseRepository.selectByPurchaseReferenceAndFofoId(o.getInvoiceNumber(), o.getRetailerId());
|
| - |
|
768 |
orderIterator.remove();
|
| - |
|
769 |
orderRemovedCount++;
|
| - |
|
770 |
} catch (Exception e) {
|
| - |
|
771 |
|
| - |
|
772 |
}
|
| - |
|
773 |
}
|
| - |
|
774 |
}
|
| - |
|
775 |
LOGGER.info("Order removed count is {}", orderRemovedCount);
|
| - |
|
776 |
return lastOrdersList;
|
| - |
|
777 |
}
|
| - |
|
778 |
|
| - |
|
779 |
@RequestMapping(value = "/indent/confirm-pause", method = RequestMethod.POST)
|
| - |
|
780 |
public String raisePO(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
| - |
|
781 |
throws Exception {
|
| - |
|
782 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
| - |
|
783 |
for (int i = 0; i < jsonArray.length(); i++) {
|
| - |
|
784 |
JSONObject obj = jsonArray.getJSONObject(i);
|
| - |
|
785 |
|
| - |
|
786 |
TagListing tl = tagListingRepository.selectByItemId(obj.getInt("id"));
|
| - |
|
787 |
if (tl == null) {
|
| - |
|
788 |
continue;
|
| - |
|
789 |
} else {
|
| - |
|
790 |
tl.setActive(obj.getBoolean("active"));
|
| - |
|
791 |
tagListingRepository.persist(tl);
|
| - |
|
792 |
}
|
| - |
|
793 |
}
|
| - |
|
794 |
model.addAttribute("response", true);
|
| - |
|
795 |
return "response";
|
| - |
|
796 |
}
|
| - |
|
797 |
|
| - |
|
798 |
@RequestMapping(value = "/indent/confirm-hotdeals-pause", method = RequestMethod.POST)
|
| - |
|
799 |
public String hotdealUpdate(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
| - |
|
800 |
throws Exception {
|
| - |
|
801 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
| - |
|
802 |
for (int i = 0; i < jsonArray.length(); i++) {
|
| - |
|
803 |
JSONObject obj = jsonArray.getJSONObject(i);
|
| - |
|
804 |
|
| - |
|
805 |
TagListing tl = tagListingRepository.selectByItemId(obj.getInt("id"));
|
| - |
|
806 |
if (tl == null) {
|
| - |
|
807 |
continue;
|
| - |
|
808 |
} else {
|
| - |
|
809 |
tl.setHotDeals(obj.getBoolean("hotDeals"));
|
| - |
|
810 |
tagListingRepository.persist(tl);
|
| - |
|
811 |
}
|
| - |
|
812 |
}
|
| - |
|
813 |
model.addAttribute("response", true);
|
| - |
|
814 |
return "response";
|
| - |
|
815 |
}
|
| - |
|
816 |
|
| - |
|
817 |
@RequestMapping(value = "/indent/create-po", method = RequestMethod.POST)
|
| - |
|
818 |
public String raisePO(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
819 |
boolean success = false;
|
| - |
|
820 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
821 |
int fofoId = loginDetails.getFofoId();
|
| - |
|
822 |
List<ItemPriceQuantity> itemQuantities = this.getItemQuantities(fofoId);
|
| - |
|
823 |
CustomRetailer customRetailer = retailerService.getFofoRetailers(Arrays.asList(fofoId)).get(fofoId);
|
| - |
|
824 |
Client userClient = new UserClient().getClient();
|
| - |
|
825 |
double totalAmount = itemQuantities.stream().mapToDouble(x -> x.getQty() * x.getPrice()).sum();
|
| - |
|
826 |
|
| - |
|
827 |
if (totalAmount > 0) {
|
| - |
|
828 |
userClient.addItemPricingToCart(customRetailer.getCartId(), itemQuantities);
|
| - |
|
829 |
User user = userRepository.selectById(loginDetails.getFofoId());
|
| - |
|
830 |
userClient = new UserClient().getClient();
|
| - |
|
831 |
LOGGER.info("Setting wallet amount in cart");
|
| - |
|
832 |
long transactionId = userClient.createOrders(user.getActiveCartId(), "", 0, "", 0, loginDetails.getFofoId(),
|
| - |
|
833 |
7890, OrderSource.WEBSITE.getValue(), true);
|
| - |
|
834 |
LOGGER.info("Creating wallet payment for transactionId - {}", transactionId);
|
| - |
|
835 |
createPayment(user, totalAmount, transactionId);
|
| - |
|
836 |
TransactionService.Client transactionClient = new TransactionClient().getClient();
|
| - |
|
837 |
transactionClient.changeTransactionStatus(transactionId, TransactionStatus.AUTHORIZED,
|
| - |
|
838 |
"Payment received for the order", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
| - |
|
839 |
transactionClient.changeTransactionStatus(Long.valueOf(transactionId), TransactionStatus.IN_PROCESS,
|
| - |
|
840 |
"Paid fully through wallet", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
| - |
|
841 |
LOGGER.info("Successfully created transaction: " + transactionId + " for amount: " + totalAmount);
|
| - |
|
842 |
transactionClient = new TransactionClient().getClient();
|
| - |
|
843 |
transactionClient.markOrderForRegisteredGstInvoice(Collections.singletonList(Long.valueOf(transactionId)));
|
| - |
|
844 |
try {
|
| - |
|
845 |
transactionClient.enqueueTransactionInfoEmail(transactionId);
|
| - |
|
846 |
} catch (Exception e1) {
|
| - |
|
847 |
e1.printStackTrace();
|
| - |
|
848 |
LOGGER.error("Unable to update status of transaction. Thrift Exception:", e1);
|
| - |
|
849 |
}
|
| - |
|
850 |
resetCart(transactionClient.getTransaction(transactionId));
|
| - |
|
851 |
}
|
| - |
|
852 |
model.addAttribute("response", mvcResponseSender.createResponseString(success));
|
| - |
|
853 |
return "response";
|
| - |
|
854 |
}
|
| - |
|
855 |
|
| - |
|
856 |
private void createPayment(User user, double totalAmount, long transactionId)
|
| - |
|
857 |
throws NumberFormatException, PaymentException, TException {
|
| - |
|
858 |
List<Attribute> paymentAttributes = new ArrayList<Attribute>();
|
| - |
|
859 |
in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
|
| - |
|
860 |
paymentAttributes.add(new Attribute("payMethod", "7890"));
|
| - |
|
861 |
long paymentId = paymentClient.createPayment(user.getId(), totalAmount, WALLET_GATEWAY_ID, transactionId,
|
| - |
|
862 |
false);
|
| - |
|
863 |
paymentClient.updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null,
|
| - |
|
864 |
PaymentStatus.SUCCESS, null, paymentAttributes);
|
| - |
|
865 |
}
|
| - |
|
866 |
|
| 800 |
@RequestMapping(value = "/indent/loadIndentPreviousMonth")
|
867 |
@RequestMapping(value = "/indent/loadIndentPreviousMonth")
|
| 801 |
public String previousMonthLoadOpenIndent(HttpServletRequest request, Model model,
|
868 |
public String previousMonthLoadOpenIndent(HttpServletRequest request, Model model,
|
| 802 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
869 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 803 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
870 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 804 |
LocalDate planMonthStart = null;
|
871 |
LocalDate planMonthStart = null;
|
| 805 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
872 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
| 806 |
planMonthStart = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
873 |
planMonthStart = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| 807 |
} else {
|
874 |
} else {
|
| 808 |
planMonthStart = LocalDate.now().withDayOfMonth(1);
|
875 |
planMonthStart = LocalDate.now().withDayOfMonth(1);
|
| Line 1019... |
Line 1086... |
| 1019 |
model.addAttribute("totalPcs", totalPcs);
|
1086 |
model.addAttribute("totalPcs", totalPcs);
|
| 1020 |
return "open-indent";
|
1087 |
return "open-indent";
|
| 1021 |
|
1088 |
|
| 1022 |
}
|
1089 |
}
|
| 1023 |
|
1090 |
|
| 1024 |
private List<Order> filterValidOrders(List<Order> lastOrdersList) {
|
1091 |
private long resetCart(Transaction transaction) {
|
| 1025 |
int orderRemovedCount = 0;
|
1092 |
long sum = 0;
|
| 1026 |
Iterator<Order> orderIterator = lastOrdersList.iterator();
|
1093 |
Map<Long, Double> items = new HashMap<Long, Double>();
|
| 1027 |
while (orderIterator.hasNext()) {
|
1094 |
for (in.shop2020.model.v1.order.Order order : transaction.getOrders()) {
|
| 1028 |
Order o = orderIterator.next();
|
1095 |
sum += order.getGvAmount();
|
| 1029 |
if (o.getInvoiceNumber() != null) {
|
1096 |
for (LineItem lineitem : order.getLineitems()) {
|
| 1030 |
try {
|
1097 |
Long itemId = lineitem.getItem_id();
|
| 1031 |
purchaseRepository.selectByPurchaseReferenceAndFofoId(o.getInvoiceNumber(), o.getRetailerId());
|
1098 |
Double quantity = items.get(itemId);
|
| 1032 |
orderIterator.remove();
|
1099 |
if (quantity == null) {
|
| 1033 |
orderRemovedCount++;
|
1100 |
quantity = lineitem.getQuantity();
|
| 1034 |
} catch (Exception e) {
|
1101 |
} else {
|
| 1035 |
|
- |
|
| - |
|
1102 |
quantity = quantity + lineitem.getQuantity();
|
| 1036 |
}
|
1103 |
}
|
| - |
|
1104 |
items.put(itemId, quantity);
|
| 1037 |
}
|
1105 |
}
|
| 1038 |
}
|
1106 |
}
|
| 1039 |
LOGGER.info("Order removed count is {}", orderRemovedCount);
|
- |
|
| 1040 |
return lastOrdersList;
|
- |
|
| 1041 |
}
|
- |
|
| 1042 |
|
- |
|
| 1043 |
@RequestMapping(value = "/indent/confirm-pause", method = RequestMethod.POST)
|
- |
|
| 1044 |
public String raisePO(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
- |
|
| 1045 |
throws Exception {
|
- |
|
| 1046 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
- |
|
| 1047 |
for (int i = 0; i < jsonArray.length(); i++) {
|
- |
|
| 1048 |
JSONObject obj = jsonArray.getJSONObject(i);
|
- |
|
| 1049 |
|
- |
|
| 1050 |
TagListing tl = tagListingRepository.selectByItemId(obj.getInt("id"));
|
- |
|
| 1051 |
if (tl == null) {
|
- |
|
| 1052 |
continue;
|
- |
|
| 1053 |
} else {
|
- |
|
| 1054 |
tl.setActive(obj.getBoolean("active"));
|
- |
|
| 1055 |
tagListingRepository.persist(tl);
|
- |
|
| 1056 |
}
|
- |
|
| 1057 |
}
|
- |
|
| 1058 |
model.addAttribute("response", true);
|
- |
|
| 1059 |
return "response";
|
- |
|
| 1060 |
}
|
- |
|
| 1061 |
|
1107 |
|
| 1062 |
@RequestMapping(value = "/indent/confirm-hotdeals-pause", method = RequestMethod.POST)
|
- |
|
| 1063 |
public String hotdealUpdate(HttpServletRequest request, Model model, @RequestBody String jsonArrayString)
|
- |
|
| 1064 |
throws Exception {
|
- |
|
| 1065 |
JSONArray jsonArray = new JSONArray(jsonArrayString);
|
- |
|
| 1066 |
for (int i = 0; i < jsonArray.length(); i++) {
|
- |
|
| 1067 |
JSONObject obj = jsonArray.getJSONObject(i);
|
- |
|
| 1068 |
|
- |
|
| 1069 |
TagListing tl = tagListingRepository.selectByItemId(obj.getInt("id"));
|
- |
|
| 1070 |
if (tl == null) {
|
- |
|
| 1071 |
continue;
|
- |
|
| 1072 |
} else {
|
- |
|
| 1073 |
tl.setHotDeals(obj.getBoolean("hotDeals"));
|
- |
|
| 1074 |
tagListingRepository.persist(tl);
|
- |
|
| 1075 |
}
|
- |
|
| 1076 |
}
|
- |
|
| 1077 |
model.addAttribute("response", true);
|
- |
|
| 1078 |
return "response";
|
- |
|
| 1079 |
}
|
- |
|
| 1080 |
|
- |
|
| 1081 |
@RequestMapping(value = "/indent/create-po", method = RequestMethod.POST)
|
- |
|
| 1082 |
public String raisePO(HttpServletRequest request, Model model) throws Exception {
|
- |
|
| 1083 |
boolean success = false;
|
- |
|
| 1084 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 1085 |
int fofoId = loginDetails.getFofoId();
|
- |
|
| 1086 |
List<ItemPriceQuantity> itemQuantities = this.getItemQuantities(fofoId);
|
- |
|
| 1087 |
CustomRetailer customRetailer = retailerService.getFofoRetailers(Arrays.asList(fofoId)).get(fofoId);
|
- |
|
| 1088 |
Client userClient = new UserClient().getClient();
|
1108 |
LOGGER.debug("Items to reset in cart are: " + items);
|
| 1089 |
double totalAmount = itemQuantities.stream().mapToDouble(x -> x.getQty() * x.getPrice()).sum();
|
- |
|
| 1090 |
|
1109 |
|
| 1091 |
if (totalAmount > 0) {
|
1110 |
try {
|
| 1092 |
userClient.addItemPricingToCart(customRetailer.getCartId(), itemQuantities);
|
- |
|
| 1093 |
User user = userRepository.selectById(loginDetails.getFofoId());
|
- |
|
| 1094 |
userClient = new UserClient().getClient();
|
1111 |
Client userClient = new UserClient().getClient();
|
| 1095 |
LOGGER.info("Setting wallet amount in cart");
|
1112 |
userClient.resetCart(transaction.getShoppingCartid(), items);
|
| 1096 |
long transactionId = userClient.createOrders(user.getActiveCartId(), "", 0, "", 0, loginDetails.getFofoId(),
|
- |
|
| 1097 |
7890, OrderSource.WEBSITE.getValue(), true);
|
1113 |
} catch (TException e) {
|
| 1098 |
LOGGER.info("Creating wallet payment for transactionId - {}", transactionId);
|
1114 |
LOGGER.error("Error while updating information in payment database.", e);
|
| 1099 |
createPayment(user, totalAmount, transactionId);
|
1115 |
} catch (ShoppingCartException e) {
|
| 1100 |
TransactionService.Client transactionClient = new TransactionClient().getClient();
|
- |
|
| 1101 |
transactionClient.changeTransactionStatus(transactionId, TransactionStatus.AUTHORIZED,
|
- |
|
| 1102 |
"Payment received for the order", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
- |
|
| 1103 |
transactionClient.changeTransactionStatus(Long.valueOf(transactionId), TransactionStatus.IN_PROCESS,
|
- |
|
| 1104 |
"Paid fully through wallet", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
- |
|
| 1105 |
LOGGER.info("Successfully created transaction: " + transactionId + " for amount: " + totalAmount);
|
1116 |
LOGGER.error("Error while reseting the cart in cart database.", e);
|
| 1106 |
transactionClient = new TransactionClient().getClient();
|
- |
|
| 1107 |
transactionClient.markOrderForRegisteredGstInvoice(Collections.singletonList(Long.valueOf(transactionId)));
|
- |
|
| 1108 |
try {
|
- |
|
| 1109 |
transactionClient.enqueueTransactionInfoEmail(transactionId);
|
- |
|
| 1110 |
} catch (Exception e1) {
|
1117 |
} catch (Exception e) {
|
| 1111 |
e1.printStackTrace();
|
- |
|
| 1112 |
LOGGER.error("Unable to update status of transaction. Thrift Exception:", e1);
|
1118 |
LOGGER.error("Unexpected exception", e);
|
| 1113 |
}
|
- |
|
| 1114 |
resetCart(transactionClient.getTransaction(transactionId));
|
- |
|
| 1115 |
}
|
1119 |
}
|
| 1116 |
model.addAttribute("response", mvcResponseSender.createResponseString(success));
|
- |
|
| 1117 |
return "response";
|
1120 |
return sum;
|
| 1118 |
}
|
- |
|
| 1119 |
|
- |
|
| 1120 |
private void createPayment(User user, double totalAmount, long transactionId)
|
- |
|
| 1121 |
throws NumberFormatException, PaymentException, TException {
|
- |
|
| 1122 |
List<Attribute> paymentAttributes = new ArrayList<Attribute>();
|
- |
|
| 1123 |
in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
|
- |
|
| 1124 |
paymentAttributes.add(new Attribute("payMethod", "7890"));
|
- |
|
| 1125 |
long paymentId = paymentClient.createPayment(user.getId(), totalAmount, WALLET_GATEWAY_ID, transactionId,
|
- |
|
| 1126 |
false);
|
- |
|
| 1127 |
paymentClient.updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null,
|
- |
|
| 1128 |
PaymentStatus.SUCCESS, null, paymentAttributes);
|
- |
|
| 1129 |
}
|
1121 |
}
|
| 1130 |
|
1122 |
|
| 1131 |
private List<ItemPriceQuantity> getItemQuantities(int fofoId) throws ProfitMandiBusinessException {
|
1123 |
private List<ItemPriceQuantity> getItemQuantities(int fofoId) throws ProfitMandiBusinessException {
|
| 1132 |
List<ItemPriceQuantity> itemQuantities = new ArrayList<>();
|
1124 |
List<ItemPriceQuantity> itemQuantities = new ArrayList<>();
|
| 1133 |
/*
|
1125 |
/*
|
| Line 1136... |
Line 1128... |
| 1136 |
* .selectItemsStock(fofoId); itemCisMap =
|
1128 |
* .selectItemsStock(fofoId); itemCisMap =
|
| 1137 |
* currentInventorySnapshots.stream().filter(x -> x.getAvailability() > 0)
|
1129 |
* currentInventorySnapshots.stream().filter(x -> x.getAvailability() > 0)
|
| 1138 |
* .collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
1130 |
* .collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 1139 |
* List<StockAllocationModel> stockAllocationList =
|
1131 |
* List<StockAllocationModel> stockAllocationList =
|
| 1140 |
* stockAllocationService.getStockAllocation(fofoId, true);
|
1132 |
* stockAllocationService.getStockAllocation(fofoId, true);
|
| 1141 |
*
|
1133 |
*
|
| 1142 |
* Map<Integer, StockAllocationModel> itemStockAllocationMap =
|
1134 |
* Map<Integer, StockAllocationModel> itemStockAllocationMap =
|
| 1143 |
* stockAllocationList.stream() .collect(Collectors.toMap(x -> x.catalogId(), x
|
1135 |
* stockAllocationList.stream() .collect(Collectors.toMap(x -> x.catalogId(), x
|
| 1144 |
* -> x)); Map<Integer, Integer> itemsInTransit = null;
|
1136 |
* -> x)); Map<Integer, Integer> itemsInTransit = null;
|
| 1145 |
* LOGGER.info("Item Stock Allocation Model Map {}", itemStockAllocationMap);
|
1137 |
* LOGGER.info("Item Stock Allocation Model Map {}", itemStockAllocationMap);
|
| 1146 |
* List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
1138 |
* List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
| Line 1148... |
Line 1140... |
| 1148 |
* validOrderStatusList); inTransitOrders =
|
1140 |
* validOrderStatusList); inTransitOrders =
|
| 1149 |
* this.filterValidOrders(inTransitOrders); itemsInTransit =
|
1141 |
* this.filterValidOrders(inTransitOrders); itemsInTransit =
|
| 1150 |
* inTransitOrders.stream().collect(Collectors.groupingBy(x ->
|
1142 |
* inTransitOrders.stream().collect(Collectors.groupingBy(x ->
|
| 1151 |
* x.getLineItem().getItemId(), Collectors.summingInt(x ->
|
1143 |
* x.getLineItem().getItemId(), Collectors.summingInt(x ->
|
| 1152 |
* x.getLineItem().getQuantity())));
|
1144 |
* x.getLineItem().getQuantity())));
|
| 1153 |
*
|
1145 |
*
|
| 1154 |
* Iterator<TagListing> iterator = tagListings.iterator();
|
1146 |
* Iterator<TagListing> iterator = tagListings.iterator();
|
| 1155 |
*
|
1147 |
*
|
| 1156 |
* int toBeOrdered = 0; while (iterator.hasNext()) { TagListing tagListing =
|
1148 |
* int toBeOrdered = 0; while (iterator.hasNext()) { TagListing tagListing =
|
| 1157 |
* iterator.next(); LOGGER.info(" tagListing.setAllocatedQuantity {}",
|
1149 |
* iterator.next(); LOGGER.info(" tagListing.setAllocatedQuantity {}",
|
| 1158 |
* tagListing.getAllocatedQuantity()); if
|
1150 |
* tagListing.getAllocatedQuantity()); if
|
| 1159 |
* (!itemCisMap.containsKey(tagListing.getItemId()) &&
|
1151 |
* (!itemCisMap.containsKey(tagListing.getItemId()) &&
|
| 1160 |
* !itemStockAllocationMap.containsKey(tagListing.getItemId())) {
|
1152 |
* !itemStockAllocationMap.containsKey(tagListing.getItemId())) {
|
| 1161 |
* iterator.remove(); continue; } ItemIdAvailability itemIdAvailability =
|
1153 |
* iterator.remove(); continue; } ItemIdAvailability itemIdAvailability =
|
| 1162 |
* itemCisMap.get(tagListing.getItemId());
|
1154 |
* itemCisMap.get(tagListing.getItemId());
|
| 1163 |
* tagListing.setStockInHand(itemIdAvailability == null ? 0 :
|
1155 |
* tagListing.setStockInHand(itemIdAvailability == null ? 0 :
|
| 1164 |
* itemIdAvailability.getAvailability()); StockAllocationModel
|
1156 |
* itemIdAvailability.getAvailability()); StockAllocationModel
|
| 1165 |
* stockAllocationModel = itemStockAllocationMap.get(tagListing.getItemId());
|
1157 |
* stockAllocationModel = itemStockAllocationMap.get(tagListing.getItemId());
|
| 1166 |
*
|
1158 |
*
|
| 1167 |
* if (itemsInTransit.containsKey(tagListing.getItemId())) {
|
1159 |
* if (itemsInTransit.containsKey(tagListing.getItemId())) {
|
| 1168 |
* tagListing.setInTransitQuantity(itemsInTransit.get(tagListing.getItemId()));
|
1160 |
* tagListing.setInTransitQuantity(itemsInTransit.get(tagListing.getItemId()));
|
| 1169 |
* } else { tagListing.setInTransitQuantity(0); } if (stockAllocationModel !=
|
1161 |
* } else { tagListing.setInTransitQuantity(0); } if (stockAllocationModel !=
|
| 1170 |
* null) { tagListing.setAllocatedQuantity(stockAllocationModel.getQuantity());
|
1162 |
* null) { tagListing.setAllocatedQuantity(stockAllocationModel.getQuantity());
|
| 1171 |
* toBeOrdered = Math.max(tagListing.getAllocatedQuantity() -
|
1163 |
* toBeOrdered = Math.max(tagListing.getAllocatedQuantity() -
|
| Line 1176... |
Line 1168... |
| 1176 |
*/
|
1168 |
*/
|
| 1177 |
return itemQuantities;
|
1169 |
return itemQuantities;
|
| 1178 |
|
1170 |
|
| 1179 |
}
|
1171 |
}
|
| 1180 |
|
1172 |
|
| 1181 |
private long resetCart(Transaction transaction) {
|
- |
|
| 1182 |
long sum = 0;
|
- |
|
| 1183 |
Map<Long, Double> items = new HashMap<Long, Double>();
|
- |
|
| 1184 |
for (in.shop2020.model.v1.order.Order order : transaction.getOrders()) {
|
- |
|
| 1185 |
sum += order.getGvAmount();
|
- |
|
| 1186 |
for (LineItem lineitem : order.getLineitems()) {
|
- |
|
| 1187 |
Long itemId = lineitem.getItem_id();
|
- |
|
| 1188 |
Double quantity = items.get(itemId);
|
- |
|
| 1189 |
if (quantity == null) {
|
- |
|
| 1190 |
quantity = lineitem.getQuantity();
|
- |
|
| 1191 |
} else {
|
- |
|
| 1192 |
quantity = quantity + lineitem.getQuantity();
|
- |
|
| 1193 |
}
|
- |
|
| 1194 |
items.put(itemId, quantity);
|
- |
|
| 1195 |
}
|
- |
|
| 1196 |
}
|
- |
|
| 1197 |
|
- |
|
| 1198 |
LOGGER.debug("Items to reset in cart are: " + items);
|
- |
|
| 1199 |
|
- |
|
| 1200 |
try {
|
- |
|
| 1201 |
Client userClient = new UserClient().getClient();
|
- |
|
| 1202 |
userClient.resetCart(transaction.getShoppingCartid(), items);
|
- |
|
| 1203 |
} catch (TException e) {
|
- |
|
| 1204 |
LOGGER.error("Error while updating information in payment database.", e);
|
- |
|
| 1205 |
} catch (ShoppingCartException e) {
|
- |
|
| 1206 |
LOGGER.error("Error while reseting the cart in cart database.", e);
|
- |
|
| 1207 |
} catch (Exception e) {
|
- |
|
| 1208 |
LOGGER.error("Unexpected exception", e);
|
- |
|
| 1209 |
}
|
- |
|
| 1210 |
return sum;
|
- |
|
| 1211 |
}
|
- |
|
| 1212 |
|
- |
|
| 1213 |
@RequestMapping(value = "/getFocusedModel", method = RequestMethod.GET)
|
1173 |
@RequestMapping(value = "/getFocusedModel", method = RequestMethod.GET)
|
| 1214 |
public String getFocusedModel(HttpServletRequest request,
|
1174 |
public String getFocusedModel(HttpServletRequest request,
|
| 1215 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
1175 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 1216 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
1176 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 1217 |
throws ProfitMandiBusinessException {
|
1177 |
throws ProfitMandiBusinessException {
|
| 1218 |
|
1178 |
|
| 1219 |
long size = 0;
|
1179 |
long size = 0;
|
| 1220 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
1180 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
| 1221 |
|
1181 |
|
| Line 1249... |
Line 1209... |
| 1249 |
model.addAttribute("regions", regions);
|
1209 |
model.addAttribute("regions", regions);
|
| 1250 |
|
1210 |
|
| 1251 |
return "focused_model";
|
1211 |
return "focused_model";
|
| 1252 |
}
|
1212 |
}
|
| 1253 |
|
1213 |
|
| - |
|
1214 |
private Map<Integer, Item> getItemByCatalogId(List<FocusedModel> focusedModels) {
|
| - |
|
1215 |
Map<Integer, Item> itemMap = new HashMap<>();
|
| - |
|
1216 |
for (FocusedModel focusedModel : focusedModels) {
|
| - |
|
1217 |
List<Item> items = itemRepository.selectAllByCatalogItemId(focusedModel.getCatalogId());
|
| - |
|
1218 |
itemMap.put(items.get(0).getCatalogItemId(), items.get(0));
|
| - |
|
1219 |
}
|
| - |
|
1220 |
|
| - |
|
1221 |
return itemMap;
|
| - |
|
1222 |
}
|
| - |
|
1223 |
|
| - |
|
1224 |
private Map<Integer, Region> getRegionByRegionId(List<FocusedModel> focusedModels) {
|
| - |
|
1225 |
Map<Integer, Region> regionMap = new HashMap<>();
|
| - |
|
1226 |
for (FocusedModel focusedModel : focusedModels) {
|
| - |
|
1227 |
Region region = regionRepository.selectById(focusedModel.getRegionId());
|
| - |
|
1228 |
regionMap.put(region.getId(), region);
|
| - |
|
1229 |
}
|
| - |
|
1230 |
|
| - |
|
1231 |
return regionMap;
|
| - |
|
1232 |
}
|
| - |
|
1233 |
|
| 1254 |
@RequestMapping(value = "/getPaginatedFocusedModel", method = RequestMethod.GET)
|
1234 |
@RequestMapping(value = "/getPaginatedFocusedModel", method = RequestMethod.GET)
|
| 1255 |
public String getPaginatedFocusedModel(HttpServletRequest request,
|
1235 |
public String getPaginatedFocusedModel(HttpServletRequest request,
|
| 1256 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
1236 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 1257 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
1237 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 1258 |
throws ProfitMandiBusinessException {
|
1238 |
throws ProfitMandiBusinessException {
|
| 1259 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
1239 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
| 1260 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
1240 |
List<FocusedModel> focusedModels = focusedModelRepository.selectAll(offset, limit);
|
| 1261 |
|
1241 |
|
| 1262 |
if (!focusedModels.isEmpty()) {
|
1242 |
if (!focusedModels.isEmpty()) {
|
| Line 1275... |
Line 1255... |
| 1275 |
|
1255 |
|
| 1276 |
model.addAttribute("regions", regions);
|
1256 |
model.addAttribute("regions", regions);
|
| 1277 |
return "focused-model-paginated";
|
1257 |
return "focused-model-paginated";
|
| 1278 |
}
|
1258 |
}
|
| 1279 |
|
1259 |
|
| 1280 |
private Map<Integer, Item> getItemByCatalogId(List<FocusedModel> focusedModels) {
|
- |
|
| 1281 |
Map<Integer, Item> itemMap = new HashMap<>();
|
- |
|
| 1282 |
for (FocusedModel focusedModel : focusedModels) {
|
- |
|
| 1283 |
List<Item> items = itemRepository.selectAllByCatalogItemId(focusedModel.getCatalogId());
|
- |
|
| 1284 |
itemMap.put(items.get(0).getCatalogItemId(), items.get(0));
|
- |
|
| 1285 |
}
|
- |
|
| 1286 |
|
- |
|
| 1287 |
return itemMap;
|
- |
|
| 1288 |
}
|
- |
|
| 1289 |
|
- |
|
| 1290 |
private Map<Integer, Region> getRegionByRegionId(List<FocusedModel> focusedModels) {
|
- |
|
| 1291 |
Map<Integer, Region> regionMap = new HashMap<>();
|
- |
|
| 1292 |
for (FocusedModel focusedModel : focusedModels) {
|
- |
|
| 1293 |
Region region = regionRepository.selectById(focusedModel.getRegionId());
|
- |
|
| 1294 |
regionMap.put(region.getId(), region);
|
- |
|
| 1295 |
}
|
- |
|
| 1296 |
|
- |
|
| 1297 |
return regionMap;
|
- |
|
| 1298 |
}
|
- |
|
| 1299 |
|
- |
|
| 1300 |
@RequestMapping(value = "/focusedModel", method = RequestMethod.POST)
|
1260 |
@RequestMapping(value = "/focusedModel", method = RequestMethod.POST)
|
| 1301 |
public String focusedModel(HttpServletRequest request, @RequestParam int catalogId,
|
1261 |
public String focusedModel(HttpServletRequest request, @RequestParam int catalogId,
|
| 1302 |
@RequestParam(name = "recommended", defaultValue = "0") int recommended,
|
1262 |
@RequestParam(name = "recommended", defaultValue = "0") int recommended,
|
| 1303 |
@RequestParam(name = "minimumQty", defaultValue = "0") int minimumQty,
|
1263 |
@RequestParam(name = "minimumQty", defaultValue = "0") int minimumQty,
|
| 1304 |
@RequestParam(name = "obvrecommend", defaultValue = "0") int obvrecommend,
|
1264 |
@RequestParam(name = "obvrecommend", defaultValue = "0") int obvrecommend,
|
| 1305 |
@RequestParam(name = "obvminimum", defaultValue = "0") int obvminimum, @RequestParam int regionId,
|
1265 |
@RequestParam(name = "obvminimum", defaultValue = "0") int obvminimum, @RequestParam int regionId,
|
| 1306 |
Model model) throws ProfitMandiBusinessException {
|
1266 |
Model model) throws ProfitMandiBusinessException {
|
| 1307 |
|
1267 |
|
| 1308 |
FocusedModel fm = new FocusedModel();
|
1268 |
FocusedModel fm = new FocusedModel();
|
| 1309 |
fm.setCatalogId(catalogId);
|
1269 |
fm.setCatalogId(catalogId);
|
| 1310 |
fm.setMinimumQty(minimumQty);
|
1270 |
fm.setMinimumQty(minimumQty);
|
| 1311 |
fm.setRecommendedQty(recommended);
|
1271 |
fm.setRecommendedQty(recommended);
|
| Line 1315... |
Line 1275... |
| 1315 |
fm.setCreatedTimestamp(LocalDateTime.now());
|
1275 |
fm.setCreatedTimestamp(LocalDateTime.now());
|
| 1316 |
focusedModelRepository.persist(fm);
|
1276 |
focusedModelRepository.persist(fm);
|
| 1317 |
return "focused_model";
|
1277 |
return "focused_model";
|
| 1318 |
}
|
1278 |
}
|
| 1319 |
|
1279 |
|
| 1320 |
@RequestMapping(value = "/removeItem", method = RequestMethod.DELETE)
|
- |
|
| 1321 |
public String removeFocusedModelItem(HttpServletRequest request,
|
- |
|
| 1322 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
- |
|
| 1323 |
|
- |
|
| 1324 |
focusedModelRepository.deleteById(id);
|
- |
|
| 1325 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
- |
|
| 1326 |
return "response";
|
- |
|
| 1327 |
}
|
- |
|
| 1328 |
|
- |
|
| 1329 |
private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
|
1280 |
private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
|
| 1330 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
|
1281 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
|
| 1331 |
|
1282 |
|
| 1332 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
|
1283 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
|
| 1333 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
1284 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
| Line 1381... |
Line 1332... |
| 1381 |
|
1332 |
|
| 1382 |
return "partner-po";
|
1333 |
return "partner-po";
|
| 1383 |
|
1334 |
|
| 1384 |
}
|
1335 |
}
|
| 1385 |
|
1336 |
|
| - |
|
1337 |
@RequestMapping(value = "/removeItem", method = RequestMethod.DELETE)
|
| - |
|
1338 |
public String removeFocusedModelItem(HttpServletRequest request,
|
| - |
|
1339 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
| - |
|
1340 |
|
| - |
|
1341 |
focusedModelRepository.deleteById(id);
|
| - |
|
1342 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
1343 |
return "response";
|
| - |
|
1344 |
}
|
| - |
|
1345 |
|
| 1386 |
@RequestMapping(value = "/getPartnerloadContent")
|
1346 |
@RequestMapping(value = "/getPartnerloadContent")
|
| 1387 |
public String getPartnerloadContent(HttpServletRequest request, Model model,
|
1347 |
public String getPartnerloadContent(HttpServletRequest request, Model model,
|
| 1388 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
1348 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 1389 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
1349 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 1390 |
|
1350 |
|
| 1391 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
1351 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 1392 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
1352 |
Set<Integer> roleIds = loginDetails.getRoleIds();
|
| 1393 |
LOGGER.info("Counter size is {}", counterSize);
|
1353 |
LOGGER.info("Counter size is {}", counterSize);
|
| 1394 |
LOGGER.info("Fofo Id is {}", fofoId);
|
1354 |
LOGGER.info("Fofo Id is {}", fofoId);
|
| Line 1472... |
Line 1432... |
| 1472 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
1432 |
if (LocalDate.now().isAfter(LocalDate.now().withDayOfMonth(PLANNING_OPEN_DAY))) {
|
| 1473 |
currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
1433 |
currentMonthDate = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| 1474 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
|
1434 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
|
| 1475 |
LOGGER.info("monthlyPlanned2" + monthlyPlanned);
|
1435 |
LOGGER.info("monthlyPlanned2" + monthlyPlanned);
|
| 1476 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
1436 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
| 1477 |
LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
|
1437 |
LocalDateTime.now().minusDays(15), LocalDateTime.now()).stream().map(x -> x.getId())
|
| 1478 |
.collect(Collectors.toList());
|
1438 |
.collect(Collectors.toList());
|
| 1479 |
|
1439 |
|
| 1480 |
model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
|
1440 |
model.addAttribute("planningMonth", LocalDate.now().plusMonths(1).getMonth());
|
| 1481 |
} else {
|
1441 |
} else {
|
| 1482 |
currentMonthDate = LocalDate.now().withDayOfMonth(1);
|
1442 |
currentMonthDate = LocalDate.now().withDayOfMonth(1);
|
| Line 1484... |
Line 1444... |
| 1484 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
|
1444 |
monthlyPlanned = monthlyPlannedRepository.selectByFofoIdYearMonth(fofoId, currentMonthDate);
|
| 1485 |
model.addAttribute("planningMonth", currentMonthDate.getMonth());
|
1445 |
model.addAttribute("planningMonth", currentMonthDate.getMonth());
|
| 1486 |
model.addAttribute("mtd", true);
|
1446 |
model.addAttribute("mtd", true);
|
| 1487 |
model.addAttribute("freezed", true);
|
1447 |
model.addAttribute("freezed", true);
|
| 1488 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
1448 |
fofoOrderIds = fofoOrderRepository.selectByFofoIdBetweenCreatedTimeStamp(loginDetails.getFofoId(),
|
| 1489 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
|
1449 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX)).stream().map(x -> x.getId())
|
| 1490 |
.collect(Collectors.toList());
|
1450 |
.collect(Collectors.toList());
|
| 1491 |
LOGGER.info("monthlyPlanned1" + monthlyPlanned);
|
1451 |
LOGGER.info("monthlyPlanned1" + monthlyPlanned);
|
| 1492 |
}
|
1452 |
}
|
| 1493 |
|
1453 |
|
| 1494 |
Map<Integer, Integer> plannedDetailMap = null;
|
1454 |
Map<Integer, Integer> plannedDetailMap = null;
|
| Line 1673... |
Line 1633... |
| 1673 |
|
1633 |
|
| 1674 |
return "create-partner-po";
|
1634 |
return "create-partner-po";
|
| 1675 |
|
1635 |
|
| 1676 |
}
|
1636 |
}
|
| 1677 |
|
1637 |
|
| 1678 |
@RequestMapping(value = "/createPo", method = RequestMethod.POST)
|
- |
|
| 1679 |
public String createPo(HttpServletRequest request, @RequestBody SuggestedPoModel monthlyPoModel, Model model)
|
- |
|
| 1680 |
throws Exception {
|
- |
|
| 1681 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 1682 |
SuggestedPo mp = new SuggestedPo();
|
- |
|
| 1683 |
mp.setFofoId(monthlyPoModel.getFofoId());
|
- |
|
| 1684 |
mp.setCreateTimestamp(LocalDateTime.now());
|
- |
|
| 1685 |
mp.setStatus("open");
|
- |
|
| 1686 |
mp.setAuthId(loginDetails.getEmailId());
|
- |
|
| 1687 |
monthlyPoRepository.persist(mp);
|
- |
|
| 1688 |
|
- |
|
| 1689 |
for (SuggestedPoIdModel poId : monthlyPoModel.getPoIds()) {
|
- |
|
| 1690 |
SuggestedPoDetail mpd = new SuggestedPoDetail();
|
- |
|
| 1691 |
mpd.setItemId(poId.getItemId());
|
- |
|
| 1692 |
mpd.setQuantity(poId.getQty());
|
- |
|
| 1693 |
mpd.setUpdatedTimestamp(LocalDateTime.now());
|
- |
|
| 1694 |
mpd.setPoId(mp.getId());
|
- |
|
| 1695 |
monthlyPoDetailRepository.persist(mpd);
|
- |
|
| 1696 |
}
|
- |
|
| 1697 |
|
- |
|
| 1698 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
- |
|
| 1699 |
sendNotificationModel.setCampaignName("Alert");
|
- |
|
| 1700 |
sendNotificationModel.setMessage("Suggested Po");
|
- |
|
| 1701 |
sendNotificationModel.setType("url");
|
- |
|
| 1702 |
sendNotificationModel.setTitle("Alert");
|
- |
|
| 1703 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/partnerPo/" + mp.getId());
|
- |
|
| 1704 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
- |
|
| 1705 |
sendNotificationModel.setMessageType(MessageType.notification);
|
- |
|
| 1706 |
int userId = userAccountRepository.selectUserIdByRetailerId(monthlyPoModel.getFofoId());
|
- |
|
| 1707 |
|
- |
|
| 1708 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
- |
|
| 1709 |
notificationService.sendNotification(sendNotificationModel);
|
- |
|
| 1710 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
- |
|
| 1711 |
|
- |
|
| 1712 |
return "response";
|
- |
|
| 1713 |
}
|
- |
|
| 1714 |
|
- |
|
| 1715 |
@RequestMapping(value = "/selectItemColor", method = RequestMethod.GET)
|
1638 |
@RequestMapping(value = "/selectItemColor", method = RequestMethod.GET)
|
| 1716 |
public String selectItemColor(HttpServletRequest request, @RequestParam int catalogId, Model model)
|
1639 |
public String selectItemColor(HttpServletRequest request, @RequestParam int catalogId, Model model)
|
| 1717 |
throws Exception {
|
1640 |
throws Exception {
|
| 1718 |
|
1641 |
|
| 1719 |
List<Item> selecteditems = itemRepository.selectAllByCatalogItemId(catalogId);
|
1642 |
List<Item> selecteditems = itemRepository.selectAllByCatalogItemId(catalogId);
|
| Line 1878... |
Line 1801... |
| 1878 |
model.addAttribute("grnPendingAccessTvOrders", grnPendingAccessTvOrders);
|
1801 |
model.addAttribute("grnPendingAccessTvOrders", grnPendingAccessTvOrders);
|
| 1879 |
model.addAttribute("fofoIdPartnerTypeMap", fofoIdPartnerTypeMap);
|
1802 |
model.addAttribute("fofoIdPartnerTypeMap", fofoIdPartnerTypeMap);
|
| 1880 |
return "partner-brandwise-detail";
|
1803 |
return "partner-brandwise-detail";
|
| 1881 |
}
|
1804 |
}
|
| 1882 |
|
1805 |
|
| - |
|
1806 |
@RequestMapping(value = "/createPo", method = RequestMethod.POST)
|
| - |
|
1807 |
public String createPo(HttpServletRequest request, @RequestBody SuggestedPoModel monthlyPoModel, Model model)
|
| - |
|
1808 |
throws Exception {
|
| - |
|
1809 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
1810 |
SuggestedPo mp = new SuggestedPo();
|
| - |
|
1811 |
mp.setFofoId(monthlyPoModel.getFofoId());
|
| - |
|
1812 |
mp.setCreateTimestamp(LocalDateTime.now());
|
| - |
|
1813 |
mp.setStatus("open");
|
| - |
|
1814 |
mp.setAuthId(loginDetails.getEmailId());
|
| - |
|
1815 |
suggestedPoRepository.persist(mp);
|
| - |
|
1816 |
|
| - |
|
1817 |
for (SuggestedPoIdModel poId : monthlyPoModel.getPoIds()) {
|
| - |
|
1818 |
SuggestedPoDetail mpd = new SuggestedPoDetail();
|
| - |
|
1819 |
mpd.setItemId(poId.getItemId());
|
| - |
|
1820 |
mpd.setQuantity(poId.getQty());
|
| - |
|
1821 |
mpd.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
1822 |
mpd.setPoId(mp.getId());
|
| - |
|
1823 |
suggestedPoDetailRepository.persist(mpd);
|
| - |
|
1824 |
}
|
| - |
|
1825 |
|
| - |
|
1826 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
1827 |
sendNotificationModel.setCampaignName("Alert");
|
| - |
|
1828 |
sendNotificationModel.setMessage("Suggested Po");
|
| - |
|
1829 |
sendNotificationModel.setType("url");
|
| - |
|
1830 |
sendNotificationModel.setTitle("Alert");
|
| - |
|
1831 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/partnerPo/" + mp.getId());
|
| - |
|
1832 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
| - |
|
1833 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| - |
|
1834 |
int userId = userAccountRepository.selectUserIdByRetailerId(monthlyPoModel.getFofoId());
|
| - |
|
1835 |
|
| - |
|
1836 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| - |
|
1837 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
1838 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
1839 |
|
| - |
|
1840 |
return "response";
|
| - |
|
1841 |
}
|
| - |
|
1842 |
|
| 1883 |
@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
|
1843 |
@RequestMapping(value = "/getPartnerShortageStock", method = RequestMethod.GET)
|
| 1884 |
public String getPartnerShortageStock(HttpServletRequest request,
|
1844 |
public String getPartnerShortageStock(HttpServletRequest request,
|
| 1885 |
@RequestParam(required = false, defaultValue = "") String brand, @RequestParam int fofoId, Model model)
|
1845 |
@RequestParam(required = false, defaultValue = "") String brand, @RequestParam int fofoId, Model model)
|
| 1886 |
throws Exception {
|
1846 |
throws Exception {
|
| 1887 |
|
1847 |
|
| 1888 |
Map<Integer, Map<Integer, List<SaholicCIS>>> warehouseItemAvailabilityMap = saholicInventoryService
|
1848 |
Map<Integer, Map<Integer, List<SaholicCIS>>> warehouseItemAvailabilityMap = saholicInventoryService
|
| 1889 |
.getSaholicStock();
|
1849 |
.getSaholicStock();
|
| 1890 |
|
1850 |
|
| Line 1999... |
Line 1959... |
| 1999 |
return "partner-stock";
|
1959 |
return "partner-stock";
|
| 2000 |
|
1960 |
|
| 2001 |
}
|
1961 |
}
|
| 2002 |
|
1962 |
|
| 2003 |
private FocusedModelShortageModel getFocusedModelShortage(int qty, int catalogId,
|
1963 |
private FocusedModelShortageModel getFocusedModelShortage(int qty, int catalogId,
|
| 2004 |
Map<Integer, Integer> processingOrderMap, Map<Integer, Integer> grnPendingOrdersMap,
|
1964 |
Map<Integer, Integer> processingOrderMap, Map<Integer, Integer> grnPendingOrdersMap,
|
| 2005 |
Map<Integer, Integer> catalogIdAndQtyMap, int fofoId,
|
1965 |
Map<Integer, Integer> catalogIdAndQtyMap, int fofoId,
|
| 2006 |
Map<Integer, Map<Integer, List<SaholicCIS>>> warehouseItemAvailabilityMap,
|
1966 |
Map<Integer, Map<Integer, List<SaholicCIS>>> warehouseItemAvailabilityMap,
|
| 2007 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap, List<Item> items,
|
1967 |
Map<Integer, Map<Integer, List<SaholicPOItem>>> warehousePoItemAvailabilityMap, List<Item> items,
|
| 2008 |
CustomRetailer customRetailer) throws ProfitMandiBusinessException {
|
1968 |
CustomRetailer customRetailer) throws ProfitMandiBusinessException {
|
| 2009 |
|
1969 |
|
| 2010 |
int minQty = qty;
|
1970 |
int minQty = qty;
|
| 2011 |
int inStockQty = 0;
|
1971 |
int inStockQty = 0;
|
| 2012 |
int processingQty = 0;
|
1972 |
int processingQty = 0;
|
| 2013 |
int grnPendingQty = 0;
|
1973 |
int grnPendingQty = 0;
|
| Line 2075... |
Line 2035... |
| 2075 |
fm.setAvailabitiy(allColorNetAvailability);
|
2035 |
fm.setAvailabitiy(allColorNetAvailability);
|
| 2076 |
return fm;
|
2036 |
return fm;
|
| 2077 |
|
2037 |
|
| 2078 |
}
|
2038 |
}
|
| 2079 |
|
2039 |
|
| - |
|
2040 |
@RequestMapping(value = "/indent/send-po-notification", method = RequestMethod.GET)
|
| - |
|
2041 |
public String SendPONotification(HttpServletRequest request, Model model) {
|
| - |
|
2042 |
model.addAttribute("warehouses", ProfitMandiConstants.WAREHOUSE_MAP);
|
| - |
|
2043 |
return "send-po-notification";
|
| - |
|
2044 |
}
|
| - |
|
2045 |
|
| - |
|
2046 |
@RequestMapping(value = "/indent/send-po-notification", method = RequestMethod.POST)
|
| - |
|
2047 |
public String sendPONotification(HttpServletRequest request, @RequestBody POItemWarehouseModel poItemWarehouseModel, Model model) throws Exception {
|
| - |
|
2048 |
|
| - |
|
2049 |
Map<Integer, Item> selectedItemsMap = itemRepository.selectByIds(poItemWarehouseModel.getItemIdQuantityList().stream().map(x -> x.getItemId()).collect(Collectors.toSet())).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
2050 |
|
| - |
|
2051 |
Set<String> brands = selectedItemsMap.values().stream().map(x -> x.getBrand().toLowerCase()).collect(Collectors.toSet());
|
| - |
|
2052 |
int warehouseId = poItemWarehouseModel.getWarehouseId();
|
| - |
|
2053 |
|
| - |
|
2054 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
2055 |
sendNotificationModel.setCampaignName("SendPo");
|
| - |
|
2056 |
sendNotificationModel.setTitle(String.format(PO_TITLE_STRING));
|
| - |
|
2057 |
StringBuilder stringBuilder = new StringBuilder();
|
| - |
|
2058 |
poItemWarehouseModel.getItemIdQuantityList().stream().forEach(itemIdQuantity -> {
|
| - |
|
2059 |
stringBuilder.append(selectedItemsMap.get(itemIdQuantity.getItemId()).getItemDescription()).append("-").append(itemIdQuantity.getQuantity()).append("pcs").append("\n");
|
| - |
|
2060 |
});
|
| - |
|
2061 |
sendNotificationModel.setMessage(stringBuilder.toString());
|
| - |
|
2062 |
sendNotificationModel.setType("url");
|
| - |
|
2063 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| - |
|
2064 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| - |
|
2065 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| - |
|
2066 |
|
| - |
|
2067 |
List<BrandRegionMapping> brandRegionMappings = brandRegionMappingRepository.selectAll().stream().filter(x -> brands.contains(x.getBrand().toLowerCase()) && x.getFromWarehouseId() == warehouseId && x.isAccessory() == false).collect(Collectors.toList());
|
| - |
|
2068 |
List<Integer> toWarehouseIds = brandRegionMappings.stream().map(x -> x.getToWarehouseId()).collect(Collectors.toList());
|
| - |
|
2069 |
|
| - |
|
2070 |
List<Integer> fofoIds = fofoStoreRepository.selectByWarehouseIds(toWarehouseIds).stream().filter(x -> !x.isInternal() && x.isActive()).map(x -> x.getId()).collect(Collectors.toList());
|
| - |
|
2071 |
|
| - |
|
2072 |
List<Integer> userIds = userAccountRepository.selectUserIdsByRetailerIds(fofoIds);
|
| - |
|
2073 |
sendNotificationModel.setUserIds(userIds);
|
| - |
|
2074 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
2075 |
model.addAttribute("response", true);
|
| - |
|
2076 |
return "response";
|
| - |
|
2077 |
}
|
| - |
|
2078 |
|
| 2080 |
}
|
2079 |
}
|
| 2081 |
|
2080 |
|