| Line 3... |
Line 3... |
| 3 |
import com.google.gson.Gson;
|
3 |
import com.google.gson.Gson;
|
| 4 |
import com.smartdukaan.cron.scheduled.OppoImeiActivationService;
|
4 |
import com.smartdukaan.cron.scheduled.OppoImeiActivationService;
|
| 5 |
import com.smartdukaan.cron.scheduled.SamsungIMEIActivationService;
|
5 |
import com.smartdukaan.cron.scheduled.SamsungIMEIActivationService;
|
| 6 |
import com.smartdukaan.cron.scheduled.ScheduledTasks;
|
6 |
import com.smartdukaan.cron.scheduled.ScheduledTasks;
|
| 7 |
import com.smartdukaan.cron.scheduled.amazon.shop.AmazonPurchaseService;
|
7 |
import com.smartdukaan.cron.scheduled.amazon.shop.AmazonPurchaseService;
|
| - |
|
8 |
import com.smartdukaan.cron.scheduled.amazon.shop.OrderSummary;
|
| - |
|
9 |
import com.smartdukaan.cron.scheduled.amazon.shop.model.OrderRow;
|
| 8 |
import com.spice.profitmandi.common.enumuration.ItemType;
|
10 |
import com.spice.profitmandi.common.enumuration.ItemType;
|
| 9 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
11 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 10 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
12 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 11 |
import com.spice.profitmandi.common.model.ImeiDropSummaryModel;
|
13 |
import com.spice.profitmandi.common.model.ImeiDropSummaryModel;
|
| 12 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
14 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| Line 81... |
Line 83... |
| 81 |
import org.apache.commons.csv.CSVRecord;
|
83 |
import org.apache.commons.csv.CSVRecord;
|
| 82 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
84 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 83 |
import org.apache.commons.lang.StringUtils;
|
85 |
import org.apache.commons.lang.StringUtils;
|
| 84 |
import org.apache.logging.log4j.LogManager;
|
86 |
import org.apache.logging.log4j.LogManager;
|
| 85 |
import org.apache.logging.log4j.Logger;
|
87 |
import org.apache.logging.log4j.Logger;
|
| - |
|
88 |
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
| - |
|
89 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
| - |
|
90 |
import org.apache.poi.ss.usermodel.CellType;
|
| - |
|
91 |
import org.apache.poi.ss.usermodel.DataFormatter;
|
| - |
|
92 |
import org.apache.poi.xssf.usermodel.XSSFCell;
|
| - |
|
93 |
import org.apache.poi.xssf.usermodel.XSSFRow;
|
| - |
|
94 |
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
| - |
|
95 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| 86 |
import org.json.JSONArray;
|
96 |
import org.json.JSONArray;
|
| 87 |
import org.json.JSONObject;
|
97 |
import org.json.JSONObject;
|
| 88 |
import org.openqa.selenium.Dimension;
|
98 |
import org.openqa.selenium.Dimension;
|
| 89 |
import org.openqa.selenium.OutputType;
|
99 |
import org.openqa.selenium.OutputType;
|
| 90 |
import org.openqa.selenium.TakesScreenshot;
|
100 |
import org.openqa.selenium.TakesScreenshot;
|
| Line 887... |
Line 897... |
| 887 |
}
|
897 |
}
|
| 888 |
|
898 |
|
| 889 |
@Autowired
|
899 |
@Autowired
|
| 890 |
AmazonPurchaseService amazonPurchaseService;
|
900 |
AmazonPurchaseService amazonPurchaseService;
|
| 891 |
|
901 |
|
| - |
|
902 |
private static DataFormatter formatter = new DataFormatter();
|
| - |
|
903 |
|
| 892 |
@Autowired
|
904 |
@Autowired
|
| 893 |
OfferTargetSlabRepository offerTargetSlabRepository;
|
905 |
OfferTargetSlabRepository offerTargetSlabRepository;
|
| 894 |
|
906 |
|
| 895 |
public void amazonPurchase() throws Exception {
|
907 |
public void amazonPurchase() throws Exception {
|
| - |
|
908 |
//Read file
|
| - |
|
909 |
FileInputStream fis = new FileInputStream(new File("/Users/amit/Downloads/amazon.xlsx"));
|
| - |
|
910 |
//creating workbook instance that refers to .xls file
|
| - |
|
911 |
XSSFWorkbook wb = new XSSFWorkbook(fis);
|
| - |
|
912 |
//creating a Sheet object to retrieve the object
|
| - |
|
913 |
XSSFSheet sheet = wb.getSheetAt(0);
|
| - |
|
914 |
|
| - |
|
915 |
OrderSummary orderSummary = this.getOrderSummary(sheet);
|
| - |
|
916 |
List<OrderRow> orderRows = new ArrayList<>();
|
| - |
|
917 |
int rows = sheet.getLastRowNum();
|
| - |
|
918 |
for (int rowNum = 3; rowNum < rows; rowNum++) {
|
| - |
|
919 |
try {
|
| - |
|
920 |
OrderRow orderRow = parseRow(orderSummary, sheet.getRow(rowNum));
|
| - |
|
921 |
orderRows.add(orderRow);
|
| - |
|
922 |
} catch (RuntimeException re) {
|
| - |
|
923 |
System.out.println("Could not parse rownum - " + rowNum);
|
| - |
|
924 |
}
|
| - |
|
925 |
}
|
| 896 |
amazonPurchaseService.purchaseAmazon("B085M5R82K", 10, 3999);
|
926 |
amazonPurchaseService.purchaseAmazon(orderSummary, orderRows);
|
| - |
|
927 |
}
|
| - |
|
928 |
|
| - |
|
929 |
private OrderSummary getOrderSummary(XSSFSheet sheet) {
|
| - |
|
930 |
XSSFRow firstRow = sheet.getRow(0);
|
| - |
|
931 |
String asin = firstRow.getCell(1).getStringCellValue();
|
| - |
|
932 |
int purchasePrice = (int) firstRow.getCell(3).getNumericCellValue();
|
| - |
|
933 |
int qtyPerOrder = (int) firstRow.getCell(5).getNumericCellValue();
|
| - |
|
934 |
boolean gst = Boolean.parseBoolean(getCellString(firstRow.getCell(7)));
|
| - |
|
935 |
XSSFRow secondRow = sheet.getRow(1);
|
| - |
|
936 |
boolean prepaid = Boolean.parseBoolean(getCellString(secondRow.getCell(1)));
|
| - |
|
937 |
boolean noCostEmi = Boolean.parseBoolean(getCellString(secondRow.getCell(3)));
|
| - |
|
938 |
OrderSummary orderSummary = new OrderSummary();
|
| - |
|
939 |
orderSummary.setAsin(asin);
|
| - |
|
940 |
orderSummary.setGst(gst);
|
| - |
|
941 |
orderSummary.setQtyPerOrder(qtyPerOrder);
|
| - |
|
942 |
orderSummary.setPrepaid(prepaid);
|
| - |
|
943 |
orderSummary.setNoCostEmi(noCostEmi);
|
| - |
|
944 |
return orderSummary;
|
| - |
|
945 |
}
|
| - |
|
946 |
|
| - |
|
947 |
private static String getCellString(XSSFCell xssfCell) {
|
| - |
|
948 |
xssfCell.setCellType(CellType.STRING);
|
| - |
|
949 |
return xssfCell.getStringCellValue();
|
| - |
|
950 |
}
|
| - |
|
951 |
|
| - |
|
952 |
private OrderRow parseRow(OrderSummary orderSummary, XSSFRow row) {
|
| - |
|
953 |
int col = 0;
|
| - |
|
954 |
OrderRow orderRow = new OrderRow();
|
| - |
|
955 |
String userName = getCellString(row.getCell(col++));
|
| - |
|
956 |
String password = getCellString(row.getCell(col++));
|
| - |
|
957 |
orderRow.setUserName(userName);
|
| - |
|
958 |
orderRow.setPassword(password);
|
| - |
|
959 |
|
| - |
|
960 |
if (orderSummary.isPrepaid()) {
|
| - |
|
961 |
String cardName = getCellString(row.getCell(col++));
|
| - |
|
962 |
String cardNumber = getCellString(row.getCell(col++));
|
| - |
|
963 |
String cardExpiryYr = getCellString(row.getCell(col++));
|
| - |
|
964 |
String cardExpiryMonth = getCellString(row.getCell(col++));
|
| - |
|
965 |
String cvv = getCellString(row.getCell(col++));
|
| - |
|
966 |
String verificationPin = getCellString(row.getCell(col++));
|
| - |
|
967 |
boolean orderPlaced = getCellString(row.getCell(col++)).equals("1") ? true : false;
|
| - |
|
968 |
orderRow.setCardNumber(cardNumber);
|
| - |
|
969 |
orderRow.setCvv( StringUtils.repeat("0",3 - cvv.length()) + cvv);
|
| - |
|
970 |
orderRow.setCardName(cardName);
|
| - |
|
971 |
orderRow.setExpiryYr(cardExpiryYr);
|
| - |
|
972 |
orderRow.setExpiryMonth(cardExpiryMonth);
|
| - |
|
973 |
orderRow.setVerificationPin(verificationPin);
|
| - |
|
974 |
orderRow.setOrderPlaced(orderPlaced);
|
| - |
|
975 |
}
|
| - |
|
976 |
return orderRow;
|
| 897 |
}
|
977 |
}
|
| 898 |
|
978 |
|
| 899 |
@Autowired
|
979 |
@Autowired
|
| 900 |
ItemCriteriaRepository itemCriteriaRepository;
|
980 |
ItemCriteriaRepository itemCriteriaRepository;
|
| 901 |
|
981 |
|
| Line 1592... |
Line 1672... |
| 1592 |
YearMonth currentMonth = YearMonth.from(currentDate);
|
1672 |
YearMonth currentMonth = YearMonth.from(currentDate);
|
| 1593 |
List<LocalDate> dates = new ArrayList<>();
|
1673 |
List<LocalDate> dates = new ArrayList<>();
|
| 1594 |
for (int i = 1; i < currentDate.getDayOfMonth(); i++) {
|
1674 |
for (int i = 1; i < currentDate.getDayOfMonth(); i++) {
|
| 1595 |
LocalDate date = currentMonth.atDay(i);
|
1675 |
LocalDate date = currentMonth.atDay(i);
|
| 1596 |
boolean exists = partnerDailyInvestmentRepository.isDateExist(date);
|
1676 |
boolean exists = partnerDailyInvestmentRepository.isDateExist(date);
|
| 1597 |
if(!exists) {
|
1677 |
if (!exists) {
|
| 1598 |
dates.add(date);
|
1678 |
dates.add(date);
|
| 1599 |
}
|
1679 |
}
|
| 1600 |
}
|
1680 |
}
|
| 1601 |
for (LocalDate date : dates) {
|
1681 |
for (LocalDate date : dates) {
|
| 1602 |
LOGGER.info("Date - {}", date);
|
1682 |
LOGGER.info("Date - {}", date);
|
| Line 1885... |
Line 1965... |
| 1885 |
UserWalletHistory userWalletHistory = userWalletHistories.get(0);
|
1965 |
UserWalletHistory userWalletHistory = userWalletHistories.get(0);
|
| 1886 |
walletService.addAmountToWallet(insurancePolicy.getRetailerId(), userWalletHistory.getReference(), WalletReferenceType.DAMAGE_PROTECTION, "Excess deduction - settled", 198, LocalDateTime.now());
|
1966 |
walletService.addAmountToWallet(insurancePolicy.getRetailerId(), userWalletHistory.getReference(), WalletReferenceType.DAMAGE_PROTECTION, "Excess deduction - settled", 198, LocalDateTime.now());
|
| 1887 |
}
|
1967 |
}
|
| 1888 |
}
|
1968 |
}
|
| 1889 |
}
|
1969 |
}
|
| 1890 |
|
- |
|
| 1891 |
|
- |
|
| 1892 |
}
|
1970 |
}
|
| 1893 |
|
1971 |
|
| 1894 |
//7015845171
|
1972 |
//7015845171
|
| 1895 |
|
1973 |
|