Subversion Repositories SmartDukaan

Rev

Rev 1044 | Rev 2355 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
405 rajveer 1
package in.shop2020.serving.controllers;
2
 
2191 varun.gupt 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
 
832 rajveer 16
import org.apache.log4j.Logger;
781 vikas 17
import org.apache.struts2.convention.annotation.InterceptorRef;
18
import org.apache.struts2.convention.annotation.InterceptorRefs;
413 rajveer 19
import org.apache.struts2.convention.annotation.Result;
20
import org.apache.struts2.convention.annotation.Results;
405 rajveer 21
 
22
/**
413 rajveer 23
 * @author rajveer
405 rajveer 24
 *
25
 */
413 rajveer 26
 
781 vikas 27
@InterceptorRefs({
822 vikas 28
    @InterceptorRef("myDefault"),
29
    @InterceptorRef("login")
781 vikas 30
})
31
 
637 rajveer 32
@Results({
33
    @Result(name="redirect", type="redirectAction", 
34
    		params = {"actionName" , "login"})
35
})
650 rajveer 36
public class MyaccountController extends BaseController {
405 rajveer 37
 
650 rajveer 38
	private static final long serialVersionUID = 1L;
2191 varun.gupt 39
	private static Logger log = Logger.getLogger(Class.class);
40
    private FormattingUtils formattingUtils = new FormattingUtils();
650 rajveer 41
 
2191 varun.gupt 42
    Map<Long, String> providerNames = new HashMap<Long, String>();
43
    List<Order> orders = null;
44
    List<String> orderDate = new ArrayList<String>();
405 rajveer 45
 
46
	public MyaccountController() {
47
		super();
48
	}
650 rajveer 49
 
50
	public String index(){
51
    	log.info("this.request=" + this.request);
52
 
2191 varun.gupt 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)
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)    {
72
                Date orderedOn = new Date(order.getCreated_timestamp());
73
                orderDate.add(dateformat.format(orderedOn));
74
            }
75
        }
650 rajveer 76
		return "index";
405 rajveer 77
    }
78
 
2191 varun.gupt 79
	public String formatPrice(double price)    {
80
        return formattingUtils.formatPrice(price);
81
    }
507 rajveer 82
 
2191 varun.gupt 83
    public Map<Long, String> getProviderNames() {
84
        return providerNames;
85
    }
86
 
87
    public List<Order> getOrders()  {
88
        return orders;
89
    }
90
 
91
    public List<String> getOrderDate()  {
92
        return orderDate;
93
    }
94
}