Subversion Repositories SmartDukaan

Rev

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

Rev 3126 Rev 3209
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
-
 
3
import in.shop2020.datalogger.EventType;
3
import in.shop2020.model.v1.catalog.Item;
4
import in.shop2020.model.v1.catalog.Item;
4
import in.shop2020.model.v1.user.Address;
5
import in.shop2020.model.v1.user.Address;
5
import in.shop2020.model.v1.user.Cart;
6
import in.shop2020.model.v1.user.Cart;
6
import in.shop2020.model.v1.user.Line;
7
import in.shop2020.model.v1.user.Line;
7
import in.shop2020.serving.utils.FormattingUtils;
8
import in.shop2020.serving.utils.FormattingUtils;
-
 
9
import in.shop2020.serving.utils.Utils;
8
import in.shop2020.thrift.clients.CatalogClient;
10
import in.shop2020.thrift.clients.CatalogClient;
9
import in.shop2020.thrift.clients.LogisticsClient;
11
import in.shop2020.thrift.clients.LogisticsClient;
10
import in.shop2020.thrift.clients.UserClient;
12
import in.shop2020.thrift.clients.UserClient;
-
 
13
import in.shop2020.utils.DataLogger;
11
 
14
 
12
import java.util.Collection;
15
import java.util.Collection;
13
import java.util.List;
16
import java.util.List;
14
import java.util.ResourceBundle;
17
import java.util.ResourceBundle;
15
 
18
 
Line 68... Line 71...
68
        UserClient userContextServiceClient = null;
71
        UserClient userContextServiceClient = null;
69
        in.shop2020.model.v1.user.UserContextService.Client userClient = null;
72
        in.shop2020.model.v1.user.UserContextService.Client userClient = null;
70
        
73
        
71
        Address address;
74
        Address address;
72
        List<Line> lineItems;
75
        List<Line> lineItems;
73
        
76
        String itemIdString = "";
74
        try {
77
        try {
75
            userContextServiceClient = new UserClient();
78
            userContextServiceClient = new UserClient();
76
            userClient = userContextServiceClient.getClient();
79
            userClient = userContextServiceClient.getClient();
77
            
80
            
78
            long cartId = userinfo.getCartId();
81
            long cartId = userinfo.getCartId();
Line 82... Line 85...
82
            errorMsg = userClient.validateCart(cartId);
85
            errorMsg = userClient.validateCart(cartId);
83
            
86
            
84
 
87
 
85
            Cart cart = userClient.getCart(cartId);
88
            Cart cart = userClient.getCart(cartId);
86
            setTotalAmount(cart);
89
            setTotalAmount(cart);
-
 
90
            itemIdString = Utils.getItemIdStringInCart(cart);
87
            
91
            
88
            //Get the line items to check if COD option should be shown.
92
            //Get the line items to check if COD option should be shown.
89
            lineItems = cart.getLines();
93
            lineItems = cart.getLines();
90
            
94
            
91
            // Get the address to check if COD option is available for this
95
            // Get the address to check if COD option is available for this
92
            // address.
96
            // address.
93
            if(addressId == -1){
97
            if(addressId == -1){
94
                addressId = cart.getAddressId();
98
                addressId = cart.getAddressId();
95
            }
99
            }
96
            address = userClient.getAddressById(addressId);
100
            address = userClient.getAddressById(addressId);
-
 
101
            DataLogger.logData(EventType.PROCEED_TO_PAY, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
-
 
102
                    Long.toString(cartId), itemIdString);
97
        } catch(Exception e) {
103
        } catch(Exception e) {
98
            logger.error("Error while either validating the cart or getting the address", e);
104
            logger.error("Error while either validating the cart or getting the address", e);
99
            addActionError("We are experiencing some problem. Please try again.");
105
            addActionError("We are experiencing some problem. Please try again.");
100
            return "shipping-redirect";
106
            return "shipping-redirect";
101
        }
107
        }