Subversion Repositories SmartDukaan

Rev

Rev 7386 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7226 anupam.sin 1
package in.shop2020.serving.controllers;
2
 
3
import java.text.SimpleDateFormat;
4
import java.util.Date;
5
 
6
import in.shop2020.model.v1.catalog.Item;
7386 anupam.sin 7
import in.shop2020.model.v1.order.HotspotStore;
7226 anupam.sin 8
import in.shop2020.thrift.clients.CatalogClient;
7386 anupam.sin 9
import in.shop2020.thrift.clients.TransactionClient;
7226 anupam.sin 10
 
11
public class OrderDetailsController  extends BaseController {
12
 
13
    /**
14
     * 
15
     */
16
    private static final long serialVersionUID = 1L;
17
    private long itemId = 9161;
18
    private long product_id = 9161;
19
    private Item item;
20
    private Double price;
21
    private Double advanceAmount;
22
    private Long deliveryDate;
23
    private String displayDate;
24
    private String dealText;
25
    private String pin;
7323 anupam.sin 26
    private String imageSource;
7226 anupam.sin 27
 
28
    public String index() {
7386 anupam.sin 29
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
30
        if(loginStatus == null || !loginStatus.equals("TRUE")){
31
            return "authfail";
32
        }
7226 anupam.sin 33
 
7386 anupam.sin 34
        storeId = Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
35
        if(!hotspotStores.containsKey(storeId)){
36
            try{
37
                HotspotStore hotSpotStore = (new TransactionClient()).getClient().getHotspotStore(storeId, "");
38
                hotspotStores.put(storeId, hotSpotStore);
39
            } catch (Exception e) {
40
                log.error("Unable to get store", e);
41
            }
42
        }
43
 
7226 anupam.sin 44
        /**
45
         * The following code should be in create method.*********************************************************************
46
         */
47
        try {
48
            CatalogClient csc = new CatalogClient();
7263 anupam.sin 49
            setItem(csc.getClient().getItem(product_id));
19706 amit.gupta 50
            if(!isOCRSession()) {
51
            	setPrice(getItem().getSellingPrice());
52
            }
53
 
7226 anupam.sin 54
       } catch (Exception e) {
55
           log.error("Unable to get item from catalog service", e);
56
       }
57
       /**
58
        * ****************END ************************************************************************************************
59
        */
60
 
61
       return INDEX;
62
    }
63
 
64
    public String create(){
65
        return index();
66
    }
67
 
68
    public String getProductName() {
69
        return item.getBrand() 
70
                + (item.getModelName() == null ? "" : " " + item.getModelName())
71
                + (item.getModelNumber() == null ? "" : " " + item.getModelNumber())
7323 anupam.sin 72
                + (item.getColor() == null || item.getColor() == "" ? "" : " (" + item.getColor() + ")");
7226 anupam.sin 73
    }
74
 
7386 anupam.sin 75
//    public String getPricingDetails() {
76
//
77
//        SimpleDateFormat sdf = new SimpleDateFormat("h:m a, d MMMM yyyy");
78
//        /**
79
//         * TODO : Ask for advance to be paid, price and DeliveryDate from catalog Service
80
//         */
81
//        
82
//        
83
//        price = 10000.0;
84
//        advanceAmount = 6000.0;
85
//        deliveryDate = 1367498907000L;
86
//        
87
//        setDisplayDate(sdf.format(new Date(deliveryDate)));
88
//        return "pricing-details";
89
//    }
7226 anupam.sin 90
 
91
    public void setItemId(long itemId) {
92
        this.itemId = itemId;
93
    }
94
    public long getItemId() {
95
        return itemId;
96
    }
97
 
98
    public void setItem(Item item) {
99
        this.item = item;
100
    }
101
 
102
    public Item getItem() {
103
        return item;
104
    }
105
 
106
    public Double getPrice() {
107
        return price;
108
    }
109
 
110
    public void setPrice(Double price) {
111
        this.price = price;
112
    }
113
 
114
    public Double getAdvanceAmount() {
115
        return advanceAmount;
116
    }
117
 
118
    public void setAdvanceAmount(Double advanceAmount) {
119
        this.advanceAmount = advanceAmount;
120
    }
121
 
122
    public Long getDeliveryDate() {
123
        return deliveryDate;
124
    }
125
 
126
    public void setDeliveryDate(Long deliveryDate) {
127
        this.deliveryDate = deliveryDate;
128
    }
129
 
130
    public void setDisplayDate(String displayDate) {
131
        this.displayDate = displayDate;
132
    }
133
 
134
    public String getDisplayDate() {
135
        return displayDate;
136
    }
137
 
138
    public void setDealText(String dealText) {
139
        this.dealText = dealText;
140
    }
141
 
142
    public String getDealText() {
143
        return dealText;
144
    }
145
 
146
    public void setPin(String pin) {
147
        this.pin = pin;
148
    }
149
 
150
    public String getPin() {
151
        return pin;
152
    }
153
 
154
    public void setProduct_id(long product_id) {
155
        this.itemId = product_id;
7323 anupam.sin 156
        this.product_id = product_id;
7226 anupam.sin 157
    }
158
 
7263 anupam.sin 159
    public long getProduct_id() {
160
        return product_id;
161
    }
162
 
7323 anupam.sin 163
    public String getImageSource() {
164
        return "/storewebsite/images/website/" + Long.toString(item.getCatalogItemId()) + "/default.jpg";
165
    }
166
 
167
    public void setImageSource(String imageSource) {
168
        this.imageSource = imageSource;
169
    }
170
 
7226 anupam.sin 171
}