| 13584 |
manish.sha |
1 |
package in.shop2020.serving.services;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.model.v1.order.FlipkartFCWarehouseLocation;
|
|
|
4 |
import in.shop2020.model.v1.order.FlipkartFaSalesSnapshot;
|
|
|
5 |
import in.shop2020.utils.EmailUtils;
|
|
|
6 |
import in.shop2020.utils.FlipkartConsumer;
|
|
|
7 |
import in.shop2020.utils.GmailUtils;
|
|
|
8 |
|
|
|
9 |
import java.io.BufferedReader;
|
|
|
10 |
import java.io.File;
|
|
|
11 |
import java.io.FileWriter;
|
|
|
12 |
import java.io.IOException;
|
|
|
13 |
import java.io.InputStreamReader;
|
|
|
14 |
import java.text.SimpleDateFormat;
|
|
|
15 |
import java.util.ArrayList;
|
|
|
16 |
import java.util.Calendar;
|
|
|
17 |
import java.util.Date;
|
|
|
18 |
import java.util.HashMap;
|
|
|
19 |
import java.util.List;
|
|
|
20 |
import java.util.Map;
|
|
|
21 |
|
|
|
22 |
import org.apache.http.HttpResponse;
|
|
|
23 |
import org.apache.http.NameValuePair;
|
|
|
24 |
import org.apache.http.client.ClientProtocolException;
|
|
|
25 |
import org.apache.http.client.HttpClient;
|
|
|
26 |
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
27 |
import org.apache.http.client.methods.HttpGet;
|
|
|
28 |
import org.apache.http.client.methods.HttpPost;
|
|
|
29 |
import org.apache.http.entity.StringEntity;
|
|
|
30 |
import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
31 |
import org.apache.http.message.BasicNameValuePair;
|
|
|
32 |
import org.json.JSONException;
|
|
|
33 |
import org.json.JSONObject;
|
|
|
34 |
import org.slf4j.Logger;
|
|
|
35 |
import org.slf4j.LoggerFactory;
|
|
|
36 |
|
|
|
37 |
import au.com.bytecode.opencsv.CSVReader;
|
|
|
38 |
import au.com.bytecode.opencsv.CSVWriter;
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
public class FlipkartFaSaleSnapshotGetter{
|
|
|
42 |
private static Logger logger = LoggerFactory.getLogger(FlipkartFaSaleSnapshotGetter .class);
|
|
|
43 |
private static HttpClient client = new DefaultHttpClient();
|
| 13668 |
manish.sha |
44 |
private static String cookies;
|
| 13584 |
manish.sha |
45 |
|
|
|
46 |
public static String getCsrfValue() throws ClientProtocolException, IOException, JSONException{
|
|
|
47 |
HttpResponse response;
|
|
|
48 |
|
|
|
49 |
BufferedReader rd= null;
|
|
|
50 |
HttpGet get_new;
|
|
|
51 |
|
|
|
52 |
String line = "";
|
|
|
53 |
|
| 13613 |
manish.sha |
54 |
get_new = new HttpGet("https://seller.flipkart.com/sfx");
|
| 13668 |
manish.sha |
55 |
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");
|
|
|
56 |
get_new.addHeader("Host","seller.flipkart.com");
|
|
|
57 |
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");
|
|
|
58 |
get_new.addHeader("Connection","keep-alive");
|
|
|
59 |
|
| 13584 |
manish.sha |
60 |
response = client.execute(get_new);
|
|
|
61 |
|
|
|
62 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
63 |
|
|
|
64 |
String csrfVal = "";
|
|
|
65 |
while ((line = rd.readLine()) != null) {
|
|
|
66 |
if(line.contains("var seller = ")){
|
|
|
67 |
String desiredLine = line;
|
|
|
68 |
desiredLine = desiredLine.split("var seller = ")[1].trim();
|
|
|
69 |
desiredLine = desiredLine.substring(0, desiredLine.length()-1);
|
|
|
70 |
System.out.println("desiredLine... "+desiredLine);
|
|
|
71 |
JSONObject jsonObj = new JSONObject(desiredLine);
|
|
|
72 |
|
|
|
73 |
csrfVal=(String)jsonObj.get("csrf");
|
|
|
74 |
System.out.println(csrfVal);
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
return csrfVal;
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
public static void main(String[] args){
|
|
|
81 |
HttpPost post = new HttpPost("https://seller.flipkart.com/login");
|
|
|
82 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
83 |
SimpleDateFormat repSdf = new SimpleDateFormat("MM-dd-yyyy");
|
|
|
84 |
SimpleDateFormat flipkartRepFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy");
|
|
|
85 |
Calendar cal1 = Calendar.getInstance();
|
|
|
86 |
Calendar cal2 = Calendar.getInstance();
|
| 13669 |
manish.sha |
87 |
cal1.add(Calendar.DAY_OF_MONTH, -5);
|
| 13584 |
manish.sha |
88 |
String startDate = sdf.format(cal1.getTime());
|
|
|
89 |
//cal2.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
90 |
String endDate = sdf.format(cal2.getTime());
|
|
|
91 |
cal1.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
92 |
String repStartDate = repSdf.format(cal1.getTime());
|
|
|
93 |
cal2.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
94 |
String repEndDate = repSdf.format(cal2.getTime());
|
|
|
95 |
BufferedReader rd= null;
|
|
|
96 |
Map<Date,Map<String,FlipkartFaSalesSnapshot>> orderDateItemIdFbaSaleSnapshotMap = new HashMap<Date,Map<String,FlipkartFaSalesSnapshot>>();
|
|
|
97 |
List<FlipkartFaSalesSnapshot> flipkartFaSalesSnapshotList = new ArrayList<FlipkartFaSalesSnapshot>();
|
|
|
98 |
Map<Long, Double> skuInventoryPriceMap = new HashMap<Long, Double>();
|
|
|
99 |
try {
|
| 13668 |
manish.sha |
100 |
HttpGet get_new;
|
|
|
101 |
get_new = new HttpGet("https://seller.flipkart.com/");
|
|
|
102 |
get_new.addHeader("Host","seller.flipkart.com");
|
|
|
103 |
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");
|
|
|
104 |
get_new.addHeader("Connection","keep-alive");
|
|
|
105 |
|
|
|
106 |
HttpResponse response = client.execute(get_new);
|
|
|
107 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
108 |
String line = "";
|
|
|
109 |
while ((line = rd.readLine()) != null) {
|
|
|
110 |
System.out.println(line);
|
|
|
111 |
}
|
|
|
112 |
cookies = response.getFirstHeader("Set-Cookie") == null ? "" :
|
|
|
113 |
response.getFirstHeader("Set-Cookie").getValue();
|
|
|
114 |
|
|
|
115 |
System.out.println("Cookies Before Login "+ cookies);
|
|
|
116 |
|
| 13584 |
manish.sha |
117 |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
|
|
|
118 |
nameValuePairs.add(new BasicNameValuePair("authName",
|
|
|
119 |
"flipkart"));
|
|
|
120 |
nameValuePairs.add(new BasicNameValuePair("username",
|
|
|
121 |
"flipkart-support@saholic.com"));
|
|
|
122 |
nameValuePairs.add(new BasicNameValuePair("password",
|
|
|
123 |
"bestmobiledeals2010"));
|
| 13668 |
manish.sha |
124 |
post.addHeader("Cookie",cookies);
|
| 13584 |
manish.sha |
125 |
post.addHeader("User-agent", "Mozilla/4.0");
|
| 13668 |
manish.sha |
126 |
post.addHeader("Referer", "seller.flipkart.com");
|
| 13584 |
manish.sha |
127 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
| 13668 |
manish.sha |
128 |
response = client.execute(post);
|
|
|
129 |
cookies = response.getFirstHeader("Set-Cookie") == null ? "" :
|
|
|
130 |
response.getFirstHeader("Set-Cookie").getValue();
|
|
|
131 |
System.out.println("Cookies After Login "+cookies);
|
| 13584 |
manish.sha |
132 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 13668 |
manish.sha |
133 |
line = "";
|
|
|
134 |
|
| 13584 |
manish.sha |
135 |
while ((line = rd.readLine()) != null) {
|
|
|
136 |
System.out.println(line);
|
|
|
137 |
}
|
|
|
138 |
HttpPost post_1;
|
|
|
139 |
String csrfVal= getCsrfValue();
|
| 13602 |
manish.sha |
140 |
|
| 13584 |
manish.sha |
141 |
Thread.sleep(5000);
|
| 13602 |
manish.sha |
142 |
|
| 13584 |
manish.sha |
143 |
get_new = new HttpGet("https://seller.flipkart.com/sfx/inventory/stock/download?inventoryType=all&sellerId=m2z93iskuj81qiid&warehouse_id=del");
|
| 13668 |
manish.sha |
144 |
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");
|
|
|
145 |
get_new.addHeader("Host","seller.flipkart.com");
|
|
|
146 |
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");
|
|
|
147 |
get_new.addHeader("Connection","keep-alive");
|
|
|
148 |
|
| 13584 |
manish.sha |
149 |
response = client.execute(get_new);
|
|
|
150 |
|
|
|
151 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 13602 |
manish.sha |
152 |
|
| 13584 |
manish.sha |
153 |
CSVReader csvInventoryReader = new CSVReader(rd);
|
|
|
154 |
String[] values;
|
| 13611 |
manish.sha |
155 |
|
|
|
156 |
File inventoryFile = new File("/home/FAInventory.csv");
|
|
|
157 |
|
|
|
158 |
if(inventoryFile.exists()){
|
|
|
159 |
inventoryFile.delete();
|
|
|
160 |
}
|
| 13668 |
manish.sha |
161 |
int i=1;
|
| 13602 |
manish.sha |
162 |
|
| 13587 |
manish.sha |
163 |
CSVWriter writer = new CSVWriter(new FileWriter("/home/FAInventory.csv", true));
|
| 13584 |
manish.sha |
164 |
while ((values = csvInventoryReader.readNext()) != null) {
|
|
|
165 |
writer.writeNext(values);
|
|
|
166 |
if(i==1){
|
|
|
167 |
i++;
|
|
|
168 |
continue;
|
|
|
169 |
}
|
|
|
170 |
skuInventoryPriceMap.put(Long.parseLong(values[0]),Double.parseDouble(values[2]));
|
|
|
171 |
i++;
|
|
|
172 |
}
|
|
|
173 |
writer.close();
|
| 13602 |
manish.sha |
174 |
|
| 13584 |
manish.sha |
175 |
String paramVal = "{\"fromDate\":\""+startDate+"\",\"toDate\":\""+endDate+"\",\"warehouseId\":\"del\",\"type\":\"InvoiceReport\",\"_csrf\":\""+csrfVal+"\"}";
|
|
|
176 |
System.out.println(paramVal);
|
|
|
177 |
StringEntity entity = new StringEntity(paramVal, "utf-8");
|
| 13602 |
manish.sha |
178 |
|
|
|
179 |
|
| 13584 |
manish.sha |
180 |
post_1 = new HttpPost("https://seller.flipkart.com/sfx/reports/submit?sellerId=m2z93iskuj81qiid");
|
| 13668 |
manish.sha |
181 |
post_1.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");
|
| 13584 |
manish.sha |
182 |
post_1.addHeader("fk-csrf-token",csrfVal);
|
|
|
183 |
post_1.addHeader("Content-Type","application/json;charset=UTF-8");
|
|
|
184 |
post_1.addHeader("Host","seller.flipkart.com");
|
|
|
185 |
post_1.addHeader("Origin","https://seller.flipkart.com");
|
|
|
186 |
post_1.addHeader("Accept","application/json, text/plain, *//*");
|
|
|
187 |
post_1.addHeader("Accept-Language","en-US,en;q=0.8");
|
|
|
188 |
post_1.addHeader("Referer","https://seller.flipkart.com/sfx");
|
|
|
189 |
post_1.addHeader("User-Agent","Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36");
|
|
|
190 |
|
|
|
191 |
post_1.setEntity(entity);
|
|
|
192 |
|
|
|
193 |
response = client.execute(post_1);
|
| 13602 |
manish.sha |
194 |
|
| 13584 |
manish.sha |
195 |
response.getEntity().consumeContent();
|
|
|
196 |
|
|
|
197 |
Thread.sleep(120000);
|
| 13602 |
manish.sha |
198 |
|
| 13584 |
manish.sha |
199 |
//https://seller.flipkart.com/sfx/reports/download/?sellerId=m2z93iskuj81qiid&downloadurl=/reports/invoices/invoice_csv_m2z93iskuj81qiid_09-30-2014_10-30-2014/download_csv
|
|
|
200 |
get_new = new HttpGet("https://seller.flipkart.com/sfx/reports/download/?sellerId=m2z93iskuj81qiid&downloadurl=/reports/invoices/invoice_csv_m2z93iskuj81qiid_"+repStartDate+"_"+repEndDate+"/download_csv");
|
| 13668 |
manish.sha |
201 |
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");
|
|
|
202 |
get_new.addHeader("Host","seller.flipkart.com");
|
|
|
203 |
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");
|
|
|
204 |
get_new.addHeader("Connection","keep-alive");
|
|
|
205 |
|
| 13584 |
manish.sha |
206 |
response = client.execute(get_new);
|
|
|
207 |
|
| 13602 |
manish.sha |
208 |
|
| 13584 |
manish.sha |
209 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
| 13602 |
manish.sha |
210 |
|
| 13584 |
manish.sha |
211 |
i=1;
|
|
|
212 |
CSVReader csvReader = new CSVReader(rd);
|
|
|
213 |
while ((values = csvReader.readNext()) != null) {
|
|
|
214 |
if(i==1){
|
|
|
215 |
i++;
|
|
|
216 |
continue;
|
|
|
217 |
}
|
|
|
218 |
System.out.println(values[0]);
|
| 13602 |
manish.sha |
219 |
Date date = flipkartRepFormat.parse(values[5]);
|
| 13584 |
manish.sha |
220 |
Date date_key = sdf.parse(sdf.format(date));
|
| 13602 |
manish.sha |
221 |
if(!(values[12].equalsIgnoreCase("SalesInvoice")||values[12].equalsIgnoreCase("CourierReturnInvoice")||values[12].equalsIgnoreCase("CustomerReturnInvoice"))){
|
|
|
222 |
i++;
|
|
|
223 |
continue;
|
|
|
224 |
}
|
|
|
225 |
if(orderDateItemIdFbaSaleSnapshotMap.containsKey(date_key)){
|
|
|
226 |
FlipkartFaSalesSnapshot faSalesSnapshot;
|
|
|
227 |
if(orderDateItemIdFbaSaleSnapshotMap.get(date_key).containsKey(values[7])){
|
|
|
228 |
faSalesSnapshot = orderDateItemIdFbaSaleSnapshotMap.get(date_key).get(values[7]);
|
|
|
229 |
if(values[12].equalsIgnoreCase("SalesInvoice")){
|
|
|
230 |
faSalesSnapshot.setTotalOrderCount(faSalesSnapshot.getTotalOrderCount()+Integer.parseInt(values[13]));
|
|
|
231 |
faSalesSnapshot.setTotalSale(faSalesSnapshot.getTotalSale()+ Double.parseDouble(values[9]));
|
| 13584 |
manish.sha |
232 |
}
|
| 13602 |
manish.sha |
233 |
if(values[12].equalsIgnoreCase("CourierReturnInvoice")||values[12].equalsIgnoreCase("CustomerReturnInvoice")){
|
|
|
234 |
faSalesSnapshot.setTotalOrderCount(faSalesSnapshot.getTotalOrderCount()+0);
|
|
|
235 |
faSalesSnapshot.setTotalSale(faSalesSnapshot.getTotalSale()+0.0);
|
|
|
236 |
faSalesSnapshot.setReturnQuantity(faSalesSnapshot.getReturnQuantity()+Integer.parseInt(values[13]));
|
|
|
237 |
faSalesSnapshot.setReturnValue(faSalesSnapshot.getReturnValue()+Double.parseDouble(values[9]));
|
|
|
238 |
}
|
|
|
239 |
Map<String,FlipkartFaSalesSnapshot> itemIdFaSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date_key);
|
|
|
240 |
itemIdFaSnapshotMap.put(values[7], faSalesSnapshot);
|
|
|
241 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key, itemIdFaSnapshotMap);
|
|
|
242 |
} else{
|
|
|
243 |
faSalesSnapshot = new FlipkartFaSalesSnapshot();
|
| 13584 |
manish.sha |
244 |
faSalesSnapshot.setDateOfSale(date_key.getTime());
|
|
|
245 |
faSalesSnapshot.setItem_id(Long.parseLong(values[7]));
|
|
|
246 |
faSalesSnapshot.setOurPrice(Double.parseDouble(values[9])/Double.parseDouble(values[13]));
|
|
|
247 |
if(values[12].equalsIgnoreCase("SalesInvoice")){
|
|
|
248 |
faSalesSnapshot.setTotalOrderCount(Integer.parseInt(values[13]));
|
|
|
249 |
faSalesSnapshot.setTotalSale(Double.parseDouble(values[9]));
|
| 13602 |
manish.sha |
250 |
}
|
|
|
251 |
if(values[12].equalsIgnoreCase("CourierReturnInvoice")||values[12].equalsIgnoreCase("CustomerReturnInvoice")){
|
| 13584 |
manish.sha |
252 |
faSalesSnapshot.setTotalOrderCount(0);
|
|
|
253 |
faSalesSnapshot.setTotalSale(0.0);
|
|
|
254 |
faSalesSnapshot.setReturnQuantity(Integer.parseInt(values[13]));
|
|
|
255 |
faSalesSnapshot.setReturnValue(Double.parseDouble(values[9]));
|
|
|
256 |
}
|
|
|
257 |
faSalesSnapshot.setFcLocation(FlipkartFCWarehouseLocation.Delhi);
|
|
|
258 |
faSalesSnapshot.setIsOutOfStock(false);
|
| 13602 |
manish.sha |
259 |
Map<String,FlipkartFaSalesSnapshot> itemIdFaSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(date_key);
|
| 13584 |
manish.sha |
260 |
itemIdFaSnapshotMap.put(values[7], faSalesSnapshot);
|
|
|
261 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key, itemIdFaSnapshotMap);
|
|
|
262 |
}
|
| 13602 |
manish.sha |
263 |
} else {
|
|
|
264 |
FlipkartFaSalesSnapshot faSalesSnapshot = new FlipkartFaSalesSnapshot();
|
|
|
265 |
faSalesSnapshot.setDateOfSale(date_key.getTime());
|
|
|
266 |
faSalesSnapshot.setItem_id(Long.parseLong(values[7]));
|
|
|
267 |
faSalesSnapshot.setOurPrice(Double.parseDouble(values[9])/Double.parseDouble(values[13]));
|
|
|
268 |
if(values[12].equalsIgnoreCase("SalesInvoice")){
|
|
|
269 |
faSalesSnapshot.setTotalOrderCount(Integer.parseInt(values[13]));
|
|
|
270 |
faSalesSnapshot.setTotalSale(Double.parseDouble(values[9]));
|
|
|
271 |
}
|
|
|
272 |
if(values[12].equalsIgnoreCase("CourierReturnInvoice")||values[12].equalsIgnoreCase("CustomerReturnInvoice")){
|
|
|
273 |
faSalesSnapshot.setTotalOrderCount(0);
|
|
|
274 |
faSalesSnapshot.setTotalSale(0.0);
|
|
|
275 |
faSalesSnapshot.setReturnQuantity(Integer.parseInt(values[13]));
|
|
|
276 |
faSalesSnapshot.setReturnValue(Double.parseDouble(values[9]));
|
|
|
277 |
}
|
|
|
278 |
faSalesSnapshot.setFcLocation(FlipkartFCWarehouseLocation.Delhi);
|
|
|
279 |
faSalesSnapshot.setIsOutOfStock(false);
|
|
|
280 |
Map<String,FlipkartFaSalesSnapshot> itemIdFaSnapshotMap = new HashMap<String,FlipkartFaSalesSnapshot>();
|
|
|
281 |
itemIdFaSnapshotMap.put(values[7], faSalesSnapshot);
|
|
|
282 |
orderDateItemIdFbaSaleSnapshotMap.put(date_key, itemIdFaSnapshotMap);
|
|
|
283 |
}
|
|
|
284 |
i++;
|
| 13584 |
manish.sha |
285 |
}
|
| 13602 |
manish.sha |
286 |
|
| 13584 |
manish.sha |
287 |
for(Long itemId : skuInventoryPriceMap.keySet()){
|
|
|
288 |
for(Date dateOfSale : orderDateItemIdFbaSaleSnapshotMap.keySet()){
|
|
|
289 |
if(orderDateItemIdFbaSaleSnapshotMap.get(dateOfSale).containsKey(itemId.toString())){
|
|
|
290 |
continue;
|
|
|
291 |
}else{
|
|
|
292 |
FlipkartFaSalesSnapshot faSalesSnapshot = new FlipkartFaSalesSnapshot();
|
|
|
293 |
faSalesSnapshot.setItem_id(itemId);
|
|
|
294 |
faSalesSnapshot.setDateOfSale(dateOfSale.getTime());
|
|
|
295 |
faSalesSnapshot.setOurPrice(skuInventoryPriceMap.get(itemId));
|
|
|
296 |
faSalesSnapshot.setTotalOrderCount(0);
|
|
|
297 |
faSalesSnapshot.setTotalSale(0.0);
|
|
|
298 |
faSalesSnapshot.setReturnQuantity(0);
|
|
|
299 |
faSalesSnapshot.setReturnValue(0.0);
|
|
|
300 |
faSalesSnapshot.setIsOutOfStock(true);
|
|
|
301 |
faSalesSnapshot.setFcLocation(FlipkartFCWarehouseLocation.Delhi);
|
|
|
302 |
orderDateItemIdFbaSaleSnapshotMap.get(dateOfSale).put(itemId.toString(), faSalesSnapshot);
|
|
|
303 |
}
|
|
|
304 |
}
|
|
|
305 |
}
|
| 13602 |
manish.sha |
306 |
|
| 13584 |
manish.sha |
307 |
for(Date dateOfSale : orderDateItemIdFbaSaleSnapshotMap.keySet()){
|
|
|
308 |
Map<String,FlipkartFaSalesSnapshot> itemIdFaSnapshotMap = orderDateItemIdFbaSaleSnapshotMap.get(dateOfSale);
|
|
|
309 |
for(String itemId : itemIdFaSnapshotMap.keySet()){
|
|
|
310 |
flipkartFaSalesSnapshotList.add(itemIdFaSnapshotMap.get(itemId));
|
|
|
311 |
}
|
|
|
312 |
}
|
|
|
313 |
boolean valuesUpdated = FlipkartConsumer.bulkAddOrUpdateFlipkartFbaSalesSnapshot(flipkartFaSalesSnapshotList);
|
| 13602 |
manish.sha |
314 |
|
| 13584 |
manish.sha |
315 |
if(valuesUpdated){
|
|
|
316 |
System.out.println("Values are updated");
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
}
|
|
|
320 |
catch(Exception e){
|
| 13612 |
manish.sha |
321 |
e.printStackTrace();
|
| 13587 |
manish.sha |
322 |
String[] sendTo = new String[] { "manish.sharma@shop2020.in","kshitij.sood@shop2020.in","amit.gupta@shop2020.in","anikendra.das@shop2020.in"};
|
| 13602 |
manish.sha |
323 |
String emailSubjectTxt = "Error while generating Flipkart Sale Snapshot";
|
|
|
324 |
String message = "Run FlipkartFaSaleSnapshotGetter in Common Project. \nSend all Flipkart Reports Again. \nJobs are configured at Support-backup Machine";
|
|
|
325 |
try {
|
|
|
326 |
GmailUtils mailer = new GmailUtils();
|
| 13620 |
manish.sha |
327 |
mailer.sendSSLMessage(sendTo, emailSubjectTxt, message, "build-staging@shop2020.in", "shop2020", new ArrayList<File>());
|
| 13602 |
manish.sha |
328 |
} catch (Exception ex) {
|
|
|
329 |
ex.printStackTrace();
|
|
|
330 |
|
|
|
331 |
}
|
| 13584 |
manish.sha |
332 |
}
|
|
|
333 |
}
|
|
|
334 |
}
|