Subversion Repositories SmartDukaan

Rev

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

Rev 23968 Rev 23973
Line 891... Line 891...
891
			LocalDateTime startDate, LocalDateTime endDate, int offset, int limit) throws ProfitMandiBusinessException {
891
			LocalDateTime startDate, LocalDateTime endDate, int offset, int limit) throws ProfitMandiBusinessException {
892
		long countItems = 0;
892
		long countItems = 0;
893
		List<FofoOrder> fofoOrders = new ArrayList<>();
893
		List<FofoOrder> fofoOrders = new ArrayList<>();
894
 
894
 
895
		if (searchType == SearchType.CUSTOMER_MOBILE_NUMBER && !searchValue.isEmpty()) {
895
		if (searchType == SearchType.CUSTOMER_MOBILE_NUMBER && !searchValue.isEmpty()) {
896
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerMobileNumber(fofoId, searchValue, startDate,
896
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerMobileNumber(fofoId, searchValue, null,
897
					endDate, offset, limit);
897
					null, offset, limit);
898
			countItems = fofoOrderRepository.selectCountByCustomerMobileNumber(fofoId, searchValue, startDate,
898
			countItems = fofoOrderRepository.selectCountByCustomerMobileNumber(fofoId, searchValue, null,
899
					endDate);
899
					null);
900
		} else if (searchType == SearchType.CUSTOMER_NAME && !searchValue.isEmpty()) {
900
		} else if (searchType == SearchType.CUSTOMER_NAME && !searchValue.isEmpty()) {
901
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerName(fofoId, searchValue, startDate,
901
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerName(fofoId, searchValue, null,
902
					endDate, offset, limit);
902
					null, offset, limit);
903
			countItems = fofoOrderRepository.selectCountByCustomerName(fofoId, searchValue, startDate, endDate);
903
			countItems = fofoOrderRepository.selectCountByCustomerName(fofoId, searchValue, null, null);
904
		} else if (searchType == SearchType.IMEI && !searchValue.isEmpty()) {
904
		} else if (searchType == SearchType.IMEI && !searchValue.isEmpty()) {
905
			fofoOrders = fofoOrderRepository.selectByFofoIdAndSerialNumber(fofoId, searchValue, startDate,
905
			fofoOrders = fofoOrderRepository.selectByFofoIdAndSerialNumber(fofoId, searchValue, null,
906
					endDate, offset, limit);
906
					null, offset, limit);
907
			countItems = fofoOrderRepository.selectCountBySerialNumber(fofoId, searchValue, startDate, endDate);
907
			countItems = fofoOrderRepository.selectCountBySerialNumber(fofoId, searchValue, null, null);
908
		} else if (searchType == SearchType.ITEM_NAME && !searchValue.isEmpty()) {
908
		} else if (searchType == SearchType.ITEM_NAME && !searchValue.isEmpty()) {
909
			fofoOrders = fofoOrderRepository.selectByFofoIdAndItemName(fofoId, searchValue, startDate, endDate,
909
			fofoOrders = fofoOrderRepository.selectByFofoIdAndItemName(fofoId, searchValue, null, null,
910
					offset, limit);
910
					offset, limit);
-
 
911
			countItems=fofoOrderRepository.selectCountByItemName(fofoId, searchValue, null, null);
911
		} else if (searchType == SearchType.INVOICE_NUMBER && !searchValue.isEmpty()) {
912
		} else if (searchType == SearchType.INVOICE_NUMBER && !searchValue.isEmpty()) {
912
			fofoOrders = Arrays.asList(fofoOrderRepository.selectByFofoIdAndInvoiceNumber(fofoId, searchValue));
913
			fofoOrders = Arrays.asList(fofoOrderRepository.selectByFofoIdAndInvoiceNumber(fofoId, searchValue));
913
			countItems = fofoOrders.size();
914
			countItems = fofoOrders.size();
914
		} else {
915
		}  else if(searchType == SearchType.DATE_RANGE){
915
			fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startDate, endDate, offset, limit);
916
			fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startDate, endDate, offset, limit);
916
			countItems = fofoOrderRepository.selectCountByFofoId(fofoId, startDate, endDate);
917
			countItems = fofoOrderRepository.selectCountByFofoId(fofoId, startDate, endDate);
917
		}
918
		}
918
		Map<String, Object> map = new HashMap<>();
919
		Map<String, Object> map = new HashMap<>();
919
 
920
 
Line 921... Line 922...
921
		map.put("start", offset + 1);
922
		map.put("start", offset + 1);
922
		map.put("size", countItems);
923
		map.put("size", countItems);
923
		map.put("searchType", searchType);
924
		map.put("searchType", searchType);
924
		map.put("searchTypes", SearchType.values());
925
		map.put("searchTypes", SearchType.values());
925
		map.put("startDate", startDate);
926
		map.put("startDate", startDate);
-
 
927
		map.put("searchValue", searchValue);
926
		map.put(ProfitMandiConstants.END_TIME, endDate);
928
		map.put(ProfitMandiConstants.END_TIME, endDate);
927
		if (fofoOrders.size() < limit) {
929
		if (fofoOrders.size() < limit) {
928
			map.put("end", offset + fofoOrders.size());
930
			map.put("end", offset + fofoOrders.size());
929
		} else {
931
		} else {
930
			map.put("end", offset + limit);
932
			map.put("end", offset + limit);
Line 947... Line 949...
947
			fofoOrders = fofoOrderRepository.selectByFofoIdAndSerialNumber(fofoId, searchValue, startDate,
949
			fofoOrders = fofoOrderRepository.selectByFofoIdAndSerialNumber(fofoId, searchValue, startDate,
948
					endDate, offset, limit);
950
					endDate, offset, limit);
949
		} else if (searchType == SearchType.ITEM_NAME && !searchValue.isEmpty()) {
951
		} else if (searchType == SearchType.ITEM_NAME && !searchValue.isEmpty()) {
950
			fofoOrders = fofoOrderRepository.selectByFofoIdAndItemName(fofoId, searchValue, startDate, endDate,
952
			fofoOrders = fofoOrderRepository.selectByFofoIdAndItemName(fofoId, searchValue, startDate, endDate,
951
					offset, limit);
953
					offset, limit);
952
		} else {
954
			
-
 
955
		}  else if (searchType == SearchType.DATE_RANGE){
953
			fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startDate, endDate, offset, limit);
956
			fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startDate, endDate, offset, limit);
954
		}
957
		}
955
		Map<String, Object> map = new HashMap<>();
958
		Map<String, Object> map = new HashMap<>();
956
 
-
 
957
		map.put("saleHistories", fofoOrders);
959
		map.put("saleHistories", fofoOrders);
-
 
960
		map.put("searchType", searchType);
-
 
961
		map.put("searchTypes", SearchType.values());
-
 
962
		map.put("startDate", startDate);
-
 
963
		map.put("searchValue", searchValue);
-
 
964
		map.put(ProfitMandiConstants.END_TIME, endDate);
958
		return map;
965
		return map;
959
	}
966
	}
960
 
967
 
961
	private String getFofoStoreCode(int fofoId) throws ProfitMandiBusinessException {
968
	private String getFofoStoreCode(int fofoId) throws ProfitMandiBusinessException {
962
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
969
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);