Subversion Repositories SmartDukaan

Rev

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

Rev 6050 Rev 6056
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
3
import in.shop2020.model.v1.order.RechargeOrder;
3
import in.shop2020.model.v1.order.RechargeOrder;
4
import in.shop2020.model.v1.order.RechargeOrderStatus;
4
import in.shop2020.model.v1.order.RechargeOrderStatus;
-
 
5
import in.shop2020.model.v1.order.RechargeType;
5
import in.shop2020.model.v1.order.TransactionServiceException;
6
import in.shop2020.model.v1.order.TransactionServiceException;
6
import in.shop2020.model.v1.user.Affiliate;
7
import in.shop2020.model.v1.user.Affiliate;
7
import in.shop2020.model.v1.user.TrackLogType;
8
import in.shop2020.model.v1.user.TrackLogType;
8
import in.shop2020.model.v1.user.UserAffiliateException;
9
import in.shop2020.model.v1.user.UserAffiliateException;
9
import in.shop2020.payments.PaymentException;
10
import in.shop2020.payments.PaymentException;
Line 13... Line 14...
13
import in.shop2020.thrift.clients.TransactionClient;
14
import in.shop2020.thrift.clients.TransactionClient;
14
import in.shop2020.thrift.clients.UserClient;
15
import in.shop2020.thrift.clients.UserClient;
15
 
16
 
16
import java.text.SimpleDateFormat;
17
import java.text.SimpleDateFormat;
17
import java.util.Date;
18
import java.util.Date;
-
 
19
import java.util.HashMap;
-
 
20
import java.util.Map;
18
 
21
 
19
import org.apache.log4j.Logger;
22
import org.apache.log4j.Logger;
20
import org.apache.struts2.convention.annotation.InterceptorRef;
23
import org.apache.struts2.convention.annotation.InterceptorRef;
21
import org.apache.struts2.convention.annotation.InterceptorRefs;
24
import org.apache.struts2.convention.annotation.InterceptorRefs;
22
import org.apache.thrift.TException;
25
import org.apache.thrift.TException;
-
 
26
import org.apache.thrift.transport.TTransportException;
23
 
27
 
24
@InterceptorRefs({
28
@InterceptorRefs({
25
    @InterceptorRef("myDefault"),
29
    @InterceptorRef("myDefault"),
26
    @InterceptorRef("login")
30
    @InterceptorRef("login")
27
})
31
})
Line 33... Line 37...
33
 
37
 
34
    private static Logger log = Logger.getLogger(Class.class);
38
    private static Logger log = Logger.getLogger(Class.class);
35
    private FormattingUtils formattingUtils = new FormattingUtils();
39
    private FormattingUtils formattingUtils = new FormattingUtils();
36
 
40
 
37
    private boolean isShooglooAff  = false;
41
    private boolean isShooglooAff  = false;
-
 
42
    private static Map<Long,String> allProviders;
-
 
43
    static {
-
 
44
    	try {
-
 
45
			allProviders = new TransactionClient().getClient().getServiceProviders(RechargeType.DTH);
-
 
46
			allProviders.putAll(new TransactionClient().getClient().getServiceProviders(RechargeType.MOBILE));
-
 
47
		} catch (TTransportException e) {
-
 
48
			// TODO Auto-generated catch block
-
 
49
			e.printStackTrace();
-
 
50
		} catch (TException e) {
-
 
51
			// TODO Auto-generated catch block
-
 
52
			e.printStackTrace();
38
 
53
		}
-
 
54
    }
39
    long merchantPaymentId;
55
    long merchantPaymentId;
40
    RechargeOrder rechargeOrder = null;
56
    RechargeOrder rechargeOrder = null;
41
    String message = null;
57
    String message = null;
42
 
58
 
43
    public RechargeResultController(){
59
    public RechargeResultController(){
44
        super();
60
        super();
45
    }
61
    }
46
 
62
 
47
    public String index() {
63
    public String index() {
48
        long i = 2;
-
 
49
        if (i == 2) {
-
 
50
            return "index";
-
 
51
        }
-
 
52
        PaymentClient paymentServiceClient = null;
64
        PaymentClient paymentServiceClient = null;
53
        TransactionClient transactionServiceClient = null;
65
        TransactionClient transactionServiceClient = null;
54
        UserClient userServiceClient = null;
66
        UserClient userServiceClient = null;
55
 
67
 
56
        try {
68
        try {
Line 62... Line 74...
62
            log.error("Unable to initialize the client for either payment or transaction or user service", e1);
74
            log.error("Unable to initialize the client for either payment or transaction or user service", e1);
63
        }
75
        }
64
 
76
 
65
 
77
 
66
        merchantPaymentId = Long.parseLong(this.request.getParameter("paymentId"));
78
        merchantPaymentId = Long.parseLong(this.request.getParameter("paymentId"));
67
 
-
 
-
 
79
        String operator = "";
68
        long txnId;
80
        long txnId;
69
        try {
81
        try {
70
            txnId = paymentServiceClient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
82
            txnId = paymentServiceClient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
71
            rechargeOrder = transactionServiceClient.getClient().getRechargeOrdersForTransaction(txnId);
83
            rechargeOrder = transactionServiceClient.getClient().getRechargeOrdersForTransaction(txnId);
72
 
84
 
Line 137... Line 149...
137
    }
149
    }
138
 
150
 
139
    public void setRechargeOrder(RechargeOrder rechargeOrder) {
151
    public void setRechargeOrder(RechargeOrder rechargeOrder) {
140
        this.rechargeOrder = rechargeOrder;
152
        this.rechargeOrder = rechargeOrder;
141
    }
153
    }
-
 
154
    
-
 
155
 
-
 
156
    public boolean isDTH() {
-
 
157
    	return rechargeOrder.getRechargeType().equals(RechargeType.DTH);
-
 
158
    }
-
 
159
    
-
 
160
    public String getProvider() {
-
 
161
    	return allProviders.get(rechargeOrder.getOperatorId());
-
 
162
    }
-
 
163
    
-
 
164
    public String[] getOrderStatus(){
-
 
165
    	RechargeOrderStatus status = rechargeOrder.getStatus();
-
 
166
    	if(status.equals(RechargeOrderStatus.PAYMENT_FAILED)||status.equals(RechargeOrderStatus.PAYMENT_PENDING)){
-
 
167
    		return new String[]{"red", "PAYMENT FAILED", "Payment failed. Try to <a href='/recharge'>recharge again</a>"};
-
 
168
    	}
-
 
169
    	else if(status.equals(RechargeOrderStatus.PAYMENT_SUCCESSFUL)||status.equals(RechargeOrderStatus.RECHARGE_FAILED)){
-
 
170
			return new String[]{"red", "RECHARGE FAILED", "Payment was successful and amount is transferred to your <a href='/wallet'>wallet</a>.<br> <a href='/recharge'>Recharge again</a> using wallet."};
-
 
171
    	} else {
-
 
172
    		return new String[] {"", "SUCCESS", "Congratulations your mobile is successfully recharged."};
-
 
173
    	}
-
 
174
    }
142
}
175
}
143
176