Subversion Repositories SmartDukaan

Rev

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

Rev 7953 Rev 8942
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.EmiScheme;
3
import in.shop2020.model.v1.order.LineItem;
4
import in.shop2020.model.v1.order.LineItem;
4
import in.shop2020.model.v1.order.Order;
5
import in.shop2020.model.v1.order.Order;
5
import in.shop2020.model.v1.order.OrderSource;
6
import in.shop2020.model.v1.order.OrderSource;
6
import in.shop2020.model.v1.order.RechargeOrder;
7
import in.shop2020.model.v1.order.RechargeOrder;
7
import in.shop2020.model.v1.order.Transaction;
8
import in.shop2020.model.v1.order.Transaction;
Line 12... Line 13...
12
import in.shop2020.model.v1.user.ShoppingCartException;
13
import in.shop2020.model.v1.user.ShoppingCartException;
13
import in.shop2020.logistics.PickUpType;
14
import in.shop2020.logistics.PickUpType;
14
import in.shop2020.payments.Payment;
15
import in.shop2020.payments.Payment;
15
import in.shop2020.payments.PaymentException;
16
import in.shop2020.payments.PaymentException;
16
import in.shop2020.payments.PaymentStatus;
17
import in.shop2020.payments.PaymentStatus;
-
 
18
import in.shop2020.serving.controllers.ProceedToPayController;
17
import in.shop2020.thrift.clients.PaymentClient;
19
import in.shop2020.thrift.clients.PaymentClient;
18
import in.shop2020.thrift.clients.PromotionClient;
20
import in.shop2020.thrift.clients.PromotionClient;
19
import in.shop2020.thrift.clients.TransactionClient;
21
import in.shop2020.thrift.clients.TransactionClient;
20
import in.shop2020.thrift.clients.UserClient;
22
import in.shop2020.thrift.clients.UserClient;
21
 
23
 
22
import java.util.HashMap;
24
import java.util.HashMap;
-
 
25
import java.util.List;
23
import java.util.Map;
26
import java.util.Map;
24
 
27
 
25
import org.apache.log4j.Logger;
28
import org.apache.log4j.Logger;
26
import org.apache.thrift.TException;
29
import org.apache.thrift.TException;
27
 
30
 
Line 261... Line 264...
261
			log.error("Unable to initialize user context service client", e);
264
			log.error("Unable to initialize user context service client", e);
262
			throw new TransactionServiceException(100, "Unable to initialize the user service client");
265
			throw new TransactionServiceException(100, "Unable to initialize the user service client");
263
		}
266
		}
264
		in.shop2020.model.v1.order.TransactionService.Client tClient = transactionServiceClient.getClient();
267
		in.shop2020.model.v1.order.TransactionService.Client tClient = transactionServiceClient.getClient();
265
		Transaction transaction = tClient.getTransaction(txnId);
268
		Transaction transaction = tClient.getTransaction(txnId);
266
		Map<Long, Double> miscCharges = tClient.getMiscCharges(txnId);
269
//		Map<Long, Double> miscCharges = tClient.getMiscCharges(txnId);
267
		System.out.println(miscCharges);
270
//		System.out.println(miscCharges);
268
		if(miscCharges != null & !miscCharges.isEmpty()){
271
//		if(miscCharges != null & !miscCharges.isEmpty()){
269
			totalAmount = totalAmount + miscCharges.get(1L);
272
//			totalAmount = totalAmount + miscCharges.get(1L);
270
		}
273
//		}
271
		for(Order order: transaction.getOrders()){
274
		for(Order order: transaction.getOrders()){
272
			totalAmount = totalAmount + order.getTotal_amount();
275
			totalAmount = totalAmount + order.getTotal_amount();
273
			gvAmount = gvAmount + order.getGvAmount();
276
			gvAmount = gvAmount + order.getGvAmount();
274
		}
277
		}
275
		if(gvAmount>0){
278
		if(gvAmount>0){
Line 368... Line 371...
368
        }
371
        }
369
        
372
        
370
        return true;
373
        return true;
371
    
374
    
372
    }
375
    }
-
 
376
    
-
 
377
    public static double calculateEmiAmount(String payOption, double totalAmount){
-
 
378
    	double emiAmount = 0.0;
-
 
379
    	List<EmiScheme> schemes = ProceedToPayController.getEmiSchemes();
-
 
380
    	for(EmiScheme scheme: schemes){
-
 
381
    		if(scheme.getId() == Long.parseLong(payOption)){
-
 
382
    			double interestRate = scheme.getInterestRate()/12/100;
-
 
383
    			emiAmount = totalAmount*interestRate*Math.pow((1+interestRate), scheme.getTenure())/(Math.pow((1+interestRate), scheme.getTenure())-1);
-
 
384
    		}
-
 
385
    	}
-
 
386
    	return emiAmount;
-
 
387
    }
-
 
388
    
373
    public static void main(String[] args) {
389
    public static void main(String[] args) {
374
    	Map<Long, Double> miscCharges = new HashMap<Long, Double>();
390
    	Map<Long, Double> miscCharges = new HashMap<Long, Double>();
375
    	miscCharges.put(1L, 3.988);
391
    	miscCharges.put(1L, 3.988);
376
    	System.out.println(miscCharges);
392
    	System.out.println(miscCharges);
377
		if(miscCharges != null & !miscCharges.isEmpty()){
393
		if(miscCharges != null & !miscCharges.isEmpty()){