Subversion Repositories SmartDukaan

Rev

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

Rev 27253 Rev 27271
Line 4... Line 4...
4
import java.io.Serializable;
4
import java.io.Serializable;
5
import java.sql.Timestamp;
5
import java.sql.Timestamp;
6
import java.time.LocalDate;
6
import java.time.LocalDate;
7
import java.time.LocalDateTime;
7
import java.time.LocalDateTime;
8
import java.time.LocalTime;
8
import java.time.LocalTime;
-
 
9
import java.time.Month;
9
import java.time.format.DateTimeFormatter;
10
import java.time.format.DateTimeFormatter;
10
import java.time.temporal.ChronoUnit;
11
import java.time.temporal.ChronoUnit;
11
import java.util.ArrayList;
12
import java.util.ArrayList;
12
import java.util.Arrays;
13
import java.util.Arrays;
13
import java.util.Collections;
14
import java.util.Collections;
Line 74... Line 75...
74
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
75
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
75
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
76
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
76
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
77
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
77
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
78
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
78
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
79
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
-
 
80
import com.spice.profitmandi.dao.entity.dtr.User;
79
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
81
import com.spice.profitmandi.dao.entity.fofo.ActivityType;
80
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
82
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
81
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
83
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
82
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
84
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
83
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
85
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
Line 668... Line 670...
668
			}
670
			}
669
		} catch (Exception e) {
671
		} catch (Exception e) {
670
			e.printStackTrace();
672
			e.printStackTrace();
671
			throw e;
673
			throw e;
672
		}
674
		}
673
		List<UserWalletHistory> uwhs = userWalletHistoryRepository.selectAllByDateType(startDate, endDate,
675
		List<UserWalletHistory> uwhs = userWalletHistoryRepository.selectAllByDateType(LocalDate.now().atStartOfDay(), endDate,
674
				Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
676
				Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
675
		System.out.println("Amount\tReference\tReferenceType\tTimestamp\tDescription");
677
		System.out.println("Amount\tReference\tReferenceType\tTimestamp\tDescription");
676
		for (UserWalletHistory uwh : uwhs) {
678
		for (UserWalletHistory uwh : uwhs) {
677
			System.out.println(String.format("%d\t%d\t%s\t%s\t%s", uwh.getAmount(), uwh.getReference(),
679
			System.out.println(String.format("%d\t%d\t%s\t%s\t%s", uwh.getAmount(), uwh.getReference(),
678
					uwh.getReferenceType(), uwh.getTimestamp().toString(), uwh.getDescription()));
680
					uwh.getReferenceType(), uwh.getTimestamp().toString(), uwh.getDescription()));
Line 2134... Line 2136...
2134
							emailRowsMap.put(y.getKey(), new ArrayList<>());
2136
							emailRowsMap.put(y.getKey(), new ArrayList<>());
2135
						}
2137
						}
2136
						List<List<? extends Serializable>> fms = x.getValue().stream()
2138
						List<List<? extends Serializable>> fms = x.getValue().stream()
2137
								.map(r -> Arrays.asList(r.getStoreCode(), r.getStoreName(), r.getBrandName(),
2139
								.map(r -> Arrays.asList(r.getStoreCode(), r.getStoreName(), r.getBrandName(),
2138
										r.getModelName(), r.getModelNumber(), r.getWarehouseName(), r.getStateManager(),
2140
										r.getModelName(), r.getModelNumber(), r.getWarehouseName(), r.getStateManager(),
2139
										r.getTerritoryManager(), r.getShortageQty(), r.getAvailabitiy(),
2141
										r.getTerritoryManager(), r.getShortageQty(), r.getAvailabitiy()))
2140
										r.getPoAvailabitiy()))
-
 
2141
								.collect(Collectors.toList());
2142
								.collect(Collectors.toList());
2142
						emailRowsMap.get(y.getKey()).addAll(fms);
2143
						emailRowsMap.get(y.getKey()).addAll(fms);
2143
 
2144
 
2144
					}
2145
					}
2145
 
2146
 
2146
				});
2147
				});
2147
 
2148
 
2148
			});
2149
			});
2149
 
2150
 
2150
			List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number",
2151
			List<String> headers = Arrays.asList("Store Code", "Store Name", "Brand", "Model Name", "Model Number",
2151
					"Warehouse Name", "State Manager", "Territory Manager", "Shortage Qty", "Availability",
2152
					"Warehouse Name", "State Manager", "Territory Manager", "Shortage Qty", "Availability");
2152
					"PO Availability");
-
 
2153
			emailRowsMap.entrySet().forEach(entry -> {
2153
			emailRowsMap.entrySet().forEach(entry -> {
2154
 
2154
 
2155
				ByteArrayOutputStream baos = null;
2155
				ByteArrayOutputStream baos = null;
2156
				try {
2156
				try {
2157
					baos = FileUtil.getCSVByteStream(headers, entry.getValue());
2157
					baos = FileUtil.getCSVByteStream(headers, entry.getValue());
Line 2371... Line 2371...
2371
		sb.append("</tbody></table></body></html>");
2371
		sb.append("</tbody></table></body></html>");
2372
 
2372
 
2373
		return sb.toString();
2373
		return sb.toString();
2374
	}
2374
	}
2375
 
2375
 
-
 
2376
	public void reverseWallet() throws Exception {
-
 
2377
		LocalDate localDate = LocalDate.of(2020, 10, 28);
-
 
2378
		List<UserWalletHistory> uwhList = userWalletHistoryRepository.selectAllByDateType(localDate.atStartOfDay(), localDate.plusDays(1).atStartOfDay(), 
-
 
2379
				Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
-
 
2380
		for (UserWalletHistory uwh : uwhList) {
-
 
2381
			if(uwh.getBusinessTimestamp().getMonth().equals(Month.SEPTEMBER)) {
-
 
2382
				LOGGER.info("UWH - {}", uwh);
-
 
2383
				//walletService.rollbackAmountFromWallet(uwh.getFofoId(), uwh.getAmount(), uwh.getReference(), uwh.getReferenceType(), "Margin reversal for error prone run", uwh.getBusinessTimestamp());
-
 
2384
			}
-
 
2385
		}
-
 
2386
		
-
 
2387
	}
-
 
2388
 
2376
}
2389
}