Subversion Repositories SmartDukaan

Rev

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

Rev 23857 Rev 23891
Line 886... Line 886...
886
		}
886
		}
887
	}
887
	}
888
 
888
 
889
	@Override
889
	@Override
890
	public Map<String, Object> getSaleHistory(int fofoId, SearchType searchType, String searchValue,
890
	public Map<String, Object> getSaleHistory(int fofoId, SearchType searchType, String searchValue,
891
			String startTimeString, String endTimeString, int offset, int limit) throws ProfitMandiBusinessException {
891
			LocalDateTime startDate, LocalDateTime endDate, int offset, int limit) throws ProfitMandiBusinessException {
892
		LocalDateTime startDateTime = StringUtils.toDateTime(startTimeString);
-
 
893
		LocalDateTime endDateTime = StringUtils.toDateTime(endTimeString);
-
 
894
		long countItems = 0;
892
		long countItems = 0;
895
		List<FofoOrder> fofoOrders = new ArrayList<>();
893
		List<FofoOrder> fofoOrders = new ArrayList<>();
896
 
894
 
897
		if (searchType == SearchType.CUSTOMER_MOBILE_NUMBER && !searchValue.isEmpty()) {
895
		if (searchType == SearchType.CUSTOMER_MOBILE_NUMBER && !searchValue.isEmpty()) {
898
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerMobileNumber(fofoId, searchValue, startDateTime,
896
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerMobileNumber(fofoId, searchValue, startDate,
899
					endDateTime, offset, limit);
897
					endDate, offset, limit);
900
			countItems = fofoOrderRepository.selectCountByCustomerMobileNumber(fofoId, searchValue, startDateTime,
898
			countItems = fofoOrderRepository.selectCountByCustomerMobileNumber(fofoId, searchValue, startDate,
901
					endDateTime);
899
					endDate);
902
		} else if (searchType == SearchType.CUSTOMER_NAME && !searchValue.isEmpty()) {
900
		} else if (searchType == SearchType.CUSTOMER_NAME && !searchValue.isEmpty()) {
903
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerName(fofoId, searchValue, startDateTime,
901
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerName(fofoId, searchValue, startDate,
904
					endDateTime, offset, limit);
902
					endDate, offset, limit);
905
			countItems = fofoOrderRepository.selectCountByCustomerName(fofoId, searchValue, startDateTime, endDateTime);
903
			countItems = fofoOrderRepository.selectCountByCustomerName(fofoId, searchValue, startDate, endDate);
906
		} else if (searchType == SearchType.IMEI && !searchValue.isEmpty()) {
904
		} else if (searchType == SearchType.IMEI && !searchValue.isEmpty()) {
907
			fofoOrders = fofoOrderRepository.selectByFofoIdAndSerialNumber(fofoId, searchValue, startDateTime,
905
			fofoOrders = fofoOrderRepository.selectByFofoIdAndSerialNumber(fofoId, searchValue, startDate,
908
					endDateTime, offset, limit);
906
					endDate, offset, limit);
909
			countItems = fofoOrderRepository.selectCountBySerialNumber(fofoId, searchValue, startDateTime, endDateTime);
907
			countItems = fofoOrderRepository.selectCountBySerialNumber(fofoId, searchValue, startDate, endDate);
910
		} else if (searchType == SearchType.ITEM_NAME && !searchValue.isEmpty()) {
908
		} else if (searchType == SearchType.ITEM_NAME && !searchValue.isEmpty()) {
911
			fofoOrders = fofoOrderRepository.selectByFofoIdAndItemName(fofoId, searchValue, startDateTime, endDateTime,
909
			fofoOrders = fofoOrderRepository.selectByFofoIdAndItemName(fofoId, searchValue, startDate, endDate,
912
					offset, limit);
910
					offset, limit);
913
			countItems = fofoOrderRepository.selectCountByItemName(fofoId, searchValue, startDateTime, endDateTime);
911
			countItems = fofoOrderRepository.selectCountByItemName(fofoId, searchValue, startDate, endDate);
914
		} else {
912
		} else {
915
			fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startDateTime, endDateTime, offset, limit);
913
			fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startDate, endDate, offset, limit);
916
			countItems = fofoOrderRepository.selectCountByFofoId(fofoId, startDateTime, endDateTime);
914
			countItems = fofoOrderRepository.selectCountByFofoId(fofoId, startDate, endDate);
917
		}
915
		}
918
		Map<String, Object> map = new HashMap<>();
916
		Map<String, Object> map = new HashMap<>();
919
 
917
 
920
		map.put("saleHistories", fofoOrders);
918
		map.put("saleHistories", fofoOrders);
921
		map.put("start", offset + 1);
919
		map.put("start", offset + 1);
922
		map.put("size", countItems);
920
		map.put("size", countItems);
923
		map.put("searchType", searchType);
921
		map.put("searchType", searchType);
924
		map.put("searchTypes", SearchType.values());
922
		map.put("searchTypes", SearchType.values());
925
		map.put(ProfitMandiConstants.START_TIME, startTimeString);
923
		map.put("startDate", startDate);
926
		map.put(ProfitMandiConstants.END_TIME, endTimeString);
924
		map.put(ProfitMandiConstants.END_TIME, endDate);
927
		if (fofoOrders.size() < limit) {
925
		if (fofoOrders.size() < limit) {
928
			map.put("end", offset + fofoOrders.size());
926
			map.put("end", offset + fofoOrders.size());
929
		} else {
927
		} else {
930
			map.put("end", offset + limit);
928
			map.put("end", offset + limit);
931
		}
929
		}
932
		return map;
930
		return map;
933
	}
931
	}
934
 
932
 
935
	@Override
933
	@Override
936
	public Map<String, Object> getSaleHistoryPaginated(int fofoId, SearchType searchType, String searchValue,
934
	public Map<String, Object> getSaleHistoryPaginated(int fofoId, SearchType searchType, String searchValue,
937
			String startTimeString, String endTimeString, int offset, int limit) throws ProfitMandiBusinessException {
935
			LocalDateTime startDate, LocalDateTime endDate, int offset, int limit) throws ProfitMandiBusinessException {
938
		LocalDateTime startDateTime = StringUtils.toDateTime(startTimeString);
-
 
939
		LocalDateTime endDateTime = StringUtils.toDateTime(endTimeString);
-
 
940
		List<FofoOrder> fofoOrders = new ArrayList<>();
936
		List<FofoOrder> fofoOrders = new ArrayList<>();
941
 
937
 
942
		if (searchType == SearchType.CUSTOMER_MOBILE_NUMBER && !searchValue.isEmpty()) {
938
		if (searchType == SearchType.CUSTOMER_MOBILE_NUMBER && !searchValue.isEmpty()) {
943
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerMobileNumber(fofoId, searchValue, startDateTime,
939
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerMobileNumber(fofoId, searchValue, startDate,
944
					endDateTime, offset, limit);
940
					endDate, offset, limit);
945
		} else if (searchType == SearchType.CUSTOMER_NAME && !searchValue.isEmpty()) {
941
		} else if (searchType == SearchType.CUSTOMER_NAME && !searchValue.isEmpty()) {
946
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerName(fofoId, searchValue, startDateTime,
942
			fofoOrders = fofoOrderRepository.selectByFofoIdAndCustomerName(fofoId, searchValue, startDate,
947
					endDateTime, offset, limit);
943
					endDate, offset, limit);
948
		} else if (searchType == SearchType.IMEI && !searchValue.isEmpty()) {
944
		} else if (searchType == SearchType.IMEI && !searchValue.isEmpty()) {
949
			fofoOrders = fofoOrderRepository.selectByFofoIdAndSerialNumber(fofoId, searchValue, startDateTime,
945
			fofoOrders = fofoOrderRepository.selectByFofoIdAndSerialNumber(fofoId, searchValue, startDate,
950
					endDateTime, offset, limit);
946
					endDate, offset, limit);
951
		} else if (searchType == SearchType.ITEM_NAME && !searchValue.isEmpty()) {
947
		} else if (searchType == SearchType.ITEM_NAME && !searchValue.isEmpty()) {
952
			fofoOrders = fofoOrderRepository.selectByFofoIdAndItemName(fofoId, searchValue, startDateTime, endDateTime,
948
			fofoOrders = fofoOrderRepository.selectByFofoIdAndItemName(fofoId, searchValue, startDate, endDate,
953
					offset, limit);
949
					offset, limit);
954
		} else {
950
		} else {
955
			fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startDateTime, endDateTime, offset, limit);
951
			fofoOrders = fofoOrderRepository.selectByFofoId(fofoId, startDate, endDate, offset, limit);
956
		}
952
		}
957
		Map<String, Object> map = new HashMap<>();
953
		Map<String, Object> map = new HashMap<>();
958
 
954
 
959
		map.put("saleHistories", fofoOrders);
955
		map.put("saleHistories", fofoOrders);
960
		return map;
956
		return map;