Subversion Repositories SmartDukaan

Rev

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

Rev 27819 Rev 27861
Line 42... Line 42...
42
import com.spice.profitmandi.common.model.CartFofo;
42
import com.spice.profitmandi.common.model.CartFofo;
43
import com.spice.profitmandi.common.model.CreateOrderRequest;
43
import com.spice.profitmandi.common.model.CreateOrderRequest;
44
import com.spice.profitmandi.common.model.CreditNotePdfModel;
44
import com.spice.profitmandi.common.model.CreditNotePdfModel;
45
import com.spice.profitmandi.common.model.CustomCustomer;
45
import com.spice.profitmandi.common.model.CustomCustomer;
46
import com.spice.profitmandi.common.model.CustomRetailer;
46
import com.spice.profitmandi.common.model.CustomRetailer;
-
 
47
import com.spice.profitmandi.common.model.FofoItemIdAmountModel;
47
import com.spice.profitmandi.common.model.FoiBadReturnRequest;
48
import com.spice.profitmandi.common.model.FoiBadReturnRequest;
-
 
49
import com.spice.profitmandi.common.model.PartnerOptionsAndItemAmountModel;
48
import com.spice.profitmandi.common.model.PaymentOptionTransactionModel;
50
import com.spice.profitmandi.common.model.PaymentOptionTransactionModel;
49
import com.spice.profitmandi.common.model.PdfModel;
51
import com.spice.profitmandi.common.model.PdfModel;
50
import com.spice.profitmandi.common.model.PriceModel;
52
import com.spice.profitmandi.common.model.PriceModel;
51
import com.spice.profitmandi.common.model.ProfitMandiConstants;
53
import com.spice.profitmandi.common.model.ProfitMandiConstants;
52
import com.spice.profitmandi.common.util.PdfUtils;
54
import com.spice.profitmandi.common.util.PdfUtils;
53
import com.spice.profitmandi.common.util.StringUtils;
55
import com.spice.profitmandi.common.util.StringUtils;
54
import com.spice.profitmandi.common.web.util.ResponseSender;
56
import com.spice.profitmandi.common.web.util.ResponseSender;
55
import com.spice.profitmandi.dao.entity.catalog.Item;
57
import com.spice.profitmandi.dao.entity.catalog.Item;
-
 
58
import com.spice.profitmandi.dao.entity.catalog.TagListing;
56
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
59
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
57
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
60
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
58
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
61
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
59
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
62
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
60
import com.spice.profitmandi.dao.entity.fofo.Customer;
63
import com.spice.profitmandi.dao.entity.fofo.Customer;
Line 69... Line 72...
69
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
72
import com.spice.profitmandi.dao.entity.fofo.PendingOrderItem;
70
import com.spice.profitmandi.dao.entity.user.Address;
73
import com.spice.profitmandi.dao.entity.user.Address;
71
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
74
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
72
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
75
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
73
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
76
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
-
 
77
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
74
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
78
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
75
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
79
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
76
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
80
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
77
import com.spice.profitmandi.dao.repository.dtr.PaymentOptionTransactionRepository;
81
import com.spice.profitmandi.dao.repository.dtr.PaymentOptionTransactionRepository;
78
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
82
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
Line 185... Line 189...
185
	private RetailerService retailerService;
189
	private RetailerService retailerService;
186
 
190
 
187
	@Autowired
191
	@Autowired
188
	private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
192
	private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
189
 
193
 
-
 
194
	@Autowired
-
 
195
	private TagListingRepository tagListingRepository;
-
 
196
 
190
	@RequestMapping(value = "/order")
197
	@RequestMapping(value = "/order")
191
	public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
198
	public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
192
			throws ProfitMandiBusinessException {
199
			throws ProfitMandiBusinessException {
193
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
200
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
194
		;
201
		;
Line 411... Line 418...
411
		List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
418
		List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
412
		Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
419
		Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
413
		CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
420
		CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
414
		List<Integer> fofoPartnerPaymentOptions = fofoPartnerPaymentOptionRepository
421
		List<Integer> fofoPartnerPaymentOptions = fofoPartnerPaymentOptionRepository
415
				.selectPaymentOptionIdsByFofoId(fofoOrder.getFofoId());
422
				.selectPaymentOptionIdsByFofoId(fofoOrder.getFofoId());
416
 
-
 
417
		Map<Integer, Item> itemsMap = fofoOrderItems.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> {
423
		Map<Integer, Item> itemsMap = fofoOrderItems.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> {
418
			try {
424
			try {
419
				return itemRepository.selectById(x.getItemId());
425
				return itemRepository.selectById(x.getItemId());
420
			} catch (ProfitMandiBusinessException e) {
426
			} catch (ProfitMandiBusinessException e) {
421
				// TODO Auto-generated catch block
427
				// TODO Auto-generated catch block
Line 684... Line 690...
684
	}
690
	}
685
 
691
 
686
	@PutMapping(value = "/updatePaymentTransaction")
692
	@PutMapping(value = "/updatePaymentTransaction")
687
	public String updateTransactionDetails(HttpServletRequest request, @RequestParam String referenceType,
693
	public String updateTransactionDetails(HttpServletRequest request, @RequestParam String referenceType,
688
			@RequestParam int fofoId, @RequestParam int referenceId,
694
			@RequestParam int fofoId, @RequestParam int referenceId,
689
			@RequestBody List<PaymentOptionTransactionModel> paymentOptionTransactionModels, Model model)
695
			@RequestBody PartnerOptionsAndItemAmountModel partnerOptionsAndItemAmountModel,
690
			throws Exception {
-
 
691
		float amount = 0;
-
 
692
		LOGGER.info(paymentOptionTransactionModels);
696
			@RequestParam int totalAmount, Model model) throws Exception {
693
 
697
 
694
		for (PaymentOptionTransactionModel paymentOptionTransactionModel : paymentOptionTransactionModels) {
698
		List<PaymentOptionTransactionModel> paymentOptionTransactionModels = partnerOptionsAndItemAmountModel
-
 
699
				.getPaymentOptionTransactionModel();
695
			amount = amount + paymentOptionTransactionModel.getAmount();
700
		LOGGER.info(paymentOptionTransactionModels);
696
		}
-
 
697
		FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoId, referenceId);
701
		FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoId, referenceId);
698
		LOGGER.info("FofoOrder amount" + fofoOrder.getTotalAmount() + "amount" + amount);
702
		LOGGER.info("sdssd" + fofoOrder);
699
		if (amount == fofoOrder.getTotalAmount()) {
703
		fofoOrder.setTotalAmount(totalAmount);
700
			if (paymentOptionTransactionModels.size() > 0) {
-
 
701
				List<PaymentOptionTransaction> paymentOptionTransactions = fofoOrderPaymentOptionRepository
704
		List<FofoItemIdAmountModel> fofoItemIdAmountModel = partnerOptionsAndItemAmountModel.getItemAmountModel();
702
						.selectByReferenceIdAndType(referenceId, PaymentOptionReferenceType.ORDER);
-
 
703
				Map<Integer, PaymentOptionTransaction> paymentOptionIdPaymentOptionTransactionMap = this
-
 
704
						.paymentOptionIdPaymentOptionTransactionMap(paymentOptionTransactions);
705
		for (FofoItemIdAmountModel fim : fofoItemIdAmountModel) {
705
				LOGGER.info("paymentOptionIdPaymentOptionTransactionMap"
706
			LOGGER.info("fim" + fim.getFofoItemId());
706
						+ paymentOptionIdPaymentOptionTransactionMap.keySet());
707
			Item item = itemRepository.selectById(fim.getItemId());
707
				for (PaymentOptionTransactionModel paymentOptionTransactionModel : paymentOptionTransactionModels) {
-
 
708
					if (paymentOptionIdPaymentOptionTransactionMap
-
 
709
							.containsKey(paymentOptionTransactionModel.getPaymentOptionId())) {
708
			TagListing tagListing = tagListingRepository.selectByItemId(item.getId());
710
 
-
 
711
						PaymentOptionTransaction paymentOptionTransaction = paymentOptionIdPaymentOptionTransactionMap
709
			FofoOrderItem fofoOrderItem = fofoOrderItemRepository.selectById(fim.getFofoItemId());
712
								.get(paymentOptionTransactionModel.getPaymentOptionId());
-
 
713
 
710
 
714
						if (paymentOptionTransactionModel.getAmount() == 0) {
711
			if (item.getCategoryId() == 10006) {
715
							fofoOrderPaymentOptionRepository.delete(paymentOptionTransaction);
712
				if (fofoOrderItem.getMop() >= fim.getAmount()) {
716
							LOGGER.info("deleted successfully");
-
 
717
						} else {
-
 
718
 
-
 
719
							paymentOptionTransaction.setAmount(paymentOptionTransactionModel.getAmount());
-
 
720
							fofoOrderPaymentOptionRepository.persist(paymentOptionTransaction);
-
 
721
							LOGGER.info("updated successfully");
-
 
722
 
713
 
-
 
714
					if (tagListing.getMrp() <= fim.getAmount() || tagListing.getMrp() == 0) {
723
						}
715
						fofoOrderItem.setSellingPrice(fim.getAmount());
724
					} else {
716
					} else {
725
						if (paymentOptionTransactionModel.getAmount() > 0) {
-
 
726
							PaymentOptionTransaction paymentOptionTransaction = new PaymentOptionTransaction();
-
 
727
							paymentOptionTransaction.setReferenceId(referenceId);
-
 
728
							paymentOptionTransaction.setReferenceType(PaymentOptionReferenceType.ORDER);
-
 
729
							paymentOptionTransaction
-
 
730
									.setPaymentOptionId(paymentOptionTransactionModel.getPaymentOptionId());
-
 
731
							paymentOptionTransaction.setAmount(paymentOptionTransactionModel.getAmount());
717
						throw new ProfitMandiBusinessException("Amount", fim.getAmount(),
732
							paymentOptionTransaction.setFofoId(fofoId);
718
								"Sum of amount is not less than  to MRP");
733
							paymentOptionTransaction.setCreateTimestamp(fofoOrder.getCreateTimestamp());
-
 
734
							fofoOrderPaymentOptionRepository.persist(paymentOptionTransaction);
-
 
735
							LOGGER.info("inserted successfully");
-
 
736
						}
-
 
737
					}
719
					}
738
 
720
 
-
 
721
					LOGGER.info("fofoOrderItem2" + fofoOrderItem);
-
 
722
 
739
				}
723
				}
740
 
724
 
-
 
725
			} else {
741
				model.addAttribute("response", mvcResponseSender.createResponseString(true));
726
				fofoOrderItem.setSellingPrice(fim.getAmount());
-
 
727
				LOGGER.info("fofoOrderItem1" + fofoOrderItem);
-
 
728
 
742
			}
729
			}
743
		} else {
-
 
744
			throw new ProfitMandiBusinessException("Amount", amount, "Sum of amount is not equal to total amount");
730
			LOGGER.info("fofoOrderItem" + fofoOrderItem);
-
 
731
 
745
		}
732
		}
746
 
733
 
-
 
734
		/*
-
 
735
		 * for (PaymentOptionTransactionModel paymentOptionTransactionModel :
-
 
736
		 * paymentOptionTransactionModels) { amount = amount +
-
 
737
		 * paymentOptionTransactionModel.getAmount(); } LOGGER.info("FofoOrder amount" +
-
 
738
		 * fofoOrder.getTotalAmount() + "amount" + amount); if (amount ==
-
 
739
		 * fofoOrder.getTotalAmount()) {
-
 
740
		 */
-
 
741
		if (paymentOptionTransactionModels.size() > 0) {
-
 
742
			List<PaymentOptionTransaction> paymentOptionTransactions = fofoOrderPaymentOptionRepository
-
 
743
					.selectByReferenceIdAndType(referenceId, PaymentOptionReferenceType.ORDER);
-
 
744
			Map<Integer, PaymentOptionTransaction> paymentOptionIdPaymentOptionTransactionMap = this
-
 
745
					.paymentOptionIdPaymentOptionTransactionMap(paymentOptionTransactions);
-
 
746
			LOGGER.info(
-
 
747
					"paymentOptionIdPaymentOptionTransactionMap" + paymentOptionIdPaymentOptionTransactionMap.keySet());
-
 
748
			for (PaymentOptionTransactionModel paymentOptionTransactionModel : paymentOptionTransactionModels) {
-
 
749
				if (paymentOptionIdPaymentOptionTransactionMap
-
 
750
						.containsKey(paymentOptionTransactionModel.getPaymentOptionId())) {
-
 
751
 
-
 
752
					PaymentOptionTransaction paymentOptionTransaction = paymentOptionIdPaymentOptionTransactionMap
-
 
753
							.get(paymentOptionTransactionModel.getPaymentOptionId());
-
 
754
 
-
 
755
					if (paymentOptionTransactionModel.getAmount() == 0) {
-
 
756
						fofoOrderPaymentOptionRepository.delete(paymentOptionTransaction);
-
 
757
						LOGGER.info("deleted successfully");
-
 
758
					} else {
-
 
759
 
-
 
760
						paymentOptionTransaction.setAmount(paymentOptionTransactionModel.getAmount());
-
 
761
						fofoOrderPaymentOptionRepository.persist(paymentOptionTransaction);
-
 
762
						LOGGER.info("updated successfully");
-
 
763
 
-
 
764
					}
-
 
765
				} else {
-
 
766
					if (paymentOptionTransactionModel.getAmount() > 0) {
-
 
767
						PaymentOptionTransaction paymentOptionTransaction = new PaymentOptionTransaction();
-
 
768
						paymentOptionTransaction.setReferenceId(referenceId);
-
 
769
						paymentOptionTransaction.setReferenceType(PaymentOptionReferenceType.ORDER);
-
 
770
						paymentOptionTransaction.setPaymentOptionId(paymentOptionTransactionModel.getPaymentOptionId());
-
 
771
						paymentOptionTransaction.setAmount(paymentOptionTransactionModel.getAmount());
-
 
772
						paymentOptionTransaction.setFofoId(fofoId);
-
 
773
						paymentOptionTransaction.setCreateTimestamp(fofoOrder.getCreateTimestamp());
-
 
774
						fofoOrderPaymentOptionRepository.persist(paymentOptionTransaction);
-
 
775
						LOGGER.info("inserted successfully");
-
 
776
					}
-
 
777
				}
-
 
778
 
-
 
779
			}
-
 
780
 
-
 
781
			model.addAttribute("response", mvcResponseSender.createResponseString(true));
-
 
782
		}
-
 
783
		/*
-
 
784
		 * else
-
 
785
		 * 
-
 
786
		 * { throw new ProfitMandiBusinessException("Amount", amount,
-
 
787
		 * "Sum of amount is not equal to total amount"); }
-
 
788
		 */
-
 
789
 
747
		return "response";
790
		return "response";
-
 
791
 
748
	}
792
	}
749
 
793
 
750
	private Map<String, List<MobileInsurancePlan>> getPlans(float sellingPrice, int itemId)
794
	private Map<String, List<MobileInsurancePlan>> getPlans(float sellingPrice, int itemId)
751
			throws ProfitMandiBusinessException {
795
			throws ProfitMandiBusinessException {
752
		try {
796
		try {