Subversion Repositories SmartDukaan

Rev

Rev 8789 | Rev 8801 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8789 Rev 8800
Line 101... Line 101...
101
			in.shop2020.model.v1.user.UserContextService.Client userClient = new UserClient().getClient();
101
			in.shop2020.model.v1.user.UserContextService.Client userClient = new UserClient().getClient();
102
			user = userClient.getUserByEmail(sourceDetail.getEmail());
102
			user = userClient.getUserByEmail(sourceDetail.getEmail());
103
		} catch (Exception e) {
103
		} catch (Exception e) {
104
			logger.error("Unable to establish connection to the User service ", e);
104
			logger.error("Unable to establish connection to the User service ", e);
105
		}
105
		}
-
 
106
		int duplicate_orders = 0;
106
		int total_orders = 0;
107
		int new_orders = 0;
107
		int processed_orders = 0;
108
		int processed_orders = 0;
108
		StringBuffer sb = new StringBuffer();
109
		StringBuffer sb = new StringBuffer();
109
		for(Order order:orders.getOrder()){
110
		for(Order order:orders.getOrder()){
110
			long subOrderId = (long) order.getSuborderId();
111
			long subOrderId = (long) order.getSuborderId();
111
			Client transaction_client = null;
112
			Client transaction_client = null;
112
			try {
113
			try {
113
				transaction_client = new TransactionClient().getClient();
114
				transaction_client = new TransactionClient().getClient();
114
				if(transaction_client.snapdealOrderExists(subOrderId)) {
115
				if(transaction_client.snapdealOrderExists(subOrderId)) {
115
					logger.error("Snapdeal suborder id exists " + subOrderId);
116
					logger.error("Snapdeal suborder id exists " + subOrderId);
-
 
117
					duplicate_orders++;
116
					continue;
118
					continue;
117
				}
119
				}
118
 
120
 
119
			} catch (TTransportException e1) {
121
			} catch (TTransportException e1) {
120
				logger.error("Problem with Transaction service " , e1);
122
				logger.error("Problem with Transaction service " , e1);
121
				e1.printStackTrace();
123
				e1.printStackTrace();
122
			} catch (TException e) {
124
			} catch (TException e) {
123
				logger.error("Problem.. thrift exception with Transaction service " , e);
125
				logger.error("Problem.. thrift exception with Transaction service " , e);
124
				e.printStackTrace();
126
				e.printStackTrace();
125
			}
127
			}
126
			total_orders++;
128
			new_orders++;
127
			Transaction txn = new Transaction();
129
			Transaction txn = new Transaction();
128
			txn.setShoppingCartid(user.getActiveCartId());
130
			txn.setShoppingCartid(user.getActiveCartId());
129
			txn.setCustomer_id(user.getUserId());
131
			txn.setCustomer_id(user.getUserId());
130
			System.out.println("User Id is " + user.getUserId());
132
			System.out.println("User Id is " + user.getUserId());
131
			txn.setCreatedOn(new Date().getTime());
133
			txn.setCreatedOn(new Date().getTime());
Line 393... Line 395...
393
		Calendar cal=GregorianCalendar.getInstance();
395
		Calendar cal=GregorianCalendar.getInstance();
394
		String emailFromAddress = "build@shop2020.in";
396
		String emailFromAddress = "build@shop2020.in";
395
		String password = "cafe@nes";
397
		String password = "cafe@nes";
396
		GmailUtils mailer = new GmailUtils();
398
		GmailUtils mailer = new GmailUtils();
397
		try {
399
		try {
398
			if(total_orders==processed_orders && total_orders > 0){
400
			if(new_orders==processed_orders && new_orders > 0){
399
				String emailSubjectTxt = total_orders + " Snapdeal Orders Created Successfully "+sdf.format(cal.getTime());
401
				String emailSubjectTxt = "Snapdeal Orders Created Successfully "+sdf.format(cal.getTime());
400
				String text = "Order is now available for processing on Order Management Dashboard";
402
				String text = "Total Orders Received : " + ( new_orders + duplicate_orders ) + "\n" + 
-
 
403
				"Duplicate Orders Received : " + duplicate_orders + "\n" +
-
 
404
				"Processed Orders : " + processed_orders + "\n" +
-
 
405
				"Failed Orders : " + (new_orders - processed_orders);
401
				String sendTo[] = new String[]{"vikram.raghav@shop2020.in"};
406
				String sendTo[] = new String[]{"vikram.raghav@shop2020.in"};
402
				//String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in","khushal.bhatia@shop2020.in","rajveer.singh@saholic.com","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com"};
407
				//String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in","khushal.bhatia@shop2020.in","rajveer.singh@saholic.com","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com"};
403
				mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
408
				mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
404
			}
409
			}
405
			else if(total_orders > 0){
410
			else if(new_orders > 0){
-
 
411
				String emailSubjectTxt = "Snapdeal Orders Failed while creation "+sdf.format(cal.getTime());
-
 
412
				String text = "Total Orders Received : " + ( new_orders + duplicate_orders ) + "\n" + 
-
 
413
				"Duplicate Orders Received : " + duplicate_orders + "\n" +
-
 
414
				"Processed Orders : " + processed_orders + "\n" +
406
				int failed_orders = total_orders - processed_orders;
415
				"Failed Orders : " + (new_orders - processed_orders) + "\n"+ "\n" +
-
 
416
				sb.toString();
-
 
417
				String sendTo[] = new String[]{"vikram.raghav@shop2020.in"};
-
 
418
				//String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in","khushal.bhatia@shop2020.in","rajveer.singh@saholic.com","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com"};
-
 
419
				mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
-
 
420
			}
-
 
421
			else{
407
				String emailSubjectTxt = failed_orders + " Snapdeal Orders Failed while creation "+sdf.format(cal.getTime());
422
				String emailSubjectTxt = "No new Snapdeal Orders " + sdf.format(cal.getTime());
-
 
423
				String text = "Total Orders Received : " + ( new_orders + duplicate_orders ) + "\n" + 
-
 
424
				"Duplicate Orders Received : " + duplicate_orders + "\n" +
-
 
425
				"Processed Orders : " + processed_orders + "\n" +
-
 
426
				"Failed Orders : " + (new_orders - processed_orders) + "\n"+ "\n" +
408
				String text = sb.toString();
427
				sb.toString();
409
				String sendTo[] = new String[]{"vikram.raghav@shop2020.in"};
428
				String sendTo[] = new String[]{"vikram.raghav@shop2020.in"};
410
				//String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in","khushal.bhatia@shop2020.in","rajveer.singh@saholic.com","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com"};
429
				//String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in","khushal.bhatia@shop2020.in","rajveer.singh@saholic.com","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com"};
411
				mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
430
				mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
412
			}
431
			}
413
		}
432
		}