Subversion Repositories SmartDukaan

Rev

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

Rev 26531 Rev 26647
Line 40... Line 40...
40
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
40
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
41
import com.spice.profitmandi.common.model.CartFofo;
41
import com.spice.profitmandi.common.model.CartFofo;
42
import com.spice.profitmandi.common.model.CreateOrderRequest;
42
import com.spice.profitmandi.common.model.CreateOrderRequest;
43
import com.spice.profitmandi.common.model.CreditNotePdfModel;
43
import com.spice.profitmandi.common.model.CreditNotePdfModel;
44
import com.spice.profitmandi.common.model.CustomCustomer;
44
import com.spice.profitmandi.common.model.CustomCustomer;
-
 
45
import com.spice.profitmandi.common.model.CustomRetailer;
45
import com.spice.profitmandi.common.model.FoiBadReturnRequest;
46
import com.spice.profitmandi.common.model.FoiBadReturnRequest;
46
import com.spice.profitmandi.common.model.PaymentOptionTransactionModel;
47
import com.spice.profitmandi.common.model.PaymentOptionTransactionModel;
47
import com.spice.profitmandi.common.model.PdfModel;
48
import com.spice.profitmandi.common.model.PdfModel;
48
import com.spice.profitmandi.common.model.PriceModel;
49
import com.spice.profitmandi.common.model.PriceModel;
49
import com.spice.profitmandi.common.model.ProfitMandiConstants;
50
import com.spice.profitmandi.common.model.ProfitMandiConstants;
Line 52... Line 53...
52
import com.spice.profitmandi.common.web.util.ResponseSender;
53
import com.spice.profitmandi.common.web.util.ResponseSender;
53
import com.spice.profitmandi.dao.entity.catalog.Item;
54
import com.spice.profitmandi.dao.entity.catalog.Item;
54
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
55
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
55
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
56
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
56
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
57
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
-
 
58
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
57
import com.spice.profitmandi.dao.entity.fofo.Customer;
59
import com.spice.profitmandi.dao.entity.fofo.Customer;
58
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
60
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
59
import com.spice.profitmandi.dao.entity.fofo.CustomerCreditNote;
61
import com.spice.profitmandi.dao.entity.fofo.CustomerCreditNote;
60
import com.spice.profitmandi.dao.entity.fofo.CustomerReturnItem;
62
import com.spice.profitmandi.dao.entity.fofo.CustomerReturnItem;
61
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
63
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
62
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
64
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
63
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
65
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
64
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
66
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
-
 
67
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
-
 
68
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
65
import com.spice.profitmandi.dao.entity.user.Address;
69
import com.spice.profitmandi.dao.entity.user.Address;
66
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
70
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
67
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
71
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
-
 
72
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
68
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
73
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
69
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
74
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
70
import com.spice.profitmandi.dao.repository.dtr.PaymentOptionTransactionRepository;
75
import com.spice.profitmandi.dao.repository.dtr.PaymentOptionTransactionRepository;
71
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
76
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
-
 
77
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
72
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
78
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
73
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
79
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
74
import com.spice.profitmandi.dao.repository.fofo.CustomerReturnItemRepository;
80
import com.spice.profitmandi.dao.repository.fofo.CustomerReturnItemRepository;
75
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
81
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
76
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
82
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
77
import com.spice.profitmandi.dao.repository.fofo.FofoPartnerPaymentOptionRepository;
83
import com.spice.profitmandi.dao.repository.fofo.FofoPartnerPaymentOptionRepository;
78
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
84
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
-
 
85
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
-
 
86
import com.spice.profitmandi.dao.repository.fofo.PendingOrderRepository;
79
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
87
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
80
import com.spice.profitmandi.dao.repository.user.AddressRepository;
88
import com.spice.profitmandi.dao.repository.user.AddressRepository;
81
import com.spice.profitmandi.service.authentication.RoleManager;
89
import com.spice.profitmandi.service.authentication.RoleManager;
82
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
90
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
83
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
91
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
84
import com.spice.profitmandi.service.order.OrderService;
92
import com.spice.profitmandi.service.order.OrderService;
85
import com.spice.profitmandi.service.pricing.PricingService;
93
import com.spice.profitmandi.service.pricing.PricingService;
-
 
94
import com.spice.profitmandi.service.user.RetailerService;
86
import com.spice.profitmandi.web.model.LoginDetails;
95
import com.spice.profitmandi.web.model.LoginDetails;
87
import com.spice.profitmandi.web.util.CookiesProcessor;
96
import com.spice.profitmandi.web.util.CookiesProcessor;
88
import com.spice.profitmandi.web.util.MVCResponseSender;
97
import com.spice.profitmandi.web.util.MVCResponseSender;
89
 
98
 
90
@Controller
99
@Controller
Line 156... Line 165...
156
	private FofoPartnerPaymentOptionRepository fofoPartnerPaymentOptionRepository;
165
	private FofoPartnerPaymentOptionRepository fofoPartnerPaymentOptionRepository;
157
 
166
 
158
	@Autowired
167
	@Autowired
159
	private ResponseSender<?> responseSender;
168
	private ResponseSender<?> responseSender;
160
 
169
 
-
 
170
	@Autowired
-
 
171
	private PendingOrderRepository pendingOrderRepository;
-
 
172
 
-
 
173
	@Autowired
-
 
174
	private PendingOrderItemRepository pendingOrderItemRepository;
-
 
175
 
-
 
176
	@Autowired
-
 
177
	private FofoStoreRepository fofoStoreRepository;
-
 
178
 
-
 
179
	@Autowired
-
 
180
	private RetailerService retailerService;
-
 
181
 
-
 
182
	@Autowired
-
 
183
	private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
-
 
184
 
161
	@RequestMapping(value = "/order")
185
	@RequestMapping(value = "/order")
162
	public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
186
	public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
163
			throws ProfitMandiBusinessException {
187
			throws ProfitMandiBusinessException {
164
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
188
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
165
		;
189
		;
Line 481... Line 505...
481
	}
505
	}
482
 
506
 
483
	@RequestMapping(value = "/create-order", method = RequestMethod.POST)
507
	@RequestMapping(value = "/create-order", method = RequestMethod.POST)
484
	public String createOrder(HttpServletRequest request, @RequestBody CreateOrderRequest createOrderRequest,
508
	public String createOrder(HttpServletRequest request, @RequestBody CreateOrderRequest createOrderRequest,
485
			Model model) throws ProfitMandiBusinessException {
509
			Model model) throws ProfitMandiBusinessException {
486
		//throw new ProfitMandiBusinessException("Billing is on hold temporarily", "Billing is on hold temporarily", "Billing is on hold temporarily");
510
		// throw new ProfitMandiBusinessException("Billing is on hold temporarily",
-
 
511
		// "Billing is on hold temporarily", "Billing is on hold temporarily");
487
		LOGGER.info("request at uri {} body {}", request.getRequestURI(), createOrderRequest);
512
		LOGGER.info("request at uri {} body {}", request.getRequestURI(), createOrderRequest);
488
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
513
		LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
489
 
514
 
490
		int fofoOrderId = orderService.createOrder(createOrderRequest, fofoDetails.getFofoId(), accessoriesDeals);
515
		int fofoOrderId = orderService.createOrder(createOrderRequest, fofoDetails.getFofoId(), accessoriesDeals);
491
		LOGGER.info("Order has been created successfully...");
516
		LOGGER.info("Order has been created successfully...");
Line 719... Line 744...
719
					sellingPrice);
744
					sellingPrice);
720
			return productDurationPlans;
745
			return productDurationPlans;
721
		} catch (Exception e) {
746
		} catch (Exception e) {
722
			e.printStackTrace();
747
			e.printStackTrace();
723
			throw new ProfitMandiBusinessException("Fetch Insurance Plans", "Insurance",
748
			throw new ProfitMandiBusinessException("Fetch Insurance Plans", "Insurance",
724
					"Could not fetch insurance Plans");	
749
					"Could not fetch insurance Plans");
725
		}
750
		}
726
 
751
 
727
	}
752
	}
728
 
753
 
729
	@GetMapping("/insuranceDetails")
754
	@GetMapping("/insuranceDetails")
Line 764... Line 789...
764
				.stream().collect(Collectors.toMap(InsuranceProvider::getId, InsuranceProvider::getName));
789
				.stream().collect(Collectors.toMap(InsuranceProvider::getId, InsuranceProvider::getName));
765
		model.addAttribute("insurancePolicies", insurancePolicies);
790
		model.addAttribute("insurancePolicies", insurancePolicies);
766
		model.addAttribute("providerPolicyNameAndIdMap", providerPolicyNameAndIdMap);
791
		model.addAttribute("providerPolicyNameAndIdMap", providerPolicyNameAndIdMap);
767
		return "insurance-details-paginated";
792
		return "insurance-details-paginated";
768
	}
793
	}
-
 
794
 
-
 
795
	@GetMapping("/pendingOrders")
-
 
796
	public String getPendingOrders(HttpServletRequest request,
-
 
797
			@RequestParam(name = "offset", defaultValue = "0") int offset,
-
 
798
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
-
 
799
			throws ProfitMandiBusinessException {
-
 
800
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
801
		boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
-
 
802
		List<Integer> fofoIds = fofoStoreRepository.selectActiveStores().stream().map(x -> x.getId())
-
 
803
				.collect(Collectors.toList());
-
 
804
 
-
 
805
		Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
-
 
806
 
-
 
807
		List<PendingOrder> pendingOrder = null;
-
 
808
		if (isAdmin) {
-
 
809
			pendingOrder = pendingOrderRepository.selectAllByStatus(offset, limit, "pending");
-
 
810
			model.addAttribute("customRetailersMap", customRetailersMap);
-
 
811
		} else {
-
 
812
			pendingOrder = pendingOrderRepository.selectByFofoId(loginDetails.getFofoId(), "pending", offset, limit);
-
 
813
		}
-
 
814
		model.addAttribute("pendingOrder", pendingOrder);
-
 
815
		return "pending_fofo_order";
-
 
816
	}
-
 
817
 
-
 
818
	@GetMapping("/getPendingOrderItem")
-
 
819
	public String getPendingOrderItem(HttpServletRequest request, @RequestParam int orderId, Model model)
-
 
820
			throws ProfitMandiBusinessException {
-
 
821
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
822
		Map<Integer, Item> itemMap = new HashMap<>();
-
 
823
		Map<Integer, CurrentInventorySnapshot> inventoryMap = new HashMap<>();
-
 
824
		List<PendingOrderItem> pendingOrderItems = pendingOrderItemRepository.selectByOrderId(orderId);
-
 
825
		for (PendingOrderItem pendingOrderItem : pendingOrderItems) {
-
 
826
			Item item = itemRepository.selectById(pendingOrderItem.getItemId());
-
 
827
			CurrentInventorySnapshot cis = currentInventorySnapshotRepository
-
 
828
					.selectByItemAndFofoId(pendingOrderItem.getItemId(), loginDetails.getFofoId());
-
 
829
			itemMap.put(pendingOrderItem.getItemId(), item);
-
 
830
			LOGGER.info("cis" + cis);
-
 
831
			inventoryMap.put(pendingOrderItem.getItemId(), cis);
-
 
832
		}
-
 
833
 
-
 
834
		LOGGER.info("inventoryMap" + inventoryMap);
-
 
835
		model.addAttribute("pendingOrderItems", pendingOrderItems);
-
 
836
		model.addAttribute("itemMap", itemMap);
-
 
837
		model.addAttribute("inventoryMap", inventoryMap);
-
 
838
		return "pending-order-item";
-
 
839
	}
769
}
840
}