Subversion Repositories SmartDukaan

Rev

Rev 22931 | Rev 22988 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21339 kshitij.so 1
package com.spice.profitmandi.web.controller;
2
 
3
import java.time.LocalDateTime;
4
import java.util.ArrayList;
22336 amit.gupta 5
import java.util.Arrays;
21339 kshitij.so 6
import java.util.HashMap;
22952 amit.gupta 7
import java.util.Iterator;
21339 kshitij.so 8
import java.util.List;
9
import java.util.Map;
10
 
11
import javax.servlet.http.HttpServletRequest;
12
 
22319 amit.gupta 13
import org.apache.commons.lang3.StringUtils;
14
import org.json.JSONArray;
15
import org.json.JSONObject;
21339 kshitij.so 16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
22273 amit.gupta 18
import org.springframework.beans.factory.annotation.Autowired;
21339 kshitij.so 19
import org.springframework.beans.factory.annotation.Value;
20
import org.springframework.http.HttpStatus;
21
import org.springframework.http.MediaType;
22
import org.springframework.http.ResponseEntity;
23
import org.springframework.stereotype.Controller;
22286 amit.gupta 24
import org.springframework.transaction.annotation.Transactional;
21339 kshitij.so 25
import org.springframework.web.bind.annotation.PathVariable;
26
import org.springframework.web.bind.annotation.RequestMapping;
27
import org.springframework.web.bind.annotation.RequestMethod;
28
import org.springframework.web.bind.annotation.RequestParam;
29
 
30
import com.eclipsesource.json.Json;
31
import com.eclipsesource.json.JsonArray;
32
import com.eclipsesource.json.JsonObject;
33
import com.eclipsesource.json.JsonValue;
34
import com.google.gson.Gson;
21356 kshitij.so 35
import com.google.gson.reflect.TypeToken;
21643 ashik.ali 36
import com.spice.profitmandi.common.enumuration.SchemeType;
21339 kshitij.so 37
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
38
import com.spice.profitmandi.common.model.ProfitMandiConstants;
21740 ashik.ali 39
import com.spice.profitmandi.common.model.ProfitMandiResponse;
40
import com.spice.profitmandi.common.model.ResponseStatus;
22289 amit.gupta 41
import com.spice.profitmandi.common.model.UserInfo;
21643 ashik.ali 42
import com.spice.profitmandi.common.web.client.RestClient;
22319 amit.gupta 43
import com.spice.profitmandi.common.web.util.ResponseSender;
22289 amit.gupta 44
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
22361 amit.gupta 45
import com.spice.profitmandi.dao.model.UserCart;
22333 amit.gupta 46
import com.spice.profitmandi.dao.repository.dtr.Mongo;
22361 amit.gupta 47
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
22931 ashik.ali 48
import com.spice.profitmandi.service.inventory.InventoryService;
22287 amit.gupta 49
import com.spice.profitmandi.service.pricing.PricingService;
22952 amit.gupta 50
import com.spice.profitmandi.web.res.AvailabilityInfo;
21356 kshitij.so 51
import com.spice.profitmandi.web.res.DealBrands;
21339 kshitij.so 52
import com.spice.profitmandi.web.res.DealObjectResponse;
53
import com.spice.profitmandi.web.res.DealsResponse;
22328 amit.gupta 54
import com.spice.profitmandi.web.res.FofoAvailabilityInfo;
55
import com.spice.profitmandi.web.res.FofoCatalogResponse;
21339 kshitij.so 56
 
57
import io.swagger.annotations.ApiImplicitParam;
58
import io.swagger.annotations.ApiImplicitParams;
59
import io.swagger.annotations.ApiOperation;
60
 
61
@Controller
22319 amit.gupta 62
@Transactional(rollbackFor = Throwable.class)
21339 kshitij.so 63
public class DealsController {
64
 
22319 amit.gupta 65
	private static final Logger logger = LoggerFactory.getLogger(DealsController.class);
21339 kshitij.so 66
 
67
	@Value("${python.api.host}")
68
	private String host;
22931 ashik.ali 69
 
21339 kshitij.so 70
	@Value("${python.api.port}")
71
	private int port;
22708 amit.gupta 72
 
22710 amit.gupta 73
	@Value("${fofo.warehouseIds}")
22708 amit.gupta 74
	private int[] warehouseIds; 
22319 amit.gupta 75
 
76
	@Autowired
77
	private PricingService pricingService;
22273 amit.gupta 78
 
79
	@Autowired
22333 amit.gupta 80
	private Mongo mongoClient;
81
 
82
	@Autowired
22361 amit.gupta 83
	private UserAccountRepository userAccountRepository;
84
 
85
	@Autowired
22931 ashik.ali 86
	private ResponseSender<?> responseSender;
22336 amit.gupta 87
 
22554 amit.gupta 88
	@Autowired
22931 ashik.ali 89
	private InventoryService inventoryService;
22401 amit.gupta 90
 
22554 amit.gupta 91
 
22336 amit.gupta 92
	List<String> filterableParams = Arrays.asList("brand");
21339 kshitij.so 93
 
22319 amit.gupta 94
	@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
21339 kshitij.so 95
	@ApiImplicitParams({
22319 amit.gupta 96
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
21339 kshitij.so 97
	@ApiOperation(value = "Get deals")
22319 amit.gupta 98
	public ResponseEntity<?> getDeals(HttpServletRequest request, @RequestParam(value = "categoryId") String categoryId,
99
			@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
100
			@RequestParam(value = "sort", required = false) String sort,
101
			@RequestParam(value = "direction", required = false) String direction,
22931 ashik.ali 102
			@RequestParam(value = "filterData", required = false) String filterData) throws ProfitMandiBusinessException {
22319 amit.gupta 103
		logger.info("Request " + request.getParameterMap());
21339 kshitij.so 104
		String response = null;
22319 amit.gupta 105
		int userId = (int) request.getAttribute("userId");
106
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
107
		// TODO: move to properties
108
		String uri = "/deals/" + userId;
109
		RestClient rc = new RestClient(SchemeType.HTTP, host, port);
21339 kshitij.so 110
		Map<String, String> params = new HashMap<>();
111
		params.put("offset", offset);
112
		params.put("limit", limit);
113
		params.put("categoryId", categoryId);
114
		params.put("direction", direction);
115
		params.put("sort", sort);
116
		params.put("filterData", filterData);
22272 amit.gupta 117
		params.put("source", "deals");
22319 amit.gupta 118
		if (userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
22289 amit.gupta 119
			params.put("tag_ids", getCommaSeparateTags(userId));
120
		}
21356 kshitij.so 121
		List<Object> responseObject = new ArrayList<>();
22931 ashik.ali 122
		response = rc.get(uri, params);
123
 
21339 kshitij.so 124
		JsonArray result_json = Json.parse(response).asArray();
22319 amit.gupta 125
		for (JsonValue j : result_json) {
22842 amit.gupta 126
			//logger.info("res " + j.asArray());
21339 kshitij.so 127
			List<Object> innerObject = new ArrayList<>();
22319 amit.gupta 128
			for (JsonValue jsonObject : j.asArray()) {
21356 kshitij.so 129
				innerObject.add(toDealObject(jsonObject.asObject()));
21339 kshitij.so 130
			}
22319 amit.gupta 131
			if (innerObject.size() > 0) {
21339 kshitij.so 132
				responseObject.add(innerObject);
133
			}
134
		}
22319 amit.gupta 135
		final ProfitMandiResponse<?> profitMandiResponse = new ProfitMandiResponse<>(LocalDateTime.now(),
136
				request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS,
137
				responseObject);
138
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
21339 kshitij.so 139
	}
140
 
22931 ashik.ali 141
	private String getCommaSeparateTags(int userId){
22361 amit.gupta 142
		UserCart uc = userAccountRepository.getUserCart(userId);
143
		List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(uc.getUserId());
22287 amit.gupta 144
		List<String> strTagIds = new ArrayList<>();
145
		for (Integer tagId : tagIds) {
146
			strTagIds.add(String.valueOf(tagId));
22273 amit.gupta 147
		}
22287 amit.gupta 148
		return String.join(",", strTagIds);
22273 amit.gupta 149
	}
150
 
22319 amit.gupta 151
	@ApiImplicitParams({
152
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
153
	@RequestMapping(value = "/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
154
	public ResponseEntity<?> getFofo(HttpServletRequest request, @RequestParam(value = "categoryId") String categoryId,
155
			@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
22336 amit.gupta 156
			@RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand) throws Throwable {
22328 amit.gupta 157
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
22319 amit.gupta 158
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
159
		if (userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
22361 amit.gupta 160
			UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
161
			List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(uc.getUserId());
22319 amit.gupta 162
			RestClient rc  = new RestClient(SchemeType.HTTP, "dtr", 8984);
163
			Map<String, String> params = new HashMap<>();
22336 amit.gupta 164
			List<String> mandatoryQ = new ArrayList<>();
165
			if(brand != null) {
22347 amit.gupta 166
 
22348 amit.gupta 167
				mandatoryQ.add(String.format("+{!parent which=\"brand_s=%s\"} tagId_i:(%s)", brand, StringUtils.join(tagIds, " ")));
22347 amit.gupta 168
			} else {
169
				mandatoryQ.add(String.format("+{!parent which=\"id:catalog*\"} tagId_i:(%s)", StringUtils.join(tagIds, " ")));
22336 amit.gupta 170
			}
22340 amit.gupta 171
			params.put("q", StringUtils.join(mandatoryQ," "));
22319 amit.gupta 172
			params.put("fl", "*, [child parentFilter=id:catalog*]");
173
			params.put("sort", "rank_i asc");
174
			params.put("start", String.valueOf(offset));
175
			params.put("rows", String.valueOf(limit));
176
			params.put("wt", "json");
22330 amit.gupta 177
			logger.info(rc.getUrl());
22319 amit.gupta 178
			String response  =rc.get("solr/demo/select", params);
179
			JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
180
			JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
181
			for(int i=0; i < docs.length(); i++) {
22328 amit.gupta 182
				Map<Integer, FofoAvailabilityInfo> fofoAvailabilityInfoMap = new HashMap<>();
22319 amit.gupta 183
				JSONObject doc = docs.getJSONObject(i);
22328 amit.gupta 184
				FofoCatalogResponse ffdr = new FofoCatalogResponse();
22319 amit.gupta 185
				ffdr.setCatalogId(doc.getInt("catalogId_i"));
186
				ffdr.setImageUrl(doc.getString("imageUrl_s"));
187
				ffdr.setTitle(doc.getString("title_s"));
22333 amit.gupta 188
				ffdr.setBrand(doc.getString("brand_s"));
22323 amit.gupta 189
				for(int j=0; j< doc.getJSONArray("_childDocuments_").length(); j++) {
190
					JSONObject childItem = doc.getJSONArray("_childDocuments_").getJSONObject(j);
22319 amit.gupta 191
					int itemId = childItem.getInt("itemId_i");
192
					float sellingPrice = (float)childItem.getDouble("sellingPrice_f");
22328 amit.gupta 193
					if(fofoAvailabilityInfoMap.containsKey(itemId)) {
194
						if(fofoAvailabilityInfoMap.get(itemId).getSellingPrice() > sellingPrice) {
195
							fofoAvailabilityInfoMap.get(itemId).setSellingPrice(sellingPrice);
196
							fofoAvailabilityInfoMap.get(itemId).setMop((float)childItem.getDouble("mop_f"));
22319 amit.gupta 197
						} 
198
					} else {
22328 amit.gupta 199
							FofoAvailabilityInfo fdi = new FofoAvailabilityInfo();
22319 amit.gupta 200
							fdi.setSellingPrice((float)childItem.getDouble("sellingPrice_f"));
201
							fdi.setMop((float)childItem.getDouble("mop_f"));
22324 amit.gupta 202
							fdi.setColor(childItem.has("color_s")?childItem.getString("color_s"): "");
22319 amit.gupta 203
							fdi.setTagId(childItem.getInt("tagId_i"));
22328 amit.gupta 204
							fdi.setItem_id(itemId);
22708 amit.gupta 205
							fdi.setAvailability(inventoryService.getCachedAvailabilityByItemIdWarehouseIds(itemId, warehouseIds));
22328 amit.gupta 206
							fdi.setQuantityStep(1);
207
							fdi.setMinBuyQuantity(1);
22561 amit.gupta 208
							fdi.setMaxQuantity(Math.min(fdi.getAvailability(), 100));
22328 amit.gupta 209
							fofoAvailabilityInfoMap.put(itemId, fdi);
22319 amit.gupta 210
					}
211
				}
22328 amit.gupta 212
				ffdr.setItems(new ArrayList<FofoAvailabilityInfo>(fofoAvailabilityInfoMap.values()));
22319 amit.gupta 213
				dealResponse.add(ffdr);
214
			}
215
 
216
		} else {
217
			return responseSender.badRequest(new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
218
		}
219
		return responseSender.ok(dealResponse);
220
	}
22273 amit.gupta 221
 
22319 amit.gupta 222
	@RequestMapping(value = "/online-deals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
22272 amit.gupta 223
	@ApiImplicitParams({
22319 amit.gupta 224
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
22272 amit.gupta 225
	@ApiOperation(value = "Get online deals")
22319 amit.gupta 226
	public ResponseEntity<?> getOnlineDeals(HttpServletRequest request,
227
			@RequestParam(value = "categoryId") String categoryId, @RequestParam(value = "offset") String offset,
228
			@RequestParam(value = "limit") String limit, @RequestParam(value = "sort", required = false) String sort,
229
			@RequestParam(value = "direction", required = false) String direction,
230
			@RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
231
		logger.info("Request " + request.getParameterMap());
22272 amit.gupta 232
		String response = null;
22319 amit.gupta 233
		int userId = (int) request.getAttribute("userId");
22289 amit.gupta 234
 
22319 amit.gupta 235
		String uri = "/deals/" + userId;
236
		RestClient rc = new RestClient(SchemeType.HTTP, host, port);
22272 amit.gupta 237
		Map<String, String> params = new HashMap<>();
238
		params.put("offset", offset);
239
		params.put("limit", limit);
240
		params.put("categoryId", categoryId);
241
		params.put("direction", direction);
242
		params.put("sort", sort);
243
		params.put("source", "online");
244
		params.put("filterData", filterData);
22357 amit.gupta 245
		/*if (userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
22289 amit.gupta 246
			params.put("tag_ids", getCommaSeparateTags(userId));
22357 amit.gupta 247
		}*/
22272 amit.gupta 248
		List<Object> responseObject = new ArrayList<>();
22931 ashik.ali 249
		response = rc.get(uri, params);
250
 
22272 amit.gupta 251
		JsonArray result_json = Json.parse(response).asArray();
22319 amit.gupta 252
		for (JsonValue j : result_json) {
22843 amit.gupta 253
			//logger.info("res " + j.asArray());
22272 amit.gupta 254
			List<Object> innerObject = new ArrayList<>();
22319 amit.gupta 255
			for (JsonValue jsonObject : j.asArray()) {
22272 amit.gupta 256
				innerObject.add(toDealObject(jsonObject.asObject()));
257
			}
22319 amit.gupta 258
			if (innerObject.size() > 0) {
22272 amit.gupta 259
				responseObject.add(innerObject);
260
			}
261
		}
22319 amit.gupta 262
		final ProfitMandiResponse<?> profitMandiResponse = new ProfitMandiResponse<>(LocalDateTime.now(),
263
				request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS,
264
				responseObject);
265
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
22272 amit.gupta 266
	}
267
 
22319 amit.gupta 268
	/*
269
	 * @RequestMapping(value = "/direct-deals",
270
	 * method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
271
	 * 
272
	 * @ApiImplicitParams({
273
	 * 
274
	 * @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required =
275
	 * true, dataType = "string", paramType = "header") }) public
276
	 * ResponseEntity<?> getDirectDeals(HttpServletRequest
277
	 * request, @RequestParam(value="categoryId") String
278
	 * categoryId,@RequestParam(value="offset") String offset,
279
	 * 
280
	 * @RequestParam(value="limit") String limit, @RequestParam(value="sort",
281
	 * required=false) String sort, @RequestParam(value="direction",
282
	 * required=false) String direction,
283
	 * 
284
	 * @RequestParam(value="filterData", required=false) String filterData ){
285
	 * 
286
	 * return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK); }
287
	 */
288
 
289
	private Object toDealObject(JsonObject jsonObject) {
290
		if (jsonObject.get("dealObject") != null && jsonObject.get("dealObject").asInt() == 1) {
21339 kshitij.so 291
			return new Gson().fromJson(jsonObject.toString(), DealObjectResponse.class);
292
		}
293
		return new Gson().fromJson(jsonObject.toString(), DealsResponse.class);
294
	}
22319 amit.gupta 295
 
296
	@RequestMapping(value = ProfitMandiConstants.URL_BRANDS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
21356 kshitij.so 297
	@ApiImplicitParams({
22319 amit.gupta 298
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
21356 kshitij.so 299
	@ApiOperation(value = "Get brand list and count for category")
22319 amit.gupta 300
	public ResponseEntity<?> getBrands(HttpServletRequest request,
22931 ashik.ali 301
			@RequestParam(value = "category_id") String category_id) throws ProfitMandiBusinessException{
22319 amit.gupta 302
		logger.info("Request " + request.getParameterMap());
21356 kshitij.so 303
		String response = null;
22319 amit.gupta 304
		// TODO: move to properties
21356 kshitij.so 305
		String uri = ProfitMandiConstants.URL_BRANDS;
22319 amit.gupta 306
		RestClient rc = new RestClient(SchemeType.HTTP, host, port);
21356 kshitij.so 307
		Map<String, String> params = new HashMap<>();
308
		params.put("category_id", category_id);
21358 kshitij.so 309
		List<DealBrands> dealBrandsResponse = null;
22931 ashik.ali 310
		response = rc.get(uri, params);
311
 
22319 amit.gupta 312
		dealBrandsResponse = new Gson().fromJson(response, new TypeToken<List<DealBrands>>() {
313
		}.getType());
314
		final ProfitMandiResponse<?> profitMandiResponse = new ProfitMandiResponse<>(LocalDateTime.now(),
315
				request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS,
316
				dealBrandsResponse);
317
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
21356 kshitij.so 318
	}
22319 amit.gupta 319
 
320
	@RequestMapping(value = ProfitMandiConstants.URL_UNIT_DEAL, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
21445 kshitij.so 321
	@ApiImplicitParams({
22319 amit.gupta 322
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
21445 kshitij.so 323
	@ApiOperation(value = "Get unit deal object")
22931 ashik.ali 324
	public ResponseEntity<?> getUnitDeal(HttpServletRequest request, @PathVariable(value = "id") long id) 
325
			throws ProfitMandiBusinessException{
21445 kshitij.so 326
		String response = null;
22319 amit.gupta 327
		// TODO: move to properties
328
		String uri = "getDealById/" + id;
329
		System.out.println("Unit deal " + uri);
330
		RestClient rc = new RestClient(SchemeType.HTTP, host, port);
21445 kshitij.so 331
		Map<String, String> params = new HashMap<>();
332
		DealsResponse dealsResponse = null;
22931 ashik.ali 333
		response = rc.get(uri, params);
334
 
21445 kshitij.so 335
		JsonObject result_json = Json.parse(response).asObject();
22319 amit.gupta 336
		if (!result_json.isEmpty()) {
21445 kshitij.so 337
			dealsResponse = new Gson().fromJson(response, DealsResponse.class);
22952 amit.gupta 338
			Iterator<AvailabilityInfo> iter = dealsResponse.getAvailabilityInfo().iterator();
339
			while (iter.hasNext()){
340
				AvailabilityInfo ai = iter.next();
341
				if(ai.getAvailability() <= 0)
342
					iter.remove();
343
			}
21445 kshitij.so 344
		}
22952 amit.gupta 345
		/*final ProfitMandiResponse<?> profitMandiResponse = new ProfitMandiResponse<>(LocalDateTime.now(),
22319 amit.gupta 346
				request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS,
22952 amit.gupta 347
				dealsResponse);*/
348
		return responseSender.ok(dealsResponse);
21445 kshitij.so 349
	}
22333 amit.gupta 350
 
351
	@RequestMapping(value = "/fofo/brands", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
352
	public ResponseEntity<?> getBrandsToDisplay() {
353
		return new ResponseEntity<>(mongoClient.getBrandsToDisplay(), HttpStatus.OK);
354
	}
22401 amit.gupta 355
 
22446 amit.gupta 356
	@RequestMapping(value = "/banners/{bannerType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
22448 amit.gupta 357
	public ResponseEntity<?> getBanners(@PathVariable String bannerType) {
22447 amit.gupta 358
		return new ResponseEntity<>(mongoClient.getBannersByType(bannerType), HttpStatus.OK);
22446 amit.gupta 359
	}
360
 
22406 amit.gupta 361
	@ApiImplicitParams({
362
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })	
22401 amit.gupta 363
	@RequestMapping(value = "/deals/skus/{skus}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
22931 ashik.ali 364
	public ResponseEntity<?> getDealsBySkus(@PathVariable String skus) throws ProfitMandiBusinessException {
22401 amit.gupta 365
		StringBuffer sb = new StringBuffer("/getDealsForNotification/");
366
		String uri = sb.append(skus).toString();
367
		RestClient rc = new RestClient(SchemeType.HTTP, host, port);
368
		String response = rc.get(uri, new HashMap<>());
22406 amit.gupta 369
		JsonArray result_json = Json.parse(response).asArray();
22407 amit.gupta 370
		List<Object> responseObject = new ArrayList<>();
371
		for (JsonValue j : result_json) {
22843 amit.gupta 372
			//logger.info("res " + j.asArray());
22407 amit.gupta 373
			List<Object> innerObject = new ArrayList<>();
374
			for (JsonValue jsonObject : j.asArray()) {
375
				innerObject.add(toDealObject(jsonObject.asObject()));
376
			}
377
			if (innerObject.size() > 0) {
378
				responseObject.add(innerObject);
379
			}
380
		}
22408 amit.gupta 381
		return responseSender.ok(responseObject);
22401 amit.gupta 382
	}
21339 kshitij.so 383
 
384
}