Subversion Repositories SmartDukaan

Rev

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

Rev 26855 Rev 26857
Line 8... Line 8...
8
import java.util.HashSet;
8
import java.util.HashSet;
9
import java.util.List;
9
import java.util.List;
10
import java.util.Map;
10
import java.util.Map;
11
import java.util.Optional;
11
import java.util.Optional;
12
import java.util.Set;
12
import java.util.Set;
13
import java.util.stream.Collector;
-
 
14
import java.util.stream.Collectors;
13
import java.util.stream.Collectors;
15
 
14
 
16
import javax.servlet.http.HttpServletRequest;
15
import javax.servlet.http.HttpServletRequest;
17
 
16
 
18
import org.apache.commons.lang3.StringUtils;
17
import org.apache.commons.lang3.StringUtils;
Line 42... Line 41...
42
import com.spice.profitmandi.common.enumuration.SchemeType;
41
import com.spice.profitmandi.common.enumuration.SchemeType;
43
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
42
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
44
import com.spice.profitmandi.common.model.CreatePendingOrderRequest;
43
import com.spice.profitmandi.common.model.CreatePendingOrderRequest;
45
import com.spice.profitmandi.common.model.CustomRetailer;
44
import com.spice.profitmandi.common.model.CustomRetailer;
46
import com.spice.profitmandi.common.model.CustomerOrderDetail;
45
import com.spice.profitmandi.common.model.CustomerOrderDetail;
47
import com.spice.profitmandi.common.model.Notification;
-
 
48
import com.spice.profitmandi.common.model.ProfitMandiConstants;
46
import com.spice.profitmandi.common.model.ProfitMandiConstants;
49
import com.spice.profitmandi.common.model.UserInfo;
47
import com.spice.profitmandi.common.model.UserInfo;
50
import com.spice.profitmandi.common.solr.SolrService;
48
import com.spice.profitmandi.common.solr.SolrService;
51
import com.spice.profitmandi.common.web.client.RestClient;
49
import com.spice.profitmandi.common.web.client.RestClient;
52
import com.spice.profitmandi.common.web.util.ResponseSender;
50
import com.spice.profitmandi.common.web.util.ResponseSender;
53
import com.spice.profitmandi.dao.entity.catalog.Item;
51
import com.spice.profitmandi.dao.entity.catalog.Item;
54
import com.spice.profitmandi.dao.entity.catalog.TagListing;
52
import com.spice.profitmandi.dao.entity.catalog.TagListing;
55
import com.spice.profitmandi.dao.entity.dtr.WebListing;
53
import com.spice.profitmandi.dao.entity.dtr.WebListing;
56
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
54
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
57
import com.spice.profitmandi.dao.entity.fofo.Customer;
55
import com.spice.profitmandi.dao.entity.fofo.Customer;
-
 
56
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
58
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
57
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
59
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
58
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
60
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
59
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
61
import com.spice.profitmandi.dao.entity.inventory.ItemAvailabilityCache;
60
import com.spice.profitmandi.dao.entity.inventory.ItemAvailabilityCache;
62
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
61
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
Line 127... Line 126...
127
	@Autowired
126
	@Autowired
128
	private FofoStoreRepository fofoStoreRepository;
127
	private FofoStoreRepository fofoStoreRepository;
129
 
128
 
130
	@Autowired
129
	@Autowired
131
	private RetailerService retailerService;
130
	private RetailerService retailerService;
-
 
131
	
-
 
132
	@Autowired
-
 
133
	private PendingOrderRepository pendingOrderRepository;
-
 
134
	
-
 
135
	@Autowired
-
 
136
	private PendingOrderItemRepository pendingOrderItemRepository;
132
 
137
 
133
	@Autowired
138
	@Autowired
134
	private PendingOrderService pendingOrderService;
139
	private PendingOrderService pendingOrderService;
135
 
140
 
136
	@Autowired
141
	@Autowired
Line 167... Line 172...
167
	private WebProductListingRepository webProductListingRepository;
172
	private WebProductListingRepository webProductListingRepository;
168
 
173
 
169
	@Autowired
174
	@Autowired
170
	private RoleManager roleManagerService;
175
	private RoleManager roleManagerService;
171
 
176
 
172
	@Autowired
-
 
173
	private PendingOrderRepository pendingOrderRepository;
-
 
174
 
-
 
175
	@Autowired
-
 
176
	private PendingOrderItemRepository pendingOrderItemRepository;
-
 
177
 
-
 
178
	List<String> filterableParams = Arrays.asList("brand");
177
	List<String> filterableParams = Arrays.asList("brand");
179
 
178
 
180
	@ApiImplicitParams({
179
	@ApiImplicitParams({
181
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
180
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
182
	@RequestMapping(value = "/store/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
181
	@RequestMapping(value = "/store/fofo", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
Line 366... Line 365...
366
	}
365
	}
367
 
366
 
368
	@RequestMapping(value = "/store/otp/generateOTP", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
367
	@RequestMapping(value = "/store/otp/generateOTP", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
369
	public ResponseEntity<?> generateOtp(HttpServletRequest request, @RequestParam String mobile) throws Exception {
368
	public ResponseEntity<?> generateOtp(HttpServletRequest request, @RequestParam String mobile) throws Exception {
370
 
369
 
371
		return responseSender.ok(otpProcessor.generateOtp(mobile, OtpType.PREBOOKING_ORDER));
370
		return responseSender.ok(otpProcessor.generateOtp(mobile, OtpType.REGISTRATION));
372
 
371
 
373
	}
372
	}
374
 
373
 
375
	@RequestMapping(value = "/store/checkmobile/{mobile}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
374
	@RequestMapping(value = "/store/checkmobile/{mobile}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
376
	public ResponseEntity<?> checkRegistrationUsingMobile(HttpServletRequest request, @PathVariable String mobile)
375
	public ResponseEntity<?> checkRegistrationUsingMobile(HttpServletRequest request, @PathVariable String mobile)
Line 390... Line 389...
390
			return responseSender.ok(true);
389
			return responseSender.ok(true);
391
		} else {
390
		} else {
392
			return responseSender.ok(false);
391
			return responseSender.ok(false);
393
		}
392
		}
394
	}
393
	}
395
 
394
	
396
	@RequestMapping(value = "/store/resetPassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
395
	@RequestMapping(value = "/store/resetPassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
397
	public ResponseEntity<?> resetPassword(HttpServletRequest request, @RequestBody UserModel userModel)
396
	public ResponseEntity<?> resetPassword(HttpServletRequest request, @RequestBody UserModel userModel) throws Exception {
398
			throws Exception {
-
 
399
		customerService.changePassword(userModel.getMobile(), userModel.getPassword());
397
		customerService.changePassword(userModel.getMobile(), userModel.getPassword());
400
		return responseSender.ok(true);
398
		return responseSender.ok(true);
401
	}
399
	}
402
 
400
 
-
 
401
	@RequestMapping(value = "/store/register", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
402
	public ResponseEntity<?> register(HttpServletRequest request, @RequestBody UserModel userModel) throws Exception {
-
 
403
		Customer customer = new Customer();
-
 
404
		customer.setPassword(userModel.getPassword());
-
 
405
		customer.setEmailId(userModel.getEmail());
-
 
406
		customer.setFirstName(userModel.getFirstName());
-
 
407
		customer.setLastName(userModel.getLastName());
-
 
408
		customer.setMobileNumber(userModel.getMobile());
-
 
409
		return responseSender.ok(customerService.addCustomer(customer));
-
 
410
	}
-
 
411
 
403
	@RequestMapping(value = "/store/confirmOrder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
412
	@RequestMapping(value = "/store/confirmOrder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
404
	public ResponseEntity<?> confirmCart(HttpServletRequest request,
413
	public ResponseEntity<?> confirmOrder(HttpServletRequest request,
405
			@RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
414
			@RequestBody CreatePendingOrderRequest createPendingOrderRequest) throws Exception {
406
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
415
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
407
		Integer storeId = userInfo.getRetailerId();
416
		Integer storeId = userInfo.getRetailerId();
408
		createPendingOrderRequest.setFofoId(storeId);
417
		createPendingOrderRequest.setFofoId(storeId);
409
		this.pendingOrderService.createPendingOrder(createPendingOrderRequest);
418
		return responseSender.ok(this.pendingOrderService.createPendingOrder(createPendingOrderRequest));
410
		return responseSender.ok(true);
-
 
411
 
419
 
412
	}
420
	}
413
 
421
 
-
 
422
	@RequestMapping(value = "/store/address", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
423
	@ApiImplicitParams({
-
 
424
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
425
	@ApiOperation(value = "Get brand list and count for category")
-
 
426
	public ResponseEntity<?> getAddress(HttpServletRequest request) throws Exception {
-
 
427
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
-
 
428
		Integer storeId = userInfo.getRetailerId();
-
 
429
		CustomRetailer customRetailer = retailerService.getFofoRetailer(storeId);
-
 
430
 
-
 
431
		return responseSender.ok(customRetailer.getAddress());
-
 
432
 
-
 
433
	}
-
 
434
 
-
 
435
	@RequestMapping(value = "/store/address/{pincode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
436
	@ApiImplicitParams({
-
 
437
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
438
	@ApiOperation(value = "Get brand list and count for category")
-
 
439
	public ResponseEntity<?> getStoresByPincode(HttpServletRequest request, @PathVariable String pincode)
-
 
440
			throws Exception {
-
 
441
		List<PincodePartner> pincodePartners = pincodePartnerRepository.selectPartnersByPincode(pincode);
-
 
442
		int fofoId = DEFAULT_STORE;
-
 
443
		if (pincodePartners.size() > 0) {
-
 
444
			fofoId = pincodePartners.get(0).getFofoId();
-
 
445
		}
-
 
446
		return responseSender.ok(fofoStoreRepository.selectByRetailerId(fofoId).getCode());
-
 
447
	}
-
 
448
	
414
	@RequestMapping(value = "/store/order", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
449
	@RequestMapping(value = "/store/order", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
415
	public ResponseEntity<?> getOrderDetail(HttpServletRequest request, @RequestParam(value = "id") int id,
450
	public ResponseEntity<?> getOrderDetail(HttpServletRequest request, @RequestParam(value = "id") int id,
416
			@RequestParam(name = "offset") int offset, @RequestParam(name = "limit") int limit)
451
			@RequestParam(name = "offset") int offset, @RequestParam(name = "limit") int limit)
417
			throws ProfitMandiBusinessException {
452
			throws ProfitMandiBusinessException {
418
		List<CustomerOrderDetail> customerOrderDetails = new ArrayList<>();
453
		List<CustomerOrderDetail> customerOrderDetails = new ArrayList<>();
Line 442... Line 477...
442
		}
477
		}
443
 
478
 
444
		return responseSender.ok(customerOrderDetails);
479
		return responseSender.ok(customerOrderDetails);
445
	}
480
	}
446
 
481
 
447
	@RequestMapping(value = "/store/address", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
448
	@ApiImplicitParams({
-
 
449
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
450
	@ApiOperation(value = "Get brand list and count for category")
-
 
451
	public ResponseEntity<?> getAddress(HttpServletRequest request) throws Exception {
-
 
452
		UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
-
 
453
		Integer storeId = userInfo.getRetailerId();
-
 
454
		CustomRetailer customRetailer = retailerService.getFofoRetailer(storeId);
-
 
455
 
-
 
456
		return responseSender.ok(customRetailer.getAddress());
-
 
457
 
-
 
458
	}
-
 
459
 
-
 
460
	@RequestMapping(value = "/store/address/{pincode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
461
	@ApiImplicitParams({
-
 
462
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
463
	@ApiOperation(value = "Get brand list and count for category")
-
 
464
	public ResponseEntity<?> getStoresByPincode(HttpServletRequest request, @PathVariable String pincode)
-
 
465
			throws Exception {
-
 
466
		List<PincodePartner> pincodePartners = pincodePartnerRepository.selectPartnersByPincode(pincode);
-
 
467
		int fofoId = DEFAULT_STORE;
-
 
468
		if (pincodePartners.size() > 0) {
-
 
469
			fofoId = pincodePartners.get(0).getFofoId();
-
 
470
		}
-
 
471
		return responseSender.ok(fofoStoreRepository.selectByRetailerId(fofoId).getCode());
-
 
472
	}
-
 
473
 
482
 
474
	@RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
483
	@RequestMapping(value = "/store/listing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
475
	@Cacheable(value = "storelisting.all", cacheManager = "thirtyMinsTimeOutCacheManager")
484
	@Cacheable(value = "storelisting.all", cacheManager = "thirtyMinsTimeOutCacheManager")
476
	public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
485
	public ResponseEntity<?> getStoresListing(HttpServletRequest request) throws Exception {
477
		List<WebListing> webListings = webListingRepository.selectAllWebListing(Optional.of(true));
486
		List<WebListing> webListings = webListingRepository.selectAllWebListing(Optional.of(true));
Line 701... Line 710...
701
	@RequestMapping(value = "/store/addresses/{customerId}", method = RequestMethod.GET)
710
	@RequestMapping(value = "/store/addresses/{customerId}", method = RequestMethod.GET)
702
	public ResponseEntity<?> getAll(HttpServletRequest request, @PathVariable int customerId) throws Throwable {
711
	public ResponseEntity<?> getAll(HttpServletRequest request, @PathVariable int customerId) throws Throwable {
703
		return responseSender.ok(customerAddressRepository.selectByCustomerId(customerId));
712
		return responseSender.ok(customerAddressRepository.selectByCustomerId(customerId));
704
	}
713
	}
705
 
714
 
-
 
715
	@RequestMapping(value = "/store/address", method = RequestMethod.POST)
-
 
716
	public ResponseEntity<?> addAddress(HttpServletRequest request, @RequestBody CustomerAddress customerAddress)
-
 
717
			throws Throwable {
-
 
718
		customerAddressRepository.persist(customerAddress);
-
 
719
		return responseSender.ok(customerAddress);
-
 
720
	}
-
 
721
 
706
}
722
}
707
 
723
 
708
class UserModel {
724
class UserModel {
-
 
725
	@JsonProperty(required = true)
709
	private String mobile;
726
	private String mobile;
-
 
727
	@JsonProperty(required = true)
710
	private String password;
728
	private String password;
-
 
729
	@JsonProperty(required = false)
-
 
730
	private String firstName;
-
 
731
	@JsonProperty(required = false)
-
 
732
	private String lastName;
-
 
733
	@JsonProperty(required = false)
-
 
734
	private String email;
711
 
735
 
712
	@Override
736
	@Override
713
	public String toString() {
737
	public String toString() {
714
		return "UserModel [mobile=" + mobile + ", password=" + password + "]";
738
		return "UserModel [mobile=" + mobile + ", password=" + password + "]";
715
	}
739
	}
Line 727... Line 751...
727
	}
751
	}
728
 
752
 
729
	public void setPassword(String password) {
753
	public void setPassword(String password) {
730
		this.password = password;
754
		this.password = password;
731
	}
755
	}
-
 
756
 
-
 
757
	public String getFirstName() {
-
 
758
		return firstName;
-
 
759
	}
-
 
760
 
-
 
761
	public void setFirstName(String firstName) {
-
 
762
		this.firstName = firstName;
-
 
763
	}
-
 
764
 
-
 
765
	public String getLastName() {
-
 
766
		return lastName;
-
 
767
	}
-
 
768
 
-
 
769
	public void setLastName(String lastName) {
-
 
770
		this.lastName = lastName;
-
 
771
	}
-
 
772
 
-
 
773
	public String getEmail() {
-
 
774
		return email;
-
 
775
	}
-
 
776
 
-
 
777
	public void setEmail(String email) {
-
 
778
		this.email = email;
-
 
779
	}
-
 
780
 
732
}
781
}
733
 
782
 
734
class CustomerModel {
783
class CustomerModel {
735
 
784
 
736
	@JsonProperty(required = false)
785
	@JsonProperty(required = false)