Subversion Repositories SmartDukaan

Rev

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

Rev 7080 Rev 7109
Line 1... Line 1...
1
package in.shop2020.recharge.controllers;
1
package in.shop2020.recharge.controllers;
2
 
2
 
-
 
3
import java.nio.ByteBuffer;
-
 
4
 
-
 
5
import javax.servlet.ServletOutputStream;
-
 
6
 
3
import in.shop2020.model.v1.order.DeviceNumberInfo;
7
import in.shop2020.model.v1.order.DeviceNumberInfo;
4
import in.shop2020.model.v1.order.RechargeOrderStatus;
8
import in.shop2020.model.v1.order.RechargeOrderStatus;
5
import in.shop2020.model.v1.order.RechargeTransaction;
9
import in.shop2020.model.v1.order.RechargeTransaction;
6
import in.shop2020.model.v1.order.RechargeType;
10
import in.shop2020.model.v1.order.RechargeType;
-
 
11
import in.shop2020.model.v1.order.TransactionService;
7
import in.shop2020.thrift.clients.TransactionClient;
12
import in.shop2020.thrift.clients.TransactionClient;
8
 
13
 
9
 
14
 
10
public class RechargeResultController extends BaseController {
15
public class RechargeResultController extends BaseController {
11
 
16
 
12
    private static final long serialVersionUID = 1L;
17
    private static final long serialVersionUID = 1L;
13
    private long rechargeId;
18
    private long rechargeId = 0l;
14
    private RechargeTransaction recharge = null;
19
    private RechargeTransaction recharge = null;
15
    
20
    
16
    
21
    
17
    public String index() {
22
    public String index() {
18
        TransactionClient tcl;
23
        TransactionClient tcl;
Line 48... Line 53...
48
        } else {
53
        } else {
49
            return false;
54
            return false;
50
        }
55
        }
51
    }
56
    }
52
    
57
    
-
 
58
    public String downloadInvoice() {
-
 
59
        ByteBuffer buffer = null;
-
 
60
        try {
-
 
61
            if (rechargeId == 0) {
-
 
62
                log.error("Recharge Id 0");
-
 
63
                return "index";
-
 
64
            }
-
 
65
            TransactionClient transactionServiceClient = new TransactionClient();
-
 
66
            TransactionService.Client orderClient = transactionServiceClient.getClient();
-
 
67
            buffer = orderClient.retrieveHotspotRechargeInvoice(rechargeId);
-
 
68
            if(!buffer.hasArray()) {
-
 
69
                log.error("The invoice was not found for rechargeId : " + rechargeId);
-
 
70
            }
-
 
71
        } catch (Exception e) {
-
 
72
            System.out.println(e.getMessage());
-
 
73
        }
-
 
74
        response.setHeader("Content-disposition", "inline; filename=recharge-invoice-" + rechargeId + ".pdf");
-
 
75
 
-
 
76
        ServletOutputStream sos;
-
 
77
        try {
-
 
78
            sos = response.getOutputStream();
-
 
79
            sos.write(buffer.array());
-
 
80
            sos.flush();
-
 
81
        } catch (Exception e) {
-
 
82
            System.out.println("Unable to stream the invoice file");
-
 
83
        }
-
 
84
        return "index";
-
 
85
    }
-
 
86
    
53
    
87
    
54
    public long getRechargeId() {
88
    public long getRechargeId() {
55
        return rechargeId;
89
        return rechargeId;
56
    }
90
    }
57
 
91