Subversion Repositories SmartDukaan

Rev

Rev 8263 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8263 Rev 13014
Line 1... Line 1...
1
package in.shop2020.recharge.controllers;
1
package in.shop2020.recharge.controllers;
2
 
2
 
3
import in.shop2020.model.v1.order.HotspotStore;
3
import in.shop2020.model.v1.order.HotspotStore;
-
 
4
import in.shop2020.model.v1.order.RechargeOrder;
4
import in.shop2020.model.v1.order.RechargeOrderStatus;
5
import in.shop2020.model.v1.order.RechargeOrderStatus;
5
import in.shop2020.model.v1.order.RechargeTransaction;
6
import in.shop2020.model.v1.order.RechargeTransaction;
6
import in.shop2020.model.v1.order.TransactionService;
7
import in.shop2020.model.v1.order.TransactionService;
7
import in.shop2020.thrift.clients.TransactionClient;
8
import in.shop2020.thrift.clients.TransactionClient;
8
 
9
 
9
import java.nio.ByteBuffer;
10
import java.nio.ByteBuffer;
-
 
11
import java.util.Arrays;
-
 
12
import java.util.List;
10
 
13
 
11
import javax.servlet.ServletOutputStream;
14
import javax.servlet.ServletOutputStream;
12
 
15
 
-
 
16
import org.apache.struts2.convention.annotation.Result;
-
 
17
import org.apache.struts2.convention.annotation.Results;
-
 
18
import org.apache.thrift.TException;
-
 
19
 
-
 
20
@Results({
-
 
21
    @Result(name = "recharge-status", location = "recharge-status.vm")
-
 
22
})
-
 
23
 
13
 
24
 
14
public class RechargeResultController extends BaseController {
25
public class RechargeResultController extends BaseController {
15
 
26
 
16
    private static final long serialVersionUID = 1L;
27
    private static final long serialVersionUID = 1L;
17
    private long rechargeId = 0l;
28
    private long rechargeId = 0l;
18
    private long paymentAmount;
29
    private long paymentAmount;
19
	private RechargeTransaction recharge = null;
30
	private RechargeTransaction recharge = null;
-
 
31
	private static List<Long> asyncOperators = Arrays.asList(9l);
-
 
32
	private boolean rechargeModeSynchronous = false;
-
 
33
    private String isFinal;
-
 
34
    private String newStatus;
20
    
35
    
21
    
36
    
22
    public String index() {
37
    public String index() {
23
        TransactionClient tcl;
38
        TransactionClient tcl;
24
        try {
39
        try {
Line 27... Line 42...
27
                return "authfail";
42
                return "authfail";
28
            }
43
            }
29
            tcl = new TransactionClient();
44
            tcl = new TransactionClient();
30
            recharge =  tcl.getClient().getRechargeTransaction(rechargeId);
45
            recharge =  tcl.getClient().getRechargeTransaction(rechargeId);
31
            storeId = Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
46
            storeId = Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
-
 
47
            log.info("Store id****");
-
 
48
            log.info((String)request.getSession().getAttribute("STORE_ID"));
32
            try{
49
            try{
33
                HotspotStore hotSpotStore = (new TransactionClient()).getClient().getHotspotStore(storeId, "");
50
                HotspotStore hotSpotStore = (new TransactionClient()).getClient().getHotspotStore(storeId, "");
34
                hotspotStores.put(storeId, hotSpotStore);
51
                hotspotStores.put(storeId, hotSpotStore);
35
            } catch (Exception e) {
52
            } catch (Exception e) {
36
                log.error("Unable to get store", e);
53
                log.error("Unable to get store", e);
Line 51... Line 68...
51
            return "Recharge Failed. Reason : " + recharge.getDescription();
68
            return "Recharge Failed. Reason : " + recharge.getDescription();
52
        }
69
        }
53
        else if (recharge.getStatus() == RechargeOrderStatus.RECHARGE_UNKNOWN) {
70
        else if (recharge.getStatus() == RechargeOrderStatus.RECHARGE_UNKNOWN) {
54
            return "Recharge Under Process";
71
            return "Recharge Under Process";
55
        }
72
        }
-
 
73
        else if (recharge.getStatus() == RechargeOrderStatus.RECHARGE_IN_PROCESS){
-
 
74
            return "Please wait while we check recharge with operator.Donot close this window.";
-
 
75
        }
56
        else {
76
        else {
57
            return "There is some problem. Please try again later.";
77
            return "There is some problem. Please try again later.";
58
        }
78
        }
59
    }
79
    }
-
 
80
    
-
 
81
    public String getRechargeStatus() throws NumberFormatException, TException{
-
 
82
        TransactionClient transactionServiceClient = null;
-
 
83
        transactionServiceClient = new TransactionClient();
-
 
84
        recharge = transactionServiceClient.getClient().getRcgTransactionStatus(rechargeId, Boolean.valueOf(isFinal));
-
 
85
        setNewStatus(recharge.getStatus().name());
-
 
86
        return "recharge-status";
-
 
87
    }
60
 
88
 
61
    public boolean showPrintButton() {
89
    public boolean showPrintButton() {
62
        if(recharge.getStatus() == RechargeOrderStatus.RECHARGE_SUCCESSFUL) {
90
        if(recharge.getStatus() == RechargeOrderStatus.RECHARGE_SUCCESSFUL) {
63
            return true;
91
            return true;
64
        } else {
92
        } else {
Line 119... Line 147...
119
	}
147
	}
120
 
148
 
121
	public void setPaymentAmount(long paymentAmount) {
149
	public void setPaymentAmount(long paymentAmount) {
122
		this.paymentAmount = paymentAmount;
150
		this.paymentAmount = paymentAmount;
123
	}
151
	}
-
 
152
 
-
 
153
    public void setRechargeModeSynchronous(boolean rechargeModeSynchronous) {
-
 
154
        this.rechargeModeSynchronous = rechargeModeSynchronous;
-
 
155
    }
-
 
156
 
-
 
157
    public boolean isRechargeModeSynchronous() {
-
 
158
        return rechargeModeSynchronous;
-
 
159
    }
-
 
160
 
-
 
161
    public void setIsFinal(String isFinal) {
-
 
162
        this.isFinal = isFinal;
-
 
163
    }
-
 
164
 
-
 
165
    public String getIsFinal() {
-
 
166
        return isFinal;
-
 
167
    }
-
 
168
 
-
 
169
    public void setNewStatus(String newStatus) {
-
 
170
        log.info(newStatus);
-
 
171
        this.newStatus = newStatus;
-
 
172
    }
-
 
173
 
-
 
174
    public String getNewStatus() {
-
 
175
        return newStatus;
-
 
176
    }
124
}
177
}