Subversion Repositories SmartDukaan

Rev

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

Rev 4533 Rev 4668
Line 98... Line 98...
98
            Cart cart = userClient.getCart(cartId);
98
            Cart cart = userClient.getCart(cartId);
99
            
99
            
100
            String couponCode = cart.getCouponCode();
100
            String couponCode = cart.getCouponCode();
101
            logger.info("Coupon: " + couponCode);
101
            logger.info("Coupon: " + couponCode);
102
            
102
            
103
            if(couponCode != null && couponCode.trim().equalsIgnoreCase("SH911"))	{
-
 
104
            	showCodOption = false;
-
 
105
            }
-
 
106
            
-
 
107
            setTotalAmount(cart);
103
            setTotalAmount(cart);
108
            itemIdString = Utils.getItemIdStringInCart(cart);
104
            itemIdString = Utils.getItemIdStringInCart(cart);
109
            
105
            
110
            //Get the line items to check if COD option should be shown.
106
            //Get the line items to check if COD option should be shown.
111
            lineItems = cart.getLines();
107
            lineItems = cart.getLines();
Line 114... Line 110...
114
            // address.
110
            // address.
115
            if(addressId == -1){
111
            if(addressId == -1){
116
                addressId = cart.getAddressId();
112
                addressId = cart.getAddressId();
117
            }
113
            }
118
            address = userClient.getAddressById(addressId);
114
            address = userClient.getAddressById(addressId);
-
 
115
            
-
 
116
            try {
-
 
117
                showCodOption = userClient.showCODOption(cartId, sourceId, address.getPin());
-
 
118
            } catch(Exception e) {
-
 
119
                logger.error("Error while checking if COD is available for: " + showCodOption, e);
-
 
120
                showCodOption = false; //Not a critical error, proceeding with defensive behaviour.
-
 
121
            }
-
 
122
            
119
            DataLogger.logData(EventType.PROCEED_TO_PAY, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
123
            DataLogger.logData(EventType.PROCEED_TO_PAY, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
120
                    Long.toString(cartId), itemIdString);
124
                    Long.toString(cartId), itemIdString);
121
        } catch(Exception e) {
125
        } catch(Exception e) {
122
            logger.error("Error while either validating the cart or getting the address", e);
126
            logger.error("Error while either validating the cart or getting the address", e);
123
            addActionError("We are experiencing some problem. Please try again.");
127
            addActionError("We are experiencing some problem. Please try again.");
124
            return "shipping-redirect";
128
            return "shipping-redirect";
125
        }
129
        }
126
        
130
        
127
        try {
-
 
128
            CatalogClient catalogServiceClient  = new CatalogClient();
-
 
129
            in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = catalogServiceClient.getClient();
-
 
130
            for (Line line : lineItems) {
-
 
131
                Item item = catalogClient.getItemForSource(line.getItemId(), sourceId);
-
 
132
                if(item.getSellingPrice() > COD_MAX_AMOUNT || item.getSellingPrice() < COD_MIN_AMOUNT )
-
 
133
                    showCodOption = false;    
-
 
134
            }
-
 
135
        } catch(Exception e) {
-
 
136
            logger.error("Error while getting item info from the catalog service", e);
-
 
137
            addActionError("We are experiencing some problem. Please try again.");
-
 
138
            return "shipping-redirect";
-
 
139
        }
-
 
140
        
-
 
141
        try {
-
 
142
            LogisticsClient lClient = new LogisticsClient();
-
 
143
            showCodOption = showCodOption && lClient.getClient().isCodAllowed(address.getPin());
-
 
144
        } catch(Exception e) {
-
 
145
            logger.error("Error while checking if COD is available for: " + showCodOption, e);
-
 
146
            showCodOption = false; //Not a critical error, proceeding with defensive behaviour.
-
 
147
        }
-
 
148
        
-
 
149
        Collection<String> actionErrors = getActionErrors();
131
        Collection<String> actionErrors = getActionErrors();
150
        if(actionErrors != null && !actionErrors.isEmpty()){
132
        if(actionErrors != null && !actionErrors.isEmpty()){
151
            for (String str : actionErrors) {
133
            for (String str : actionErrors) {
152
                errorMsg += "<BR/>" + str;
134
                errorMsg += "<BR/>" + str;
153
            }
135
            }