| Line 79... |
Line 79... |
| 79 |
fileToCreate = new File("/tmp/", this.orderDataFileName);
|
79 |
fileToCreate = new File("/tmp/", this.orderDataFileName);
|
| 80 |
FileUtils.copyFile(this.orderDataFile, fileToCreate);
|
80 |
FileUtils.copyFile(this.orderDataFile, fileToCreate);
|
| 81 |
} catch (Exception e) {
|
81 |
} catch (Exception e) {
|
| 82 |
logger.error("Error while writing order data file to the local file system for Ebay", e);
|
82 |
logger.error("Error while writing order data file to the local file system for Ebay", e);
|
| 83 |
addActionError("Error while writing order data file to the local file system");
|
83 |
addActionError("Error while writing order data file to the local file system");
|
| - |
|
84 |
setErrorMsg(getErrorMsg() + "Error in opening File for Order creation");
|
| 84 |
}
|
85 |
}
|
| 85 |
|
86 |
|
| 86 |
|
87 |
|
| 87 |
if(checkForErrors())
|
88 |
if(checkForErrors())
|
| 88 |
return "authsuccess";
|
89 |
return "authsuccess";
|
| Line 92... |
Line 93... |
| 92 |
try {
|
93 |
try {
|
| 93 |
wb = new HSSFWorkbook(new FileInputStream(fileToCreate));
|
94 |
wb = new HSSFWorkbook(new FileInputStream(fileToCreate));
|
| 94 |
} catch (Exception e) {
|
95 |
} catch (Exception e) {
|
| 95 |
logger.error("Unable to open the File for Order Creation for Ebay ", e);
|
96 |
logger.error("Unable to open the File for Order Creation for Ebay ", e);
|
| 96 |
addActionError("Unable to open the File for Order creation");
|
97 |
addActionError("Unable to open the File for Order creation");
|
| - |
|
98 |
setErrorMsg(getErrorMsg() + "Error in opening File for Order creation");
|
| 97 |
}
|
99 |
}
|
| 98 |
if(checkForErrors())
|
100 |
if(checkForErrors())
|
| 99 |
return "authsuccess";
|
101 |
return "authsuccess";
|
| 100 |
|
102 |
|
| 101 |
TransactionService.Client tsc = null;
|
103 |
TransactionService.Client tsc = null;
|
| 102 |
try {
|
104 |
try {
|
| 103 |
tsc = new TransactionClient().getClient();
|
105 |
tsc = new TransactionClient().getClient();
|
| 104 |
} catch (Exception e) {
|
106 |
} catch (Exception e) {
|
| 105 |
logger.error("Unable to establish connection to the transaction service", e);
|
107 |
logger.error("Unable to establish connection to the transaction service", e);
|
| 106 |
addActionError("Unable to establish connection to the transaction service");
|
108 |
addActionError("Unable to establish connection to the transaction service");
|
| - |
|
109 |
setErrorMsg(getErrorMsg() + "Error in connecting to Order Service");
|
| 107 |
}
|
110 |
}
|
| 108 |
|
111 |
|
| 109 |
if(checkForErrors())
|
112 |
if(checkForErrors())
|
| 110 |
return "authsuccess";
|
113 |
return "authsuccess";
|
| 111 |
|
114 |
|
| 112 |
if(checkForErrors())
|
115 |
if(checkForErrors())
|
| 113 |
return "authsuccess";
|
116 |
return "authsuccess";
|
| 114 |
|
117 |
|
| 115 |
Sheet sheet = wb.getSheetAt(0);
|
118 |
Sheet sheet = wb.getSheetAt(0);
|
| 116 |
Row firstRow = sheet.getRow(0);
|
119 |
Row firstRow = sheet.getRow(0);
|
| 117 |
logger.info("Last row number is:" + sheet.getLastRowNum());
|
- |
|
| 118 |
for (Row row : sheet) {
|
120 |
for (Row row : sheet) {
|
| 119 |
User user = null;
|
121 |
User user = null;
|
| - |
|
122 |
rowId++;
|
| 120 |
long orderCountForRow = 0;
|
123 |
long orderCountForRow = 0;
|
| 121 |
if(row.equals(firstRow))
|
124 |
if(row.equals(firstRow))
|
| 122 |
continue;
|
125 |
continue;
|
| 123 |
rowId++;
|
- |
|
| 124 |
|
126 |
try {
|
| 125 |
Order order = null;
|
127 |
Order order = null;
|
| 126 |
Transaction transaction = null;
|
128 |
Transaction transaction = null;
|
| 127 |
try {
|
129 |
try {
|
| 128 |
row.getCell(EBAY_LISTINGID_INDEX).setCellType(Cell.CELL_TYPE_STRING);
|
130 |
row.getCell(EBAY_LISTINGID_INDEX).setCellType(Cell.CELL_TYPE_STRING);
|
| 129 |
//EbayOrder ebayOrder = tsc.getEbayOrderBySalesRecNumber(new Double(row.getCell(SALES_RECORD_NUM_INDEX).getNumericCellValue()).longValue());
|
- |
|
| 130 |
EbayOrder ebayOrder = tsc.getEbayOrder(new Double(row.getCell(SALES_RECORD_NUM_INDEX).getNumericCellValue()).longValue(),
|
131 |
EbayOrder ebayOrder = tsc.getEbayOrder(new Double(row.getCell(SALES_RECORD_NUM_INDEX).getNumericCellValue()).longValue(),
|
| 131 |
row.getCell(EBAY_LISTINGID_INDEX).getStringCellValue(), null).get(0);
|
132 |
row.getCell(EBAY_LISTINGID_INDEX).getStringCellValue(), null).get(0);
|
| 132 |
row.getCell(TRANSACTION_ID_INDEX).setCellType(Cell.CELL_TYPE_STRING);
|
133 |
row.getCell(TRANSACTION_ID_INDEX).setCellType(Cell.CELL_TYPE_STRING);
|
| 133 |
ebayOrder.setTransactionId(row.getCell(TRANSACTION_ID_INDEX).getStringCellValue());
|
134 |
ebayOrder.setTransactionId(row.getCell(TRANSACTION_ID_INDEX).getStringCellValue());
|
| 134 |
tsc.updateEbayOrder(ebayOrder);
|
135 |
tsc.updateEbayOrder(ebayOrder);
|
| 135 |
order = tsc.getOrder(ebayOrder.getOrderId());
|
136 |
order = tsc.getOrder(ebayOrder.getOrderId());
|
| 136 |
transaction = tsc.getTransaction(order.getTransactionId());
|
137 |
transaction = tsc.getTransaction(order.getTransactionId());
|
| - |
|
138 |
} catch (Exception e) {
|
| - |
|
139 |
logger.error("Unable to get EbayOrder for row number " + rowId, e);
|
| - |
|
140 |
addActionError("Unable to get EbayOrder for row number " + rowId);
|
| - |
|
141 |
setErrorMsg(getErrorMsg() + "<br>Unable to get EbayOrder for row number " + rowId);
|
| - |
|
142 |
continue;
|
| - |
|
143 |
}
|
| - |
|
144 |
|
| - |
|
145 |
try {
|
| - |
|
146 |
in.shop2020.model.v1.user.UserContextService.Client userClient = new UserClient().getClient();
|
| - |
|
147 |
if (userClient.userExists(row.getCell(EMAIL_INDEX).getStringCellValue())) {
|
| - |
|
148 |
user = userClient.getUserByEmail(row.getCell(EMAIL_INDEX).getStringCellValue());
|
| - |
|
149 |
} else {
|
| - |
|
150 |
user = new User();
|
| - |
|
151 |
user.setName(row.getCell(BUYER_NAME_INDEX).getStringCellValue());
|
| - |
|
152 |
user.setEmail(row.getCell(EMAIL_INDEX).getStringCellValue());
|
| - |
|
153 |
//TODO set password for user;
|
| - |
|
154 |
user.setIsAnonymous(false);
|
| - |
|
155 |
user = userClient.createUser(user);
|
| - |
|
156 |
}
|
| - |
|
157 |
} catch (Exception e) {
|
| - |
|
158 |
logger.error("Unable to get or create user for row number " + rowId, e);
|
| - |
|
159 |
addActionError("Unable to get or create user for row number " + rowId);
|
| - |
|
160 |
setErrorMsg(getErrorMsg() + "<br>Unable to get or create user for row number " + rowId);
|
| - |
|
161 |
continue;
|
| - |
|
162 |
}
|
| - |
|
163 |
|
| - |
|
164 |
//TODO Shopping cart is not being set right now Will
|
| - |
|
165 |
transaction.setShoppingCartid(user.getActiveCartId());
|
| - |
|
166 |
transaction.setCustomer_id(user.getUserId());
|
| - |
|
167 |
transaction.setCreatedOn(new Date().getTime());
|
| - |
|
168 |
|
| - |
|
169 |
order.setCustomer_id(user.getUserId());
|
| - |
|
170 |
order.setCustomer_email(user.getEmail());
|
| - |
|
171 |
order.setCustomer_name(user.getName());
|
| - |
|
172 |
if (order.getCustomer_mobilenumber()== null || order.getCustomer_mobilenumber() == "") {
|
| - |
|
173 |
order.setCustomer_mobilenumber(user.getMobileNumber());
|
| - |
|
174 |
}
|
| - |
|
175 |
order.setCustomer_address1(row.getCell(ADDR1_INDEX).getStringCellValue());
|
| - |
|
176 |
Cell address2Cell = row.getCell(ADDR2_INDEX);
|
| - |
|
177 |
if(address2Cell != null && address2Cell.getCellType() != Cell.CELL_TYPE_BLANK) {
|
| - |
|
178 |
order.setCustomer_address2(row.getCell(ADDR2_INDEX).getStringCellValue());
|
| - |
|
179 |
}
|
| - |
|
180 |
order.setCustomer_city(row.getCell(CITY_INDEX).getStringCellValue());
|
| - |
|
181 |
order.setCustomer_state(row.getCell(STATE_INDEX).getStringCellValue());
|
| - |
|
182 |
row.getCell(PINCODE_INDEX).setCellType(Cell.CELL_TYPE_STRING);
|
| - |
|
183 |
order.setCustomer_pincode(row.getCell(PINCODE_INDEX).getStringCellValue());
|
| - |
|
184 |
|
| - |
|
185 |
order.setStatus(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| - |
|
186 |
order.setStatusDescription("IN Process");
|
| - |
|
187 |
order.setCreated_timestamp(new Date().getTime());
|
| - |
|
188 |
|
| - |
|
189 |
orderCountForRow++;
|
| - |
|
190 |
try {
|
| - |
|
191 |
updatePayment(transaction.getId());
|
| - |
|
192 |
} catch (Exception e) {
|
| - |
|
193 |
logger.error("Unable to update payment for row number " + rowId, e);
|
| - |
|
194 |
addActionError("Unable to update payment for row number " + rowId);
|
| - |
|
195 |
setErrorMsg(getErrorMsg() + "<br>Unable to update payment for row number " + rowId);
|
| - |
|
196 |
continue;
|
| - |
|
197 |
}
|
| - |
|
198 |
try {
|
| - |
|
199 |
tsc.updateOrderForEbay(order);
|
| - |
|
200 |
} catch (Exception e) {
|
| - |
|
201 |
logger.error("Unable to update Ebay Order for row number " + rowId, e);
|
| - |
|
202 |
addActionError("Unable to update Ebay Order for row number " + rowId);
|
| - |
|
203 |
setErrorMsg(getErrorMsg() + "<br>Unable to update Ebay Order for row number " + rowId);
|
| - |
|
204 |
continue;
|
| - |
|
205 |
}
|
| 137 |
} catch (Exception e) {
|
206 |
} catch (Exception e) {
|
| 138 |
logger.error("Unable to get EbayOrder for row number " + (rowId + 1), e);
|
207 |
logger.error("Unable to update Order for Ebay Order " + rowId, e);
|
| 139 |
addActionError("Unable to get EbayOrder for row number " + (rowId + 1));
|
208 |
addActionError("Unable to update Order for Ebay Order " + rowId);
|
| 140 |
return "authsuccess";
|
- |
|
| 141 |
}
|
- |
|
| 142 |
|
- |
|
| 143 |
try {
|
- |
|
| 144 |
in.shop2020.model.v1.user.UserContextService.Client userClient = new UserClient().getClient();
|
- |
|
| 145 |
if (userClient.userExists(row.getCell(EMAIL_INDEX).getStringCellValue())) {
|
- |
|
| 146 |
user = userClient.getUserByEmail(row.getCell(EMAIL_INDEX).getStringCellValue());
|
- |
|
| 147 |
} else {
|
- |
|
| 148 |
user = new User();
|
- |
|
| 149 |
user.setName(row.getCell(BUYER_NAME_INDEX).getStringCellValue());
|
- |
|
| 150 |
user.setEmail(row.getCell(EMAIL_INDEX).getStringCellValue());
|
- |
|
| 151 |
//TODO set password for user;
|
- |
|
| 152 |
user.setIsAnonymous(false);
|
- |
|
| 153 |
user = userClient.createUser(user);
|
- |
|
| 154 |
}
|
- |
|
| 155 |
} catch (Exception e) {
|
- |
|
| 156 |
logger.error("Unable to establish connection to the User service for row number " + (rowId + 1), e);
|
- |
|
| 157 |
addActionError("Unable to establish connection to the User servicefor row number " + (rowId + 1));
|
- |
|
| 158 |
return "authsuccess";
|
- |
|
| 159 |
}
|
- |
|
| 160 |
|
- |
|
| 161 |
//TODO Shopping cart is not being set right now Will
|
- |
|
| 162 |
transaction.setShoppingCartid(user.getActiveCartId());
|
- |
|
| 163 |
transaction.setCustomer_id(user.getUserId());
|
- |
|
| 164 |
transaction.setCreatedOn(new Date().getTime());
|
- |
|
| 165 |
|
- |
|
| 166 |
order.setCustomer_id(user.getUserId());
|
- |
|
| 167 |
order.setCustomer_email(user.getEmail());
|
- |
|
| 168 |
order.setCustomer_name(user.getName());
|
- |
|
| 169 |
if (order.getCustomer_mobilenumber()== null || order.getCustomer_mobilenumber() == "") {
|
- |
|
| 170 |
order.setCustomer_mobilenumber(user.getMobileNumber());
|
- |
|
| 171 |
}
|
- |
|
| 172 |
order.setCustomer_address1(row.getCell(ADDR1_INDEX).getStringCellValue());
|
- |
|
| 173 |
Cell address2Cell = row.getCell(ADDR2_INDEX);
|
- |
|
| 174 |
if(address2Cell != null && address2Cell.getCellType() != Cell.CELL_TYPE_BLANK) {
|
- |
|
| 175 |
order.setCustomer_address2(row.getCell(ADDR2_INDEX).getStringCellValue());
|
- |
|
| 176 |
}
|
- |
|
| 177 |
order.setCustomer_city(row.getCell(CITY_INDEX).getStringCellValue());
|
- |
|
| 178 |
order.setCustomer_state(row.getCell(STATE_INDEX).getStringCellValue());
|
- |
|
| 179 |
row.getCell(PINCODE_INDEX).setCellType(Cell.CELL_TYPE_STRING);
|
- |
|
| 180 |
order.setCustomer_pincode(row.getCell(PINCODE_INDEX).getStringCellValue());
|
- |
|
| 181 |
|
- |
|
| 182 |
order.setStatus(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
- |
|
| 183 |
order.setStatusDescription("IN Process");
|
- |
|
| 184 |
order.setCreated_timestamp(new Date().getTime());
|
- |
|
| 185 |
|
- |
|
| 186 |
orderCountForRow++;
|
- |
|
| 187 |
try {
|
- |
|
| 188 |
updatePayment(transaction.getId());
|
- |
|
| 189 |
} catch (Exception e) {
|
- |
|
| 190 |
logger.error("Unable to update payment for row number " + (rowId + 1), e);
|
- |
|
| 191 |
addActionError("Unable to update payment for row number " + (rowId + 1));
|
209 |
setErrorMsg(getErrorMsg() + "<br>Unable to update Order for Ebay Order " + rowId);
|
| 192 |
return "authsuccess";
|
210 |
continue;
|
| 193 |
}
|
211 |
}
|
| 194 |
try {
|
- |
|
| 195 |
tsc.updateOrderForEbay(order);
|
- |
|
| 196 |
//tsc.changeTransactionStatus(Long.valueOf(transaction.getId()), TransactionStatus.AUTHORIZED, "", new Long(PickUpType.SELF.getValue()), OrderType.B2C, OrderSource.EBAY);
|
- |
|
| 197 |
} catch (Exception e) {
|
- |
|
| 198 |
logger.error("Unable to update transaction status for row number " + (rowId +1), e);
|
- |
|
| 199 |
addActionError("Unable to update transaction status for row number " + (rowId +1));
|
- |
|
| 200 |
return "authsuccess";
|
- |
|
| 201 |
}
|
- |
|
| 202 |
}
|
212 |
}
|
| 203 |
|
213 |
|
| 204 |
checkForErrors();
|
214 |
checkForErrors();
|
| 205 |
|
215 |
|
| 206 |
return "authsuccess";
|
216 |
return "authsuccess";
|