| Line 11... |
Line 11... |
| 11 |
import in.shop2020.model.v1.order.OrderStatus;
|
11 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 12 |
import in.shop2020.model.v1.order.OrderType;
|
12 |
import in.shop2020.model.v1.order.OrderType;
|
| 13 |
import in.shop2020.model.v1.order.SnapdealOrder;
|
13 |
import in.shop2020.model.v1.order.SnapdealOrder;
|
| 14 |
import in.shop2020.model.v1.order.SourceDetail;
|
14 |
import in.shop2020.model.v1.order.SourceDetail;
|
| 15 |
import in.shop2020.model.v1.order.Transaction;
|
15 |
import in.shop2020.model.v1.order.Transaction;
|
| - |
|
16 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 16 |
import in.shop2020.model.v1.order.TransactionStatus;
|
17 |
import in.shop2020.model.v1.order.TransactionStatus;
|
| 17 |
import in.shop2020.model.v1.order.TransactionService.Client;
|
18 |
import in.shop2020.model.v1.order.TransactionService.Client;
|
| 18 |
import in.shop2020.model.v1.user.User;
|
19 |
import in.shop2020.model.v1.user.User;
|
| 19 |
import in.shop2020.payments.PaymentException;
|
20 |
import in.shop2020.payments.PaymentException;
|
| 20 |
import in.shop2020.payments.PaymentStatus;
|
21 |
import in.shop2020.payments.PaymentStatus;
|
| Line 23... |
Line 24... |
| 23 |
import in.shop2020.thrift.clients.PaymentClient;
|
24 |
import in.shop2020.thrift.clients.PaymentClient;
|
| 24 |
import in.shop2020.thrift.clients.TransactionClient;
|
25 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 25 |
import in.shop2020.thrift.clients.UserClient;
|
26 |
import in.shop2020.thrift.clients.UserClient;
|
| 26 |
|
27 |
|
| 27 |
import java.io.File;
|
28 |
import java.io.File;
|
| - |
|
29 |
import java.text.ParseException;
|
| 28 |
import java.text.SimpleDateFormat;
|
30 |
import java.text.SimpleDateFormat;
|
| 29 |
import java.util.ArrayList;
|
31 |
import java.util.ArrayList;
|
| 30 |
import java.util.Calendar;
|
32 |
import java.util.Calendar;
|
| 31 |
import java.util.Collections;
|
33 |
import java.util.Collections;
|
| 32 |
import java.util.Date;
|
34 |
import java.util.Date;
|
| Line 188... |
Line 190... |
| 188 |
t_order.setOrderType(OrderType.B2C);
|
190 |
t_order.setOrderType(OrderType.B2C);
|
| 189 |
t_order.setSource(SNAPDEAL_SOURCE_ID);
|
191 |
t_order.setSource(SNAPDEAL_SOURCE_ID);
|
| 190 |
t_order.setOrderType(OrderType.B2C);
|
192 |
t_order.setOrderType(OrderType.B2C);
|
| 191 |
orderlist.add(t_order);
|
193 |
orderlist.add(t_order);
|
| 192 |
txn.setOrders(orderlist);
|
194 |
txn.setOrders(orderlist);
|
| 193 |
try {
|
- |
|
| 194 |
String referenceCode = order.getReferenceCode();
|
195 |
String referenceCode = order.getReferenceCode();
|
| 195 |
String productName = order.getProduct();
|
196 |
String productName = order.getProduct();
|
| 196 |
SimpleDateFormat istFormatter = new SimpleDateFormat("dd/mm/yyyy");
|
197 |
SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| 197 |
//SimpleDateFormat istFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
198 |
Date snapdealTxnDate = null;
|
| - |
|
199 |
try {
|
| 198 |
Date snapdealTxnDate = istFormatter.parse(order.getOrderPlacedDate());
|
200 |
snapdealTxnDate = istFormatter.parse(order.getOrderPlacedDate());
|
| - |
|
201 |
} catch (ParseException e) {
|
| - |
|
202 |
logger.error("Could not parse order date from file ");
|
| - |
|
203 |
e.printStackTrace();
|
| - |
|
204 |
}
|
| - |
|
205 |
try {
|
| 199 |
transactionId = String.valueOf(transaction_client.createTransaction(txn));
|
206 |
transactionId = String.valueOf(transaction_client.createTransaction(txn));
|
| - |
|
207 |
} catch (TransactionServiceException e) {
|
| - |
|
208 |
logger.error("Could not create transaction ");
|
| - |
|
209 |
e.printStackTrace();
|
| - |
|
210 |
} catch (TException e) {
|
| - |
|
211 |
logger.error("Problem with transaction service while creating transaction");
|
| - |
|
212 |
e.printStackTrace();
|
| - |
|
213 |
}
|
| 200 |
createPayment(user, (new Long(subOrderId)).toString(), lineItem.getTotal_price());
|
214 |
createPayment(user, (new Long(subOrderId)).toString(), lineItem.getTotal_price());
|
| 201 |
|
215 |
|
| - |
|
216 |
Transaction transaction = null;
|
| - |
|
217 |
try {
|
| 202 |
Transaction transaction = transaction_client.getTransaction(Long.parseLong(transactionId));
|
218 |
transaction = transaction_client.getTransaction(Long.parseLong(transactionId));
|
| - |
|
219 |
} catch (NumberFormatException e) {
|
| - |
|
220 |
logger.error("Problem parsing transaction id " + transactionId);
|
| - |
|
221 |
e.printStackTrace();
|
| - |
|
222 |
} catch (TransactionServiceException e) {
|
| - |
|
223 |
logger.error("Problem getting transaction from service transaction id " + transactionId);
|
| - |
|
224 |
e.printStackTrace();
|
| - |
|
225 |
} catch (TException e) {
|
| - |
|
226 |
logger.error("Problem with transaction service while getting transaction id " + transactionId);
|
| - |
|
227 |
e.printStackTrace();
|
| - |
|
228 |
}
|
| 203 |
in.shop2020.model.v1.order.Order snapdealorder = transaction.getOrders().get(0);
|
229 |
in.shop2020.model.v1.order.Order snapdealorder = transaction.getOrders().get(0);
|
| 204 |
|
230 |
|
| 205 |
//inventoryClient.reserveItemInWarehouse(lineItem.getItem_id(), fulfillmentWarehouse.getId(), 1,
|
231 |
//inventoryClient.reserveItemInWarehouse(lineItem.getItem_id(), fulfillmentWarehouse.getId(), 1,
|
| 206 |
// snapdealorder.getId(), snapdealorder.getCreated_timestamp(), snapdealorder.getPromised_shipping_time(), snapdealorder.getLineitems().get(0).getQuantity());
|
232 |
// snapdealorder.getId(), snapdealorder.getCreated_timestamp(), snapdealorder.getPromised_shipping_time(), snapdealorder.getLineitems().get(0).getQuantity());
|
| 207 |
|
233 |
|
| Line 211... |
Line 237... |
| 211 |
snapdealOrder.setSubOrderId(subOrderId);
|
237 |
snapdealOrder.setSubOrderId(subOrderId);
|
| 212 |
snapdealOrder.setReferenceCode(referenceCode);
|
238 |
snapdealOrder.setReferenceCode(referenceCode);
|
| 213 |
snapdealOrder.setProductName(productName);
|
239 |
snapdealOrder.setProductName(productName);
|
| 214 |
snapdealOrder.setSnapdealTxnDate(snapdealTxnDate.getTime());
|
240 |
snapdealOrder.setSnapdealTxnDate(snapdealTxnDate.getTime());
|
| 215 |
snapdealOrder.setListingPrice(lineItem.getTotal_price());
|
241 |
snapdealOrder.setListingPrice(lineItem.getTotal_price());
|
| - |
|
242 |
try {
|
| 216 |
transaction_client.createSnapdealOrder(snapdealOrder);
|
243 |
transaction_client.createSnapdealOrder(snapdealOrder);
|
| - |
|
244 |
} catch (TException e) {
|
| - |
|
245 |
logger.error("Could not create Snapdeal Order");
|
| - |
|
246 |
e.printStackTrace();
|
| - |
|
247 |
}
|
| 217 |
|
248 |
|
| 218 |
}
|
249 |
}
|
| 219 |
catch (Exception e) {
|
- |
|
| 220 |
logger.error("Error in creating transaction " + order.getSuborderId());
|
- |
|
| 221 |
continue;
|
- |
|
| 222 |
}
|
- |
|
| 223 |
}
|
- |
|
| 224 |
|
250 |
|
| 225 |
}
|
251 |
}
|
| 226 |
|
252 |
|
| 227 |
public static void createPayment(User user, String subOrderId, double amount) {
|
253 |
public static void createPayment(User user, String subOrderId, double amount) {
|
| 228 |
in.shop2020.payments.PaymentService.Client client = null;
|
254 |
in.shop2020.payments.PaymentService.Client client = null;
|