Subversion Repositories SmartDukaan

Rev

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

Rev 1044 Rev 2191
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
-
 
3
import java.text.SimpleDateFormat;
-
 
4
import java.util.ArrayList;
-
 
5
import java.util.Date;
-
 
6
import java.util.HashMap;
-
 
7
import java.util.List;
-
 
8
import java.util.Map;
-
 
9
 
-
 
10
import in.shop2020.logistics.Provider;
-
 
11
import in.shop2020.model.v1.order.Order;
-
 
12
import in.shop2020.serving.utils.FormattingUtils;
-
 
13
import in.shop2020.thrift.clients.LogisticsServiceClient;
-
 
14
import in.shop2020.thrift.clients.TransactionServiceClient;
-
 
15
 
3
import org.apache.log4j.Logger;
16
import org.apache.log4j.Logger;
4
import org.apache.struts2.convention.annotation.InterceptorRef;
17
import org.apache.struts2.convention.annotation.InterceptorRef;
5
import org.apache.struts2.convention.annotation.InterceptorRefs;
18
import org.apache.struts2.convention.annotation.InterceptorRefs;
6
import org.apache.struts2.convention.annotation.Result;
19
import org.apache.struts2.convention.annotation.Result;
7
import org.apache.struts2.convention.annotation.Results;
20
import org.apache.struts2.convention.annotation.Results;
Line 21... Line 34...
21
    		params = {"actionName" , "login"})
34
    		params = {"actionName" , "login"})
22
})
35
})
23
public class MyaccountController extends BaseController {
36
public class MyaccountController extends BaseController {
24
 
37
 
25
	private static final long serialVersionUID = 1L;
38
	private static final long serialVersionUID = 1L;
-
 
39
	private static Logger log = Logger.getLogger(Class.class);
-
 
40
    private FormattingUtils formattingUtils = new FormattingUtils();
26
 
41
 
-
 
42
    Map<Long, String> providerNames = new HashMap<Long, String>();
-
 
43
    List<Order> orders = null;
27
	private static Logger log = Logger.getLogger(Class.class);	
44
    List<String> orderDate = new ArrayList<String>();
28
	
45
	
29
	public MyaccountController() {
46
	public MyaccountController() {
30
		super();
47
		super();
31
	}
48
	}
32
    
49
    
33
 
-
 
34
	public String index(){
50
	public String index(){
35
    	log.info("this.request=" + this.request);
51
    	log.info("this.request=" + this.request);
36
 
52
 
-
 
53
        try {
-
 
54
            TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
-
 
55
            in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
-
 
56
            orders = orderClient.getOrdersForCustomer(userinfo.getUserId(), 0, (new Date()).getTime(), null);
-
 
57
            
-
 
58
            LogisticsServiceClient logisticsServiceClient = new LogisticsServiceClient();
-
 
59
            in.shop2020.logistics.LogisticsService.Client logisticsClient = logisticsServiceClient.getClient();
-
 
60
            List<Provider> providers = logisticsClient.getAllProviders();
-
 
61
            
-
 
62
            for(Provider provider: providers)
37
		htmlSnippets.put("MYACCOUNT_HEADER", pageLoader.getMyaccountHeaderHtml());
63
                providerNames.put(provider.getId(), provider.getName());
-
 
64
            
-
 
65
        } catch (Exception e)   {
-
 
66
            e.printStackTrace();
-
 
67
        }
-
 
68
        SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
-
 
69
        
-
 
70
        if(orders != null && !orders.isEmpty()){
-
 
71
            for(Order order: orders)    {
38
		htmlSnippets.put("MYACCOUNT_DETAILS", pageLoader.getMyaccountDetailsHtml(userinfo.getUserId()));
72
                Date orderedOn = new Date(order.getCreated_timestamp());
-
 
73
                orderDate.add(dateformat.format(orderedOn));
-
 
74
            }
-
 
75
        }
39
		return "index";
76
		return "index";
40
    	
-
 
41
    }
77
    }
42
    
78
    
-
 
79
	public String formatPrice(double price)    {
-
 
80
        return formattingUtils.formatPrice(price);
-
 
81
    }
43
	
82
	
44
	public String getMyaccountHeaderSnippet(){
83
    public Map<Long, String> getProviderNames() {
45
		return htmlSnippets.get("MYACCOUNT_HEADER");
84
        return providerNames;
46
	}
85
    }
47
	
86
    
48
	public String getMyaccountDetailsSnippet(){
87
    public List<Order> getOrders()  {
49
		return htmlSnippets.get("MYACCOUNT_DETAILS");
88
        return orders;
50
	}
89
    }
51
	
90
    
-
 
91
    public List<String> getOrderDate()  {
-
 
92
        return orderDate;
-
 
93
    }
52
}
94
}
53
95