| 9776 |
vikram.rag |
1 |
package in.shop2020;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.model.v1.catalog.MarketPlaceItemPrice;
|
|
|
4 |
import in.shop2020.model.v1.catalog.SnapdealItemDetails;
|
|
|
5 |
import in.shop2020.thrift.clients.CatalogClient;
|
|
|
6 |
import in.shop2020.utils.GmailUtils;
|
|
|
7 |
import inventory.Inventory;
|
|
|
8 |
import inventory.InventoryHistoryItems;
|
|
|
9 |
|
|
|
10 |
import java.io.BufferedReader;
|
|
|
11 |
import java.io.File;
|
|
|
12 |
import java.io.FileInputStream;
|
|
|
13 |
import java.io.FileNotFoundException;
|
|
|
14 |
import java.io.FileOutputStream;
|
|
|
15 |
import java.io.IOException;
|
|
|
16 |
import java.io.InputStreamReader;
|
| 9858 |
vikram.rag |
17 |
import java.io.UnsupportedEncodingException;
|
| 9776 |
vikram.rag |
18 |
import java.text.SimpleDateFormat;
|
|
|
19 |
import java.util.ArrayList;
|
|
|
20 |
import java.util.HashMap;
|
|
|
21 |
import java.util.List;
|
|
|
22 |
import java.util.Map;
|
| 9821 |
vikram.rag |
23 |
import java.util.Map.Entry;
|
| 9776 |
vikram.rag |
24 |
|
|
|
25 |
import javax.mail.MessagingException;
|
|
|
26 |
|
|
|
27 |
import org.apache.http.HttpResponse;
|
|
|
28 |
import org.apache.http.NameValuePair;
|
|
|
29 |
import org.apache.http.client.ClientProtocolException;
|
|
|
30 |
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
31 |
import org.apache.http.client.methods.HttpGet;
|
|
|
32 |
import org.apache.http.client.methods.HttpPost;
|
|
|
33 |
import org.apache.http.entity.mime.MultipartEntity;
|
|
|
34 |
import org.apache.http.entity.mime.content.ContentBody;
|
|
|
35 |
import org.apache.http.entity.mime.content.FileBody;
|
|
|
36 |
import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
37 |
import org.apache.http.message.BasicNameValuePair;
|
|
|
38 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
39 |
import org.apache.poi.ss.usermodel.Row;
|
|
|
40 |
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
41 |
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
42 |
import org.apache.thrift.TException;
|
|
|
43 |
import org.apache.thrift.transport.TTransportException;
|
|
|
44 |
|
|
|
45 |
import pricing.CurrentPricing;
|
|
|
46 |
import pricing.CurrentPricingItems;
|
|
|
47 |
import pricing.PricingHistory;
|
|
|
48 |
import pricing.PricingHistoryItems;
|
|
|
49 |
|
|
|
50 |
import com.google.gson.Gson;
|
|
|
51 |
|
|
|
52 |
public class CreateSnapdealPricingFeed {
|
|
|
53 |
|
|
|
54 |
private static DefaultHttpClient client = new DefaultHttpClient();
|
|
|
55 |
private static long time = System.currentTimeMillis();
|
|
|
56 |
private static String SNAPDEAL_PRICING_SHEET;
|
|
|
57 |
static Map<String,SnapdealItemDetails> snapdealItemMap = new HashMap<String,SnapdealItemDetails>();
|
|
|
58 |
static Map<Long,SnapdealItemDetails> itemSnapdealMap = new HashMap<Long,SnapdealItemDetails>();
|
|
|
59 |
static List<MarketPlaceItemPrice> marketPlaceItemsPrices;
|
|
|
60 |
static Map<String,CurrentPricing> currentPricesMap = new HashMap<String,CurrentPricing>();
|
|
|
61 |
static PricingHistoryItems pricingHistoryItems;
|
|
|
62 |
static CurrentPricingItems currentPricingItems;
|
|
|
63 |
private static SimpleDateFormat sdf;
|
|
|
64 |
private static String emailFromAddress;
|
|
|
65 |
private static String password;
|
|
|
66 |
private static GmailUtils mailer;
|
|
|
67 |
private static String[] sendTo;
|
|
|
68 |
|
|
|
69 |
static {
|
|
|
70 |
sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
|
|
71 |
emailFromAddress = "build@shop2020.in";
|
|
|
72 |
password = "cafe@nes";
|
|
|
73 |
mailer = new GmailUtils();
|
| 9800 |
vikram.rag |
74 |
//sendTo = new String[]{"vikram.raghav@shop2020.in"};
|
|
|
75 |
sendTo = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
|
| 9776 |
vikram.rag |
76 |
"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
| 10254 |
manish.sha |
77 |
"yukti.jain@shop2020.in","manisha.sharma@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in"};
|
| 9776 |
vikram.rag |
78 |
CatalogClient catalogServiceClient = null;
|
|
|
79 |
try {
|
|
|
80 |
catalogServiceClient = new CatalogClient();
|
|
|
81 |
} catch (TTransportException e1) {
|
|
|
82 |
e1.printStackTrace();
|
|
|
83 |
}
|
|
|
84 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient.getClient();
|
|
|
85 |
List<SnapdealItemDetails> allSnapdealItems = null;
|
|
|
86 |
try {
|
|
|
87 |
allSnapdealItems = catalogClient.getAllSnapdealItems();
|
|
|
88 |
time = System.currentTimeMillis();
|
|
|
89 |
SNAPDEAL_PRICING_SHEET = "/home/snapdeal/snapdeal-pricing-"+time+".xls";
|
|
|
90 |
marketPlaceItemsPrices = catalogClient.getMarketPlaceItemsForPriceUpdate(7);
|
|
|
91 |
if(marketPlaceItemsPrices.size()==0){
|
|
|
92 |
System.out.println("No Change in Price to update");
|
|
|
93 |
try {
|
|
|
94 |
mailer.sendSSLMessage(sendTo,"No changes in Snapdeal Item Prices "+ sdf.format(System.currentTimeMillis()),"No change in Snapdeal Prices to be update ", emailFromAddress, password, new ArrayList<File>());
|
|
|
95 |
} catch (MessagingException e) {
|
|
|
96 |
e.printStackTrace();
|
|
|
97 |
}
|
|
|
98 |
System.exit(0);
|
|
|
99 |
}
|
|
|
100 |
} catch (TException e) {
|
|
|
101 |
e.printStackTrace();
|
|
|
102 |
}
|
|
|
103 |
for(SnapdealItemDetails snapdealItem:allSnapdealItems){
|
|
|
104 |
snapdealItemMap.put(snapdealItem.getSkuAtSnapdeal(),snapdealItem);
|
|
|
105 |
itemSnapdealMap.put(snapdealItem.getItem_id(), snapdealItem);
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
}
|
| 9858 |
vikram.rag |
109 |
public static void handleLogin() throws ClientProtocolException, IOException{
|
|
|
110 |
HttpGet get = new HttpGet("http://selleraccounts.snapdeal.com/keymaker/login");
|
| 9776 |
vikram.rag |
111 |
HttpResponse response = null;
|
|
|
112 |
try {
|
| 9858 |
vikram.rag |
113 |
response = client.execute(get);
|
| 9776 |
vikram.rag |
114 |
} catch (ClientProtocolException e) {
|
|
|
115 |
// TODO Auto-generated catch block
|
|
|
116 |
e.printStackTrace();
|
|
|
117 |
} catch (IOException e) {
|
|
|
118 |
// TODO Auto-generated catch block
|
|
|
119 |
e.printStackTrace();
|
|
|
120 |
}
|
| 9858 |
vikram.rag |
121 |
BufferedReader rd = null;
|
| 9776 |
vikram.rag |
122 |
try {
|
|
|
123 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
124 |
} catch (IllegalStateException e1) {
|
| 9891 |
vikram.rag |
125 |
// TODO Auto-generated catch block
|
| 9776 |
vikram.rag |
126 |
e1.printStackTrace();
|
|
|
127 |
} catch (IOException e1) {
|
|
|
128 |
// TODO Auto-generated catch block
|
|
|
129 |
e1.printStackTrace();
|
|
|
130 |
}
|
|
|
131 |
String line = "";
|
| 9858 |
vikram.rag |
132 |
StringBuffer sb = new StringBuffer();
|
| 9776 |
vikram.rag |
133 |
try {
|
|
|
134 |
while ((line = rd.readLine()) != null) {
|
| 9858 |
vikram.rag |
135 |
sb.append(line);
|
|
|
136 |
System.out.println(line);
|
| 9776 |
vikram.rag |
137 |
}
|
|
|
138 |
} catch (IOException e) {
|
|
|
139 |
// TODO Auto-generated catch block
|
|
|
140 |
e.printStackTrace();
|
|
|
141 |
}
|
| 9858 |
vikram.rag |
142 |
int i= sb.toString().indexOf("name=\"lt\" value=");
|
|
|
143 |
char[] charArray = sb.toString().toCharArray();
|
|
|
144 |
String lt = "";
|
|
|
145 |
int j=0;
|
|
|
146 |
for(j=i+16;j<=charArray.length;j++){
|
|
|
147 |
|
|
|
148 |
if(charArray[j]==' '){
|
|
|
149 |
break;
|
|
|
150 |
}
|
|
|
151 |
}
|
|
|
152 |
lt = sb.substring(i+17,j-1);
|
|
|
153 |
System.out.println("LT VALUE " + lt);
|
|
|
154 |
i= sb.toString().indexOf("name=\"execution\" value=");
|
|
|
155 |
charArray = sb.toString().toCharArray();
|
|
|
156 |
String ex = "";
|
|
|
157 |
j=0;
|
|
|
158 |
for(j=i+24;j<=charArray.length;j++){
|
|
|
159 |
if(charArray[j]==' '){
|
|
|
160 |
break;
|
|
|
161 |
}
|
|
|
162 |
}
|
|
|
163 |
ex = sb.substring(i+24,j-1);
|
|
|
164 |
System.out.println("EXECUTION VALUE " + ex);
|
| 10038 |
vikram.rag |
165 |
HttpPost post = new HttpPost("http://selleraccounts.snapdeal.com/login?service=http%3A%2F%2Fseller.snapdeal.com%2Fj_spring_cas_security_check");
|
| 9858 |
vikram.rag |
166 |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
|
| 10019 |
vikram.rag |
167 |
//nameValuePairs.add(new BasicNameValuePair("username",
|
|
|
168 |
//"khushal.bhatia@saholic.com"));
|
| 9858 |
vikram.rag |
169 |
nameValuePairs.add(new BasicNameValuePair("username",
|
| 10019 |
vikram.rag |
170 |
"saholic-snapdeal@saholic.com"));
|
|
|
171 |
//nameValuePairs.add(new BasicNameValuePair("password",
|
|
|
172 |
//"sonline"));
|
| 9858 |
vikram.rag |
173 |
nameValuePairs.add(new BasicNameValuePair("password",
|
| 10019 |
vikram.rag |
174 |
"bc452ce4"));
|
| 9858 |
vikram.rag |
175 |
nameValuePairs.add(new BasicNameValuePair("_eventId","submit"));
|
|
|
176 |
nameValuePairs.add(new BasicNameValuePair("execution",ex));
|
|
|
177 |
nameValuePairs.add(new BasicNameValuePair("lt",lt));
|
|
|
178 |
nameValuePairs.add(new BasicNameValuePair("submit","LOGIN"));
|
|
|
179 |
post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
|
|
180 |
response = client.execute(post);
|
|
|
181 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
182 |
line = "";
|
|
|
183 |
while ((line = rd.readLine()) != null) {
|
|
|
184 |
//System.out.println(line);
|
|
|
185 |
}
|
|
|
186 |
get = new HttpGet("http://seller.snapdeal.com/pricing/");
|
|
|
187 |
response = client.execute(get);
|
|
|
188 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
189 |
while ((line = rd.readLine()) != null) {
|
|
|
190 |
//System.out.println(line);
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
public static void main(String... args) throws IOException, InterruptedException{
|
|
|
196 |
handleLogin();
|
|
|
197 |
HttpGet get;
|
|
|
198 |
BufferedReader rd= null;
|
| 9776 |
vikram.rag |
199 |
Gson gson = new Gson();
|
|
|
200 |
int i = 1;
|
|
|
201 |
boolean exitfetchingcurrent = true;
|
|
|
202 |
System.out.println("Fetching current prices");
|
| 9858 |
vikram.rag |
203 |
HttpResponse response;
|
| 9776 |
vikram.rag |
204 |
while(exitfetchingcurrent){
|
|
|
205 |
get = new HttpGet("http://seller.snapdeal.com/pricing/search?gridType=normal&_search=false&nd="+time+"&rows=30&page="+i+"&sidx=&sord=asc");
|
|
|
206 |
response = client.execute(get);
|
|
|
207 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
208 |
currentPricingItems = (CurrentPricingItems) gson.fromJson(rd, CurrentPricingItems.class);
|
|
|
209 |
if(currentPricingItems.getRows().size()!=0){
|
|
|
210 |
for(CurrentPricing currentPricing:currentPricingItems.getRows()){
|
|
|
211 |
currentPricesMap.put(currentPricing.getSellerSku(),currentPricing);
|
| 9891 |
vikram.rag |
212 |
System.out.println(currentPricing.getSellerSku()+" "+currentPricing.getSellingPrice());
|
| 9776 |
vikram.rag |
213 |
}
|
|
|
214 |
}
|
|
|
215 |
else{
|
|
|
216 |
exitfetchingcurrent = false;
|
|
|
217 |
}
|
|
|
218 |
i++;
|
|
|
219 |
}
|
|
|
220 |
FileInputStream fis = new FileInputStream("/root/code/trunk/SnapDealFeeds/SellerPricing.xls");
|
|
|
221 |
Workbook hwb = new HSSFWorkbook(fis);
|
|
|
222 |
Sheet sheet = hwb.getSheetAt(0);
|
|
|
223 |
Row row;
|
|
|
224 |
int iterator = 1;
|
| 9821 |
vikram.rag |
225 |
Map<String,Double> toUpdateSkuMap = new HashMap<String,Double>();
|
| 9776 |
vikram.rag |
226 |
for(MarketPlaceItemPrice marketPlaceItemPrice:marketPlaceItemsPrices){
|
|
|
227 |
System.out.println(marketPlaceItemPrice.getItem_id() + " " + marketPlaceItemPrice.getSellingPrice());
|
|
|
228 |
if(itemSnapdealMap.containsKey(marketPlaceItemPrice.getItem_id()) && marketPlaceItemPrice.getLastUpdatedOn() > marketPlaceItemPrice.getLastUpdatedOnMarketplace() && !marketPlaceItemPrice.isIsPriceOverride() && marketPlaceItemPrice.isIsListedOnSource()){
|
|
|
229 |
if(currentPricesMap.containsKey(itemSnapdealMap.get(marketPlaceItemPrice.getItem_id()).getSkuAtSnapdeal()) && Double.parseDouble(currentPricesMap.get(itemSnapdealMap.get(marketPlaceItemPrice.getItem_id()).getSkuAtSnapdeal()).getSellingPrice()) != marketPlaceItemPrice.getSellingPrice() && marketPlaceItemPrice.getSellingPrice()!=0){
|
| 9799 |
vikram.rag |
230 |
row = sheet.getRow((short) iterator);
|
| 9776 |
vikram.rag |
231 |
row.getCell((short) 0).setCellValue(currentPricesMap.get(itemSnapdealMap.get(marketPlaceItemPrice.getItem_id()).getSkuAtSnapdeal()).getSupc());
|
|
|
232 |
row.getCell((short) 1).setCellValue(itemSnapdealMap.get(marketPlaceItemPrice.getItem_id()).getSkuAtSnapdeal());
|
|
|
233 |
row.getCell((short) 2).setCellValue(currentPricesMap.get(itemSnapdealMap.get(marketPlaceItemPrice.getItem_id()).getSkuAtSnapdeal()).getProductName());
|
|
|
234 |
row.getCell((short) 3).setCellValue(marketPlaceItemPrice.getSellingPrice());
|
|
|
235 |
row.getCell((short) 4).setCellValue(currentPricesMap.get(itemSnapdealMap.get(marketPlaceItemPrice.getItem_id()).getSkuAtSnapdeal()).getLive());
|
| 9821 |
vikram.rag |
236 |
toUpdateSkuMap.put(itemSnapdealMap.get(marketPlaceItemPrice.getItem_id()).getSkuAtSnapdeal(),marketPlaceItemPrice.getSellingPrice());
|
| 9776 |
vikram.rag |
237 |
iterator++;
|
|
|
238 |
}
|
|
|
239 |
}
|
|
|
240 |
}
|
|
|
241 |
if(iterator!=1){
|
|
|
242 |
FileOutputStream fileOut = null;
|
|
|
243 |
fis.close();
|
|
|
244 |
try {
|
|
|
245 |
System.out.println("Before writing file ");
|
|
|
246 |
fileOut = new FileOutputStream(SNAPDEAL_PRICING_SHEET);
|
|
|
247 |
} catch (FileNotFoundException e) {
|
|
|
248 |
e.printStackTrace();
|
|
|
249 |
}
|
|
|
250 |
try {
|
|
|
251 |
|
|
|
252 |
hwb.write(fileOut);
|
|
|
253 |
} catch (IOException e) {
|
|
|
254 |
e.printStackTrace();
|
|
|
255 |
}
|
| 11121 |
vikram.rag |
256 |
HttpPost post = new HttpPost("http://seller.snapdeal.com/pricing/upload?uploadType=SP");
|
| 9776 |
vikram.rag |
257 |
File file = new File(SNAPDEAL_PRICING_SHEET);
|
|
|
258 |
MultipartEntity mpEntity = new MultipartEntity();
|
|
|
259 |
ContentBody cbFile = new FileBody(file,"application/vnd.ms-excel");
|
|
|
260 |
mpEntity.addPart("file", cbFile);
|
|
|
261 |
post.setEntity(mpEntity);
|
|
|
262 |
response = client.execute(post);
|
|
|
263 |
try {
|
|
|
264 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
265 |
} catch (IllegalStateException e1) {
|
|
|
266 |
e1.printStackTrace();
|
|
|
267 |
} catch (IOException e1) {
|
|
|
268 |
e1.printStackTrace();
|
|
|
269 |
}
|
| 9858 |
vikram.rag |
270 |
String line = "";
|
| 9776 |
vikram.rag |
271 |
String feedresponse = null;
|
|
|
272 |
try {
|
|
|
273 |
while ((line = rd.readLine()) != null) {
|
|
|
274 |
feedresponse = line;
|
|
|
275 |
}
|
|
|
276 |
} catch (IOException e) {
|
|
|
277 |
e.printStackTrace();
|
|
|
278 |
}
|
|
|
279 |
int retry = 5;
|
|
|
280 |
boolean exitfetchinghistory;
|
|
|
281 |
int successfullyUpdated;
|
| 9821 |
vikram.rag |
282 |
Map<String,Double> updatedSkuMap = new HashMap<String,Double>();
|
| 9776 |
vikram.rag |
283 |
System.out.println("Feed response " + feedresponse);
|
|
|
284 |
if(feedresponse.contains("Error")){
|
|
|
285 |
System.out.println("Error while uploading sheet");
|
|
|
286 |
try {
|
| 9891 |
vikram.rag |
287 |
mailer.sendSSLMessage(sendTo,"Error at Snapdeal while Uploading Pricing feed "+ sdf.format(System.currentTimeMillis()),"This Error means that there is some problem while uploading pricing feed to snapdeal", emailFromAddress, password, new ArrayList<File>());
|
| 9776 |
vikram.rag |
288 |
} catch (MessagingException e) {
|
|
|
289 |
e.printStackTrace();
|
|
|
290 |
}
|
|
|
291 |
System.exit(0);
|
|
|
292 |
}
|
|
|
293 |
String uploadId = "UID"+feedresponse.split("UID")[1];
|
|
|
294 |
System.out.println("Feed Upload Id is " + uploadId);
|
|
|
295 |
int j = 1;
|
|
|
296 |
i=1;
|
|
|
297 |
while(retry > 0){
|
|
|
298 |
Thread.sleep(5*60*1000);
|
|
|
299 |
exitfetchinghistory = true;
|
|
|
300 |
System.out.println("Fetching history prices " + j);
|
|
|
301 |
successfullyUpdated =0;
|
|
|
302 |
while(exitfetchinghistory){
|
|
|
303 |
get = new HttpGet("http://seller.snapdeal.com/pricing/search?gridType=history&_search=false&nd="+time+"&rows=30&page="+i+"&sidx=&sord=asc");
|
|
|
304 |
response = client.execute(get);
|
|
|
305 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
306 |
pricingHistoryItems = (PricingHistoryItems) gson.fromJson(rd, PricingHistoryItems.class);
|
| 9778 |
vikram.rag |
307 |
if(pricingHistoryItems.getRows().size()!=0 && successfullyUpdated != (iterator - 1)){
|
| 9776 |
vikram.rag |
308 |
for(PricingHistory pricingHistory:pricingHistoryItems.getRows()){
|
|
|
309 |
if(Long.parseLong(pricingHistory.getModifiedOn()) > time && pricingHistory.getApprovalStatus().equals("Done") && pricingHistory.getUploadId().equals(uploadId)){
|
|
|
310 |
successfullyUpdated++;
|
| 9821 |
vikram.rag |
311 |
updatedSkuMap.put(pricingHistory.getSellerSku(),Double.parseDouble(pricingHistory.getLineitems().get(0).getNewValue()));
|
| 9778 |
vikram.rag |
312 |
System.out.println("SKU Updated " + pricingHistory.getSellerSku() + " " + pricingHistory.getUploadId());
|
| 9776 |
vikram.rag |
313 |
}
|
|
|
314 |
}
|
|
|
315 |
}
|
|
|
316 |
else{
|
|
|
317 |
exitfetchinghistory = false;
|
| 9778 |
vikram.rag |
318 |
if(successfullyUpdated == (iterator-1)){
|
| 9776 |
vikram.rag |
319 |
retry = 0;
|
|
|
320 |
}
|
|
|
321 |
}
|
|
|
322 |
i++;
|
|
|
323 |
}
|
|
|
324 |
retry--;
|
|
|
325 |
j++;
|
|
|
326 |
}
|
|
|
327 |
CatalogClient catalogServiceClient = null;
|
|
|
328 |
try {
|
|
|
329 |
catalogServiceClient = new CatalogClient();
|
|
|
330 |
} catch (TTransportException e1) {
|
|
|
331 |
e1.printStackTrace();
|
|
|
332 |
}
|
|
|
333 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient.getClient();
|
|
|
334 |
List<Long> updatedItems = new ArrayList<Long>();
|
| 9821 |
vikram.rag |
335 |
String tableHeader = "<tr>"
|
|
|
336 |
+ "<td>" + "Product Name" +"</td>"
|
|
|
337 |
+"<td>" + "Item ID" + "</td>"
|
|
|
338 |
+"<td>" + "SKU at Snapdeal" + "</td>"
|
|
|
339 |
+"<td>" + "Old Price" + "</td>"
|
|
|
340 |
+"<td>" + "New Price" + "</td>"
|
|
|
341 |
+"</tr>";
|
|
|
342 |
if(toUpdateSkuMap.size() != updatedSkuMap.size()){
|
|
|
343 |
StringBuffer notUpdatedMailBody =new StringBuffer();
|
|
|
344 |
for(Entry<String, Double> entry:updatedSkuMap.entrySet()){
|
|
|
345 |
toUpdateSkuMap.remove(entry.getKey());
|
|
|
346 |
}
|
|
|
347 |
for(Entry<String, Double> entry:toUpdateSkuMap.entrySet()){
|
|
|
348 |
notUpdatedMailBody.append("<tr>" + "<td>" + currentPricesMap.get(entry.getKey()).getProductName() + "</td>"
|
| 9824 |
vikram.rag |
349 |
+"<td>" + snapdealItemMap.get(entry.getKey()).getItem_id() + "</td>"
|
|
|
350 |
+"<td>" + snapdealItemMap.get(entry.getKey()).getSkuAtSnapdeal() + "</td>"
|
|
|
351 |
+"<td>" + currentPricesMap.get(entry.getKey()).getSellingPrice() + "</td>"
|
|
|
352 |
+"<td>" + entry.getValue() +"</td>");
|
|
|
353 |
|
| 9821 |
vikram.rag |
354 |
}
|
|
|
355 |
String text = "<html><table border=\"1\" align=\"center\">"
|
| 9824 |
vikram.rag |
356 |
+ tableHeader
|
|
|
357 |
+ notUpdatedMailBody.toString() + "</table></html>";
|
|
|
358 |
|
| 9776 |
vikram.rag |
359 |
System.out.println("SKUs not updated");
|
|
|
360 |
try {
|
| 9821 |
vikram.rag |
361 |
mailer.sendSSLMessage(sendTo,"Snapdeal Item Prices were not updated "+ sdf.format(System.currentTimeMillis()),emailFromAddress, password, text);
|
| 9776 |
vikram.rag |
362 |
} catch (MessagingException e) {
|
|
|
363 |
e.printStackTrace();
|
|
|
364 |
}
|
| 9824 |
vikram.rag |
365 |
|
| 9776 |
vikram.rag |
366 |
}
|
| 9821 |
vikram.rag |
367 |
if(updatedSkuMap.size()>0){
|
|
|
368 |
StringBuffer updatedMailBody =new StringBuffer();
|
|
|
369 |
for(Entry<String, Double> entry:updatedSkuMap.entrySet()){
|
|
|
370 |
updatedMailBody.append("<tr>" + "<td>" + currentPricesMap.get(entry.getKey()).getProductName() + "</td>"
|
|
|
371 |
+"<td>" + snapdealItemMap.get(entry.getKey()).getItem_id() + "</td>"
|
| 9824 |
vikram.rag |
372 |
+"<td>" + snapdealItemMap.get(entry.getKey()).getSkuAtSnapdeal() + "</td>"
|
| 9821 |
vikram.rag |
373 |
+"<td>" + currentPricesMap.get(entry.getKey()).getSellingPrice() + "</td>"
|
|
|
374 |
+"<td>" + entry.getValue() +"</td>");
|
| 9824 |
vikram.rag |
375 |
updatedItems.add(snapdealItemMap.get(entry.getKey()).getItem_id());
|
| 9776 |
vikram.rag |
376 |
}
|
|
|
377 |
try {
|
| 9817 |
vikram.rag |
378 |
catalogClient.updateMarketPlacePriceUpdateStatus(updatedItems,time,7);
|
| 9776 |
vikram.rag |
379 |
} catch (TException e) {
|
|
|
380 |
try {
|
| 9817 |
vikram.rag |
381 |
new CatalogClient().getClient().updateMarketPlacePriceUpdateStatus(updatedItems, time,7);
|
| 9776 |
vikram.rag |
382 |
} catch (TTransportException e1) {
|
|
|
383 |
e1.printStackTrace();
|
|
|
384 |
} catch (TException e1) {
|
|
|
385 |
e1.printStackTrace();
|
|
|
386 |
}
|
|
|
387 |
e.printStackTrace();
|
|
|
388 |
}
|
| 9821 |
vikram.rag |
389 |
String text = "<html><table border=\"1\" align=\"center\">"
|
|
|
390 |
+ tableHeader
|
|
|
391 |
+ updatedMailBody.toString() + "</table></html>";
|
| 9824 |
vikram.rag |
392 |
|
| 9776 |
vikram.rag |
393 |
try {
|
| 9778 |
vikram.rag |
394 |
System.out.println("Snapdeal Item Prices updated Successfully");
|
| 9821 |
vikram.rag |
395 |
if(updatedSkuMap.size()==1){
|
|
|
396 |
mailer.sendSSLMessage(sendTo,updatedSkuMap.size()+" Snapdeal Item Price updated Successfully "+ sdf.format(System.currentTimeMillis()), emailFromAddress, password,text);
|
| 9797 |
vikram.rag |
397 |
}
|
|
|
398 |
else{
|
| 9821 |
vikram.rag |
399 |
mailer.sendSSLMessage(sendTo,updatedSkuMap.size()+" Snapdeal Items Price updated Successfully "+ sdf.format(System.currentTimeMillis()), emailFromAddress, password,text);
|
| 9797 |
vikram.rag |
400 |
}
|
| 9776 |
vikram.rag |
401 |
} catch (MessagingException e) {
|
|
|
402 |
e.printStackTrace();
|
|
|
403 |
}
|
|
|
404 |
}
|
|
|
405 |
}
|
|
|
406 |
else{
|
|
|
407 |
try {
|
|
|
408 |
System.out.println("Prices are same as the snapdeal prices");
|
|
|
409 |
mailer.sendSSLMessage(sendTo,"No changes in Snapdeal Item Prices "+ sdf.format(System.currentTimeMillis()),"No change in Snapdeal Prices to be update ", emailFromAddress, password, new ArrayList<File>());
|
|
|
410 |
} catch (MessagingException e) {
|
|
|
411 |
e.printStackTrace();
|
|
|
412 |
}
|
| 9824 |
vikram.rag |
413 |
|
| 9776 |
vikram.rag |
414 |
}
|
|
|
415 |
|
|
|
416 |
}
|
|
|
417 |
|
|
|
418 |
|
|
|
419 |
}
|