Subversion Repositories SmartDukaan

Rev

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

Rev 18057 Rev 18659
Line 93... Line 93...
93
    }
93
    }
94
 
94
 
95
    // POST /order/
95
    // POST /order/
96
    public String create(){
96
    public String create(){
97
    	String addressIdString = this.request.getParameter("addressid");
97
    	String addressIdString = this.request.getParameter("addressid");
-
 
98
    	if(addressIdString == null){
-
 
99
    		addActionError("Please specify shipping address to continue.");
-
 
100
    		return "proceed-to-pay-redirect";
-
 
101
    	}
-
 
102
    	long addressId;
-
 
103
    	try {
-
 
104
    		addressId = Long.parseLong(addressIdString);   
-
 
105
    	} catch(NumberFormatException nfe){
-
 
106
    		log.error("Unable to get address id", nfe);
-
 
107
    		addActionError("Invalid address. Please add an address to the cart.");
-
 
108
    		return "shipping-redirect";
-
 
109
    	}
98
    	OrderType orderType = OrderType.B2C;
110
    	OrderType orderType = OrderType.B2C;
99
    	String tin = null;
111
    	String tin = null;
100
    	if(userinfo.isPrivateDealUser()){
112
    	if(userinfo.isPrivateDealUser()){
101
    		try {
113
    		try {
102
    			UserClient userServiceClient = new UserClient();
114
    			UserClient userServiceClient = new UserClient();
103
                in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
115
                in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
104
                PrivateDealUser user = userClient.getPrivateDealUser(userinfo.getUserId());
116
                PrivateDealUser user = userClient.getPrivateDealUser(userinfo.getUserId());
-
 
117
                Address billingAddress= userClient.getBillingAddressForUser(user.getUserId());
-
 
118
            	if(billingAddress != null){
-
 
119
            		Address shippingAddress = userClient.getAddressById(addressId);
-
 
120
            		if(billingAddress.getState().equals(shippingAddress.getState())){
-
 
121
            			orderType = OrderType.B2B;
105
                log.info(user);
122
            			tin = user.getTin().trim();
-
 
123
            		}
-
 
124
            	}
106
                if(user.getTin() != null && !user.getTin().equals("")) {
125
                if(user.getTin() != null && !user.getTin().equals("")) {
107
                	orderType = OrderType.B2B;
126
                	orderType = OrderType.B2B;
108
                	tin = user.getTin().trim();
127
                	tin = user.getTin().trim();
109
                }
128
                }
110
                    
129
                    
Line 112... Line 131...
112
                log.error("Unable to talk to the user context service.", e);
131
                log.error("Unable to talk to the user context service.", e);
113
                addActionError("We are experiencing some problems. Please try later.");
132
                addActionError("We are experiencing some problems. Please try later.");
114
                return "proceed-to-pay-redirect";
133
                return "proceed-to-pay-redirect";
115
            }
134
            }
116
    	}
135
    	}
117
    	if(addressIdString == null){
-
 
118
    		addActionError("Please specify shipping address to continue.");
-
 
119
    		return "proceed-to-pay-redirect";
-
 
120
    	}
-
 
121
    	
136
    	
122
    	String paymentOption = request.getParameter("payment_option");
137
    	String paymentOption = request.getParameter("payment_option");
123
    	log.info("Payment Option Selected: " + paymentOption);
138
    	log.info("Payment Option Selected: " + paymentOption);
124
    	if(paymentOption == null || paymentOption.equals("")){
139
    	if(paymentOption == null || paymentOption.equals("")){
125
    		addActionError("Please select a payment method to continue.");
140
    		addActionError("Please select a payment method to continue.");
126
    		return "proceed-to-pay-redirect";
141
    		return "proceed-to-pay-redirect";
127
    	}
142
    	}
128
    	
143
    	
129
    	
144
    	
130
    	long addressId;
-
 
131
    	try {
-
 
132
    	    addressId = Long.parseLong(addressIdString);   
-
 
133
    	} catch(NumberFormatException nfe){
-
 
134
    	    log.error("Unable to get address id", nfe);
-
 
135
    	    addActionError("Invalid address. Please add an address to the cart.");
-
 
136
    	    return "shipping-redirect";
-
 
137
    	}
-
 
138
    	 
145
    	 
139
    	long currentCartId = userinfo.getCartId();
146
    	long currentCartId = userinfo.getCartId();
140
    	long currentUserId = userinfo.getUserId();
147
    	long currentUserId = userinfo.getUserId();
141
    	
148
    	
142
    	if(paymentOption.equals(IPaymentService.COD)){
149
    	if(paymentOption.equals(IPaymentService.COD)){