Subversion Repositories SmartDukaan

Rev

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

Rev 7349 Rev 7386
Line 35... Line 35...
35
import org.apache.poi.ss.usermodel.Workbook;
35
import org.apache.poi.ss.usermodel.Workbook;
36
import org.apache.thrift.meta_data.SetMetaData;
36
import org.apache.thrift.meta_data.SetMetaData;
37
import org.slf4j.Logger;
37
import org.slf4j.Logger;
38
import org.slf4j.LoggerFactory;
38
import org.slf4j.LoggerFactory;
39
 
39
 
40
public class ReportController  extends BaseController {
40
public class ReportController extends BaseController {
41
 
41
 
42
    /**
42
    /**
43
     * 
43
     * 
44
     */
44
     */
45
    private static final long serialVersionUID = 1L;
45
    private static final long serialVersionUID = 1L;
Line 76... Line 76...
76
    private Long refundAmount;
76
    private Long refundAmount;
77
    
77
    
78
    private boolean showReprintColumn = false;
78
    private boolean showReprintColumn = false;
79
    
79
    
80
    public ReportController(){
80
    public ReportController(){
-
 
81
        super();
81
        try {
82
        try {
82
            tsc = new TransactionClient();
83
            tsc = new TransactionClient();
83
            tClient = tsc.getClient();
84
            tClient = tsc.getClient();
84
        } catch (Exception e) {
85
        } catch (Exception e) {
85
            logger.error("Error connecting to one of the user, order or payment service", e);
86
            logger.error("Error connecting to one of the user, order or payment service", e);
86
        }
87
        }
87
    }
88
    }
88
        
89
        
89
    
90
    
90
    public String index() {
91
    public String index() {
91
//      String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
92
      String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
92
//        if(loginStatus == null || !loginStatus.equals("TRUE")){
93
        if(loginStatus == null || !loginStatus.equals("TRUE")){
93
//            return "authfail";
94
            return "authfail";
94
//        }
95
        }
95
//        
96
        
96
//        storeId = Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
97
        storeId = Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
97
        storeId = 1L;
-
 
98
        if(!hotspotStores.containsKey(storeId)){
98
        if(!hotspotStores.containsKey(storeId)){
99
            try{
99
            try{
100
                HotspotStore hotSpotStore = (new TransactionClient()).getClient().getHotspotStore(storeId, "");
100
                HotspotStore hotSpotStore = (new TransactionClient()).getClient().getHotspotStore(storeId, "");
101
                hotspotStores.put(storeId, hotSpotStore);
101
                hotspotStores.put(storeId, hotSpotStore);
102
            } catch (Exception e) {
102
            } catch (Exception e) {
Line 115... Line 115...
115
        }
115
        }
116
        return "index";
116
        return "index";
117
    }
117
    }
118
    
118
    
119
    public String search() {
119
    public String search() {
120
//        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
120
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
121
//        if(loginStatus == null || !loginStatus.equals("TRUE")){
121
        if(loginStatus == null || !loginStatus.equals("TRUE")){
122
//            return "authfail";
122
            return "authfail";
123
//        }
123
        }
124
        if(number != null) {
124
        if(number != null) {
125
            try {
125
            try {
126
                List<OrderStatus> statuses = new ArrayList<OrderStatus>();
126
                List<OrderStatus> statuses = new ArrayList<OrderStatus>();
127
                setSearchResult(tClient.getOrdersForStore(number, 1, -1, -1, statuses));
127
                setSearchResult(tClient.getOrdersForStore(number, 1, -1, -1, statuses));
128
                if(searchResult.size() == 0) {
128
                if(searchResult.size() == 0) {
Line 135... Line 135...
135
        }
135
        }
136
        return index();
136
        return index();
137
    }
137
    }
138
    
138
    
139
    public String getCollection() throws Exception{
139
    public String getCollection() throws Exception{
140
//        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
140
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
141
//        if(loginStatus == null || !loginStatus.equals("TRUE")){
141
        if(loginStatus == null || !loginStatus.equals("TRUE")){
142
//            return "authfail";
142
            return "authfail";
143
//        }
143
        }
144
        long today = -1;
144
        long today = -1;
145
        today = new Date().getTime();
145
        today = new Date().getTime();
146
        List<OrderStatus> statuses = new ArrayList<OrderStatus>();
146
        List<OrderStatus> statuses = new ArrayList<OrderStatus>();
147
        statuses.add(OrderStatus.DELIVERY_SUCCESS);
147
        statuses.add(OrderStatus.DELIVERY_SUCCESS);
148
        List<Order> successfulOrders = tClient.getOrdersForStore(0, 1, today, today, statuses);
148
        List<Order> successfulOrders = tClient.getOrdersForStore(0, 1, today, today, statuses);
Line 332... Line 332...
332
                log.error("rechargeId is 0");
332
                log.error("rechargeId is 0");
333
                return "index";
333
                return "index";
334
            }
334
            }
335
            TransactionClient transactionServiceClient = new TransactionClient();
335
            TransactionClient transactionServiceClient = new TransactionClient();
336
            TransactionService.Client orderClient = transactionServiceClient.getClient();
336
            TransactionService.Client orderClient = transactionServiceClient.getClient();
-
 
337
            //TODO : dynamically get StoreId
337
            buffer = orderClient.getStoreOrderAdvanceInvoice(number);
338
            buffer = orderClient.getStoreOrderAdvanceInvoice(number, 1);
338
            if(!buffer.hasArray()) {
339
            if(!buffer.hasArray()) {
339
                log.error("The invoice was not found for orderId : " + 1);
340
                log.error("The invoice was not found for orderId : " + 1);
340
            }
341
            }
341
        } catch (Exception e) {
342
        } catch (Exception e) {
342
            System.out.println(e.getMessage());
343
            System.out.println(e.getMessage());
Line 403... Line 404...
403
    }
404
    }
404
    
405
    
405
    public String cancelRequest() {
406
    public String cancelRequest() {
406
        try{
407
        try{
407
        TransactionClient tcl = new TransactionClient();
408
        TransactionClient tcl = new TransactionClient();
-
 
409
        
408
        tcl.getClient().markOrderCancellationRequestReceived(orderId);
410
        tcl.getClient().refundOrder(orderId, "Store", "User requested for cancellation");
409
        } catch (Exception e) {
411
        } catch (Exception e) {
410
            logger.error("Could not mark order as cancellation requested for id : " + orderId.toString(), e);
412
            logger.error("Could not mark order as cancellation requested for id : " + orderId.toString(), e);
411
            setSearchError("Request failed. Try again or call customer care.");
413
            setSearchError("Request failed. Try again or call customer care.");
412
        }
414
        }
413
        number = orderId;
415
        number = orderId;
Line 595... Line 597...
595
 
597
 
596
    public Long getRefundAmount() {
598
    public Long getRefundAmount() {
597
        return refundAmount;
599
        return refundAmount;
598
    }
600
    }
599
    
601
    
-
 
602
    public boolean isOrderPlacedOnSameDay(long orderTime) {
-
 
603
        Calendar calOrderDate = Calendar.getInstance();
-
 
604
        calOrderDate.setTimeInMillis(orderTime);
-
 
605
        
-
 
606
        Calendar cal = Calendar.getInstance();
-
 
607
        if(cal.get(Calendar.DATE) == calOrderDate.get(Calendar.DATE) 
-
 
608
                && cal.get(Calendar.MONTH) == calOrderDate.get(Calendar.MONTH)
-
 
609
                && cal.get(Calendar.YEAR) == calOrderDate.get(Calendar.YEAR)) {
-
 
610
            return true;
-
 
611
        }
-
 
612
        return false;
600
    
613
    }
601
 
614
 
602
}
615
}
603
616