| Line 3... |
Line 3... |
| 3 |
import in.shop2020.model.v1.order.OrderSource;
|
3 |
import in.shop2020.model.v1.order.OrderSource;
|
| 4 |
import in.shop2020.model.v1.order.OrderStatus;
|
4 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 5 |
import in.shop2020.thrift.clients.TransactionClient;
|
5 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 6 |
|
6 |
|
| 7 |
import java.io.BufferedReader;
|
7 |
import java.io.BufferedReader;
|
| - |
|
8 |
import java.io.IOException;
|
| 8 |
import java.io.InputStreamReader;
|
9 |
import java.io.InputStreamReader;
|
| 9 |
import java.io.UnsupportedEncodingException;
|
10 |
import java.io.UnsupportedEncodingException;
|
| 10 |
import java.text.SimpleDateFormat;
|
11 |
import java.text.SimpleDateFormat;
|
| 11 |
import java.util.ArrayList;
|
12 |
import java.util.ArrayList;
|
| 12 |
import java.util.Date;
|
13 |
import java.util.Date;
|
| Line 14... |
Line 15... |
| 14 |
import java.util.List;
|
15 |
import java.util.List;
|
| 15 |
import java.util.Map;
|
16 |
import java.util.Map;
|
| 16 |
|
17 |
|
| 17 |
import org.apache.http.HttpResponse;
|
18 |
import org.apache.http.HttpResponse;
|
| 18 |
import org.apache.http.NameValuePair;
|
19 |
import org.apache.http.NameValuePair;
|
| - |
|
20 |
import org.apache.http.client.ClientProtocolException;
|
| 19 |
import org.apache.http.client.HttpClient;
|
21 |
import org.apache.http.client.HttpClient;
|
| 20 |
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
22 |
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
| 21 |
import org.apache.http.client.methods.HttpGet;
|
23 |
import org.apache.http.client.methods.HttpGet;
|
| 22 |
import org.apache.http.client.methods.HttpPost;
|
24 |
import org.apache.http.client.methods.HttpPost;
|
| 23 |
import org.apache.http.impl.client.DefaultHttpClient;
|
25 |
import org.apache.http.impl.client.DefaultHttpClient;
|
| Line 68... |
Line 70... |
| 68 |
//startDate = startDate.replace("-", "%2F");
|
70 |
//startDate = startDate.replace("-", "%2F");
|
| 69 |
|
71 |
|
| 70 |
String endDate = snapdealDateFormat.format(new Date(System.currentTimeMillis()));
|
72 |
String endDate = snapdealDateFormat.format(new Date(System.currentTimeMillis()));
|
| 71 |
logger.info("Snapdeal Order Recon End Date .. "+endDate);
|
73 |
logger.info("Snapdeal Order Recon End Date .. "+endDate);
|
| 72 |
//endDate = endDate.replace("-", "%2F");
|
74 |
//endDate = endDate.replace("-", "%2F");
|
| - |
|
75 |
|
| - |
|
76 |
|
| - |
|
77 |
HttpClient client = new DefaultHttpClient();
|
| - |
|
78 |
|
| - |
|
79 |
HttpGet get = new HttpGet("http://selleraccounts.snapdeal.com/keymaker/login");
|
| - |
|
80 |
HttpResponse response = null;
|
| - |
|
81 |
try {
|
| - |
|
82 |
response = client.execute(get);
|
| - |
|
83 |
} catch (ClientProtocolException e) {
|
| 73 |
|
84 |
|
| - |
|
85 |
e.printStackTrace();
|
| - |
|
86 |
} catch (IOException e) {
|
| 74 |
|
87 |
|
| 75 |
HttpClient client = new DefaultHttpClient();
|
88 |
e.printStackTrace();
|
| 76 |
HttpPost post = new HttpPost("http://shipping.snapdeal.com/login_security_check?spring-security-redirect=http://shipping.snapdeal.com/vendor/product-shipment/shippingDashboard&");
|
- |
|
| 77 |
HttpGet get;
|
89 |
}
|
| 78 |
BufferedReader rd= null;
|
90 |
BufferedReader rd = null;
|
| - |
|
91 |
try {
|
| - |
|
92 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| - |
|
93 |
} catch (IllegalStateException e1) {
|
| 79 |
|
94 |
|
| - |
|
95 |
e1.printStackTrace();
|
| - |
|
96 |
} catch (IOException e1) {
|
| - |
|
97 |
|
| - |
|
98 |
e1.printStackTrace();
|
| - |
|
99 |
}
|
| - |
|
100 |
String line = "";
|
| - |
|
101 |
StringBuffer sb = new StringBuffer();
|
| - |
|
102 |
try {
|
| - |
|
103 |
while ((line = rd.readLine()) != null) {
|
| - |
|
104 |
sb.append(line);
|
| - |
|
105 |
//System.out.println(line);
|
| - |
|
106 |
}
|
| - |
|
107 |
} catch (IOException e) {
|
| - |
|
108 |
|
| - |
|
109 |
e.printStackTrace();
|
| - |
|
110 |
}
|
| - |
|
111 |
int i= sb.toString().indexOf("name=\"lt\" value=");
|
| - |
|
112 |
char[] charArray = sb.toString().toCharArray();
|
| - |
|
113 |
String lt = "";
|
| - |
|
114 |
int j=0;
|
| - |
|
115 |
for(j=i+16;j<=charArray.length;j++){
|
| - |
|
116 |
|
| - |
|
117 |
if(charArray[j]==' '){
|
| - |
|
118 |
break;
|
| - |
|
119 |
}
|
| - |
|
120 |
}
|
| - |
|
121 |
lt = sb.substring(i+17,j-1);
|
| - |
|
122 |
System.out.println("LT VALUE " + lt);
|
| - |
|
123 |
i= sb.toString().indexOf("name=\"execution\" value=");
|
| - |
|
124 |
charArray = sb.toString().toCharArray();
|
| - |
|
125 |
|
| - |
|
126 |
String ex = "";
|
| - |
|
127 |
j=0;
|
| - |
|
128 |
for(j=i+24;j<=charArray.length;j++){
|
| - |
|
129 |
if(charArray[j]==' '){
|
| - |
|
130 |
break;
|
| - |
|
131 |
}
|
| - |
|
132 |
}
|
| - |
|
133 |
ex = sb.substring(i+24,j-1);
|
| - |
|
134 |
System.out.println("EXECUTION VALUE " + ex);
|
| - |
|
135 |
|
| - |
|
136 |
|
| - |
|
137 |
|
| - |
|
138 |
HttpPost post = new HttpPost("http://selleraccounts.snapdeal.com/login?service=http%3A%2F%2Fshipping.snapdeal.com%2Fj_spring_cas_security_check");
|
| 80 |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
|
139 |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
|
| - |
|
140 |
//nameValuePairs.add(new BasicNameValuePair("username",
|
| - |
|
141 |
//"khushal.bhatia@saholic.com"));
|
| 81 |
nameValuePairs.add(new BasicNameValuePair("j_username",
|
142 |
nameValuePairs.add(new BasicNameValuePair("username",
|
| 82 |
"saholic-snapdeal@saholic.com"));
|
143 |
"saholic-snapdeal@saholic.com"));
|
| - |
|
144 |
//nameValuePairs.add(new BasicNameValuePair("password",
|
| - |
|
145 |
//"sonline"));
|
| 83 |
nameValuePairs.add(new BasicNameValuePair("j_password",
|
146 |
nameValuePairs.add(new BasicNameValuePair("password",
|
| 84 |
"d73eaa39"));
|
147 |
"bc452ce4"));
|
| - |
|
148 |
nameValuePairs.add(new BasicNameValuePair("_eventId","submit"));
|
| - |
|
149 |
nameValuePairs.add(new BasicNameValuePair("execution",ex));
|
| - |
|
150 |
nameValuePairs.add(new BasicNameValuePair("lt",lt));
|
| - |
|
151 |
nameValuePairs.add(new BasicNameValuePair("submit","LOGIN"));
|
| 85 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
152 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
| 86 |
HttpResponse response = null;
|
153 |
//response = null;
|
| 87 |
try {
|
154 |
try {
|
| 88 |
response = client.execute(post);
|
155 |
response = client.execute(post);
|
| 89 |
} catch (Exception e) {
|
156 |
} catch (Exception e) {
|
| 90 |
logger.error("Unable to get Http Response for snapdeal seller portal login", e);
|
157 |
logger.error("Unable to get Http Response for snapdeal seller portal login", e);
|
| 91 |
}
|
158 |
}
|
| Line 93... |
Line 160... |
| 93 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
160 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 94 |
} catch (Exception e1) {
|
161 |
} catch (Exception e1) {
|
| 95 |
logger.error("Unable to read Http Response for snapdeal seller portal login", e1);
|
162 |
logger.error("Unable to read Http Response for snapdeal seller portal login", e1);
|
| 96 |
}
|
163 |
}
|
| 97 |
|
164 |
|
| 98 |
String line = "";
|
165 |
//Striline = "";
|
| 99 |
try {
|
166 |
try {
|
| 100 |
while ((line = rd.readLine()) != null) {
|
167 |
while ((line = rd.readLine()) != null) {
|
| 101 |
System.out.println(line);
|
168 |
System.out.println(line);
|
| 102 |
}
|
169 |
}
|
| 103 |
} catch (Exception e) {
|
170 |
} catch (Exception e) {
|
| 104 |
logger.error("Unable to extract Http Response for snapdeal seller portal login", e);
|
171 |
logger.error("Unable to extract Http Response for snapdeal seller portal login", e);
|
| 105 |
}
|
172 |
}
|
| 106 |
|
173 |
|
| 107 |
JSONObject jsonDataObj = null;
|
174 |
JSONArray jsonDataObj = null;
|
| 108 |
JSONArray jsonDataShip = null;
|
175 |
JSONArray jsonDataShip = null;
|
| 109 |
String line1 = "";
|
176 |
String line1 = "";
|
| 110 |
|
177 |
|
| 111 |
for(long start = start_date.getTime(); start < end_date.getTime();){
|
178 |
for(long start = start_date.getTime(); start < end_date.getTime();){
|
| 112 |
long end = start + 604800000l;
|
179 |
long end = start + 604800000l;
|
| Line 121... |
Line 188... |
| 121 |
logger.info("==== Start Date.."+startDate+"\n");
|
188 |
logger.info("==== Start Date.."+startDate+"\n");
|
| 122 |
logger.info("==== End Date.."+endDate+"\n");
|
189 |
logger.info("==== End Date.."+endDate+"\n");
|
| 123 |
|
190 |
|
| 124 |
|
191 |
|
| 125 |
logger.info("Getting Delivery Information for DropShip Snapdeal Orders");
|
192 |
logger.info("Getting Delivery Information for DropShip Snapdeal Orders");
|
| - |
|
193 |
//http://shipping.snapdeal.com/vendor/ONESHIP/product-shipment/shippedData/fetch?statusCode=COURIER_DELIVERED&dispatchCategoryId=0&startDate=2014%2F04%2F01&endDate=2014%2F04%2F07&statusColumn=deliveredOn
|
| 126 |
String dropshipUrl = "http://shipping.snapdeal.com/vendor/DROPSHIP/product-shipment/shippedData/fetch/?startDate="+startDate+"&endDate="+endDate+"&specialPanelAccess=&statusCode=COURIER_DELIVERED&statusColumn=deliveredOn&dispatchCategoryId=0&sCode=COURIER_DELIVERED";
|
194 |
String dropshipUrl = "http://shipping.snapdeal.com/vendor/DROPSHIP/product-shipment/shippedData/fetch/?startDate="+startDate+"&endDate="+endDate+"&statusCode=COURIER_DELIVERED&statusColumn=deliveredOn&dispatchCategoryId=0";
|
| 127 |
logger.info("Drop Ship Url "+dropshipUrl);
|
195 |
logger.info("Drop Ship Url "+dropshipUrl);
|
| 128 |
|
196 |
|
| 129 |
get = new HttpGet(dropshipUrl);
|
197 |
get = new HttpGet(dropshipUrl);
|
| 130 |
|
198 |
|
| 131 |
try {
|
199 |
try {
|
| Line 140... |
Line 208... |
| 140 |
logger.error("Unable to read Http Response for snapdeal dropship delivered orders", e);
|
208 |
logger.error("Unable to read Http Response for snapdeal dropship delivered orders", e);
|
| 141 |
}
|
209 |
}
|
| 142 |
|
210 |
|
| 143 |
|
211 |
|
| 144 |
try {
|
212 |
try {
|
| - |
|
213 |
|
| - |
|
214 |
String resP = rd.readLine();
|
| 145 |
jsonDataObj = new JSONObject(rd.readLine());
|
215 |
jsonDataObj = new JSONArray("["+resP+"]");
|
| - |
|
216 |
JSONObject j1 = (JSONObject)jsonDataObj.get(0);
|
| 146 |
jsonDataShip = new JSONArray(jsonDataObj.get("jsonDataString").toString());
|
217 |
jsonDataShip = new JSONArray(j1.get("jsonDataString").toString());
|
| 147 |
} catch (Exception e) {
|
218 |
} catch (Exception e) {
|
| 148 |
logger.error("Unable to extract Http Response for snapdeal dropship delivered orders", e);
|
219 |
logger.error("Unable to extract Http Response for snapdeal dropship delivered orders", e);
|
| 149 |
}
|
220 |
}
|
| 150 |
|
221 |
|
| 151 |
|
222 |
|
| 152 |
if(jsonDataShip!=null && jsonDataShip.length()>0){
|
223 |
if(jsonDataShip!=null && jsonDataShip.length()>0){
|
| 153 |
for(int i=0; i< jsonDataShip.length(); i++){
|
224 |
for(i=0; i< jsonDataShip.length(); i++){
|
| 154 |
JSONObject jsonObj = null;
|
225 |
JSONObject jsonObj = null;
|
| 155 |
try {
|
226 |
try {
|
| 156 |
jsonObj = jsonDataShip.getJSONObject(i);
|
227 |
jsonObj = jsonDataShip.getJSONObject(i);
|
| 157 |
|
228 |
|
| 158 |
if(jsonObj!=null){
|
229 |
if(jsonObj!=null){
|
| Line 173... |
Line 244... |
| 173 |
}
|
244 |
}
|
| 174 |
}
|
245 |
}
|
| 175 |
|
246 |
|
| 176 |
logger.info("Getting Delivery Information for OneShip Snapdeal Orders");
|
247 |
logger.info("Getting Delivery Information for OneShip Snapdeal Orders");
|
| 177 |
//statusCode=CLD&dispatchCategoryId=0&startDate=2013%2F11%2F01&endDate=2013%2F11%2F07&statusColumn=cancelledOn
|
248 |
//statusCode=CLD&dispatchCategoryId=0&startDate=2013%2F11%2F01&endDate=2013%2F11%2F07&statusColumn=cancelledOn
|
| 178 |
String oneShipUrl = "http://shipping.snapdeal.com/vendor/ONESHIP/product-shipment/shippedData/fetch/?startDate="+startDate+"&endDate="+endDate+"&specialPanelAccess=&statusCode=COURIER_DELIVERED&statusColumn=deliveredOn&dispatchCategoryId=0&sCode=COURIER_DELIVERED";
|
249 |
String oneShipUrl = "http://shipping.snapdeal.com/vendor/ONESHIP/product-shipment/shippedData/fetch/?startDate="+startDate+"&endDate="+endDate+"&statusCode=COURIER_DELIVERED&statusColumn=deliveredOn&dispatchCategoryId=0";
|
| 179 |
logger.info("One Ship Url "+oneShipUrl);
|
250 |
logger.info("One Ship Url "+oneShipUrl);
|
| 180 |
|
251 |
|
| 181 |
get = new HttpGet(oneShipUrl);
|
252 |
get = new HttpGet(oneShipUrl);
|
| 182 |
|
253 |
|
| 183 |
try {
|
254 |
try {
|
| Line 191... |
Line 262... |
| 191 |
} catch (Exception e) {
|
262 |
} catch (Exception e) {
|
| 192 |
logger.error("Unable to read Http Response for snapdeal oneship delivered orders", e);
|
263 |
logger.error("Unable to read Http Response for snapdeal oneship delivered orders", e);
|
| 193 |
}
|
264 |
}
|
| 194 |
|
265 |
|
| 195 |
try {
|
266 |
try {
|
| - |
|
267 |
String resP = rd.readLine();
|
| 196 |
jsonDataObj = new JSONObject(rd.readLine());
|
268 |
jsonDataObj = new JSONArray("["+resP+"]");
|
| - |
|
269 |
JSONObject j1 = (JSONObject)jsonDataObj.get(0);
|
| 197 |
jsonDataShip = new JSONArray(jsonDataObj.get("jsonDataString").toString());
|
270 |
jsonDataShip = new JSONArray(j1.get("jsonDataString").toString());
|
| 198 |
} catch (Exception e) {
|
271 |
} catch (Exception e) {
|
| 199 |
logger.error("Unable to extract Http Response for snapdeal oneship delivered orders", e);
|
272 |
logger.error("Unable to extract Http Response for snapdeal oneship delivered orders", e);
|
| 200 |
}
|
273 |
}
|
| 201 |
|
274 |
|
| 202 |
if(jsonDataShip!=null && jsonDataShip.length()>0){
|
275 |
if(jsonDataShip!=null && jsonDataShip.length()>0){
|
| 203 |
for(int i=0; i< jsonDataShip.length(); i++){
|
276 |
for(i=0; i< jsonDataShip.length(); i++){
|
| 204 |
JSONObject jsonObj = null;
|
277 |
JSONObject jsonObj = null;
|
| 205 |
try {
|
278 |
try {
|
| 206 |
jsonObj = jsonDataShip.getJSONObject(i);
|
279 |
jsonObj = jsonDataShip.getJSONObject(i);
|
| 207 |
|
280 |
|
| 208 |
if(jsonObj!=null){
|
281 |
if(jsonObj!=null){
|
| Line 242... |
Line 315... |
| 242 |
} catch (Exception e) {
|
315 |
} catch (Exception e) {
|
| 243 |
logger.error("Unable to read Http Response for snapdeal dropship cancelled orders", e);
|
316 |
logger.error("Unable to read Http Response for snapdeal dropship cancelled orders", e);
|
| 244 |
}
|
317 |
}
|
| 245 |
|
318 |
|
| 246 |
try {
|
319 |
try {
|
| - |
|
320 |
String resP = rd.readLine();
|
| 247 |
jsonDataObj = new JSONObject(rd.readLine());
|
321 |
jsonDataObj = new JSONArray("["+resP+"]");
|
| - |
|
322 |
JSONObject j1 = (JSONObject)jsonDataObj.get(0);
|
| 248 |
jsonDataShip = new JSONArray(jsonDataObj.get("jsonDataString").toString());
|
323 |
jsonDataShip = new JSONArray(j1.get("jsonDataString").toString());
|
| 249 |
} catch (Exception e) {
|
324 |
} catch (Exception e) {
|
| 250 |
logger.error("Unable to extract Http Response for snapdeal dropship cancelled orders", e);
|
325 |
logger.error("Unable to extract Http Response for snapdeal dropship cancelled orders", e);
|
| 251 |
}
|
326 |
}
|
| 252 |
|
327 |
|
| 253 |
if(jsonDataShip!=null && jsonDataShip.length()>0){
|
328 |
if(jsonDataShip!=null && jsonDataShip.length()>0){
|
| 254 |
for(int i=0; i< jsonDataShip.length(); i++){
|
329 |
for(i=0; i< jsonDataShip.length(); i++){
|
| 255 |
JSONObject jsonObj = null;
|
330 |
JSONObject jsonObj = null;
|
| 256 |
try {
|
331 |
try {
|
| 257 |
jsonObj = jsonDataShip.getJSONObject(i);
|
332 |
jsonObj = jsonDataShip.getJSONObject(i);
|
| 258 |
|
333 |
|
| 259 |
if(jsonObj!=null){
|
334 |
if(jsonObj!=null){
|
| Line 288... |
Line 363... |
| 288 |
} catch (Exception e) {
|
363 |
} catch (Exception e) {
|
| 289 |
logger.error("Unable to read Http Response for snapdeal oneship cancelled orders", e);
|
364 |
logger.error("Unable to read Http Response for snapdeal oneship cancelled orders", e);
|
| 290 |
}
|
365 |
}
|
| 291 |
|
366 |
|
| 292 |
try {
|
367 |
try {
|
| - |
|
368 |
String resP = rd.readLine();
|
| 293 |
jsonDataObj = new JSONObject(rd.readLine());
|
369 |
jsonDataObj = new JSONArray("["+resP+"]");
|
| - |
|
370 |
JSONObject j1 = (JSONObject)jsonDataObj.get(0);
|
| 294 |
jsonDataShip = new JSONArray(jsonDataObj.get("jsonDataString").toString());
|
371 |
jsonDataShip = new JSONArray(j1.get("jsonDataString").toString());
|
| 295 |
} catch (Exception e) {
|
372 |
} catch (Exception e) {
|
| 296 |
logger.error("Unable to extract Http Response for snapdeal oneship cancelled orders", e);
|
373 |
logger.error("Unable to extract Http Response for snapdeal oneship cancelled orders", e);
|
| 297 |
}
|
374 |
}
|
| 298 |
|
375 |
|
| 299 |
if(jsonDataShip!=null && jsonDataShip.length()>0){
|
376 |
if(jsonDataShip!=null && jsonDataShip.length()>0){
|
| 300 |
for(int i=0; i< jsonDataShip.length(); i++){
|
377 |
for(i=0; i< jsonDataShip.length(); i++){
|
| 301 |
JSONObject jsonObj = null;
|
378 |
JSONObject jsonObj = null;
|
| 302 |
try {
|
379 |
try {
|
| 303 |
jsonObj = jsonDataShip.getJSONObject(i);
|
380 |
jsonObj = jsonDataShip.getJSONObject(i);
|
| 304 |
|
381 |
|
| 305 |
if(jsonObj!=null){
|
382 |
if(jsonObj!=null){
|