| Line 107... |
Line 107... |
| 107 |
// 1 call per 10 mins
|
107 |
// 1 call per 10 mins
|
| 108 |
static final long LIST_ORDERS_THROTTLE_LIMIT = 600000L;
|
108 |
static final long LIST_ORDERS_THROTTLE_LIMIT = 600000L;
|
| 109 |
// 1 call per 12 secs
|
109 |
// 1 call per 12 secs
|
| 110 |
static final long LIST_ORDER_ITEMS_THROTTLE_LIMIT = 12000L;
|
110 |
static final long LIST_ORDER_ITEMS_THROTTLE_LIMIT = 12000L;
|
| 111 |
|
111 |
|
| 112 |
static long tempId;
|
- |
|
| 113 |
|
- |
|
| 114 |
static {
|
- |
|
| 115 |
TransactionClient tcl = null;
|
- |
|
| 116 |
UserClient ucl = null;
|
- |
|
| 117 |
try {
|
- |
|
| 118 |
tcl = new TransactionClient();
|
- |
|
| 119 |
ucl = new UserClient();
|
- |
|
| 120 |
try {
|
- |
|
| 121 |
SourceDetail source = tcl.getClient().getSourceDetail(3);
|
- |
|
| 122 |
User user = ucl.getClient().getUserByEmail(source.getEmail());
|
- |
|
| 123 |
tempId = user.getUserId();
|
- |
|
| 124 |
} catch (TException e) {
|
- |
|
| 125 |
// TODO Auto-generated catch block
|
- |
|
| 126 |
e.printStackTrace();
|
- |
|
| 127 |
} catch (UserContextException e) {
|
- |
|
| 128 |
// TODO Auto-generated catch block
|
- |
|
| 129 |
e.printStackTrace();
|
- |
|
| 130 |
}
|
- |
|
| 131 |
} catch (TTransportException e) {
|
- |
|
| 132 |
// TODO Auto-generated catch block
|
- |
|
| 133 |
e.printStackTrace();
|
- |
|
| 134 |
}
|
- |
|
| 135 |
|
- |
|
| 136 |
|
- |
|
| 137 |
|
- |
|
| 138 |
}
|
- |
|
| 139 |
|
- |
|
| 140 |
final public static String AMAZON_ORDER_ACKNOWLEDGEMENT_XML = "/home/vikram/OrderAcknowledgeMent.xml";
|
112 |
final public static String AMAZON_ORDER_ACKNOWLEDGEMENT_XML = "/home/vikram/OrderAcknowledgeMent.xml";
|
| 141 |
|
113 |
|
| 142 |
static final int INTERVAL_IN_MINS = 30; // 1-minute update interval
|
114 |
static final int INTERVAL_IN_MINS = 30; // 1-minute update interval
|
| 143 |
|
115 |
|
| 144 |
//static final int INTERVAL_IN_MINS = 15; // 15-minute update interval
|
116 |
//static final int INTERVAL_IN_MINS = 15; // 15-minute update interval
|
| Line 815... |
Line 787... |
| 815 |
i++;
|
787 |
i++;
|
| 816 |
}
|
788 |
}
|
| 817 |
//if(order.getFulfillmentChannel().equals(FulfillmentChannelEnum.MFN) && (order.getOrderStatus().equals(OrderStatusEnum.UNSHIPPED) || order.getOrderStatus().equals(OrderStatusEnum.CANCELED))){
|
789 |
//if(order.getFulfillmentChannel().equals(FulfillmentChannelEnum.MFN) && (order.getOrderStatus().equals(OrderStatusEnum.UNSHIPPED) || order.getOrderStatus().equals(OrderStatusEnum.CANCELED))){
|
| 818 |
//if(order.getFulfillmentChannel().equals(FulfillmentChannelEnum.MFN) && (order.getOrderStatus().equals(OrderStatusEnum.UNSHIPPED) || order.getOrderStatus().equals(OrderStatusEnum.PARTIALLY_SHIPPED))){
|
790 |
//if(order.getFulfillmentChannel().equals(FulfillmentChannelEnum.MFN) && (order.getOrderStatus().equals(OrderStatusEnum.UNSHIPPED) || order.getOrderStatus().equals(OrderStatusEnum.PARTIALLY_SHIPPED))){
|
| 819 |
if(order.getFulfillmentChannel().equals(FulfillmentChannelEnum.MFN) && order.getOrderStatus().equals(OrderStatusEnum.UNSHIPPED) && order.getSellerOrderId()==null ){
|
791 |
if(order.getFulfillmentChannel().equals(FulfillmentChannelEnum.MFN) && order.getOrderStatus().equals(OrderStatusEnum.UNSHIPPED) && order.getSellerOrderId()==null ){
|
| - |
|
792 |
String userEmail = order.getBuyerEmail();
|
| - |
|
793 |
User user = new User();
|
| - |
|
794 |
user.setCommunicationEmail(userEmail);
|
| - |
|
795 |
user.setEmail(userEmail);
|
| - |
|
796 |
user.setName(order.getBuyerName());
|
| - |
|
797 |
user.setMobileNumber(order.getShippingAddress().getPhone());
|
| - |
|
798 |
user.setPassword("amazon");
|
| - |
|
799 |
try {
|
| - |
|
800 |
UserClient ucl = new UserClient();
|
| - |
|
801 |
user = ucl.getClient().createUser(user);
|
| - |
|
802 |
} catch(Exception e) {
|
| - |
|
803 |
//////////////log.error("Unable to get default source", e);
|
| - |
|
804 |
}
|
| - |
|
805 |
|
| - |
|
806 |
long userId = user.getUserId();
|
| 820 |
AmazonOrder amazonOrder = new AmazonOrder();
|
807 |
AmazonOrder amazonOrder = new AmazonOrder();
|
| 821 |
long txnId = amazonOrder.persistTransaction(order,orderItems);
|
808 |
long txnId = amazonOrder.persistTransaction(userId, user.getActiveCartId(), user.getEmail(), order, orderItems);
|
| - |
|
809 |
|
| 822 |
TransactionClient tcl=null;
|
810 |
TransactionClient tcl=null;
|
| 823 |
InventoryClient icl = null;
|
811 |
InventoryClient icl = null;
|
| 824 |
PaymentClient pcl = null;
|
812 |
PaymentClient pcl = null;
|
| 825 |
Map<Long,Double> saholicItemMap = new HashMap<Long,Double>();
|
813 |
Map<Long,Double> saholicItemMap = new HashMap<Long,Double>();
|
| 826 |
if (txnId != -1){
|
814 |
if (txnId != -1){
|
| Line 828... |
Line 816... |
| 828 |
try {
|
816 |
try {
|
| 829 |
|
817 |
|
| 830 |
tcl = new TransactionClient();
|
818 |
tcl = new TransactionClient();
|
| 831 |
icl = new InventoryClient();
|
819 |
icl = new InventoryClient();
|
| 832 |
pcl = new PaymentClient();;
|
820 |
pcl = new PaymentClient();;
|
| 833 |
System.out.println("temp id is" +tempId);
|
821 |
System.out.println("temp id is" +userId);
|
| 834 |
List<in.shop2020.model.v1.order.Order> saholicOrders =tcl.getClient().getOrdersForTransaction(txnId,tempId);
|
822 |
List<in.shop2020.model.v1.order.Order> saholicOrders =tcl.getClient().getOrdersForTransaction(txnId,userId);
|
| 835 |
for(in.shop2020.model.v1.order.Order saholicOrder:saholicOrders)
|
823 |
for(in.shop2020.model.v1.order.Order saholicOrder:saholicOrders)
|
| 836 |
{
|
824 |
{
|
| 837 |
List<in.shop2020.model.v1.order.LineItem> lineitems= saholicOrder.getLineitems();
|
825 |
List<in.shop2020.model.v1.order.LineItem> lineitems= saholicOrder.getLineitems();
|
| 838 |
long itemId=0;
|
826 |
long itemId=0;
|
| 839 |
for(in.shop2020.model.v1.order.LineItem lineitem:lineitems){
|
827 |
for(in.shop2020.model.v1.order.LineItem lineitem:lineitems){
|
| Line 851... |
Line 839... |
| 851 |
aOrder.setTransactionId(txnId);
|
839 |
aOrder.setTransactionId(txnId);
|
| 852 |
aOrder.setStatus("Order-Creation-Success");
|
840 |
aOrder.setStatus("Order-Creation-Success");
|
| 853 |
tcl.getClient().addAmazonOrder(aOrder);
|
841 |
tcl.getClient().addAmazonOrder(aOrder);
|
| 854 |
amazonOrders.add(aOrder);
|
842 |
amazonOrders.add(aOrder);
|
| 855 |
}
|
843 |
}
|
| 856 |
long merchantPaymentId = pcl.getClient().createPayment(tempId, Double.parseDouble(order.getOrderTotal().getAmount()), 15, txnId, false);
|
844 |
long merchantPaymentId = pcl.getClient().createPayment(userId, Double.parseDouble(order.getOrderTotal().getAmount()), 15, txnId, false);
|
| 857 |
pcl.getClient().updatePaymentDetails(merchantPaymentId, "", "", "15", "", "", "", "", "", PaymentStatus.SUCCESS, "", null);
|
845 |
pcl.getClient().updatePaymentDetails(merchantPaymentId, "", "", "15", "", "", "", "", "", PaymentStatus.SUCCESS, "", null);
|
| 858 |
boolean success=tcl.getClient().changeTransactionStatus(txnId, TransactionStatus.AUTHORIZED, "Payment authorized", PickUpType.COURIER.getValue(), OrderType.B2C, OrderSource.AMAZON);
|
846 |
boolean success=tcl.getClient().changeTransactionStatus(txnId, TransactionStatus.AUTHORIZED, "Payment authorized", PickUpType.COURIER.getValue(), OrderType.B2C, OrderSource.AMAZON);
|
| 859 |
if(success){
|
847 |
if(success){
|
| 860 |
for(in.shop2020.model.v1.order.AmazonOrder aorder:amazonOrders){
|
848 |
for(in.shop2020.model.v1.order.AmazonOrder aorder:amazonOrders){
|
| 861 |
AmazonInventorySnapshot amazonInventorySnapshot=icl.getClient().getAmazonInventoryForItem(aorder.getItem_id());
|
849 |
AmazonInventorySnapshot amazonInventorySnapshot=icl.getClient().getAmazonInventoryForItem(aorder.getItem_id());
|