| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.services;
|
1 |
package in.shop2020.serving.services;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.model.v1.order.OrderSource;
|
- |
|
| 4 |
import in.shop2020.serving.model.Order;
|
- |
|
| 5 |
import in.shop2020.serving.model.OrderItems;
|
- |
|
| 6 |
import in.shop2020.thrift.clients.TransactionClient;
|
3 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 7 |
import in.shop2020.utils.GmailUtils;
|
4 |
import in.shop2020.utils.GmailUtils;
|
| 8 |
|
5 |
|
| 9 |
import java.io.BufferedReader;
|
6 |
import java.io.BufferedReader;
|
| 10 |
import java.io.InputStreamReader;
|
7 |
import java.io.InputStreamReader;
|
| 11 |
import java.text.SimpleDateFormat;
|
8 |
import java.text.SimpleDateFormat;
|
| 12 |
import java.util.ArrayList;
|
9 |
import java.util.ArrayList;
|
| 13 |
import java.util.Calendar;
|
10 |
import java.util.Calendar;
|
| 14 |
import java.util.Date;
|
- |
|
| 15 |
import java.util.List;
|
11 |
import java.util.List;
|
| 16 |
|
12 |
|
| 17 |
import javax.mail.MessagingException;
|
13 |
import javax.mail.MessagingException;
|
| 18 |
|
14 |
|
| 19 |
import org.apache.http.HttpResponse;
|
15 |
import org.apache.http.HttpResponse;
|
| Line 25... |
Line 21... |
| 25 |
import org.apache.http.impl.client.DefaultHttpClient;
|
21 |
import org.apache.http.impl.client.DefaultHttpClient;
|
| 26 |
import org.apache.http.message.BasicNameValuePair;
|
22 |
import org.apache.http.message.BasicNameValuePair;
|
| 27 |
import org.json.JSONArray;
|
23 |
import org.json.JSONArray;
|
| 28 |
import org.json.JSONObject;
|
24 |
import org.json.JSONObject;
|
| 29 |
|
25 |
|
| 30 |
import com.google.gson.Gson;
|
- |
|
| 31 |
|
- |
|
| 32 |
public class FlipkartOrderStatusReconciliation{
|
26 |
public class FlipkartOrderStatusReconciliation{
|
| 33 |
static String emailFromAddress;
|
27 |
static String emailFromAddress;
|
| 34 |
static String password;
|
28 |
static String password;
|
| 35 |
static GmailUtils mailer;
|
29 |
static GmailUtils mailer;
|
| 36 |
static String sendTo[];
|
30 |
static String sendTo[];
|
| - |
|
31 |
private static String cookies;
|
| 37 |
|
32 |
|
| 38 |
static {
|
33 |
static {
|
| 39 |
emailFromAddress = "build-staging@shop2020.in";
|
34 |
emailFromAddress = "build-staging@shop2020.in";
|
| 40 |
password = "shop2020";
|
35 |
password = "shop2020";
|
| 41 |
mailer = new GmailUtils();
|
36 |
mailer = new GmailUtils();
|
| Line 55... |
Line 50... |
| 55 |
try {
|
50 |
try {
|
| 56 |
/*minCreationDate = 1386432631000l;new TransactionClient().getClient().getMinCreatedTimeStampUndeliveredOrdersForSource(OrderSource.FLIPKART.getValue());*/
|
51 |
/*minCreationDate = 1386432631000l;new TransactionClient().getClient().getMinCreatedTimeStampUndeliveredOrdersForSource(OrderSource.FLIPKART.getValue());*/
|
| 57 |
Calendar cal = Calendar.getInstance();
|
52 |
Calendar cal = Calendar.getInstance();
|
| 58 |
cal.add(Calendar.DAY_OF_MONTH, -30);
|
53 |
cal.add(Calendar.DAY_OF_MONTH, -30);
|
| 59 |
minCreationDate = cal.getTimeInMillis();
|
54 |
minCreationDate = cal.getTimeInMillis();
|
| - |
|
55 |
HttpGet get_new;
|
| - |
|
56 |
get_new = new HttpGet("https://seller.flipkart.com/");
|
| - |
|
57 |
get_new.addHeader("Host","seller.flipkart.com");
|
| - |
|
58 |
get_new.addHeader("User-agent", "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31");
|
| - |
|
59 |
get_new.addHeader("Connection","keep-alive");
|
| - |
|
60 |
|
| - |
|
61 |
HttpResponse response = client.execute(get_new);
|
| - |
|
62 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| - |
|
63 |
String line = "";
|
| - |
|
64 |
while ((line = rd.readLine()) != null) {
|
| - |
|
65 |
System.out.println(line);
|
| - |
|
66 |
}
|
| - |
|
67 |
cookies = response.getFirstHeader("Set-Cookie") == null ? "" :
|
| - |
|
68 |
response.getFirstHeader("Set-Cookie").getValue();
|
| - |
|
69 |
|
| - |
|
70 |
System.out.println("Cookies Before Login "+ cookies);
|
| - |
|
71 |
|
| 60 |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
|
72 |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
|
| 61 |
nameValuePairs.add(new BasicNameValuePair("authName",
|
73 |
nameValuePairs.add(new BasicNameValuePair("authName",
|
| 62 |
"flipkart"));
|
74 |
"flipkart"));
|
| 63 |
nameValuePairs.add(new BasicNameValuePair("username",
|
75 |
nameValuePairs.add(new BasicNameValuePair("username",
|
| 64 |
"flipkart-support@saholic.com"));
|
76 |
"flipkart-support@saholic.com"));
|
| 65 |
nameValuePairs.add(new BasicNameValuePair("password",
|
77 |
nameValuePairs.add(new BasicNameValuePair("password",
|
| 66 |
"bestmobiledeals2010"));
|
78 |
"bestmobiledeals2010"));
|
| 67 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
- |
|
| 68 |
post.addHeader("Cookie","__gads=ID=dfe0374cf04d1576:T=1381304511:S=ALNI_Ma2TpDrlF9_amkoqp3MOYJBaFAOUg; km_lv=x; S=d1t173VTuVxLMgd3in7R3mbHGNz0STqFkHgnidNrhKqBdz8wEKt%2BO9d%2B%2FRDHtf6fmq2ugaE7nZHV7zYSxOLcWBzq31A%3D%3D; __isReg=true; _ga=GA1.2.1156779613.1390806906; km_ai=m2z93iskuj81qiid; km_ni=m2z93iskuj81qiid; km_uq=; pincode=201301; __sonar=6631097455123118581; s_cc=true; s_sq=%5B%5BB%5D%5D; __utma=19769839.1733153395.1408690721.1416647806.1417179072.33; __utmc=19769839; __utmz=19769839.1415795608.26.5.utmcsr=savemoneyindia.com|utmccn=(referral)|utmcmd=referral|utmcct=/; SN=2.VIB1DBEC9C6CD94162ACB61060135212D1.SI47EBA2DE47044D0AA7C05F24AD4F42EB.VS141717906546900755654.1417179082; VID=2.VIB1DBEC9C6CD94162ACB61060135212D1.1417179082.VS141717906546900755654; NSID=2.SI47EBA2DE47044D0AA7C05F24AD4F42EB.1417179082.VIB1DBEC9C6CD94162ACB61060135212D1; T=TI138130450866706710769873257251497444628820234222703981199700765991; s_ppv=53; __CG=u%3A6208250296506778000%2Cs%3A1505183865%2Ct%3A1417179187815%2Cc%3A2%2Ck%3Awww.flipkart.com/30/77/1452%2Cf%3A0%2Ci%3A1; connect.sid=s%3AsMt6GmxeIzE45d0nKtsgQvNm.sea6W5znLeuulBNKyJu1%2FmvpO5xROchbo49GJMoHoFs; __utmt=1; __utma=143439159.1156779613.1390806906.1415709197.1417274947.45; __utmb=143439159.1.10.1417274947; __utmc=143439159; __utmz=143439159.1390806906.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)");
|
79 |
post.addHeader("Cookie",cookies);
|
| 69 |
post.addHeader("User-agent", "Mozilla/4.0");
|
80 |
post.addHeader("User-agent", "Mozilla/4.0");
|
| 70 |
post.addHeader("Referer", "seller.flipkart.com");
|
81 |
post.addHeader("Referer", "seller.flipkart.com");
|
| - |
|
82 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
| 71 |
HttpResponse response = client.execute(post);
|
83 |
response = client.execute(post);
|
| - |
|
84 |
cookies = response.getFirstHeader("Set-Cookie") == null ? "" :
|
| - |
|
85 |
response.getFirstHeader("Set-Cookie").getValue();
|
| - |
|
86 |
System.out.println("Cookies After Login "+cookies);
|
| 72 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
87 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 73 |
String line = "";
|
88 |
line = "";
|
| 74 |
Gson gson;
|
- |
|
| 75 |
List<Order> orders = new ArrayList<Order>();
|
- |
|
| 76 |
OrderItems new_orders;
|
- |
|
| 77 |
HttpGet get_new;
|
- |
|
| 78 |
|
89 |
|
| 79 |
long time;
|
- |
|
| 80 |
int i=1;
|
- |
|
| 81 |
while ((line = rd.readLine()) != null) {
|
90 |
while ((line = rd.readLine()) != null) {
|
| 82 |
System.out.println(line);
|
91 |
System.out.println(line);
|
| 83 |
}
|
92 |
}
|
| - |
|
93 |
|
| - |
|
94 |
long time;
|
| - |
|
95 |
int i=1;
|
| 84 |
time = System.currentTimeMillis();
|
96 |
time = System.currentTimeMillis();
|
| 85 |
|
97 |
|
| 86 |
outer:while(true){
|
98 |
outer:while(true){
|
| 87 |
get_new = new HttpGet("https://seller.flipkart.com/dashboard/som/shipped_order_items?status=delivered&page="+i+"&page_size=50&_="+time);
|
99 |
get_new = new HttpGet("https://seller.flipkart.com/dashboard/som/shipped_order_items?status=delivered&page="+i+"&page_size=50&_="+time);
|
| 88 |
get_new.addHeader("Cookie","__gads=ID=dfe0374cf04d1576:T=1381304511:S=ALNI_Ma2TpDrlF9_amkoqp3MOYJBaFAOUg; km_lv=x; S=d1t173VTuVxLMgd3in7R3mbHGNz0STqFkHgnidNrhKqBdz8wEKt%2BO9d%2B%2FRDHtf6fmq2ugaE7nZHV7zYSxOLcWBzq31A%3D%3D; __isReg=true; is_login=true; _ga=GA1.2.1156779613.1390806906; km_ai=m2z93iskuj81qiid; km_ni=m2z93iskuj81qiid; km_uq=; pincode=201301; __sonar=6631097455123118581; s_cc=true; s_sq=%5B%5BB%5D%5D; __utma=19769839.1733153395.1408690721.1416647806.1417179072.33; __utmc=19769839; __utmz=19769839.1415795608.26.5.utmcsr=savemoneyindia.com|utmccn=(referral)|utmcmd=referral|utmcct=/; SN=2.VIB1DBEC9C6CD94162ACB61060135212D1.SI47EBA2DE47044D0AA7C05F24AD4F42EB.VS141717906546900755654.1417179082; VID=2.VIB1DBEC9C6CD94162ACB61060135212D1.1417179082.VS141717906546900755654; NSID=2.SI47EBA2DE47044D0AA7C05F24AD4F42EB.1417179082.VIB1DBEC9C6CD94162ACB61060135212D1; T=TI138130450866706710769873257251497444628820234222703981199700765991; s_ppv=53; __CG=u%3A6208250296506778000%2Cs%3A1505183865%2Ct%3A1417179187815%2Cc%3A2%2Ck%3Awww.flipkart.com/30/77/1452%2Cf%3A0%2Ci%3A1; connect.sid=s%3AsMt6GmxeIzE45d0nKtsgQvNm.sea6W5znLeuulBNKyJu1%2FmvpO5xROchbo49GJMoHoFs; __utmt=1; __utma=143439159.1156779613.1390806906.1415709197.1417274947.45; __utmb=143439159.1.10.1417274947; __utmc=143439159; __utmz=143439159.1390806906.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)");
|
100 |
get_new.addHeader("Cookie",cookies+"; __utmt=1; __utma=143439159.1675929865.1422546011.1422546011.1422546011.1; __utmb=143439159.1.10.1422546011; __utmc=143439159; __utmz=143439159.1422546011.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); is_login=true; sellerId=m2z93iskuj81qiid");
|
| 89 |
//get_new.addHeader("Cookie","__gads=ID=dfe0374cf04d1576:T=1381304511:S=ALNI_Ma2TpDrlF9_amkoqp3MOYJBaFAOUg; km_lv=x; S=d1t173VTuVxLMgd3in7R3mbHGNz0STqFkHgnidNrhKqBdz8wEKt%2BO9d%2B%2FRDHtf6fmq2ugaE7nZHV7zYSxOLcWBzq31A%3D%3D; __isReg=true; pincode=201301; __sonar=6631097455123118581; s_cc=true; s_sq=%5B%5BB%5D%5D; __utma=19769839.1733153395.1408690721.1416647806.1417179072.33; __utmc=19769839; __utmz=19769839.1415795608.26.5.utmcsr=savemoneyindia.com|utmccn=(referral)|utmcmd=referral|utmcct=/; SN=2.VIB1DBEC9C6CD94162ACB61060135212D1.SI47EBA2DE47044D0AA7C05F24AD4F42EB.VS141717906546900755654.1417179082; VID=2.VIB1DBEC9C6CD94162ACB61060135212D1.1417179082.VS141717906546900755654; NSID=2.SI47EBA2DE47044D0AA7C05F24AD4F42EB.1417179082.VIB1DBEC9C6CD94162ACB61060135212D1; T=TI138130450866706710769873257251497444628820234222703981199700765991; s_ppv=53; __CG=u%3A6208250296506778000%2Cs%3A1505183865%2Ct%3A1417179187815%2Cc%3A2%2Ck%3Awww.flipkart.com/30/77/1452%2Cf%3A0%2Ci%3A1; is_login=true; sellerId=m2z93iskuj81qiid; __utma=143439159.1156779613.1390806906.1417274947.1417519426.46; __utmb=143439159.4.10.1417519426; __utmc=143439159; __utmz=143439159.1390806906.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.2.1156779613.1390806906; km_ai=m2z93iskuj81qiid; km_ni=m2z93iskuj81qiid; km_vs=1; km_uq=");
|
101 |
get_new.addHeader("Host","seller.flipkart.com");
|
| - |
|
102 |
get_new.addHeader("User-agent", "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31");
|
| - |
|
103 |
get_new.addHeader("Connection","keep-alive");
|
| 90 |
response = client.execute(get_new);
|
104 |
response = client.execute(get_new);
|
| 91 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
105 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 92 |
line = "";
|
106 |
line = "";
|
| 93 |
gson = new Gson();
|
- |
|
| 94 |
|
107 |
|
| 95 |
JSONObject jsonDataObj = null;
|
108 |
JSONObject jsonDataObj = null;
|
| 96 |
line = rd.readLine();
|
109 |
line = rd.readLine();
|
| 97 |
|
110 |
|
| 98 |
JSONArray jsonObjArr = null;
|
111 |
JSONArray jsonObjArr = null;
|