Subversion Repositories SmartDukaan

Rev

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

Rev 6220 Rev 6603
Line 12... Line 12...
12
import in.shop2020.logistics.Provider;
12
import in.shop2020.logistics.Provider;
13
import in.shop2020.model.v1.order.Order;
13
import in.shop2020.model.v1.order.Order;
14
import in.shop2020.model.v1.order.OrderStatus;
14
import in.shop2020.model.v1.order.OrderStatus;
15
import in.shop2020.model.v1.order.OrderStatusGroups;
15
import in.shop2020.model.v1.order.OrderStatusGroups;
16
import in.shop2020.model.v1.order.RechargeOrder;
16
import in.shop2020.model.v1.order.RechargeOrder;
-
 
17
import in.shop2020.model.v1.order.RechargeOrderStatus;
17
import in.shop2020.model.v1.order.RechargeType;
18
import in.shop2020.model.v1.order.RechargeType;
-
 
19
import in.shop2020.model.v1.order.UserWallet;
18
import in.shop2020.serving.utils.FormattingUtils;
20
import in.shop2020.serving.utils.FormattingUtils;
19
import in.shop2020.serving.utils.Utils;
21
import in.shop2020.serving.utils.Utils;
20
import in.shop2020.thrift.clients.LogisticsClient;
22
import in.shop2020.thrift.clients.LogisticsClient;
21
import in.shop2020.thrift.clients.TransactionClient;
23
import in.shop2020.thrift.clients.TransactionClient;
22
 
24
 
23
import org.apache.log4j.Logger;
25
import org.apache.log4j.Logger;
24
import org.apache.struts2.convention.annotation.InterceptorRef;
26
import org.apache.struts2.convention.annotation.InterceptorRef;
25
import org.apache.struts2.convention.annotation.InterceptorRefs;
27
import org.apache.struts2.convention.annotation.InterceptorRefs;
26
import org.apache.struts2.convention.annotation.Result;
28
import org.apache.struts2.convention.annotation.Result;
27
import org.apache.struts2.convention.annotation.Results;
29
import org.apache.struts2.convention.annotation.Results;
-
 
30
import org.apache.thrift.TException;
28
 
31
 
29
/**
32
/**
30
 * @author rajveer
33
 * @author rajveer
31
 *
34
 *
32
 */
35
 */
Line 48... Line 51...
48
    private FormattingUtils formattingUtils = new FormattingUtils();
51
    private FormattingUtils formattingUtils = new FormattingUtils();
49
    
52
    
50
    Map<Long, String> providerNames = new HashMap<Long, String>();
53
    Map<Long, String> providerNames = new HashMap<Long, String>();
51
    List<RechargeOrder> rechargeOrders = null;
54
    List<RechargeOrder> rechargeOrders = null;
52
    List<String> orderDate = new ArrayList<String>();
55
    List<String> orderDate = new ArrayList<String>();
-
 
56
    private long orderId = 0;
53
 
57
 
54
    private static Map<Long, String> rechargeProviderMap = new HashMap<Long, String>() ;
58
    private Map<Long, String> rechargeProviderMap = new HashMap<Long, String>() ;
-
 
59
 
-
 
60
    private String errorMessage = "";
55
	
61
	
56
   // private  static final OrderStatusGroups statusGroup = new OrderStatusGroups();
-
 
57
    //private  static final List<OrderStatus> openOrderStatuses = statusGroup.getOpenOrders();
-
 
58
    //private  static final List<OrderStatus> shippedOrderStatuses = statusGroup.getShippedOrders();
-
 
59
    
-
 
60
	public MyRechargesController() {
62
	public MyRechargesController() {
61
		super();
63
		super();
62
	}
64
	}
63
    
65
    
64
	public String index(){
66
	public String index(){
Line 97... Line 99...
97
        Date date = new Date(timestamp);
99
        Date date = new Date(timestamp);
98
        SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
100
        SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");
99
        return dateformat.format(date);
101
        return dateformat.format(date);
100
    }
102
    }
101
	
103
	
-
 
104
	public boolean shouldShowRefundButton() {
-
 
105
	    try {
-
 
106
    	    TransactionClient transactionServiceClient = new TransactionClient();
-
 
107
            in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
-
 
108
            UserWallet wallet = orderClient.getUserWallet(userinfo.getUserId());
-
 
109
            if (wallet.getAmount() > 0) {
-
 
110
                for(RechargeOrder rechargeOrder : rechargeOrders) {
-
 
111
                    if (Utils.refundableRechargeStatusList.contains(rechargeOrder.getStatus()) && 
-
 
112
                            (rechargeOrder.getWalletAmount() != (rechargeOrder.getTotalAmount() - rechargeOrder.getCouponAmount()))) {
-
 
113
                        return true;
-
 
114
                    }
-
 
115
                }
-
 
116
            }    
-
 
117
        } catch (Exception e) {
-
 
118
            logger.error("Unable to get Wallet", e);
-
 
119
        }
-
 
120
        return false;
-
 
121
	}
-
 
122
	
-
 
123
	public boolean isRefundPossible(RechargeOrder rechargeOrder) {
-
 
124
	    if (Utils.refundableRechargeStatusList.contains(rechargeOrder.getStatus()) && 
-
 
125
                (rechargeOrder.getWalletAmount() != (rechargeOrder.getTotalAmount() - rechargeOrder.getCouponAmount()))) {
-
 
126
            return true;
-
 
127
        }
-
 
128
	    return false;
-
 
129
	}
-
 
130
	
-
 
131
	public String create() {
-
 
132
	    try {
-
 
133
            TransactionClient transactionServiceClient = new TransactionClient();
-
 
134
            if(!transactionServiceClient.getClient().refundRechargeOrder(orderId)) {
-
 
135
                errorMessage = "Refund failed";
-
 
136
            }
-
 
137
        } catch (Exception e) {
-
 
138
            logger.error("Unable to refund rechargeOrder : " + orderId, e);
-
 
139
            errorMessage = "Refund failed";
-
 
140
        }
-
 
141
        return index();
-
 
142
	}
-
 
143
	
-
 
144
	public String getDisplayStatus(RechargeOrderStatus status) {
-
 
145
	    return Utils.statusMap.get(status);
-
 
146
	}
-
 
147
	
102
    public List<RechargeOrder> getRechargeOrders()  {
148
    public List<RechargeOrder> getRechargeOrders()  {
103
        return rechargeOrders;
149
        return rechargeOrders;
104
    }
150
    }
105
    
151
    
106
    public List<String> getOrderDate()  {
152
    public List<String> getOrderDate()  {
Line 108... Line 154...
108
    }
154
    }
109
    
155
    
110
    public String getProviderName(Long rechargeOrderId) {
156
    public String getProviderName(Long rechargeOrderId) {
111
        return rechargeProviderMap.get(rechargeOrderId);
157
        return rechargeProviderMap.get(rechargeOrderId);
112
    }
158
    }
-
 
159
 
-
 
160
    public long getOrderId() {
-
 
161
        return orderId;
-
 
162
    }
-
 
163
 
-
 
164
    public void setOrderId(long orderId) {
-
 
165
        this.orderId = orderId;
-
 
166
    }
-
 
167
 
-
 
168
    public String getErrorMessage() {
-
 
169
        return errorMessage;
-
 
170
    }
-
 
171
 
-
 
172
    public void setErrorMessage(String errorMessage) {
-
 
173
        this.errorMessage = errorMessage;
-
 
174
    }
113
}
175
}
114
176