| Line 77... |
Line 77... |
| 77 |
{
|
77 |
{
|
| 78 |
sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
78 |
sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
| 79 |
emailFromAddress = "build@shop2020.in";
|
79 |
emailFromAddress = "build@shop2020.in";
|
| 80 |
password = "cafe@nes";
|
80 |
password = "cafe@nes";
|
| 81 |
mailer = new GmailUtils();
|
81 |
mailer = new GmailUtils();
|
| 82 |
sendTo = new String[]{"vikram.raghav@shop2020.in"};
|
82 |
//sendTo = new String[]{"vikram.raghav@shop2020.in"};
|
| 83 |
/* sendTo = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
|
83 |
sendTo = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
|
| 84 |
"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
84 |
"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
| 85 |
"yukti.jain@shop2020.in","manoj.pal@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","amar.kumar@shop2020.in"};
|
85 |
"yukti.jain@shop2020.in","manoj.pal@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","amar.kumar@shop2020.in","anikendra.das@shop2020.in"};
|
| 86 |
*/ List<String> flipkartorderids = null;
|
86 |
List<String> flipkartorderids = null;
|
| 87 |
Client catalogServiceClient = null;
|
87 |
Client catalogServiceClient = null;
|
| 88 |
try {
|
88 |
try {
|
| 89 |
catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
89 |
catalogServiceClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| 90 |
} catch (TTransportException e) {
|
90 |
} catch (TTransportException e) {
|
| 91 |
e.printStackTrace();
|
91 |
e.printStackTrace();
|
| 92 |
}
|
92 |
}
|
| 93 |
try {
|
93 |
try {
|
| 94 |
flipkartItems = catalogServiceClient.getAllFlipkartItems();
|
94 |
flipkartItems = catalogServiceClient.getAllFlipkartItems();
|
| 95 |
snapdealItems = catalogServiceClient.getAllSnapdealItems();
|
95 |
snapdealItems = catalogServiceClient.getAllSnapdealItems();
|
| 96 |
} catch (TException e) {
|
96 |
} catch (TException e) {
|
| 97 |
e.printStackTrace();
|
97 |
e.printStackTrace();
|
| 98 |
}
|
98 |
}
|
| 99 |
for(FlipkartItem flipkartItem:flipkartItems){
|
99 |
for(FlipkartItem flipkartItem:flipkartItems){
|
| 100 |
if(flipkartItem.isIsListedOnFlipkart() && !flipkartItem.isSuppressInventoryFeed())
|
100 |
if(flipkartItem.isIsListedOnFlipkart() && !flipkartItem.isSuppressInventoryFeed())
|
| 101 |
flipkartInventoryItems.add(flipkartItem);
|
101 |
flipkartInventoryItems.add(flipkartItem);
|
| 102 |
}
|
102 |
}
|
| 103 |
for(SnapdealItemDetails snapdealItem:snapdealItems){
|
103 |
for(SnapdealItemDetails snapdealItem:snapdealItems){
|
| 104 |
snapdealItemsMap.put(snapdealItem.getItem_id(),snapdealItem);
|
104 |
snapdealItemsMap.put(snapdealItem.getItem_id(),snapdealItem);
|
| 105 |
}
|
105 |
}
|
| 106 |
if(flipkartInventoryItems.size()==0){
|
106 |
if(flipkartInventoryItems.size()==0){
|
| 107 |
String text = "";
|
107 |
String text = "";
|
| 108 |
try {
|
108 |
try {
|
| 109 |
mailer.sendSSLMessage(sendTo,"No items to send inventory ", emailFromAddress, password, text);
|
109 |
mailer.sendSSLMessage(sendTo,"No items to send inventory ", emailFromAddress, password, text);
|
| 110 |
System.exit(0);
|
110 |
System.exit(0);
|
| 111 |
} catch (MessagingException e) {
|
111 |
} catch (MessagingException e) {
|
| 112 |
e.printStackTrace();
|
112 |
e.printStackTrace();
|
| 113 |
}
|
113 |
}
|
| 114 |
}
|
114 |
}
|
| 115 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
|
115 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
|
| 116 |
try {
|
116 |
try {
|
| 117 |
flipkartorderids = FetchOrders();
|
117 |
flipkartorderids = FetchOrders();
|
| 118 |
} catch (ClientProtocolException e1) {
|
118 |
} catch (ClientProtocolException e1) {
|
| 119 |
e1.printStackTrace();
|
119 |
e1.printStackTrace();
|
| 120 |
} catch (IOException e1) {
|
120 |
} catch (IOException e1) {
|
| 121 |
e1.printStackTrace();
|
121 |
e1.printStackTrace();
|
| 122 |
}
|
122 |
}
|
| 123 |
try {
|
123 |
try {
|
| 124 |
transactionClient = new TransactionClient().getClient();
|
124 |
transactionClient = new TransactionClient().getClient();
|
| 125 |
if(flipkartorderids!=null && flipkartorderids.size()>0){
|
125 |
if(flipkartorderids!=null && flipkartorderids.size()>0){
|
| 126 |
itemIdOrdersMap = transactionClient.getCreatedOrdersForFlipkart(flipkartorderids);
|
126 |
itemIdOrdersMap = transactionClient.getCreatedOrdersForFlipkart(flipkartorderids);
|
| 127 |
}
|
127 |
}
|
| 128 |
} catch (TTransportException e) {
|
128 |
} catch (TTransportException e) {
|
| 129 |
try {
|
129 |
try {
|
| 130 |
itemIdOrdersMap = transactionClient.getCreatedOrdersForFlipkart(flipkartorderids);
|
130 |
itemIdOrdersMap = transactionClient.getCreatedOrdersForFlipkart(flipkartorderids);
|
| 131 |
} catch (TException e1) {
|
131 |
} catch (TException e1) {
|
| 132 |
e1.printStackTrace();
|
132 |
e1.printStackTrace();
|
| 133 |
}
|
133 |
}
|
| 134 |
}catch (TException e) {
|
134 |
}catch (TException e) {
|
| 135 |
e.printStackTrace();
|
135 |
e.printStackTrace();
|
| 136 |
}
|
136 |
}
|
| 137 |
try {
|
137 |
try {
|
| 138 |
List<FlipkartInventorySnapshot> updatedFlipkartInventoryList = new InventoryClient().getClient().getFlipkartInventorySnapshot();
|
138 |
List<FlipkartInventorySnapshot> updatedFlipkartInventoryList = new InventoryClient().getClient().getFlipkartInventorySnapshot();
|
| 139 |
for(FlipkartInventorySnapshot updatedFlipkartInventory:updatedFlipkartInventoryList){
|
139 |
for(FlipkartInventorySnapshot updatedFlipkartInventory:updatedFlipkartInventoryList){
|
| 140 |
updatedFlipkartInventoryMap.put(updatedFlipkartInventory.getItem_id(),updatedFlipkartInventory.getAvailability());
|
140 |
updatedFlipkartInventoryMap.put(updatedFlipkartInventory.getItem_id(),updatedFlipkartInventory.getAvailability());
|
| 141 |
}
|
141 |
}
|
| 142 |
} catch (TException e) {
|
142 |
} catch (TException e) {
|
| 143 |
e.printStackTrace();
|
143 |
e.printStackTrace();
|
| 144 |
}
|
144 |
}
|
| 145 |
catch(Exception e){
|
145 |
catch(Exception e){
|
| 146 |
List<FlipkartInventorySnapshot> updatedFlipkartInventoryList = null;
|
146 |
List<FlipkartInventorySnapshot> updatedFlipkartInventoryList = null;
|
| 147 |
try {
|
147 |
try {
|
| 148 |
updatedFlipkartInventoryList = new InventoryClient().getClient().getFlipkartInventorySnapshot();
|
148 |
updatedFlipkartInventoryList = new InventoryClient().getClient().getFlipkartInventorySnapshot();
|
| 149 |
} catch (TTransportException e1) {
|
149 |
} catch (TTransportException e1) {
|
| 150 |
e1.printStackTrace();
|
150 |
e1.printStackTrace();
|
| 151 |
} catch (TException e1) {
|
151 |
} catch (TException e1) {
|
| 152 |
e1.printStackTrace();
|
152 |
e1.printStackTrace();
|
| 153 |
}
|
153 |
}
|
| 154 |
if(updatedFlipkartInventoryList != null){
|
154 |
if(updatedFlipkartInventoryList != null){
|
| 155 |
for(FlipkartInventorySnapshot updatedFlipkartInventory:updatedFlipkartInventoryList){
|
155 |
for(FlipkartInventorySnapshot updatedFlipkartInventory:updatedFlipkartInventoryList){
|
| 156 |
updatedFlipkartInventoryMap.put(updatedFlipkartInventory.getItem_id(),updatedFlipkartInventory.getAvailability());
|
156 |
updatedFlipkartInventoryMap.put(updatedFlipkartInventory.getItem_id(),updatedFlipkartInventory.getAvailability());
|
| 157 |
}
|
157 |
}
|
| 158 |
}
|
158 |
}
|
| 159 |
}
|
159 |
}
|
| 160 |
|
160 |
|
| 161 |
|
161 |
|
| 162 |
}
|
162 |
}
|
| 163 |
|
163 |
|
| 164 |
public static void main(String[] args) throws ClientProtocolException, TException{
|
164 |
public static void main(String[] args) throws ClientProtocolException, TException{
|
| Line 169... |
Line 169... |
| 169 |
// new AuthScope("sandbox-api.flipkart.net", 443),
|
169 |
// new AuthScope("sandbox-api.flipkart.net", 443),
|
| 170 |
// new UsernamePasswordCredentials("og3yg5994bxbxxc1", "8a137068-417c-4e4f-ae95-9295ab938d88"));/// Test Server Access Keys
|
170 |
// new UsernamePasswordCredentials("og3yg5994bxbxxc1", "8a137068-417c-4e4f-ae95-9295ab938d88"));/// Test Server Access Keys
|
| 171 |
//httpclient.getCredentialsProvider().setCredentials(
|
171 |
//httpclient.getCredentialsProvider().setCredentials(
|
| 172 |
// new AuthScope("api.flipkart.net", 443),
|
172 |
// new AuthScope("api.flipkart.net", 443),
|
| 173 |
// new UsernamePasswordCredentials("m2z93iskuj81qiid","0c7ab6a5-98c0-4cdc-8be3-72c591e0add4")); //Prod Server Access Keys
|
173 |
// new UsernamePasswordCredentials("m2z93iskuj81qiid","0c7ab6a5-98c0-4cdc-8be3-72c591e0add4")); //Prod Server Access Keys
|
| 174 |
|
174 |
|
| 175 |
HttpPost httppost = new HttpPost("https://api.flipkart.net/sellers/skus/listings/bulk"); // PROD
|
175 |
HttpPost httppost = new HttpPost("https://api.flipkart.net/sellers/skus/listings/bulk"); // PROD
|
| 176 |
|
176 |
|
| 177 |
String auth = "m2z93iskuj81qiid"+":"+"0c7ab6a5-98c0-4cdc-8be3-72c591e0add4";
|
177 |
String auth = "m2z93iskuj81qiid"+":"+"0c7ab6a5-98c0-4cdc-8be3-72c591e0add4";
|
| 178 |
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII")));
|
178 |
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII")));
|
| 179 |
String authHeader = "Basic " + new String(encodedAuth);
|
179 |
String authHeader = "Basic " + new String(encodedAuth);
|
| 180 |
httppost.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
|
180 |
httppost.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
|
| 181 |
//HttpPost httppost = new HttpPost("https://sandbox-api.flipkart.net/sellers/skus/listings/bulk"); // TEST
|
181 |
//HttpPost httppost = new HttpPost("https://sandbox-api.flipkart.net/sellers/skus/listings/bulk"); // TEST
|
| Line 325... |
Line 325... |
| 325 |
if(logisticinfo.getShippingTime() > 5 && stock > 0){
|
325 |
if(logisticinfo.getShippingTime() > 5 && stock > 0){
|
| 326 |
System.out.println("Product : "+getProductName(item)+" Item ID : " + item.getId() + " Stock : " + stock +" "+ " SLA : " + logisticinfo.getShippingTime());
|
326 |
System.out.println("Product : "+getProductName(item)+" Item ID : " + item.getId() + " Stock : " + stock +" "+ " SLA : " + logisticinfo.getShippingTime());
|
| 327 |
stock = 0;
|
327 |
stock = 0;
|
| 328 |
}
|
328 |
}
|
| 329 |
System.out.println("++++++++++++++++++++After checking > 5 SLA++++++++++++++++++++++++");
|
329 |
System.out.println("++++++++++++++++++++After checking > 5 SLA++++++++++++++++++++++++");
|
| 330 |
|
330 |
|
| 331 |
if(!updatedFlipkartInventoryMap.containsKey(entry.getKey())){
|
331 |
if(!updatedFlipkartInventoryMap.containsKey(entry.getKey())){
|
| 332 |
inventoryItems.append("<tr>"
|
332 |
inventoryItems.append("<tr>"
|
| 333 |
+ "<td>" +getProductName(item)+"</td>"
|
333 |
+ "<td>" +getProductName(item)+"</td>"
|
| 334 |
+"<td>" + item.getId() + "</td>"
|
334 |
+"<td>" + item.getId() + "</td>"
|
| 335 |
+"<td>" + actualstock + "</td>"
|
335 |
+"<td>" + actualstock + "</td>"
|