| 26607 |
amit.gupta |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import com.eclipsesource.json.JsonObject;
|
|
|
4 |
import com.google.gson.Gson;
|
|
|
5 |
import com.google.gson.reflect.TypeToken;
|
| 37937 |
amit |
6 |
import com.spice.profitmandi.service.user.StoreStatusService;
|
| 28377 |
tejbeer |
7 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 26607 |
amit.gupta |
8 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
|
|
9 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 30123 |
amit.gupta |
10 |
import com.spice.profitmandi.common.model.*;
|
| 34917 |
vikas |
11 |
import com.spice.profitmandi.dao.entity.affiliate.AffiliateEarnings;
|
| 34902 |
vikas |
12 |
import com.spice.profitmandi.dao.entity.affiliate.AffiliateProduct;
|
| 34444 |
vikas.jang |
13 |
import com.spice.profitmandi.dao.entity.catalog.LiquidationDetail;
|
| 36428 |
aman |
14 |
import com.spice.profitmandi.dao.entity.catalog.SuperCatalogMapping;
|
| 26607 |
amit.gupta |
15 |
import com.spice.profitmandi.common.solr.SolrService;
|
| 28304 |
amit.gupta |
16 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 28566 |
tejbeer |
17 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 28405 |
amit.gupta |
18 |
import com.spice.profitmandi.common.util.Utils;
|
| 26607 |
amit.gupta |
19 |
import com.spice.profitmandi.common.web.client.RestClient;
|
|
|
20 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 34242 |
tejus.loha |
21 |
import com.spice.profitmandi.dao.entity.WebEntity.NavBar;
|
| 34444 |
vikas.jang |
22 |
import com.spice.profitmandi.dao.entity.catalog.Bid;
|
| 26607 |
amit.gupta |
23 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 34444 |
vikas.jang |
24 |
import com.spice.profitmandi.dao.entity.catalog.Liquidation;
|
| 26607 |
amit.gupta |
25 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 33436 |
ranu |
26 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
| 30123 |
amit.gupta |
27 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 33399 |
ranu |
28 |
import com.spice.profitmandi.dao.entity.inventory.State;
|
| 31203 |
tejbeer |
29 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 26630 |
amit.gupta |
30 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
| 31573 |
tejbeer |
31 |
import com.spice.profitmandi.dao.enumuration.dtr.WebListingSource;
|
| 27045 |
tejbeer |
32 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 30123 |
amit.gupta |
33 |
import com.spice.profitmandi.dao.model.*;
|
| 33436 |
ranu |
34 |
import com.spice.profitmandi.dao.model.pendingOrder.PendingOrderDetail;
|
| 34902 |
vikas |
35 |
import com.spice.profitmandi.dao.repository.affiliateLink.AffiliateLinkRepository;
|
| 34444 |
vikas.jang |
36 |
import com.spice.profitmandi.dao.repository.catalog.BidRepository;
|
| 26607 |
amit.gupta |
37 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 34444 |
vikas.jang |
38 |
import com.spice.profitmandi.dao.repository.catalog.LiquidationRepository;
|
| 36428 |
aman |
39 |
import com.spice.profitmandi.dao.repository.catalog.SuperCatalogMappingRepository;
|
| 26607 |
amit.gupta |
40 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 28290 |
tejbeer |
41 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 30123 |
amit.gupta |
42 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
|
|
43 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 26607 |
amit.gupta |
44 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
| 33399 |
ranu |
45 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 28582 |
amit.gupta |
46 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 34248 |
aman.kumar |
47 |
import com.spice.profitmandi.dao.repository.webRepository.NavBarRepository;
|
| 34917 |
vikas |
48 |
import com.spice.profitmandi.dao.service.AffiliateService;
|
| 34494 |
vikas.jang |
49 |
import com.spice.profitmandi.dao.service.BidService;
|
| 34882 |
aman |
50 |
import com.spice.profitmandi.dao.service.OTPResponse;
|
| 26784 |
amit.gupta |
51 |
import com.spice.profitmandi.service.CustomerService;
|
| 28377 |
tejbeer |
52 |
import com.spice.profitmandi.service.EmailService;
|
| 35243 |
aman |
53 |
import com.spice.profitmandi.service.FofoUser;
|
| 28377 |
tejbeer |
54 |
import com.spice.profitmandi.service.NotificationService;
|
| 26607 |
amit.gupta |
55 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 34444 |
vikas.jang |
56 |
import com.spice.profitmandi.service.catalog.BiddingModel;
|
| 33399 |
ranu |
57 |
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
|
|
|
58 |
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
|
| 36428 |
aman |
59 |
import com.spice.profitmandi.service.catalog.SuperCatalogModel;
|
| 30123 |
amit.gupta |
60 |
import com.spice.profitmandi.service.inventory.*;
|
| 28566 |
tejbeer |
61 |
import com.spice.profitmandi.service.order.OrderService;
|
| 26683 |
amit.gupta |
62 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 26651 |
amit.gupta |
63 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 33514 |
tejus.loha |
64 |
import com.spice.profitmandi.dao.service.OtpProcessor;
|
| 34654 |
vikas.jang |
65 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 26607 |
amit.gupta |
66 |
import com.spice.profitmandi.web.res.DealBrands;
|
|
|
67 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
|
|
68 |
import com.spice.profitmandi.web.res.DealsResponse;
|
|
|
69 |
import com.spice.profitmandi.web.res.ValidateCartResponse;
|
| 28322 |
amit.gupta |
70 |
import com.spice.profitmandi.web.services.PartnerIndexService;
|
| 36428 |
aman |
71 |
import com.spice.profitmandi.service.tag.ItemTagModel;
|
|
|
72 |
import in.shop2020.model.v1.catalog.status;
|
| 34654 |
vikas.jang |
73 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| 26607 |
amit.gupta |
74 |
import io.swagger.annotations.ApiImplicitParam;
|
|
|
75 |
import io.swagger.annotations.ApiImplicitParams;
|
|
|
76 |
import io.swagger.annotations.ApiOperation;
|
| 30123 |
amit.gupta |
77 |
import org.apache.commons.lang3.StringUtils;
|
|
|
78 |
import org.apache.http.conn.HttpHostConnectException;
|
|
|
79 |
import org.apache.logging.log4j.LogManager;
|
|
|
80 |
import org.apache.logging.log4j.Logger;
|
|
|
81 |
import org.json.JSONArray;
|
|
|
82 |
import org.json.JSONObject;
|
|
|
83 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
84 |
import org.springframework.beans.factory.annotation.Value;
|
| 35079 |
vikas |
85 |
import org.springframework.cache.annotation.Cacheable;
|
| 30123 |
amit.gupta |
86 |
import org.springframework.http.HttpHeaders;
|
|
|
87 |
import org.springframework.http.HttpStatus;
|
|
|
88 |
import org.springframework.http.MediaType;
|
|
|
89 |
import org.springframework.http.ResponseEntity;
|
|
|
90 |
import org.springframework.stereotype.Controller;
|
|
|
91 |
import org.springframework.transaction.annotation.Transactional;
|
| 33399 |
ranu |
92 |
import org.springframework.ui.Model;
|
| 30123 |
amit.gupta |
93 |
import org.springframework.web.bind.annotation.*;
|
| 26607 |
amit.gupta |
94 |
|
| 30123 |
amit.gupta |
95 |
import javax.servlet.http.HttpServletRequest;
|
|
|
96 |
import javax.servlet.http.HttpServletResponse;
|
|
|
97 |
import java.io.ByteArrayOutputStream;
|
|
|
98 |
import java.io.IOException;
|
| 35243 |
aman |
99 |
import java.time.LocalDate;
|
| 30123 |
amit.gupta |
100 |
import java.time.LocalDateTime;
|
|
|
101 |
import java.time.LocalTime;
|
| 35243 |
aman |
102 |
import java.time.YearMonth;
|
| 30123 |
amit.gupta |
103 |
import java.time.format.DateTimeFormatter;
|
|
|
104 |
import java.util.*;
|
|
|
105 |
import java.util.stream.Collectors;
|
|
|
106 |
|
| 26607 |
amit.gupta |
107 |
@Controller
|
|
|
108 |
@Transactional(rollbackFor = Throwable.class)
|
|
|
109 |
public class StoreController {
|
|
|
110 |
|
| 32018 |
tejbeer |
111 |
private static final Logger logger = LogManager.getLogger(StoreController.class);
|
| 26630 |
amit.gupta |
112 |
|
| 32018 |
tejbeer |
113 |
private static final LocalTime CUTOFF_TIME = LocalTime.of(15, 0);
|
| 26745 |
amit.gupta |
114 |
|
| 32018 |
tejbeer |
115 |
private static final List<Integer> TAG_IDS = Arrays.asList(4);
|
| 26745 |
amit.gupta |
116 |
|
| 32018 |
tejbeer |
117 |
@Autowired
|
|
|
118 |
CustomerAddressRepository customerAddressRepository;
|
| 28392 |
tejbeer |
119 |
|
| 32018 |
tejbeer |
120 |
@Autowired
|
|
|
121 |
WebOfferRepository webOfferRepository;
|
| 26607 |
amit.gupta |
122 |
|
| 32018 |
tejbeer |
123 |
@Value("${new.solr.url}")
|
|
|
124 |
private String solrUrl;
|
| 28345 |
tejbeer |
125 |
|
| 32018 |
tejbeer |
126 |
@Autowired
|
|
|
127 |
private PartnerIndexService partnerIndexService;
|
| 28345 |
tejbeer |
128 |
|
| 32018 |
tejbeer |
129 |
@Autowired
|
|
|
130 |
InventoryService inventoryService;
|
| 27045 |
tejbeer |
131 |
|
| 32018 |
tejbeer |
132 |
@Autowired
|
|
|
133 |
UserAccountRepository userAccountRepository;
|
| 26923 |
amit.gupta |
134 |
|
| 32018 |
tejbeer |
135 |
@Value("${python.api.host}")
|
|
|
136 |
private String host;
|
| 26833 |
amit.gupta |
137 |
|
| 32018 |
tejbeer |
138 |
@Autowired
|
|
|
139 |
CustomerService customerService;
|
| 26607 |
amit.gupta |
140 |
|
| 32018 |
tejbeer |
141 |
@Value("${python.api.port}")
|
|
|
142 |
private int port;
|
| 26923 |
amit.gupta |
143 |
|
| 32018 |
tejbeer |
144 |
@Autowired
|
|
|
145 |
private SaholicInventoryService saholicInventoryService;
|
| 26607 |
amit.gupta |
146 |
|
| 32018 |
tejbeer |
147 |
@Autowired
|
|
|
148 |
private PincodePartnerRepository pincodePartnerRepository;
|
| 26715 |
amit.gupta |
149 |
|
| 32018 |
tejbeer |
150 |
@Autowired
|
|
|
151 |
private FofoStoreRepository fofoStoreRepository;
|
| 26745 |
amit.gupta |
152 |
|
| 32018 |
tejbeer |
153 |
@Autowired
|
|
|
154 |
private RetailerService retailerService;
|
| 26861 |
tejbeer |
155 |
|
| 32018 |
tejbeer |
156 |
@Autowired
|
|
|
157 |
private PendingOrderRepository pendingOrderRepository;
|
| 26861 |
tejbeer |
158 |
|
| 32018 |
tejbeer |
159 |
@Autowired
|
|
|
160 |
private PendingOrderItemRepository pendingOrderItemRepository;
|
| 26652 |
amit.gupta |
161 |
|
| 32018 |
tejbeer |
162 |
@Autowired
|
|
|
163 |
private PendingOrderService pendingOrderService;
|
| 26648 |
amit.gupta |
164 |
|
| 32018 |
tejbeer |
165 |
@Autowired
|
|
|
166 |
private CustomerRepository customerRepository;
|
| 26774 |
amit.gupta |
167 |
|
| 32018 |
tejbeer |
168 |
@Autowired
|
|
|
169 |
private SolrService commonSolrService;
|
| 26607 |
amit.gupta |
170 |
|
| 32018 |
tejbeer |
171 |
@Autowired
|
|
|
172 |
private OtpProcessor otpProcessor;
|
| 26630 |
amit.gupta |
173 |
|
| 32018 |
tejbeer |
174 |
@Autowired
|
|
|
175 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 26607 |
amit.gupta |
176 |
|
| 32018 |
tejbeer |
177 |
@Autowired
|
|
|
178 |
private ResponseSender<?> responseSender;
|
| 26607 |
amit.gupta |
179 |
|
| 32018 |
tejbeer |
180 |
@Autowired
|
|
|
181 |
private TagListingRepository tagListingRepository;
|
| 26607 |
amit.gupta |
182 |
|
| 32018 |
tejbeer |
183 |
@Autowired
|
|
|
184 |
private ItemRepository itemRepository;
|
| 26701 |
amit.gupta |
185 |
|
| 32018 |
tejbeer |
186 |
@Autowired
|
|
|
187 |
private SchemeService schemeService;
|
| 26607 |
amit.gupta |
188 |
|
| 32018 |
tejbeer |
189 |
@Autowired
|
| 36428 |
aman |
190 |
private SuperCatalogMappingRepository superCatalogMappingRepository;
|
|
|
191 |
|
|
|
192 |
@Autowired
|
|
|
193 |
private Mongo mongoClient;
|
|
|
194 |
|
|
|
195 |
@Autowired
|
| 32018 |
tejbeer |
196 |
private UserRepository userRepository;
|
| 28566 |
tejbeer |
197 |
|
| 32018 |
tejbeer |
198 |
@Autowired
|
|
|
199 |
private ItemAvailabilityCacheRepository itemAvailabilityCacheRepository;
|
| 26607 |
amit.gupta |
200 |
|
| 32018 |
tejbeer |
201 |
@Autowired
|
|
|
202 |
private WebListingRepository webListingRepository;
|
| 26745 |
amit.gupta |
203 |
|
| 32018 |
tejbeer |
204 |
@Autowired
|
|
|
205 |
private WebProductListingRepository webProductListingRepository;
|
| 26745 |
amit.gupta |
206 |
|
| 32018 |
tejbeer |
207 |
@Autowired
|
|
|
208 |
private RoleManager roleManagerService;
|
| 26607 |
amit.gupta |
209 |
|
| 32018 |
tejbeer |
210 |
@Autowired
|
|
|
211 |
EmailService emailService;
|
| 27028 |
tejbeer |
212 |
|
| 32018 |
tejbeer |
213 |
@Autowired
|
|
|
214 |
CsService csService;
|
| 28339 |
tejbeer |
215 |
|
| 32018 |
tejbeer |
216 |
@Autowired
|
|
|
217 |
private NotificationService notificationService;
|
| 28377 |
tejbeer |
218 |
|
| 32018 |
tejbeer |
219 |
@Autowired
|
|
|
220 |
private com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
|
| 28377 |
tejbeer |
221 |
|
| 32018 |
tejbeer |
222 |
@Autowired
|
|
|
223 |
private FofoOrderRepository fofoOrderRepository;
|
| 28566 |
tejbeer |
224 |
|
| 32018 |
tejbeer |
225 |
@Autowired
|
|
|
226 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 28566 |
tejbeer |
227 |
|
| 32018 |
tejbeer |
228 |
@Autowired
|
|
|
229 |
private OrderService orderService;
|
| 29515 |
tejbeer |
230 |
|
| 32018 |
tejbeer |
231 |
@Autowired
|
| 33436 |
ranu |
232 |
InsurancePolicyRepository insurancePolicyRepository;
|
|
|
233 |
|
|
|
234 |
@Autowired
|
| 34444 |
vikas.jang |
235 |
LiquidationRepository liquidationRepository;
|
|
|
236 |
|
|
|
237 |
@Autowired
|
| 33436 |
ranu |
238 |
PendingOrderPlanRepository pendingOrderPlanRepository;
|
|
|
239 |
|
|
|
240 |
@Autowired
|
| 32018 |
tejbeer |
241 |
private ScratchOfferRepository scratchOfferRepository;
|
|
|
242 |
private static final List<String> offlineOrders = Arrays.asList("EMIOD", "POD");
|
| 28339 |
tejbeer |
243 |
|
| 34242 |
tejus.loha |
244 |
@Autowired
|
|
|
245 |
NavBarRepository navBarRepository;
|
|
|
246 |
|
| 34444 |
vikas.jang |
247 |
@Autowired
|
|
|
248 |
BidRepository bidRepository;
|
|
|
249 |
|
| 34494 |
vikas.jang |
250 |
@Autowired
|
|
|
251 |
BidService bidService;
|
|
|
252 |
|
| 34654 |
vikas.jang |
253 |
@Autowired
|
|
|
254 |
WalletService walletService;
|
|
|
255 |
|
| 34902 |
vikas |
256 |
@Autowired
|
| 37937 |
amit |
257 |
private StoreStatusService storeStatusService;
|
|
|
258 |
|
|
|
259 |
@Autowired
|
| 34902 |
vikas |
260 |
AffiliateLinkRepository affiliateLinkRepository;
|
|
|
261 |
|
| 34917 |
vikas |
262 |
@Autowired
|
|
|
263 |
AffiliateService affiliateService;
|
|
|
264 |
|
| 35243 |
aman |
265 |
@Autowired
|
|
|
266 |
FofoUser fofoUser;
|
|
|
267 |
|
| 37144 |
amit |
268 |
@Autowired
|
|
|
269 |
private com.spice.profitmandi.web.services.PartnerSolrClient partnerSolrClient;
|
|
|
270 |
|
|
|
271 |
@Autowired
|
|
|
272 |
private com.spice.profitmandi.service.catalog.BrandsService brandsService;
|
|
|
273 |
|
| 32018 |
tejbeer |
274 |
List<String> filterableParams = Arrays.asList("brand");
|
| 26607 |
amit.gupta |
275 |
|
| 32018 |
tejbeer |
276 |
@RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
277 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
|
|
278 |
@ApiOperation(value = "Get unit deal object")
|
|
|
279 |
public ResponseEntity<?> getUnitFocoDeal(HttpServletRequest request, @PathVariable(value = "id") long id) throws ProfitMandiBusinessException {
|
|
|
280 |
List<FofoCatalogResponse> dealResponses = new ArrayList<>();
|
|
|
281 |
List<Integer> tagIds = Arrays.asList(4);
|
|
|
282 |
FofoCatalogResponse fofoCatalogResponse = null;
|
|
|
283 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
|
|
284 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
|
|
285 |
String categoryId = "(3 OR 6)";
|
| 26745 |
amit.gupta |
286 |
|
| 32018 |
tejbeer |
287 |
Map<String, String> params = new HashMap<>();
|
|
|
288 |
List<String> mandatoryQ = new ArrayList<>();
|
|
|
289 |
String catalogString = "catalog" + id;
|
| 26607 |
amit.gupta |
290 |
|
| 32018 |
tejbeer |
291 |
mandatoryQ.add(String.format("+(categoryId_i:%s) +(id:%s) +{!parent which=\"id:%s\"} tagId_i:(%s)", categoryId, catalogString, catalogString, StringUtils.join(tagIds, " ")));
|
| 26668 |
amit.gupta |
292 |
|
| 32018 |
tejbeer |
293 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
|
|
294 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
|
|
295 |
params.put("sort", "rank_i asc, create_s desc");
|
|
|
296 |
params.put("wt", "json");
|
| 37144 |
amit |
297 |
JSONArray docs = partnerSolrClient.selectDocs(params, userInfo.getRetailerId());
|
| 32018 |
tejbeer |
298 |
dealResponses = getCatalogResponse(docs, false, userInfo.getRetailerId());
|
|
|
299 |
fofoCatalogResponse = dealResponses.get(0);
|
|
|
300 |
fofoCatalogResponse.setWebOffers(webOfferRepository.selectAllActiveOffers().get(fofoCatalogResponse.getCatalogId()));
|
| 28467 |
tejbeer |
301 |
|
| 32018 |
tejbeer |
302 |
} else {
|
|
|
303 |
return responseSender.badRequest(
|
|
|
304 |
new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
|
|
|
305 |
}
|
|
|
306 |
return responseSender.ok(dealResponses.get(0));
|
|
|
307 |
}
|
| 26668 |
amit.gupta |
308 |
|
| 32018 |
tejbeer |
309 |
private Object toDealObject(JsonObject jsonObject) {
|
|
|
310 |
if (jsonObject.get("dealObject") != null && jsonObject.get("dealObject").asInt() == 1) {
|
|
|
311 |
return new Gson().fromJson(jsonObject.toString(), DealObjectResponse.class);
|
|
|
312 |
}
|
|
|
313 |
return new Gson().fromJson(jsonObject.toString(), DealsResponse.class);
|
|
|
314 |
}
|
| 26607 |
amit.gupta |
315 |
|
| 32018 |
tejbeer |
316 |
@RequestMapping(value = "/store/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
317 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
|
|
318 |
@ApiOperation(value = "Get brand list and count for category")
|
|
|
319 |
public ResponseEntity<?> getBrands(HttpServletRequest request, @RequestParam(value = "category_id") String category_id) throws ProfitMandiBusinessException {
|
|
|
320 |
logger.info("Request " + request.getParameterMap());
|
|
|
321 |
String response = null;
|
|
|
322 |
// TODO: move to properties
|
|
|
323 |
String uri = ProfitMandiConstants.URL_BRANDS;
|
|
|
324 |
RestClient rc = new RestClient();
|
|
|
325 |
Map<String, String> params = new HashMap<>();
|
|
|
326 |
params.put("category_id", category_id);
|
|
|
327 |
List<DealBrands> dealBrandsResponse = null;
|
|
|
328 |
try {
|
|
|
329 |
response = rc.get(SchemeType.HTTP, host, port, uri, params);
|
|
|
330 |
} catch (HttpHostConnectException e) {
|
|
|
331 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
|
|
332 |
}
|
| 26607 |
amit.gupta |
333 |
|
| 32018 |
tejbeer |
334 |
dealBrandsResponse = new Gson().fromJson(response, new TypeToken<List<DealBrands>>() {
|
|
|
335 |
}.getType());
|
| 26607 |
amit.gupta |
336 |
|
| 37144 |
amit |
337 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
|
|
338 |
List<String> restrictedBrands = brandsService.restrictedBrands(userInfo.getRetailerId());
|
|
|
339 |
dealBrandsResponse = dealBrandsResponse.stream().filter(x -> !restrictedBrands.contains(x.getBrand()))
|
|
|
340 |
.collect(Collectors.toList());
|
|
|
341 |
|
| 32018 |
tejbeer |
342 |
return responseSender.ok(dealBrandsResponse);
|
|
|
343 |
}
|
| 26607 |
amit.gupta |
344 |
|
| 32018 |
tejbeer |
345 |
@RequestMapping(value = "/store/listing/{listingUrl}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
346 |
public ResponseEntity<?> bestSellers(HttpServletRequest request, @PathVariable String listingUrl) throws Exception {
|
|
|
347 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
|
|
348 |
WebListing webListing = webListingRepository.selectByUrl(listingUrl);
|
|
|
349 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing));
|
|
|
350 |
return responseSender.ok(webListing);
|
|
|
351 |
}
|
| 26654 |
amit.gupta |
352 |
|
| 32018 |
tejbeer |
353 |
@RequestMapping(value = "/store/otp/generateOTP", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
354 |
public ResponseEntity<?> generateOtp(HttpServletRequest request, @RequestParam String mobile) throws Exception {
|
| 26630 |
amit.gupta |
355 |
|
| 32018 |
tejbeer |
356 |
return responseSender.ok(otpProcessor.generateOtp(mobile, OtpType.REGISTRATION));
|
| 26630 |
amit.gupta |
357 |
|
| 32018 |
tejbeer |
358 |
}
|
| 26652 |
amit.gupta |
359 |
|
| 32018 |
tejbeer |
360 |
@RequestMapping(value = "/store/checkmobile/{mobile}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 34882 |
aman |
361 |
public ResponseEntity<?> checkRegistrationUsingMobile(HttpServletRequest request, @PathVariable String mobile ,@RequestParam(required = false, defaultValue = "false") boolean isSmartSeller) throws Exception {
|
| 32018 |
tejbeer |
362 |
try {
|
|
|
363 |
Customer customer = customerRepository.selectByMobileNumber(mobile);
|
|
|
364 |
customer.setPasswordExist(StringUtils.isNotEmpty(customer.getPassword()));
|
| 34882 |
aman |
365 |
if(isSmartSeller){
|
| 34917 |
vikas |
366 |
//ToDo: Send welcome mail
|
| 34882 |
aman |
367 |
customer.setSmartSeller(isSmartSeller);
|
| 34917 |
vikas |
368 |
List<String> bccTo = Arrays.asList("sdtech@smartdukaan.com", "sriwant.wariz@smartdukaan.com");
|
|
|
369 |
String[] userEmail = new String[]{customer.getEmailId()};
|
|
|
370 |
emailService.sendMailWithAttachments("Welcome to SmartDukaan's SmartSeller", "welcome-smartseller.vm", null, userEmail, null, bccTo.toArray(new String[0]));
|
| 34882 |
aman |
371 |
}
|
| 32018 |
tejbeer |
372 |
return responseSender.ok(new CustomerModel(true, customer));
|
|
|
373 |
} catch (Exception e) {
|
|
|
374 |
return responseSender.ok(new CustomerModel(false, null));
|
|
|
375 |
}
|
|
|
376 |
}
|
| 26833 |
amit.gupta |
377 |
|
| 34477 |
aman.kumar |
378 |
|
| 32019 |
tejbeer |
379 |
@RequestMapping(value = "/store/getCustomerById/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 32018 |
tejbeer |
380 |
public ResponseEntity<?> getCustomerById(HttpServletRequest request, @PathVariable int id) throws Exception {
|
| 26774 |
amit.gupta |
381 |
|
| 32018 |
tejbeer |
382 |
Customer customer = customerRepository.selectById(id);
|
|
|
383 |
customer.setPasswordExist(StringUtils.isNotEmpty(customer.getPassword()));
|
| 32218 |
tejbeer |
384 |
|
| 32018 |
tejbeer |
385 |
return responseSender.ok(customer);
|
| 26857 |
amit.gupta |
386 |
|
| 32018 |
tejbeer |
387 |
}
|
| 26652 |
amit.gupta |
388 |
|
| 32018 |
tejbeer |
389 |
@RequestMapping(value = "/store/signin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
390 |
public ResponseEntity<?> signIn(HttpServletRequest request, @RequestBody UserModel userModel) throws Exception {
|
|
|
391 |
if (customerService.authenticate(userModel.getMobile(), userModel.getPassword())) {
|
|
|
392 |
return responseSender.ok(true);
|
|
|
393 |
} else {
|
| 34899 |
aman |
394 |
return responseSender.badRequest("Invalid Credentials");
|
| 32018 |
tejbeer |
395 |
}
|
|
|
396 |
}
|
| 27028 |
tejbeer |
397 |
|
| 32018 |
tejbeer |
398 |
@RequestMapping(value = "/store/resetPassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 34190 |
aman.kumar |
399 |
public ResponseEntity<?> resetPassword(@RequestBody UserModel userModel) throws Exception {
|
| 34247 |
aman.kumar |
400 |
if ((userModel.getMobile() == null || userModel.getMobile().isEmpty()) && (userModel.getPassword() == null || userModel.getPassword().isEmpty())) {
|
|
|
401 |
throw new ProfitMandiBusinessException("error", "", "all field are required");
|
|
|
402 |
}
|
| 34259 |
aman.kumar |
403 |
try {
|
|
|
404 |
customerService.resetPassword(userModel.getMobile(), userModel.getPassword());
|
|
|
405 |
} catch (ProfitMandiBusinessException p) {
|
|
|
406 |
throw new ProfitMandiBusinessException("error", "", "An error occurred while resetting password");
|
|
|
407 |
}
|
| 34247 |
aman.kumar |
408 |
|
| 32018 |
tejbeer |
409 |
return responseSender.ok(true);
|
|
|
410 |
}
|
| 34242 |
tejus.loha |
411 |
|
| 34190 |
aman.kumar |
412 |
@RequestMapping(value = "/store/changePassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
413 |
public ResponseEntity<?> changePassword(@RequestBody UserModel userModel) throws Exception {
|
| 34259 |
aman.kumar |
414 |
logger.info("UserModel - " + userModel);
|
|
|
415 |
if ((userModel.getOldPassword() == null || userModel.getOldPassword().isEmpty()) && (userModel.getMobile() == null || userModel.getMobile().isEmpty()) && (userModel.getPassword() == null || userModel.getPassword().isEmpty())) {
|
| 34247 |
aman.kumar |
416 |
throw new ProfitMandiBusinessException("error", "", "all fields are required");
|
| 34190 |
aman.kumar |
417 |
}
|
| 34259 |
aman.kumar |
418 |
try {
|
|
|
419 |
customerService.changePassword(userModel.getMobile(), userModel.getOldPassword(), userModel.getPassword());
|
|
|
420 |
} catch (ProfitMandiBusinessException p) {
|
| 34247 |
aman.kumar |
421 |
throw new ProfitMandiBusinessException("error", "", "An error occurred while changing password");
|
|
|
422 |
}
|
|
|
423 |
return responseSender.ok(true);
|
| 34190 |
aman.kumar |
424 |
}
|
| 28339 |
tejbeer |
425 |
|
| 32018 |
tejbeer |
426 |
@RequestMapping(value = "/store/register", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
427 |
public ResponseEntity<?> register(HttpServletRequest request, @RequestBody UserModel userModel) throws Exception {
|
|
|
428 |
Customer customer = new Customer();
|
|
|
429 |
customer.setPassword(userModel.getPassword());
|
|
|
430 |
customer.setEmailId(userModel.getEmail());
|
|
|
431 |
customer.setFirstName(userModel.getFirstName());
|
|
|
432 |
customer.setLastName(userModel.getLastName());
|
|
|
433 |
customer.setMobileNumber(userModel.getMobile());
|
| 34882 |
aman |
434 |
customer.setSmartSeller(userModel.getIsSmartSeller());
|
| 34917 |
vikas |
435 |
if (userModel.getIsSmartSeller()){
|
|
|
436 |
if (userModel.getReferralCode() != null && !userModel.getReferralCode().isEmpty()) {
|
|
|
437 |
int referrerId = Integer.parseInt(userModel.getReferralCode().substring(2));
|
|
|
438 |
AffiliateEarnings earnings = new AffiliateEarnings();
|
|
|
439 |
earnings.setType(ProfitMandiConstants.EARNING_TYPE.REFERRAL);
|
|
|
440 |
earnings.setAffiliateCode(userModel.getReferralCode());
|
|
|
441 |
earnings.setPoints(ProfitMandiConstants.SMARTSELLER_REFERRAL_POINTS);
|
|
|
442 |
earnings.setAmount((float) ProfitMandiConstants.SMARTSELLER_REFERRAL_POINTS);
|
|
|
443 |
earnings.setCustomerId(referrerId);
|
|
|
444 |
earnings.setOrderId(referrerId);
|
|
|
445 |
earnings.setItemId(referrerId);
|
|
|
446 |
earnings.setExpireAt(LocalDateTime.now().plusYears(1));
|
|
|
447 |
affiliateService.createEarnings(earnings);
|
|
|
448 |
customer.setReferralCode(userModel.getReferralCode());
|
|
|
449 |
}
|
|
|
450 |
List<String> bccTo = Arrays.asList("sdtech@smartdukaan.com", "sriwant.wariz@smartdukaan.com");
|
|
|
451 |
String[] userEmail = new String[]{userModel.getEmail()};
|
|
|
452 |
emailService.sendMailWithAttachments("Welcome to SmartDukaan's SmartSeller", "welcome-smartseller.vm", null, userEmail, null, bccTo.toArray(new String[0]));
|
|
|
453 |
}
|
| 32018 |
tejbeer |
454 |
return responseSender.ok(customerService.addCustomer(customer));
|
|
|
455 |
}
|
| 34882 |
aman |
456 |
@RequestMapping(value = "/store/signinWithOtp", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
457 |
public ResponseEntity<?> signInWithOtp(HttpServletRequest request,
|
|
|
458 |
@RequestBody OtpLoginRequest otpLoginRequest) throws Exception {
|
|
|
459 |
OTPResponse otpResponse = otpProcessor.validateOtp(
|
|
|
460 |
otpLoginRequest.getReferenceId(),
|
|
|
461 |
otpLoginRequest.getMobile(),
|
|
|
462 |
otpLoginRequest.getOtp()
|
|
|
463 |
);
|
|
|
464 |
if (otpResponse.isResult()) {
|
|
|
465 |
return responseSender.ok(true);
|
|
|
466 |
} else {
|
|
|
467 |
return responseSender.badRequest("Invalid otp please check again");
|
|
|
468 |
}
|
|
|
469 |
}
|
| 28339 |
tejbeer |
470 |
|
| 33573 |
amit.gupta |
471 |
@RequestMapping(value = "/store/checkplans", method = RequestMethod.GET)
|
| 33436 |
ranu |
472 |
public ResponseEntity<?> getInsurancePrices(HttpServletRequest request, @RequestParam float price, Model model,
|
| 33573 |
amit.gupta |
473 |
@RequestParam int itemId) throws ProfitMandiBusinessException {
|
| 33399 |
ranu |
474 |
logger.info("Request received at url : {}", request.getRequestURI());
|
|
|
475 |
|
|
|
476 |
try {
|
| 33436 |
ranu |
477 |
Map<String, List<MobileInsurancePlan>> response = this.getPlans(price, itemId);
|
|
|
478 |
List<MobileInsurancePlan> combinedPlans = new ArrayList<>();
|
|
|
479 |
for (List<MobileInsurancePlan> plans : response.values()) {
|
|
|
480 |
combinedPlans.addAll(plans);
|
|
|
481 |
}
|
|
|
482 |
return responseSender.ok(combinedPlans);
|
| 33399 |
ranu |
483 |
} catch (Exception e) {
|
|
|
484 |
logger.info(e.getMessage(), e);
|
|
|
485 |
throw new ProfitMandiBusinessException("Plans", "Plans API", "Error formatting insurance plans");
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
@Autowired
|
|
|
491 |
InsuranceService insuranceService;
|
|
|
492 |
|
|
|
493 |
private Map<String, List<MobileInsurancePlan>> getPlans(float sellingPrice, int itemId)
|
|
|
494 |
throws ProfitMandiBusinessException {
|
|
|
495 |
try {
|
| 33573 |
amit.gupta |
496 |
Map<String, List<MobileInsurancePlan>> productDurationPlans = insuranceService.getAllPlans(itemId, sellingPrice, true);
|
| 34822 |
ranu |
497 |
Map<String, List<MobileInsurancePlan>> filteredPlans = productDurationPlans.entrySet()
|
|
|
498 |
.stream()
|
|
|
499 |
.collect(Collectors.toMap(
|
|
|
500 |
Map.Entry::getKey,
|
|
|
501 |
e -> e.getValue().stream()
|
| 34823 |
ranu |
502 |
.filter(plan -> "5".equals(plan.getProviderId()))
|
| 34822 |
ranu |
503 |
.collect(Collectors.toList())
|
|
|
504 |
));
|
|
|
505 |
return filteredPlans;
|
| 33399 |
ranu |
506 |
} catch (Exception e) {
|
|
|
507 |
logger.info(e, e);
|
| 34247 |
aman.kumar |
508 |
throw new ProfitMandiBusinessException("Fetch Insurance Plans", "Insurance", "Could not fetch insurance Plans");
|
| 33399 |
ranu |
509 |
}
|
|
|
510 |
|
|
|
511 |
}
|
|
|
512 |
|
| 32018 |
tejbeer |
513 |
@RequestMapping(value = "/store/confirmOrder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
514 |
public ResponseEntity<?> confirmOrder(HttpServletRequest request, @RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
|
|
|
515 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
|
|
516 |
Integer storeId = userInfo.getRetailerId();
|
|
|
517 |
createPendingOrderRequest.setFofoId(storeId);
|
|
|
518 |
List<CreatePendingOrderItem> pendingOrderItems = createPendingOrderRequest.getCreatePendingOrderItem();
|
|
|
519 |
List<CartItem> cartItems = new ArrayList<>();
|
|
|
520 |
pendingOrderItems.stream().forEach(x -> {
|
|
|
521 |
CartItem ci = new CartItem();
|
|
|
522 |
ci.setItemId(x.getItemId());
|
|
|
523 |
ci.setQuantity(x.getQuantity());
|
|
|
524 |
ci.setSellingPrice(x.getSellingPrice());
|
| 34902 |
vikas |
525 |
ci.setSmartSellerId(x.getSmartSellerId());
|
| 33436 |
ranu |
526 |
ci.setPendingOrderItemPolicyPlan(x.getPendingOrderItemPolicyPlan());
|
| 32018 |
tejbeer |
527 |
cartItems.add(ci);
|
|
|
528 |
});
|
| 33573 |
amit.gupta |
529 |
logger.info("cartItems {}", cartItems);
|
| 32018 |
tejbeer |
530 |
CartResponse cr = this.validateCart(storeId, cartItems);
|
| 34239 |
vikas.jang |
531 |
logger.info("CartResponse cr {}", cr);
|
| 32018 |
tejbeer |
532 |
if (cr.getCartMessageChanged() > 0 || cr.getTotalAmount() != createPendingOrderRequest.getTotalAmount()) {
|
| 34186 |
vikas.jang |
533 |
return responseSender.badRequest(cr.getCartMessages());
|
| 32018 |
tejbeer |
534 |
}
|
| 28377 |
tejbeer |
535 |
|
| 32018 |
tejbeer |
536 |
Map<String, String> returnMap = this.pendingOrderService.createPendingOrder(createPendingOrderRequest, cr);
|
| 28377 |
tejbeer |
537 |
|
| 32018 |
tejbeer |
538 |
PendingOrder pendingOrder = pendingOrderRepository.selectById(Integer.parseInt(returnMap.get("poId")));
|
|
|
539 |
if (offlineOrders.contains(pendingOrder.getPayMethod())) {
|
| 28391 |
tejbeer |
540 |
|
| 32018 |
tejbeer |
541 |
Map<String, Object> emailModel = pendingOrderService.sendCreateOrderMail(pendingOrder);
|
| 28400 |
tejbeer |
542 |
|
| 32018 |
tejbeer |
543 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(pendingOrder.getFofoId());
|
|
|
544 |
Customer customer = customerRepository.selectById(pendingOrder.getCustomerId());
|
|
|
545 |
String[] customerEmail = null;
|
|
|
546 |
if (Utils.validateEmail(customer.getEmailId())) {
|
|
|
547 |
customerEmail = new String[]{customer.getEmailId()};
|
|
|
548 |
}
|
| 31203 |
tejbeer |
549 |
|
| 37629 |
amit |
550 |
List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "niranjan.kala@smartdukaan.com", "ranu.rajput@smartdukaan.com", "devkinandan.lal@smartdukaan.com", customRetailer.getEmail());
|
| 28394 |
tejbeer |
551 |
|
| 32018 |
tejbeer |
552 |
List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
|
|
|
553 |
if (authUserEmails != null) {
|
|
|
554 |
authUserEmails = new ArrayList<>();
|
|
|
555 |
}
|
|
|
556 |
logger.info("authUserEmails {}", authUserEmails);
|
|
|
557 |
authUserEmails.addAll(bccTo);
|
|
|
558 |
StringBuffer itemBuffer = new StringBuffer();
|
|
|
559 |
List<PendingOrderItem> orderItems = pendingOrderItemRepository.selectByOrderId(pendingOrder.getId());
|
|
|
560 |
int totalItems = 0;
|
|
|
561 |
String itemNoColor = null;
|
|
|
562 |
float maxValue = 0;
|
|
|
563 |
for (PendingOrderItem orderItem : orderItems) {
|
|
|
564 |
if (maxValue < orderItem.getSellingPrice()) {
|
|
|
565 |
maxValue = orderItem.getSellingPrice();
|
|
|
566 |
itemNoColor = itemRepository.selectById(orderItem.getItemId()).getItemDescriptionNoColor();
|
|
|
567 |
}
|
|
|
568 |
totalItems += orderItem.getQuantity();
|
|
|
569 |
}
|
|
|
570 |
if (totalItems > 1) {
|
|
|
571 |
itemBuffer.append(StringUtils.abbreviate(itemNoColor, 22));
|
|
|
572 |
itemBuffer.append(" +").append(totalItems - 1).append(" items");
|
|
|
573 |
} else {
|
|
|
574 |
itemBuffer.append(StringUtils.abbreviate(itemNoColor, 30));
|
|
|
575 |
}
|
|
|
576 |
String message = String.format(OtpProcessor.TEMPLATE_ORDER_CREATED, pendingOrder.getId(), itemBuffer.toString(), pendingOrder.getTotalAmount());
|
|
|
577 |
otpProcessor.sendSms(OtpProcessor.TEMPLATE_ORDER_CREATED_ID, message, customer.getMobileNumber());
|
| 28377 |
tejbeer |
578 |
|
| 32018 |
tejbeer |
579 |
emailService.sendMailWithAttachments("Order Created with SmartDukaan", "order-confirm.vm", emailModel, customerEmail, null, bccTo.toArray(new String[0]));
|
| 28377 |
tejbeer |
580 |
|
| 32018 |
tejbeer |
581 |
List<String> emailIds = csService.getAuthUserIdByPartnerId(customRetailer.getPartnerId()).stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
| 27028 |
tejbeer |
582 |
|
| 32018 |
tejbeer |
583 |
emailIds.addAll(
|
|
|
584 |
csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_MARKETING, Arrays.asList(EscalationType.L1, EscalationType.L2, EscalationType.L3, EscalationType.L4)).stream().map(x -> x.getEmailId()).collect(Collectors.toList()));
|
|
|
585 |
emailIds.add("tarun.verma@smartdukaan.com");
|
|
|
586 |
emailIds.add("devkinandan.lal@smartdukaan.com");
|
| 34917 |
vikas |
587 |
emailIds.add("sdtech@smartdukaan.com");
|
|
|
588 |
emailIds.add("sourcing@smartdukaan.com");
|
| 32018 |
tejbeer |
589 |
List<User> user = dtrUserRepository.selectAllByEmailIds(emailIds);
|
|
|
590 |
List<Integer> userIds = user.stream().map(x -> x.getId()).collect(Collectors.toList());
|
| 26630 |
amit.gupta |
591 |
|
| 32018 |
tejbeer |
592 |
logger.info("userIds" + userIds);
|
|
|
593 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
594 |
sendNotificationModel.setCampaignName("Online Order Alert");
|
|
|
595 |
sendNotificationModel.setTitle("Online Order Update");
|
|
|
596 |
sendNotificationModel.setMessage(String.format(
|
|
|
597 |
"You have new Online Order. Please check your Dashboard. In case of an activation scheme pls ensure the handset is activated, payout will be processed as per brand's activation report."));
|
|
|
598 |
sendNotificationModel.setType("url");
|
| 34902 |
vikas |
599 |
sendNotificationModel.setUrl("https://smartdukaan.com/pages/home/notifications");
|
| 32018 |
tejbeer |
600 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
|
|
601 |
sendNotificationModel.setMessageType(MessageType.notification);
|
|
|
602 |
int userId = userAccountRepository.selectUserIdByRetailerId(pendingOrder.getFofoId());
|
|
|
603 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
|
|
604 |
notificationService.sendNotification(sendNotificationModel);
|
| 26857 |
amit.gupta |
605 |
|
| 32018 |
tejbeer |
606 |
SendNotificationModel snm = new SendNotificationModel();
|
|
|
607 |
snm.setCampaignName("Online Order Alert");
|
|
|
608 |
snm.setTitle("Online Order Update");
|
|
|
609 |
snm.setMessage(String.format("Your Partner " + customRetailer.getBusinessName() + " have new Online Order. Please inform your partner. In case of an activation scheme pls ensure the handset is activated, payout will be processed as per brand's activation report."));
|
|
|
610 |
snm.setType("url");
|
| 35758 |
vikas |
611 |
snm.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 32018 |
tejbeer |
612 |
snm.setExpiresat(LocalDateTime.now().plusDays(1));
|
|
|
613 |
snm.setMessageType(MessageType.notification);
|
|
|
614 |
snm.setUserIds(userIds);
|
|
|
615 |
notificationService.sendNotification(snm);
|
| 26857 |
amit.gupta |
616 |
|
| 32018 |
tejbeer |
617 |
}
|
|
|
618 |
return responseSender.ok(returnMap);
|
| 26857 |
amit.gupta |
619 |
|
| 32018 |
tejbeer |
620 |
}
|
|
|
621 |
@RequestMapping(value = "/store/address", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
622 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
|
|
623 |
@ApiOperation(value = "Get brand list and count for category")
|
|
|
624 |
public ResponseEntity<?> getAddress(HttpServletRequest request) throws Exception {
|
|
|
625 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
|
|
626 |
Integer storeId = userInfo.getRetailerId();
|
|
|
627 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(storeId);
|
| 26923 |
amit.gupta |
628 |
|
| 32018 |
tejbeer |
629 |
return responseSender.ok(customRetailer.getAddress());
|
| 28566 |
tejbeer |
630 |
|
| 32018 |
tejbeer |
631 |
}
|
| 34190 |
aman.kumar |
632 |
@RequestMapping(value = "/store/address/defaultAddress/{addressId}/{customerId}", method = RequestMethod.POST)
|
|
|
633 |
@ApiImplicitParams({
|
|
|
634 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")
|
|
|
635 |
})
|
|
|
636 |
@ApiOperation(value = "Set default address for a store")
|
| 34259 |
aman.kumar |
637 |
public ResponseEntity<?> setDefaultAddress(HttpServletRequest request, @PathVariable int addressId, @PathVariable int customerId) throws Exception {
|
| 34190 |
aman.kumar |
638 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
|
|
639 |
CustomerAddress defaultAddress;
|
|
|
640 |
try {
|
|
|
641 |
defaultAddress = customerAddressRepository.selectById(addressId);
|
|
|
642 |
} catch (ProfitMandiBusinessException e) {
|
|
|
643 |
return responseSender.badRequest("Address not found.");
|
|
|
644 |
}
|
|
|
645 |
logger.info("CustomerID: {}", customerId);
|
|
|
646 |
List<CustomerAddress> customerAddresses = customerAddressRepository.selectByActiveCustomerId(customerId);
|
|
|
647 |
logger.info("customerAddresses: {}", customerAddresses);
|
|
|
648 |
for (CustomerAddress addr : customerAddresses) {
|
| 34259 |
aman.kumar |
649 |
if (addr.getDefault() ) {
|
| 34190 |
aman.kumar |
650 |
addr.setDefault(false);
|
|
|
651 |
}
|
|
|
652 |
}
|
|
|
653 |
defaultAddress.setDefault(true);
|
|
|
654 |
return responseSender.ok("Default address updated successfully.");
|
|
|
655 |
}
|
| 28566 |
tejbeer |
656 |
|
| 32018 |
tejbeer |
657 |
@RequestMapping(value = "/store/address/{pincode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
658 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
|
|
659 |
@ApiOperation(value = "Get brand list and count for category")
|
|
|
660 |
public ResponseEntity<?> getStoresByPincode(HttpServletRequest request, @PathVariable String pincode) throws Exception {
|
|
|
661 |
List<PincodePartner> pincodePartners = pincodePartnerRepository.selectPartnersByPincode(pincode);
|
|
|
662 |
int fofoId = ProfitMandiConstants.DEFAULT_STORE;
|
|
|
663 |
if (pincodePartners.size() > 0) {
|
|
|
664 |
List<Integer> fofoIds = pincodePartners.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
|
|
665 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActivePartnersByRetailerIds(fofoIds);
|
|
|
666 |
if (fofoStores.size() > 0) {
|
|
|
667 |
fofoId = fofoStores.get(0).getId();
|
|
|
668 |
}
|
| 28566 |
tejbeer |
669 |
|
| 32018 |
tejbeer |
670 |
}
|
|
|
671 |
return responseSender.ok(fofoStoreRepository.selectByRetailerId(fofoId).getCode());
|
|
|
672 |
}
|
| 28566 |
tejbeer |
673 |
|
| 32018 |
tejbeer |
674 |
@RequestMapping(value = "/store/addresses", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
675 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
|
|
676 |
@ApiOperation(value = "Get brand list and count for category")
|
|
|
677 |
public ResponseEntity<?> getStoresByPincod(HttpServletRequest request, @RequestParam String pincode, @RequestParam(name = "fofoCode", defaultValue = "", required = false) String fofoCode) throws Exception {
|
| 28566 |
tejbeer |
678 |
|
| 32018 |
tejbeer |
679 |
List<CustomRetailer> customerRetailers = new ArrayList<>();
|
| 28566 |
tejbeer |
680 |
|
| 32018 |
tejbeer |
681 |
logger.info("fofoCode" + fofoCode);
|
| 30426 |
tejbeer |
682 |
|
| 32018 |
tejbeer |
683 |
if (fofoCode != null) {
|
|
|
684 |
FofoStore fs = fofoStoreRepository.selectByStoreCode(fofoCode.toUpperCase());
|
|
|
685 |
PincodePartner pp = pincodePartnerRepository.selectPartnerByPincode(pincode, fs.getId());
|
|
|
686 |
if (pp != null) {
|
|
|
687 |
return responseSender.ok(customerRetailers.add(retailerService.getFofoRetailer(pp.getFofoId())));
|
|
|
688 |
} else {
|
| 30426 |
tejbeer |
689 |
|
| 32018 |
tejbeer |
690 |
List<PincodePartner> pincodePartners = pincodePartnerRepository.selectPartnersByPincode(pincode);
|
|
|
691 |
if (pincodePartners.size() > 0) {
|
| 28566 |
tejbeer |
692 |
|
| 32018 |
tejbeer |
693 |
List<Integer> fofoIds = pincodePartners.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
|
|
694 |
List<Integer> activefofoIds = fofoStoreRepository.selectByRetailerIds(fofoIds).stream().filter(x -> x.isActive()).map(x -> x.getId()).collect(Collectors.toList());
|
| 28566 |
tejbeer |
695 |
|
| 32018 |
tejbeer |
696 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 28566 |
tejbeer |
697 |
|
| 32018 |
tejbeer |
698 |
Map<Integer, CustomRetailer> customerRetailerMap = activefofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 28566 |
tejbeer |
699 |
|
| 32018 |
tejbeer |
700 |
customerRetailers.addAll(customerRetailerMap.values());
|
| 30426 |
tejbeer |
701 |
|
| 32018 |
tejbeer |
702 |
}
|
|
|
703 |
return responseSender.ok(customerRetailers);
|
| 30426 |
tejbeer |
704 |
|
| 32018 |
tejbeer |
705 |
}
|
|
|
706 |
} else {
|
| 28566 |
tejbeer |
707 |
|
| 32018 |
tejbeer |
708 |
List<PincodePartner> pincodePartners = pincodePartnerRepository.selectPartnersByPincode(pincode);
|
|
|
709 |
if (pincodePartners.size() > 0) {
|
|
|
710 |
List<Integer> fofoIds = pincodePartners.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
|
|
711 |
List<Integer> activefofoIds = fofoStoreRepository.selectByRetailerIds(fofoIds).stream().filter(x -> x.isActive()).map(x -> x.getId()).collect(Collectors.toList());
|
| 28566 |
tejbeer |
712 |
|
| 32018 |
tejbeer |
713 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 28566 |
tejbeer |
714 |
|
| 32018 |
tejbeer |
715 |
Map<Integer, CustomRetailer> customerRetailerMap = activefofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 28566 |
tejbeer |
716 |
|
| 32018 |
tejbeer |
717 |
customerRetailers.addAll(customerRetailerMap.values());
|
|
|
718 |
}
|
| 28298 |
tejbeer |
719 |
|
| 32018 |
tejbeer |
720 |
return responseSender.ok(customerRetailers);
|
| 30426 |
tejbeer |
721 |
|
| 32018 |
tejbeer |
722 |
}
|
| 30426 |
tejbeer |
723 |
|
| 32018 |
tejbeer |
724 |
}
|
| 30426 |
tejbeer |
725 |
|
| 32018 |
tejbeer |
726 |
@RequestMapping(value = "/store/address/detail/{pincode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
727 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
|
|
728 |
@ApiOperation(value = "Get brand list and count for category")
|
|
|
729 |
public ResponseEntity<?> getStoresDetailsByPincode(HttpServletRequest request, @PathVariable String pincode) throws Exception {
|
|
|
730 |
List<CustomRetailer> customerRetailers = new ArrayList<>();
|
|
|
731 |
List<PincodePartner> pincodePartners = pincodePartnerRepository.selectPartnersByPincode(pincode);
|
| 28298 |
tejbeer |
732 |
|
| 32018 |
tejbeer |
733 |
if (!pincodePartners.isEmpty()) {
|
|
|
734 |
List<Integer> fofoIds = pincodePartners.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
|
|
735 |
List<Integer> activefofoIds = fofoStoreRepository.selectByRetailerIds(fofoIds).stream().filter(x -> x.isActive()).map(x -> x.getId()).collect(Collectors.toList());
|
| 28298 |
tejbeer |
736 |
|
| 32018 |
tejbeer |
737 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
| 28566 |
tejbeer |
738 |
|
| 32018 |
tejbeer |
739 |
Map<Integer, CustomRetailer> customerRetailerMap = activefofoIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null).collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 27049 |
tejbeer |
740 |
|
| 32018 |
tejbeer |
741 |
customerRetailers.addAll(customerRetailerMap.values());
|
|
|
742 |
}
|
| 27049 |
tejbeer |
743 |
|
| 32018 |
tejbeer |
744 |
logger.info("customerRetailers" + customerRetailers);
|
|
|
745 |
return responseSender.ok(customerRetailers);
|
|
|
746 |
}
|
| 26855 |
tejbeer |
747 |
|
| 32018 |
tejbeer |
748 |
@RequestMapping(value = "/store/order", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
749 |
public ResponseEntity<?> getOrderDetail(HttpServletRequest request, @RequestParam(value = "id") int id, @RequestParam(name = "offset") int offset, @RequestParam(name = "limit") int limit) throws Exception {
|
| 33436 |
ranu |
750 |
|
|
|
751 |
List<PendingOrderDetail> pendingOrderDetails = new ArrayList<>();
|
| 32018 |
tejbeer |
752 |
List<Integer> catalogIds = new ArrayList<>();
|
|
|
753 |
List<PendingOrder> pendingOrders = pendingOrderRepository.selectByCustomerId(id, offset, limit);
|
| 26855 |
tejbeer |
754 |
|
| 32018 |
tejbeer |
755 |
if (!pendingOrders.isEmpty()) {
|
|
|
756 |
for (PendingOrder po : pendingOrders) {
|
|
|
757 |
List<PendingOrderItem> pois = pendingOrderItemRepository.selectByOrderId(po.getId());
|
|
|
758 |
for (PendingOrderItem pendingOrderItem : pois) {
|
|
|
759 |
Item item = itemRepository.selectById(pendingOrderItem.getItemId());
|
|
|
760 |
pendingOrderItem.setItemName(item.getItemDescription());
|
| 34287 |
vikas.jang |
761 |
FofoOrderItem fofoItem = fofoOrderItemRepository.selectByPendingOrderItemId(pendingOrderItem.getId());
|
|
|
762 |
if (fofoItem != null) pendingOrderItem.setFofoOrderItem(fofoItem);
|
| 32018 |
tejbeer |
763 |
catalogIds.add(item.getCatalogItemId());
|
|
|
764 |
}
|
| 26855 |
tejbeer |
765 |
|
| 32018 |
tejbeer |
766 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
| 26855 |
tejbeer |
767 |
|
| 32018 |
tejbeer |
768 |
for (PendingOrderItem poi : pois) {
|
| 33436 |
ranu |
769 |
PendingOrderDetail pendingOrderDetail = new PendingOrderDetail();
|
| 32018 |
tejbeer |
770 |
Item item = itemRepository.selectById(poi.getItemId());
|
| 34287 |
vikas.jang |
771 |
if(contentMap.containsKey(item.getCatalogItemId())) {
|
|
|
772 |
JSONObject jsonObj = contentMap.get(item.getCatalogItemId());
|
|
|
773 |
pendingOrderDetail.setImageUrl(jsonObj.getString("imageUrl_s"));
|
|
|
774 |
} else {
|
|
|
775 |
pendingOrderDetail.setImageUrl(ProfitMandiConstants.NO_IMAGE);
|
|
|
776 |
}
|
| 33436 |
ranu |
777 |
pendingOrderDetail.setBrand(item.getBrand());
|
|
|
778 |
pendingOrderDetail.setColor(item.getColor());
|
|
|
779 |
pendingOrderDetail.setPendingOrderItemId(poi.getId());
|
|
|
780 |
pendingOrderDetail.setId(poi.getOrderId());
|
| 34287 |
vikas.jang |
781 |
if(poi.getFofoOrderItem() != null && poi.getFofoOrderItem().getOrderId() > 0) pendingOrderDetail.setFofoOrderId(poi.getFofoOrderItem().getOrderId());
|
| 33436 |
ranu |
782 |
pendingOrderDetail.setItemId(poi.getItemId());
|
|
|
783 |
pendingOrderDetail.setModelName(item.getModelName());
|
|
|
784 |
pendingOrderDetail.setModelNumber(item.getModelNumber());
|
|
|
785 |
pendingOrderDetail.setQuantity(poi.getQuantity());
|
|
|
786 |
pendingOrderDetail.setBilledTimestamp(poi.getBilledTimestamp());
|
|
|
787 |
pendingOrderDetail.setStatus(poi.getStatus());
|
|
|
788 |
pendingOrderDetail.setTotalPrice(poi.getSellingPrice());
|
|
|
789 |
pendingOrderDetail.setPayMethod(po.getPayMethod());
|
|
|
790 |
pendingOrderDetail.setCreatedTimeStamp(po.getCreateTimestamp());
|
|
|
791 |
pendingOrderDetail.setPendingOrderPlan(pendingOrderPlanRepository.selectByPoid(poi.getId()));
|
|
|
792 |
pendingOrderDetails.add(pendingOrderDetail);
|
| 32018 |
tejbeer |
793 |
}
|
|
|
794 |
}
|
|
|
795 |
}
|
| 28566 |
tejbeer |
796 |
|
| 33436 |
ranu |
797 |
return responseSender.ok(pendingOrderDetails);
|
| 32018 |
tejbeer |
798 |
}
|
| 28566 |
tejbeer |
799 |
|
| 32018 |
tejbeer |
800 |
@RequestMapping(value = "/store/invoiceOrder", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
801 |
public ResponseEntity<?> getOrderInvoiceDetail(HttpServletRequest request, @RequestParam(value = "id") int id, @RequestParam(name = "offset") int offset, @RequestParam(name = "limit") int limit) throws Exception {
|
| 33436 |
ranu |
802 |
List<CustomerOrderAndInsuranceDetails> customerOrderAndInsuranceDetails = new ArrayList<>();
|
| 32018 |
tejbeer |
803 |
List<Integer> catalogIds = new ArrayList<>();
|
|
|
804 |
List<FofoOrder> fofoOrders = fofoOrderRepository.selectOrderByCustomerId(id, offset, limit);
|
| 28566 |
tejbeer |
805 |
|
| 32018 |
tejbeer |
806 |
if (!fofoOrders.isEmpty()) {
|
|
|
807 |
for (FofoOrder fo : fofoOrders) {
|
|
|
808 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fo.getId());
|
|
|
809 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
|
|
810 |
Item item = itemRepository.selectById(fofoOrderItem.getItemId());
|
|
|
811 |
fofoOrderItem.setItemName(item.getItemDescription());
|
|
|
812 |
catalogIds.add(item.getCatalogItemId());
|
|
|
813 |
}
|
| 28566 |
tejbeer |
814 |
|
| 32018 |
tejbeer |
815 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
|
|
816 |
for (FofoOrderItem foi : fofoOrderItems) {
|
| 33436 |
ranu |
817 |
CustomerOrderAndInsuranceDetails customerOrderDetail = new CustomerOrderAndInsuranceDetails();
|
| 32018 |
tejbeer |
818 |
Item item = itemRepository.selectById(foi.getItemId());
|
|
|
819 |
JSONObject jsonObj = contentMap.get(item.getCatalogItemId());
|
|
|
820 |
customerOrderDetail.setImageUrl(jsonObj.getString("imageUrl_s"));
|
|
|
821 |
customerOrderDetail.setBrand(item.getBrand());
|
|
|
822 |
customerOrderDetail.setColor(item.getColor());
|
|
|
823 |
customerOrderDetail.setFofoOrderItemId(foi.getId());
|
|
|
824 |
customerOrderDetail.setFofoOrderId(foi.getOrderId());
|
|
|
825 |
customerOrderDetail.setItemId(foi.getItemId());
|
|
|
826 |
customerOrderDetail.setModelName(item.getModelName());
|
|
|
827 |
customerOrderDetail.setModelNumber(item.getModelNumber());
|
|
|
828 |
customerOrderDetail.setQuantity(foi.getQuantity());
|
|
|
829 |
customerOrderDetail.setTotalPrice(foi.getSellingPrice());
|
|
|
830 |
customerOrderDetail.setCreatedTimeStamp(foi.getCreateTimestamp());
|
|
|
831 |
customerOrderDetail.setInvoiceNumber(fo.getInvoiceNumber());
|
|
|
832 |
customerOrderDetail.setCancelledTimestamp(fo.getCancelledTimestamp());
|
| 33436 |
ranu |
833 |
customerOrderDetail.setInsurancePolicies(insurancePolicyRepository.selectByRetailerIdInvoiceNumber(fo.getInvoiceNumber()));
|
|
|
834 |
customerOrderAndInsuranceDetails.add(customerOrderDetail);
|
| 32018 |
tejbeer |
835 |
}
|
| 33436 |
ranu |
836 |
|
| 32018 |
tejbeer |
837 |
}
|
| 28566 |
tejbeer |
838 |
|
| 32018 |
tejbeer |
839 |
}
|
| 33436 |
ranu |
840 |
return responseSender.ok(customerOrderAndInsuranceDetails);
|
| 32018 |
tejbeer |
841 |
}
|
| 28566 |
tejbeer |
842 |
|
| 36377 |
vikas |
843 |
@RequestMapping(value = "/store/generateInvoice", method = RequestMethod.GET, produces = MediaType.APPLICATION_PDF_VALUE)
|
|
|
844 |
public ResponseEntity<byte[]> generateInvoice(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws ProfitMandiBusinessException {
|
| 32018 |
tejbeer |
845 |
InvoicePdfModel pdfModel = null;
|
|
|
846 |
FofoOrder fo = fofoOrderRepository.selectByOrderId(orderId);
|
|
|
847 |
pdfModel = orderService.getInvoicePdfModel(fo.getFofoId(), orderId);
|
|
|
848 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
849 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
|
|
850 |
try {
|
|
|
851 |
byteArrayOutputStream.close();
|
|
|
852 |
} catch (IOException e) {
|
|
|
853 |
e.printStackTrace();
|
|
|
854 |
}
|
| 36377 |
vikas |
855 |
byte[] pdfBytes = byteArrayOutputStream.toByteArray();
|
| 32018 |
tejbeer |
856 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
857 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
|
|
858 |
headers.set("Content-disposition", "inline; filename=invoice-" + pdfModel.getInvoiceNumber() + ".pdf");
|
|
|
859 |
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
|
|
|
860 |
headers.add("Pragma", "no-cache");
|
|
|
861 |
headers.add("Expires", "0");
|
| 36377 |
vikas |
862 |
headers.setContentLength(pdfBytes.length);
|
|
|
863 |
return new ResponseEntity<>(pdfBytes, headers, HttpStatus.OK);
|
| 28287 |
amit.gupta |
864 |
|
| 32018 |
tejbeer |
865 |
}
|
| 26607 |
amit.gupta |
866 |
|
| 32018 |
tejbeer |
867 |
@RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 35079 |
vikas |
868 |
@Cacheable(value = "storesListing", cacheManager = "thirtyMinsTimeOutCacheManager")
|
| 32018 |
tejbeer |
869 |
public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
|
|
|
870 |
List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.store);
|
|
|
871 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 32546 |
amit.gupta |
872 |
for (WebListing webListing : webListings) {
|
|
|
873 |
webListing.setFofoCatalogResponses(getDealResponses(userInfo, webListing));
|
|
|
874 |
}
|
|
|
875 |
return responseSender.ok(webListings);
|
|
|
876 |
}
|
| 33399 |
ranu |
877 |
|
|
|
878 |
@Autowired
|
|
|
879 |
StateRepository stateRepository;
|
|
|
880 |
|
|
|
881 |
@RequestMapping(value = "/store/stateList", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
882 |
public ResponseEntity<?> getStateList(HttpServletRequest request) throws Exception {
|
|
|
883 |
List<State> states = stateRepository.selectAll();
|
|
|
884 |
return responseSender.ok(states);
|
|
|
885 |
}
|
| 32546 |
amit.gupta |
886 |
/*@RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
887 |
public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
|
|
|
888 |
List<WebListing> webListings = webListingRepository.selectAllWebListingByType(Optional.of(true), WebListingSource.store);
|
|
|
889 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 32544 |
amit.gupta |
890 |
Iterator<WebListing> webListingIterator = webListings.iterator();
|
|
|
891 |
while (webListingIterator.hasNext()) {
|
|
|
892 |
WebListing webListing = webListingIterator.next();
|
|
|
893 |
List<FofoCatalogResponse> catalogResponses = getDealResponses(userInfo, webListing);
|
|
|
894 |
boolean isAvailable = catalogResponses.stream().anyMatch(x->x.getItems().stream().anyMatch(y->y.getAvailability()>0));
|
| 32545 |
amit.gupta |
895 |
webListing.setFofoCatalogResponses(catalogResponses);
|
| 32544 |
amit.gupta |
896 |
if(!isAvailable) {
|
|
|
897 |
webListings.remove(webListing);
|
|
|
898 |
}
|
| 32018 |
tejbeer |
899 |
}
|
| 32544 |
amit.gupta |
900 |
|
| 32018 |
tejbeer |
901 |
return responseSender.ok(webListings);
|
| 32546 |
amit.gupta |
902 |
}*/
|
| 26607 |
amit.gupta |
903 |
|
| 32018 |
tejbeer |
904 |
private List<FofoCatalogResponse> getDealResponses(UserInfo userInfo, WebListing webListing) throws ProfitMandiBusinessException {
|
|
|
905 |
List<Integer> webProducts = webProductListingRepository.selectAllByWebListingId(webListing.getId()).stream().filter(x -> x.getRank() > 0).map(x -> x.getEntityId()).collect(Collectors.toList());
|
|
|
906 |
if (webProducts.size() == 0) {
|
|
|
907 |
return new ArrayList<>();
|
|
|
908 |
}
|
|
|
909 |
Map<String, String> params = new HashMap<>();
|
|
|
910 |
List<String> mandatoryQ = new ArrayList<>();
|
|
|
911 |
mandatoryQ.add(String.format(
|
| 33599 |
amit.gupta |
912 |
"+{!parent which=\"catalogId_i:(" + StringUtils.join(webProducts, " ") + ")\"} tagId_i:(%s)", StringUtils.join(TAG_IDS, " ")));
|
| 32018 |
tejbeer |
913 |
params.put("q", StringUtils.join(mandatoryQ, " "));
|
|
|
914 |
params.put("fl", "*, [child parentFilter=id:catalog*]");
|
|
|
915 |
// params.put("sort", "create_s desc");
|
|
|
916 |
params.put("start", String.valueOf(0));
|
|
|
917 |
params.put("rows", String.valueOf(100));
|
|
|
918 |
params.put("wt", "json");
|
| 37144 |
amit |
919 |
JSONArray docs = partnerSolrClient.selectDocs(params, userInfo.getRetailerId());
|
| 32018 |
tejbeer |
920 |
List<FofoCatalogResponse> dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
|
|
|
921 |
return dealResponse;
|
|
|
922 |
}
|
| 26607 |
amit.gupta |
923 |
|
| 32018 |
tejbeer |
924 |
@RequestMapping(value = "/store/cart", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
925 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
|
|
926 |
@ApiOperation(value = "Get brand list and count for category")
|
|
|
927 |
public ResponseEntity<?> cart(HttpServletRequest request, @RequestBody AddCartRequest cartRequest) throws Exception {
|
|
|
928 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 34902 |
vikas |
929 |
logger.info("cartRequest: {}",cartRequest);
|
| 32018 |
tejbeer |
930 |
Integer storeId = userInfo.getRetailerId();
|
|
|
931 |
ValidateCartResponse vc = new ValidateCartResponse(this.validateCart(storeId, cartRequest.getCartItems()), "Success", "Items added to cart successfully");
|
|
|
932 |
return responseSender.ok(vc);
|
|
|
933 |
}
|
| 26607 |
amit.gupta |
934 |
|
| 32018 |
tejbeer |
935 |
// Validate Cart for B2C Customers
|
|
|
936 |
private CartResponse validateCart(int storeId, List<CartItem> cartItems) throws Exception {
|
| 33436 |
ranu |
937 |
|
| 33573 |
amit.gupta |
938 |
logger.info("cartItems {}", cartItems);
|
| 32018 |
tejbeer |
939 |
cartItems = cartItems.stream().filter(x -> x.getQuantity() > 0).collect(Collectors.toList());
|
|
|
940 |
List<Integer> itemIds = cartItems.stream().map(x -> x.getItemId()).collect(Collectors.toList());
|
|
|
941 |
Map<Integer, AvailabilityModel> inventoryItemAvailabilityMap = inventoryService.getStoreAndOurStock(storeId, itemIds);
|
|
|
942 |
CartResponse cartResponse = new CartResponse();
|
|
|
943 |
List<CartItemResponseModel> cartItemResponseModels = new ArrayList<>();
|
|
|
944 |
cartResponse.setCartItems(cartItemResponseModels);
|
|
|
945 |
Set<Integer> itemsIdsSet = new HashSet<>(itemIds);
|
|
|
946 |
logger.info("Store Id {}, Item Ids {}", storeId, itemsIdsSet);
|
| 26607 |
amit.gupta |
947 |
|
| 32018 |
tejbeer |
948 |
Map<Integer, Item> itemsMap = itemRepository.selectByIds(itemsIdsSet).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| 26652 |
amit.gupta |
949 |
|
| 32018 |
tejbeer |
950 |
Map<Integer, TagListing> tagListingMap = tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(itemIds), new HashSet<>(Arrays.asList(4))).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 26923 |
amit.gupta |
951 |
|
| 32018 |
tejbeer |
952 |
List<Integer> catalogIds = itemsMap.values().stream().map(x -> x.getCatalogItemId()).collect(Collectors.toList());
|
| 26607 |
amit.gupta |
953 |
|
| 32018 |
tejbeer |
954 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
| 27030 |
amit.gupta |
955 |
|
| 32018 |
tejbeer |
956 |
// cartResponse.getCartItems()
|
|
|
957 |
int cartMessageChanged = 0;
|
|
|
958 |
int cartMessageOOS = 0;
|
|
|
959 |
int totalAmount = 0;
|
|
|
960 |
int totalQty = 0;
|
| 34186 |
vikas.jang |
961 |
List<CartMessage> itemMessages = new ArrayList<>();
|
| 32018 |
tejbeer |
962 |
for (CartItem cartItem : cartItems) {
|
|
|
963 |
Item item = itemsMap.get(cartItem.getItemId());
|
| 34186 |
vikas.jang |
964 |
CartMessage itemMsg = new CartMessage();
|
| 32018 |
tejbeer |
965 |
TagListing tagListing = tagListingMap.get(cartItem.getItemId());
|
| 32977 |
amit.gupta |
966 |
int catalogId = itemsMap.get(cartItem.getItemId()).getCatalogItemId();
|
|
|
967 |
Float cashback = schemeService.getCatalogSchemeCashBack(storeId, Arrays.asList(catalogId))
|
|
|
968 |
.get(itemsMap.get(cartItem.getItemId()).getCatalogItemId());
|
| 32018 |
tejbeer |
969 |
cashback = cashback == null ? 0 : cashback;
|
|
|
970 |
float itemSellingPrice = tagListing.getMop() - cashback;
|
|
|
971 |
CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
|
|
|
972 |
cartItemResponseModel.setSellingPrice(cartItem.getSellingPrice());
|
| 33436 |
ranu |
973 |
cartItemResponseModel.setPendingOrderItemPolicyPlan(cartItem.getPendingOrderItemPolicyPlan());
|
| 34259 |
aman.kumar |
974 |
logger.info("itemSellingPrice: {}", itemSellingPrice);
|
|
|
975 |
logger.info("cartItem: {}", cartItem.getSellingPrice());
|
|
|
976 |
logger.info("cashback: {}", cashback);
|
| 32018 |
tejbeer |
977 |
if (itemSellingPrice != cartItem.getSellingPrice()) {
|
| 34186 |
vikas.jang |
978 |
itemMsg.setType("price");
|
| 34259 |
aman.kumar |
979 |
itemMsg.setMessageText("Price has changed to " + itemSellingPrice);
|
| 32018 |
tejbeer |
980 |
cartItemResponseModel.setSellingPrice(itemSellingPrice);
|
|
|
981 |
cartMessageChanged++;
|
|
|
982 |
}
|
|
|
983 |
int estimate = -2;
|
|
|
984 |
LocalDateTime promiseDeliveryTime = LocalDateTime.now();
|
|
|
985 |
int qtyRequired = (int) cartItem.getQuantity();
|
|
|
986 |
AvailabilityModel availabilityModel = inventoryItemAvailabilityMap.get(cartItem.getItemId());
|
|
|
987 |
cartItemResponseModel.setMaxQuantity(availabilityModel.getMaxAvailability());
|
|
|
988 |
if (availabilityModel.getStoreAvailability() >= qtyRequired) {
|
| 34239 |
vikas.jang |
989 |
itemMsg.setType("estimate0");
|
| 34259 |
aman.kumar |
990 |
itemMsg.setMessageText("Store availability is " + availabilityModel.getStoreAvailability());
|
| 32018 |
tejbeer |
991 |
estimate = 0;
|
|
|
992 |
} else if (availabilityModel.getWarehouseAvailability() >= qtyRequired) {
|
| 34239 |
vikas.jang |
993 |
itemMsg.setType("estimate2");
|
| 34259 |
aman.kumar |
994 |
itemMsg.setMessageText("Store availability is " + availabilityModel.getWarehouseAvailability());
|
| 32018 |
tejbeer |
995 |
estimate = 2;
|
|
|
996 |
} else if (availabilityModel.getStoreAvailability() > 0) {
|
|
|
997 |
estimate = 0;
|
|
|
998 |
qtyRequired = availabilityModel.getStoreAvailability();
|
|
|
999 |
cartMessageChanged++;
|
| 34186 |
vikas.jang |
1000 |
itemMsg.setType("quantity0");
|
| 34259 |
aman.kumar |
1001 |
itemMsg.setMessageText("quantity is updated " + qtyRequired);
|
| 32018 |
tejbeer |
1002 |
} else if (availabilityModel.getWarehouseAvailability() > 0) {
|
|
|
1003 |
qtyRequired = availabilityModel.getWarehouseAvailability();
|
|
|
1004 |
estimate = 2;
|
|
|
1005 |
cartMessageChanged++;
|
| 34186 |
vikas.jang |
1006 |
itemMsg.setType("quantity2");
|
| 34259 |
aman.kumar |
1007 |
itemMsg.setMessageText("quantity is updated " + qtyRequired);
|
| 32018 |
tejbeer |
1008 |
} else {
|
|
|
1009 |
qtyRequired = 0;
|
|
|
1010 |
cartMessageChanged++;
|
| 34186 |
vikas.jang |
1011 |
itemMsg.setType("item");
|
|
|
1012 |
itemMsg.setMessageText(item.getItemDescriptionNoColor() + " is out of stock");
|
| 32018 |
tejbeer |
1013 |
}
|
|
|
1014 |
cartItemResponseModel.setQuantity(qtyRequired);
|
|
|
1015 |
if (estimate >= 0 && LocalTime.now().isAfter(CUTOFF_TIME)) {
|
|
|
1016 |
estimate = estimate + 1;
|
|
|
1017 |
promiseDeliveryTime = promiseDeliveryTime.plusDays(3);
|
|
|
1018 |
}
|
|
|
1019 |
totalQty += qtyRequired;
|
| 33573 |
amit.gupta |
1020 |
if (cartItem.getPendingOrderItemPolicyPlan() != null) {
|
|
|
1021 |
totalAmount += qtyRequired * itemSellingPrice + qtyRequired * cartItem.getPendingOrderItemPolicyPlan().getPrice();
|
|
|
1022 |
} else {
|
| 33436 |
ranu |
1023 |
totalAmount += qtyRequired * itemSellingPrice;
|
|
|
1024 |
}
|
| 34902 |
vikas |
1025 |
AffiliateProduct product = affiliateLinkRepository.findByCode(cartItem.getSmartSellerId());
|
| 33436 |
ranu |
1026 |
|
| 34902 |
vikas |
1027 |
logger.info("product ===: {}", product);
|
|
|
1028 |
|
|
|
1029 |
if (product != null && !product.getExpiryDate().isBefore(LocalDateTime.now())) {
|
|
|
1030 |
cartItemResponseModel.setSmartSellerId(cartItem.getSmartSellerId());
|
|
|
1031 |
}
|
|
|
1032 |
|
| 32018 |
tejbeer |
1033 |
cartItemResponseModel.setEstimate(estimate);
|
|
|
1034 |
cartItemResponseModel.setTitle(item.getItemDescriptionNoColor());
|
|
|
1035 |
cartItemResponseModel.setItemId(cartItem.getItemId());
|
|
|
1036 |
cartItemResponseModel.setMinBuyQuantity(1);
|
|
|
1037 |
cartItemResponseModel.setQuantity(qtyRequired);
|
| 34884 |
vikas |
1038 |
cartItemResponseModel.setCategoryId(item.getCategoryId());
|
| 32018 |
tejbeer |
1039 |
cartItemResponseModel.setQuantityStep(1);
|
|
|
1040 |
cartItemResponseModel.setPromiseDelivery(promiseDeliveryTime);
|
|
|
1041 |
cartItemResponseModel.setMaxQuantity(availabilityModel.getMaxAvailability());
|
|
|
1042 |
cartItemResponseModel.setCatalogItemId(item.getCatalogItemId());
|
|
|
1043 |
cartItemResponseModel.setImageUrl(contentMap.get(item.getCatalogItemId()).getString("imageUrl_s"));
|
|
|
1044 |
cartItemResponseModel.setColor(item.getColor());
|
|
|
1045 |
cartItemResponseModels.add(cartItemResponseModel);
|
| 34186 |
vikas.jang |
1046 |
itemMessages.add(itemMsg);
|
| 32018 |
tejbeer |
1047 |
}
|
|
|
1048 |
cartResponse.setCartItems(cartItemResponseModels);
|
| 34186 |
vikas.jang |
1049 |
cartResponse.setCartMessages(itemMessages);
|
| 32018 |
tejbeer |
1050 |
cartResponse.setCartMessageChanged(cartMessageChanged);
|
|
|
1051 |
cartResponse.setCartMessageOOS(cartMessageOOS);
|
|
|
1052 |
int maxEstimate = cartItemResponseModels.stream().mapToInt(x -> x.getEstimate()).max().getAsInt();
|
|
|
1053 |
cartResponse.setMaxEstimate(maxEstimate);
|
|
|
1054 |
cartResponse.setTotalAmount(totalAmount);
|
|
|
1055 |
cartResponse.setTotalQty(totalQty);
|
| 26607 |
amit.gupta |
1056 |
|
| 32018 |
tejbeer |
1057 |
return cartResponse;
|
| 26923 |
amit.gupta |
1058 |
|
| 32018 |
tejbeer |
1059 |
}
|
| 27069 |
tejbeer |
1060 |
|
| 32018 |
tejbeer |
1061 |
@RequestMapping(value = "/store/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 33573 |
amit.gupta |
1062 |
public ResponseEntity<?> partnerStock(HttpServletRequest request, @RequestParam(required = false, defaultValue = "3") String categoryId, @RequestParam int offset,
|
| 34444 |
vikas.jang |
1063 |
@RequestParam int limit, @RequestParam(required = false) String sort, @RequestParam(required = false) String brand,
|
| 37298 |
amit |
1064 |
@RequestParam(value = "subCategoryId", required = false, defaultValue = "0") int subCategoryId, @RequestParam(required = false) String queryTerm,
|
| 34444 |
vikas.jang |
1065 |
@RequestParam(required = false) String listing, @RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly) throws Throwable {
|
| 32018 |
tejbeer |
1066 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 36428 |
aman |
1067 |
int dbCategoryId = mapFrontendCategoryToDb(categoryId);
|
|
|
1068 |
List<FofoCatalogResponse> dealResponse = getCatalogResponseFromDb(
|
| 36932 |
ranu |
1069 |
dbCategoryId, userInfo.getRetailerId(), offset, limit, brand, queryTerm, subCategoryId, partnerStockOnly);
|
| 32018 |
tejbeer |
1070 |
return responseSender.ok(dealResponse);
|
|
|
1071 |
}
|
| 26923 |
amit.gupta |
1072 |
|
| 36428 |
aman |
1073 |
private int mapFrontendCategoryToDb(String frontendCategoryId) {
|
|
|
1074 |
if ("3".equals(frontendCategoryId)) return 10006;
|
|
|
1075 |
try {
|
|
|
1076 |
return Integer.parseInt(frontendCategoryId);
|
|
|
1077 |
} catch (NumberFormatException e) {
|
|
|
1078 |
return 10006;
|
|
|
1079 |
}
|
|
|
1080 |
}
|
|
|
1081 |
|
|
|
1082 |
private List<FofoCatalogResponse> getCatalogResponseFromDb(int dbCategoryId, int fofoId, int offset, int limit,
|
| 36932 |
ranu |
1083 |
String brand, String queryTerm, int subCategoryId,
|
|
|
1084 |
boolean partnerStockOnly) throws ProfitMandiBusinessException {
|
| 36428 |
aman |
1085 |
List<status> statuses = Arrays.asList(status.ACTIVE, status.PAUSED_BY_RISK, status.PARTIALLY_ACTIVE);
|
|
|
1086 |
List<ItemTagModel> itemTagModels = tagListingRepository.getItemTagByCategoryAndStatus(dbCategoryId, statuses);
|
|
|
1087 |
|
|
|
1088 |
List<String> excludeBrands = Arrays.asList("Dummy", "FOC HANDSET", "FOC", "Live Demo");
|
|
|
1089 |
|
| 36932 |
ranu |
1090 |
// Sell-mode (partnerStockOnly): fetch partner stock first so we can prune
|
|
|
1091 |
// catalogs to in-stock items only before any other lookups. This cuts the
|
|
|
1092 |
// work for warehouse/cashback/image batches and skips empty catalogs entirely.
|
|
|
1093 |
Map<Integer, Integer> partnerStockMap = Collections.emptyMap();
|
|
|
1094 |
if (fofoId > 0) {
|
|
|
1095 |
partnerStockMap = currentInventorySnapshotRepository.selectItemsStock(fofoId).stream()
|
|
|
1096 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability(), (a, b) -> a));
|
|
|
1097 |
}
|
|
|
1098 |
final Map<Integer, Integer> psMap = partnerStockMap;
|
|
|
1099 |
|
| 36428 |
aman |
1100 |
Map<Integer, List<ItemTagModel>> catalogGrouped = itemTagModels.stream()
|
|
|
1101 |
.filter(itm -> !excludeBrands.contains(itm.getItem().getBrand()))
|
|
|
1102 |
.filter(itm -> brand == null || brand.isEmpty() || itm.getItem().getBrand().equalsIgnoreCase(brand))
|
|
|
1103 |
.filter(itm -> queryTerm == null || queryTerm.isEmpty() || queryTerm.equals("null")
|
|
|
1104 |
|| matchesSearchQuery(itm.getItem(), queryTerm))
|
|
|
1105 |
.filter(itm -> subCategoryId == 0 || itm.getItem().getCategoryId() == subCategoryId)
|
| 36932 |
ranu |
1106 |
// Drop items the partner has zero of when sell-mode demands in-stock only.
|
|
|
1107 |
.filter(itm -> !partnerStockOnly || psMap.getOrDefault(itm.getItem().getId(), 0) > 0)
|
| 36428 |
aman |
1108 |
.collect(Collectors.groupingBy(itm -> itm.getItem().getCatalogItemId()));
|
|
|
1109 |
|
|
|
1110 |
if (catalogGrouped.isEmpty()) {
|
|
|
1111 |
return new ArrayList<>();
|
|
|
1112 |
}
|
|
|
1113 |
|
|
|
1114 |
Set<Integer> allItemIds = catalogGrouped.values().stream()
|
|
|
1115 |
.flatMap(List::stream)
|
|
|
1116 |
.map(itm -> itm.getItem().getId())
|
|
|
1117 |
.collect(Collectors.toSet());
|
|
|
1118 |
|
|
|
1119 |
Map<Integer, Integer> warehouseStockMap = saholicInventoryService.getTotalAvailabilityByItemIds(new ArrayList<>(allItemIds));
|
|
|
1120 |
|
|
|
1121 |
Map<Integer, List<WebOffer>> webOfferMap = webOfferRepository.selectAllActiveOffers();
|
|
|
1122 |
|
|
|
1123 |
List<SuperCatalogModel> superCatalogModels = superCatalogMappingRepository.selectJoinedData();
|
|
|
1124 |
List<SuperCatalogMapping> superCatalogs = superCatalogMappingRepository.selectAll();
|
|
|
1125 |
|
|
|
1126 |
List<Integer> allCatalogIds = new ArrayList<>(catalogGrouped.keySet());
|
|
|
1127 |
|
|
|
1128 |
Map<Integer, Float> cashBackCache = fofoId > 0
|
|
|
1129 |
? schemeService.getCatalogSchemeCashBack(fofoId, allCatalogIds)
|
|
|
1130 |
: new HashMap<>();
|
|
|
1131 |
|
|
|
1132 |
Map<Long, ContentPojo> imageCache = mongoClient.getEntitiesByIds(
|
|
|
1133 |
allCatalogIds.stream().map(Integer::longValue).collect(Collectors.toList()));
|
|
|
1134 |
|
|
|
1135 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
|
|
1136 |
|
|
|
1137 |
for (Map.Entry<Integer, List<ItemTagModel>> entry : catalogGrouped.entrySet()) {
|
|
|
1138 |
int catalogId = entry.getKey();
|
|
|
1139 |
List<ItemTagModel> catalogItems = entry.getValue();
|
|
|
1140 |
Item firstItem = catalogItems.get(0).getItem();
|
|
|
1141 |
|
|
|
1142 |
FofoCatalogResponse ffdr = new FofoCatalogResponse();
|
|
|
1143 |
ffdr.setCatalogId(catalogId);
|
|
|
1144 |
|
|
|
1145 |
String title = Arrays.asList(firstItem.getBrand(), firstItem.getModelName(), firstItem.getModelNumber())
|
|
|
1146 |
.stream().filter(s -> s != null && !s.isEmpty()).collect(Collectors.joining(" "));
|
|
|
1147 |
ffdr.setTitle(title);
|
|
|
1148 |
ContentPojo cachedEntity = imageCache.get((long) catalogId);
|
|
|
1149 |
String imageUrl = cachedEntity != null ? cachedEntity.getDefaultImageUrl() : null;
|
|
|
1150 |
ffdr.setImageUrl(imageUrl != null ? imageUrl : "https://images.smartdukaan.com/uploads/campaigns/" + catalogId + ".jpg");
|
|
|
1151 |
ffdr.setBrand(firstItem.getBrand());
|
|
|
1152 |
ffdr.setIsSmartPhone(firstItem.isSmartPhone());
|
|
|
1153 |
ffdr.setFeature(null);
|
|
|
1154 |
|
|
|
1155 |
Optional<SuperCatalogModel> scMapping = superCatalogModels.stream()
|
|
|
1156 |
.filter(m -> m.getCatalogId() == catalogId).findFirst();
|
|
|
1157 |
if (scMapping.isPresent()) {
|
|
|
1158 |
ffdr.setSuperCatalogId(scMapping.get().getSuperCatalogId());
|
|
|
1159 |
ffdr.setSuperCatalogTitle(scMapping.get().getSuperCatalogName());
|
|
|
1160 |
ffdr.setSuperCatalogVariants(buildVariantsJson(superCatalogs, scMapping.get().getSuperCatalogId(), itemTagModels));
|
|
|
1161 |
} else {
|
|
|
1162 |
ffdr.setSuperCatalogId(0);
|
|
|
1163 |
ffdr.setSuperCatalogTitle(title);
|
|
|
1164 |
ffdr.setSuperCatalogVariants("[]");
|
|
|
1165 |
}
|
|
|
1166 |
|
|
|
1167 |
List<WebOffer> webOffers = webOfferMap.get(catalogId);
|
|
|
1168 |
if (webOffers != null && !webOffers.isEmpty()) {
|
|
|
1169 |
ffdr.setOffers(webOffers.stream().map(x -> x.getTitle()).collect(Collectors.toList()));
|
|
|
1170 |
}
|
|
|
1171 |
|
|
|
1172 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
|
|
1173 |
for (ItemTagModel itm : catalogItems) {
|
|
|
1174 |
Item item = itm.getItem();
|
|
|
1175 |
TagListing tl = itm.getTagListing();
|
|
|
1176 |
int itemId = item.getId();
|
|
|
1177 |
float sellingPrice = tl.getSellingPrice();
|
|
|
1178 |
|
|
|
1179 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
|
|
1180 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
|
|
1181 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
|
|
1182 |
fofoAvailabilityInfoMap.get(itemId).setMop(tl.getMop());
|
|
|
1183 |
}
|
|
|
1184 |
} else {
|
|
|
1185 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
|
|
1186 |
fdi.setSellingPrice(sellingPrice);
|
|
|
1187 |
fdi.setMrp(tl.getMrp());
|
|
|
1188 |
fdi.setMop(tl.getMop());
|
|
|
1189 |
fdi.setColor(item.getColor() != null ? item.getColor().replace("f_", "") : "");
|
|
|
1190 |
fdi.setTagId(tl.getTagId());
|
|
|
1191 |
fdi.setItem_id(itemId);
|
|
|
1192 |
fdi.setCatalog_id(catalogId);
|
|
|
1193 |
|
|
|
1194 |
Float cb = cashBackCache.get(catalogId);
|
|
|
1195 |
fdi.setCashback(cb != null ? cb : 0f);
|
|
|
1196 |
fdi.setMinBuyQuantity(1);
|
|
|
1197 |
|
|
|
1198 |
int partnerAvailability = partnerStockMap.getOrDefault(itemId, 0);
|
|
|
1199 |
int ourStockAvailability = Math.max(0, warehouseStockMap.getOrDefault(itemId, 0));
|
|
|
1200 |
fdi.setActive(partnerAvailability > 0);
|
|
|
1201 |
fdi.setPartnerAvailability(partnerAvailability);
|
|
|
1202 |
fdi.setAvailability(Math.min(5, ourStockAvailability + partnerAvailability));
|
|
|
1203 |
fdi.setQuantityStep(1);
|
|
|
1204 |
fdi.setMaxQuantity(fdi.getAvailability());
|
|
|
1205 |
|
|
|
1206 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
|
|
1207 |
}
|
|
|
1208 |
}
|
|
|
1209 |
|
|
|
1210 |
if (!fofoAvailabilityInfoMap.isEmpty()) {
|
|
|
1211 |
ffdr.setItems(fofoAvailabilityInfoMap.values().stream()
|
|
|
1212 |
.sorted(Comparator.comparing(FofoAvailabilityInfo::isActive, Comparator.reverseOrder())
|
|
|
1213 |
.thenComparingInt(y -> -y.getAvailability()))
|
|
|
1214 |
.collect(Collectors.toList()));
|
|
|
1215 |
dealResponse.add(ffdr);
|
|
|
1216 |
}
|
|
|
1217 |
}
|
|
|
1218 |
|
|
|
1219 |
dealResponse.sort(Comparator.comparing(FofoCatalogResponse::getItems,
|
|
|
1220 |
(s1, s2) -> (s2.get(0).isActive() ? 1 : 0) - (s1.get(0).isActive() ? 1 : 0))
|
|
|
1221 |
.thenComparing(FofoCatalogResponse::getItems,
|
|
|
1222 |
(x, y) -> y.get(0).getAvailability() - x.get(0).getAvailability()));
|
|
|
1223 |
|
|
|
1224 |
int start = Math.min(offset, dealResponse.size());
|
|
|
1225 |
int end = Math.min(offset + limit, dealResponse.size());
|
|
|
1226 |
return dealResponse.subList(start, end);
|
|
|
1227 |
}
|
|
|
1228 |
|
|
|
1229 |
private boolean matchesSearchQuery(Item item, String query) {
|
|
|
1230 |
String q = query.toLowerCase();
|
|
|
1231 |
String searchable = String.join(" ",
|
|
|
1232 |
item.getBrand() != null ? item.getBrand() : "",
|
|
|
1233 |
item.getModelName() != null ? item.getModelName() : "",
|
|
|
1234 |
item.getModelNumber() != null ? item.getModelNumber() : "",
|
|
|
1235 |
item.getColor() != null ? item.getColor() : "").toLowerCase();
|
|
|
1236 |
for (String term : q.split("\\s+")) {
|
|
|
1237 |
if (!searchable.contains(term)) return false;
|
|
|
1238 |
}
|
|
|
1239 |
return true;
|
|
|
1240 |
}
|
|
|
1241 |
|
|
|
1242 |
private String buildVariantsJson(List<SuperCatalogMapping> superCatalogs, int superCatalogId, List<ItemTagModel> itemTagModels) {
|
|
|
1243 |
List<Map<String, Object>> variantList = new ArrayList<>();
|
|
|
1244 |
List<SuperCatalogMapping> matchingVariants = superCatalogs.stream()
|
|
|
1245 |
.filter(m -> m.getSuperCatalogId() == superCatalogId)
|
|
|
1246 |
.collect(Collectors.toList());
|
|
|
1247 |
|
|
|
1248 |
for (SuperCatalogMapping variant : matchingVariants) {
|
|
|
1249 |
if (variant.getVariantName() == null) continue;
|
|
|
1250 |
boolean hasActiveTag = itemTagModels.stream()
|
|
|
1251 |
.anyMatch(tag -> tag.getItem().getCatalogItemId() == variant.getCatalogId() && tag.getTagListing().isActive());
|
|
|
1252 |
if (!hasActiveTag) continue;
|
|
|
1253 |
|
|
|
1254 |
ItemTagModel tagModel = itemTagModels.stream()
|
|
|
1255 |
.filter(tag -> tag.getItem().getCatalogItemId() == variant.getCatalogId())
|
|
|
1256 |
.findFirst().orElse(null);
|
|
|
1257 |
|
|
|
1258 |
Map<String, Object> variantObj = new HashMap<>();
|
|
|
1259 |
variantObj.put("catalogId", variant.getCatalogId());
|
|
|
1260 |
variantObj.put("variantName", variant.getVariantName());
|
|
|
1261 |
variantObj.put("mrp", tagModel != null ? tagModel.getTagListing().getMrp() : 0.0);
|
|
|
1262 |
variantObj.put("mop", tagModel != null ? tagModel.getTagListing().getMop() : 0.0);
|
|
|
1263 |
variantObj.put("sellingPrice", tagModel != null ? tagModel.getTagListing().getSellingPrice() : 0.0);
|
|
|
1264 |
variantList.add(variantObj);
|
|
|
1265 |
}
|
|
|
1266 |
|
|
|
1267 |
if (variantList.isEmpty()) return "[]";
|
|
|
1268 |
return new Gson().toJson(variantList);
|
|
|
1269 |
}
|
|
|
1270 |
|
| 32018 |
tejbeer |
1271 |
private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId) throws ProfitMandiBusinessException {
|
|
|
1272 |
Map<Integer, Integer> ourItemAvailabilityMap = null;
|
|
|
1273 |
Map<Integer, Integer> partnerStockAvailabilityMap = null;
|
|
|
1274 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
|
|
1275 |
List<Integer> tagIds = Arrays.asList(4);
|
|
|
1276 |
if (docs.length() > 0) {
|
|
|
1277 |
HashSet<Integer> itemsSet = new HashSet<>();
|
|
|
1278 |
for (int i = 0; i < docs.length(); i++) {
|
|
|
1279 |
JSONObject doc = docs.getJSONObject(i);
|
|
|
1280 |
if (doc.has("_childDocuments_")) {
|
|
|
1281 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
|
|
1282 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
|
|
1283 |
int itemId = childItem.getInt("itemId_i");
|
|
|
1284 |
itemsSet.add(itemId);
|
|
|
1285 |
}
|
|
|
1286 |
}
|
|
|
1287 |
}
|
|
|
1288 |
if (itemsSet.size() == 0) {
|
|
|
1289 |
return dealResponse;
|
|
|
1290 |
}
|
|
|
1291 |
if (fofoId > 0) {
|
|
|
1292 |
partnerStockAvailabilityMap = currentInventorySnapshotRepository.selectItemsStock(fofoId).stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getAvailability()));
|
|
|
1293 |
}
|
|
|
1294 |
ourItemAvailabilityMap = saholicInventoryService.getTotalAvailabilityByItemIds(new ArrayList<>(itemsSet));
|
|
|
1295 |
}
|
| 26833 |
amit.gupta |
1296 |
|
| 32018 |
tejbeer |
1297 |
for (int i = 0; i < docs.length(); i++) {
|
|
|
1298 |
Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
|
|
|
1299 |
JSONObject doc = docs.getJSONObject(i);
|
|
|
1300 |
FofoCatalogResponse ffdr = new FofoCatalogResponse();
|
|
|
1301 |
ffdr.setCatalogId(doc.getInt("catalogId_i"));
|
|
|
1302 |
ffdr.setImageUrl(doc.getString("imageUrl_s"));
|
|
|
1303 |
ffdr.setTitle(doc.getString("title_s"));
|
| 34239 |
vikas.jang |
1304 |
ffdr.setSuperCatalogTitle(doc.getString("superCatalog_s"));
|
|
|
1305 |
ffdr.setSuperCatalogId(doc.getInt("superCatalog_i"));
|
|
|
1306 |
ffdr.setSuperCatalogVariants(doc.getString("superCatalogVariants_s"));
|
| 32018 |
tejbeer |
1307 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(ffdr.getCatalogId());
|
|
|
1308 |
if (webOffers != null && webOffers.size() > 0) {
|
|
|
1309 |
ffdr.setOffers(webOffers.stream().map(x -> x.getTitle()).collect(Collectors.toList()));
|
|
|
1310 |
}
|
|
|
1311 |
try {
|
|
|
1312 |
ffdr.setFeature(doc.getString("feature_s"));
|
|
|
1313 |
} catch (Exception e) {
|
|
|
1314 |
ffdr.setFeature(null);
|
|
|
1315 |
}
|
|
|
1316 |
ffdr.setBrand(doc.getJSONArray("brand_ss").getString(0));
|
| 33314 |
ranu |
1317 |
|
| 32018 |
tejbeer |
1318 |
if (doc.has("_childDocuments_")) {
|
|
|
1319 |
for (int j = 0; j < doc.getJSONArray("_childDocuments_").length(); j++) {
|
|
|
1320 |
JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
|
|
|
1321 |
int itemId = childItem.getInt("itemId_i");
|
| 36376 |
aman |
1322 |
// Solr sometimes outlives the DB row (stale index, soft-deleted Item,
|
|
|
1323 |
// cache lag). One bad row shouldn't 400 the whole catalogue — treat
|
|
|
1324 |
// a missing row as "not a smartphone" and keep going.
|
|
|
1325 |
try {
|
|
|
1326 |
ffdr.setIsSmartPhone(itemRepository.selectById(itemId).isSmartPhone());
|
|
|
1327 |
} catch (ProfitMandiBusinessException e) {
|
|
|
1328 |
logger.warn("partnerStock: itemId {} present in Solr but missing from DB — skipping isSmartPhone", itemId);
|
|
|
1329 |
ffdr.setIsSmartPhone(false);
|
|
|
1330 |
}
|
| 32018 |
tejbeer |
1331 |
float sellingPrice = (float) childItem.getDouble("sellingPrice_f");
|
|
|
1332 |
if (fofoAvailabilityInfoMap.containsKey(itemId)) {
|
|
|
1333 |
if (fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
|
|
|
1334 |
fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
|
|
|
1335 |
fofoAvailabilityInfoMap.get(itemId).setMop((float) childItem.getDouble("mop_f"));
|
|
|
1336 |
}
|
|
|
1337 |
} else {
|
|
|
1338 |
FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
|
|
|
1339 |
fdi.setSellingPrice(sellingPrice);
|
|
|
1340 |
fdi.setMrp(childItem.getDouble("mrp_f"));
|
|
|
1341 |
fdi.setMop((float) childItem.getDouble("mop_f"));
|
|
|
1342 |
fdi.setColor(childItem.has("color_s") ? childItem.getString("color_s") : "");
|
|
|
1343 |
fdi.setTagId(childItem.getInt("tagId_i"));
|
|
|
1344 |
fdi.setItem_id(itemId);
|
| 34196 |
ranu |
1345 |
fdi.setCatalog_id(doc.getInt("catalogId_i"));
|
| 32977 |
amit.gupta |
1346 |
Float cashBack = schemeService.getCatalogSchemeCashBack(fofoId, Arrays.asList(ffdr.getCatalogId())).get(ffdr.getCatalogId());
|
| 32018 |
tejbeer |
1347 |
cashBack = cashBack == null ? 0 : cashBack;
|
|
|
1348 |
// TODO:Dont commit
|
|
|
1349 |
// fdi.setCashback(Math.min(100, fdi.getMop()));
|
|
|
1350 |
fdi.setCashback(cashBack);
|
|
|
1351 |
fdi.setMinBuyQuantity(1);
|
|
|
1352 |
int partnerAvailability = partnerStockAvailabilityMap.get(itemId) == null ? 0 : partnerStockAvailabilityMap.get(itemId);
|
|
|
1353 |
int ourStockAvailability = ourItemAvailabilityMap.get(itemId) == null ? 0 : Math.max(0, ourItemAvailabilityMap.get(itemId));
|
|
|
1354 |
fdi.setActive(partnerAvailability > 0);
|
|
|
1355 |
// fdi.setActive(true);
|
| 34239 |
vikas.jang |
1356 |
fdi.setPartnerAvailability(partnerAvailability);
|
| 32018 |
tejbeer |
1357 |
fdi.setAvailability(Math.min(5, ourStockAvailability + partnerAvailability));
|
|
|
1358 |
fdi.setQuantityStep(1);
|
|
|
1359 |
fdi.setMaxQuantity(fdi.getAvailability());
|
|
|
1360 |
fofoAvailabilityInfoMap.put(itemId, fdi);
|
|
|
1361 |
}
|
|
|
1362 |
}
|
|
|
1363 |
}
|
|
|
1364 |
if (fofoAvailabilityInfoMap.values().size() > 0) {
|
|
|
1365 |
ffdr.setItems(fofoAvailabilityInfoMap.values().stream().sorted(Comparator.comparing(FofoAvailabilityInfo::isActive, Comparator.reverseOrder()).thenComparingInt(y -> -y.getAvailability())).collect(Collectors.toList()));
|
|
|
1366 |
dealResponse.add(ffdr);
|
|
|
1367 |
}
|
|
|
1368 |
}
|
|
|
1369 |
return dealResponse.stream().sorted(Comparator.comparing(FofoCatalogResponse::getItems, (s1, s2) -> (s2.get(0).isActive() ? 1 : 0) - (s1.get(0).isActive() ? 1 : 0)).thenComparing(FofoCatalogResponse::getItems, (x, y) -> y.get(0).getAvailability() - x.get(0).getAvailability())).collect(Collectors.toList());
|
|
|
1370 |
}
|
| 26857 |
amit.gupta |
1371 |
|
| 32018 |
tejbeer |
1372 |
@GetMapping(value = "store/order-status/{pendingOrderId}")
|
|
|
1373 |
public ResponseEntity<?> orderStatus(HttpServletRequest request, @PathVariable int pendingOrderId) throws Exception {
|
|
|
1374 |
PendingOrder pendingOrder = pendingOrderRepository.selectById(pendingOrderId);
|
|
|
1375 |
List<PendingOrderItem> pendingOrderItems = pendingOrderItemRepository.selectByOrderId(pendingOrder.getId());
|
|
|
1376 |
List<Integer> catalogIds = new ArrayList<>();
|
|
|
1377 |
for (PendingOrderItem pendingOrderItem : pendingOrderItems) {
|
| 34477 |
aman.kumar |
1378 |
//TODO : Amit feedback use poItemId instead of poId change Param name
|
|
|
1379 |
// when list is supposed then use method names as selectAllBy instead selectBy of
|
|
|
1380 |
//check for unique constraint
|
|
|
1381 |
List<PendingOrderPlan> policyPlans = pendingOrderPlanRepository.selectByPoId(pendingOrderItem.getId());
|
|
|
1382 |
pendingOrderItem.setPendingOrderItemPolicyPlan(policyPlans);
|
| 32018 |
tejbeer |
1383 |
Item item = itemRepository.selectById(pendingOrderItem.getItemId());
|
|
|
1384 |
pendingOrderItem.setItemName(item.getItemDescription());
|
| 34186 |
vikas.jang |
1385 |
pendingOrderItem.setCatalogId(item.getCatalogItemId());
|
| 32018 |
tejbeer |
1386 |
catalogIds.add(item.getCatalogItemId());
|
|
|
1387 |
}
|
|
|
1388 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
|
|
1389 |
for (PendingOrderItem pendingOrderItem : pendingOrderItems) {
|
|
|
1390 |
Item item = itemRepository.selectById(pendingOrderItem.getItemId());
|
|
|
1391 |
JSONObject jsonObj = contentMap.get(item.getCatalogItemId());
|
|
|
1392 |
pendingOrderItem.setImgUrl(jsonObj.getString("imageUrl_s"));
|
|
|
1393 |
}
|
|
|
1394 |
pendingOrder.setPendingOrderItems(pendingOrderItems);
|
| 27045 |
tejbeer |
1395 |
|
| 32018 |
tejbeer |
1396 |
return responseSender.ok(pendingOrder);
|
|
|
1397 |
}
|
| 28345 |
tejbeer |
1398 |
|
| 32018 |
tejbeer |
1399 |
@RequestMapping(value = "/store/addresses/{customerId}", method = RequestMethod.GET)
|
|
|
1400 |
public ResponseEntity<?> getAll(HttpServletRequest request, @PathVariable int customerId) throws Throwable {
|
|
|
1401 |
return responseSender.ok(customerAddressRepository.selectByActiveCustomerId(customerId));
|
|
|
1402 |
}
|
| 26861 |
tejbeer |
1403 |
|
| 32018 |
tejbeer |
1404 |
@RequestMapping(value = "/store/address", method = RequestMethod.POST)
|
|
|
1405 |
public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestBody CustomerAddress customerAddress) throws Throwable {
|
| 34259 |
aman.kumar |
1406 |
List<CustomerAddress> customerAddresses = customerAddressRepository.selectByActiveCustomerId(customerAddress.getCustomerId());
|
|
|
1407 |
if (customerAddresses.isEmpty()) {
|
|
|
1408 |
customerAddress.setDefault(true);
|
|
|
1409 |
} else {
|
|
|
1410 |
customerAddress.setDefault(false);
|
|
|
1411 |
}
|
| 32018 |
tejbeer |
1412 |
customerAddressRepository.persist(customerAddress);
|
|
|
1413 |
return responseSender.ok(customerAddress);
|
|
|
1414 |
}
|
| 27045 |
tejbeer |
1415 |
|
| 32018 |
tejbeer |
1416 |
@RequestMapping(value = "/store/deactivateCustomerAddress", method = RequestMethod.POST)
|
|
|
1417 |
public ResponseEntity<?> deactivateAddresss(HttpServletRequest request, @RequestParam int id) throws Throwable {
|
|
|
1418 |
CustomerAddress cust = customerAddressRepository.selectById(id);
|
| 34259 |
aman.kumar |
1419 |
List<CustomerAddress> customerAddresses = customerAddressRepository.selectByCustomerId(cust.getCustomerId());
|
| 32018 |
tejbeer |
1420 |
cust.setActive(false);
|
| 34259 |
aman.kumar |
1421 |
if(cust.getDefault()){
|
|
|
1422 |
List<CustomerAddress> activeAddresses = customerAddresses.stream()
|
|
|
1423 |
.filter(a -> a.getActive() && a.getId() != id)
|
|
|
1424 |
.sorted(Comparator.comparing(CustomerAddress::getUpdateTimestamp).reversed())
|
|
|
1425 |
.collect(Collectors.toList());
|
|
|
1426 |
|
|
|
1427 |
if (!activeAddresses.isEmpty()) {
|
|
|
1428 |
CustomerAddress newDefault = activeAddresses.get(0);
|
|
|
1429 |
newDefault.setDefault(true);
|
|
|
1430 |
}
|
|
|
1431 |
}
|
| 32018 |
tejbeer |
1432 |
return responseSender.ok(cust);
|
|
|
1433 |
}
|
| 27048 |
tejbeer |
1434 |
|
| 32018 |
tejbeer |
1435 |
@RequestMapping(value = "/store/updateCustomer", method = RequestMethod.POST)
|
|
|
1436 |
public ResponseEntity<?> updateCustomerProfile(HttpServletRequest request, @RequestBody Customer customer) throws Throwable {
|
|
|
1437 |
Customer cust = customerRepository.selectById(customer.getId());
|
|
|
1438 |
cust.setGender(customer.getGender());
|
|
|
1439 |
cust.setProfileImageId(customer.getProfileImageId());
|
| 34186 |
vikas.jang |
1440 |
cust.setEmailId(customer.getEmailId());
|
| 32018 |
tejbeer |
1441 |
cust.setDob(customer.getDob());
|
|
|
1442 |
return responseSender.ok(cust);
|
|
|
1443 |
}
|
| 27048 |
tejbeer |
1444 |
|
| 32018 |
tejbeer |
1445 |
@RequestMapping(value = "/stores/{state}/{city}/{storeCode}", method = RequestMethod.GET)
|
|
|
1446 |
public void getStoreIndex(HttpServletResponse response, HttpServletRequest request, @PathVariable String state, @PathVariable String city, @PathVariable String storeCode) throws Throwable {
|
|
|
1447 |
logger.info("Store code {}", storeCode);
|
|
|
1448 |
Map<String, Integer> map = retailerService.getStoreCodeRetailerMap();
|
|
|
1449 |
logger.info("retailer id {}", map.get(storeCode));
|
|
|
1450 |
String retailerName = retailerService.getAllFofoRetailers().get(map.get(storeCode)).getBusinessName();
|
|
|
1451 |
String html = partnerIndexService.getPartnerIndexHtml();
|
|
|
1452 |
logger.info("html {}", html);
|
|
|
1453 |
html = html.replace("Buy Mobiles and Accessories at exciting prices - SmartDukaan", String.format("%s is now ONLINE. Buy Mobiles, Accessories & more | SmartDukaan", retailerName));
|
|
|
1454 |
response.getWriter().write(html);
|
|
|
1455 |
}
|
| 27048 |
tejbeer |
1456 |
|
| 32018 |
tejbeer |
1457 |
@RequestMapping(value = "/cancelPendingOrderItem", method = RequestMethod.POST)
|
| 34186 |
vikas.jang |
1458 |
public ResponseEntity<?> cancelPendingOrderItem(HttpServletRequest request, @RequestParam int id, @RequestParam String statusDescription, @RequestParam String reason) throws Exception {
|
| 28339 |
tejbeer |
1459 |
|
| 32018 |
tejbeer |
1460 |
PendingOrderItem pendingOrderItem = pendingOrderItemRepository.selectById(id);
|
|
|
1461 |
PendingOrder pendingOrder = pendingOrderRepository.selectById(pendingOrderItem.getOrderId());
|
|
|
1462 |
Customer customer = customerRepository.selectById(pendingOrder.getCustomerId());
|
|
|
1463 |
if (pendingOrderItem.getBilledTimestamp() == null) {
|
|
|
1464 |
pendingOrderItem.setStatus(OrderStatus.CANCELLED);
|
|
|
1465 |
pendingOrderItem.setRemark(reason);
|
|
|
1466 |
pendingOrderItem.setStatusDescription("cancel by self");
|
|
|
1467 |
pendingOrderItem.setCancelledTimestamp(LocalDateTime.now());
|
|
|
1468 |
List<OrderStatus> status = pendingOrderItemRepository.selectByOrderId(pendingOrderItem.getOrderId()).stream().map(x -> x.getStatus()).collect(Collectors.toList());
|
| 28339 |
tejbeer |
1469 |
|
| 32018 |
tejbeer |
1470 |
if (!status.contains(OrderStatus.PENDING) && !status.contains(OrderStatus.PROCESSING) && !status.contains(OrderStatus.BILLED) && !status.contains(OrderStatus.UNSETTLED) && !status.contains(OrderStatus.CLAIMED)) {
|
|
|
1471 |
pendingOrder.setStatus(OrderStatus.CLOSED);
|
|
|
1472 |
}
|
| 28339 |
tejbeer |
1473 |
|
| 32018 |
tejbeer |
1474 |
pendingOrderItemRepository.persist(pendingOrderItem);
|
|
|
1475 |
String itemDescription = itemRepository.selectById(pendingOrderItem.getItemId()).getItemDescription();
|
|
|
1476 |
otpProcessor.sendSms(OtpProcessor.SELF_CANCELLED_TEMPLATE_ID, String.format(OtpProcessor.SELF_CANCELLED_TEMPLATE, pendingOrder.getId(), StringUtils.abbreviate(itemDescription, 30), FormattingUtils.format(pendingOrderItem.getCancelledTimestamp())), customer.getMobileNumber());
|
| 28339 |
tejbeer |
1477 |
|
| 32018 |
tejbeer |
1478 |
List<Integer> catalogIds = new ArrayList<>();
|
| 28339 |
tejbeer |
1479 |
|
| 32018 |
tejbeer |
1480 |
Item item = itemRepository.selectById(pendingOrderItem.getItemId());
|
|
|
1481 |
pendingOrderItem.setItemName(item.getItemDescription());
|
|
|
1482 |
catalogIds.add(item.getCatalogItemId());
|
| 28339 |
tejbeer |
1483 |
|
| 32018 |
tejbeer |
1484 |
Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
|
|
1485 |
JSONObject jsonObj = contentMap.get(item.getCatalogItemId());
|
|
|
1486 |
pendingOrderItem.setImgUrl(jsonObj.getString("imageUrl_s"));
|
|
|
1487 |
pendingOrder.setPendingOrderItems(Arrays.asList(pendingOrderItem));
|
|
|
1488 |
CustomerAddress customerAddress = customerAddressRepository.selectById(pendingOrder.getCustomerAddressId());
|
| 28355 |
tejbeer |
1489 |
|
| 32018 |
tejbeer |
1490 |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy h:mm a");
|
| 28339 |
tejbeer |
1491 |
|
| 32018 |
tejbeer |
1492 |
Map<String, Object> emailModel = new HashMap<>();
|
|
|
1493 |
emailModel.put("customer", customerAddress);
|
|
|
1494 |
emailModel.put("pendingOrder", pendingOrder);
|
|
|
1495 |
emailModel.put("date", dateTimeFormatter);
|
| 27048 |
tejbeer |
1496 |
|
| 32018 |
tejbeer |
1497 |
String[] customerEmail = null;
|
|
|
1498 |
if (customer.getEmailId() != null) {
|
|
|
1499 |
customerEmail = new String[]{customer.getEmailId()};
|
| 27048 |
tejbeer |
1500 |
|
| 34186 |
vikas.jang |
1501 |
List<String> bccTo = Arrays.asList("vikas.jangra@smartdukaan.com");
|
| 29515 |
tejbeer |
1502 |
|
| 32018 |
tejbeer |
1503 |
emailService.sendMailWithAttachments("Order Cancellation", "order-cancellation.vm", emailModel, customerEmail, null, bccTo.toArray(new String[0]));
|
| 29515 |
tejbeer |
1504 |
|
| 32018 |
tejbeer |
1505 |
}
|
|
|
1506 |
}
|
| 29515 |
tejbeer |
1507 |
|
| 32018 |
tejbeer |
1508 |
return responseSender.ok(true);
|
| 29515 |
tejbeer |
1509 |
|
| 32018 |
tejbeer |
1510 |
}
|
| 31444 |
tejbeer |
1511 |
|
| 32018 |
tejbeer |
1512 |
@RequestMapping(value = "/store/checkEligibilityStoreOffers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
1513 |
public ResponseEntity<?> checkEligibilityStoreOffers(HttpServletRequest request, @RequestParam(value = "id") int id) throws Exception {
|
| 29515 |
tejbeer |
1514 |
|
| 32018 |
tejbeer |
1515 |
boolean eligibility = false;
|
| 29515 |
tejbeer |
1516 |
|
| 34186 |
vikas.jang |
1517 |
List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(id, ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
|
| 29515 |
tejbeer |
1518 |
|
| 32018 |
tejbeer |
1519 |
if (!scratchOffers.isEmpty()) {
|
|
|
1520 |
eligibility = true;
|
| 31457 |
tejbeer |
1521 |
|
| 32018 |
tejbeer |
1522 |
}
|
|
|
1523 |
return responseSender.ok(eligibility);
|
|
|
1524 |
}
|
| 29515 |
tejbeer |
1525 |
|
| 32018 |
tejbeer |
1526 |
@RequestMapping(value = "/store/ScratchOffers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
1527 |
public ResponseEntity<?> scratchOffers(HttpServletRequest request, @RequestParam(value = "id") int id) throws Exception {
|
| 29515 |
tejbeer |
1528 |
|
| 34186 |
vikas.jang |
1529 |
List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(id, ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
|
| 29515 |
tejbeer |
1530 |
|
| 32218 |
tejbeer |
1531 |
logger.info("scratchOffers {}", scratchOffers);
|
| 32018 |
tejbeer |
1532 |
// List<ScratchOffer> scratchOffers =
|
|
|
1533 |
// scratchOfferRepository.selectBycCustomerId(id);
|
|
|
1534 |
for (ScratchOffer so : scratchOffers) {
|
|
|
1535 |
if (LocalDateTime.now().isAfter(so.getUnlockedAt())) {
|
|
|
1536 |
so.setUnlocked(true);
|
|
|
1537 |
} else {
|
|
|
1538 |
so.setUnlocked(false);
|
|
|
1539 |
}
|
| 34371 |
ranu |
1540 |
LocalDateTime expiredTimestamp = ProfitMandiConstants.SCRATCH_OFFER_END_DATE.plusDays(0).atTime(LocalTime.MAX);
|
| 32671 |
ranu |
1541 |
so.setExpiredTimestamp(expiredTimestamp);
|
| 33573 |
amit.gupta |
1542 |
if (LocalDateTime.now().isAfter(expiredTimestamp)) {
|
| 32671 |
ranu |
1543 |
so.setExpired(true);
|
|
|
1544 |
}
|
| 32018 |
tejbeer |
1545 |
}
|
| 29515 |
tejbeer |
1546 |
|
| 32018 |
tejbeer |
1547 |
return responseSender.ok(scratchOffers);
|
|
|
1548 |
}
|
|
|
1549 |
|
|
|
1550 |
@RequestMapping(value = "/store/ScratchedOffer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
1551 |
public ResponseEntity<?> scratchedOffer(HttpServletRequest request, @RequestParam(value = "id") int id) throws Exception {
|
|
|
1552 |
|
|
|
1553 |
ScratchOffer scratchOffer = scratchOfferRepository.selectById(id);
|
|
|
1554 |
scratchOffer.setScratched(true);
|
|
|
1555 |
scratchOffer.setScracthedAt(LocalDateTime.now());
|
|
|
1556 |
|
|
|
1557 |
return responseSender.ok(true);
|
|
|
1558 |
}
|
|
|
1559 |
|
| 34242 |
tejus.loha |
1560 |
@RequestMapping(value = "/store/navbar", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
1561 |
public ResponseEntity<?> navBars() throws Exception {
|
|
|
1562 |
List<NavBar> navBars = navBarRepository.selectAllActive();
|
|
|
1563 |
return responseSender.ok(navBars);
|
|
|
1564 |
}
|
|
|
1565 |
|
| 35243 |
aman |
1566 |
|
|
|
1567 |
@RequestMapping(value = "/getMonthSale", method = RequestMethod.GET)
|
|
|
1568 |
public ResponseEntity<?> getMonthsale(HttpServletRequest request) throws Exception {
|
|
|
1569 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
|
|
1570 |
int fofoId = userInfo.getRetailerId();
|
|
|
1571 |
logger.info("getting the user resonse {} ",userInfo);
|
|
|
1572 |
Map<String, MonthSaleModel> monthSaleMap = new HashMap<>();
|
|
|
1573 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
|
|
1574 |
int dayOfMonth = curDate.getDayOfMonth();
|
|
|
1575 |
YearMonth yearMonth = YearMonth.now();
|
| 35309 |
aman |
1576 |
for (int i = 0; i <= 6; i++) {
|
| 35243 |
aman |
1577 |
LocalDateTime startOfMonth = curDate.withDayOfMonth(1).minusMonths(i);
|
|
|
1578 |
int lengthOfMonth = YearMonth.from(startOfMonth).lengthOfMonth();
|
|
|
1579 |
logger.info("Start of previous Month {}, start of next month Month {}", startOfMonth, startOfMonth.plusMonths(1));
|
|
|
1580 |
double monthSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusMonths(1), fofoId, false).get(fofoId);
|
|
|
1581 |
double mtdSales = fofoOrderItemRepository.selectSumMopGroupByRetailer(startOfMonth, startOfMonth.plusDays(Math.min(dayOfMonth, lengthOfMonth)), fofoId, false).get(fofoId);
|
|
|
1582 |
|
|
|
1583 |
MonthSaleModel ms = new MonthSaleModel();
|
|
|
1584 |
ms.setMtdSales(fofoUser.format((long) mtdSales));
|
|
|
1585 |
ms.setMonthlySales(fofoUser.format(((long) monthSales)));
|
|
|
1586 |
ms.setMonth(startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
|
|
|
1587 |
monthSaleMap.put(String.valueOf(i), ms);
|
|
|
1588 |
}
|
|
|
1589 |
logger.info("getting the month sale map {}",monthSaleMap);
|
|
|
1590 |
return responseSender.ok(monthSaleMap);
|
|
|
1591 |
}
|
|
|
1592 |
@RequestMapping(value = "/getBrandwisePartnerSale", method = RequestMethod.GET)
|
|
|
1593 |
@ResponseBody
|
|
|
1594 |
public ResponseEntity<?> getBrandwisePartnerSale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, Model model) throws Exception {
|
|
|
1595 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
|
|
1596 |
int fofoId = userInfo.getRetailerId();
|
|
|
1597 |
List<BrandWisePartnerSaleModel> brandWisePartnerSaleModels = fofoStoreRepository.selectBrandWiseMonthlyPartnerSale(Collections.singletonList(fofoId), month);
|
|
|
1598 |
List<Map<String, Object>> response = new ArrayList<>();
|
|
|
1599 |
for (BrandWisePartnerSaleModel m : brandWisePartnerSaleModels) {
|
|
|
1600 |
Map<String, Object> row = new HashMap<>();
|
|
|
1601 |
row.put("brand", m.getBrand());
|
|
|
1602 |
row.put("lms", fofoUser.format(m.getLms()));
|
|
|
1603 |
row.put("lmsQty", m.getLmsQty());
|
|
|
1604 |
row.put("mtd", fofoUser.format(m.getMtd()));
|
|
|
1605 |
row.put("mtdQty", m.getMtdQty());
|
|
|
1606 |
row.put("lmtd", fofoUser.format(m.getLmtd()));
|
|
|
1607 |
row.put("lmtdQty", m.getLmtdQty());
|
|
|
1608 |
row.put("amtd", fofoUser.format(m.getAmtd()));
|
|
|
1609 |
response.add(row);
|
|
|
1610 |
}
|
|
|
1611 |
logger.info("brandItemWisePartnerSaleModels {}", response);
|
|
|
1612 |
return responseSender.ok(response);
|
|
|
1613 |
}
|
|
|
1614 |
@RequestMapping(value = "/getBrandItemwisePartnerSale", method = RequestMethod.GET)
|
|
|
1615 |
@ResponseBody
|
|
|
1616 |
public ResponseEntity<?> getBrandItemwisePartnerSale(HttpServletRequest request, @RequestParam(name = "month", required = true, defaultValue = "0") int month, @RequestParam(name = "brand") String brand) throws Exception {
|
|
|
1617 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
|
|
1618 |
int fofoId = userInfo.getRetailerId();
|
|
|
1619 |
List<BrandItemWisePartnerSaleModel> brandItemWisePartnerSaleModels = fofoStoreRepository.selectPartnerBrandItemMonthlySale(Collections.singletonList(fofoId), month, brand);
|
|
|
1620 |
logger.info("getting brandwise item sale {}",brandItemWisePartnerSaleModels);
|
|
|
1621 |
return responseSender.ok(brandItemWisePartnerSaleModels);
|
|
|
1622 |
}
|
|
|
1623 |
|
|
|
1624 |
|
| 34444 |
vikas.jang |
1625 |
@RequestMapping(value = "/store/clearance", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
1626 |
public ResponseEntity<?> getLiquidations() throws Exception {
|
|
|
1627 |
List<Integer> catalogIds = new ArrayList<>();
|
|
|
1628 |
Map<Integer, JSONObject> contentMap = null;
|
| 34545 |
vikas.jang |
1629 |
List<Liquidation> liquidations = liquidationRepository.selectAllByStatus(ProfitMandiConstants.LIQUIDATION_ENUM.PUBLISHED);
|
| 34242 |
tejus.loha |
1630 |
|
| 34444 |
vikas.jang |
1631 |
if (!liquidations.isEmpty()) {
|
|
|
1632 |
for (Liquidation liquidation : liquidations) catalogIds.add(liquidation.getCatalogId());
|
|
|
1633 |
contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
|
|
|
1634 |
}
|
|
|
1635 |
|
|
|
1636 |
List<LiquidationDetail> resultList = new ArrayList<>();
|
|
|
1637 |
|
|
|
1638 |
if (contentMap != null) {
|
|
|
1639 |
for (Liquidation liquidation : liquidations) {
|
|
|
1640 |
List<Bid> bidList = bidRepository.selectBidByLiquidationId(liquidation.getId());
|
|
|
1641 |
LiquidationDetail liquidationDetail = new LiquidationDetail();
|
|
|
1642 |
if(contentMap.containsKey(liquidation.getCatalogId())) {
|
|
|
1643 |
JSONObject jsonObj = contentMap.get(liquidation.getCatalogId());
|
|
|
1644 |
liquidationDetail.setLiquidationId(liquidation.getId());
|
|
|
1645 |
liquidationDetail.setImageURL(jsonObj.getString("imageUrl_s"));
|
|
|
1646 |
liquidationDetail.setItemName(jsonObj.getString("title_s"));
|
|
|
1647 |
liquidationDetail.setBrand(jsonObj.getString("title_s"));
|
|
|
1648 |
liquidationDetail.setCatalogId(jsonObj.getInt("catalogId_i"));
|
|
|
1649 |
liquidationDetail.setMrp(jsonObj.getFloat("mop_f"));
|
|
|
1650 |
liquidationDetail.setMop(jsonObj.getFloat("mop_f"));
|
|
|
1651 |
liquidationDetail.setDp(jsonObj.getFloat("dp_f"));
|
|
|
1652 |
liquidationDetail.setSuperCatalogs(jsonObj.getString("superCatalogVariants_s"));
|
|
|
1653 |
liquidationDetail.setStartDate(liquidation.getStartDate());
|
|
|
1654 |
liquidationDetail.setEndDate(liquidation.getEndDate());
|
|
|
1655 |
liquidationDetail.setSellingPrice(liquidation.getPrice());
|
|
|
1656 |
liquidationDetail.setAvailableQuantity(liquidation.getQuantity());
|
| 34494 |
vikas.jang |
1657 |
liquidationDetail.setIncrementStep(liquidation.getIncrementStep());
|
| 34444 |
vikas.jang |
1658 |
liquidationDetail.setBidList(bidList);
|
|
|
1659 |
resultList.add(liquidationDetail);
|
|
|
1660 |
}
|
|
|
1661 |
}
|
|
|
1662 |
}
|
|
|
1663 |
|
|
|
1664 |
return responseSender.ok(resultList);
|
|
|
1665 |
}
|
|
|
1666 |
|
|
|
1667 |
@RequestMapping(value = "/store/clearance/bid", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
1668 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
|
|
1669 |
public ResponseEntity<?> saveBidding(HttpServletRequest request, @RequestBody BiddingModel biddingModel) throws Exception {
|
| 34446 |
vikas.jang |
1670 |
LocalDateTime now = LocalDateTime.now();
|
| 34476 |
vikas.jang |
1671 |
Liquidation liquidation = liquidationRepository.selectLiquidationById(biddingModel.getLiquidationId());
|
|
|
1672 |
LocalDateTime endDateTime = LocalDateTime.of(liquidation.getEndDate().toLocalDate(), LocalTime.of(ProfitMandiConstants.BID_END_HOUR, ProfitMandiConstants.BID_END_MIN));
|
| 34494 |
vikas.jang |
1673 |
List<Bid> biddings = bidRepository.selectBidByLiquidationId(biddingModel.getLiquidationId());
|
| 34476 |
vikas.jang |
1674 |
if (now.isAfter(endDateTime)) {
|
| 34494 |
vikas.jang |
1675 |
return responseSender.badRequest("Bid on this product has been closed");
|
| 34446 |
vikas.jang |
1676 |
}
|
| 34444 |
vikas.jang |
1677 |
Bid bid = null;
|
|
|
1678 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
|
|
1679 |
if (biddingModel.getId() != null && biddingModel.getId() > 0) {
|
|
|
1680 |
bid = bidRepository.selectById(biddingModel.getId());
|
|
|
1681 |
if (bid == null) {
|
| 34494 |
vikas.jang |
1682 |
return responseSender.badRequest("Bidding record not found with ID: " + biddingModel.getId());
|
| 34444 |
vikas.jang |
1683 |
}
|
|
|
1684 |
} else {
|
|
|
1685 |
bid = new Bid();
|
|
|
1686 |
}
|
| 34476 |
vikas.jang |
1687 |
logger.info("biddingModel {}: ",biddingModel);
|
| 34444 |
vikas.jang |
1688 |
bid.setLiquidationId(biddingModel.getLiquidationId());
|
|
|
1689 |
bid.setBiddingAmount(biddingModel.getBiddingAmount());
|
|
|
1690 |
bid.setFofoId(userInfo.getRetailerId());
|
|
|
1691 |
bid.setItemName(biddingModel.getItemName());
|
|
|
1692 |
bid.setQuantity(biddingModel.getBidQty());
|
|
|
1693 |
bid.setStatus(ProfitMandiConstants.BID_ENUM.PENDING);
|
|
|
1694 |
bid.setCreatedAt(LocalDateTime.now());
|
| 34562 |
ranu |
1695 |
if (biddingModel.getId() == null) {
|
| 37937 |
amit |
1696 |
storeStatusService.assertCanSpendWallet(bid.getFofoId());
|
| 34562 |
ranu |
1697 |
bidRepository.persist(bid);
|
| 34654 |
vikas.jang |
1698 |
//debit 500 from wallet
|
| 34878 |
vikas |
1699 |
try {
|
|
|
1700 |
String reason = "Advance security for "+bid.getItemName()+" bid";
|
| 35211 |
vikas |
1701 |
String message = "Dear Partner, We have Debited Rs "+ProfitMandiConstants.BID_CHARGES+" as booking amount against your bidding of Model No. "+bid.getItemName()+". We will adjust this amount from your order amount if the bid gets approved.";
|
| 34878 |
vikas |
1702 |
walletService.consumeAmountFromWallet(bid.getFofoId(),
|
|
|
1703 |
bid.getId(),
|
|
|
1704 |
WalletReferenceType.ADVANCE_SECURITY,
|
|
|
1705 |
reason, ProfitMandiConstants.BID_CHARGES,
|
|
|
1706 |
bid.getCreatedAt(),false);
|
|
|
1707 |
bidService.sendPushNotification(message,"Bidding Update!",Arrays.asList(bid.getFofoId()));
|
|
|
1708 |
} catch (Exception e) {
|
|
|
1709 |
logger.info("WalletDebit: {}",e.getMessage());
|
|
|
1710 |
}
|
| 34562 |
ranu |
1711 |
}
|
| 34494 |
vikas.jang |
1712 |
if (biddings.size() > 1) {
|
|
|
1713 |
for (Bid bidding : biddings) {
|
| 34562 |
ranu |
1714 |
if (!(bid.getFofoId().equals(bidding.getFofoId()))) bidService.notifyPartner(bidding.getFofoId(), bid, ProfitMandiConstants.BID_ENUM.UPDATE);
|
| 34494 |
vikas.jang |
1715 |
}
|
|
|
1716 |
}
|
|
|
1717 |
return responseSender.ok("Bid placed successfully!");
|
| 34444 |
vikas.jang |
1718 |
}
|
|
|
1719 |
|
|
|
1720 |
|
| 26607 |
amit.gupta |
1721 |
}
|