Subversion Repositories SmartDukaan

Rev

Rev 27028 | Rev 27045 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27028 Rev 27030
Line 36... Line 36...
36
import org.springframework.mail.javamail.MimeMessageHelper;
36
import org.springframework.mail.javamail.MimeMessageHelper;
37
import org.springframework.stereotype.Controller;
37
import org.springframework.stereotype.Controller;
38
import org.springframework.transaction.annotation.Transactional;
38
import org.springframework.transaction.annotation.Transactional;
39
import org.springframework.web.bind.annotation.GetMapping;
39
import org.springframework.web.bind.annotation.GetMapping;
40
import org.springframework.web.bind.annotation.PathVariable;
40
import org.springframework.web.bind.annotation.PathVariable;
41
import org.springframework.web.bind.annotation.PostMapping;
-
 
42
import org.springframework.web.bind.annotation.RequestBody;
41
import org.springframework.web.bind.annotation.RequestBody;
43
import org.springframework.web.bind.annotation.RequestMapping;
42
import org.springframework.web.bind.annotation.RequestMapping;
44
import org.springframework.web.bind.annotation.RequestMethod;
43
import org.springframework.web.bind.annotation.RequestMethod;
45
import org.springframework.web.bind.annotation.RequestParam;
44
import org.springframework.web.bind.annotation.RequestParam;
46
 
45
 
Line 61... Line 60...
61
import com.spice.profitmandi.common.web.client.RestClient;
60
import com.spice.profitmandi.common.web.client.RestClient;
62
import com.spice.profitmandi.common.web.util.ResponseSender;
61
import com.spice.profitmandi.common.web.util.ResponseSender;
63
import com.spice.profitmandi.dao.entity.catalog.Item;
62
import com.spice.profitmandi.dao.entity.catalog.Item;
64
import com.spice.profitmandi.dao.entity.catalog.TagListing;
63
import com.spice.profitmandi.dao.entity.catalog.TagListing;
65
import com.spice.profitmandi.dao.entity.dtr.WebListing;
64
import com.spice.profitmandi.dao.entity.dtr.WebListing;
66
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
-
 
67
import com.spice.profitmandi.dao.entity.fofo.Customer;
65
import com.spice.profitmandi.dao.entity.fofo.Customer;
68
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
66
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
69
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
67
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
70
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
68
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
71
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
69
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
72
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
70
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
73
import com.spice.profitmandi.dao.model.AddCartRequest;
71
import com.spice.profitmandi.dao.model.AddCartRequest;
74
import com.spice.profitmandi.dao.model.CartItem;
72
import com.spice.profitmandi.dao.model.CartItem;
75
import com.spice.profitmandi.dao.model.CartItemResponseModel;
73
import com.spice.profitmandi.dao.model.CartItemResponseModel;
76
import com.spice.profitmandi.dao.model.CartResponse;
74
import com.spice.profitmandi.dao.model.CartResponse;
-
 
75
import com.spice.profitmandi.dao.model.UserCart;
77
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
76
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
78
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
77
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
79
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
78
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
-
 
79
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
80
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
80
import com.spice.profitmandi.dao.repository.dtr.WebListingRepository;
81
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
81
import com.spice.profitmandi.dao.repository.dtr.WebProductListingRepository;
82
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
82
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
83
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
83
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
84
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
84
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
Line 120... Line 120...
120
 
120
 
121
	@Autowired
121
	@Autowired
122
	CustomerAddressRepository customerAddressRepository;
122
	CustomerAddressRepository customerAddressRepository;
123
 
123
 
124
	@Autowired
124
	@Autowired
-
 
125
	SolrService solrService;
-
 
126
	
-
 
127
	@Autowired
125
	InventoryService inventoryService;
128
	InventoryService inventoryService;
-
 
129
	
-
 
130
	@Autowired
-
 
131
	UserAccountRepository userAccountRepository;
126
 
132
 
127
	@Value("${python.api.host}")
133
	@Value("${python.api.host}")
128
	private String host;
134
	private String host;
129
 
135
 
130
	@Autowired
136
	@Autowired
Line 200... Line 206...
200
	@Autowired
206
	@Autowired
201
	JavaMailSender mailSender;
207
	JavaMailSender mailSender;
202
 
208
 
203
	List<String> filterableParams = Arrays.asList("brand");
209
	List<String> filterableParams = Arrays.asList("brand");
204
 
210
 
205
	@ApiImplicitParams({
211
	/*@ApiImplicitParams({
206
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
212
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
207
	@RequestMapping(value = "/store/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
213
	@RequestMapping(value = "/store/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
208
	public ResponseEntity<?> getFofo(HttpServletRequest request,
214
	public ResponseEntity<?> getFofo(HttpServletRequest request,
209
			@RequestParam(value = "categoryId", required = false, defaultValue = "(3 OR 6)") String categoryId,
215
			@RequestParam(value = "categoryId", required = false, defaultValue = "(3 OR 6)") String categoryId,
210
			@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
216
			@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
Line 257... Line 263...
257
				throw new ProfitMandiBusinessException("", "", "Could not connect to host");
263
				throw new ProfitMandiBusinessException("", "", "Could not connect to host");
258
			}
264
			}
259
			JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
265
			JSONObject solrResponseJSONObj = new JSONObject(response).getJSONObject("response");
260
			JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
266
			JSONArray docs = solrResponseJSONObj.getJSONArray("docs");
261
			dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
267
			dealResponse = getCatalogResponse(docs, false, userInfo.getRetailerId());
262
			/*
268
			
263
			 * if (Mongo.PARTNER_BLoCKED_BRANDS.containsKey(userInfo.getEmail())) {
269
			 * if (Mongo.PARTNER_BLoCKED_BRANDS.containsKey(userInfo.getEmail())) {
264
			 * dealResponse.stream() .filter(x ->
270
			 * dealResponse.stream() .filter(x ->
265
			 * Mongo.PARTNER_BLoCKED_BRANDS.get(userInfo.getEmail()).contains(x.getBrand()))
271
			 * Mongo.PARTNER_BLoCKED_BRANDS.get(userInfo.getEmail()).contains(x.getBrand()))
266
			 * ; }
272
			 * ; }
267
			 */
273
			 
268
		} else {
274
		} else {
269
			return responseSender.badRequest(
275
			return responseSender.badRequest(
270
					new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
276
					new ProfitMandiBusinessException("Retailer id", userInfo.getUserId(), "NOT_FOFO_RETAILER"));
271
		}
277
		}
272
		return responseSender.ok(dealResponse);
278
		return responseSender.ok(dealResponse);
273
	}
279
	}*/
274
 
280
 
275
	@RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
281
	@RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
276
	@ApiImplicitParams({
282
	@ApiImplicitParams({
277
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
283
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
278
	@ApiOperation(value = "Get unit deal object")
284
	@ApiOperation(value = "Get unit deal object")
Line 693... Line 699...
693
 
699
 
694
		return cartResponse;
700
		return cartResponse;
695
 
701
 
696
	}
702
	}
697
 
703
 
-
 
704
	@RequestMapping(value = "/store/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
705
	public ResponseEntity<?> partnerStock(HttpServletRequest request,
-
 
706
			@RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId,
-
 
707
			@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
-
 
708
			@RequestParam(value = "sort", required = false) String sort,
-
 
709
			@RequestParam(value = "brand", required = false) String brand,
-
 
710
			@RequestParam(value = "subCategoryId", required = false) int subCategoryId,
-
 
711
			@RequestParam(value = "q", required = false) String queryTerm,
-
 
712
			@RequestParam(value = " ", required = false, defaultValue = "true") boolean partnerStockOnly)
-
 
713
			throws Throwable {
-
 
714
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
-
 
715
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
-
 
716
		dealResponse = this.getCatalogResponse(solrService.getSolrDocs(queryTerm, categoryId, offset, limit,
-
 
717
				sort, brand, subCategoryId, false), false, userInfo.getRetailerId());
-
 
718
		return responseSender.ok(dealResponse);
-
 
719
	}
-
 
720
 
698
	private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId)
721
	private List<FofoCatalogResponse> getCatalogResponse(JSONArray docs, boolean hotDeal, int fofoId)
699
			throws ProfitMandiBusinessException {
722
			throws ProfitMandiBusinessException {
700
		Map<Integer, Integer> ourItemAvailabilityMap = null;
723
		Map<Integer, Integer> ourItemAvailabilityMap = null;
701
		Map<Integer, Integer> partnerStockAvailabilityMap = null;
724
		Map<Integer, Integer> partnerStockAvailabilityMap = null;
702
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();
725
		List<FofoCatalogResponse> dealResponse = new ArrayList<>();